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 the player
145 void teleport_to_player(int m_idx, int power)
147 int ny, nx, oy, ox, d, i, min;
151 monster_type *m_ptr = &m_list[m_idx];
155 if (!m_ptr->r_idx) return;
158 if (randint1(100) > power) return;
164 /* Save the old location */
168 /* Minimum distance */
171 /* Look until done */
172 while (look && --attempts)
174 /* Verify max distance */
175 if (dis > 200) dis = 200;
177 /* Try several locations */
178 for (i = 0; i < 500; i++)
180 /* Pick a (possibly illegal) location */
183 ny = rand_spread(py, dis);
184 nx = rand_spread(px, dis);
185 d = distance(py, px, ny, nx);
186 if ((d >= min) && (d <= dis)) break;
189 /* Ignore illegal locations */
190 if (!in_bounds(ny, nx)) continue;
192 /* Require "empty" floor space */
193 if (!cave_empty_bold(ny, nx)) continue;
195 /* Hack -- no teleport onto glyph of warding */
196 if (is_glyph_grid(&cave[ny][nx])) continue;
197 if (is_explosive_rune_grid(&cave[ny][nx])) continue;
199 /* ...nor onto the Pattern */
200 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
201 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2)) continue;
203 /* No teleporting into vaults and such */
204 /* if (cave[ny][nx].info & (CAVE_ICKY)) continue; */
206 /* This grid looks good */
213 /* Increase the maximum distance */
216 /* Decrease the minimum distance */
220 if (attempts < 1) return;
223 sound(SOUND_TPOTHER);
225 /* Update the new location */
226 cave[ny][nx].m_idx = m_idx;
228 /* Update the old location */
229 cave[oy][ox].m_idx = 0;
231 /* Move the monster */
235 /* Update the monster (new location) */
236 update_mon(m_idx, TRUE);
238 /* Redraw the old grid */
241 /* Redraw the new grid */
244 p_ptr->update |= (PU_MON_LITE);
249 * Teleport the player to a location up to "dis" grids away.
251 * If no such spaces are readily available, the distance may increase.
252 * Try very hard to move the player at least a quarter that distance.
254 * When long-range teleport effects are considered, there is a nasty
255 * tendency to "bounce" the player between two or three different spots
256 * because these are the only spots that are "far enough" way to satisfy
257 * the algorithm. Therefore, if the teleport distance is more than 50,
258 * we decrease the minimum acceptable distance to try to increase randomness.
261 void teleport_player(int dis)
263 int d, i, min, ox, oy;
274 if (p_ptr->wild_mode) return;
276 if (p_ptr->anti_tele)
279 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
281 msg_print("A mysterious force prevents you from teleporting!");
287 if (dis > 200) dis = 200; /* To be on the safe side... */
289 /* Minimum distance */
290 min = dis / (dis > 50 ? 3 : 2);
292 /* Look until done */
297 /* Verify max distance */
298 if (dis > 200) dis = 200;
300 /* Try several locations */
301 for (i = 0; i < 500; i++)
303 /* Pick a (possibly illegal) location */
306 y = rand_spread(py, dis);
307 x = rand_spread(px, dis);
308 d = distance(py, px, y, x);
309 if ((d >= min) && (d <= dis)) break;
312 /* Ignore illegal locations */
313 if (!in_bounds(y, x)) continue;
315 /* Require "naked" floor space or trees */
316 if (!(cave_naked_bold(y, x) ||
317 (cave[y][x].feat == FEAT_TREES))) continue;
319 /* No teleporting into vaults and such */
320 if (cave[y][x].info & CAVE_ICKY) continue;
322 /* This grid looks good */
329 /* Increase the maximum distance */
332 /* Decrease the minimum distance */
335 /* Stop after MAX_TRIES tries */
336 if (tries > MAX_TRIES) return;
340 sound(SOUND_TELEPORT);
343 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
344 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
347 /* Save the old location */
351 /* Move the player */
358 tmp = cave[py][px].m_idx;
359 cave[py][px].m_idx = cave[oy][ox].m_idx;
360 cave[oy][ox].m_idx = tmp;
361 m_list[p_ptr->riding].fy = py;
362 m_list[p_ptr->riding].fx = px;
363 update_mon(cave[py][px].m_idx, TRUE);
366 /* Redraw the old spot */
369 /* Monsters with teleport ability may follow the player */
370 for (xx = -1; xx < 2; xx++)
372 for (yy = -1; yy < 2; yy++)
374 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
376 /* A monster except your mount may follow */
377 if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
379 monster_type *m_ptr = &m_list[tmp_m_idx];
380 monster_race *r_ptr = &r_info[m_ptr->r_idx];
383 * The latter limitation is to avoid
384 * totally unkillable suckers...
386 if ((r_ptr->flags6 & RF6_TPORT) &&
387 !(r_ptr->flagsr & RFR_RES_TELE))
389 if (!m_ptr->csleep) teleport_to_player(tmp_m_idx, r_ptr->level);
397 /* Redraw the new spot */
400 /* Check for new panel (redraw map) */
404 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
406 /* Update the monsters */
407 p_ptr->update |= (PU_DISTANCE);
410 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
412 /* Handle stuff XXX XXX XXX */
419 * Teleport player to a grid near the given location
421 * This function is slightly obsessive about correctness.
422 * This function allows teleporting into vaults (!)
424 void teleport_player_to(int ny, int nx, bool no_tele)
426 int y, x, oy, ox, dis = 0, ctr = 0;
428 if (p_ptr->anti_tele && no_tele)
431 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
433 msg_print("A mysterious force prevents you from teleporting!");
439 /* Find a usable location */
442 /* Pick a nearby legal location */
445 y = rand_spread(ny, dis);
446 x = rand_spread(nx, dis);
447 if (in_bounds(y, x)) break;
450 /* Accept "naked" floor grids */
453 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;
455 else if (cave_empty_bold(y, x) || player_bold(y, x)) break;
457 /* Occasionally advance the distance */
458 if (++ctr > (4 * dis * dis + 4 * dis + 1))
466 sound(SOUND_TELEPORT);
468 /* Save the old location */
472 /* Move the player */
479 tmp = cave[py][px].m_idx;
480 cave[py][px].m_idx = cave[oy][ox].m_idx;
481 cave[oy][ox].m_idx = tmp;
482 m_list[p_ptr->riding].fy = py;
483 m_list[p_ptr->riding].fx = px;
484 update_mon(cave[py][px].m_idx, TRUE);
489 /* Redraw the old spot */
492 /* Redraw the new spot */
495 /* Check for new panel (redraw map) */
499 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
501 /* Update the monsters */
502 p_ptr->update |= (PU_DISTANCE);
505 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
507 /* Handle stuff XXX XXX XXX */
514 * Teleport the player one level up or down (random when legal)
516 void teleport_player_level(void)
520 /* No effect in arena or quest */
521 if (p_ptr->inside_arena || (p_ptr->inside_quest && !random_quest_number(dun_level)) ||
522 ((quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth)) && (dun_level > 1) && ironman_downward))
525 msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
527 msg_print("There is no effect.");
533 if (p_ptr->anti_tele)
536 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
538 msg_print("A mysterious force prevents you from teleporting!");
544 /* Choose up or down */
545 if (randint0(100) < 50) go_up = TRUE;
550 if (get_check("Force to go up? ")) go_up = TRUE;
551 else if (get_check("Force to go down? ")) go_up = FALSE;
555 if (ironman_downward || (dun_level <= d_info[dungeon_type].mindepth))
558 msg_print("¤¢¤Ê¤¿¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£");
560 msg_print("You sink through the floor.");
564 dungeon_type = p_ptr->recall_dungeon;
569 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
571 if (autosave_l) do_cmd_save_game(TRUE);
575 dun_level = d_info[dungeon_type].mindepth;
576 prepare_change_floor_mode(CFM_RAND_PLACE | CFM_CLEAR_ALL);
580 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
584 p_ptr->leaving = TRUE;
588 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
591 msg_print("¤¢¤Ê¤¿¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£");
593 msg_print("You rise up through the ceiling.");
597 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
599 if (autosave_l) do_cmd_save_game(TRUE);
601 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
606 p_ptr->inside_quest = 0;
607 p_ptr->leaving = TRUE;
612 msg_print("¤¢¤Ê¤¿¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£");
614 msg_print("You rise up through the ceiling.");
618 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
620 if (autosave_l) do_cmd_save_game(TRUE);
622 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
625 p_ptr->leaving = TRUE;
630 msg_print("¤¢¤Ê¤¿¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£");
632 msg_print("You sink through the floor.");
635 /* Never reach this code on the surface */
636 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
638 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
640 if (autosave_l) do_cmd_save_game(TRUE);
642 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
645 p_ptr->leaving = TRUE;
649 sound(SOUND_TPLEVEL);
654 static int choose_dungeon(cptr note)
660 /* Allocate the "dun" array */
661 C_MAKE(dun, max_d_idx, s16b);
664 for(i = 1; i < max_d_idx; i++)
669 if (!d_info[i].maxdepth) continue;
670 if (!max_dlv[i]) continue;
671 if (d_info[i].final_guardian)
673 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
675 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
678 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
680 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
686 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
688 prt(format("Which dungeon do you %s?: ", note), 0, 0);
695 /* Free the "dun" array */
696 C_KILL(dun, max_d_idx, s16b);
701 if (i >= 'a' && i <('a'+num))
703 select_dungeon = dun[i-'a'];
710 /* Free the "dun" array */
711 C_KILL(dun, max_d_idx, s16b);
713 return select_dungeon;
718 * Recall the player to town or dungeon
720 bool recall_player(int turns)
723 * TODO: Recall the player to the last
724 * visited town when in the wilderness
728 if (p_ptr->inside_arena || ironman_downward)
731 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
733 msg_print("Nothing happens.");
739 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
742 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
744 if (get_check("Reset recall depth? "))
747 max_dlv[dungeon_type] = dun_level;
748 if (record_maxdeapth)
750 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
752 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
757 if (!p_ptr->word_recall)
763 select_dungeon = choose_dungeon("¤Ëµ¢´Ô");
765 select_dungeon = choose_dungeon("recall");
767 if (!select_dungeon) return FALSE;
768 p_ptr->recall_dungeon = select_dungeon;
770 p_ptr->word_recall = turns;
772 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
774 msg_print("The air about you becomes charged...");
777 p_ptr->redraw |= (PR_STATUS);
781 p_ptr->word_recall = 0;
783 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
785 msg_print("A tension leaves the air around you...");
788 p_ptr->redraw |= (PR_STATUS);
794 bool word_of_recall(void)
796 return(recall_player(randint0(21) + 15));
800 bool reset_recall(void)
802 int select_dungeon, dummy = 0;
807 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È");
809 select_dungeon = choose_dungeon("reset");
813 if (ironman_downward)
816 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
818 msg_print("Nothing happens.");
824 if (!select_dungeon) return FALSE;
827 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
829 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
834 sprintf(tmp_val, "%d", MAX(dun_level, 1));
836 /* Ask for a level */
837 if (get_string(ppp, tmp_val, 10))
839 /* Extract request */
840 dummy = atoi(tmp_val);
843 if (dummy < 1) dummy = 1;
846 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
847 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
849 max_dlv[select_dungeon] = dummy;
851 if (record_maxdeapth)
853 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
855 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
859 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
861 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
874 * Apply disenchantment to the player's stuff
876 * XXX XXX XXX This function is also called from the "melee" code
878 * Return "TRUE" if the player notices anything
880 bool apply_disenchant(int mode)
884 char o_name[MAX_NLEN];
885 int to_h, to_d, to_a, pval;
887 /* Pick a random slot */
890 case 1: t = INVEN_RARM; break;
891 case 2: t = INVEN_LARM; break;
892 case 3: t = INVEN_BOW; break;
893 case 4: t = INVEN_BODY; break;
894 case 5: t = INVEN_OUTER; break;
895 case 6: t = INVEN_HEAD; break;
896 case 7: t = INVEN_HANDS; break;
897 case 8: t = INVEN_FEET; break;
901 o_ptr = &inventory[t];
903 /* No item, nothing happens */
904 if (!o_ptr->k_idx) return (FALSE);
907 /* Nothing to disenchant */
908 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
910 /* Nothing to notice */
915 /* Describe the object */
916 object_desc(o_name, o_ptr, FALSE, 0);
919 /* Artifacts have 71% chance to resist */
920 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 71))
924 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
926 msg_format("Your %s (%c) resist%s disenchantment!",
927 o_name, index_to_label(t),
928 ((o_ptr->number != 1) ? "" : "s"));
937 /* Memorize old value */
943 /* Disenchant tohit */
944 if (o_ptr->to_h > 0) o_ptr->to_h--;
945 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
947 /* Disenchant todam */
948 if (o_ptr->to_d > 0) o_ptr->to_d--;
949 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
951 /* Disenchant toac */
952 if (o_ptr->to_a > 0) o_ptr->to_a--;
953 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
955 /* Disenchant pval (occasionally) */
956 /* Unless called from wild_magic() */
957 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
959 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
960 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
964 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
965 o_name, index_to_label(t) );
967 msg_format("Your %s (%c) %s disenchanted!",
968 o_name, index_to_label(t),
969 ((o_ptr->number != 1) ? "were" : "was"));
972 chg_virtue(V_HARMONY, 1);
973 chg_virtue(V_ENCHANT, -2);
975 /* Recalculate bonuses */
976 p_ptr->update |= (PU_BONUS);
979 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
989 void mutate_player(void)
991 int max1, cur1, max2, cur2, ii, jj, i;
993 /* Pick a pair of stats */
995 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
997 max1 = p_ptr->stat_max[ii];
998 cur1 = p_ptr->stat_cur[ii];
999 max2 = p_ptr->stat_max[jj];
1000 cur2 = p_ptr->stat_cur[jj];
1002 p_ptr->stat_max[ii] = max2;
1003 p_ptr->stat_cur[ii] = cur2;
1004 p_ptr->stat_max[jj] = max1;
1005 p_ptr->stat_cur[jj] = cur1;
1009 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1010 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1013 p_ptr->update |= (PU_BONUS);
1020 void apply_nexus(monster_type *m_ptr)
1022 switch (randint1(7))
1024 case 1: case 2: case 3:
1026 teleport_player(200);
1032 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE);
1038 if (randint0(100) < p_ptr->skill_sav)
1041 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1043 msg_print("You resist the effects!");
1049 /* Teleport Level */
1050 teleport_player_level();
1056 if (randint0(100) < p_ptr->skill_sav)
1059 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1061 msg_print("You resist the effects!");
1068 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1070 msg_print("Your body starts to scramble...");
1081 * Charge a lite (torch or latern)
1083 void phlogiston(void)
1086 object_type * o_ptr = &inventory[INVEN_LITE];
1089 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1091 max_flog = FUEL_LAMP;
1095 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1097 max_flog = FUEL_TORCH;
1100 /* No torch to refill */
1104 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1106 msg_print("You are not wielding anything which uses phlogiston.");
1112 if (o_ptr->xtra4 >= max_flog)
1115 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1117 msg_print("No more phlogiston can be put in this item.");
1124 o_ptr->xtra4 += (max_flog / 2);
1128 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1130 msg_print("You add phlogiston to your light item.");
1135 if (o_ptr->xtra4 >= max_flog)
1137 o_ptr->xtra4 = max_flog;
1139 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1141 msg_print("Your light item is full.");
1146 /* Recalculate torch */
1147 p_ptr->update |= (PU_TORCH);
1151 static bool item_tester_hook_weapon_nobow(object_type *o_ptr)
1153 switch (o_ptr->tval)
1163 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
1171 * Brand the current weapon
1173 void brand_weapon(int brand_type)
1180 /* Assume enchant weapon */
1181 item_tester_hook = item_tester_hook_weapon_nobow;
1182 item_tester_no_ryoute = TRUE;
1186 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1187 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1189 q = "Enchant which weapon? ";
1190 s = "You have nothing to enchant.";
1193 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1195 /* Get the item (in the pack) */
1198 o_ptr = &inventory[item];
1201 /* Get the item (on the floor) */
1204 o_ptr = &o_list[0 - item];
1208 /* you can never modify artifacts / ego-items */
1209 /* you can never modify cursed items */
1210 /* TY: You _can_ modify broken items (if you're silly enough) */
1211 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
1212 !o_ptr->art_name && !cursed_p(o_ptr) &&
1213 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1214 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1215 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1219 /* Let's get the name before it is changed... */
1220 char o_name[MAX_NLEN];
1221 object_desc(o_name, o_ptr, FALSE, 0);
1226 if (o_ptr->tval == TV_SWORD)
1229 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1231 act = "becomes very sharp!";
1234 o_ptr->name2 = EGO_SHARPNESS;
1235 o_ptr->pval = m_bonus(5, dun_level) + 1;
1240 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1242 act = "seems very powerful.";
1245 o_ptr->name2 = EGO_EARTHQUAKES;
1246 o_ptr->pval = m_bonus(3, dun_level);
1251 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1253 act = "seems to be looking for humans!";
1256 o_ptr->name2 = EGO_SLAY_HUMAN;
1260 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1262 act = "covered with lightning!";
1265 o_ptr->name2 = EGO_BRAND_ELEC;
1269 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1271 act = "coated with acid!";
1274 o_ptr->name2 = EGO_BRAND_ACID;
1278 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1280 act = "seems to be looking for evil monsters!";
1283 o_ptr->name2 = EGO_SLAY_EVIL;
1287 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1289 act = "seems to be looking for demons!";
1292 o_ptr->name2 = EGO_SLAY_DEMON;
1296 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1298 act = "seems to be looking for undead!";
1301 o_ptr->name2 = EGO_SLAY_UNDEAD;
1305 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1307 act = "seems to be looking for animals!";
1310 o_ptr->name2 = EGO_SLAY_ANIMAL;
1314 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1316 act = "seems to be looking for dragons!";
1319 o_ptr->name2 = EGO_SLAY_DRAGON;
1323 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1325 act = "seems to be looking for troll!s";
1328 o_ptr->name2 = EGO_SLAY_TROLL;
1332 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1334 act = "seems to be looking for orcs!";
1337 o_ptr->name2 = EGO_SLAY_ORC;
1341 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1343 act = "seems to be looking for giants!";
1346 o_ptr->name2 = EGO_SLAY_GIANT;
1350 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1352 act = "seems very unstable now.";
1355 o_ptr->name2 = EGO_TRUMP;
1356 o_ptr->pval = randint1(2);
1360 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1362 act = "thirsts for blood!";
1365 o_ptr->name2 = EGO_VAMPIRIC;
1369 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1371 act = "is coated with poison.";
1374 o_ptr->name2 = EGO_BRAND_POIS;
1378 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1380 act = "is engulfed in raw Logrus!";
1383 o_ptr->name2 = EGO_CHAOTIC;
1387 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1389 act = "is covered in a fiery shield!";
1392 o_ptr->name2 = EGO_BRAND_FIRE;
1396 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1398 act = "glows deep, icy blue!";
1401 o_ptr->name2 = EGO_BRAND_COLD;
1406 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1408 msg_format("Your %s %s", o_name, act);
1412 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1414 o_ptr->discount = 99;
1415 chg_virtue(V_ENCHANT, 2);
1419 if (flush_failure) flush();
1422 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1424 msg_print("The Branding failed.");
1427 chg_virtue(V_ENCHANT, -2);
1434 * Determine if a "feature" is a "vanishable"
1435 * Non-permanent walls, trees, mountains, or doors
1437 #define vanishable_feat(F) \
1438 ((!feat_floor(F) && (((F) < FEAT_PERM_EXTRA) || ((F) > FEAT_PERM_SOLID))) || \
1439 ((F) == FEAT_OPEN) || ((F) == FEAT_BROKEN))
1442 * Vanish all walls in this floor
1444 static bool vanish_dungeon(void)
1448 monster_type *m_ptr;
1452 /* Prevent vasishing of quest levels and town */
1453 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1458 /* Scan all normal grids */
1459 for (y = 1; y < cur_hgt - 1; y++)
1461 for (x = 1; x < cur_wid - 1; x++)
1463 c_ptr = &cave[y][x];
1465 /* Seeing true feature code (ignore mimic) */
1468 /* Lose room and vault */
1469 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1474 m_ptr = &m_list[c_ptr->m_idx];
1476 /* Reset sleep counter */
1479 /* Notice the "waking up" */
1482 /* Acquire the monster name */
1483 monster_desc(m_name, m_ptr, 0);
1485 /* Dump a message */
1487 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1489 msg_format("%^s wakes up.", m_name);
1492 /* Redraw the health bar */
1493 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
1494 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
1498 /* Process all walls, doors and patterns */
1499 if (vanishable_feat(feat) || pattern_tile(y, x))
1502 cave_set_feat(y, x, floor_type[randint0(100)]);
1507 /* Special boundary walls -- Top and bottom */
1508 for (x = 0; x < cur_wid; x++)
1510 c_ptr = &cave[0][x];
1512 /* Lose room and vault */
1513 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1515 /* Set boundary mimic if needed */
1516 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1518 c_ptr = &cave[cur_hgt - 1][x];
1520 /* Lose room and vault */
1521 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1523 /* Set boundary mimic if needed */
1524 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1527 /* Special boundary walls -- Left and right */
1528 for (y = 1; y < (cur_hgt - 1); y++)
1530 c_ptr = &cave[y][0];
1532 /* Lose room and vault */
1533 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1535 /* Set boundary mimic if needed */
1536 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1538 c_ptr = &cave[y][cur_wid - 1];
1540 /* Lose room and vault */
1541 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1543 /* Set boundary mimic if needed */
1544 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1547 /* Mega-Hack -- Forget the view and lite */
1548 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1551 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1553 /* Update the monsters */
1554 p_ptr->update |= (PU_MONSTERS);
1557 p_ptr->redraw |= (PR_MAP);
1560 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1566 void call_the_(void)
1570 bool do_call = TRUE;
1572 for (i = 0; i < 9; i++)
1574 y = py + ddy_ddd[i];
1575 x = px + ddx_ddd[i];
1577 if (!cave_floor_bold(y, x) && !boundary_floor_bold(y, x))
1586 for (i = 1; i < 10; i++)
1588 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1591 for (i = 1; i < 10; i++)
1593 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1596 for (i = 1; i < 10; i++)
1598 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1602 /* Prevent destruction of quest levels and town */
1603 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1606 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1608 msg_print("The ground trembles.");
1615 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1616 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1617 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1619 msg_format("You %s the %s too close to a wall!",
1620 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1621 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1622 msg_print("There is a loud explosion!");
1628 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1630 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1635 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1637 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1639 msg_print("The dungeon collapses...");
1644 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1646 msg_print("The dungeon trembles.");
1651 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1653 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1660 * Fetch an item (teleport it right underneath the caster)
1662 void fetch(int dir, int wgt, bool require_los)
1667 char o_name[MAX_NLEN];
1669 /* Check to see if an object is already there */
1670 if (cave[py][px].o_idx)
1673 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1675 msg_print("You can't fetch when you're already standing on something.");
1682 if (dir == 5 && target_okay())
1687 if (distance(py, px, ty, tx) > MAX_RANGE)
1690 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1692 msg_print("You can't fetch something that far away!");
1698 c_ptr = &cave[ty][tx];
1700 /* We need an item to fetch */
1704 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1706 msg_print("There is no object at this place.");
1712 /* No fetching from vault */
1713 if (c_ptr->info & CAVE_ICKY)
1716 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1718 msg_print("The item slips from your control.");
1724 /* We need to see the item */
1725 if (require_los && !player_has_los_bold(ty, tx))
1728 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1730 msg_print("You have no direct line of sight to that location.");
1738 /* Use a direction */
1739 ty = py; /* Where to drop the item */
1746 c_ptr = &cave[ty][tx];
1748 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1749 !cave_floor_bold(ty, tx)) return;
1751 while (!c_ptr->o_idx);
1754 o_ptr = &o_list[c_ptr->o_idx];
1756 if (o_ptr->weight > wgt)
1758 /* Too heavy to 'fetch' */
1760 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1762 msg_print("The object is too heavy.");
1769 c_ptr->o_idx = o_ptr->next_o_idx;
1770 cave[py][px].o_idx = i; /* 'move' it */
1771 o_ptr->next_o_idx = 0;
1772 o_ptr->iy = (byte)py;
1773 o_ptr->ix = (byte)px;
1775 object_desc(o_name, o_ptr, TRUE, 0);
1777 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1779 msg_format("%^s flies through the air to your feet.", o_name);
1784 p_ptr->redraw |= PR_MAP;
1788 void alter_reality(void)
1790 /* Ironman option */
1791 if (p_ptr->inside_arena || ironman_downward)
1794 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1796 msg_print("Nothing happens.");
1801 if (!p_ptr->alter_reality)
1803 int turns = randint0(21) + 15;
1805 p_ptr->alter_reality = turns;
1807 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1809 msg_print("The view around you begins to change...");
1812 p_ptr->redraw |= (PR_STATUS);
1816 p_ptr->alter_reality = 0;
1818 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1820 msg_print("The view around you got back...");
1823 p_ptr->redraw |= (PR_STATUS);
1830 * Leave a "glyph of warding" which prevents monster movement
1832 bool warding_glyph(void)
1835 if (!cave_clean_bold(py, px))
1838 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1840 msg_print("The object resists the spell.");
1846 /* Create a glyph */
1847 cave[py][px].info |= CAVE_OBJECT;
1848 cave[py][px].mimic = FEAT_GLYPH;
1859 bool warding_mirror(void)
1862 if (!cave_clean_bold(py, px))
1865 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1867 msg_print("The object resists the spell.");
1873 /* Create a mirror */
1874 cave[py][px].info |= CAVE_OBJECT;
1875 cave[py][px].mimic = FEAT_MIRROR;
1877 /* Turn on the light */
1878 cave[py][px].info |= CAVE_GLOW;
1891 * Leave an "explosive rune" which prevents monster movement
1893 bool explosive_rune(void)
1896 if (!cave_clean_bold(py, px))
1899 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1901 msg_print("The object resists the spell.");
1907 /* Create a glyph */
1908 cave[py][px].info |= CAVE_OBJECT;
1909 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1922 * Identify everything being carried.
1923 * Done by a potion of "self knowledge".
1925 void identify_pack(void)
1929 /* Simply identify and know every item */
1930 for (i = 0; i < INVEN_TOTAL; i++)
1932 object_type *o_ptr = &inventory[i];
1934 /* Skip non-objects */
1935 if (!o_ptr->k_idx) continue;
1938 identify_item(o_ptr);
1944 * Used by the "enchant" function (chance of failure)
1945 * (modified for Zangband, we need better stuff there...) -- TY
1947 static int enchant_table[16] =
1949 0, 10, 50, 100, 200,
1950 300, 400, 500, 650, 800,
1951 950, 987, 993, 995, 998,
1957 * Removes curses from items in inventory
1959 * Note that Items which are "Perma-Cursed" (The One Ring,
1960 * The Crown of Morgoth) can NEVER be uncursed.
1962 * Note that if "all" is FALSE, then Items which are
1963 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1964 * will not be uncursed.
1966 static int remove_curse_aux(int all)
1970 /* Attempt to uncurse items being worn */
1971 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1973 object_type *o_ptr = &inventory[i];
1975 /* Skip non-objects */
1976 if (!o_ptr->k_idx) continue;
1978 /* Uncursed already */
1979 if (!cursed_p(o_ptr)) continue;
1981 /* Heavily Cursed Items need a special spell */
1982 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1984 /* Perma-Cursed Items can NEVER be uncursed */
1985 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1988 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1993 o_ptr->curse_flags = 0L;
1995 /* Hack -- Assume felt */
1996 o_ptr->ident |= (IDENT_SENSE);
1999 o_ptr->feeling = FEEL_NONE;
2001 /* Recalculate the bonuses */
2002 p_ptr->update |= (PU_BONUS);
2005 p_ptr->window |= (PW_EQUIP);
2007 /* Count the uncursings */
2011 /* Return "something uncursed" */
2017 * Remove most curses
2019 bool remove_curse(void)
2021 return (remove_curse_aux(FALSE));
2027 bool remove_all_curse(void)
2029 return (remove_curse_aux(TRUE));
2034 * Turns an object into gold, gain some of its value in a shop
2043 char o_name[MAX_NLEN];
2044 char out_val[MAX_NLEN+40];
2048 /* Hack -- force destruction */
2049 if (command_arg > 0) force = TRUE;
2053 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2054 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2056 q = "Turn which item to gold? ";
2057 s = "You have nothing to turn to gold.";
2060 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2062 /* Get the item (in the pack) */
2065 o_ptr = &inventory[item];
2068 /* Get the item (on the floor) */
2071 o_ptr = &o_list[0 - item];
2075 /* See how many items */
2076 if (o_ptr->number > 1)
2078 /* Get a quantity */
2079 amt = get_quantity(NULL, o_ptr->number);
2081 /* Allow user abort */
2082 if (amt <= 0) return FALSE;
2086 /* Describe the object */
2087 old_number = o_ptr->number;
2088 o_ptr->number = amt;
2089 object_desc(o_name, o_ptr, TRUE, 3);
2090 o_ptr->number = old_number;
2092 /* Verify unless quantity given */
2095 if (confirm_destroy || (object_value(o_ptr) > 0))
2097 /* Make a verification */
2099 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2101 sprintf(out_val, "Really turn %s to gold? ", o_name);
2104 if (!get_check(out_val)) return FALSE;
2108 /* Artifacts cannot be destroyed */
2109 if (!can_player_destroy_object(o_ptr))
2113 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2115 msg_format("You fail to turn %s to gold!", o_name);
2122 price = object_value_real(o_ptr);
2128 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2130 msg_format("You turn %s to fool's gold.", o_name);
2138 if (amt > 1) price *= amt;
2140 if (price > 30000) price = 30000;
2142 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2144 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2150 p_ptr->redraw |= (PR_GOLD);
2153 p_ptr->window |= (PW_PLAYER);
2157 /* Eliminate the item (from the pack) */
2160 inven_item_increase(item, -amt);
2161 inven_item_describe(item);
2162 inven_item_optimize(item);
2165 /* Eliminate the item (from the floor) */
2168 floor_item_increase(0 - item, -amt);
2169 floor_item_describe(0 - item);
2170 floor_item_optimize(0 - item);
2179 * Hook to specify "weapon"
2181 bool item_tester_hook_weapon(object_type *o_ptr)
2183 switch (o_ptr->tval)
2197 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2204 static bool item_tester_hook_weapon2(object_type *o_ptr)
2206 switch (o_ptr->tval)
2226 * Hook to specify "armour"
2228 bool item_tester_hook_armour(object_type *o_ptr)
2230 switch (o_ptr->tval)
2251 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2253 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2255 switch (o_ptr->tval)
2284 * Check if an object is nameless weapon or armour
2286 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2288 switch (o_ptr->tval)
2307 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2309 if (object_known_p(o_ptr)) return FALSE;
2319 * Break the curse of an item
2321 static void break_curse(object_type *o_ptr)
2323 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2326 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2328 msg_print("The curse is broken!");
2331 o_ptr->curse_flags = 0L;
2333 o_ptr->ident |= (IDENT_SENSE);
2335 o_ptr->feeling = FEEL_NONE;
2341 * Enchants a plus onto an item. -RAK-
2343 * Revamped! Now takes item pointer, number of times to try enchanting,
2344 * and a flag of what to try enchanting. Artifacts resist enchantment
2345 * some of the time, and successful enchantment to at least +0 might
2346 * break a curse on the item. -CFT-
2348 * Note that an item can technically be enchanted all the way to +15 if
2349 * you wait a very, very, long time. Going from +9 to +10 only works
2350 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2352 * Note that this function can now be used on "piles" of items, and
2353 * the larger the pile, the lower the chance of success.
2355 bool enchant(object_type *o_ptr, int n, int eflag)
2357 int i, chance, prob;
2359 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2360 bool force = (eflag & ENCH_FORCE);
2363 /* Large piles resist enchantment */
2364 prob = o_ptr->number * 100;
2366 /* Missiles are easy to enchant */
2367 if ((o_ptr->tval == TV_BOLT) ||
2368 (o_ptr->tval == TV_ARROW) ||
2369 (o_ptr->tval == TV_SHOT))
2375 for (i = 0; i < n; i++)
2377 /* Hack -- Roll for pile resistance */
2378 if (!force && randint0(prob) >= 100) continue;
2380 /* Enchant to hit */
2381 if (eflag & ENCH_TOHIT)
2383 if (o_ptr->to_h < 0) chance = 0;
2384 else if (o_ptr->to_h > 15) chance = 1000;
2385 else chance = enchant_table[o_ptr->to_h];
2387 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2392 /* only when you get it above -1 -CFT */
2393 if (o_ptr->to_h >= 0)
2398 /* Enchant to damage */
2399 if (eflag & ENCH_TODAM)
2401 if (o_ptr->to_d < 0) chance = 0;
2402 else if (o_ptr->to_d > 15) chance = 1000;
2403 else chance = enchant_table[o_ptr->to_d];
2405 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2410 /* only when you get it above -1 -CFT */
2411 if (o_ptr->to_d >= 0)
2416 /* Enchant to armor class */
2417 if (eflag & ENCH_TOAC)
2419 if (o_ptr->to_a < 0) chance = 0;
2420 else if (o_ptr->to_a > 15) chance = 1000;
2421 else chance = enchant_table[o_ptr->to_a];
2423 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2428 /* only when you get it above -1 -CFT */
2429 if (o_ptr->to_a >= 0)
2436 if (!res) return (FALSE);
2438 /* Recalculate bonuses */
2439 p_ptr->update |= (PU_BONUS);
2441 /* Combine / Reorder the pack (later) */
2442 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2445 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2456 * Enchant an item (in the inventory or on the floor)
2457 * Note that "num_ac" requires armour, else weapon
2458 * Returns TRUE if attempted, FALSE if cancelled
2460 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2465 char o_name[MAX_NLEN];
2469 /* Assume enchant weapon */
2470 item_tester_hook = item_tester_hook_weapon;
2471 item_tester_no_ryoute = TRUE;
2473 /* Enchant armor if requested */
2474 if (num_ac) item_tester_hook = item_tester_hook_armour;
2478 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2479 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2481 q = "Enchant which item? ";
2482 s = "You have nothing to enchant.";
2485 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2487 /* Get the item (in the pack) */
2490 o_ptr = &inventory[item];
2493 /* Get the item (on the floor) */
2496 o_ptr = &o_list[0 - item];
2501 object_desc(o_name, o_ptr, FALSE, 0);
2505 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2508 msg_format("%s %s glow%s brightly!",
2509 ((item >= 0) ? "Your" : "The"), o_name,
2510 ((o_ptr->number > 1) ? "" : "s"));
2515 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2516 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2517 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2523 if (flush_failure) flush();
2527 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2529 msg_print("The enchantment failed.");
2532 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2535 chg_virtue(V_ENCHANT, 1);
2539 /* Something happened */
2544 bool artifact_scroll(void)
2549 char o_name[MAX_NLEN];
2553 item_tester_no_ryoute = TRUE;
2554 /* Enchant weapon/armour */
2555 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2559 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2560 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2562 q = "Enchant which item? ";
2563 s = "You have nothing to enchant.";
2566 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2568 /* Get the item (in the pack) */
2571 o_ptr = &inventory[item];
2574 /* Get the item (on the floor) */
2577 o_ptr = &o_list[0 - item];
2582 object_desc(o_name, o_ptr, FALSE, 0);
2586 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2588 msg_format("%s %s radiate%s a blinding light!",
2589 ((item >= 0) ? "Your" : "The"), o_name,
2590 ((o_ptr->number > 1) ? "" : "s"));
2593 if (o_ptr->name1 || o_ptr->art_name)
2596 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2598 msg_format("The %s %s already %s!",
2599 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2600 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2606 else if (o_ptr->name2)
2609 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2611 msg_format("The %s %s already %s!",
2612 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2613 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2619 else if (o_ptr->xtra3)
2622 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2624 msg_format("The %s %s already %s!",
2625 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2626 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2632 if (o_ptr->number > 1)
2635 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2636 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2638 msg_print("Not enough enough energy to enchant more than one object!");
2639 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2644 inven_item_increase(item, 1-(o_ptr->number));
2648 floor_item_increase(0-item, 1-(o_ptr->number));
2651 okay = create_artifact(o_ptr, TRUE);
2658 if (flush_failure) flush();
2662 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2664 msg_print("The enchantment failed.");
2667 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2670 chg_virtue(V_ENCHANT, 1);
2674 /* Something happened */
2680 * Identify an object
2682 bool identify_item(object_type *o_ptr)
2684 bool old_known = FALSE;
2685 char o_name[MAX_NLEN];
2688 object_desc(o_name, o_ptr, TRUE, 3);
2690 if (o_ptr->ident & IDENT_KNOWN)
2693 if (!(o_ptr->ident & (IDENT_MENTAL)))
2695 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2696 chg_virtue(V_KNOWLEDGE, 1);
2699 /* Identify it fully */
2700 object_aware(o_ptr);
2701 object_known(o_ptr);
2703 /* Recalculate bonuses */
2704 p_ptr->update |= (PU_BONUS);
2706 /* Combine / Reorder the pack (later) */
2707 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2710 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2712 strcpy(record_o_name, o_name);
2716 object_desc(o_name, o_ptr, TRUE, 0);
2718 if(record_fix_art && !old_known && artifact_p(o_ptr))
2719 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2720 if(record_rand_art && !old_known && o_ptr->art_name)
2721 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2727 static bool item_tester_hook_identify(object_type *o_ptr)
2729 return (bool)!object_known_p(o_ptr);
2732 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2734 if (object_known_p(o_ptr))
2736 return item_tester_hook_weapon_armour(o_ptr);
2740 * Identify an object in the inventory (or on the floor)
2741 * This routine does *not* automatically combine objects.
2742 * Returns TRUE if something was identified, else FALSE.
2744 bool ident_spell(bool only_equip)
2748 char o_name[MAX_NLEN];
2753 item_tester_no_ryoute = TRUE;
2756 item_tester_hook = item_tester_hook_identify_weapon_armour;
2758 item_tester_hook = item_tester_hook_identify;
2760 if (!can_get_item())
2764 item_tester_hook = item_tester_hook_weapon_armour;
2768 item_tester_hook = NULL;
2774 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2775 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2777 q = "Identify which item? ";
2778 s = "You have nothing to identify.";
2781 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2783 /* Get the item (in the pack) */
2786 o_ptr = &inventory[item];
2789 /* Get the item (on the floor) */
2792 o_ptr = &o_list[0 - item];
2796 old_known = identify_item(o_ptr);
2799 object_desc(o_name, o_ptr, TRUE, 3);
2802 if (item >= INVEN_RARM)
2805 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2807 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2813 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2815 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2821 msg_format("¾²¾å: %s¡£", o_name);
2823 msg_format("On the ground: %s.", o_name);
2827 /* Auto-inscription/destroy */
2828 idx = is_autopick(o_ptr);
2829 auto_inscribe_item(item, idx);
2830 if (destroy_identify && !old_known)
2831 auto_destroy_item(item, idx);
2833 /* Something happened */
2839 * Mundanify an object in the inventory (or on the floor)
2840 * This routine does *not* automatically combine objects.
2841 * Returns TRUE if something was mundanified, else FALSE.
2843 bool mundane_spell(bool only_equip)
2849 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
2850 item_tester_no_ryoute = TRUE;
2854 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2855 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2857 q = "Use which item? ";
2858 s = "You have nothing you can use.";
2861 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2863 /* Get the item (in the pack) */
2866 o_ptr = &inventory[item];
2869 /* Get the item (on the floor) */
2872 o_ptr = &o_list[0 - item];
2877 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2879 msg_print("There is a bright flash of light!");
2882 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2883 byte ix = o_ptr->ix; /* X-position on map, or zero */
2884 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2885 byte marked = o_ptr->marked; /* Object is marked */
2886 s16b weight = o_ptr->number * o_ptr->weight;
2887 u16b inscription = o_ptr->inscription;
2890 object_prep(o_ptr, o_ptr->k_idx);
2894 o_ptr->next_o_idx = next_o_idx;
2895 o_ptr->marked = marked;
2896 o_ptr->inscription = inscription;
2897 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2901 /* Something happened */
2907 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2909 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2912 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2914 if (!item_tester_hook_identify_fully(o_ptr))
2916 return item_tester_hook_weapon_armour(o_ptr);
2920 * Fully "identify" an object in the inventory -BEN-
2921 * This routine returns TRUE if an item was identified.
2923 bool identify_fully(bool only_equip)
2927 char o_name[MAX_NLEN];
2932 item_tester_no_ryoute = TRUE;
2934 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2936 item_tester_hook = item_tester_hook_identify_fully;
2938 if (!can_get_item())
2941 item_tester_hook = item_tester_hook_weapon_armour;
2943 item_tester_hook = NULL;
2948 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2949 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2951 q = "Identify which item? ";
2952 s = "You have nothing to identify.";
2955 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2957 /* Get the item (in the pack) */
2960 o_ptr = &inventory[item];
2963 /* Get the item (on the floor) */
2966 o_ptr = &o_list[0 - item];
2970 old_known = identify_item(o_ptr);
2972 /* Mark the item as fully known */
2973 o_ptr->ident |= (IDENT_MENTAL);
2979 object_desc(o_name, o_ptr, TRUE, 3);
2982 if (item >= INVEN_RARM)
2985 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2987 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2995 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2997 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3003 msg_format("¾²¾å: %s¡£", o_name);
3005 msg_format("On the ground: %s.", o_name);
3009 /* Describe it fully */
3010 (void)screen_object(o_ptr, TRUE);
3012 /* Auto-inscription/destroy */
3013 idx = is_autopick(o_ptr);
3014 auto_inscribe_item(item, idx);
3015 if (destroy_identify && !old_known)
3016 auto_destroy_item(item, idx);
3026 * Hook for "get_item()". Determine if something is rechargable.
3028 bool item_tester_hook_recharge(object_type *o_ptr)
3030 /* Recharge staffs */
3031 if (o_ptr->tval == TV_STAFF) return (TRUE);
3033 /* Recharge wands */
3034 if (o_ptr->tval == TV_WAND) return (TRUE);
3036 /* Hack -- Recharge rods */
3037 if (o_ptr->tval == TV_ROD) return (TRUE);
3045 * Recharge a wand/staff/rod from the pack or on the floor.
3046 * This function has been rewritten in Oangband and ZAngband.
3048 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3049 * Chaos -- Arcane Binding --> recharge(90)
3051 * Scroll of recharging --> recharge(130)
3052 * Artifact activation/Thingol --> recharge(130)
3054 * It is harder to recharge high level, and highly charged wands,
3055 * staffs, and rods. The more wands in a stack, the more easily and
3056 * strongly they recharge. Staffs, however, each get fewer charges if
3059 * XXX XXX XXX Beware of "sliding index errors".
3061 bool recharge(int power)
3064 int recharge_strength, recharge_amount;
3073 char o_name[MAX_NLEN];
3075 /* Only accept legal items */
3076 item_tester_hook = item_tester_hook_recharge;
3080 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3081 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3083 q = "Recharge which item? ";
3084 s = "You have nothing to recharge.";
3087 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3089 /* Get the item (in the pack) */
3092 o_ptr = &inventory[item];
3095 /* Get the item (on the floor) */
3098 o_ptr = &o_list[0 - item];
3101 /* Get the object kind. */
3102 k_ptr = &k_info[o_ptr->k_idx];
3104 /* Extract the object "level" */
3105 lev = get_object_level(o_ptr);
3108 /* Recharge a rod */
3109 if (o_ptr->tval == TV_ROD)
3111 /* Extract a recharge strength by comparing object level to power. */
3112 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3116 if (one_in_(recharge_strength))
3118 /* Activate the failure code. */
3125 /* Recharge amount */
3126 recharge_amount = (power * damroll(3, 2));
3128 /* Recharge by that amount */
3129 if (o_ptr->timeout > recharge_amount)
3130 o_ptr->timeout -= recharge_amount;
3137 /* Recharge wand/staff */
3140 /* Extract a recharge strength by comparing object level to power.
3141 * Divide up a stack of wands' charges to calculate charge penalty.
3143 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3144 recharge_strength = (100 + power - lev -
3145 (8 * o_ptr->pval / o_ptr->number)) / 15;
3147 /* All staffs, unstacked wands. */
3148 else recharge_strength = (100 + power - lev -
3149 (8 * o_ptr->pval)) / 15;
3152 if (recharge_strength < 0) recharge_strength = 0;
3155 if (one_in_(recharge_strength))
3157 /* Activate the failure code. */
3161 /* If the spell didn't backfire, recharge the wand or staff. */
3164 /* Recharge based on the standard number of charges. */
3165 recharge_amount = randint1(1 + k_ptr->pval / 2);
3167 /* Multiple wands in a stack increase recharging somewhat. */
3168 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3171 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3172 if (recharge_amount < 1) recharge_amount = 1;
3173 if (recharge_amount > 12) recharge_amount = 12;
3176 /* But each staff in a stack gets fewer additional charges,
3177 * although always at least one.
3179 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3181 recharge_amount /= o_ptr->number;
3182 if (recharge_amount < 1) recharge_amount = 1;
3185 /* Recharge the wand or staff. */
3186 o_ptr->pval += recharge_amount;
3189 /* Hack -- we no longer "know" the item */
3190 o_ptr->ident &= ~(IDENT_KNOWN);
3192 /* Hack -- we no longer think the item is empty */
3193 o_ptr->ident &= ~(IDENT_EMPTY);
3198 /* Inflict the penalties for failing a recharge. */
3201 /* Artifacts are never destroyed. */
3202 if (artifact_p(o_ptr))
3204 object_desc(o_name, o_ptr, TRUE, 0);
3206 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3208 msg_format("The recharging backfires - %s is completely drained!", o_name);
3212 /* Artifact rods. */
3213 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3214 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3216 /* Artifact wands and staffs. */
3217 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3222 /* Get the object description */
3223 object_desc(o_name, o_ptr, FALSE, 0);
3225 /*** Determine Seriousness of Failure ***/
3227 /* Mages recharge objects more safely. */
3228 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)
3230 /* 10% chance to blow up one rod, otherwise draining. */
3231 if (o_ptr->tval == TV_ROD)
3233 if (one_in_(10)) fail_type = 2;
3236 /* 75% chance to blow up one wand, otherwise draining. */
3237 else if (o_ptr->tval == TV_WAND)
3239 if (!one_in_(3)) fail_type = 2;
3242 /* 50% chance to blow up one staff, otherwise no effect. */
3243 else if (o_ptr->tval == TV_STAFF)
3245 if (one_in_(2)) fail_type = 2;
3250 /* All other classes get no special favors. */
3253 /* 33% chance to blow up one rod, otherwise draining. */
3254 if (o_ptr->tval == TV_ROD)
3256 if (one_in_(3)) fail_type = 2;
3259 /* 20% chance of the entire stack, else destroy one wand. */
3260 else if (o_ptr->tval == TV_WAND)
3262 if (one_in_(5)) fail_type = 3;
3265 /* Blow up one staff. */
3266 else if (o_ptr->tval == TV_STAFF)
3272 /*** Apply draining and destruction. ***/
3274 /* Drain object or stack of objects. */
3277 if (o_ptr->tval == TV_ROD)
3280 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3282 msg_print("The recharge backfires, draining the rod further!");
3285 if (o_ptr->timeout < 10000)
3286 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3288 else if (o_ptr->tval == TV_WAND)
3291 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3293 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3298 /* Staffs aren't drained. */
3301 /* Destroy an object or one in a stack of objects. */
3304 if (o_ptr->number > 1)
3306 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3308 msg_format("Wild magic consumes one of your %s!", o_name);
3313 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3315 msg_format("Wild magic consumes your %s!", o_name);
3319 /* Reduce rod stack maximum timeout, drain wands. */
3320 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3321 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3323 /* Reduce and describe inventory */
3326 inven_item_increase(item, -1);
3327 inven_item_describe(item);
3328 inven_item_optimize(item);
3331 /* Reduce and describe floor item */
3334 floor_item_increase(0 - item, -1);
3335 floor_item_describe(0 - item);
3336 floor_item_optimize(0 - item);
3340 /* Destroy all members of a stack of objects. */
3343 if (o_ptr->number > 1)
3345 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3347 msg_format("Wild magic consumes all your %s!", o_name);
3352 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3354 msg_format("Wild magic consumes your %s!", o_name);
3359 /* Reduce and describe inventory */
3362 inven_item_increase(item, -999);
3363 inven_item_describe(item);
3364 inven_item_optimize(item);
3367 /* Reduce and describe floor item */
3370 floor_item_increase(0 - item, -999);
3371 floor_item_describe(0 - item);
3372 floor_item_optimize(0 - item);
3378 /* Combine / Reorder the pack (later) */
3379 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3382 p_ptr->window |= (PW_INVEN);
3384 /* Something was done */
3392 bool bless_weapon(void)
3396 u32b flgs[TR_FLAG_SIZE];
3397 char o_name[MAX_NLEN];
3400 item_tester_no_ryoute = TRUE;
3401 /* Assume enchant weapon */
3402 item_tester_hook = item_tester_hook_weapon2;
3406 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3407 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3409 q = "Bless which weapon? ";
3410 s = "You have weapon to bless.";
3413 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3416 /* Get the item (in the pack) */
3419 o_ptr = &inventory[item];
3422 /* Get the item (on the floor) */
3425 o_ptr = &o_list[0 - item];
3430 object_desc(o_name, o_ptr, FALSE, 0);
3432 /* Extract the flags */
3433 object_flags(o_ptr, flgs);
3435 if (cursed_p(o_ptr))
3437 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3438 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3441 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3444 msg_format("The black aura on %s %s disrupts the blessing!",
3445 ((item >= 0) ? "your" : "the"), o_name);
3452 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3455 msg_format("A malignant aura leaves %s %s.",
3456 ((item >= 0) ? "your" : "the"), o_name);
3461 o_ptr->curse_flags = 0L;
3463 /* Hack -- Assume felt */
3464 o_ptr->ident |= (IDENT_SENSE);
3467 o_ptr->feeling = FEEL_NONE;
3469 /* Recalculate the bonuses */
3470 p_ptr->update |= (PU_BONUS);
3473 p_ptr->window |= (PW_EQUIP);
3477 * Next, we try to bless it. Artifacts have a 1/3 chance of
3478 * being blessed, otherwise, the operation simply disenchants
3479 * them, godly power negating the magic. Ok, the explanation
3480 * is silly, but otherwise priests would always bless every
3481 * artifact weapon they find. Ego weapons and normal weapons
3482 * can be blessed automatically.
3484 if (have_flag(flgs, TR_BLESSED))
3487 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3490 msg_format("%s %s %s blessed already.",
3491 ((item >= 0) ? "Your" : "The"), o_name,
3492 ((o_ptr->number > 1) ? "were" : "was"));
3498 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3502 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3505 msg_format("%s %s shine%s!",
3506 ((item >= 0) ? "Your" : "The"), o_name,
3507 ((o_ptr->number > 1) ? "" : "s"));
3510 add_flag(o_ptr->art_flags, TR_BLESSED);
3511 o_ptr->discount = 99;
3515 bool dis_happened = FALSE;
3518 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3520 msg_print("The weapon resists your blessing!");
3524 /* Disenchant tohit */
3525 if (o_ptr->to_h > 0)
3528 dis_happened = TRUE;
3531 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3533 /* Disenchant todam */
3534 if (o_ptr->to_d > 0)
3537 dis_happened = TRUE;
3540 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3542 /* Disenchant toac */
3543 if (o_ptr->to_a > 0)
3546 dis_happened = TRUE;
3549 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3554 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3556 msg_print("There is a static feeling in the air...");
3560 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3563 msg_format("%s %s %s disenchanted!",
3564 ((item >= 0) ? "Your" : "The"), o_name,
3565 ((o_ptr->number > 1) ? "were" : "was"));
3571 /* Recalculate bonuses */
3572 p_ptr->update |= (PU_BONUS);
3575 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3586 bool pulish_shield(void)
3590 u32b flgs[TR_FLAG_SIZE];
3591 char o_name[MAX_NLEN];
3594 item_tester_no_ryoute = TRUE;
3595 /* Assume enchant weapon */
3596 item_tester_tval = TV_SHIELD;
3600 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3601 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3603 q = "Pulish which weapon? ";
3604 s = "You have weapon to pulish.";
3607 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3610 /* Get the item (in the pack) */
3613 o_ptr = &inventory[item];
3616 /* Get the item (on the floor) */
3619 o_ptr = &o_list[0 - item];
3624 object_desc(o_name, o_ptr, FALSE, 0);
3626 /* Extract the flags */
3627 object_flags(o_ptr, flgs);
3629 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3630 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3633 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3635 msg_format("%s %s shine%s!",
3636 ((item >= 0) ? "Your" : "The"), o_name,
3637 ((o_ptr->number > 1) ? "" : "s"));
3639 o_ptr->name2 = EGO_REFLECTION;
3640 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3642 o_ptr->discount = 99;
3643 chg_virtue(V_ENCHANT, 2);
3649 if (flush_failure) flush();
3652 msg_print("¼ºÇÔ¤·¤¿¡£");
3654 msg_print("Failed.");
3657 chg_virtue(V_ENCHANT, -2);
3666 * Potions "smash open" and cause an area effect when
3667 * (1) they are shattered while in the player's inventory,
3668 * due to cold (etc) attacks;
3669 * (2) they are thrown at a monster, or obstacle;
3670 * (3) they are shattered by a "cold ball" or other such spell
3671 * while lying on the floor.
3674 * who --- who caused the potion to shatter (0=player)
3675 * potions that smash on the floor are assumed to
3676 * be caused by no-one (who = 1), as are those that
3677 * shatter inside the player inventory.
3678 * (Not anymore -- I changed this; TY)
3679 * y, x --- coordinates of the potion (or player if
3680 * the potion was in her inventory);
3681 * o_ptr --- pointer to the potion object.
3683 bool potion_smash_effect(int who, int y, int x, int k_idx)
3690 object_kind *k_ptr = &k_info[k_idx];
3692 switch (k_ptr->sval)
3694 case SV_POTION_SALT_WATER:
3695 case SV_POTION_SLIME_MOLD:
3696 case SV_POTION_LOSE_MEMORIES:
3697 case SV_POTION_DEC_STR:
3698 case SV_POTION_DEC_INT:
3699 case SV_POTION_DEC_WIS:
3700 case SV_POTION_DEC_DEX:
3701 case SV_POTION_DEC_CON:
3702 case SV_POTION_DEC_CHR:
3703 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3704 case SV_POTION_APPLE_JUICE:
3707 case SV_POTION_INFRAVISION:
3708 case SV_POTION_DETECT_INVIS:
3709 case SV_POTION_SLOW_POISON:
3710 case SV_POTION_CURE_POISON:
3711 case SV_POTION_BOLDNESS:
3712 case SV_POTION_RESIST_HEAT:
3713 case SV_POTION_RESIST_COLD:
3714 case SV_POTION_HEROISM:
3715 case SV_POTION_BESERK_STRENGTH:
3716 case SV_POTION_RES_STR:
3717 case SV_POTION_RES_INT:
3718 case SV_POTION_RES_WIS:
3719 case SV_POTION_RES_DEX:
3720 case SV_POTION_RES_CON:
3721 case SV_POTION_RES_CHR:
3722 case SV_POTION_INC_STR:
3723 case SV_POTION_INC_INT:
3724 case SV_POTION_INC_WIS:
3725 case SV_POTION_INC_DEX:
3726 case SV_POTION_INC_CON:
3727 case SV_POTION_INC_CHR:
3728 case SV_POTION_AUGMENTATION:
3729 case SV_POTION_ENLIGHTENMENT:
3730 case SV_POTION_STAR_ENLIGHTENMENT:
3731 case SV_POTION_SELF_KNOWLEDGE:
3732 case SV_POTION_EXPERIENCE:
3733 case SV_POTION_RESISTANCE:
3734 case SV_POTION_INVULNERABILITY:
3735 case SV_POTION_NEW_LIFE:
3736 /* All of the above potions have no effect when shattered */
3738 case SV_POTION_SLOWNESS:
3743 case SV_POTION_POISON:
3748 case SV_POTION_BLINDNESS:
3752 case SV_POTION_CONFUSION: /* Booze */
3756 case SV_POTION_SLEEP:
3760 case SV_POTION_RUINATION:
3761 case SV_POTION_DETONATIONS:
3763 dam = damroll(25, 25);
3766 case SV_POTION_DEATH:
3767 dt = GF_DEATH_RAY; /* !! */
3768 dam = k_ptr->level * 10;
3772 case SV_POTION_SPEED:
3775 case SV_POTION_CURE_LIGHT:
3777 dam = damroll(2, 3);
3779 case SV_POTION_CURE_SERIOUS:
3781 dam = damroll(4, 3);
3783 case SV_POTION_CURE_CRITICAL:
3784 case SV_POTION_CURING:
3786 dam = damroll(6, 3);
3788 case SV_POTION_HEALING:
3790 dam = damroll(10, 10);
3792 case SV_POTION_RESTORE_EXP:
3797 case SV_POTION_LIFE:
3799 dam = damroll(50, 50);
3802 case SV_POTION_STAR_HEALING:
3804 dam = damroll(50, 50);
3807 case SV_POTION_RESTORE_MANA: /* MANA */
3809 dam = damroll(10, 10);
3816 (void)project(who, radius, y, x, dam, dt,
3817 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3819 /* XXX those potions that explode need to become "known" */
3825 * Hack -- Display all known spells in a window
3827 * XXX XXX XXX Need to analyze size of the window.
3829 * XXX XXX XXX Need more color coding.
3831 void display_spell_list(void)
3844 /* They have too many spells to list */
3845 if (p_ptr->pclass == CLASS_SORCERER) return;
3846 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3848 /* mind.c type classes */
3849 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3850 (p_ptr->pclass == CLASS_BERSERKER) ||
3851 (p_ptr->pclass == CLASS_NINJA) ||
3852 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3853 (p_ptr->pclass == CLASS_FORCETRAINER))
3859 int plev = p_ptr->lev;
3865 bool use_hp = FALSE;
3867 /* Display a list of spells */
3870 put_str("̾Á°", y, x + 5);
3871 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3873 put_str("Name", y, x + 5);
3874 put_str("Lv Mana Fail Info", y, x + 35);
3877 switch(p_ptr->pclass)
3879 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3880 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3881 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3882 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3883 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3884 default: use_mind = 0;break;
3887 /* Dump the spells */
3888 for (i = 0; i < MAX_MIND_POWERS; i++)
3890 byte a = TERM_WHITE;
3892 /* Access the available spell */
3893 spell = mind_powers[use_mind].info[i];
3894 if (spell.min_lev > plev) break;
3896 /* Get the failure rate */
3897 chance = spell.fail;
3899 /* Reduce failure rate by "effective" level adjustment */
3900 chance -= 3 * (p_ptr->lev - spell.min_lev);
3902 /* Reduce failure rate by INT/WIS adjustment */
3903 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3907 /* Not enough mana to cast */
3908 if (spell.mana_cost > p_ptr->csp)
3910 chance += 5 * (spell.mana_cost - p_ptr->csp);
3916 /* Not enough hp to cast */
3917 if (spell.mana_cost > p_ptr->chp)
3924 /* Extract the minimum failure rate */
3925 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3927 /* Minimum failure rate */
3928 if (chance < minfail) chance = minfail;
3930 /* Stunning makes spells harder */
3931 if (p_ptr->stun > 50) chance += 25;
3932 else if (p_ptr->stun) chance += 15;
3934 /* Always a 5 percent chance of working */
3935 if (chance > 95) chance = 95;
3938 mindcraft_info(comment, use_mind, i);
3940 /* Dump the spell */
3941 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3943 spell.min_lev, spell.mana_cost, chance, comment);
3945 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3950 /* Cannot read spellbooks */
3951 if (REALM_NONE == p_ptr->realm1) return;
3953 /* Normal spellcaster with books */
3956 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3960 /* Reset vertical */
3963 /* Vertical location */
3964 y = (j < 3) ? 0 : (m[j - 3] + 2);
3966 /* Horizontal location */
3970 for (i = 0; i < 32; i++)
3972 byte a = TERM_WHITE;
3974 /* Access the spell */
3975 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3977 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3981 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3984 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
3987 if (s_ptr->slevel >= 99)
3991 strcpy(name, "(ȽÆÉÉÔǽ)");
3993 strcpy(name, "(illegible)");
4003 ((p_ptr->spell_forgotten1 & (1L << i))) :
4004 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4011 else if (!((j < 1) ?
4012 (p_ptr->spell_learned1 & (1L << i)) :
4013 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4020 else if (!((j < 1) ?
4021 (p_ptr->spell_worked1 & (1L << i)) :
4022 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4028 /* Dump the spell --(-- */
4029 sprintf(out_val, "%c/%c) %-20.20s",
4030 I2A(n / 8), I2A(n % 8), name);
4035 /* Dump onto the window */
4036 Term_putstr(x, m[j], -1, a, out_val);
4046 * Returns experience of a spell
4048 s16b experience_of_spell(int spell, int use_realm)
4050 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4051 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4052 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4053 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4059 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4061 int mod_need_mana(int need_mana, int spell, int realm)
4063 #define MANA_CONST 2400
4065 #define DEC_MANA_DIV 3
4068 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4071 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4072 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4074 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4075 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4076 need_mana /= MANA_CONST * MANA_DIV;
4077 if (need_mana < 1) need_mana = 1;
4080 /* Non-realm magic */
4083 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4095 * Returns spell chance of failure for spell -RAK-
4097 s16b spell_chance(int spell, int use_realm)
4099 int chance, minfail;
4102 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4105 /* Paranoia -- must be literate */
4106 if (!mp_ptr->spell_book) return (100);
4108 if (use_realm == REALM_HISSATSU) return 0;
4110 /* Access the spell */
4111 if (!is_magic(use_realm))
4113 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4117 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4120 /* Extract the base spell failure rate */
4121 chance = s_ptr->sfail;
4123 /* Reduce failure rate by "effective" level adjustment */
4124 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4126 /* Reduce failure rate by INT/WIS adjustment */
4127 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4130 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4132 /* Extract mana consumption rate */
4133 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4135 /* Not enough mana to cast */
4136 if (need_mana > p_ptr->csp)
4138 chance += 5 * (need_mana - p_ptr->csp);
4141 chance += p_ptr->to_m_chance;
4142 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4144 /* Extract the minimum failure rate */
4145 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4148 * Non mage/priest characters never get too good
4149 * (added high mage, mindcrafter)
4151 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4153 if (minfail < 5) minfail = 5;
4156 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4157 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4158 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4160 if (p_ptr->heavy_spell) chance += 20;
4161 if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
4162 else if (p_ptr->easy_spell) chance-=3;
4163 else if (p_ptr->dec_mana) chance-=2;
4165 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4166 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4167 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4169 /* Minimum failure rate */
4170 if (chance < minfail) chance = minfail;
4172 /* Stunning makes spells harder */
4173 if (p_ptr->stun > 50) chance += 25;
4174 else if (p_ptr->stun) chance += 15;
4176 /* Always a 5 percent chance of working */
4177 if (chance > 95) chance = 95;
4179 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4180 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4182 s16b exp = experience_of_spell(spell, use_realm);
4183 if (exp >= SPELL_EXP_EXPERT) chance--;
4184 if (exp >= SPELL_EXP_MASTER) chance--;
4186 if(p_ptr->dec_mana) chance--;
4187 if (p_ptr->heavy_spell) chance += 5;
4189 chance = MAX(chance,0);
4191 /* Return the chance */
4198 * Determine if a spell is "okay" for the player to cast or study
4199 * The spell must be legible, not forgotten, and also, to cast,
4200 * it must be known, and to study, it must not be known.
4202 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4206 /* Access the spell */
4207 if (!is_magic(use_realm))
4209 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4213 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4216 /* Spell is illegal */
4217 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4219 /* Spell is forgotten */
4220 if ((use_realm == p_ptr->realm2) ?
4221 (p_ptr->spell_forgotten2 & (1L << spell)) :
4222 (p_ptr->spell_forgotten1 & (1L << spell)))
4228 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4229 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4231 /* Spell is learned */
4232 if ((use_realm == p_ptr->realm2) ?
4233 (p_ptr->spell_learned2 & (1L << spell)) :
4234 (p_ptr->spell_learned1 & (1L << spell)))
4237 return (!study_pray);
4240 /* Okay to study, not to cast */
4247 * Extra information on a spell -DRS-
4249 * We can use up to 14 characters of the buffer 'p'
4251 * The strings in this function were extracted from the code in the
4252 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4254 static void spell_info(char *p, int spell, int use_realm)
4256 int plev = p_ptr->lev;
4259 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4260 p_ptr->pclass == CLASS_HIGH_MAGE ||
4261 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4263 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4264 p_ptr->pclass == CLASS_HIGH_MAGE ||
4265 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4267 cptr s_dam = "»½ý:";
4268 cptr s_dur = "´ü´Ö:";
4269 cptr s_range = "ÈÏ°Ï:";
4270 cptr s_heal = "²óÉü:";
4271 cptr s_random = "¥é¥ó¥À¥à";
4272 cptr s_delay = "ÃÙ±ä:";
4274 cptr s_dam = "dam ";
4275 cptr s_dur = "dur ";
4276 cptr s_range = "range ";
4277 cptr s_heal = "heal ";
4278 cptr s_random = "random";
4279 cptr s_delay = "delay ";
4284 /* Analyze the spell */
4287 case REALM_LIFE: /* Life */
4290 case 0: sprintf(p, " %s2d10", s_heal); break;
4291 case 1: sprintf(p, " %s12+d12", s_dur); break;
4292 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4293 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4294 case 5: sprintf(p, " %s4d10", s_heal); break;
4295 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4296 case 10: sprintf(p, " %s8d10", s_heal); break;
4297 case 11: sprintf(p, " %s20+d20", s_dur); break;
4298 case 14: sprintf(p, " %s300", s_heal); break;
4299 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4300 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4301 case 21: sprintf(p, " %s15+d21", s_delay); break;
4302 case 29: sprintf(p, " %s2000", s_heal); break;
4303 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4307 case REALM_SORCERY: /* Sorcery */
4310 case 1: sprintf(p, " %s10", s_range); break;
4311 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4312 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4313 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4314 case 18: sprintf(p, " %s25+d30", s_dur); break;
4315 case 22: sprintf(p, " %s15+d21", s_delay); break;
4316 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4317 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4319 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4321 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4323 case 27: sprintf(p, " %s25+d30", s_dur); break;
4324 case 31: sprintf(p, " %s4+d4", s_dur); break;
4328 case REALM_NATURE: /* Nature */
4332 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4334 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4336 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4337 case 6: sprintf(p, " %s20+d20", s_dur); break;
4338 case 7: sprintf(p, " %s2d8", s_heal); break;
4339 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4340 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4341 case 12: sprintf(p, " %s6d8", s_dam); break;
4342 case 15: sprintf(p, " %s500", s_heal); break;
4343 case 17: sprintf(p, " %s20+d30", s_dur); break;
4344 case 18: sprintf(p, " %s20+d20", s_dur); break;
4346 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4348 case 24: sprintf(p, " rad 10"); break;
4350 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4351 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4352 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4353 case 29: sprintf(p, " %s75", s_dam); break;
4354 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4358 case REALM_CHAOS: /* Chaos */
4361 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4362 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4363 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4364 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4365 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4366 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4367 case 8: sprintf(p, " %s", s_random); break;
4368 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4369 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4370 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4371 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4372 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4373 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4374 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4375 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4376 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4378 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4380 case 25: sprintf(p, " dam %d each", plev * 2); break;
4382 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4383 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4384 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4385 case 30: sprintf(p, " %s%d", s_dam, p_ptr->chp); break;
4386 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4390 case REALM_DEATH: /* Death */
4393 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4394 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4395 case 5: sprintf(p, " %s20+d20", s_dur); break;
4396 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4397 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4398 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4400 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4402 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4404 case 16: sprintf(p, " %s25+d25", s_dur); break;
4405 case 17: sprintf(p, " %s", s_random); break;
4406 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4407 case 19: sprintf(p, " %s25+d25", s_dur); break;
4408 case 21: sprintf(p, " %s3*100", s_dam); break;
4409 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4410 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4411 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4412 case 30: sprintf(p, " %s666", s_dam); break;
4413 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4417 case REALM_TRUMP: /* Trump */
4420 case 0: sprintf(p, " %s10", s_range); break;
4421 case 2: sprintf(p, " %s", s_random); break;
4422 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4423 case 5: sprintf(p, " %s25+d30", s_dur); break;
4425 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4427 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4429 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4430 case 14: sprintf(p, " %s15+d21", s_delay); break;
4431 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4433 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4435 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4440 case REALM_ARCANE: /* Arcane */
4443 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4444 case 4: sprintf(p, " %s10", s_range); break;
4445 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4446 case 7: sprintf(p, " %s2d8", s_heal); break;
4450 case 17: sprintf(p, " %s20+d20", s_dur); break;
4451 case 18: sprintf(p, " %s4d8", s_heal); break;
4452 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4453 case 21: sprintf(p, " %s6d8", s_dam); break;
4454 case 24: sprintf(p, " %s24+d24", s_dur); break;
4455 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4456 case 30: sprintf(p, " %s15+d21", s_delay); break;
4457 case 31: sprintf(p, " %s25+d30", s_dur); break;
4461 case REALM_ENCHANT: /* Craft */
4464 case 0: sprintf(p, " %s100+d100", s_dur); break;
4465 case 1: sprintf(p, " %s80+d80", s_dur); break;
4471 case 18: sprintf(p, " %s20+d20", s_dur); break;
4472 case 5: sprintf(p, " %s25+d25", s_dur); break;
4473 case 8: sprintf(p, " %s24+d24", s_dur); break;
4474 case 11: sprintf(p, " %s25+d25", s_dur); break;
4475 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4476 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4477 case 16: sprintf(p, " %s25+d30", s_dur); break;
4478 case 17: sprintf(p, " %s30+d20", s_dur); break;
4479 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4480 case 20: sprintf(p, " %s50+d50", s_dur); break;
4481 case 23: sprintf(p, " %s20+d20", s_dur); break;
4482 case 31: sprintf(p, " %s13+d13", s_dur); break;
4486 case REALM_DAEMON: /* Daemon */
4489 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4490 case 2: sprintf(p, " %s12+d12", s_dur); break;
4491 case 3: sprintf(p, " %s20+d20", s_dur); break;
4492 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4493 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4494 case 10: sprintf(p, " %s20+d20", s_dur); break;
4495 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4496 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4497 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4498 case 16: sprintf(p, " %s30+d25", s_dur); break;
4499 case 17: sprintf(p, " %s20+d20", s_dur); break;
4500 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4501 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4502 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4503 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4504 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4505 case 24: sprintf(p, " %s25+d25", s_dur); break;
4506 case 25: sprintf(p, " %s20+d20", s_dur); break;
4507 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4508 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4509 case 30: sprintf(p, " %s600", s_dam); break;
4510 case 31: sprintf(p, " %s15+d15", s_dur); break;
4514 case REALM_CRUSADE: /* Crusade */
4517 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4518 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4520 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4522 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4524 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4525 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4526 case 12: sprintf(p, " %s24+d24", s_dur); break;
4527 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4528 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4530 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4532 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4534 case 18: sprintf(p, " %s18+d18", s_dur); break;
4535 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4536 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4537 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4538 case 24: sprintf(p, " %s25+d25", s_dur); break;
4539 case 28: sprintf(p, " %s10+d10", s_dur); break;
4541 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4543 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4546 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4548 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4553 case REALM_MUSIC: /* Music */
4556 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4557 case 4 : sprintf(p, " %s2d6", s_heal); break;
4558 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4559 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4560 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4561 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4562 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4563 case 28: sprintf(p, " %s15d10", s_heal); break;
4564 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4569 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4571 sprintf(p, "Unknown type: %d.", use_realm);
4578 * Print a list of spells (for browsing or casting or viewing)
4580 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4582 int i, spell, exp_level, increment = 64;
4594 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4596 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4598 msg_print("Warning! print_spells called with null realm");
4602 /* Title the list */
4604 if (use_realm == REALM_HISSATSU)
4606 strcpy(buf," Lv MP");
4608 strcpy(buf," Lv SP");
4612 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4614 strcpy(buf,"Profic Lv SP Fail Effect");
4618 put_str("̾Á°", y, x + 5);
4619 put_str(buf, y, x + 29);
4621 put_str("Name", y, x + 5);
4622 put_str(buf, y, x + 29);
4625 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4626 else if (use_realm == p_ptr->realm1) increment = 0;
4627 else if (use_realm == p_ptr->realm2) increment = 32;
4629 /* Dump the spells */
4630 for (i = 0; i < num; i++)
4632 /* Access the spell */
4635 /* Access the spell */
4636 if (!is_magic(use_realm))
4638 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4642 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4645 if (use_realm == REALM_HISSATSU)
4646 need_mana = s_ptr->smana;
4649 s16b exp = experience_of_spell(spell, use_realm);
4651 /* Extract mana consumption rate */
4652 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4654 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4655 else exp_level = spell_exp_level(exp);
4658 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4659 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4660 else if (s_ptr->slevel >= 99) max = TRUE;
4661 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4663 strncpy(ryakuji, exp_level_str[exp_level], 4);
4668 if (use_menu && target_spell)
4670 if (i == (target_spell-1))
4672 strcpy(out_val, " ¡Õ ");
4674 strcpy(out_val, " > ");
4677 strcpy(out_val, " ");
4679 else sprintf(out_val, " %c) ", I2A(i));
4680 /* Skip illegible spells */
4681 if (s_ptr->slevel >= 99)
4684 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4686 strcat(out_val, format("%-30s", "(illegible)"));
4689 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4693 /* XXX XXX Could label spells above the players level */
4695 /* Get extra info */
4696 spell_info(info, spell, use_realm);
4701 /* Assume spell is known and tried */
4702 line_attr = TERM_WHITE;
4704 /* Analyze the spell */
4705 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4707 if (s_ptr->slevel > p_ptr->max_plv)
4712 comment = " unknown";
4715 line_attr = TERM_L_BLUE;
4717 else if (s_ptr->slevel > p_ptr->lev)
4722 comment = " forgotten";
4725 line_attr = TERM_YELLOW;
4728 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4733 comment = " unknown";
4736 line_attr = TERM_L_BLUE;
4738 else if ((use_realm == p_ptr->realm1) ?
4739 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4740 ((p_ptr->spell_forgotten2 & (1L << spell))))
4745 comment = " forgotten";
4748 line_attr = TERM_YELLOW;
4750 else if (!((use_realm == p_ptr->realm1) ?
4751 (p_ptr->spell_learned1 & (1L << spell)) :
4752 (p_ptr->spell_learned2 & (1L << spell))))
4757 comment = " unknown";
4760 line_attr = TERM_L_BLUE;
4762 else if (!((use_realm == p_ptr->realm1) ?
4763 (p_ptr->spell_worked1 & (1L << spell)) :
4764 (p_ptr->spell_worked2 & (1L << spell))))
4767 comment = " ̤·Ð¸³";
4769 comment = " untried";
4772 line_attr = TERM_L_GREEN;
4775 /* Dump the spell --(-- */
4776 if (use_realm == REALM_HISSATSU)
4778 strcat(out_val, format("%-25s %2d %4d",
4779 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4780 s_ptr->slevel, need_mana));
4784 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4785 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4786 (max ? '!' : ' '), ryakuji,
4787 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4789 c_prt(line_attr, out_val, y + i + 1, x);
4792 /* Clear the bottom line */
4793 prt("", y + i + 1, x);
4798 * Note that amulets, rods, and high-level spell books are immune
4799 * to "inventory damage" of any kind. Also sling ammo and shovels.
4804 * Does a given class of objects (usually) hate acid?
4805 * Note that acid can either melt or corrode something.
4807 bool hates_acid(object_type *o_ptr)
4809 /* Analyze the type */
4810 switch (o_ptr->tval)
4812 /* Wearable items */
4832 /* Staffs/Scrolls are wood/paper */
4845 /* Junk is useless */
4859 * Does a given object (usually) hate electricity?
4861 bool hates_elec(object_type *o_ptr)
4863 switch (o_ptr->tval)
4877 * Does a given object (usually) hate fire?
4878 * Hafted/Polearm weapons have wooden shafts.
4879 * Arrows/Bows are mostly wooden.
4881 bool hates_fire(object_type *o_ptr)
4883 /* Analyze the type */
4884 switch (o_ptr->tval)
4902 case TV_SORCERY_BOOK:
4903 case TV_NATURE_BOOK:
4907 case TV_ARCANE_BOOK:
4908 case TV_ENCHANT_BOOK:
4909 case TV_DAEMON_BOOK:
4910 case TV_CRUSADE_BOOK:
4912 case TV_HISSATSU_BOOK:
4923 /* Staffs/Scrolls burn */
4936 * Does a given object (usually) hate cold?
4938 bool hates_cold(object_type *o_ptr)
4940 switch (o_ptr->tval)
4957 int set_acid_destroy(object_type *o_ptr)
4959 u32b flgs[TR_FLAG_SIZE];
4960 if (!hates_acid(o_ptr)) return (FALSE);
4961 object_flags(o_ptr, flgs);
4962 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4970 int set_elec_destroy(object_type *o_ptr)
4972 u32b flgs[TR_FLAG_SIZE];
4973 if (!hates_elec(o_ptr)) return (FALSE);
4974 object_flags(o_ptr, flgs);
4975 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4983 int set_fire_destroy(object_type *o_ptr)
4985 u32b flgs[TR_FLAG_SIZE];
4986 if (!hates_fire(o_ptr)) return (FALSE);
4987 object_flags(o_ptr, flgs);
4988 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4996 int set_cold_destroy(object_type *o_ptr)
4998 u32b flgs[TR_FLAG_SIZE];
4999 if (!hates_cold(o_ptr)) return (FALSE);
5000 object_flags(o_ptr, flgs);
5001 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
5007 * Destroys a type of item on a given percent chance
5008 * Note that missiles are no longer necessarily all destroyed
5009 * Destruction taken from "melee.c" code for "stealing".
5010 * New-style wands and rods handled correctly. -LM-
5011 * Returns number of items destroyed.
5013 int inven_damage(inven_func typ, int perc)
5017 char o_name[MAX_NLEN];
5019 /* Multishadow effects is determined by turn */
5020 if( p_ptr->multishadow && (turn & 1) )return 0;
5022 if (p_ptr->inside_arena) return 0;
5024 /* Count the casualties */
5027 /* Scan through the slots backwards */
5028 for (i = 0; i < INVEN_PACK; i++)
5030 o_ptr = &inventory[i];
5032 /* Skip non-objects */
5033 if (!o_ptr->k_idx) continue;
5035 /* Hack -- for now, skip artifacts */
5036 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
5038 /* Give this item slot a shot at death */
5041 /* Count the casualties */
5042 for (amt = j = 0; j < o_ptr->number; ++j)
5044 if (randint0(100) < perc) amt++;
5047 /* Some casualities */
5050 /* Get a description */
5051 object_desc(o_name, o_ptr, FALSE, 3);
5055 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
5057 msg_format("%sour %s (%c) %s destroyed!",
5061 o_name, index_to_label(i),
5062 ((o_ptr->number > 1) ?
5063 ((amt == o_ptr->number) ? "Á´Éô" :
5064 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
5066 ((o_ptr->number > 1) ?
5067 ((amt == o_ptr->number) ? "All of y" :
5068 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
5069 o_name, index_to_label(i),
5070 ((amt > 1) ? "were" : "was"));
5074 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
5075 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
5078 /* Potions smash open */
5079 if (object_is_potion(o_ptr))
5081 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
5084 /* Reduce the charges of rods/wands */
5085 reduce_charges(o_ptr, amt);
5087 /* Destroy "amt" items */
5088 inven_item_increase(i, -amt);
5089 inven_item_optimize(i);
5091 /* Count the casualties */
5097 /* Return the casualty count */
5103 * Acid has hit the player, attempt to affect some armor.
5105 * Note that the "base armor" of an object never changes.
5107 * If any armor is damaged (or resists), the player takes less damage.
5109 static int minus_ac(void)
5111 object_type *o_ptr = NULL;
5112 u32b flgs[TR_FLAG_SIZE];
5113 char o_name[MAX_NLEN];
5116 /* Pick a (possibly empty) inventory slot */
5117 switch (randint1(7))
5119 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5120 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5121 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5122 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5123 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5124 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5125 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5128 /* Nothing to damage */
5129 if (!o_ptr->k_idx) return (FALSE);
5131 if (o_ptr->tval < TV_BOOTS) return (FALSE);
5133 /* No damage left to be done */
5134 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5138 object_desc(o_name, o_ptr, FALSE, 0);
5140 /* Extract the flags */
5141 object_flags(o_ptr, flgs);
5143 /* Object resists */
5144 if (have_flag(flgs, TR_IGNORE_ACID))
5147 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5149 msg_format("Your %s is unaffected!", o_name);
5158 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5160 msg_format("Your %s is damaged!", o_name);
5164 /* Damage the item */
5167 /* Calculate bonuses */
5168 p_ptr->update |= (PU_BONUS);
5171 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5175 /* Item was damaged */
5181 * Hurt the player with Acid
5183 int acid_dam(int dam, cptr kb_str, int monspell)
5186 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5187 bool double_resist = IS_OPPOSE_ACID();
5189 /* Total Immunity */
5190 if (p_ptr->immune_acid || (dam <= 0))
5192 learn_spell(monspell);
5196 /* Vulnerability (Ouch!) */
5197 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5198 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5200 /* Resist the damage */
5201 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5202 if (double_resist) dam = (dam + 2) / 3;
5204 if ((!(double_resist || p_ptr->resist_acid)) &&
5205 one_in_(HURT_CHANCE))
5206 (void)do_dec_stat(A_CHR);
5208 /* If any armor gets hit, defend the player */
5209 if (minus_ac()) dam = (dam + 1) / 2;
5212 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5214 /* Inventory damage */
5215 if (!(double_resist && p_ptr->resist_acid))
5216 inven_damage(set_acid_destroy, inv);
5222 * Hurt the player with electricity
5224 int elec_dam(int dam, cptr kb_str, int monspell)
5227 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5228 bool double_resist = IS_OPPOSE_ELEC();
5230 /* Total immunity */
5231 if (p_ptr->immune_elec || (dam <= 0))
5233 learn_spell(monspell);
5237 /* Vulnerability (Ouch!) */
5238 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5239 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5240 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5242 /* Resist the damage */
5243 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5244 if (double_resist) dam = (dam + 2) / 3;
5246 if ((!(double_resist || p_ptr->resist_elec)) &&
5247 one_in_(HURT_CHANCE))
5248 (void)do_dec_stat(A_DEX);
5251 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5253 /* Inventory damage */
5254 if (!(double_resist && p_ptr->resist_elec))
5255 inven_damage(set_elec_destroy, inv);
5262 * Hurt the player with Fire
5264 int fire_dam(int dam, cptr kb_str, int monspell)
5267 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5268 bool double_resist = IS_OPPOSE_FIRE();
5270 /* Totally immune */
5271 if (p_ptr->immune_fire || (dam <= 0))
5273 learn_spell(monspell);
5277 /* Vulnerability (Ouch!) */
5278 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5279 if (prace_is_(RACE_ENT)) dam += dam / 3;
5280 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5282 /* Resist the damage */
5283 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5284 if (double_resist) dam = (dam + 2) / 3;
5286 if ((!(double_resist || p_ptr->resist_fire)) &&
5287 one_in_(HURT_CHANCE))
5288 (void)do_dec_stat(A_STR);
5291 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5293 /* Inventory damage */
5294 if (!(double_resist && p_ptr->resist_fire))
5295 inven_damage(set_fire_destroy, inv);
5302 * Hurt the player with Cold
5304 int cold_dam(int dam, cptr kb_str, int monspell)
5307 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5308 bool double_resist = IS_OPPOSE_COLD();
5310 /* Total immunity */
5311 if (p_ptr->immune_cold || (dam <= 0))
5313 learn_spell(monspell);
5317 /* Vulnerability (Ouch!) */
5318 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5319 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5321 /* Resist the damage */
5322 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5323 if (double_resist) dam = (dam + 2) / 3;
5325 if ((!(double_resist || p_ptr->resist_cold)) &&
5326 one_in_(HURT_CHANCE))
5327 (void)do_dec_stat(A_STR);
5330 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5332 /* Inventory damage */
5333 if (!(double_resist && p_ptr->resist_cold))
5334 inven_damage(set_cold_destroy, inv);
5340 bool rustproof(void)
5344 char o_name[MAX_NLEN];
5347 item_tester_no_ryoute = TRUE;
5348 /* Select a piece of armour */
5349 item_tester_hook = item_tester_hook_armour;
5353 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5354 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5356 q = "Rustproof which piece of armour? ";
5357 s = "You have nothing to rustproof.";
5360 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5362 /* Get the item (in the pack) */
5365 o_ptr = &inventory[item];
5368 /* Get the item (on the floor) */
5371 o_ptr = &o_list[0 - item];
5376 object_desc(o_name, o_ptr, FALSE, 0);
5378 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5380 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5383 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5385 msg_format("%s %s look%s as good as new!",
5386 ((item >= 0) ? "Your" : "The"), o_name,
5387 ((o_ptr->number > 1) ? "" : "s"));
5394 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5396 msg_format("%s %s %s now protected against corrosion.",
5397 ((item >= 0) ? "Your" : "The"), o_name,
5398 ((o_ptr->number > 1) ? "are" : "is"));
5409 * Curse the players armor
5411 bool curse_armor(void)
5416 char o_name[MAX_NLEN];
5419 /* Curse the body armor */
5420 o_ptr = &inventory[INVEN_BODY];
5422 /* Nothing to curse */
5423 if (!o_ptr->k_idx) return (FALSE);
5427 object_desc(o_name, o_ptr, FALSE, 3);
5429 /* Attempt a saving throw for artifacts */
5430 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5434 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5435 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5437 msg_format("A %s tries to %s, but your %s resists the effects!",
5438 "terrible black aura", "surround your armor", o_name);
5443 /* not artifact or failed save... */
5448 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5450 msg_format("A terrible black aura blasts your %s!", o_name);
5453 chg_virtue(V_ENCHANT, -5);
5455 /* Blast the armor */
5457 o_ptr->name2 = EGO_BLASTED;
5458 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5465 for (i = 0; i < TR_FLAG_SIZE; i++)
5466 o_ptr->art_flags[i] = 0;
5469 o_ptr->curse_flags = TRC_CURSED;
5472 o_ptr->ident |= (IDENT_BROKEN);
5474 /* Recalculate bonuses */
5475 p_ptr->update |= (PU_BONUS);
5477 /* Recalculate mana */
5478 p_ptr->update |= (PU_MANA);
5481 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5489 * Curse the players weapon
5491 bool curse_weapon(bool force, int slot)
5497 char o_name[MAX_NLEN];
5500 /* Curse the weapon */
5501 o_ptr = &inventory[slot];
5503 /* Nothing to curse */
5504 if (!o_ptr->k_idx) return (FALSE);
5508 object_desc(o_name, o_ptr, FALSE, 3);
5510 /* Attempt a saving throw */
5511 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5515 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5516 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5518 msg_format("A %s tries to %s, but your %s resists the effects!",
5519 "terrible black aura", "surround your weapon", o_name);
5524 /* not artifact or failed save... */
5529 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5531 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5534 chg_virtue(V_ENCHANT, -5);
5536 /* Shatter the weapon */
5538 o_ptr->name2 = EGO_SHATTERED;
5539 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5540 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5546 for (i = 0; i < TR_FLAG_SIZE; i++)
5547 o_ptr->art_flags[i] = 0;
5551 o_ptr->curse_flags = TRC_CURSED;
5554 o_ptr->ident |= (IDENT_BROKEN);
5556 /* Recalculate bonuses */
5557 p_ptr->update |= (PU_BONUS);
5559 /* Recalculate mana */
5560 p_ptr->update |= (PU_MANA);
5563 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5572 * Enchant some bolts
5574 bool brand_bolts(void)
5578 /* Use the first acceptable bolts */
5579 for (i = 0; i < INVEN_PACK; i++)
5581 object_type *o_ptr = &inventory[i];
5583 /* Skip non-bolts */
5584 if (o_ptr->tval != TV_BOLT) continue;
5586 /* Skip artifacts and ego-items */
5587 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5590 /* Skip cursed/broken items */
5591 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5594 if (randint0(100) < 75) continue;
5598 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5600 msg_print("Your bolts are covered in a fiery aura!");
5605 o_ptr->name2 = EGO_FLAME;
5608 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5615 if (flush_failure) flush();
5619 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5621 msg_print("The fiery enchantment failed.");
5631 * Helper function -- return a "nearby" race for polymorphing
5633 * Note that this function is one of the more "dangerous" ones...
5635 static s16b poly_r_idx(int r_idx)
5637 monster_race *r_ptr = &r_info[r_idx];
5639 int i, r, lev1, lev2;
5641 /* Hack -- Uniques/Questors never polymorph */
5642 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5643 (r_ptr->flags1 & RF1_QUESTOR))
5646 /* Allowable range of "levels" for resulting monster */
5647 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5648 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5650 /* Pick a (possibly new) non-unique race */
5651 for (i = 0; i < 1000; i++)
5653 /* Pick a new race, using a level calculation */
5654 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5656 /* Handle failure */
5662 /* Ignore unique monsters */
5663 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5665 /* Ignore monsters with incompatible levels */
5666 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5668 /* Use that index */
5680 bool polymorph_monster(int y, int x)
5682 cave_type *c_ptr = &cave[y][x];
5683 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5684 bool polymorphed = FALSE;
5686 int old_r_idx = m_ptr->r_idx;
5687 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5688 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5689 monster_type back_m;
5691 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5693 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5695 /* Memorize the monster before polymorphing */
5698 /* Pick a "new" monster race */
5699 new_r_idx = poly_r_idx(old_r_idx);
5701 /* Handle polymorph */
5702 if (new_r_idx != old_r_idx)
5706 /* Get the monsters attitude */
5707 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5708 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5709 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5711 /* "Kill" the "old" monster */
5712 delete_monster_idx(c_ptr->m_idx);
5714 /* Create a new monster (no groups) */
5715 if (place_monster_aux(0, y, x, new_r_idx, mode))
5722 /* Placing the new monster failed */
5723 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5724 m_list[hack_m_idx_ii] = back_m;
5727 if (targeted) target_who = hack_m_idx_ii;
5728 if (health_tracked) health_track(hack_m_idx_ii);
5738 bool dimension_door(void)
5740 int plev = p_ptr->lev;
5743 if (!tgt_pt(&x, &y)) return FALSE;
5745 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5747 if (!cave_empty_bold(y, x) || (cave[y][x].info & CAVE_ICKY) ||
5748 (distance(y, x, py, px) > plev / 2 + 10) ||
5749 (!randint0(plev / 10 + 10)))
5751 if( p_ptr->pclass != CLASS_MIRROR_MASTER ){
5753 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5755 msg_print("You fail to exit the astral plane correctly!");
5761 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5763 msg_print("You fail to exit the astral plane correctly!");
5766 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5767 teleport_player((plev+2)*2);
5770 teleport_player_to(y, x, TRUE);
5776 bool eat_magic(int power)
5778 object_type * o_ptr;
5781 int recharge_strength = 0;
5787 char o_name[MAX_NLEN];
5789 item_tester_hook = item_tester_hook_recharge;
5793 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5794 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5796 q = "Drain which item? ";
5797 s = "You have nothing to drain.";
5800 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5804 o_ptr = &inventory[item];
5808 o_ptr = &o_list[0 - item];
5811 k_ptr = &k_info[o_ptr->k_idx];
5812 lev = get_object_level(o_ptr);
5814 if (o_ptr->tval == TV_ROD)
5816 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5819 if (one_in_(recharge_strength))
5821 /* Activate the failure code. */
5826 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5829 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5831 msg_print("You can't absorb energy from a discharged rod.");
5838 o_ptr->timeout += k_ptr->pval;
5844 /* All staffs, wands. */
5845 recharge_strength = (100 + power - lev) / 15;
5848 if (recharge_strength < 0) recharge_strength = 0;
5851 if (one_in_(recharge_strength))
5853 /* Activate the failure code. */
5858 if (o_ptr->pval > 0)
5860 p_ptr->csp += lev / 2;
5863 /* XXX Hack -- unstack if necessary */
5864 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5869 /* Get local object */
5872 /* Obtain a local object */
5873 object_copy(q_ptr, o_ptr);
5875 /* Modify quantity */
5878 /* Restore the charges */
5881 /* Unstack the used item */
5883 p_ptr->total_weight -= q_ptr->weight;
5884 item = inven_carry(q_ptr);
5888 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5890 msg_print("You unstack your staff.");
5898 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5900 msg_print("There's no energy there to absorb!");
5904 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5908 /* Inflict the penalties for failing a recharge. */
5911 /* Artifacts are never destroyed. */
5912 if (artifact_p(o_ptr))
5914 object_desc(o_name, o_ptr, TRUE, 0);
5916 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5918 msg_format("The recharging backfires - %s is completely drained!", o_name);
5922 /* Artifact rods. */
5923 if (o_ptr->tval == TV_ROD)
5924 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5926 /* Artifact wands and staffs. */
5927 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5932 /* Get the object description */
5933 object_desc(o_name, o_ptr, FALSE, 0);
5935 /*** Determine Seriousness of Failure ***/
5937 /* Mages recharge objects more safely. */
5938 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)
5940 /* 10% chance to blow up one rod, otherwise draining. */
5941 if (o_ptr->tval == TV_ROD)
5943 if (one_in_(10)) fail_type = 2;
5946 /* 75% chance to blow up one wand, otherwise draining. */
5947 else if (o_ptr->tval == TV_WAND)
5949 if (!one_in_(3)) fail_type = 2;
5952 /* 50% chance to blow up one staff, otherwise no effect. */
5953 else if (o_ptr->tval == TV_STAFF)
5955 if (one_in_(2)) fail_type = 2;
5960 /* All other classes get no special favors. */
5963 /* 33% chance to blow up one rod, otherwise draining. */
5964 if (o_ptr->tval == TV_ROD)
5966 if (one_in_(3)) fail_type = 2;
5969 /* 20% chance of the entire stack, else destroy one wand. */
5970 else if (o_ptr->tval == TV_WAND)
5972 if (one_in_(5)) fail_type = 3;
5975 /* Blow up one staff. */
5976 else if (o_ptr->tval == TV_STAFF)
5982 /*** Apply draining and destruction. ***/
5984 /* Drain object or stack of objects. */
5987 if (o_ptr->tval == TV_ROD)
5990 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
5992 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
5995 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5997 else if (o_ptr->tval == TV_WAND)
6000 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
6002 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
6007 /* Staffs aren't drained. */
6010 /* Destroy an object or one in a stack of objects. */
6013 if (o_ptr->number > 1)
6016 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
6018 msg_format("Wild magic consumes one of your %s!", o_name);
6021 /* Reduce rod stack maximum timeout, drain wands. */
6022 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
6023 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
6028 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
6030 msg_format("Wild magic consumes your %s!", o_name);
6033 /* Reduce and describe inventory */
6036 inven_item_increase(item, -1);
6037 inven_item_describe(item);
6038 inven_item_optimize(item);
6041 /* Reduce and describe floor item */
6044 floor_item_increase(0 - item, -1);
6045 floor_item_describe(0 - item);
6046 floor_item_optimize(0 - item);
6050 /* Destroy all members of a stack of objects. */
6053 if (o_ptr->number > 1)
6055 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
6057 msg_format("Wild magic consumes all your %s!", o_name);
6062 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
6064 msg_format("Wild magic consumes your %s!", o_name);
6069 /* Reduce and describe inventory */
6072 inven_item_increase(item, -999);
6073 inven_item_describe(item);
6074 inven_item_optimize(item);
6077 /* Reduce and describe floor item */
6080 floor_item_increase(0 - item, -999);
6081 floor_item_describe(0 - item);
6082 floor_item_optimize(0 - item);
6088 if (p_ptr->csp > p_ptr->msp)
6090 p_ptr->csp = p_ptr->msp;
6093 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6094 p_ptr->window |= (PW_INVEN);
6100 bool summon_kin_player(int level, int y, int x, u32b mode)
6102 bool pet = (bool)(mode & PM_FORCE_PET);
6103 if (!pet) mode |= PM_NO_PET;
6105 switch (p_ptr->mimic_form)
6108 switch (p_ptr->prace)
6112 case RACE_BARBARIAN:
6115 summon_kin_type = 'p';
6125 case RACE_MIND_FLAYER:
6128 summon_kin_type = 'h';
6131 summon_kin_type = 'o';
6133 case RACE_HALF_TROLL:
6134 summon_kin_type = 'T';
6136 case RACE_HALF_OGRE:
6137 summon_kin_type = 'O';
6139 case RACE_HALF_GIANT:
6140 case RACE_HALF_TITAN:
6142 summon_kin_type = 'P';
6145 summon_kin_type = 'y';
6148 summon_kin_type = 'K';
6151 summon_kin_type = 'k';
6154 if (one_in_(13)) summon_kin_type = 'U';
6155 else summon_kin_type = 'u';
6157 case RACE_DRACONIAN:
6158 summon_kin_type = 'd';
6162 summon_kin_type = 'g';
6165 if (one_in_(13)) summon_kin_type = 'L';
6166 else summon_kin_type = 's';
6169 summon_kin_type = 'z';
6172 summon_kin_type = 'V';
6175 summon_kin_type = 'G';
6178 summon_kin_type = 'I';
6181 summon_kin_type = '#';
6184 summon_kin_type = 'A';
6187 summon_kin_type = 'U';
6190 summon_kin_type = 'p';
6195 if (one_in_(13)) summon_kin_type = 'U';
6196 else summon_kin_type = 'u';
6198 case MIMIC_DEMON_LORD:
6199 summon_kin_type = 'U';
6202 summon_kin_type = 'V';
6205 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);