3 /* Purpose: Spell code (part 3) */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
15 /* Maximum number of tries for teleporting */
18 /* 1/x chance of reducing stats (for elemental attacks) */
19 #define HURT_CHANCE 16
23 * Teleport a monster, normally up to "dis" grids away.
25 * Attempt to move the monster at least "dis/2" grids away.
27 * But allow variation to prevent infinite loops.
29 bool teleport_away(int m_idx, int dis, bool dec_valour)
31 int oy, ox, d, i, min;
37 monster_type *m_ptr = &m_list[m_idx];
41 if (!m_ptr->r_idx) return (FALSE);
43 /* Save the old location */
47 /* Minimum distance */
51 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
52 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
54 chg_virtue(V_VALOUR, -1);
62 /* Verify max distance */
63 if (dis > 200) dis = 200;
65 /* Try several locations */
66 for (i = 0; i < 500; i++)
68 /* Pick a (possibly illegal) location */
71 ny = rand_spread(oy, dis);
72 nx = rand_spread(ox, dis);
73 d = distance(oy, ox, ny, nx);
74 if ((d >= min) && (d <= dis)) break;
77 /* Ignore illegal locations */
78 if (!in_bounds(ny, nx)) continue;
80 /* Require "empty" floor space */
81 if (!cave_empty_bold(ny, nx)) continue;
83 /* Hack -- no teleport onto glyph of warding */
84 if (is_glyph_grid(&cave[ny][nx])) continue;
85 if (is_explosive_rune_grid(&cave[ny][nx])) continue;
87 /* ...nor onto the Pattern */
88 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
89 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2)) continue;
91 /* No teleporting into vaults and such */
92 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
93 if (cave[ny][nx].info & CAVE_ICKY) continue;
95 /* This grid looks good */
102 /* Increase the maximum distance */
105 /* Decrease the minimum distance */
108 /* Stop after MAX_TRIES tries */
109 if (tries > MAX_TRIES) return (FALSE);
113 sound(SOUND_TPOTHER);
115 /* Update the new location */
116 cave[ny][nx].m_idx = m_idx;
118 /* Update the old location */
119 cave[oy][ox].m_idx = 0;
121 /* Move the monster */
125 /* Forget the counter target */
128 /* Update the monster (new location) */
129 update_mon(m_idx, TRUE);
131 /* Redraw the old grid */
134 /* Redraw the new grid */
143 * Teleport monster next to the player
145 void teleport_to_player(int m_idx, int power)
147 int ny, nx, oy, ox, d, i, min;
151 monster_type *m_ptr = &m_list[m_idx];
155 if (!m_ptr->r_idx) return;
158 if (randint1(100) > power) return;
164 /* Save the old location */
168 /* Minimum distance */
171 /* Look until done */
172 while (look && --attempts)
174 /* Verify max distance */
175 if (dis > 200) dis = 200;
177 /* Try several locations */
178 for (i = 0; i < 500; i++)
180 /* Pick a (possibly illegal) location */
183 ny = rand_spread(py, dis);
184 nx = rand_spread(px, dis);
185 d = distance(py, px, ny, nx);
186 if ((d >= min) && (d <= dis)) break;
189 /* Ignore illegal locations */
190 if (!in_bounds(ny, nx)) continue;
192 /* Require "empty" floor space */
193 if (!cave_empty_bold(ny, nx)) continue;
195 /* Hack -- no teleport onto glyph of warding */
196 if (is_glyph_grid(&cave[ny][nx])) continue;
197 if (is_explosive_rune_grid(&cave[ny][nx])) continue;
199 /* ...nor onto the Pattern */
200 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
201 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2)) continue;
203 /* No teleporting into vaults and such */
204 /* if (cave[ny][nx].info & (CAVE_ICKY)) continue; */
206 /* This grid looks good */
213 /* Increase the maximum distance */
216 /* Decrease the minimum distance */
220 if (attempts < 1) return;
223 sound(SOUND_TPOTHER);
225 /* Update the new location */
226 cave[ny][nx].m_idx = m_idx;
228 /* Update the old location */
229 cave[oy][ox].m_idx = 0;
231 /* Move the monster */
235 /* Update the monster (new location) */
236 update_mon(m_idx, TRUE);
238 /* Redraw the old grid */
241 /* Redraw the new grid */
244 p_ptr->update |= (PU_MON_LITE);
249 * Teleport the player to a location up to "dis" grids away.
251 * If no such spaces are readily available, the distance may increase.
252 * Try very hard to move the player at least a quarter that distance.
254 * When long-range teleport effects are considered, there is a nasty
255 * tendency to "bounce" the player between two or three different spots
256 * because these are the only spots that are "far enough" way to satisfy
257 * the algorithm. Therefore, if the teleport distance is more than 50,
258 * we decrease the minimum acceptable distance to try to increase randomness.
261 void teleport_player(int dis)
263 int d, i, min, ox, oy;
266 int xx = -1, yy = -1;
274 if (p_ptr->wild_mode) return;
276 if (p_ptr->anti_tele)
279 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
281 msg_print("A mysterious force prevents you from teleporting!");
287 if (dis > 200) dis = 200; /* To be on the safe side... */
289 /* Minimum distance */
290 min = dis / (dis > 50 ? 3 : 2);
292 /* Look until done */
297 /* Verify max distance */
298 if (dis > 200) dis = 200;
300 /* Try several locations */
301 for (i = 0; i < 500; i++)
303 /* Pick a (possibly illegal) location */
306 y = rand_spread(py, dis);
307 x = rand_spread(px, dis);
308 d = distance(py, px, y, x);
309 if ((d >= min) && (d <= dis)) break;
312 /* Ignore illegal locations */
313 if (!in_bounds(y, x)) continue;
315 /* Require "naked" floor space or trees */
316 if (!(cave_naked_bold(y, x) ||
317 (cave[y][x].feat == FEAT_TREES))) continue;
319 /* No teleporting into vaults and such */
320 if (cave[y][x].info & CAVE_ICKY) continue;
322 /* This grid looks good */
329 /* Increase the maximum distance */
332 /* Decrease the minimum distance */
335 /* Stop after MAX_TRIES tries */
336 if (tries > MAX_TRIES) return;
340 sound(SOUND_TELEPORT);
343 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
344 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
347 /* Save the old location */
351 /* Move the player */
358 tmp = cave[py][px].m_idx;
359 cave[py][px].m_idx = cave[oy][ox].m_idx;
360 cave[oy][ox].m_idx = tmp;
361 m_list[p_ptr->riding].fy = py;
362 m_list[p_ptr->riding].fx = px;
363 update_mon(cave[py][px].m_idx, TRUE);
366 /* Redraw the old spot */
369 /* Monsters with teleport ability may follow the player */
376 if (xx == 0 && yy == 0)
382 if (cave[oy+yy][ox+xx].m_idx)
384 if ((r_info[m_list[cave[oy+yy][ox+xx].m_idx].r_idx].flags6 & RF6_TPORT) &&
385 !(r_info[m_list[cave[oy+yy][ox+xx].m_idx].r_idx].flags3 & RF3_RES_TELE))
387 * The latter limitation is to avoid
388 * totally unkillable suckers...
391 if (!(m_list[cave[oy+yy][ox+xx].m_idx].csleep))
392 teleport_to_player(cave[oy+yy][ox+xx].m_idx, r_info[m_list[cave[oy+yy][ox+xx].m_idx].r_idx].level);
403 /* Redraw the new spot */
406 /* Check for new panel (redraw map) */
410 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
412 /* Update the monsters */
413 p_ptr->update |= (PU_DISTANCE);
416 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
418 /* Handle stuff XXX XXX XXX */
425 * Teleport player to a grid near the given location
427 * This function is slightly obsessive about correctness.
428 * This function allows teleporting into vaults (!)
430 void teleport_player_to(int ny, int nx, bool no_tele)
432 int y, x, oy, ox, dis = 0, ctr = 0;
434 if (p_ptr->anti_tele && no_tele)
437 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
439 msg_print("A mysterious force prevents you from teleporting!");
445 /* Find a usable location */
448 /* Pick a nearby legal location */
451 y = rand_spread(ny, dis);
452 x = rand_spread(nx, dis);
453 if (in_bounds(y, x)) break;
456 /* Accept "naked" floor grids */
459 if (cave_naked_bold(y, x) || (((cave[y][x].feat == FEAT_DEEP_LAVA) || (cave[y][x].feat == FEAT_DEEP_WATER)) && !cave[y][x].m_idx)) break;
461 else if (cave_empty_bold(y, x) || ((y == py) && (x == px))) break;
463 /* Occasionally advance the distance */
464 if (++ctr > (4 * dis * dis + 4 * dis + 1))
472 sound(SOUND_TELEPORT);
474 /* Save the old location */
478 /* Move the player */
485 tmp = cave[py][px].m_idx;
486 cave[py][px].m_idx = cave[oy][ox].m_idx;
487 cave[oy][ox].m_idx = tmp;
488 m_list[p_ptr->riding].fy = py;
489 m_list[p_ptr->riding].fx = px;
490 update_mon(cave[py][px].m_idx, TRUE);
495 /* Redraw the old spot */
498 /* Redraw the new spot */
501 /* Check for new panel (redraw map) */
505 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
507 /* Update the monsters */
508 p_ptr->update |= (PU_DISTANCE);
511 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
513 /* Handle stuff XXX XXX XXX */
520 * Teleport the player one level up or down (random when legal)
522 void teleport_player_level(void)
526 /* No effect in arena or quest */
527 if (p_ptr->inside_arena || (p_ptr->inside_quest && !random_quest_number(dun_level)) ||
528 (quest_number(dun_level) && (dun_level > 1) && ironman_downward))
531 msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
533 msg_print("There is no effect.");
539 if (p_ptr->anti_tele)
542 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
544 msg_print("A mysterious force prevents you from teleporting!");
550 /* Choose up or down */
551 if (randint0(100) < 50) go_up = TRUE;
556 if (get_check("Force to go up? ")) go_up = TRUE;
557 else if (get_check("Force to go down? ")) go_up = FALSE;
561 if (ironman_downward || (dun_level <= d_info[dungeon_type].mindepth))
564 msg_print("¤¢¤Ê¤¿¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£");
566 msg_print("You sink through the floor.");
570 dungeon_type = p_ptr->recall_dungeon;
575 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
577 if (autosave_l) do_cmd_save_game(TRUE);
581 dun_level = d_info[dungeon_type].mindepth;
582 prepare_change_floor_mode(CFM_RAND_PLACE | CFM_CLEAR_ALL);
586 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
590 p_ptr->leaving = TRUE;
594 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
597 msg_print("¤¢¤Ê¤¿¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£");
599 msg_print("You rise up through the ceiling.");
603 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
605 if (autosave_l) do_cmd_save_game(TRUE);
607 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
612 p_ptr->inside_quest = 0;
613 p_ptr->leaving = TRUE;
618 msg_print("¤¢¤Ê¤¿¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£");
620 msg_print("You rise up through the ceiling.");
624 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
626 if (autosave_l) do_cmd_save_game(TRUE);
628 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
631 p_ptr->leaving = TRUE;
636 msg_print("¤¢¤Ê¤¿¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£");
638 msg_print("You sink through the floor.");
641 /* Never reach this code on the surface */
642 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
644 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
646 if (autosave_l) do_cmd_save_game(TRUE);
648 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
651 p_ptr->leaving = TRUE;
655 sound(SOUND_TPLEVEL);
660 static int choose_dungeon(cptr note)
666 /* Allocate the "dun" array */
667 C_MAKE(dun, max_d_idx, s16b);
670 for(i = 1; i < max_d_idx; i++)
675 if (!d_info[i].maxdepth) continue;
676 if (!max_dlv[i]) continue;
677 if (d_info[i].final_guardian)
679 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
681 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
684 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
686 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
692 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
694 prt(format("Which dungeon do you %s?: ", note), 0, 0);
701 /* Free the "dun" array */
702 C_KILL(dun, max_d_idx, s16b);
707 if (i >= 'a' && i <('a'+num))
709 select_dungeon = dun[i-'a'];
716 /* Free the "dun" array */
717 C_KILL(dun, max_d_idx, s16b);
719 return select_dungeon;
724 * Recall the player to town or dungeon
726 bool recall_player(int turns)
729 * TODO: Recall the player to the last
730 * visited town when in the wilderness
734 if (p_ptr->inside_arena || ironman_downward)
737 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
739 msg_print("Nothing happens.");
745 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
748 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
750 if (get_check("Reset recall depth? "))
753 max_dlv[dungeon_type] = dun_level;
754 if (record_maxdeapth)
756 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
758 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
763 if (!p_ptr->word_recall)
769 select_dungeon = choose_dungeon("¤Ëµ¢´Ô");
771 select_dungeon = choose_dungeon("recall");
773 if (!select_dungeon) return FALSE;
774 p_ptr->recall_dungeon = select_dungeon;
776 p_ptr->word_recall = turns;
778 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
780 msg_print("The air about you becomes charged...");
783 p_ptr->redraw |= (PR_STATUS);
787 p_ptr->word_recall = 0;
789 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
791 msg_print("A tension leaves the air around you...");
794 p_ptr->redraw |= (PR_STATUS);
800 bool word_of_recall(void)
802 return(recall_player(randint0(21) + 15));
806 bool reset_recall(void)
808 int select_dungeon, dummy = 0;
813 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È");
815 select_dungeon = choose_dungeon("reset");
818 if (!select_dungeon) return FALSE;
821 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
823 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
828 sprintf(tmp_val, "%d", MAX(dun_level, 1));
830 /* Ask for a level */
831 if (get_string(ppp, tmp_val, 10))
833 /* Extract request */
834 dummy = atoi(tmp_val);
837 if (dummy < 1) dummy = 1;
840 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
841 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
843 max_dlv[select_dungeon] = dummy;
845 if (record_maxdeapth)
847 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
849 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
853 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
855 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
868 * Apply disenchantment to the player's stuff
870 * XXX XXX XXX This function is also called from the "melee" code
872 * Return "TRUE" if the player notices anything
874 bool apply_disenchant(int mode)
878 char o_name[MAX_NLEN];
879 int to_h, to_d, to_a, pval;
881 /* Pick a random slot */
884 case 1: t = INVEN_RARM; break;
885 case 2: t = INVEN_LARM; break;
886 case 3: t = INVEN_BOW; break;
887 case 4: t = INVEN_BODY; break;
888 case 5: t = INVEN_OUTER; break;
889 case 6: t = INVEN_HEAD; break;
890 case 7: t = INVEN_HANDS; break;
891 case 8: t = INVEN_FEET; break;
895 o_ptr = &inventory[t];
897 /* No item, nothing happens */
898 if (!o_ptr->k_idx) return (FALSE);
901 /* Nothing to disenchant */
902 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
904 /* Nothing to notice */
909 /* Describe the object */
910 object_desc(o_name, o_ptr, FALSE, 0);
913 /* Artifacts have 71% chance to resist */
914 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 71))
918 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
920 msg_format("Your %s (%c) resist%s disenchantment!",
921 o_name, index_to_label(t),
922 ((o_ptr->number != 1) ? "" : "s"));
931 /* Memorize old value */
937 /* Disenchant tohit */
938 if (o_ptr->to_h > 0) o_ptr->to_h--;
939 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
941 /* Disenchant todam */
942 if (o_ptr->to_d > 0) o_ptr->to_d--;
943 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
945 /* Disenchant toac */
946 if (o_ptr->to_a > 0) o_ptr->to_a--;
947 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
949 /* Disenchant pval (occasionally) */
950 /* Unless called from wild_magic() */
951 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
953 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
954 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
958 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
959 o_name, index_to_label(t) );
961 msg_format("Your %s (%c) %s disenchanted!",
962 o_name, index_to_label(t),
963 ((o_ptr->number != 1) ? "were" : "was"));
966 chg_virtue(V_HARMONY, 1);
967 chg_virtue(V_ENCHANT, -2);
969 /* Recalculate bonuses */
970 p_ptr->update |= (PU_BONUS);
973 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
983 void mutate_player(void)
985 int max1, cur1, max2, cur2, ii, jj, i;
987 /* Pick a pair of stats */
989 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
991 max1 = p_ptr->stat_max[ii];
992 cur1 = p_ptr->stat_cur[ii];
993 max2 = p_ptr->stat_max[jj];
994 cur2 = p_ptr->stat_cur[jj];
996 p_ptr->stat_max[ii] = max2;
997 p_ptr->stat_cur[ii] = cur2;
998 p_ptr->stat_max[jj] = max1;
999 p_ptr->stat_cur[jj] = cur1;
1003 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1004 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1007 p_ptr->update |= (PU_BONUS);
1014 void apply_nexus(monster_type *m_ptr)
1016 switch (randint1(7))
1018 case 1: case 2: case 3:
1020 teleport_player(200);
1026 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE);
1032 if (randint0(100) < p_ptr->skill_sav)
1035 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1037 msg_print("You resist the effects!");
1043 /* Teleport Level */
1044 teleport_player_level();
1050 if (randint0(100) < p_ptr->skill_sav)
1053 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1055 msg_print("You resist the effects!");
1062 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1064 msg_print("Your body starts to scramble...");
1075 * Charge a lite (torch or latern)
1077 void phlogiston(void)
1080 object_type * o_ptr = &inventory[INVEN_LITE];
1083 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1085 max_flog = FUEL_LAMP;
1089 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1091 max_flog = FUEL_TORCH;
1094 /* No torch to refill */
1098 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1100 msg_print("You are not wielding anything which uses phlogiston.");
1106 if (o_ptr->xtra4 >= max_flog)
1109 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1111 msg_print("No more phlogiston can be put in this item.");
1118 o_ptr->xtra4 += (max_flog / 2);
1122 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1124 msg_print("You add phlogiston to your light item.");
1129 if (o_ptr->xtra4 >= max_flog)
1131 o_ptr->xtra4 = max_flog;
1133 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1135 msg_print("Your light item is full.");
1140 /* Recalculate torch */
1141 p_ptr->update |= (PU_TORCH);
1145 static bool item_tester_hook_weapon_nobow(object_type *o_ptr)
1147 switch (o_ptr->tval)
1157 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
1165 * Brand the current weapon
1167 void brand_weapon(int brand_type)
1174 /* Assume enchant weapon */
1175 item_tester_hook = item_tester_hook_weapon_nobow;
1176 item_tester_no_ryoute = TRUE;
1180 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1181 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1183 q = "Enchant which weapon? ";
1184 s = "You have nothing to enchant.";
1187 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1189 /* Get the item (in the pack) */
1192 o_ptr = &inventory[item];
1195 /* Get the item (on the floor) */
1198 o_ptr = &o_list[0 - item];
1202 /* you can never modify artifacts / ego-items */
1203 /* you can never modify cursed items */
1204 /* TY: You _can_ modify broken items (if you're silly enough) */
1205 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
1206 !o_ptr->art_name && !cursed_p(o_ptr) &&
1207 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1208 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1209 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1213 /* Let's get the name before it is changed... */
1214 char o_name[MAX_NLEN];
1215 object_desc(o_name, o_ptr, FALSE, 0);
1220 if (o_ptr->tval == TV_SWORD)
1223 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1225 act = "becomes very sharp!";
1228 o_ptr->name2 = EGO_SHARPNESS;
1229 o_ptr->pval = m_bonus(5, dun_level) + 1;
1234 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1236 act = "seems very powerful.";
1239 o_ptr->name2 = EGO_EARTHQUAKES;
1240 o_ptr->pval = m_bonus(3, dun_level);
1245 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1247 act = "seems to be looking for humans!";
1250 o_ptr->name2 = EGO_SLAY_HUMAN;
1254 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1256 act = "covered with lightning!";
1259 o_ptr->name2 = EGO_BRAND_ELEC;
1263 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1265 act = "coated with acid!";
1268 o_ptr->name2 = EGO_BRAND_ACID;
1272 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1274 act = "seems to be looking for evil monsters!";
1277 o_ptr->name2 = EGO_SLAY_EVIL;
1281 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1283 act = "seems to be looking for demons!";
1286 o_ptr->name2 = EGO_SLAY_DEMON;
1290 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1292 act = "seems to be looking for undead!";
1295 o_ptr->name2 = EGO_SLAY_UNDEAD;
1299 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1301 act = "seems to be looking for animals!";
1304 o_ptr->name2 = EGO_SLAY_ANIMAL;
1308 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1310 act = "seems to be looking for dragons!";
1313 o_ptr->name2 = EGO_SLAY_DRAGON;
1317 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1319 act = "seems to be looking for troll!s";
1322 o_ptr->name2 = EGO_SLAY_TROLL;
1326 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1328 act = "seems to be looking for orcs!";
1331 o_ptr->name2 = EGO_SLAY_ORC;
1335 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1337 act = "seems to be looking for giants!";
1340 o_ptr->name2 = EGO_SLAY_GIANT;
1344 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1346 act = "seems very unstable now.";
1349 o_ptr->name2 = EGO_TRUMP;
1350 o_ptr->pval = randint1(2);
1354 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1356 act = "thirsts for blood!";
1359 o_ptr->name2 = EGO_VAMPIRIC;
1363 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1365 act = "is coated with poison.";
1368 o_ptr->name2 = EGO_BRAND_POIS;
1372 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1374 act = "is engulfed in raw Logrus!";
1377 o_ptr->name2 = EGO_CHAOTIC;
1381 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1383 act = "is covered in a fiery shield!";
1386 o_ptr->name2 = EGO_BRAND_FIRE;
1390 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1392 act = "glows deep, icy blue!";
1395 o_ptr->name2 = EGO_BRAND_COLD;
1400 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1402 msg_format("Your %s %s", o_name, act);
1406 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1408 o_ptr->discount = 99;
1409 chg_virtue(V_ENCHANT, 2);
1413 if (flush_failure) flush();
1416 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1418 msg_print("The Branding failed.");
1421 chg_virtue(V_ENCHANT, -2);
1427 void call_the_(void)
1431 if (cave_floor_bold(py - 1, px - 1) &&
1432 cave_floor_bold(py - 1, px ) &&
1433 cave_floor_bold(py - 1, px + 1) &&
1434 cave_floor_bold(py , px - 1) &&
1435 cave_floor_bold(py , px + 1) &&
1436 cave_floor_bold(py + 1, px - 1) &&
1437 cave_floor_bold(py + 1, px ) &&
1438 cave_floor_bold(py + 1, px + 1))
1440 for (i = 1; i < 10; i++)
1442 if (i-5) fire_ball(GF_ROCKET, i, 175, 2);
1445 for (i = 1; i < 10; i++)
1447 if (i-5) fire_ball(GF_MANA, i, 175, 3);
1450 for (i = 1; i < 10; i++)
1452 if (i-5) fire_ball(GF_NUKE, i, 175, 4);
1458 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1459 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1460 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1462 msg_format("You %s the %s too close to a wall!",
1463 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1464 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1465 msg_print("There is a loud explosion!");
1469 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), TRUE))
1471 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1473 msg_print("The dungeon collapses...");
1478 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1480 msg_print("The dungeon trembles.");
1485 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1487 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1495 * Fetch an item (teleport it right underneath the caster)
1497 void fetch(int dir, int wgt, bool require_los)
1503 char o_name[MAX_NLEN];
1505 /* Check to see if an object is already there */
1506 if (cave[py][px].o_idx)
1509 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1511 msg_print("You can't fetch when you're already standing on something.");
1518 if (dir == 5 && target_okay())
1523 if (distance(py, px, ty, tx) > MAX_RANGE)
1526 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1528 msg_print("You can't fetch something that far away!");
1534 c_ptr = &cave[ty][tx];
1536 /* We need an item to fetch */
1540 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1542 msg_print("There is no object at this place.");
1548 /* No fetching from vault */
1549 if (c_ptr->info & CAVE_ICKY)
1552 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1554 msg_print("The item slips from your control.");
1560 /* We need to see the item */
1561 if (require_los && !player_has_los_bold(ty, tx))
1564 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1566 msg_print("You have no direct line of sight to that location.");
1574 /* Use a direction */
1575 ty = py; /* Where to drop the item */
1583 c_ptr = &cave[ty][tx];
1585 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1586 !cave_floor_bold(ty, tx)) return;
1588 while (!c_ptr->o_idx);
1591 o_ptr = &o_list[c_ptr->o_idx];
1593 if (o_ptr->weight > wgt)
1595 /* Too heavy to 'fetch' */
1597 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1599 msg_print("The object is too heavy.");
1606 c_ptr->o_idx = o_ptr->next_o_idx;
1607 cave[py][px].o_idx = i; /* 'move' it */
1608 o_ptr->next_o_idx = 0;
1609 o_ptr->iy = (byte)py;
1610 o_ptr->ix = (byte)px;
1612 object_desc(o_name, o_ptr, TRUE, 0);
1614 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1616 msg_format("%^s flies through the air to your feet.", o_name);
1621 p_ptr->redraw |= PR_MAP;
1625 void alter_reality(void)
1627 /* Ironman option */
1628 if (p_ptr->inside_arena || ironman_downward)
1631 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1633 msg_print("Nothing happens.");
1638 if (!p_ptr->alter_reality)
1640 int turns = randint0(21) + 15;
1642 p_ptr->alter_reality = turns;
1644 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1646 msg_print("The view around you begins to change...");
1649 p_ptr->redraw |= (PR_STATUS);
1653 p_ptr->alter_reality = 0;
1655 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1657 msg_print("The view around you got back...");
1660 p_ptr->redraw |= (PR_STATUS);
1667 * Leave a "glyph of warding" which prevents monster movement
1669 bool warding_glyph(void)
1672 if (!cave_clean_bold(py, px))
1675 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1677 msg_print("The object resists the spell.");
1683 /* Create a glyph */
1684 cave[py][px].info |= CAVE_OBJECT;
1685 cave[py][px].mimic = FEAT_GLYPH;
1696 bool warding_mirror(void)
1699 if (!cave_clean_bold(py, px))
1702 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1704 msg_print("The object resists the spell.");
1710 /* Create a mirror */
1711 cave[py][px].info |= CAVE_OBJECT;
1712 cave[py][px].mimic = FEAT_MIRROR;
1714 /* Turn on the light */
1715 cave[py][px].info |= CAVE_GLOW;
1728 * Leave an "explosive rune" which prevents monster movement
1730 bool explosive_rune(void)
1733 if (!cave_clean_bold(py, px))
1736 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1738 msg_print("The object resists the spell.");
1744 /* Create a glyph */
1745 cave[py][px].info |= CAVE_OBJECT;
1746 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1759 * Identify everything being carried.
1760 * Done by a potion of "self knowledge".
1762 void identify_pack(void)
1766 /* Simply identify and know every item */
1767 for (i = 0; i < INVEN_TOTAL; i++)
1769 object_type *o_ptr = &inventory[i];
1771 /* Skip non-objects */
1772 if (!o_ptr->k_idx) continue;
1775 identify_item(o_ptr);
1781 * Used by the "enchant" function (chance of failure)
1782 * (modified for Zangband, we need better stuff there...) -- TY
1784 static int enchant_table[16] =
1786 0, 10, 50, 100, 200,
1787 300, 400, 500, 650, 800,
1788 950, 987, 993, 995, 998,
1794 * Removes curses from items in inventory
1796 * Note that Items which are "Perma-Cursed" (The One Ring,
1797 * The Crown of Morgoth) can NEVER be uncursed.
1799 * Note that if "all" is FALSE, then Items which are
1800 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1801 * will not be uncursed.
1803 static int remove_curse_aux(int all)
1807 /* Attempt to uncurse items being worn */
1808 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1810 object_type *o_ptr = &inventory[i];
1812 /* Skip non-objects */
1813 if (!o_ptr->k_idx) continue;
1815 /* Uncursed already */
1816 if (!cursed_p(o_ptr)) continue;
1818 /* Heavily Cursed Items need a special spell */
1819 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1821 /* Perma-Cursed Items can NEVER be uncursed */
1822 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1825 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1830 o_ptr->curse_flags = 0L;
1832 /* Hack -- Assume felt */
1833 o_ptr->ident |= (IDENT_SENSE);
1836 o_ptr->feeling = FEEL_NONE;
1838 /* Recalculate the bonuses */
1839 p_ptr->update |= (PU_BONUS);
1842 p_ptr->window |= (PW_EQUIP);
1844 /* Count the uncursings */
1848 /* Return "something uncursed" */
1854 * Remove most curses
1856 bool remove_curse(void)
1858 return (remove_curse_aux(FALSE));
1864 bool remove_all_curse(void)
1866 return (remove_curse_aux(TRUE));
1871 * Turns an object into gold, gain some of its value in a shop
1880 char o_name[MAX_NLEN];
1881 char out_val[MAX_NLEN+40];
1885 /* Hack -- force destruction */
1886 if (command_arg > 0) force = TRUE;
1890 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
1891 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
1893 q = "Turn which item to gold? ";
1894 s = "You have nothing to turn to gold.";
1897 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
1899 /* Get the item (in the pack) */
1902 o_ptr = &inventory[item];
1905 /* Get the item (on the floor) */
1908 o_ptr = &o_list[0 - item];
1912 /* See how many items */
1913 if (o_ptr->number > 1)
1915 /* Get a quantity */
1916 amt = get_quantity(NULL, o_ptr->number);
1918 /* Allow user abort */
1919 if (amt <= 0) return FALSE;
1923 /* Describe the object */
1924 old_number = o_ptr->number;
1925 o_ptr->number = amt;
1926 object_desc(o_name, o_ptr, TRUE, 3);
1927 o_ptr->number = old_number;
1929 /* Verify unless quantity given */
1932 if (confirm_destroy || (object_value(o_ptr) > 0))
1934 /* Make a verification */
1936 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
1938 sprintf(out_val, "Really turn %s to gold? ", o_name);
1941 if (!get_check(out_val)) return FALSE;
1945 /* Artifacts cannot be destroyed */
1946 if (!can_player_destroy_object(o_ptr))
1950 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
1952 msg_format("You fail to turn %s to gold!", o_name);
1959 price = object_value_real(o_ptr);
1965 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
1967 msg_format("You turn %s to fool's gold.", o_name);
1975 if (amt > 1) price *= amt;
1977 if (price > 30000) price = 30000;
1979 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
1981 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
1987 p_ptr->redraw |= (PR_GOLD);
1990 p_ptr->window |= (PW_PLAYER);
1994 /* Eliminate the item (from the pack) */
1997 inven_item_increase(item, -amt);
1998 inven_item_describe(item);
1999 inven_item_optimize(item);
2002 /* Eliminate the item (from the floor) */
2005 floor_item_increase(0 - item, -amt);
2006 floor_item_describe(0 - item);
2007 floor_item_optimize(0 - item);
2016 * Hook to specify "weapon"
2018 bool item_tester_hook_weapon(object_type *o_ptr)
2020 switch (o_ptr->tval)
2034 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2041 static bool item_tester_hook_weapon2(object_type *o_ptr)
2043 switch (o_ptr->tval)
2063 * Hook to specify "armour"
2065 bool item_tester_hook_armour(object_type *o_ptr)
2067 switch (o_ptr->tval)
2087 static bool item_tester_hook_corpse(object_type *o_ptr)
2089 switch (o_ptr->tval)
2102 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2104 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2106 switch (o_ptr->tval)
2135 * Check if an object is nameless weapon or armour
2137 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2139 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2142 switch (o_ptr->tval)
2171 * Break the curse of an item
2173 static void break_curse(object_type *o_ptr)
2175 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2178 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2180 msg_print("The curse is broken!");
2183 o_ptr->curse_flags = 0L;
2185 o_ptr->ident |= (IDENT_SENSE);
2187 o_ptr->feeling = FEEL_NONE;
2193 * Enchants a plus onto an item. -RAK-
2195 * Revamped! Now takes item pointer, number of times to try enchanting,
2196 * and a flag of what to try enchanting. Artifacts resist enchantment
2197 * some of the time, and successful enchantment to at least +0 might
2198 * break a curse on the item. -CFT-
2200 * Note that an item can technically be enchanted all the way to +15 if
2201 * you wait a very, very, long time. Going from +9 to +10 only works
2202 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2204 * Note that this function can now be used on "piles" of items, and
2205 * the larger the pile, the lower the chance of success.
2207 bool enchant(object_type *o_ptr, int n, int eflag)
2209 int i, chance, prob;
2211 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2212 bool force = (eflag & ENCH_FORCE);
2215 /* Large piles resist enchantment */
2216 prob = o_ptr->number * 100;
2218 /* Missiles are easy to enchant */
2219 if ((o_ptr->tval == TV_BOLT) ||
2220 (o_ptr->tval == TV_ARROW) ||
2221 (o_ptr->tval == TV_SHOT))
2227 for (i = 0; i < n; i++)
2229 /* Hack -- Roll for pile resistance */
2230 if (!force && randint0(prob) >= 100) continue;
2232 /* Enchant to hit */
2233 if (eflag & ENCH_TOHIT)
2235 if (o_ptr->to_h < 0) chance = 0;
2236 else if (o_ptr->to_h > 15) chance = 1000;
2237 else chance = enchant_table[o_ptr->to_h];
2239 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2244 /* only when you get it above -1 -CFT */
2245 if (o_ptr->to_h >= 0)
2250 /* Enchant to damage */
2251 if (eflag & ENCH_TODAM)
2253 if (o_ptr->to_d < 0) chance = 0;
2254 else if (o_ptr->to_d > 15) chance = 1000;
2255 else chance = enchant_table[o_ptr->to_d];
2257 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2262 /* only when you get it above -1 -CFT */
2263 if (o_ptr->to_d >= 0)
2268 /* Enchant to armor class */
2269 if (eflag & ENCH_TOAC)
2271 if (o_ptr->to_a < 0) chance = 0;
2272 else if (o_ptr->to_a > 15) chance = 1000;
2273 else chance = enchant_table[o_ptr->to_a];
2275 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2280 /* only when you get it above -1 -CFT */
2281 if (o_ptr->to_a >= 0)
2288 if (!res) return (FALSE);
2290 /* Recalculate bonuses */
2291 p_ptr->update |= (PU_BONUS);
2293 /* Combine / Reorder the pack (later) */
2294 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2297 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2308 * Enchant an item (in the inventory or on the floor)
2309 * Note that "num_ac" requires armour, else weapon
2310 * Returns TRUE if attempted, FALSE if cancelled
2312 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2317 char o_name[MAX_NLEN];
2321 /* Assume enchant weapon */
2322 item_tester_hook = item_tester_hook_weapon;
2323 item_tester_no_ryoute = TRUE;
2325 /* Enchant armor if requested */
2326 if (num_ac) item_tester_hook = item_tester_hook_armour;
2330 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2331 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2333 q = "Enchant which item? ";
2334 s = "You have nothing to enchant.";
2337 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2339 /* Get the item (in the pack) */
2342 o_ptr = &inventory[item];
2345 /* Get the item (on the floor) */
2348 o_ptr = &o_list[0 - item];
2353 object_desc(o_name, o_ptr, FALSE, 0);
2357 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2360 msg_format("%s %s glow%s brightly!",
2361 ((item >= 0) ? "Your" : "The"), o_name,
2362 ((o_ptr->number > 1) ? "" : "s"));
2367 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2368 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2369 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2375 if (flush_failure) flush();
2379 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2381 msg_print("The enchantment failed.");
2384 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2387 chg_virtue(V_ENCHANT, 1);
2391 /* Something happened */
2396 bool artifact_scroll(void)
2401 char o_name[MAX_NLEN];
2405 item_tester_no_ryoute = TRUE;
2406 /* Enchant weapon/armour */
2407 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2411 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2412 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2414 q = "Enchant which item? ";
2415 s = "You have nothing to enchant.";
2418 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2420 /* Get the item (in the pack) */
2423 o_ptr = &inventory[item];
2426 /* Get the item (on the floor) */
2429 o_ptr = &o_list[0 - item];
2434 object_desc(o_name, o_ptr, FALSE, 0);
2438 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2440 msg_format("%s %s radiate%s a blinding light!",
2441 ((item >= 0) ? "Your" : "The"), o_name,
2442 ((o_ptr->number > 1) ? "" : "s"));
2445 if (o_ptr->name1 || o_ptr->art_name)
2448 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª",
2451 msg_format("The %s %s already %s!",
2452 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2453 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2459 else if (o_ptr->name2)
2462 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª",
2465 msg_format("The %s %s already %s!",
2466 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2467 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2473 else if (o_ptr->xtra3)
2476 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª",
2479 msg_format("The %s %s already %s!",
2480 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2481 ((o_ptr->number > 1) ? "kaji items" : "an kaji item"));
2487 if (o_ptr->number > 1)
2490 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2491 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2493 msg_print("Not enough enough energy to enchant more than one object!");
2494 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2499 inven_item_increase(item, 1-(o_ptr->number));
2503 floor_item_increase(0-item, 1-(o_ptr->number));
2506 okay = create_artifact(o_ptr, TRUE);
2513 if (flush_failure) flush();
2517 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2519 msg_print("The enchantment failed.");
2522 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2525 chg_virtue(V_ENCHANT, 1);
2529 /* Something happened */
2535 * Identify an object
2537 bool identify_item(object_type *o_ptr)
2539 bool old_known = FALSE;
2540 char o_name[MAX_NLEN];
2543 object_desc(o_name, o_ptr, TRUE, 3);
2545 if (o_ptr->ident & IDENT_KNOWN)
2548 if (!(o_ptr->ident & (IDENT_MENTAL)))
2550 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2551 chg_virtue(V_KNOWLEDGE, 1);
2554 /* Identify it fully */
2555 object_aware(o_ptr);
2556 object_known(o_ptr);
2558 /* Recalculate bonuses */
2559 p_ptr->update |= (PU_BONUS);
2561 /* Combine / Reorder the pack (later) */
2562 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2565 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2567 strcpy(record_o_name, o_name);
2571 object_desc(o_name, o_ptr, TRUE, 0);
2573 if(record_fix_art && !old_known && artifact_p(o_ptr))
2574 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2575 if(record_rand_art && !old_known && o_ptr->art_name)
2576 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2582 static bool item_tester_hook_identify(object_type *o_ptr)
2584 return (bool)!object_known_p(o_ptr);
2587 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2589 if (object_known_p(o_ptr))
2591 return item_tester_hook_weapon_armour(o_ptr);
2595 * Identify an object in the inventory (or on the floor)
2596 * This routine does *not* automatically combine objects.
2597 * Returns TRUE if something was identified, else FALSE.
2599 bool ident_spell(bool only_equip)
2603 char o_name[MAX_NLEN];
2608 item_tester_no_ryoute = TRUE;
2611 item_tester_hook = item_tester_hook_identify_weapon_armour;
2613 item_tester_hook = item_tester_hook_identify;
2615 if (!can_get_item())
2619 item_tester_hook = item_tester_hook_weapon_armour;
2623 item_tester_hook = NULL;
2629 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2630 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2632 q = "Identify which item? ";
2633 s = "You have nothing to identify.";
2636 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2638 /* Get the item (in the pack) */
2641 o_ptr = &inventory[item];
2644 /* Get the item (on the floor) */
2647 o_ptr = &o_list[0 - item];
2651 old_known = identify_item(o_ptr);
2654 object_desc(o_name, o_ptr, TRUE, 3);
2657 if (item >= INVEN_RARM)
2660 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2662 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2668 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2670 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2676 msg_format("¾²¾å: %s¡£", o_name);
2678 msg_format("On the ground: %s.", o_name);
2682 /* Auto-inscription/destroy */
2683 idx = is_autopick(o_ptr);
2684 auto_inscribe_item(item, idx);
2685 if (destroy_identify && !old_known)
2686 auto_destroy_item(item, idx);
2688 /* Something happened */
2694 * Mundanify an object in the inventory (or on the floor)
2695 * This routine does *not* automatically combine objects.
2696 * Returns TRUE if something was mundanified, else FALSE.
2698 bool mundane_spell(bool only_equip)
2704 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
2705 item_tester_no_ryoute = TRUE;
2709 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2710 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2712 q = "Use which item? ";
2713 s = "You have nothing you can use.";
2716 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2718 /* Get the item (in the pack) */
2721 o_ptr = &inventory[item];
2724 /* Get the item (on the floor) */
2727 o_ptr = &o_list[0 - item];
2732 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2734 msg_print("There is a bright flash of light!");
2737 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2738 byte ix = o_ptr->ix; /* X-position on map, or zero */
2739 s16b next_o_idx= o_ptr->next_o_idx; /* Next object in stack (if any) */
2740 byte marked=o_ptr->marked; /* Object is marked */
2741 s16b weight = (o_ptr->number*o_ptr->weight);
2744 object_prep(o_ptr, o_ptr->k_idx);
2748 o_ptr->next_o_idx=next_o_idx;
2749 o_ptr->marked=marked;
2750 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2754 /* Something happened */
2760 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2762 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2765 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2767 if (!item_tester_hook_identify_fully(o_ptr))
2769 return item_tester_hook_weapon_armour(o_ptr);
2773 * Fully "identify" an object in the inventory -BEN-
2774 * This routine returns TRUE if an item was identified.
2776 bool identify_fully(bool only_equip)
2780 char o_name[MAX_NLEN];
2785 item_tester_no_ryoute = TRUE;
2787 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2789 item_tester_hook = item_tester_hook_identify_fully;
2791 if (!can_get_item())
2794 item_tester_hook = item_tester_hook_weapon_armour;
2796 item_tester_hook = NULL;
2801 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2802 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2804 q = "Identify which item? ";
2805 s = "You have nothing to identify.";
2808 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2810 /* Get the item (in the pack) */
2813 o_ptr = &inventory[item];
2816 /* Get the item (on the floor) */
2819 o_ptr = &o_list[0 - item];
2823 old_known = identify_item(o_ptr);
2825 /* Mark the item as fully known */
2826 o_ptr->ident |= (IDENT_MENTAL);
2832 object_desc(o_name, o_ptr, TRUE, 3);
2835 if (item >= INVEN_RARM)
2838 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2840 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2848 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2850 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2856 msg_format("¾²¾å: %s¡£", o_name);
2858 msg_format("On the ground: %s.", o_name);
2862 /* Describe it fully */
2863 (void)screen_object(o_ptr, TRUE);
2865 /* Auto-inscription/destroy */
2866 idx = is_autopick(o_ptr);
2867 auto_inscribe_item(item, idx);
2868 if (destroy_identify && !old_known)
2869 auto_destroy_item(item, idx);
2879 * Hook for "get_item()". Determine if something is rechargable.
2881 bool item_tester_hook_recharge(object_type *o_ptr)
2883 /* Recharge staffs */
2884 if (o_ptr->tval == TV_STAFF) return (TRUE);
2886 /* Recharge wands */
2887 if (o_ptr->tval == TV_WAND) return (TRUE);
2889 /* Hack -- Recharge rods */
2890 if (o_ptr->tval == TV_ROD) return (TRUE);
2898 * Recharge a wand/staff/rod from the pack or on the floor.
2899 * This function has been rewritten in Oangband and ZAngband.
2901 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2902 * Chaos -- Arcane Binding --> recharge(90)
2904 * Scroll of recharging --> recharge(130)
2905 * Artifact activation/Thingol --> recharge(130)
2907 * It is harder to recharge high level, and highly charged wands,
2908 * staffs, and rods. The more wands in a stack, the more easily and
2909 * strongly they recharge. Staffs, however, each get fewer charges if
2912 * XXX XXX XXX Beware of "sliding index errors".
2914 bool recharge(int power)
2917 int recharge_strength, recharge_amount;
2926 char o_name[MAX_NLEN];
2928 /* Only accept legal items */
2929 item_tester_hook = item_tester_hook_recharge;
2933 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
2934 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2936 q = "Recharge which item? ";
2937 s = "You have nothing to recharge.";
2940 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2942 /* Get the item (in the pack) */
2945 o_ptr = &inventory[item];
2948 /* Get the item (on the floor) */
2951 o_ptr = &o_list[0 - item];
2954 /* Get the object kind. */
2955 k_ptr = &k_info[o_ptr->k_idx];
2957 /* Extract the object "level" */
2958 lev = get_object_level(o_ptr);
2961 /* Recharge a rod */
2962 if (o_ptr->tval == TV_ROD)
2964 /* Extract a recharge strength by comparing object level to power. */
2965 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
2969 if (one_in_(recharge_strength))
2971 /* Activate the failure code. */
2978 /* Recharge amount */
2979 recharge_amount = (power * damroll(3, 2));
2981 /* Recharge by that amount */
2982 if (o_ptr->timeout > recharge_amount)
2983 o_ptr->timeout -= recharge_amount;
2990 /* Recharge wand/staff */
2993 /* Extract a recharge strength by comparing object level to power.
2994 * Divide up a stack of wands' charges to calculate charge penalty.
2996 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2997 recharge_strength = (100 + power - lev -
2998 (8 * o_ptr->pval / o_ptr->number)) / 15;
3000 /* All staffs, unstacked wands. */
3001 else recharge_strength = (100 + power - lev -
3002 (8 * o_ptr->pval)) / 15;
3005 if (recharge_strength < 0) recharge_strength = 0;
3008 if (one_in_(recharge_strength))
3010 /* Activate the failure code. */
3014 /* If the spell didn't backfire, recharge the wand or staff. */
3017 /* Recharge based on the standard number of charges. */
3018 recharge_amount = randint1(1 + k_ptr->pval / 2);
3020 /* Multiple wands in a stack increase recharging somewhat. */
3021 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3024 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3025 if (recharge_amount < 1) recharge_amount = 1;
3026 if (recharge_amount > 12) recharge_amount = 12;
3029 /* But each staff in a stack gets fewer additional charges,
3030 * although always at least one.
3032 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3034 recharge_amount /= o_ptr->number;
3035 if (recharge_amount < 1) recharge_amount = 1;
3038 /* Recharge the wand or staff. */
3039 o_ptr->pval += recharge_amount;
3042 /* Hack -- we no longer "know" the item */
3043 o_ptr->ident &= ~(IDENT_KNOWN);
3045 /* Hack -- we no longer think the item is empty */
3046 o_ptr->ident &= ~(IDENT_EMPTY);
3051 /* Inflict the penalties for failing a recharge. */
3054 /* Artifacts are never destroyed. */
3055 if (artifact_p(o_ptr))
3057 object_desc(o_name, o_ptr, TRUE, 0);
3059 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3061 msg_format("The recharging backfires - %s is completely drained!", o_name);
3065 /* Artifact rods. */
3066 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3067 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3069 /* Artifact wands and staffs. */
3070 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3075 /* Get the object description */
3076 object_desc(o_name, o_ptr, FALSE, 0);
3078 /*** Determine Seriousness of Failure ***/
3080 /* Mages recharge objects more safely. */
3081 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)
3083 /* 10% chance to blow up one rod, otherwise draining. */
3084 if (o_ptr->tval == TV_ROD)
3086 if (one_in_(10)) fail_type = 2;
3089 /* 75% chance to blow up one wand, otherwise draining. */
3090 else if (o_ptr->tval == TV_WAND)
3092 if (!one_in_(3)) fail_type = 2;
3095 /* 50% chance to blow up one staff, otherwise no effect. */
3096 else if (o_ptr->tval == TV_STAFF)
3098 if (one_in_(2)) fail_type = 2;
3103 /* All other classes get no special favors. */
3106 /* 33% chance to blow up one rod, otherwise draining. */
3107 if (o_ptr->tval == TV_ROD)
3109 if (one_in_(3)) fail_type = 2;
3112 /* 20% chance of the entire stack, else destroy one wand. */
3113 else if (o_ptr->tval == TV_WAND)
3115 if (one_in_(5)) fail_type = 3;
3118 /* Blow up one staff. */
3119 else if (o_ptr->tval == TV_STAFF)
3125 /*** Apply draining and destruction. ***/
3127 /* Drain object or stack of objects. */
3130 if (o_ptr->tval == TV_ROD)
3133 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3135 msg_print("The recharge backfires, draining the rod further!");
3138 if (o_ptr->timeout < 10000)
3139 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3141 else if (o_ptr->tval == TV_WAND)
3144 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3146 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3151 /* Staffs aren't drained. */
3154 /* Destroy an object or one in a stack of objects. */
3157 if (o_ptr->number > 1)
3159 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3161 msg_format("Wild magic consumes one of your %s!", o_name);
3166 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3168 msg_format("Wild magic consumes your %s!", o_name);
3172 /* Reduce rod stack maximum timeout, drain wands. */
3173 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3174 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3176 /* Reduce and describe inventory */
3179 inven_item_increase(item, -1);
3180 inven_item_describe(item);
3181 inven_item_optimize(item);
3184 /* Reduce and describe floor item */
3187 floor_item_increase(0 - item, -1);
3188 floor_item_describe(0 - item);
3189 floor_item_optimize(0 - item);
3193 /* Destroy all members of a stack of objects. */
3196 if (o_ptr->number > 1)
3198 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3200 msg_format("Wild magic consumes all your %s!", o_name);
3205 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3207 msg_format("Wild magic consumes your %s!", o_name);
3212 /* Reduce and describe inventory */
3215 inven_item_increase(item, -999);
3216 inven_item_describe(item);
3217 inven_item_optimize(item);
3220 /* Reduce and describe floor item */
3223 floor_item_increase(0 - item, -999);
3224 floor_item_describe(0 - item);
3225 floor_item_optimize(0 - item);
3231 /* Combine / Reorder the pack (later) */
3232 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3235 p_ptr->window |= (PW_INVEN);
3237 /* Something was done */
3245 bool bless_weapon(void)
3249 u32b flgs[TR_FLAG_SIZE];
3250 char o_name[MAX_NLEN];
3253 item_tester_no_ryoute = TRUE;
3254 /* Assume enchant weapon */
3255 item_tester_hook = item_tester_hook_weapon2;
3259 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3260 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3262 q = "Bless which weapon? ";
3263 s = "You have weapon to bless.";
3266 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3269 /* Get the item (in the pack) */
3272 o_ptr = &inventory[item];
3275 /* Get the item (on the floor) */
3278 o_ptr = &o_list[0 - item];
3283 object_desc(o_name, o_ptr, FALSE, 0);
3285 /* Extract the flags */
3286 object_flags(o_ptr, flgs);
3288 if (cursed_p(o_ptr))
3290 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3291 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3294 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3297 msg_format("The black aura on %s %s disrupts the blessing!",
3298 ((item >= 0) ? "your" : "the"), o_name);
3305 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3308 msg_format("A malignant aura leaves %s %s.",
3309 ((item >= 0) ? "your" : "the"), o_name);
3314 o_ptr->curse_flags = 0L;
3316 /* Hack -- Assume felt */
3317 o_ptr->ident |= (IDENT_SENSE);
3320 o_ptr->feeling = FEEL_NONE;
3322 /* Recalculate the bonuses */
3323 p_ptr->update |= (PU_BONUS);
3326 p_ptr->window |= (PW_EQUIP);
3330 * Next, we try to bless it. Artifacts have a 1/3 chance of
3331 * being blessed, otherwise, the operation simply disenchants
3332 * them, godly power negating the magic. Ok, the explanation
3333 * is silly, but otherwise priests would always bless every
3334 * artifact weapon they find. Ego weapons and normal weapons
3335 * can be blessed automatically.
3337 if (have_flag(flgs, TR_BLESSED))
3340 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3343 msg_format("%s %s %s blessed already.",
3344 ((item >= 0) ? "Your" : "The"), o_name,
3345 ((o_ptr->number > 1) ? "were" : "was"));
3351 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3355 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3358 msg_format("%s %s shine%s!",
3359 ((item >= 0) ? "Your" : "The"), o_name,
3360 ((o_ptr->number > 1) ? "" : "s"));
3363 add_flag(o_ptr->art_flags, TR_BLESSED);
3364 o_ptr->discount = 99;
3368 bool dis_happened = FALSE;
3371 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3373 msg_print("The weapon resists your blessing!");
3377 /* Disenchant tohit */
3378 if (o_ptr->to_h > 0)
3381 dis_happened = TRUE;
3384 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3386 /* Disenchant todam */
3387 if (o_ptr->to_d > 0)
3390 dis_happened = TRUE;
3393 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3395 /* Disenchant toac */
3396 if (o_ptr->to_a > 0)
3399 dis_happened = TRUE;
3402 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3407 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3409 msg_print("There is a static feeling in the air...");
3413 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3416 msg_format("%s %s %s disenchanted!",
3417 ((item >= 0) ? "Your" : "The"), o_name,
3418 ((o_ptr->number > 1) ? "were" : "was"));
3424 /* Recalculate bonuses */
3425 p_ptr->update |= (PU_BONUS);
3428 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3439 bool pulish_shield(void)
3443 u32b flgs[TR_FLAG_SIZE];
3444 char o_name[MAX_NLEN];
3447 item_tester_no_ryoute = TRUE;
3448 /* Assume enchant weapon */
3449 item_tester_tval = TV_SHIELD;
3453 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3454 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3456 q = "Pulish which weapon? ";
3457 s = "You have weapon to pulish.";
3460 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3463 /* Get the item (in the pack) */
3466 o_ptr = &inventory[item];
3469 /* Get the item (on the floor) */
3472 o_ptr = &o_list[0 - item];
3477 object_desc(o_name, o_ptr, FALSE, 0);
3479 /* Extract the flags */
3480 object_flags(o_ptr, flgs);
3482 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3483 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_SHIELD_OF_DEFLECTION))
3486 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3488 msg_format("%s %s shine%s!",
3489 ((item >= 0) ? "Your" : "The"), o_name,
3490 ((o_ptr->number > 1) ? "" : "s"));
3492 o_ptr->name2 = EGO_REFLECTION;
3493 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3495 o_ptr->discount = 99;
3496 chg_virtue(V_ENCHANT, 2);
3502 if (flush_failure) flush();
3505 msg_print("¼ºÇÔ¤·¤¿¡£");
3507 msg_print("Failed.");
3510 chg_virtue(V_ENCHANT, -2);
3519 * Potions "smash open" and cause an area effect when
3520 * (1) they are shattered while in the player's inventory,
3521 * due to cold (etc) attacks;
3522 * (2) they are thrown at a monster, or obstacle;
3523 * (3) they are shattered by a "cold ball" or other such spell
3524 * while lying on the floor.
3527 * who --- who caused the potion to shatter (0=player)
3528 * potions that smash on the floor are assumed to
3529 * be caused by no-one (who = 1), as are those that
3530 * shatter inside the player inventory.
3531 * (Not anymore -- I changed this; TY)
3532 * y, x --- coordinates of the potion (or player if
3533 * the potion was in her inventory);
3534 * o_ptr --- pointer to the potion object.
3536 bool potion_smash_effect(int who, int y, int x, int k_idx)
3544 object_kind *k_ptr = &k_info[k_idx];
3546 switch (k_ptr->sval)
3548 case SV_POTION_SALT_WATER:
3549 case SV_POTION_SLIME_MOLD:
3550 case SV_POTION_LOSE_MEMORIES:
3551 case SV_POTION_DEC_STR:
3552 case SV_POTION_DEC_INT:
3553 case SV_POTION_DEC_WIS:
3554 case SV_POTION_DEC_DEX:
3555 case SV_POTION_DEC_CON:
3556 case SV_POTION_DEC_CHR:
3557 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3558 case SV_POTION_APPLE_JUICE:
3561 case SV_POTION_INFRAVISION:
3562 case SV_POTION_DETECT_INVIS:
3563 case SV_POTION_SLOW_POISON:
3564 case SV_POTION_CURE_POISON:
3565 case SV_POTION_BOLDNESS:
3566 case SV_POTION_RESIST_HEAT:
3567 case SV_POTION_RESIST_COLD:
3568 case SV_POTION_HEROISM:
3569 case SV_POTION_BESERK_STRENGTH:
3570 case SV_POTION_RES_STR:
3571 case SV_POTION_RES_INT:
3572 case SV_POTION_RES_WIS:
3573 case SV_POTION_RES_DEX:
3574 case SV_POTION_RES_CON:
3575 case SV_POTION_RES_CHR:
3576 case SV_POTION_INC_STR:
3577 case SV_POTION_INC_INT:
3578 case SV_POTION_INC_WIS:
3579 case SV_POTION_INC_DEX:
3580 case SV_POTION_INC_CON:
3581 case SV_POTION_INC_CHR:
3582 case SV_POTION_AUGMENTATION:
3583 case SV_POTION_ENLIGHTENMENT:
3584 case SV_POTION_STAR_ENLIGHTENMENT:
3585 case SV_POTION_SELF_KNOWLEDGE:
3586 case SV_POTION_EXPERIENCE:
3587 case SV_POTION_RESISTANCE:
3588 case SV_POTION_INVULNERABILITY:
3589 case SV_POTION_NEW_LIFE:
3590 /* All of the above potions have no effect when shattered */
3592 case SV_POTION_SLOWNESS:
3598 case SV_POTION_POISON:
3604 case SV_POTION_BLINDNESS:
3609 case SV_POTION_CONFUSION: /* Booze */
3614 case SV_POTION_SLEEP:
3619 case SV_POTION_RUINATION:
3620 case SV_POTION_DETONATIONS:
3622 dam = damroll(25, 25);
3626 case SV_POTION_DEATH:
3627 dt = GF_DEATH_RAY; /* !! */
3628 dam = k_ptr->level * 10;
3633 case SV_POTION_SPEED:
3637 case SV_POTION_CURE_LIGHT:
3639 dam = damroll(2, 3);
3642 case SV_POTION_CURE_SERIOUS:
3644 dam = damroll(4, 3);
3647 case SV_POTION_CURE_CRITICAL:
3648 case SV_POTION_CURING:
3650 dam = damroll(6, 3);
3653 case SV_POTION_HEALING:
3655 dam = damroll(10, 10);
3658 case SV_POTION_RESTORE_EXP:
3664 case SV_POTION_LIFE:
3666 dam = damroll(50, 50);
3670 case SV_POTION_STAR_HEALING:
3672 dam = damroll(50, 50);
3676 case SV_POTION_RESTORE_MANA: /* MANA */
3678 dam = damroll(10, 10);
3686 (void)project(who, radius, y, x, dam, dt,
3687 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3689 /* XXX those potions that explode need to become "known" */
3695 * Hack -- Display all known spells in a window
3697 * XXX XXX XXX Need to analyze size of the window.
3699 * XXX XXX XXX Need more color coding.
3701 void display_spell_list(void)
3714 /* They have too many spells to list */
3715 if (p_ptr->pclass == CLASS_SORCERER) return;
3716 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3718 /* mind.c type classes */
3719 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3720 (p_ptr->pclass == CLASS_BERSERKER) ||
3721 (p_ptr->pclass == CLASS_NINJA) ||
3722 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3723 (p_ptr->pclass == CLASS_FORCETRAINER))
3729 int plev = p_ptr->lev;
3735 bool use_hp = FALSE;
3737 /* Display a list of spells */
3740 put_str("̾Á°", y, x + 5);
3741 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3743 put_str("Name", y, x + 5);
3744 put_str("Lv Mana Fail Info", y, x + 35);
3747 switch(p_ptr->pclass)
3749 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3750 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3751 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3752 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3753 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3754 default: use_mind = 0;break;
3757 /* Dump the spells */
3758 for (i = 0; i < MAX_MIND_POWERS; i++)
3760 byte a = TERM_WHITE;
3762 /* Access the available spell */
3763 spell = mind_powers[use_mind].info[i];
3764 if (spell.min_lev > plev) break;
3766 /* Get the failure rate */
3767 chance = spell.fail;
3769 /* Reduce failure rate by "effective" level adjustment */
3770 chance -= 3 * (p_ptr->lev - spell.min_lev);
3772 /* Reduce failure rate by INT/WIS adjustment */
3773 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3777 /* Not enough mana to cast */
3778 if (spell.mana_cost > p_ptr->csp)
3780 chance += 5 * (spell.mana_cost - p_ptr->csp);
3786 /* Not enough hp to cast */
3787 if (spell.mana_cost > p_ptr->chp)
3794 /* Extract the minimum failure rate */
3795 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3797 /* Minimum failure rate */
3798 if (chance < minfail) chance = minfail;
3800 /* Stunning makes spells harder */
3801 if (p_ptr->stun > 50) chance += 25;
3802 else if (p_ptr->stun) chance += 15;
3804 /* Always a 5 percent chance of working */
3805 if (chance > 95) chance = 95;
3808 mindcraft_info(comment, use_mind, i);
3810 /* Dump the spell */
3811 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3813 spell.min_lev, spell.mana_cost, chance, comment);
3815 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3820 /* Cannot read spellbooks */
3821 if (REALM_NONE == p_ptr->realm1) return;
3823 /* Normal spellcaster with books */
3826 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3830 /* Reset vertical */
3833 /* Vertical location */
3834 y = (j < 3) ? 0 : (m[j - 3] + 2);
3836 /* Horizontal location */
3840 for (i = 0; i < 32; i++)
3842 byte a = TERM_WHITE;
3844 /* Access the spell */
3845 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3847 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3851 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3854 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
3857 if (s_ptr->slevel >= 99)
3861 strcpy(name, "(ȽÆÉÉÔǽ)");
3863 strcpy(name, "(illegible)");
3873 ((p_ptr->spell_forgotten1 & (1L << i))) :
3874 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3881 else if (!((j < 1) ?
3882 (p_ptr->spell_learned1 & (1L << i)) :
3883 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3890 else if (!((j < 1) ?
3891 (p_ptr->spell_worked1 & (1L << i)) :
3892 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3898 /* Dump the spell --(-- */
3899 sprintf(out_val, "%c/%c) %-20.20s",
3900 I2A(n / 8), I2A(n % 8), name);
3905 /* Dump onto the window */
3906 Term_putstr(x, m[j], -1, a, out_val);
3916 * Returns experience of a spell
3918 s16b experience_of_spell(int spell, int use_realm)
3920 if (p_ptr->pclass == CLASS_SORCERER) return 1600;
3921 else if (p_ptr->pclass == CLASS_RED_MAGE) return 1200;
3922 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3923 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3929 * Returns spell chance of failure for spell -RAK-
3931 s16b spell_chance(int spell, int use_realm)
3933 int chance, minfail;
3936 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
3939 /* Paranoia -- must be literate */
3940 if (!mp_ptr->spell_book) return (100);
3942 if (use_realm == REALM_HISSATSU) return 0;
3944 /* Access the spell */
3945 if (!is_magic(use_realm))
3947 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3951 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3954 /* Extract the base spell failure rate */
3955 chance = s_ptr->sfail;
3957 /* Reduce failure rate by "effective" level adjustment */
3958 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
3960 /* Reduce failure rate by INT/WIS adjustment */
3961 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3964 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level-p_ptr->skill_exp[GINOU_RIDING]/100-10,0));
3966 /* Extract mana consumption rate */
3967 shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, use_realm)) + 2399;
3969 if(p_ptr->dec_mana) shouhimana *= 3;
3970 else shouhimana *= 4;
3973 if(shouhimana < 1) shouhimana = 1;
3975 /* Not enough mana to cast */
3976 if (shouhimana > p_ptr->csp)
3978 chance += 5 * (shouhimana - p_ptr->csp);
3981 chance += p_ptr->to_m_chance;
3982 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
3984 /* Extract the minimum failure rate */
3985 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3988 * Non mage/priest characters never get too good
3989 * (added high mage, mindcrafter)
3991 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
3993 if (minfail < 5) minfail = 5;
3996 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
3997 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3998 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4000 if (p_ptr->heavy_spell) chance += 20;
4001 if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
4002 else if (p_ptr->easy_spell) chance-=3;
4003 else if (p_ptr->dec_mana) chance-=2;
4005 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4006 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4007 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4009 /* Minimum failure rate */
4010 if (chance < minfail) chance = minfail;
4012 /* Stunning makes spells harder */
4013 if (p_ptr->stun > 50) chance += 25;
4014 else if (p_ptr->stun) chance += 15;
4016 /* Always a 5 percent chance of working */
4017 if (chance > 95) chance = 95;
4019 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2))
4021 s16b exp = experience_of_spell(spell, use_realm);
4022 if(exp > 1399) chance--;
4023 if(exp > 1599) chance--;
4025 if(p_ptr->dec_mana) chance--;
4026 if (p_ptr->heavy_spell) chance += 5;
4028 chance = MAX(chance,0);
4030 /* Return the chance */
4037 * Determine if a spell is "okay" for the player to cast or study
4038 * The spell must be legible, not forgotten, and also, to cast,
4039 * it must be known, and to study, it must not be known.
4041 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4045 /* Access the spell */
4046 if (!is_magic(use_realm))
4048 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4052 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4055 /* Spell is illegal */
4056 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4058 /* Spell is forgotten */
4059 if ((use_realm == p_ptr->realm2) ?
4060 (p_ptr->spell_forgotten2 & (1L << spell)) :
4061 (p_ptr->spell_forgotten1 & (1L << spell)))
4067 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4068 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4070 /* Spell is learned */
4071 if ((use_realm == p_ptr->realm2) ?
4072 (p_ptr->spell_learned2 & (1L << spell)) :
4073 (p_ptr->spell_learned1 & (1L << spell)))
4076 return (!study_pray);
4079 /* Okay to study, not to cast */
4086 * Extra information on a spell -DRS-
4088 * We can use up to 14 characters of the buffer 'p'
4090 * The strings in this function were extracted from the code in the
4091 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4093 static void spell_info(char *p, int spell, int use_realm)
4095 int plev = p_ptr->lev;
4098 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4099 p_ptr->pclass == CLASS_HIGH_MAGE ||
4100 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4102 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4103 p_ptr->pclass == CLASS_HIGH_MAGE ||
4104 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4106 cptr s_dam = "»½ý:";
4107 cptr s_dur = "´ü´Ö:";
4108 cptr s_range = "ÈÏ°Ï:";
4109 cptr s_heal = "²óÉü:";
4110 cptr s_random = "¥é¥ó¥À¥à";
4111 cptr s_delay = "ÃÙ±ä:";
4113 cptr s_dam = "dam ";
4114 cptr s_dur = "dur ";
4115 cptr s_range = "range ";
4116 cptr s_heal = "heal ";
4117 cptr s_random = "random";
4118 cptr s_delay = "delay ";
4123 /* Analyze the spell */
4126 case REALM_LIFE: /* Life */
4129 case 0: sprintf(p, " %s2d10", s_heal); break;
4130 case 1: sprintf(p, " %s12+d12", s_dur); break;
4131 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4132 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4133 case 5: sprintf(p, " %s4d10", s_heal); break;
4134 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4135 case 10: sprintf(p, " %s8d10", s_heal); break;
4136 case 11: sprintf(p, " %s20+d20", s_dur); break;
4137 case 14: sprintf(p, " %s300", s_heal); break;
4138 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4139 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4140 case 21: sprintf(p, " %s15+d21", s_delay); break;
4141 case 29: sprintf(p, " %s2000", s_heal); break;
4142 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4146 case REALM_SORCERY: /* Sorcery */
4149 case 1: sprintf(p, " %s10", s_range); break;
4150 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4151 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4152 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4153 case 18: sprintf(p, " %s25+d30", s_dur); break;
4154 case 22: sprintf(p, " %s15+d21", s_delay); break;
4155 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4156 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4158 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4160 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4162 case 27: sprintf(p, " %s25+d30", s_dur); break;
4163 case 31: sprintf(p, " %s4+d4", s_dur); break;
4167 case REALM_NATURE: /* Nature */
4171 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4173 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4175 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4176 case 6: sprintf(p, " %s20+d20", s_dur); break;
4177 case 7: sprintf(p, " %s2d8", s_heal); break;
4178 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4179 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4180 case 12: sprintf(p, " %s6d8", s_dam); break;
4181 case 15: sprintf(p, " %s500", s_heal); break;
4182 case 17: sprintf(p, " %s20+d30", s_dur); break;
4183 case 18: sprintf(p, " %s20+d20", s_dur); break;
4185 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4187 case 24: sprintf(p, " rad 10"); break;
4189 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4190 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4191 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4192 case 29: sprintf(p, " %s75", s_dam); break;
4193 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4197 case REALM_CHAOS: /* Chaos */
4200 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4201 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4202 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4203 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4204 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4205 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4206 case 8: sprintf(p, " %s", s_random); break;
4207 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4208 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4209 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4210 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4211 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4212 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4213 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4214 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4215 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4217 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4219 case 25: sprintf(p, " dam %d each", plev * 2); break;
4221 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4222 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4223 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4224 case 30: sprintf(p, " %s%d", s_dam, p_ptr->chp); break;
4225 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4229 case REALM_DEATH: /* Death */
4232 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4233 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4234 case 5: sprintf(p, " %s20+d20", s_dur); break;
4235 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4236 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4237 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4239 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4241 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4243 case 16: sprintf(p, " %s25+d25", s_dur); break;
4244 case 17: sprintf(p, " %s", s_random); break;
4245 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4246 case 19: sprintf(p, " %s25+d25", s_dur); break;
4247 case 21: sprintf(p, " %s3*100", s_dam); break;
4248 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4249 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4250 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4251 case 30: sprintf(p, " %s666", s_dam); break;
4252 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4256 case REALM_TRUMP: /* Trump */
4259 case 0: sprintf(p, " %s10", s_range); break;
4260 case 2: sprintf(p, " %s", s_random); break;
4261 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4262 case 5: sprintf(p, " %s25+d30", s_dur); break;
4264 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4266 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4268 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4269 case 14: sprintf(p, " %s15+d21", s_delay); break;
4270 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4272 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4274 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4279 case REALM_ARCANE: /* Arcane */
4282 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4283 case 4: sprintf(p, " %s10", s_range); break;
4284 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4285 case 7: sprintf(p, " %s2d8", s_heal); break;
4289 case 17: sprintf(p, " %s20+d20", s_dur); break;
4290 case 18: sprintf(p, " %s4d8", s_heal); break;
4291 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4292 case 21: sprintf(p, " %s6d8", s_dam); break;
4293 case 24: sprintf(p, " %s24+d24", s_dur); break;
4294 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4295 case 30: sprintf(p, " %s15+d21", s_delay); break;
4296 case 31: sprintf(p, " %s25+d30", s_dur); break;
4300 case REALM_ENCHANT: /* Craft */
4303 case 0: sprintf(p, " %s100+d100", s_dur); break;
4304 case 1: sprintf(p, " %s80+d80", s_dur); break;
4310 case 18: sprintf(p, " %s20+d20", s_dur); break;
4311 case 5: sprintf(p, " %s25+d25", s_dur); break;
4312 case 8: sprintf(p, " %s24+d24", s_dur); break;
4313 case 11: sprintf(p, " %s25+d25", s_dur); break;
4314 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4315 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4316 case 16: sprintf(p, " %s25+d30", s_dur); break;
4317 case 17: sprintf(p, " %s30+d20", s_dur); break;
4318 case 19: sprintf(p, " %s%d+d%d", s_dur, plev+20, plev); break;
4319 case 20: sprintf(p, " %s50+d50", s_dur); break;
4320 case 23: sprintf(p, " %s20+d20", s_dur); break;
4321 case 31: sprintf(p, " %s13+d13", s_dur); break;
4325 case REALM_DAEMON: /* Daemon */
4328 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4329 case 2: sprintf(p, " %s12+d12", s_dur); break;
4330 case 3: sprintf(p, " %s20+d20", s_dur); break;
4331 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4332 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4333 case 10: sprintf(p, " %s20+d20", s_dur); break;
4334 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4335 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4336 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4337 case 16: sprintf(p, " %s30+d25", s_dur); break;
4338 case 17: sprintf(p, " %s20+d20", s_dur); break;
4339 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4340 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4341 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4342 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4343 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4344 case 24: sprintf(p, " %s25+d25", s_dur); break;
4345 case 25: sprintf(p, " %s20+d20", s_dur); break;
4346 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4347 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4348 case 30: sprintf(p, " %s600", s_dam); break;
4349 case 31: sprintf(p, " %s15+d15", s_dur); break;
4353 case REALM_CRUSADE: /* Crusade */
4356 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4357 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4359 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4361 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4363 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4364 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4365 case 12: sprintf(p, " %s24+d24", s_dur); break;
4366 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4367 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4369 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4371 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4373 case 18: sprintf(p, " %s18+d18", s_dur); break;
4374 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4375 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4376 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4377 case 24: sprintf(p, " %s25+d25", s_dur); break;
4378 case 28: sprintf(p, " %s10+d10", s_dur); break;
4380 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4382 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4385 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4387 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4392 case REALM_MUSIC: /* Music */
4395 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4396 case 4 : sprintf(p, " %s2d6", s_heal); break;
4397 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4398 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4399 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4400 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4401 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4402 case 28: sprintf(p, " %s15d10", s_heal); break;
4403 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4408 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4410 sprintf(p, "Unknown type: %d.", use_realm);
4417 * Print a list of spells (for browsing or casting or viewing)
4419 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4421 int i, spell, shougou, increment = 64;
4433 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4435 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4437 msg_print("Warning! print_spells called with null realm");
4441 /* Title the list */
4443 if (use_realm == REALM_HISSATSU)
4445 strcpy(buf," Lv MP");
4447 strcpy(buf," Lv SP");
4451 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4453 strcpy(buf,"Profic Lv SP Fail Effect");
4457 put_str("̾Á°", y, x + 5);
4458 put_str(buf, y, x + 29);
4460 put_str("Name", y, x + 5);
4461 put_str(buf, y, x + 29);
4464 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4465 else if (use_realm == p_ptr->realm1) increment = 0;
4466 else if (use_realm == p_ptr->realm2) increment = 32;
4468 /* Dump the spells */
4469 for (i = 0; i < num; i++)
4471 /* Access the spell */
4474 /* Access the spell */
4475 if (!is_magic(use_realm))
4477 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4481 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4484 if (use_realm == REALM_HISSATSU)
4485 shouhimana = s_ptr->smana;
4488 s16b exp = experience_of_spell(spell, use_realm);
4490 /* Extract mana consumption rate */
4491 shouhimana = s_ptr->smana*(3800 - exp) + 2399;
4493 if(p_ptr->dec_mana) shouhimana *= 3;
4494 else shouhimana *= 4;
4497 if(shouhimana < 1) shouhimana = 1;
4499 if ((increment == 64) || (s_ptr->slevel >= 99)) shougou = 0;
4500 else if (exp < 900) shougou = 0;
4501 else if (exp < 1200) shougou = 1;
4502 else if (exp < 1400) shougou = 2;
4503 else if (exp < 1600) shougou = 3;
4507 if (!increment && (shougou == 4)) max = TRUE;
4508 else if ((increment == 32) && (shougou == 3)) max = TRUE;
4509 else if (s_ptr->slevel >= 99) max = TRUE;
4510 else if (p_ptr->pclass == CLASS_RED_MAGE) max = TRUE;
4512 strncpy(ryakuji,shougou_moji[shougou],4);
4517 if (use_menu && target_spell)
4519 if (i == (target_spell-1))
4521 strcpy(out_val, " ¡Õ ");
4523 strcpy(out_val, " > ");
4526 strcpy(out_val, " ");
4528 else sprintf(out_val, " %c) ", I2A(i));
4529 /* Skip illegible spells */
4530 if (s_ptr->slevel >= 99)
4533 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4535 strcat(out_val, format("%-30s", "(illegible)"));
4538 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4542 /* XXX XXX Could label spells above the players level */
4544 /* Get extra info */
4545 spell_info(info, spell, use_realm);
4550 /* Assume spell is known and tried */
4551 line_attr = TERM_WHITE;
4553 /* Analyze the spell */
4554 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4556 if (s_ptr->slevel > p_ptr->max_plv)
4561 comment = " unknown";
4564 line_attr = TERM_L_BLUE;
4566 else if (s_ptr->slevel > p_ptr->lev)
4571 comment = " forgotten";
4574 line_attr = TERM_YELLOW;
4577 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4582 comment = " unknown";
4585 line_attr = TERM_L_BLUE;
4587 else if ((use_realm == p_ptr->realm1) ?
4588 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4589 ((p_ptr->spell_forgotten2 & (1L << spell))))
4594 comment = " forgotten";
4597 line_attr = TERM_YELLOW;
4599 else if (!((use_realm == p_ptr->realm1) ?
4600 (p_ptr->spell_learned1 & (1L << spell)) :
4601 (p_ptr->spell_learned2 & (1L << spell))))
4606 comment = " unknown";
4609 line_attr = TERM_L_BLUE;
4611 else if (!((use_realm == p_ptr->realm1) ?
4612 (p_ptr->spell_worked1 & (1L << spell)) :
4613 (p_ptr->spell_worked2 & (1L << spell))))
4616 comment = " ̤·Ð¸³";
4618 comment = " untried";
4621 line_attr = TERM_L_GREEN;
4624 /* Dump the spell --(-- */
4625 if (use_realm == REALM_HISSATSU)
4627 strcat(out_val, format("%-25s %2d %4d",
4628 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4629 s_ptr->slevel, shouhimana));
4633 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4634 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4635 (max ? '!' : ' '), ryakuji,
4636 s_ptr->slevel, shouhimana, spell_chance(spell, use_realm), comment));
4638 c_prt(line_attr, out_val, y + i + 1, x);
4641 /* Clear the bottom line */
4642 prt("", y + i + 1, x);
4647 * Note that amulets, rods, and high-level spell books are immune
4648 * to "inventory damage" of any kind. Also sling ammo and shovels.
4653 * Does a given class of objects (usually) hate acid?
4654 * Note that acid can either melt or corrode something.
4656 bool hates_acid(object_type *o_ptr)
4658 /* Analyze the type */
4659 switch (o_ptr->tval)
4661 /* Wearable items */
4681 /* Staffs/Scrolls are wood/paper */
4694 /* Junk is useless */
4708 * Does a given object (usually) hate electricity?
4710 bool hates_elec(object_type *o_ptr)
4712 switch (o_ptr->tval)
4726 * Does a given object (usually) hate fire?
4727 * Hafted/Polearm weapons have wooden shafts.
4728 * Arrows/Bows are mostly wooden.
4730 bool hates_fire(object_type *o_ptr)
4732 /* Analyze the type */
4733 switch (o_ptr->tval)
4751 case TV_SORCERY_BOOK:
4752 case TV_NATURE_BOOK:
4756 case TV_ARCANE_BOOK:
4757 case TV_ENCHANT_BOOK:
4758 case TV_DAEMON_BOOK:
4759 case TV_CRUSADE_BOOK:
4761 case TV_HISSATSU_BOOK:
4772 /* Staffs/Scrolls burn */
4785 * Does a given object (usually) hate cold?
4787 bool hates_cold(object_type *o_ptr)
4789 switch (o_ptr->tval)
4806 int set_acid_destroy(object_type *o_ptr)
4808 u32b flgs[TR_FLAG_SIZE];
4809 if (!hates_acid(o_ptr)) return (FALSE);
4810 object_flags(o_ptr, flgs);
4811 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4819 int set_elec_destroy(object_type *o_ptr)
4821 u32b flgs[TR_FLAG_SIZE];
4822 if (!hates_elec(o_ptr)) return (FALSE);
4823 object_flags(o_ptr, flgs);
4824 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4832 int set_fire_destroy(object_type *o_ptr)
4834 u32b flgs[TR_FLAG_SIZE];
4835 if (!hates_fire(o_ptr)) return (FALSE);
4836 object_flags(o_ptr, flgs);
4837 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4845 int set_cold_destroy(object_type *o_ptr)
4847 u32b flgs[TR_FLAG_SIZE];
4848 if (!hates_cold(o_ptr)) return (FALSE);
4849 object_flags(o_ptr, flgs);
4850 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4856 * Destroys a type of item on a given percent chance
4857 * Note that missiles are no longer necessarily all destroyed
4858 * Destruction taken from "melee.c" code for "stealing".
4859 * New-style wands and rods handled correctly. -LM-
4860 * Returns number of items destroyed.
4862 int inven_damage(inven_func typ, int perc)
4866 char o_name[MAX_NLEN];
4868 /* Multishadow effects is determined by turn */
4869 if( p_ptr->multishadow && (turn & 1) )return 0;
4871 if (p_ptr->inside_arena) return 0;
4873 /* Count the casualties */
4876 /* Scan through the slots backwards */
4877 for (i = 0; i < INVEN_PACK; i++)
4879 o_ptr = &inventory[i];
4881 /* Skip non-objects */
4882 if (!o_ptr->k_idx) continue;
4884 /* Hack -- for now, skip artifacts */
4885 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
4887 /* Give this item slot a shot at death */
4890 /* Count the casualties */
4891 for (amt = j = 0; j < o_ptr->number; ++j)
4893 if (randint0(100) < perc) amt++;
4896 /* Some casualities */
4899 /* Get a description */
4900 object_desc(o_name, o_ptr, FALSE, 3);
4904 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
4906 msg_format("%sour %s (%c) %s destroyed!",
4910 o_name, index_to_label(i),
4911 ((o_ptr->number > 1) ?
4912 ((amt == o_ptr->number) ? "Á´Éô" :
4913 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
4915 ((o_ptr->number > 1) ?
4916 ((amt == o_ptr->number) ? "All of y" :
4917 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4918 o_name, index_to_label(i),
4919 ((amt > 1) ? "were" : "was"));
4923 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4924 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
4927 /* Potions smash open */
4928 if (object_is_potion(o_ptr))
4930 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
4933 /* Reduce the charges of rods/wands */
4934 reduce_charges(o_ptr, amt);
4936 /* Destroy "amt" items */
4937 inven_item_increase(i, -amt);
4938 inven_item_optimize(i);
4940 /* Count the casualties */
4946 /* Return the casualty count */
4952 * Acid has hit the player, attempt to affect some armor.
4954 * Note that the "base armor" of an object never changes.
4956 * If any armor is damaged (or resists), the player takes less damage.
4958 static int minus_ac(void)
4960 object_type *o_ptr = NULL;
4961 u32b flgs[TR_FLAG_SIZE];
4962 char o_name[MAX_NLEN];
4965 /* Pick a (possibly empty) inventory slot */
4966 switch (randint1(7))
4968 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4969 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4970 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4971 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4972 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4973 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4974 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4977 /* Nothing to damage */
4978 if (!o_ptr->k_idx) return (FALSE);
4980 if (o_ptr->tval < TV_BOOTS) return (FALSE);
4982 /* No damage left to be done */
4983 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4987 object_desc(o_name, o_ptr, FALSE, 0);
4989 /* Extract the flags */
4990 object_flags(o_ptr, flgs);
4992 /* Object resists */
4993 if (have_flag(flgs, TR_IGNORE_ACID))
4996 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
4998 msg_format("Your %s is unaffected!", o_name);
5007 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5009 msg_format("Your %s is damaged!", o_name);
5013 /* Damage the item */
5016 /* Calculate bonuses */
5017 p_ptr->update |= (PU_BONUS);
5020 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5024 /* Item was damaged */
5030 * Hurt the player with Acid
5032 int acid_dam(int dam, cptr kb_str, int monspell)
5035 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5036 bool double_resist = (p_ptr->oppose_acid || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
5038 /* Total Immunity */
5039 if (p_ptr->immune_acid || (dam <= 0))
5041 learn_spell(monspell);
5045 /* Vulnerability (Ouch!) */
5046 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5047 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5049 /* Resist the damage */
5050 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5051 if (double_resist) dam = (dam + 2) / 3;
5053 if ((!(double_resist || p_ptr->resist_acid)) &&
5054 one_in_(HURT_CHANCE))
5055 (void)do_dec_stat(A_CHR);
5057 /* If any armor gets hit, defend the player */
5058 if (minus_ac()) dam = (dam + 1) / 2;
5061 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5063 /* Inventory damage */
5064 if (!(double_resist && p_ptr->resist_acid))
5065 inven_damage(set_acid_destroy, inv);
5071 * Hurt the player with electricity
5073 int elec_dam(int dam, cptr kb_str, int monspell)
5076 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5077 bool double_resist = (p_ptr->oppose_elec || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
5079 /* Total immunity */
5080 if (p_ptr->immune_elec || (dam <= 0))
5082 learn_spell(monspell);
5086 /* Vulnerability (Ouch!) */
5087 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5088 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5089 if (p_ptr->prace == RACE_ANDROID) dam += dam / 3;
5091 /* Resist the damage */
5092 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5093 if (double_resist) dam = (dam + 2) / 3;
5095 if ((!(double_resist || p_ptr->resist_elec)) &&
5096 one_in_(HURT_CHANCE))
5097 (void)do_dec_stat(A_DEX);
5100 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5102 /* Inventory damage */
5103 if (!(double_resist && p_ptr->resist_elec))
5104 inven_damage(set_elec_destroy, inv);
5111 * Hurt the player with Fire
5113 int fire_dam(int dam, cptr kb_str, int monspell)
5116 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5117 bool double_resist = (p_ptr->oppose_fire || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
5119 /* Totally immune */
5120 if (p_ptr->immune_fire || (dam <= 0))
5122 learn_spell(monspell);
5126 /* Vulnerability (Ouch!) */
5127 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5128 if (prace_is_(RACE_ENT)) dam += dam / 3;
5129 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5131 /* Resist the damage */
5132 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5133 if (double_resist) dam = (dam + 2) / 3;
5135 if ((!(double_resist || p_ptr->resist_fire)) &&
5136 one_in_(HURT_CHANCE))
5137 (void)do_dec_stat(A_STR);
5140 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5142 /* Inventory damage */
5143 if (!(double_resist && p_ptr->resist_fire))
5144 inven_damage(set_fire_destroy, inv);
5151 * Hurt the player with Cold
5153 int cold_dam(int dam, cptr kb_str, int monspell)
5156 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5157 bool double_resist = (p_ptr->oppose_cold || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
5159 /* Total immunity */
5160 if (p_ptr->immune_cold || (dam <= 0))
5162 learn_spell(monspell);
5166 /* Vulnerability (Ouch!) */
5167 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5168 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5170 /* Resist the damage */
5171 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5172 if (double_resist) dam = (dam + 2) / 3;
5174 if ((!(double_resist || p_ptr->resist_cold)) &&
5175 one_in_(HURT_CHANCE))
5176 (void)do_dec_stat(A_STR);
5179 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5181 /* Inventory damage */
5182 if (!(double_resist && p_ptr->resist_cold))
5183 inven_damage(set_cold_destroy, inv);
5189 bool rustproof(void)
5193 char o_name[MAX_NLEN];
5196 item_tester_no_ryoute = TRUE;
5197 /* Select a piece of armour */
5198 item_tester_hook = item_tester_hook_armour;
5202 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5203 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5205 q = "Rustproof which piece of armour? ";
5206 s = "You have nothing to rustproof.";
5209 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5211 /* Get the item (in the pack) */
5214 o_ptr = &inventory[item];
5217 /* Get the item (on the floor) */
5220 o_ptr = &o_list[0 - item];
5225 object_desc(o_name, o_ptr, FALSE, 0);
5227 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5229 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5232 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5234 msg_format("%s %s look%s as good as new!",
5235 ((item >= 0) ? "Your" : "The"), o_name,
5236 ((o_ptr->number > 1) ? "" : "s"));
5243 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5245 msg_format("%s %s %s now protected against corrosion.",
5246 ((item >= 0) ? "Your" : "The"), o_name,
5247 ((o_ptr->number > 1) ? "are" : "is"));
5258 * Curse the players armor
5260 bool curse_armor(void)
5265 char o_name[MAX_NLEN];
5268 /* Curse the body armor */
5269 o_ptr = &inventory[INVEN_BODY];
5271 /* Nothing to curse */
5272 if (!o_ptr->k_idx) return (FALSE);
5276 object_desc(o_name, o_ptr, FALSE, 3);
5278 /* Attempt a saving throw for artifacts */
5279 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5283 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5284 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5286 msg_format("A %s tries to %s, but your %s resists the effects!",
5287 "terrible black aura", "surround your armor", o_name);
5292 /* not artifact or failed save... */
5297 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5299 msg_format("A terrible black aura blasts your %s!", o_name);
5302 chg_virtue(V_ENCHANT, -5);
5304 /* Blast the armor */
5306 o_ptr->name2 = EGO_BLASTED;
5307 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5314 for (i = 0; i < TR_FLAG_SIZE; i++)
5315 o_ptr->art_flags[i] = 0;
5318 o_ptr->curse_flags = TRC_CURSED;
5321 o_ptr->ident |= (IDENT_BROKEN);
5323 /* Recalculate bonuses */
5324 p_ptr->update |= (PU_BONUS);
5326 /* Recalculate mana */
5327 p_ptr->update |= (PU_MANA);
5330 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5338 * Curse the players weapon
5340 bool curse_weapon(bool force, int slot)
5346 char o_name[MAX_NLEN];
5349 /* Curse the weapon */
5350 o_ptr = &inventory[slot];
5352 /* Nothing to curse */
5353 if (!o_ptr->k_idx) return (FALSE);
5357 object_desc(o_name, o_ptr, FALSE, 3);
5359 /* Attempt a saving throw */
5360 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5364 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5365 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5367 msg_format("A %s tries to %s, but your %s resists the effects!",
5368 "terrible black aura", "surround your weapon", o_name);
5373 /* not artifact or failed save... */
5378 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5380 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5383 chg_virtue(V_ENCHANT, -5);
5385 /* Shatter the weapon */
5387 o_ptr->name2 = EGO_SHATTERED;
5388 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5389 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5395 for (i = 0; i < TR_FLAG_SIZE; i++)
5396 o_ptr->art_flags[i] = 0;
5400 o_ptr->curse_flags = TRC_CURSED;
5403 o_ptr->ident |= (IDENT_BROKEN);
5405 /* Recalculate bonuses */
5406 p_ptr->update |= (PU_BONUS);
5408 /* Recalculate mana */
5409 p_ptr->update |= (PU_MANA);
5412 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5421 * Enchant some bolts
5423 bool brand_bolts(void)
5427 /* Use the first acceptable bolts */
5428 for (i = 0; i < INVEN_PACK; i++)
5430 object_type *o_ptr = &inventory[i];
5432 /* Skip non-bolts */
5433 if (o_ptr->tval != TV_BOLT) continue;
5435 /* Skip artifacts and ego-items */
5436 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5439 /* Skip cursed/broken items */
5440 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5443 if (randint0(100) < 75) continue;
5447 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5449 msg_print("Your bolts are covered in a fiery aura!");
5454 o_ptr->name2 = EGO_FLAME;
5457 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5464 if (flush_failure) flush();
5468 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5470 msg_print("The fiery enchantment failed.");
5480 * Helper function -- return a "nearby" race for polymorphing
5482 * Note that this function is one of the more "dangerous" ones...
5484 static s16b poly_r_idx(int r_idx)
5486 monster_race *r_ptr = &r_info[r_idx];
5488 int i, r, lev1, lev2;
5490 /* Hack -- Uniques/Questors never polymorph */
5491 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5492 (r_ptr->flags1 & RF1_QUESTOR))
5495 /* Allowable range of "levels" for resulting monster */
5496 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5497 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5499 /* Pick a (possibly new) non-unique race */
5500 for (i = 0; i < 1000; i++)
5502 /* Pick a new race, using a level calculation */
5503 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5505 /* Handle failure */
5511 /* Ignore unique monsters */
5512 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5514 /* Ignore monsters with incompatible levels */
5515 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5517 /* Use that index */
5529 bool polymorph_monster(int y, int x)
5531 cave_type *c_ptr = &cave[y][x];
5532 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5533 bool polymorphed = FALSE;
5535 int old_r_idx = m_ptr->r_idx;
5536 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5537 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5538 monster_type back_m;
5540 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5542 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG_KAGE)) return (FALSE);
5544 /* Memorize the monster before polymorphing */
5547 /* Pick a "new" monster race */
5548 new_r_idx = poly_r_idx(old_r_idx);
5550 /* Handle polymorph */
5551 if (new_r_idx != old_r_idx)
5555 /* Get the monsters attitude */
5556 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5557 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5558 if (m_ptr->mflag2 & MFLAG_NOPET) mode |= PM_NO_PET;
5560 /* "Kill" the "old" monster */
5561 delete_monster_idx(c_ptr->m_idx);
5563 /* Create a new monster (no groups) */
5564 if (place_monster_aux(0, y, x, new_r_idx, mode))
5571 /* Placing the new monster failed */
5572 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5573 m_list[hack_m_idx_ii] = back_m;
5576 if (targeted) target_who = hack_m_idx_ii;
5577 if (health_tracked) health_track(hack_m_idx_ii);
5587 bool dimension_door(void)
5589 int plev = p_ptr->lev;
5592 if (!tgt_pt(&x, &y)) return FALSE;
5594 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5596 if (!cave_empty_bold(y, x) || (cave[y][x].info & CAVE_ICKY) ||
5597 (distance(y, x, py, px) > plev / 2 + 10) ||
5598 (!randint0(plev / 10 + 10)))
5600 if( p_ptr->pclass != CLASS_MIRROR_MASTER ){
5602 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5604 msg_print("You fail to exit the astral plane correctly!");
5610 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5612 msg_print("You fail to exit the astral plane correctly!");
5615 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5616 teleport_player((plev+2)*2);
5619 teleport_player_to(y, x, TRUE);
5625 bool eat_magic(int power)
5627 object_type * o_ptr;
5630 int recharge_strength = 0;
5636 char o_name[MAX_NLEN];
5638 item_tester_hook = item_tester_hook_recharge;
5642 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5643 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5645 q = "Drain which item? ";
5646 s = "You have nothing to drain.";
5649 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5653 o_ptr = &inventory[item];
5657 o_ptr = &o_list[0 - item];
5660 k_ptr = &k_info[o_ptr->k_idx];
5661 lev = get_object_level(o_ptr);
5663 if (o_ptr->tval == TV_ROD)
5665 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5668 if (one_in_(recharge_strength))
5670 /* Activate the failure code. */
5675 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5678 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5680 msg_print("You can't absorb energy from a discharged rod.");
5687 o_ptr->timeout += k_ptr->pval;
5693 /* All staffs, wands. */
5694 recharge_strength = (100 + power - lev) / 15;
5697 if (recharge_strength < 0) recharge_strength = 0;
5700 if (one_in_(recharge_strength))
5702 /* Activate the failure code. */
5707 if (o_ptr->pval > 0)
5709 p_ptr->csp += lev / 2;
5712 /* XXX Hack -- unstack if necessary */
5713 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5718 /* Get local object */
5721 /* Obtain a local object */
5722 object_copy(q_ptr, o_ptr);
5724 /* Modify quantity */
5727 /* Restore the charges */
5730 /* Unstack the used item */
5732 p_ptr->total_weight -= q_ptr->weight;
5733 item = inven_carry(q_ptr);
5737 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5739 msg_print("You unstack your staff.");
5747 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5749 msg_print("There's no energy there to absorb!");
5753 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5757 /* Inflict the penalties for failing a recharge. */
5760 /* Artifacts are never destroyed. */
5761 if (artifact_p(o_ptr))
5763 object_desc(o_name, o_ptr, TRUE, 0);
5765 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5767 msg_format("The recharging backfires - %s is completely drained!", o_name);
5771 /* Artifact rods. */
5772 if (o_ptr->tval == TV_ROD)
5773 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5775 /* Artifact wands and staffs. */
5776 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5781 /* Get the object description */
5782 object_desc(o_name, o_ptr, FALSE, 0);
5784 /*** Determine Seriousness of Failure ***/
5786 /* Mages recharge objects more safely. */
5787 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)
5789 /* 10% chance to blow up one rod, otherwise draining. */
5790 if (o_ptr->tval == TV_ROD)
5792 if (one_in_(10)) fail_type = 2;
5795 /* 75% chance to blow up one wand, otherwise draining. */
5796 else if (o_ptr->tval == TV_WAND)
5798 if (!one_in_(3)) fail_type = 2;
5801 /* 50% chance to blow up one staff, otherwise no effect. */
5802 else if (o_ptr->tval == TV_STAFF)
5804 if (one_in_(2)) fail_type = 2;
5809 /* All other classes get no special favors. */
5812 /* 33% chance to blow up one rod, otherwise draining. */
5813 if (o_ptr->tval == TV_ROD)
5815 if (one_in_(3)) fail_type = 2;
5818 /* 20% chance of the entire stack, else destroy one wand. */
5819 else if (o_ptr->tval == TV_WAND)
5821 if (one_in_(5)) fail_type = 3;
5824 /* Blow up one staff. */
5825 else if (o_ptr->tval == TV_STAFF)
5831 /*** Apply draining and destruction. ***/
5833 /* Drain object or stack of objects. */
5836 if (o_ptr->tval == TV_ROD)
5839 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
5841 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
5844 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5846 else if (o_ptr->tval == TV_WAND)
5849 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
5851 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
5856 /* Staffs aren't drained. */
5859 /* Destroy an object or one in a stack of objects. */
5862 if (o_ptr->number > 1)
5865 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
5867 msg_format("Wild magic consumes one of your %s!", o_name);
5870 /* Reduce rod stack maximum timeout, drain wands. */
5871 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5872 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5877 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
5879 msg_format("Wild magic consumes your %s!", o_name);
5882 /* Reduce and describe inventory */
5885 inven_item_increase(item, -1);
5886 inven_item_describe(item);
5887 inven_item_optimize(item);
5890 /* Reduce and describe floor item */
5893 floor_item_increase(0 - item, -1);
5894 floor_item_describe(0 - item);
5895 floor_item_optimize(0 - item);
5899 /* Destroy all members of a stack of objects. */
5902 if (o_ptr->number > 1)
5904 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
5906 msg_format("Wild magic consumes all your %s!", o_name);
5911 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
5913 msg_format("Wild magic consumes your %s!", o_name);
5918 /* Reduce and describe inventory */
5921 inven_item_increase(item, -999);
5922 inven_item_describe(item);
5923 inven_item_optimize(item);
5926 /* Reduce and describe floor item */
5929 floor_item_increase(0 - item, -999);
5930 floor_item_describe(0 - item);
5931 floor_item_optimize(0 - item);
5937 if (p_ptr->csp > p_ptr->msp)
5939 p_ptr->csp = p_ptr->msp;
5942 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5943 p_ptr->window |= (PW_INVEN);
5949 bool summon_kin_player(int level, int y, int x, u32b mode)
5951 bool pet = (bool)(mode & PM_FORCE_PET);
5952 if (!pet) mode |= PM_NO_PET;
5954 switch (p_ptr->mimic_form)
5957 switch (p_ptr->prace)
5961 case RACE_BARBARIAN:
5964 summon_kin_type = 'p';
5974 case RACE_MIND_FLAYER:
5977 summon_kin_type = 'h';
5980 summon_kin_type = 'o';
5982 case RACE_HALF_TROLL:
5983 summon_kin_type = 'T';
5985 case RACE_HALF_OGRE:
5986 summon_kin_type = 'O';
5988 case RACE_HALF_GIANT:
5989 case RACE_HALF_TITAN:
5991 summon_kin_type = 'P';
5994 summon_kin_type = 'y';
5997 summon_kin_type = 'K';
6000 summon_kin_type = 'k';
6003 if (one_in_(13)) summon_kin_type = 'U';
6004 else summon_kin_type = 'u';
6006 case RACE_DRACONIAN:
6007 summon_kin_type = 'd';
6011 summon_kin_type = 'g';
6014 if (one_in_(13)) summon_kin_type = 'L';
6015 else summon_kin_type = 's';
6018 summon_kin_type = 'z';
6021 summon_kin_type = 'V';
6024 summon_kin_type = 'G';
6027 summon_kin_type = 'I';
6030 summon_kin_type = '#';
6033 summon_kin_type = 'A';
6036 summon_kin_type = 'U';
6039 summon_kin_type = 'p';
6044 if (one_in_(13)) summon_kin_type = 'U';
6045 else summon_kin_type = 'u';
6047 case MIMIC_DEMON_LORD:
6048 summon_kin_type = 'U';
6051 summon_kin_type = 'V';
6054 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);