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->flags3 & RF3_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) || ((y == py) && (x == px))) 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);
1433 void call_the_(void)
1437 bool do_call = TRUE;
1439 for (i = 0; i < 9; i++)
1441 y = py + ddy_ddd[i];
1442 x = px + ddx_ddd[i];
1444 if (!cave_floor_bold(y, x) && !boundary_floor_bold(y, x))
1453 for (i = 1; i < 10; i++)
1455 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1458 for (i = 1; i < 10; i++)
1460 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1463 for (i = 1; i < 10; i++)
1465 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1469 /* Prevent destruction of quest levels and town */
1470 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1473 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1475 msg_print("The ground trembles.");
1482 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1483 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1484 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1486 msg_format("You %s the %s too close to a wall!",
1487 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1488 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1489 msg_print("There is a loud explosion!");
1493 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1495 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1497 msg_print("The dungeon collapses...");
1502 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1504 msg_print("The dungeon trembles.");
1509 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1511 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1518 * Fetch an item (teleport it right underneath the caster)
1520 void fetch(int dir, int wgt, bool require_los)
1525 char o_name[MAX_NLEN];
1527 /* Check to see if an object is already there */
1528 if (cave[py][px].o_idx)
1531 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1533 msg_print("You can't fetch when you're already standing on something.");
1540 if (dir == 5 && target_okay())
1545 if (distance(py, px, ty, tx) > MAX_RANGE)
1548 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1550 msg_print("You can't fetch something that far away!");
1556 c_ptr = &cave[ty][tx];
1558 /* We need an item to fetch */
1562 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1564 msg_print("There is no object at this place.");
1570 /* No fetching from vault */
1571 if (c_ptr->info & CAVE_ICKY)
1574 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1576 msg_print("The item slips from your control.");
1582 /* We need to see the item */
1583 if (require_los && !player_has_los_bold(ty, tx))
1586 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1588 msg_print("You have no direct line of sight to that location.");
1596 /* Use a direction */
1597 ty = py; /* Where to drop the item */
1604 c_ptr = &cave[ty][tx];
1606 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1607 !cave_floor_bold(ty, tx)) return;
1609 while (!c_ptr->o_idx);
1612 o_ptr = &o_list[c_ptr->o_idx];
1614 if (o_ptr->weight > wgt)
1616 /* Too heavy to 'fetch' */
1618 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1620 msg_print("The object is too heavy.");
1627 c_ptr->o_idx = o_ptr->next_o_idx;
1628 cave[py][px].o_idx = i; /* 'move' it */
1629 o_ptr->next_o_idx = 0;
1630 o_ptr->iy = (byte)py;
1631 o_ptr->ix = (byte)px;
1633 object_desc(o_name, o_ptr, TRUE, 0);
1635 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1637 msg_format("%^s flies through the air to your feet.", o_name);
1642 p_ptr->redraw |= PR_MAP;
1646 void alter_reality(void)
1648 /* Ironman option */
1649 if (p_ptr->inside_arena || ironman_downward)
1652 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1654 msg_print("Nothing happens.");
1659 if (!p_ptr->alter_reality)
1661 int turns = randint0(21) + 15;
1663 p_ptr->alter_reality = turns;
1665 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1667 msg_print("The view around you begins to change...");
1670 p_ptr->redraw |= (PR_STATUS);
1674 p_ptr->alter_reality = 0;
1676 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1678 msg_print("The view around you got back...");
1681 p_ptr->redraw |= (PR_STATUS);
1688 * Leave a "glyph of warding" which prevents monster movement
1690 bool warding_glyph(void)
1693 if (!cave_clean_bold(py, px))
1696 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1698 msg_print("The object resists the spell.");
1704 /* Create a glyph */
1705 cave[py][px].info |= CAVE_OBJECT;
1706 cave[py][px].mimic = FEAT_GLYPH;
1717 bool warding_mirror(void)
1720 if (!cave_clean_bold(py, px))
1723 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1725 msg_print("The object resists the spell.");
1731 /* Create a mirror */
1732 cave[py][px].info |= CAVE_OBJECT;
1733 cave[py][px].mimic = FEAT_MIRROR;
1735 /* Turn on the light */
1736 cave[py][px].info |= CAVE_GLOW;
1749 * Leave an "explosive rune" which prevents monster movement
1751 bool explosive_rune(void)
1754 if (!cave_clean_bold(py, px))
1757 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1759 msg_print("The object resists the spell.");
1765 /* Create a glyph */
1766 cave[py][px].info |= CAVE_OBJECT;
1767 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1780 * Identify everything being carried.
1781 * Done by a potion of "self knowledge".
1783 void identify_pack(void)
1787 /* Simply identify and know every item */
1788 for (i = 0; i < INVEN_TOTAL; i++)
1790 object_type *o_ptr = &inventory[i];
1792 /* Skip non-objects */
1793 if (!o_ptr->k_idx) continue;
1796 identify_item(o_ptr);
1802 * Used by the "enchant" function (chance of failure)
1803 * (modified for Zangband, we need better stuff there...) -- TY
1805 static int enchant_table[16] =
1807 0, 10, 50, 100, 200,
1808 300, 400, 500, 650, 800,
1809 950, 987, 993, 995, 998,
1815 * Removes curses from items in inventory
1817 * Note that Items which are "Perma-Cursed" (The One Ring,
1818 * The Crown of Morgoth) can NEVER be uncursed.
1820 * Note that if "all" is FALSE, then Items which are
1821 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1822 * will not be uncursed.
1824 static int remove_curse_aux(int all)
1828 /* Attempt to uncurse items being worn */
1829 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1831 object_type *o_ptr = &inventory[i];
1833 /* Skip non-objects */
1834 if (!o_ptr->k_idx) continue;
1836 /* Uncursed already */
1837 if (!cursed_p(o_ptr)) continue;
1839 /* Heavily Cursed Items need a special spell */
1840 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1842 /* Perma-Cursed Items can NEVER be uncursed */
1843 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1846 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1851 o_ptr->curse_flags = 0L;
1853 /* Hack -- Assume felt */
1854 o_ptr->ident |= (IDENT_SENSE);
1857 o_ptr->feeling = FEEL_NONE;
1859 /* Recalculate the bonuses */
1860 p_ptr->update |= (PU_BONUS);
1863 p_ptr->window |= (PW_EQUIP);
1865 /* Count the uncursings */
1869 /* Return "something uncursed" */
1875 * Remove most curses
1877 bool remove_curse(void)
1879 return (remove_curse_aux(FALSE));
1885 bool remove_all_curse(void)
1887 return (remove_curse_aux(TRUE));
1892 * Turns an object into gold, gain some of its value in a shop
1901 char o_name[MAX_NLEN];
1902 char out_val[MAX_NLEN+40];
1906 /* Hack -- force destruction */
1907 if (command_arg > 0) force = TRUE;
1911 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
1912 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
1914 q = "Turn which item to gold? ";
1915 s = "You have nothing to turn to gold.";
1918 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
1920 /* Get the item (in the pack) */
1923 o_ptr = &inventory[item];
1926 /* Get the item (on the floor) */
1929 o_ptr = &o_list[0 - item];
1933 /* See how many items */
1934 if (o_ptr->number > 1)
1936 /* Get a quantity */
1937 amt = get_quantity(NULL, o_ptr->number);
1939 /* Allow user abort */
1940 if (amt <= 0) return FALSE;
1944 /* Describe the object */
1945 old_number = o_ptr->number;
1946 o_ptr->number = amt;
1947 object_desc(o_name, o_ptr, TRUE, 3);
1948 o_ptr->number = old_number;
1950 /* Verify unless quantity given */
1953 if (confirm_destroy || (object_value(o_ptr) > 0))
1955 /* Make a verification */
1957 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
1959 sprintf(out_val, "Really turn %s to gold? ", o_name);
1962 if (!get_check(out_val)) return FALSE;
1966 /* Artifacts cannot be destroyed */
1967 if (!can_player_destroy_object(o_ptr))
1971 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
1973 msg_format("You fail to turn %s to gold!", o_name);
1980 price = object_value_real(o_ptr);
1986 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
1988 msg_format("You turn %s to fool's gold.", o_name);
1996 if (amt > 1) price *= amt;
1998 if (price > 30000) price = 30000;
2000 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2002 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2008 p_ptr->redraw |= (PR_GOLD);
2011 p_ptr->window |= (PW_PLAYER);
2015 /* Eliminate the item (from the pack) */
2018 inven_item_increase(item, -amt);
2019 inven_item_describe(item);
2020 inven_item_optimize(item);
2023 /* Eliminate the item (from the floor) */
2026 floor_item_increase(0 - item, -amt);
2027 floor_item_describe(0 - item);
2028 floor_item_optimize(0 - item);
2037 * Hook to specify "weapon"
2039 bool item_tester_hook_weapon(object_type *o_ptr)
2041 switch (o_ptr->tval)
2055 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2062 static bool item_tester_hook_weapon2(object_type *o_ptr)
2064 switch (o_ptr->tval)
2084 * Hook to specify "armour"
2086 bool item_tester_hook_armour(object_type *o_ptr)
2088 switch (o_ptr->tval)
2109 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2111 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2113 switch (o_ptr->tval)
2142 * Check if an object is nameless weapon or armour
2144 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2146 switch (o_ptr->tval)
2165 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2167 if (object_known_p(o_ptr)) return FALSE;
2177 * Break the curse of an item
2179 static void break_curse(object_type *o_ptr)
2181 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2184 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2186 msg_print("The curse is broken!");
2189 o_ptr->curse_flags = 0L;
2191 o_ptr->ident |= (IDENT_SENSE);
2193 o_ptr->feeling = FEEL_NONE;
2199 * Enchants a plus onto an item. -RAK-
2201 * Revamped! Now takes item pointer, number of times to try enchanting,
2202 * and a flag of what to try enchanting. Artifacts resist enchantment
2203 * some of the time, and successful enchantment to at least +0 might
2204 * break a curse on the item. -CFT-
2206 * Note that an item can technically be enchanted all the way to +15 if
2207 * you wait a very, very, long time. Going from +9 to +10 only works
2208 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2210 * Note that this function can now be used on "piles" of items, and
2211 * the larger the pile, the lower the chance of success.
2213 bool enchant(object_type *o_ptr, int n, int eflag)
2215 int i, chance, prob;
2217 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2218 bool force = (eflag & ENCH_FORCE);
2221 /* Large piles resist enchantment */
2222 prob = o_ptr->number * 100;
2224 /* Missiles are easy to enchant */
2225 if ((o_ptr->tval == TV_BOLT) ||
2226 (o_ptr->tval == TV_ARROW) ||
2227 (o_ptr->tval == TV_SHOT))
2233 for (i = 0; i < n; i++)
2235 /* Hack -- Roll for pile resistance */
2236 if (!force && randint0(prob) >= 100) continue;
2238 /* Enchant to hit */
2239 if (eflag & ENCH_TOHIT)
2241 if (o_ptr->to_h < 0) chance = 0;
2242 else if (o_ptr->to_h > 15) chance = 1000;
2243 else chance = enchant_table[o_ptr->to_h];
2245 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2250 /* only when you get it above -1 -CFT */
2251 if (o_ptr->to_h >= 0)
2256 /* Enchant to damage */
2257 if (eflag & ENCH_TODAM)
2259 if (o_ptr->to_d < 0) chance = 0;
2260 else if (o_ptr->to_d > 15) chance = 1000;
2261 else chance = enchant_table[o_ptr->to_d];
2263 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2268 /* only when you get it above -1 -CFT */
2269 if (o_ptr->to_d >= 0)
2274 /* Enchant to armor class */
2275 if (eflag & ENCH_TOAC)
2277 if (o_ptr->to_a < 0) chance = 0;
2278 else if (o_ptr->to_a > 15) chance = 1000;
2279 else chance = enchant_table[o_ptr->to_a];
2281 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2286 /* only when you get it above -1 -CFT */
2287 if (o_ptr->to_a >= 0)
2294 if (!res) return (FALSE);
2296 /* Recalculate bonuses */
2297 p_ptr->update |= (PU_BONUS);
2299 /* Combine / Reorder the pack (later) */
2300 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2303 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2314 * Enchant an item (in the inventory or on the floor)
2315 * Note that "num_ac" requires armour, else weapon
2316 * Returns TRUE if attempted, FALSE if cancelled
2318 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2323 char o_name[MAX_NLEN];
2327 /* Assume enchant weapon */
2328 item_tester_hook = item_tester_hook_weapon;
2329 item_tester_no_ryoute = TRUE;
2331 /* Enchant armor if requested */
2332 if (num_ac) item_tester_hook = item_tester_hook_armour;
2336 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2337 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2339 q = "Enchant which item? ";
2340 s = "You have nothing to enchant.";
2343 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2345 /* Get the item (in the pack) */
2348 o_ptr = &inventory[item];
2351 /* Get the item (on the floor) */
2354 o_ptr = &o_list[0 - item];
2359 object_desc(o_name, o_ptr, FALSE, 0);
2363 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2366 msg_format("%s %s glow%s brightly!",
2367 ((item >= 0) ? "Your" : "The"), o_name,
2368 ((o_ptr->number > 1) ? "" : "s"));
2373 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2374 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2375 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2381 if (flush_failure) flush();
2385 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2387 msg_print("The enchantment failed.");
2390 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2393 chg_virtue(V_ENCHANT, 1);
2397 /* Something happened */
2402 bool artifact_scroll(void)
2407 char o_name[MAX_NLEN];
2411 item_tester_no_ryoute = TRUE;
2412 /* Enchant weapon/armour */
2413 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2417 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2418 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2420 q = "Enchant which item? ";
2421 s = "You have nothing to enchant.";
2424 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2426 /* Get the item (in the pack) */
2429 o_ptr = &inventory[item];
2432 /* Get the item (on the floor) */
2435 o_ptr = &o_list[0 - item];
2440 object_desc(o_name, o_ptr, FALSE, 0);
2444 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2446 msg_format("%s %s radiate%s a blinding light!",
2447 ((item >= 0) ? "Your" : "The"), o_name,
2448 ((o_ptr->number > 1) ? "" : "s"));
2451 if (o_ptr->name1 || o_ptr->art_name)
2454 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2456 msg_format("The %s %s already %s!",
2457 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2458 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2464 else if (o_ptr->name2)
2467 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2469 msg_format("The %s %s already %s!",
2470 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2471 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2477 else if (o_ptr->xtra3)
2480 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2482 msg_format("The %s %s already %s!",
2483 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2484 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2490 if (o_ptr->number > 1)
2493 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2494 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2496 msg_print("Not enough enough energy to enchant more than one object!");
2497 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2502 inven_item_increase(item, 1-(o_ptr->number));
2506 floor_item_increase(0-item, 1-(o_ptr->number));
2509 okay = create_artifact(o_ptr, TRUE);
2516 if (flush_failure) flush();
2520 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2522 msg_print("The enchantment failed.");
2525 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2528 chg_virtue(V_ENCHANT, 1);
2532 /* Something happened */
2538 * Identify an object
2540 bool identify_item(object_type *o_ptr)
2542 bool old_known = FALSE;
2543 char o_name[MAX_NLEN];
2546 object_desc(o_name, o_ptr, TRUE, 3);
2548 if (o_ptr->ident & IDENT_KNOWN)
2551 if (!(o_ptr->ident & (IDENT_MENTAL)))
2553 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2554 chg_virtue(V_KNOWLEDGE, 1);
2557 /* Identify it fully */
2558 object_aware(o_ptr);
2559 object_known(o_ptr);
2561 /* Recalculate bonuses */
2562 p_ptr->update |= (PU_BONUS);
2564 /* Combine / Reorder the pack (later) */
2565 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2568 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2570 strcpy(record_o_name, o_name);
2574 object_desc(o_name, o_ptr, TRUE, 0);
2576 if(record_fix_art && !old_known && artifact_p(o_ptr))
2577 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2578 if(record_rand_art && !old_known && o_ptr->art_name)
2579 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2585 static bool item_tester_hook_identify(object_type *o_ptr)
2587 return (bool)!object_known_p(o_ptr);
2590 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2592 if (object_known_p(o_ptr))
2594 return item_tester_hook_weapon_armour(o_ptr);
2598 * Identify an object in the inventory (or on the floor)
2599 * This routine does *not* automatically combine objects.
2600 * Returns TRUE if something was identified, else FALSE.
2602 bool ident_spell(bool only_equip)
2606 char o_name[MAX_NLEN];
2611 item_tester_no_ryoute = TRUE;
2614 item_tester_hook = item_tester_hook_identify_weapon_armour;
2616 item_tester_hook = item_tester_hook_identify;
2618 if (!can_get_item())
2622 item_tester_hook = item_tester_hook_weapon_armour;
2626 item_tester_hook = NULL;
2632 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2633 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2635 q = "Identify which item? ";
2636 s = "You have nothing to identify.";
2639 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2641 /* Get the item (in the pack) */
2644 o_ptr = &inventory[item];
2647 /* Get the item (on the floor) */
2650 o_ptr = &o_list[0 - item];
2654 old_known = identify_item(o_ptr);
2657 object_desc(o_name, o_ptr, TRUE, 3);
2660 if (item >= INVEN_RARM)
2663 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2665 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2671 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2673 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2679 msg_format("¾²¾å: %s¡£", o_name);
2681 msg_format("On the ground: %s.", o_name);
2685 /* Auto-inscription/destroy */
2686 idx = is_autopick(o_ptr);
2687 auto_inscribe_item(item, idx);
2688 if (destroy_identify && !old_known)
2689 auto_destroy_item(item, idx);
2691 /* Something happened */
2697 * Mundanify an object in the inventory (or on the floor)
2698 * This routine does *not* automatically combine objects.
2699 * Returns TRUE if something was mundanified, else FALSE.
2701 bool mundane_spell(bool only_equip)
2707 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
2708 item_tester_no_ryoute = TRUE;
2712 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2713 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2715 q = "Use which item? ";
2716 s = "You have nothing you can use.";
2719 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2721 /* Get the item (in the pack) */
2724 o_ptr = &inventory[item];
2727 /* Get the item (on the floor) */
2730 o_ptr = &o_list[0 - item];
2735 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2737 msg_print("There is a bright flash of light!");
2740 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2741 byte ix = o_ptr->ix; /* X-position on map, or zero */
2742 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2743 byte marked = o_ptr->marked; /* Object is marked */
2744 s16b weight = o_ptr->number * o_ptr->weight;
2745 u16b inscription = o_ptr->inscription;
2748 object_prep(o_ptr, o_ptr->k_idx);
2752 o_ptr->next_o_idx = next_o_idx;
2753 o_ptr->marked = marked;
2754 o_ptr->inscription = inscription;
2755 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2759 /* Something happened */
2765 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2767 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2770 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2772 if (!item_tester_hook_identify_fully(o_ptr))
2774 return item_tester_hook_weapon_armour(o_ptr);
2778 * Fully "identify" an object in the inventory -BEN-
2779 * This routine returns TRUE if an item was identified.
2781 bool identify_fully(bool only_equip)
2785 char o_name[MAX_NLEN];
2790 item_tester_no_ryoute = TRUE;
2792 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2794 item_tester_hook = item_tester_hook_identify_fully;
2796 if (!can_get_item())
2799 item_tester_hook = item_tester_hook_weapon_armour;
2801 item_tester_hook = NULL;
2806 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2807 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2809 q = "Identify which item? ";
2810 s = "You have nothing to identify.";
2813 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2815 /* Get the item (in the pack) */
2818 o_ptr = &inventory[item];
2821 /* Get the item (on the floor) */
2824 o_ptr = &o_list[0 - item];
2828 old_known = identify_item(o_ptr);
2830 /* Mark the item as fully known */
2831 o_ptr->ident |= (IDENT_MENTAL);
2837 object_desc(o_name, o_ptr, TRUE, 3);
2840 if (item >= INVEN_RARM)
2843 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2845 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2853 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2855 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2861 msg_format("¾²¾å: %s¡£", o_name);
2863 msg_format("On the ground: %s.", o_name);
2867 /* Describe it fully */
2868 (void)screen_object(o_ptr, TRUE);
2870 /* Auto-inscription/destroy */
2871 idx = is_autopick(o_ptr);
2872 auto_inscribe_item(item, idx);
2873 if (destroy_identify && !old_known)
2874 auto_destroy_item(item, idx);
2884 * Hook for "get_item()". Determine if something is rechargable.
2886 bool item_tester_hook_recharge(object_type *o_ptr)
2888 /* Recharge staffs */
2889 if (o_ptr->tval == TV_STAFF) return (TRUE);
2891 /* Recharge wands */
2892 if (o_ptr->tval == TV_WAND) return (TRUE);
2894 /* Hack -- Recharge rods */
2895 if (o_ptr->tval == TV_ROD) return (TRUE);
2903 * Recharge a wand/staff/rod from the pack or on the floor.
2904 * This function has been rewritten in Oangband and ZAngband.
2906 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2907 * Chaos -- Arcane Binding --> recharge(90)
2909 * Scroll of recharging --> recharge(130)
2910 * Artifact activation/Thingol --> recharge(130)
2912 * It is harder to recharge high level, and highly charged wands,
2913 * staffs, and rods. The more wands in a stack, the more easily and
2914 * strongly they recharge. Staffs, however, each get fewer charges if
2917 * XXX XXX XXX Beware of "sliding index errors".
2919 bool recharge(int power)
2922 int recharge_strength, recharge_amount;
2931 char o_name[MAX_NLEN];
2933 /* Only accept legal items */
2934 item_tester_hook = item_tester_hook_recharge;
2938 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
2939 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2941 q = "Recharge which item? ";
2942 s = "You have nothing to recharge.";
2945 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2947 /* Get the item (in the pack) */
2950 o_ptr = &inventory[item];
2953 /* Get the item (on the floor) */
2956 o_ptr = &o_list[0 - item];
2959 /* Get the object kind. */
2960 k_ptr = &k_info[o_ptr->k_idx];
2962 /* Extract the object "level" */
2963 lev = get_object_level(o_ptr);
2966 /* Recharge a rod */
2967 if (o_ptr->tval == TV_ROD)
2969 /* Extract a recharge strength by comparing object level to power. */
2970 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
2974 if (one_in_(recharge_strength))
2976 /* Activate the failure code. */
2983 /* Recharge amount */
2984 recharge_amount = (power * damroll(3, 2));
2986 /* Recharge by that amount */
2987 if (o_ptr->timeout > recharge_amount)
2988 o_ptr->timeout -= recharge_amount;
2995 /* Recharge wand/staff */
2998 /* Extract a recharge strength by comparing object level to power.
2999 * Divide up a stack of wands' charges to calculate charge penalty.
3001 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3002 recharge_strength = (100 + power - lev -
3003 (8 * o_ptr->pval / o_ptr->number)) / 15;
3005 /* All staffs, unstacked wands. */
3006 else recharge_strength = (100 + power - lev -
3007 (8 * o_ptr->pval)) / 15;
3010 if (recharge_strength < 0) recharge_strength = 0;
3013 if (one_in_(recharge_strength))
3015 /* Activate the failure code. */
3019 /* If the spell didn't backfire, recharge the wand or staff. */
3022 /* Recharge based on the standard number of charges. */
3023 recharge_amount = randint1(1 + k_ptr->pval / 2);
3025 /* Multiple wands in a stack increase recharging somewhat. */
3026 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3029 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3030 if (recharge_amount < 1) recharge_amount = 1;
3031 if (recharge_amount > 12) recharge_amount = 12;
3034 /* But each staff in a stack gets fewer additional charges,
3035 * although always at least one.
3037 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3039 recharge_amount /= o_ptr->number;
3040 if (recharge_amount < 1) recharge_amount = 1;
3043 /* Recharge the wand or staff. */
3044 o_ptr->pval += recharge_amount;
3047 /* Hack -- we no longer "know" the item */
3048 o_ptr->ident &= ~(IDENT_KNOWN);
3050 /* Hack -- we no longer think the item is empty */
3051 o_ptr->ident &= ~(IDENT_EMPTY);
3056 /* Inflict the penalties for failing a recharge. */
3059 /* Artifacts are never destroyed. */
3060 if (artifact_p(o_ptr))
3062 object_desc(o_name, o_ptr, TRUE, 0);
3064 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3066 msg_format("The recharging backfires - %s is completely drained!", o_name);
3070 /* Artifact rods. */
3071 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3072 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3074 /* Artifact wands and staffs. */
3075 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3080 /* Get the object description */
3081 object_desc(o_name, o_ptr, FALSE, 0);
3083 /*** Determine Seriousness of Failure ***/
3085 /* Mages recharge objects more safely. */
3086 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)
3088 /* 10% chance to blow up one rod, otherwise draining. */
3089 if (o_ptr->tval == TV_ROD)
3091 if (one_in_(10)) fail_type = 2;
3094 /* 75% chance to blow up one wand, otherwise draining. */
3095 else if (o_ptr->tval == TV_WAND)
3097 if (!one_in_(3)) fail_type = 2;
3100 /* 50% chance to blow up one staff, otherwise no effect. */
3101 else if (o_ptr->tval == TV_STAFF)
3103 if (one_in_(2)) fail_type = 2;
3108 /* All other classes get no special favors. */
3111 /* 33% chance to blow up one rod, otherwise draining. */
3112 if (o_ptr->tval == TV_ROD)
3114 if (one_in_(3)) fail_type = 2;
3117 /* 20% chance of the entire stack, else destroy one wand. */
3118 else if (o_ptr->tval == TV_WAND)
3120 if (one_in_(5)) fail_type = 3;
3123 /* Blow up one staff. */
3124 else if (o_ptr->tval == TV_STAFF)
3130 /*** Apply draining and destruction. ***/
3132 /* Drain object or stack of objects. */
3135 if (o_ptr->tval == TV_ROD)
3138 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3140 msg_print("The recharge backfires, draining the rod further!");
3143 if (o_ptr->timeout < 10000)
3144 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3146 else if (o_ptr->tval == TV_WAND)
3149 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3151 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3156 /* Staffs aren't drained. */
3159 /* Destroy an object or one in a stack of objects. */
3162 if (o_ptr->number > 1)
3164 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3166 msg_format("Wild magic consumes one of your %s!", o_name);
3171 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3173 msg_format("Wild magic consumes your %s!", o_name);
3177 /* Reduce rod stack maximum timeout, drain wands. */
3178 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3179 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3181 /* Reduce and describe inventory */
3184 inven_item_increase(item, -1);
3185 inven_item_describe(item);
3186 inven_item_optimize(item);
3189 /* Reduce and describe floor item */
3192 floor_item_increase(0 - item, -1);
3193 floor_item_describe(0 - item);
3194 floor_item_optimize(0 - item);
3198 /* Destroy all members of a stack of objects. */
3201 if (o_ptr->number > 1)
3203 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3205 msg_format("Wild magic consumes all your %s!", o_name);
3210 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3212 msg_format("Wild magic consumes your %s!", o_name);
3217 /* Reduce and describe inventory */
3220 inven_item_increase(item, -999);
3221 inven_item_describe(item);
3222 inven_item_optimize(item);
3225 /* Reduce and describe floor item */
3228 floor_item_increase(0 - item, -999);
3229 floor_item_describe(0 - item);
3230 floor_item_optimize(0 - item);
3236 /* Combine / Reorder the pack (later) */
3237 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3240 p_ptr->window |= (PW_INVEN);
3242 /* Something was done */
3250 bool bless_weapon(void)
3254 u32b flgs[TR_FLAG_SIZE];
3255 char o_name[MAX_NLEN];
3258 item_tester_no_ryoute = TRUE;
3259 /* Assume enchant weapon */
3260 item_tester_hook = item_tester_hook_weapon2;
3264 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3265 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3267 q = "Bless which weapon? ";
3268 s = "You have weapon to bless.";
3271 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3274 /* Get the item (in the pack) */
3277 o_ptr = &inventory[item];
3280 /* Get the item (on the floor) */
3283 o_ptr = &o_list[0 - item];
3288 object_desc(o_name, o_ptr, FALSE, 0);
3290 /* Extract the flags */
3291 object_flags(o_ptr, flgs);
3293 if (cursed_p(o_ptr))
3295 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3296 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3299 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3302 msg_format("The black aura on %s %s disrupts the blessing!",
3303 ((item >= 0) ? "your" : "the"), o_name);
3310 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3313 msg_format("A malignant aura leaves %s %s.",
3314 ((item >= 0) ? "your" : "the"), o_name);
3319 o_ptr->curse_flags = 0L;
3321 /* Hack -- Assume felt */
3322 o_ptr->ident |= (IDENT_SENSE);
3325 o_ptr->feeling = FEEL_NONE;
3327 /* Recalculate the bonuses */
3328 p_ptr->update |= (PU_BONUS);
3331 p_ptr->window |= (PW_EQUIP);
3335 * Next, we try to bless it. Artifacts have a 1/3 chance of
3336 * being blessed, otherwise, the operation simply disenchants
3337 * them, godly power negating the magic. Ok, the explanation
3338 * is silly, but otherwise priests would always bless every
3339 * artifact weapon they find. Ego weapons and normal weapons
3340 * can be blessed automatically.
3342 if (have_flag(flgs, TR_BLESSED))
3345 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3348 msg_format("%s %s %s blessed already.",
3349 ((item >= 0) ? "Your" : "The"), o_name,
3350 ((o_ptr->number > 1) ? "were" : "was"));
3356 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3360 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3363 msg_format("%s %s shine%s!",
3364 ((item >= 0) ? "Your" : "The"), o_name,
3365 ((o_ptr->number > 1) ? "" : "s"));
3368 add_flag(o_ptr->art_flags, TR_BLESSED);
3369 o_ptr->discount = 99;
3373 bool dis_happened = FALSE;
3376 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3378 msg_print("The weapon resists your blessing!");
3382 /* Disenchant tohit */
3383 if (o_ptr->to_h > 0)
3386 dis_happened = TRUE;
3389 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3391 /* Disenchant todam */
3392 if (o_ptr->to_d > 0)
3395 dis_happened = TRUE;
3398 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3400 /* Disenchant toac */
3401 if (o_ptr->to_a > 0)
3404 dis_happened = TRUE;
3407 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3412 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3414 msg_print("There is a static feeling in the air...");
3418 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3421 msg_format("%s %s %s disenchanted!",
3422 ((item >= 0) ? "Your" : "The"), o_name,
3423 ((o_ptr->number > 1) ? "were" : "was"));
3429 /* Recalculate bonuses */
3430 p_ptr->update |= (PU_BONUS);
3433 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3444 bool pulish_shield(void)
3448 u32b flgs[TR_FLAG_SIZE];
3449 char o_name[MAX_NLEN];
3452 item_tester_no_ryoute = TRUE;
3453 /* Assume enchant weapon */
3454 item_tester_tval = TV_SHIELD;
3458 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3459 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3461 q = "Pulish which weapon? ";
3462 s = "You have weapon to pulish.";
3465 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3468 /* Get the item (in the pack) */
3471 o_ptr = &inventory[item];
3474 /* Get the item (on the floor) */
3477 o_ptr = &o_list[0 - item];
3482 object_desc(o_name, o_ptr, FALSE, 0);
3484 /* Extract the flags */
3485 object_flags(o_ptr, flgs);
3487 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3488 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3491 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3493 msg_format("%s %s shine%s!",
3494 ((item >= 0) ? "Your" : "The"), o_name,
3495 ((o_ptr->number > 1) ? "" : "s"));
3497 o_ptr->name2 = EGO_REFLECTION;
3498 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3500 o_ptr->discount = 99;
3501 chg_virtue(V_ENCHANT, 2);
3507 if (flush_failure) flush();
3510 msg_print("¼ºÇÔ¤·¤¿¡£");
3512 msg_print("Failed.");
3515 chg_virtue(V_ENCHANT, -2);
3524 * Potions "smash open" and cause an area effect when
3525 * (1) they are shattered while in the player's inventory,
3526 * due to cold (etc) attacks;
3527 * (2) they are thrown at a monster, or obstacle;
3528 * (3) they are shattered by a "cold ball" or other such spell
3529 * while lying on the floor.
3532 * who --- who caused the potion to shatter (0=player)
3533 * potions that smash on the floor are assumed to
3534 * be caused by no-one (who = 1), as are those that
3535 * shatter inside the player inventory.
3536 * (Not anymore -- I changed this; TY)
3537 * y, x --- coordinates of the potion (or player if
3538 * the potion was in her inventory);
3539 * o_ptr --- pointer to the potion object.
3541 bool potion_smash_effect(int who, int y, int x, int k_idx)
3548 object_kind *k_ptr = &k_info[k_idx];
3550 switch (k_ptr->sval)
3552 case SV_POTION_SALT_WATER:
3553 case SV_POTION_SLIME_MOLD:
3554 case SV_POTION_LOSE_MEMORIES:
3555 case SV_POTION_DEC_STR:
3556 case SV_POTION_DEC_INT:
3557 case SV_POTION_DEC_WIS:
3558 case SV_POTION_DEC_DEX:
3559 case SV_POTION_DEC_CON:
3560 case SV_POTION_DEC_CHR:
3561 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3562 case SV_POTION_APPLE_JUICE:
3565 case SV_POTION_INFRAVISION:
3566 case SV_POTION_DETECT_INVIS:
3567 case SV_POTION_SLOW_POISON:
3568 case SV_POTION_CURE_POISON:
3569 case SV_POTION_BOLDNESS:
3570 case SV_POTION_RESIST_HEAT:
3571 case SV_POTION_RESIST_COLD:
3572 case SV_POTION_HEROISM:
3573 case SV_POTION_BESERK_STRENGTH:
3574 case SV_POTION_RES_STR:
3575 case SV_POTION_RES_INT:
3576 case SV_POTION_RES_WIS:
3577 case SV_POTION_RES_DEX:
3578 case SV_POTION_RES_CON:
3579 case SV_POTION_RES_CHR:
3580 case SV_POTION_INC_STR:
3581 case SV_POTION_INC_INT:
3582 case SV_POTION_INC_WIS:
3583 case SV_POTION_INC_DEX:
3584 case SV_POTION_INC_CON:
3585 case SV_POTION_INC_CHR:
3586 case SV_POTION_AUGMENTATION:
3587 case SV_POTION_ENLIGHTENMENT:
3588 case SV_POTION_STAR_ENLIGHTENMENT:
3589 case SV_POTION_SELF_KNOWLEDGE:
3590 case SV_POTION_EXPERIENCE:
3591 case SV_POTION_RESISTANCE:
3592 case SV_POTION_INVULNERABILITY:
3593 case SV_POTION_NEW_LIFE:
3594 /* All of the above potions have no effect when shattered */
3596 case SV_POTION_SLOWNESS:
3601 case SV_POTION_POISON:
3606 case SV_POTION_BLINDNESS:
3610 case SV_POTION_CONFUSION: /* Booze */
3614 case SV_POTION_SLEEP:
3618 case SV_POTION_RUINATION:
3619 case SV_POTION_DETONATIONS:
3621 dam = damroll(25, 25);
3624 case SV_POTION_DEATH:
3625 dt = GF_DEATH_RAY; /* !! */
3626 dam = k_ptr->level * 10;
3630 case SV_POTION_SPEED:
3633 case SV_POTION_CURE_LIGHT:
3635 dam = damroll(2, 3);
3637 case SV_POTION_CURE_SERIOUS:
3639 dam = damroll(4, 3);
3641 case SV_POTION_CURE_CRITICAL:
3642 case SV_POTION_CURING:
3644 dam = damroll(6, 3);
3646 case SV_POTION_HEALING:
3648 dam = damroll(10, 10);
3650 case SV_POTION_RESTORE_EXP:
3655 case SV_POTION_LIFE:
3657 dam = damroll(50, 50);
3660 case SV_POTION_STAR_HEALING:
3662 dam = damroll(50, 50);
3665 case SV_POTION_RESTORE_MANA: /* MANA */
3667 dam = damroll(10, 10);
3674 (void)project(who, radius, y, x, dam, dt,
3675 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3677 /* XXX those potions that explode need to become "known" */
3683 * Hack -- Display all known spells in a window
3685 * XXX XXX XXX Need to analyze size of the window.
3687 * XXX XXX XXX Need more color coding.
3689 void display_spell_list(void)
3702 /* They have too many spells to list */
3703 if (p_ptr->pclass == CLASS_SORCERER) return;
3704 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3706 /* mind.c type classes */
3707 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3708 (p_ptr->pclass == CLASS_BERSERKER) ||
3709 (p_ptr->pclass == CLASS_NINJA) ||
3710 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3711 (p_ptr->pclass == CLASS_FORCETRAINER))
3717 int plev = p_ptr->lev;
3723 bool use_hp = FALSE;
3725 /* Display a list of spells */
3728 put_str("̾Á°", y, x + 5);
3729 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3731 put_str("Name", y, x + 5);
3732 put_str("Lv Mana Fail Info", y, x + 35);
3735 switch(p_ptr->pclass)
3737 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3738 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3739 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3740 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3741 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3742 default: use_mind = 0;break;
3745 /* Dump the spells */
3746 for (i = 0; i < MAX_MIND_POWERS; i++)
3748 byte a = TERM_WHITE;
3750 /* Access the available spell */
3751 spell = mind_powers[use_mind].info[i];
3752 if (spell.min_lev > plev) break;
3754 /* Get the failure rate */
3755 chance = spell.fail;
3757 /* Reduce failure rate by "effective" level adjustment */
3758 chance -= 3 * (p_ptr->lev - spell.min_lev);
3760 /* Reduce failure rate by INT/WIS adjustment */
3761 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3765 /* Not enough mana to cast */
3766 if (spell.mana_cost > p_ptr->csp)
3768 chance += 5 * (spell.mana_cost - p_ptr->csp);
3774 /* Not enough hp to cast */
3775 if (spell.mana_cost > p_ptr->chp)
3782 /* Extract the minimum failure rate */
3783 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3785 /* Minimum failure rate */
3786 if (chance < minfail) chance = minfail;
3788 /* Stunning makes spells harder */
3789 if (p_ptr->stun > 50) chance += 25;
3790 else if (p_ptr->stun) chance += 15;
3792 /* Always a 5 percent chance of working */
3793 if (chance > 95) chance = 95;
3796 mindcraft_info(comment, use_mind, i);
3798 /* Dump the spell */
3799 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3801 spell.min_lev, spell.mana_cost, chance, comment);
3803 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3808 /* Cannot read spellbooks */
3809 if (REALM_NONE == p_ptr->realm1) return;
3811 /* Normal spellcaster with books */
3814 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3818 /* Reset vertical */
3821 /* Vertical location */
3822 y = (j < 3) ? 0 : (m[j - 3] + 2);
3824 /* Horizontal location */
3828 for (i = 0; i < 32; i++)
3830 byte a = TERM_WHITE;
3832 /* Access the spell */
3833 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3835 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3839 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3842 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
3845 if (s_ptr->slevel >= 99)
3849 strcpy(name, "(ȽÆÉÉÔǽ)");
3851 strcpy(name, "(illegible)");
3861 ((p_ptr->spell_forgotten1 & (1L << i))) :
3862 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3869 else if (!((j < 1) ?
3870 (p_ptr->spell_learned1 & (1L << i)) :
3871 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3878 else if (!((j < 1) ?
3879 (p_ptr->spell_worked1 & (1L << i)) :
3880 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3886 /* Dump the spell --(-- */
3887 sprintf(out_val, "%c/%c) %-20.20s",
3888 I2A(n / 8), I2A(n % 8), name);
3893 /* Dump onto the window */
3894 Term_putstr(x, m[j], -1, a, out_val);
3904 * Returns experience of a spell
3906 s16b experience_of_spell(int spell, int use_realm)
3908 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3909 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3910 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3911 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3917 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3919 int mod_need_mana(int need_mana, int spell, int realm)
3921 #define MANA_CONST 2400
3923 #define DEC_MANA_DIV 3
3926 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
3929 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
3930 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
3932 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
3933 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
3934 need_mana /= MANA_CONST * MANA_DIV;
3935 if (need_mana < 1) need_mana = 1;
3938 /* Non-realm magic */
3941 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
3953 * Returns spell chance of failure for spell -RAK-
3955 s16b spell_chance(int spell, int use_realm)
3957 int chance, minfail;
3960 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
3963 /* Paranoia -- must be literate */
3964 if (!mp_ptr->spell_book) return (100);
3966 if (use_realm == REALM_HISSATSU) return 0;
3968 /* Access the spell */
3969 if (!is_magic(use_realm))
3971 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3975 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3978 /* Extract the base spell failure rate */
3979 chance = s_ptr->sfail;
3981 /* Reduce failure rate by "effective" level adjustment */
3982 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
3984 /* Reduce failure rate by INT/WIS adjustment */
3985 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3988 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
3990 /* Extract mana consumption rate */
3991 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3993 /* Not enough mana to cast */
3994 if (need_mana > p_ptr->csp)
3996 chance += 5 * (need_mana - p_ptr->csp);
3999 chance += p_ptr->to_m_chance;
4000 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4002 /* Extract the minimum failure rate */
4003 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4006 * Non mage/priest characters never get too good
4007 * (added high mage, mindcrafter)
4009 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4011 if (minfail < 5) minfail = 5;
4014 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4015 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4016 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4018 if (p_ptr->heavy_spell) chance += 20;
4019 if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
4020 else if (p_ptr->easy_spell) chance-=3;
4021 else if (p_ptr->dec_mana) chance-=2;
4023 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4024 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4025 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4027 /* Minimum failure rate */
4028 if (chance < minfail) chance = minfail;
4030 /* Stunning makes spells harder */
4031 if (p_ptr->stun > 50) chance += 25;
4032 else if (p_ptr->stun) chance += 15;
4034 /* Always a 5 percent chance of working */
4035 if (chance > 95) chance = 95;
4037 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4038 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4040 s16b exp = experience_of_spell(spell, use_realm);
4041 if (exp >= SPELL_EXP_EXPERT) chance--;
4042 if (exp >= SPELL_EXP_MASTER) chance--;
4044 if(p_ptr->dec_mana) chance--;
4045 if (p_ptr->heavy_spell) chance += 5;
4047 chance = MAX(chance,0);
4049 /* Return the chance */
4056 * Determine if a spell is "okay" for the player to cast or study
4057 * The spell must be legible, not forgotten, and also, to cast,
4058 * it must be known, and to study, it must not be known.
4060 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4064 /* Access the spell */
4065 if (!is_magic(use_realm))
4067 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4071 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4074 /* Spell is illegal */
4075 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4077 /* Spell is forgotten */
4078 if ((use_realm == p_ptr->realm2) ?
4079 (p_ptr->spell_forgotten2 & (1L << spell)) :
4080 (p_ptr->spell_forgotten1 & (1L << spell)))
4086 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4087 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4089 /* Spell is learned */
4090 if ((use_realm == p_ptr->realm2) ?
4091 (p_ptr->spell_learned2 & (1L << spell)) :
4092 (p_ptr->spell_learned1 & (1L << spell)))
4095 return (!study_pray);
4098 /* Okay to study, not to cast */
4105 * Extra information on a spell -DRS-
4107 * We can use up to 14 characters of the buffer 'p'
4109 * The strings in this function were extracted from the code in the
4110 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4112 static void spell_info(char *p, int spell, int use_realm)
4114 int plev = p_ptr->lev;
4117 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4118 p_ptr->pclass == CLASS_HIGH_MAGE ||
4119 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4121 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4122 p_ptr->pclass == CLASS_HIGH_MAGE ||
4123 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4125 cptr s_dam = "»½ý:";
4126 cptr s_dur = "´ü´Ö:";
4127 cptr s_range = "ÈÏ°Ï:";
4128 cptr s_heal = "²óÉü:";
4129 cptr s_random = "¥é¥ó¥À¥à";
4130 cptr s_delay = "ÃÙ±ä:";
4132 cptr s_dam = "dam ";
4133 cptr s_dur = "dur ";
4134 cptr s_range = "range ";
4135 cptr s_heal = "heal ";
4136 cptr s_random = "random";
4137 cptr s_delay = "delay ";
4142 /* Analyze the spell */
4145 case REALM_LIFE: /* Life */
4148 case 0: sprintf(p, " %s2d10", s_heal); break;
4149 case 1: sprintf(p, " %s12+d12", s_dur); break;
4150 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4151 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4152 case 5: sprintf(p, " %s4d10", s_heal); break;
4153 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4154 case 10: sprintf(p, " %s8d10", s_heal); break;
4155 case 11: sprintf(p, " %s20+d20", s_dur); break;
4156 case 14: sprintf(p, " %s300", s_heal); break;
4157 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4158 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4159 case 21: sprintf(p, " %s15+d21", s_delay); break;
4160 case 29: sprintf(p, " %s2000", s_heal); break;
4161 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4165 case REALM_SORCERY: /* Sorcery */
4168 case 1: sprintf(p, " %s10", s_range); break;
4169 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4170 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4171 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4172 case 18: sprintf(p, " %s25+d30", s_dur); break;
4173 case 22: sprintf(p, " %s15+d21", s_delay); break;
4174 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4175 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4177 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4179 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4181 case 27: sprintf(p, " %s25+d30", s_dur); break;
4182 case 31: sprintf(p, " %s4+d4", s_dur); break;
4186 case REALM_NATURE: /* Nature */
4190 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4192 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4194 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4195 case 6: sprintf(p, " %s20+d20", s_dur); break;
4196 case 7: sprintf(p, " %s2d8", s_heal); break;
4197 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4198 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4199 case 12: sprintf(p, " %s6d8", s_dam); break;
4200 case 15: sprintf(p, " %s500", s_heal); break;
4201 case 17: sprintf(p, " %s20+d30", s_dur); break;
4202 case 18: sprintf(p, " %s20+d20", s_dur); break;
4204 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4206 case 24: sprintf(p, " rad 10"); break;
4208 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4209 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4210 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4211 case 29: sprintf(p, " %s75", s_dam); break;
4212 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4216 case REALM_CHAOS: /* Chaos */
4219 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4220 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4221 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4222 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4223 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4224 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4225 case 8: sprintf(p, " %s", s_random); break;
4226 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4227 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4228 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4229 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4230 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4231 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4232 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4233 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4234 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4236 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4238 case 25: sprintf(p, " dam %d each", plev * 2); break;
4240 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4241 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4242 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4243 case 30: sprintf(p, " %s%d", s_dam, p_ptr->chp); break;
4244 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4248 case REALM_DEATH: /* Death */
4251 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4252 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4253 case 5: sprintf(p, " %s20+d20", s_dur); break;
4254 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4255 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4256 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4258 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4260 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4262 case 16: sprintf(p, " %s25+d25", s_dur); break;
4263 case 17: sprintf(p, " %s", s_random); break;
4264 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4265 case 19: sprintf(p, " %s25+d25", s_dur); break;
4266 case 21: sprintf(p, " %s3*100", s_dam); break;
4267 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4268 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4269 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4270 case 30: sprintf(p, " %s666", s_dam); break;
4271 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4275 case REALM_TRUMP: /* Trump */
4278 case 0: sprintf(p, " %s10", s_range); break;
4279 case 2: sprintf(p, " %s", s_random); break;
4280 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4281 case 5: sprintf(p, " %s25+d30", s_dur); break;
4283 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4285 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4287 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4288 case 14: sprintf(p, " %s15+d21", s_delay); break;
4289 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4291 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4293 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4298 case REALM_ARCANE: /* Arcane */
4301 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4302 case 4: sprintf(p, " %s10", s_range); break;
4303 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4304 case 7: sprintf(p, " %s2d8", s_heal); break;
4308 case 17: sprintf(p, " %s20+d20", s_dur); break;
4309 case 18: sprintf(p, " %s4d8", s_heal); break;
4310 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4311 case 21: sprintf(p, " %s6d8", s_dam); break;
4312 case 24: sprintf(p, " %s24+d24", s_dur); break;
4313 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4314 case 30: sprintf(p, " %s15+d21", s_delay); break;
4315 case 31: sprintf(p, " %s25+d30", s_dur); break;
4319 case REALM_ENCHANT: /* Craft */
4322 case 0: sprintf(p, " %s100+d100", s_dur); break;
4323 case 1: sprintf(p, " %s80+d80", s_dur); break;
4329 case 18: sprintf(p, " %s20+d20", s_dur); break;
4330 case 5: sprintf(p, " %s25+d25", s_dur); break;
4331 case 8: sprintf(p, " %s24+d24", s_dur); break;
4332 case 11: sprintf(p, " %s25+d25", s_dur); break;
4333 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4334 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4335 case 16: sprintf(p, " %s25+d30", s_dur); break;
4336 case 17: sprintf(p, " %s30+d20", s_dur); break;
4337 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4338 case 20: sprintf(p, " %s50+d50", s_dur); break;
4339 case 23: sprintf(p, " %s20+d20", s_dur); break;
4340 case 31: sprintf(p, " %s13+d13", s_dur); break;
4344 case REALM_DAEMON: /* Daemon */
4347 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4348 case 2: sprintf(p, " %s12+d12", s_dur); break;
4349 case 3: sprintf(p, " %s20+d20", s_dur); break;
4350 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4351 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4352 case 10: sprintf(p, " %s20+d20", s_dur); break;
4353 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4354 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4355 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4356 case 16: sprintf(p, " %s30+d25", s_dur); break;
4357 case 17: sprintf(p, " %s20+d20", s_dur); break;
4358 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4359 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4360 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4361 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4362 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4363 case 24: sprintf(p, " %s25+d25", s_dur); break;
4364 case 25: sprintf(p, " %s20+d20", s_dur); break;
4365 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4366 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4367 case 30: sprintf(p, " %s600", s_dam); break;
4368 case 31: sprintf(p, " %s15+d15", s_dur); break;
4372 case REALM_CRUSADE: /* Crusade */
4375 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4376 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4378 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4380 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4382 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4383 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4384 case 12: sprintf(p, " %s24+d24", s_dur); break;
4385 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4386 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4388 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4390 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4392 case 18: sprintf(p, " %s18+d18", s_dur); break;
4393 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4394 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4395 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4396 case 24: sprintf(p, " %s25+d25", s_dur); break;
4397 case 28: sprintf(p, " %s10+d10", s_dur); break;
4399 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4401 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4404 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4406 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4411 case REALM_MUSIC: /* Music */
4414 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4415 case 4 : sprintf(p, " %s2d6", s_heal); break;
4416 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4417 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4418 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4419 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4420 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4421 case 28: sprintf(p, " %s15d10", s_heal); break;
4422 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4427 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4429 sprintf(p, "Unknown type: %d.", use_realm);
4436 * Print a list of spells (for browsing or casting or viewing)
4438 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4440 int i, spell, exp_level, increment = 64;
4452 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4454 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4456 msg_print("Warning! print_spells called with null realm");
4460 /* Title the list */
4462 if (use_realm == REALM_HISSATSU)
4464 strcpy(buf," Lv MP");
4466 strcpy(buf," Lv SP");
4470 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4472 strcpy(buf,"Profic Lv SP Fail Effect");
4476 put_str("̾Á°", y, x + 5);
4477 put_str(buf, y, x + 29);
4479 put_str("Name", y, x + 5);
4480 put_str(buf, y, x + 29);
4483 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4484 else if (use_realm == p_ptr->realm1) increment = 0;
4485 else if (use_realm == p_ptr->realm2) increment = 32;
4487 /* Dump the spells */
4488 for (i = 0; i < num; i++)
4490 /* Access the spell */
4493 /* Access the spell */
4494 if (!is_magic(use_realm))
4496 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4500 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4503 if (use_realm == REALM_HISSATSU)
4504 need_mana = s_ptr->smana;
4507 s16b exp = experience_of_spell(spell, use_realm);
4509 /* Extract mana consumption rate */
4510 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4512 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4513 else exp_level = spell_exp_level(exp);
4516 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4517 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4518 else if (s_ptr->slevel >= 99) max = TRUE;
4519 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4521 strncpy(ryakuji, exp_level_str[exp_level], 4);
4526 if (use_menu && target_spell)
4528 if (i == (target_spell-1))
4530 strcpy(out_val, " ¡Õ ");
4532 strcpy(out_val, " > ");
4535 strcpy(out_val, " ");
4537 else sprintf(out_val, " %c) ", I2A(i));
4538 /* Skip illegible spells */
4539 if (s_ptr->slevel >= 99)
4542 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4544 strcat(out_val, format("%-30s", "(illegible)"));
4547 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4551 /* XXX XXX Could label spells above the players level */
4553 /* Get extra info */
4554 spell_info(info, spell, use_realm);
4559 /* Assume spell is known and tried */
4560 line_attr = TERM_WHITE;
4562 /* Analyze the spell */
4563 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4565 if (s_ptr->slevel > p_ptr->max_plv)
4570 comment = " unknown";
4573 line_attr = TERM_L_BLUE;
4575 else if (s_ptr->slevel > p_ptr->lev)
4580 comment = " forgotten";
4583 line_attr = TERM_YELLOW;
4586 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4591 comment = " unknown";
4594 line_attr = TERM_L_BLUE;
4596 else if ((use_realm == p_ptr->realm1) ?
4597 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4598 ((p_ptr->spell_forgotten2 & (1L << spell))))
4603 comment = " forgotten";
4606 line_attr = TERM_YELLOW;
4608 else if (!((use_realm == p_ptr->realm1) ?
4609 (p_ptr->spell_learned1 & (1L << spell)) :
4610 (p_ptr->spell_learned2 & (1L << spell))))
4615 comment = " unknown";
4618 line_attr = TERM_L_BLUE;
4620 else if (!((use_realm == p_ptr->realm1) ?
4621 (p_ptr->spell_worked1 & (1L << spell)) :
4622 (p_ptr->spell_worked2 & (1L << spell))))
4625 comment = " ̤·Ð¸³";
4627 comment = " untried";
4630 line_attr = TERM_L_GREEN;
4633 /* Dump the spell --(-- */
4634 if (use_realm == REALM_HISSATSU)
4636 strcat(out_val, format("%-25s %2d %4d",
4637 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4638 s_ptr->slevel, need_mana));
4642 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4643 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4644 (max ? '!' : ' '), ryakuji,
4645 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4647 c_prt(line_attr, out_val, y + i + 1, x);
4650 /* Clear the bottom line */
4651 prt("", y + i + 1, x);
4656 * Note that amulets, rods, and high-level spell books are immune
4657 * to "inventory damage" of any kind. Also sling ammo and shovels.
4662 * Does a given class of objects (usually) hate acid?
4663 * Note that acid can either melt or corrode something.
4665 bool hates_acid(object_type *o_ptr)
4667 /* Analyze the type */
4668 switch (o_ptr->tval)
4670 /* Wearable items */
4690 /* Staffs/Scrolls are wood/paper */
4703 /* Junk is useless */
4717 * Does a given object (usually) hate electricity?
4719 bool hates_elec(object_type *o_ptr)
4721 switch (o_ptr->tval)
4735 * Does a given object (usually) hate fire?
4736 * Hafted/Polearm weapons have wooden shafts.
4737 * Arrows/Bows are mostly wooden.
4739 bool hates_fire(object_type *o_ptr)
4741 /* Analyze the type */
4742 switch (o_ptr->tval)
4760 case TV_SORCERY_BOOK:
4761 case TV_NATURE_BOOK:
4765 case TV_ARCANE_BOOK:
4766 case TV_ENCHANT_BOOK:
4767 case TV_DAEMON_BOOK:
4768 case TV_CRUSADE_BOOK:
4770 case TV_HISSATSU_BOOK:
4781 /* Staffs/Scrolls burn */
4794 * Does a given object (usually) hate cold?
4796 bool hates_cold(object_type *o_ptr)
4798 switch (o_ptr->tval)
4815 int set_acid_destroy(object_type *o_ptr)
4817 u32b flgs[TR_FLAG_SIZE];
4818 if (!hates_acid(o_ptr)) return (FALSE);
4819 object_flags(o_ptr, flgs);
4820 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4828 int set_elec_destroy(object_type *o_ptr)
4830 u32b flgs[TR_FLAG_SIZE];
4831 if (!hates_elec(o_ptr)) return (FALSE);
4832 object_flags(o_ptr, flgs);
4833 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4841 int set_fire_destroy(object_type *o_ptr)
4843 u32b flgs[TR_FLAG_SIZE];
4844 if (!hates_fire(o_ptr)) return (FALSE);
4845 object_flags(o_ptr, flgs);
4846 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4854 int set_cold_destroy(object_type *o_ptr)
4856 u32b flgs[TR_FLAG_SIZE];
4857 if (!hates_cold(o_ptr)) return (FALSE);
4858 object_flags(o_ptr, flgs);
4859 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4865 * Destroys a type of item on a given percent chance
4866 * Note that missiles are no longer necessarily all destroyed
4867 * Destruction taken from "melee.c" code for "stealing".
4868 * New-style wands and rods handled correctly. -LM-
4869 * Returns number of items destroyed.
4871 int inven_damage(inven_func typ, int perc)
4875 char o_name[MAX_NLEN];
4877 /* Multishadow effects is determined by turn */
4878 if( p_ptr->multishadow && (turn & 1) )return 0;
4880 if (p_ptr->inside_arena) return 0;
4882 /* Count the casualties */
4885 /* Scan through the slots backwards */
4886 for (i = 0; i < INVEN_PACK; i++)
4888 o_ptr = &inventory[i];
4890 /* Skip non-objects */
4891 if (!o_ptr->k_idx) continue;
4893 /* Hack -- for now, skip artifacts */
4894 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
4896 /* Give this item slot a shot at death */
4899 /* Count the casualties */
4900 for (amt = j = 0; j < o_ptr->number; ++j)
4902 if (randint0(100) < perc) amt++;
4905 /* Some casualities */
4908 /* Get a description */
4909 object_desc(o_name, o_ptr, FALSE, 3);
4913 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
4915 msg_format("%sour %s (%c) %s destroyed!",
4919 o_name, index_to_label(i),
4920 ((o_ptr->number > 1) ?
4921 ((amt == o_ptr->number) ? "Á´Éô" :
4922 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
4924 ((o_ptr->number > 1) ?
4925 ((amt == o_ptr->number) ? "All of y" :
4926 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4927 o_name, index_to_label(i),
4928 ((amt > 1) ? "were" : "was"));
4932 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4933 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
4936 /* Potions smash open */
4937 if (object_is_potion(o_ptr))
4939 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
4942 /* Reduce the charges of rods/wands */
4943 reduce_charges(o_ptr, amt);
4945 /* Destroy "amt" items */
4946 inven_item_increase(i, -amt);
4947 inven_item_optimize(i);
4949 /* Count the casualties */
4955 /* Return the casualty count */
4961 * Acid has hit the player, attempt to affect some armor.
4963 * Note that the "base armor" of an object never changes.
4965 * If any armor is damaged (or resists), the player takes less damage.
4967 static int minus_ac(void)
4969 object_type *o_ptr = NULL;
4970 u32b flgs[TR_FLAG_SIZE];
4971 char o_name[MAX_NLEN];
4974 /* Pick a (possibly empty) inventory slot */
4975 switch (randint1(7))
4977 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4978 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4979 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4980 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4981 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4982 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4983 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4986 /* Nothing to damage */
4987 if (!o_ptr->k_idx) return (FALSE);
4989 if (o_ptr->tval < TV_BOOTS) return (FALSE);
4991 /* No damage left to be done */
4992 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4996 object_desc(o_name, o_ptr, FALSE, 0);
4998 /* Extract the flags */
4999 object_flags(o_ptr, flgs);
5001 /* Object resists */
5002 if (have_flag(flgs, TR_IGNORE_ACID))
5005 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5007 msg_format("Your %s is unaffected!", o_name);
5016 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5018 msg_format("Your %s is damaged!", o_name);
5022 /* Damage the item */
5025 /* Calculate bonuses */
5026 p_ptr->update |= (PU_BONUS);
5029 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5033 /* Item was damaged */
5039 * Hurt the player with Acid
5041 int acid_dam(int dam, cptr kb_str, int monspell)
5044 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5045 bool double_resist = IS_OPPOSE_ACID();
5047 /* Total Immunity */
5048 if (p_ptr->immune_acid || (dam <= 0))
5050 learn_spell(monspell);
5054 /* Vulnerability (Ouch!) */
5055 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5056 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5058 /* Resist the damage */
5059 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5060 if (double_resist) dam = (dam + 2) / 3;
5062 if ((!(double_resist || p_ptr->resist_acid)) &&
5063 one_in_(HURT_CHANCE))
5064 (void)do_dec_stat(A_CHR);
5066 /* If any armor gets hit, defend the player */
5067 if (minus_ac()) dam = (dam + 1) / 2;
5070 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5072 /* Inventory damage */
5073 if (!(double_resist && p_ptr->resist_acid))
5074 inven_damage(set_acid_destroy, inv);
5080 * Hurt the player with electricity
5082 int elec_dam(int dam, cptr kb_str, int monspell)
5085 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5086 bool double_resist = IS_OPPOSE_ELEC();
5088 /* Total immunity */
5089 if (p_ptr->immune_elec || (dam <= 0))
5091 learn_spell(monspell);
5095 /* Vulnerability (Ouch!) */
5096 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5097 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5098 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5100 /* Resist the damage */
5101 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5102 if (double_resist) dam = (dam + 2) / 3;
5104 if ((!(double_resist || p_ptr->resist_elec)) &&
5105 one_in_(HURT_CHANCE))
5106 (void)do_dec_stat(A_DEX);
5109 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5111 /* Inventory damage */
5112 if (!(double_resist && p_ptr->resist_elec))
5113 inven_damage(set_elec_destroy, inv);
5120 * Hurt the player with Fire
5122 int fire_dam(int dam, cptr kb_str, int monspell)
5125 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5126 bool double_resist = IS_OPPOSE_FIRE();
5128 /* Totally immune */
5129 if (p_ptr->immune_fire || (dam <= 0))
5131 learn_spell(monspell);
5135 /* Vulnerability (Ouch!) */
5136 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5137 if (prace_is_(RACE_ENT)) dam += dam / 3;
5138 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5140 /* Resist the damage */
5141 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5142 if (double_resist) dam = (dam + 2) / 3;
5144 if ((!(double_resist || p_ptr->resist_fire)) &&
5145 one_in_(HURT_CHANCE))
5146 (void)do_dec_stat(A_STR);
5149 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5151 /* Inventory damage */
5152 if (!(double_resist && p_ptr->resist_fire))
5153 inven_damage(set_fire_destroy, inv);
5160 * Hurt the player with Cold
5162 int cold_dam(int dam, cptr kb_str, int monspell)
5165 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5166 bool double_resist = IS_OPPOSE_COLD();
5168 /* Total immunity */
5169 if (p_ptr->immune_cold || (dam <= 0))
5171 learn_spell(monspell);
5175 /* Vulnerability (Ouch!) */
5176 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5177 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5179 /* Resist the damage */
5180 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5181 if (double_resist) dam = (dam + 2) / 3;
5183 if ((!(double_resist || p_ptr->resist_cold)) &&
5184 one_in_(HURT_CHANCE))
5185 (void)do_dec_stat(A_STR);
5188 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5190 /* Inventory damage */
5191 if (!(double_resist && p_ptr->resist_cold))
5192 inven_damage(set_cold_destroy, inv);
5198 bool rustproof(void)
5202 char o_name[MAX_NLEN];
5205 item_tester_no_ryoute = TRUE;
5206 /* Select a piece of armour */
5207 item_tester_hook = item_tester_hook_armour;
5211 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5212 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5214 q = "Rustproof which piece of armour? ";
5215 s = "You have nothing to rustproof.";
5218 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5220 /* Get the item (in the pack) */
5223 o_ptr = &inventory[item];
5226 /* Get the item (on the floor) */
5229 o_ptr = &o_list[0 - item];
5234 object_desc(o_name, o_ptr, FALSE, 0);
5236 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5238 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5241 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5243 msg_format("%s %s look%s as good as new!",
5244 ((item >= 0) ? "Your" : "The"), o_name,
5245 ((o_ptr->number > 1) ? "" : "s"));
5252 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5254 msg_format("%s %s %s now protected against corrosion.",
5255 ((item >= 0) ? "Your" : "The"), o_name,
5256 ((o_ptr->number > 1) ? "are" : "is"));
5267 * Curse the players armor
5269 bool curse_armor(void)
5274 char o_name[MAX_NLEN];
5277 /* Curse the body armor */
5278 o_ptr = &inventory[INVEN_BODY];
5280 /* Nothing to curse */
5281 if (!o_ptr->k_idx) return (FALSE);
5285 object_desc(o_name, o_ptr, FALSE, 3);
5287 /* Attempt a saving throw for artifacts */
5288 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5292 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5293 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5295 msg_format("A %s tries to %s, but your %s resists the effects!",
5296 "terrible black aura", "surround your armor", o_name);
5301 /* not artifact or failed save... */
5306 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5308 msg_format("A terrible black aura blasts your %s!", o_name);
5311 chg_virtue(V_ENCHANT, -5);
5313 /* Blast the armor */
5315 o_ptr->name2 = EGO_BLASTED;
5316 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5323 for (i = 0; i < TR_FLAG_SIZE; i++)
5324 o_ptr->art_flags[i] = 0;
5327 o_ptr->curse_flags = TRC_CURSED;
5330 o_ptr->ident |= (IDENT_BROKEN);
5332 /* Recalculate bonuses */
5333 p_ptr->update |= (PU_BONUS);
5335 /* Recalculate mana */
5336 p_ptr->update |= (PU_MANA);
5339 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5347 * Curse the players weapon
5349 bool curse_weapon(bool force, int slot)
5355 char o_name[MAX_NLEN];
5358 /* Curse the weapon */
5359 o_ptr = &inventory[slot];
5361 /* Nothing to curse */
5362 if (!o_ptr->k_idx) return (FALSE);
5366 object_desc(o_name, o_ptr, FALSE, 3);
5368 /* Attempt a saving throw */
5369 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5373 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5374 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5376 msg_format("A %s tries to %s, but your %s resists the effects!",
5377 "terrible black aura", "surround your weapon", o_name);
5382 /* not artifact or failed save... */
5387 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5389 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5392 chg_virtue(V_ENCHANT, -5);
5394 /* Shatter the weapon */
5396 o_ptr->name2 = EGO_SHATTERED;
5397 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5398 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5404 for (i = 0; i < TR_FLAG_SIZE; i++)
5405 o_ptr->art_flags[i] = 0;
5409 o_ptr->curse_flags = TRC_CURSED;
5412 o_ptr->ident |= (IDENT_BROKEN);
5414 /* Recalculate bonuses */
5415 p_ptr->update |= (PU_BONUS);
5417 /* Recalculate mana */
5418 p_ptr->update |= (PU_MANA);
5421 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5430 * Enchant some bolts
5432 bool brand_bolts(void)
5436 /* Use the first acceptable bolts */
5437 for (i = 0; i < INVEN_PACK; i++)
5439 object_type *o_ptr = &inventory[i];
5441 /* Skip non-bolts */
5442 if (o_ptr->tval != TV_BOLT) continue;
5444 /* Skip artifacts and ego-items */
5445 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5448 /* Skip cursed/broken items */
5449 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5452 if (randint0(100) < 75) continue;
5456 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5458 msg_print("Your bolts are covered in a fiery aura!");
5463 o_ptr->name2 = EGO_FLAME;
5466 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5473 if (flush_failure) flush();
5477 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5479 msg_print("The fiery enchantment failed.");
5489 * Helper function -- return a "nearby" race for polymorphing
5491 * Note that this function is one of the more "dangerous" ones...
5493 static s16b poly_r_idx(int r_idx)
5495 monster_race *r_ptr = &r_info[r_idx];
5497 int i, r, lev1, lev2;
5499 /* Hack -- Uniques/Questors never polymorph */
5500 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5501 (r_ptr->flags1 & RF1_QUESTOR))
5504 /* Allowable range of "levels" for resulting monster */
5505 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5506 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5508 /* Pick a (possibly new) non-unique race */
5509 for (i = 0; i < 1000; i++)
5511 /* Pick a new race, using a level calculation */
5512 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5514 /* Handle failure */
5520 /* Ignore unique monsters */
5521 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5523 /* Ignore monsters with incompatible levels */
5524 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5526 /* Use that index */
5538 bool polymorph_monster(int y, int x)
5540 cave_type *c_ptr = &cave[y][x];
5541 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5542 bool polymorphed = FALSE;
5544 int old_r_idx = m_ptr->r_idx;
5545 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5546 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5547 monster_type back_m;
5549 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5551 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5553 /* Memorize the monster before polymorphing */
5556 /* Pick a "new" monster race */
5557 new_r_idx = poly_r_idx(old_r_idx);
5559 /* Handle polymorph */
5560 if (new_r_idx != old_r_idx)
5564 /* Get the monsters attitude */
5565 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5566 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5567 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5569 /* "Kill" the "old" monster */
5570 delete_monster_idx(c_ptr->m_idx);
5572 /* Create a new monster (no groups) */
5573 if (place_monster_aux(0, y, x, new_r_idx, mode))
5580 /* Placing the new monster failed */
5581 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5582 m_list[hack_m_idx_ii] = back_m;
5585 if (targeted) target_who = hack_m_idx_ii;
5586 if (health_tracked) health_track(hack_m_idx_ii);
5596 bool dimension_door(void)
5598 int plev = p_ptr->lev;
5601 if (!tgt_pt(&x, &y)) return FALSE;
5603 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5605 if (!cave_empty_bold(y, x) || (cave[y][x].info & CAVE_ICKY) ||
5606 (distance(y, x, py, px) > plev / 2 + 10) ||
5607 (!randint0(plev / 10 + 10)))
5609 if( p_ptr->pclass != CLASS_MIRROR_MASTER ){
5611 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5613 msg_print("You fail to exit the astral plane correctly!");
5619 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5621 msg_print("You fail to exit the astral plane correctly!");
5624 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5625 teleport_player((plev+2)*2);
5628 teleport_player_to(y, x, TRUE);
5634 bool eat_magic(int power)
5636 object_type * o_ptr;
5639 int recharge_strength = 0;
5645 char o_name[MAX_NLEN];
5647 item_tester_hook = item_tester_hook_recharge;
5651 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5652 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5654 q = "Drain which item? ";
5655 s = "You have nothing to drain.";
5658 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5662 o_ptr = &inventory[item];
5666 o_ptr = &o_list[0 - item];
5669 k_ptr = &k_info[o_ptr->k_idx];
5670 lev = get_object_level(o_ptr);
5672 if (o_ptr->tval == TV_ROD)
5674 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5677 if (one_in_(recharge_strength))
5679 /* Activate the failure code. */
5684 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5687 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5689 msg_print("You can't absorb energy from a discharged rod.");
5696 o_ptr->timeout += k_ptr->pval;
5702 /* All staffs, wands. */
5703 recharge_strength = (100 + power - lev) / 15;
5706 if (recharge_strength < 0) recharge_strength = 0;
5709 if (one_in_(recharge_strength))
5711 /* Activate the failure code. */
5716 if (o_ptr->pval > 0)
5718 p_ptr->csp += lev / 2;
5721 /* XXX Hack -- unstack if necessary */
5722 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5727 /* Get local object */
5730 /* Obtain a local object */
5731 object_copy(q_ptr, o_ptr);
5733 /* Modify quantity */
5736 /* Restore the charges */
5739 /* Unstack the used item */
5741 p_ptr->total_weight -= q_ptr->weight;
5742 item = inven_carry(q_ptr);
5746 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5748 msg_print("You unstack your staff.");
5756 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5758 msg_print("There's no energy there to absorb!");
5762 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5766 /* Inflict the penalties for failing a recharge. */
5769 /* Artifacts are never destroyed. */
5770 if (artifact_p(o_ptr))
5772 object_desc(o_name, o_ptr, TRUE, 0);
5774 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5776 msg_format("The recharging backfires - %s is completely drained!", o_name);
5780 /* Artifact rods. */
5781 if (o_ptr->tval == TV_ROD)
5782 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5784 /* Artifact wands and staffs. */
5785 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5790 /* Get the object description */
5791 object_desc(o_name, o_ptr, FALSE, 0);
5793 /*** Determine Seriousness of Failure ***/
5795 /* Mages recharge objects more safely. */
5796 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)
5798 /* 10% chance to blow up one rod, otherwise draining. */
5799 if (o_ptr->tval == TV_ROD)
5801 if (one_in_(10)) fail_type = 2;
5804 /* 75% chance to blow up one wand, otherwise draining. */
5805 else if (o_ptr->tval == TV_WAND)
5807 if (!one_in_(3)) fail_type = 2;
5810 /* 50% chance to blow up one staff, otherwise no effect. */
5811 else if (o_ptr->tval == TV_STAFF)
5813 if (one_in_(2)) fail_type = 2;
5818 /* All other classes get no special favors. */
5821 /* 33% chance to blow up one rod, otherwise draining. */
5822 if (o_ptr->tval == TV_ROD)
5824 if (one_in_(3)) fail_type = 2;
5827 /* 20% chance of the entire stack, else destroy one wand. */
5828 else if (o_ptr->tval == TV_WAND)
5830 if (one_in_(5)) fail_type = 3;
5833 /* Blow up one staff. */
5834 else if (o_ptr->tval == TV_STAFF)
5840 /*** Apply draining and destruction. ***/
5842 /* Drain object or stack of objects. */
5845 if (o_ptr->tval == TV_ROD)
5848 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
5850 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
5853 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5855 else if (o_ptr->tval == TV_WAND)
5858 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
5860 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
5865 /* Staffs aren't drained. */
5868 /* Destroy an object or one in a stack of objects. */
5871 if (o_ptr->number > 1)
5874 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
5876 msg_format("Wild magic consumes one of your %s!", o_name);
5879 /* Reduce rod stack maximum timeout, drain wands. */
5880 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5881 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5886 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
5888 msg_format("Wild magic consumes your %s!", o_name);
5891 /* Reduce and describe inventory */
5894 inven_item_increase(item, -1);
5895 inven_item_describe(item);
5896 inven_item_optimize(item);
5899 /* Reduce and describe floor item */
5902 floor_item_increase(0 - item, -1);
5903 floor_item_describe(0 - item);
5904 floor_item_optimize(0 - item);
5908 /* Destroy all members of a stack of objects. */
5911 if (o_ptr->number > 1)
5913 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
5915 msg_format("Wild magic consumes all your %s!", o_name);
5920 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
5922 msg_format("Wild magic consumes your %s!", o_name);
5927 /* Reduce and describe inventory */
5930 inven_item_increase(item, -999);
5931 inven_item_describe(item);
5932 inven_item_optimize(item);
5935 /* Reduce and describe floor item */
5938 floor_item_increase(0 - item, -999);
5939 floor_item_describe(0 - item);
5940 floor_item_optimize(0 - item);
5946 if (p_ptr->csp > p_ptr->msp)
5948 p_ptr->csp = p_ptr->msp;
5951 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5952 p_ptr->window |= (PW_INVEN);
5958 bool summon_kin_player(int level, int y, int x, u32b mode)
5960 bool pet = (bool)(mode & PM_FORCE_PET);
5961 if (!pet) mode |= PM_NO_PET;
5963 switch (p_ptr->mimic_form)
5966 switch (p_ptr->prace)
5970 case RACE_BARBARIAN:
5973 summon_kin_type = 'p';
5983 case RACE_MIND_FLAYER:
5986 summon_kin_type = 'h';
5989 summon_kin_type = 'o';
5991 case RACE_HALF_TROLL:
5992 summon_kin_type = 'T';
5994 case RACE_HALF_OGRE:
5995 summon_kin_type = 'O';
5997 case RACE_HALF_GIANT:
5998 case RACE_HALF_TITAN:
6000 summon_kin_type = 'P';
6003 summon_kin_type = 'y';
6006 summon_kin_type = 'K';
6009 summon_kin_type = 'k';
6012 if (one_in_(13)) summon_kin_type = 'U';
6013 else summon_kin_type = 'u';
6015 case RACE_DRACONIAN:
6016 summon_kin_type = 'd';
6020 summon_kin_type = 'g';
6023 if (one_in_(13)) summon_kin_type = 'L';
6024 else summon_kin_type = 's';
6027 summon_kin_type = 'z';
6030 summon_kin_type = 'V';
6033 summon_kin_type = 'G';
6036 summon_kin_type = 'I';
6039 summon_kin_type = '#';
6042 summon_kin_type = 'A';
6045 summon_kin_type = 'U';
6048 summon_kin_type = 'p';
6053 if (one_in_(13)) summon_kin_type = 'U';
6054 else summon_kin_type = 'u';
6056 case MIMIC_DEMON_LORD:
6057 summon_kin_type = 'U';
6060 summon_kin_type = 'V';
6063 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);