4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Spell code (part 3) */
15 /* Maximum number of tries for teleporting */
18 /* 1/x chance of reducing stats (for elemental attacks) */
19 #define HURT_CHANCE 16
23 * Teleport a monster, normally up to "dis" grids away.
25 * Attempt to move the monster at least "dis/2" grids away.
27 * But allow variation to prevent infinite loops.
29 bool teleport_away(int m_idx, int dis, bool dec_valour)
31 int oy, ox, d, i, min;
37 monster_type *m_ptr = &m_list[m_idx];
41 if (!m_ptr->r_idx) return (FALSE);
43 /* Save the old location */
47 /* Minimum distance */
51 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
52 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
54 chg_virtue(V_VALOUR, -1);
62 /* Verify max distance */
63 if (dis > 200) dis = 200;
65 /* Try several locations */
66 for (i = 0; i < 500; i++)
68 /* Pick a (possibly illegal) location */
71 ny = rand_spread(oy, dis);
72 nx = rand_spread(ox, dis);
73 d = distance(oy, ox, ny, nx);
74 if ((d >= min) && (d <= dis)) break;
77 /* Ignore illegal locations */
78 if (!in_bounds(ny, nx)) continue;
80 /* Require "empty" floor space */
81 if (!cave_empty_bold(ny, nx)) continue;
83 /* Hack -- no teleport onto glyph of warding */
84 if (is_glyph_grid(&cave[ny][nx])) continue;
85 if (is_explosive_rune_grid(&cave[ny][nx])) continue;
87 /* ...nor onto the Pattern */
88 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
89 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2)) continue;
91 /* No teleporting into vaults and such */
92 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
93 if (cave[ny][nx].info & CAVE_ICKY) continue;
95 /* This grid looks good */
102 /* Increase the maximum distance */
105 /* Decrease the minimum distance */
108 /* Stop after MAX_TRIES tries */
109 if (tries > MAX_TRIES) return (FALSE);
113 sound(SOUND_TPOTHER);
115 /* Update the new location */
116 cave[ny][nx].m_idx = m_idx;
118 /* Update the old location */
119 cave[oy][ox].m_idx = 0;
121 /* Move the monster */
125 /* Forget the counter target */
128 /* Update the monster (new location) */
129 update_mon(m_idx, TRUE);
131 /* Redraw the old grid */
134 /* Redraw the new grid */
143 * Teleport monster next to the player
145 void teleport_to_player(int m_idx, int power)
147 int ny, nx, oy, ox, d, i, min;
151 monster_type *m_ptr = &m_list[m_idx];
155 if (!m_ptr->r_idx) return;
158 if (randint1(100) > power) return;
164 /* Save the old location */
168 /* Minimum distance */
171 /* Look until done */
172 while (look && --attempts)
174 /* Verify max distance */
175 if (dis > 200) dis = 200;
177 /* Try several locations */
178 for (i = 0; i < 500; i++)
180 /* Pick a (possibly illegal) location */
183 ny = rand_spread(py, dis);
184 nx = rand_spread(px, dis);
185 d = distance(py, px, ny, nx);
186 if ((d >= min) && (d <= dis)) break;
189 /* Ignore illegal locations */
190 if (!in_bounds(ny, nx)) continue;
192 /* Require "empty" floor space */
193 if (!cave_empty_bold(ny, nx)) continue;
195 /* Hack -- no teleport onto glyph of warding */
196 if (is_glyph_grid(&cave[ny][nx])) continue;
197 if (is_explosive_rune_grid(&cave[ny][nx])) continue;
199 /* ...nor onto the Pattern */
200 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
201 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2)) continue;
203 /* No teleporting into vaults and such */
204 /* if (cave[ny][nx].info & (CAVE_ICKY)) continue; */
206 /* This grid looks good */
213 /* Increase the maximum distance */
216 /* Decrease the minimum distance */
220 if (attempts < 1) return;
223 sound(SOUND_TPOTHER);
225 /* Update the new location */
226 cave[ny][nx].m_idx = m_idx;
228 /* Update the old location */
229 cave[oy][ox].m_idx = 0;
231 /* Move the monster */
235 /* Update the monster (new location) */
236 update_mon(m_idx, TRUE);
238 /* Redraw the old grid */
241 /* Redraw the new grid */
244 p_ptr->update |= (PU_MON_LITE);
249 * Teleport the player to a location up to "dis" grids away.
251 * If no such spaces are readily available, the distance may increase.
252 * Try very hard to move the player at least a quarter that distance.
254 * When long-range teleport effects are considered, there is a nasty
255 * tendency to "bounce" the player between two or three different spots
256 * because these are the only spots that are "far enough" way to satisfy
257 * the algorithm. Therefore, if the teleport distance is more than 50,
258 * we decrease the minimum acceptable distance to try to increase randomness.
261 void teleport_player(int dis)
263 int d, i, min, ox, oy;
274 if (p_ptr->wild_mode) return;
276 if (p_ptr->anti_tele)
279 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
281 msg_print("A mysterious force prevents you from teleporting!");
287 if (dis > 200) dis = 200; /* To be on the safe side... */
289 /* Minimum distance */
290 min = dis / (dis > 50 ? 3 : 2);
292 /* Look until done */
297 /* Verify max distance */
298 if (dis > 200) dis = 200;
300 /* Try several locations */
301 for (i = 0; i < 500; i++)
303 /* Pick a (possibly illegal) location */
306 y = rand_spread(py, dis);
307 x = rand_spread(px, dis);
308 d = distance(py, px, y, x);
309 if ((d >= min) && (d <= dis)) break;
312 /* Ignore illegal locations */
313 if (!in_bounds(y, x)) continue;
315 /* Require "naked" floor space or trees */
316 if (!(cave_naked_bold(y, x) ||
317 (cave[y][x].feat == FEAT_TREES))) continue;
319 /* No teleporting into vaults and such */
320 if (cave[y][x].info & CAVE_ICKY) continue;
322 /* This grid looks good */
329 /* Increase the maximum distance */
332 /* Decrease the minimum distance */
335 /* Stop after MAX_TRIES tries */
336 if (tries > MAX_TRIES) return;
340 sound(SOUND_TELEPORT);
343 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
344 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
347 /* Save the old location */
351 /* Move the player */
358 tmp = cave[py][px].m_idx;
359 cave[py][px].m_idx = cave[oy][ox].m_idx;
360 cave[oy][ox].m_idx = tmp;
361 m_list[p_ptr->riding].fy = py;
362 m_list[p_ptr->riding].fx = px;
363 update_mon(cave[py][px].m_idx, TRUE);
366 /* Redraw the old spot */
369 /* Monsters with teleport ability may follow the player */
370 for (xx = -1; xx < 2; xx++)
372 for (yy = -1; yy < 2; yy++)
374 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
376 /* A monster except your mount may follow */
377 if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
379 monster_type *m_ptr = &m_list[tmp_m_idx];
380 monster_race *r_ptr = &r_info[m_ptr->r_idx];
383 * The latter limitation is to avoid
384 * totally unkillable suckers...
386 if ((r_ptr->flags6 & RF6_TPORT) &&
387 !(r_ptr->flags3 & RF3_RES_TELE))
389 if (!m_ptr->csleep) teleport_to_player(tmp_m_idx, r_ptr->level);
397 /* Redraw the new spot */
400 /* Check for new panel (redraw map) */
404 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
406 /* Update the monsters */
407 p_ptr->update |= (PU_DISTANCE);
410 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
412 /* Handle stuff XXX XXX XXX */
419 * Teleport player to a grid near the given location
421 * This function is slightly obsessive about correctness.
422 * This function allows teleporting into vaults (!)
424 void teleport_player_to(int ny, int nx, bool no_tele)
426 int y, x, oy, ox, dis = 0, ctr = 0;
428 if (p_ptr->anti_tele && no_tele)
431 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
433 msg_print("A mysterious force prevents you from teleporting!");
439 /* Find a usable location */
442 /* Pick a nearby legal location */
445 y = rand_spread(ny, dis);
446 x = rand_spread(nx, dis);
447 if (in_bounds(y, x)) break;
450 /* Accept "naked" floor grids */
453 if (cave_naked_bold(y, x) || (((cave[y][x].feat == FEAT_DEEP_LAVA) || (cave[y][x].feat == FEAT_DEEP_WATER)) && !cave[y][x].m_idx)) break;
455 else if (cave_empty_bold(y, x) || ((y == py) && (x == px))) break;
457 /* Occasionally advance the distance */
458 if (++ctr > (4 * dis * dis + 4 * dis + 1))
466 sound(SOUND_TELEPORT);
468 /* Save the old location */
472 /* Move the player */
479 tmp = cave[py][px].m_idx;
480 cave[py][px].m_idx = cave[oy][ox].m_idx;
481 cave[oy][ox].m_idx = tmp;
482 m_list[p_ptr->riding].fy = py;
483 m_list[p_ptr->riding].fx = px;
484 update_mon(cave[py][px].m_idx, TRUE);
489 /* Redraw the old spot */
492 /* Redraw the new spot */
495 /* Check for new panel (redraw map) */
499 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
501 /* Update the monsters */
502 p_ptr->update |= (PU_DISTANCE);
505 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
507 /* Handle stuff XXX XXX XXX */
514 * Teleport the player one level up or down (random when legal)
516 void teleport_player_level(void)
520 /* No effect in arena or quest */
521 if (p_ptr->inside_arena || (p_ptr->inside_quest && !random_quest_number(dun_level)) ||
522 (quest_number(dun_level) && (dun_level > 1) && ironman_downward))
525 msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
527 msg_print("There is no effect.");
533 if (p_ptr->anti_tele)
536 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
538 msg_print("A mysterious force prevents you from teleporting!");
544 /* Choose up or down */
545 if (randint0(100) < 50) go_up = TRUE;
550 if (get_check("Force to go up? ")) go_up = TRUE;
551 else if (get_check("Force to go down? ")) go_up = FALSE;
555 if (ironman_downward || (dun_level <= d_info[dungeon_type].mindepth))
558 msg_print("¤¢¤Ê¤¿¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£");
560 msg_print("You sink through the floor.");
564 dungeon_type = p_ptr->recall_dungeon;
569 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
571 if (autosave_l) do_cmd_save_game(TRUE);
575 dun_level = d_info[dungeon_type].mindepth;
576 prepare_change_floor_mode(CFM_RAND_PLACE | CFM_CLEAR_ALL);
580 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
584 p_ptr->leaving = TRUE;
588 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
591 msg_print("¤¢¤Ê¤¿¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£");
593 msg_print("You rise up through the ceiling.");
597 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
599 if (autosave_l) do_cmd_save_game(TRUE);
601 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
606 p_ptr->inside_quest = 0;
607 p_ptr->leaving = TRUE;
612 msg_print("¤¢¤Ê¤¿¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£");
614 msg_print("You rise up through the ceiling.");
618 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
620 if (autosave_l) do_cmd_save_game(TRUE);
622 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
625 p_ptr->leaving = TRUE;
630 msg_print("¤¢¤Ê¤¿¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£");
632 msg_print("You sink through the floor.");
635 /* Never reach this code on the surface */
636 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
638 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
640 if (autosave_l) do_cmd_save_game(TRUE);
642 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
645 p_ptr->leaving = TRUE;
649 sound(SOUND_TPLEVEL);
654 static int choose_dungeon(cptr note)
660 /* Allocate the "dun" array */
661 C_MAKE(dun, max_d_idx, s16b);
664 for(i = 1; i < max_d_idx; i++)
669 if (!d_info[i].maxdepth) continue;
670 if (!max_dlv[i]) continue;
671 if (d_info[i].final_guardian)
673 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
675 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
678 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
680 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
686 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
688 prt(format("Which dungeon do you %s?: ", note), 0, 0);
695 /* Free the "dun" array */
696 C_KILL(dun, max_d_idx, s16b);
701 if (i >= 'a' && i <('a'+num))
703 select_dungeon = dun[i-'a'];
710 /* Free the "dun" array */
711 C_KILL(dun, max_d_idx, s16b);
713 return select_dungeon;
718 * Recall the player to town or dungeon
720 bool recall_player(int turns)
723 * TODO: Recall the player to the last
724 * visited town when in the wilderness
728 if (p_ptr->inside_arena || ironman_downward)
731 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
733 msg_print("Nothing happens.");
739 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
742 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
744 if (get_check("Reset recall depth? "))
747 max_dlv[dungeon_type] = dun_level;
748 if (record_maxdeapth)
750 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
752 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
757 if (!p_ptr->word_recall)
763 select_dungeon = choose_dungeon("¤Ëµ¢´Ô");
765 select_dungeon = choose_dungeon("recall");
767 if (!select_dungeon) return FALSE;
768 p_ptr->recall_dungeon = select_dungeon;
770 p_ptr->word_recall = turns;
772 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
774 msg_print("The air about you becomes charged...");
777 p_ptr->redraw |= (PR_STATUS);
781 p_ptr->word_recall = 0;
783 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
785 msg_print("A tension leaves the air around you...");
788 p_ptr->redraw |= (PR_STATUS);
794 bool word_of_recall(void)
796 return(recall_player(randint0(21) + 15));
800 bool reset_recall(void)
802 int select_dungeon, dummy = 0;
807 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È");
809 select_dungeon = choose_dungeon("reset");
812 if (!select_dungeon) return FALSE;
815 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
817 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
822 sprintf(tmp_val, "%d", MAX(dun_level, 1));
824 /* Ask for a level */
825 if (get_string(ppp, tmp_val, 10))
827 /* Extract request */
828 dummy = atoi(tmp_val);
831 if (dummy < 1) dummy = 1;
834 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
835 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
837 max_dlv[select_dungeon] = dummy;
839 if (record_maxdeapth)
841 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
843 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
847 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
849 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
862 * Apply disenchantment to the player's stuff
864 * XXX XXX XXX This function is also called from the "melee" code
866 * Return "TRUE" if the player notices anything
868 bool apply_disenchant(int mode)
872 char o_name[MAX_NLEN];
873 int to_h, to_d, to_a, pval;
875 /* Pick a random slot */
878 case 1: t = INVEN_RARM; break;
879 case 2: t = INVEN_LARM; break;
880 case 3: t = INVEN_BOW; break;
881 case 4: t = INVEN_BODY; break;
882 case 5: t = INVEN_OUTER; break;
883 case 6: t = INVEN_HEAD; break;
884 case 7: t = INVEN_HANDS; break;
885 case 8: t = INVEN_FEET; break;
889 o_ptr = &inventory[t];
891 /* No item, nothing happens */
892 if (!o_ptr->k_idx) return (FALSE);
895 /* Nothing to disenchant */
896 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
898 /* Nothing to notice */
903 /* Describe the object */
904 object_desc(o_name, o_ptr, FALSE, 0);
907 /* Artifacts have 71% chance to resist */
908 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 71))
912 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
914 msg_format("Your %s (%c) resist%s disenchantment!",
915 o_name, index_to_label(t),
916 ((o_ptr->number != 1) ? "" : "s"));
925 /* Memorize old value */
931 /* Disenchant tohit */
932 if (o_ptr->to_h > 0) o_ptr->to_h--;
933 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
935 /* Disenchant todam */
936 if (o_ptr->to_d > 0) o_ptr->to_d--;
937 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
939 /* Disenchant toac */
940 if (o_ptr->to_a > 0) o_ptr->to_a--;
941 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
943 /* Disenchant pval (occasionally) */
944 /* Unless called from wild_magic() */
945 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
947 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
948 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
952 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
953 o_name, index_to_label(t) );
955 msg_format("Your %s (%c) %s disenchanted!",
956 o_name, index_to_label(t),
957 ((o_ptr->number != 1) ? "were" : "was"));
960 chg_virtue(V_HARMONY, 1);
961 chg_virtue(V_ENCHANT, -2);
963 /* Recalculate bonuses */
964 p_ptr->update |= (PU_BONUS);
967 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
977 void mutate_player(void)
979 int max1, cur1, max2, cur2, ii, jj, i;
981 /* Pick a pair of stats */
983 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
985 max1 = p_ptr->stat_max[ii];
986 cur1 = p_ptr->stat_cur[ii];
987 max2 = p_ptr->stat_max[jj];
988 cur2 = p_ptr->stat_cur[jj];
990 p_ptr->stat_max[ii] = max2;
991 p_ptr->stat_cur[ii] = cur2;
992 p_ptr->stat_max[jj] = max1;
993 p_ptr->stat_cur[jj] = cur1;
997 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
998 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1001 p_ptr->update |= (PU_BONUS);
1008 void apply_nexus(monster_type *m_ptr)
1010 switch (randint1(7))
1012 case 1: case 2: case 3:
1014 teleport_player(200);
1020 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE);
1026 if (randint0(100) < p_ptr->skill_sav)
1029 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1031 msg_print("You resist the effects!");
1037 /* Teleport Level */
1038 teleport_player_level();
1044 if (randint0(100) < p_ptr->skill_sav)
1047 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1049 msg_print("You resist the effects!");
1056 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1058 msg_print("Your body starts to scramble...");
1069 * Charge a lite (torch or latern)
1071 void phlogiston(void)
1074 object_type * o_ptr = &inventory[INVEN_LITE];
1077 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1079 max_flog = FUEL_LAMP;
1083 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1085 max_flog = FUEL_TORCH;
1088 /* No torch to refill */
1092 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1094 msg_print("You are not wielding anything which uses phlogiston.");
1100 if (o_ptr->xtra4 >= max_flog)
1103 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1105 msg_print("No more phlogiston can be put in this item.");
1112 o_ptr->xtra4 += (max_flog / 2);
1116 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1118 msg_print("You add phlogiston to your light item.");
1123 if (o_ptr->xtra4 >= max_flog)
1125 o_ptr->xtra4 = max_flog;
1127 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1129 msg_print("Your light item is full.");
1134 /* Recalculate torch */
1135 p_ptr->update |= (PU_TORCH);
1139 static bool item_tester_hook_weapon_nobow(object_type *o_ptr)
1141 switch (o_ptr->tval)
1151 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
1159 * Brand the current weapon
1161 void brand_weapon(int brand_type)
1168 /* Assume enchant weapon */
1169 item_tester_hook = item_tester_hook_weapon_nobow;
1170 item_tester_no_ryoute = TRUE;
1174 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1175 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1177 q = "Enchant which weapon? ";
1178 s = "You have nothing to enchant.";
1181 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1183 /* Get the item (in the pack) */
1186 o_ptr = &inventory[item];
1189 /* Get the item (on the floor) */
1192 o_ptr = &o_list[0 - item];
1196 /* you can never modify artifacts / ego-items */
1197 /* you can never modify cursed items */
1198 /* TY: You _can_ modify broken items (if you're silly enough) */
1199 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
1200 !o_ptr->art_name && !cursed_p(o_ptr) &&
1201 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1202 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1203 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1207 /* Let's get the name before it is changed... */
1208 char o_name[MAX_NLEN];
1209 object_desc(o_name, o_ptr, FALSE, 0);
1214 if (o_ptr->tval == TV_SWORD)
1217 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1219 act = "becomes very sharp!";
1222 o_ptr->name2 = EGO_SHARPNESS;
1223 o_ptr->pval = m_bonus(5, dun_level) + 1;
1228 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1230 act = "seems very powerful.";
1233 o_ptr->name2 = EGO_EARTHQUAKES;
1234 o_ptr->pval = m_bonus(3, dun_level);
1239 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1241 act = "seems to be looking for humans!";
1244 o_ptr->name2 = EGO_SLAY_HUMAN;
1248 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1250 act = "covered with lightning!";
1253 o_ptr->name2 = EGO_BRAND_ELEC;
1257 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1259 act = "coated with acid!";
1262 o_ptr->name2 = EGO_BRAND_ACID;
1266 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1268 act = "seems to be looking for evil monsters!";
1271 o_ptr->name2 = EGO_SLAY_EVIL;
1275 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1277 act = "seems to be looking for demons!";
1280 o_ptr->name2 = EGO_SLAY_DEMON;
1284 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1286 act = "seems to be looking for undead!";
1289 o_ptr->name2 = EGO_SLAY_UNDEAD;
1293 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1295 act = "seems to be looking for animals!";
1298 o_ptr->name2 = EGO_SLAY_ANIMAL;
1302 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1304 act = "seems to be looking for dragons!";
1307 o_ptr->name2 = EGO_SLAY_DRAGON;
1311 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1313 act = "seems to be looking for troll!s";
1316 o_ptr->name2 = EGO_SLAY_TROLL;
1320 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1322 act = "seems to be looking for orcs!";
1325 o_ptr->name2 = EGO_SLAY_ORC;
1329 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1331 act = "seems to be looking for giants!";
1334 o_ptr->name2 = EGO_SLAY_GIANT;
1338 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1340 act = "seems very unstable now.";
1343 o_ptr->name2 = EGO_TRUMP;
1344 o_ptr->pval = randint1(2);
1348 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1350 act = "thirsts for blood!";
1353 o_ptr->name2 = EGO_VAMPIRIC;
1357 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1359 act = "is coated with poison.";
1362 o_ptr->name2 = EGO_BRAND_POIS;
1366 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1368 act = "is engulfed in raw Logrus!";
1371 o_ptr->name2 = EGO_CHAOTIC;
1375 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1377 act = "is covered in a fiery shield!";
1380 o_ptr->name2 = EGO_BRAND_FIRE;
1384 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1386 act = "glows deep, icy blue!";
1389 o_ptr->name2 = EGO_BRAND_COLD;
1394 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1396 msg_format("Your %s %s", o_name, act);
1400 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1402 o_ptr->discount = 99;
1403 chg_virtue(V_ENCHANT, 2);
1407 if (flush_failure) flush();
1410 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1412 msg_print("The Branding failed.");
1415 chg_virtue(V_ENCHANT, -2);
1421 void call_the_(void)
1425 if (cave_floor_bold(py - 1, px - 1) &&
1426 cave_floor_bold(py - 1, px ) &&
1427 cave_floor_bold(py - 1, px + 1) &&
1428 cave_floor_bold(py , px - 1) &&
1429 cave_floor_bold(py , px + 1) &&
1430 cave_floor_bold(py + 1, px - 1) &&
1431 cave_floor_bold(py + 1, px ) &&
1432 cave_floor_bold(py + 1, px + 1))
1434 for (i = 1; i < 10; i++)
1436 if (i-5) fire_ball(GF_ROCKET, i, 175, 2);
1439 for (i = 1; i < 10; i++)
1441 if (i-5) fire_ball(GF_MANA, i, 175, 3);
1444 for (i = 1; i < 10; i++)
1446 if (i-5) fire_ball(GF_NUKE, i, 175, 4);
1452 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1453 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1454 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1456 msg_format("You %s the %s too close to a wall!",
1457 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1458 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1459 msg_print("There is a loud explosion!");
1463 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11)))
1465 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1467 msg_print("The dungeon collapses...");
1472 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1474 msg_print("The dungeon trembles.");
1479 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1481 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1489 * Fetch an item (teleport it right underneath the caster)
1491 void fetch(int dir, int wgt, bool require_los)
1496 char o_name[MAX_NLEN];
1498 /* Check to see if an object is already there */
1499 if (cave[py][px].o_idx)
1502 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1504 msg_print("You can't fetch when you're already standing on something.");
1511 if (dir == 5 && target_okay())
1516 if (distance(py, px, ty, tx) > MAX_RANGE)
1519 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1521 msg_print("You can't fetch something that far away!");
1527 c_ptr = &cave[ty][tx];
1529 /* We need an item to fetch */
1533 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1535 msg_print("There is no object at this place.");
1541 /* No fetching from vault */
1542 if (c_ptr->info & CAVE_ICKY)
1545 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1547 msg_print("The item slips from your control.");
1553 /* We need to see the item */
1554 if (require_los && !player_has_los_bold(ty, tx))
1557 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1559 msg_print("You have no direct line of sight to that location.");
1567 /* Use a direction */
1568 ty = py; /* Where to drop the item */
1575 c_ptr = &cave[ty][tx];
1577 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1578 !cave_floor_bold(ty, tx)) return;
1580 while (!c_ptr->o_idx);
1583 o_ptr = &o_list[c_ptr->o_idx];
1585 if (o_ptr->weight > wgt)
1587 /* Too heavy to 'fetch' */
1589 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1591 msg_print("The object is too heavy.");
1598 c_ptr->o_idx = o_ptr->next_o_idx;
1599 cave[py][px].o_idx = i; /* 'move' it */
1600 o_ptr->next_o_idx = 0;
1601 o_ptr->iy = (byte)py;
1602 o_ptr->ix = (byte)px;
1604 object_desc(o_name, o_ptr, TRUE, 0);
1606 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1608 msg_format("%^s flies through the air to your feet.", o_name);
1613 p_ptr->redraw |= PR_MAP;
1617 void alter_reality(void)
1619 /* Ironman option */
1620 if (p_ptr->inside_arena || ironman_downward)
1623 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1625 msg_print("Nothing happens.");
1630 if (!p_ptr->alter_reality)
1632 int turns = randint0(21) + 15;
1634 p_ptr->alter_reality = turns;
1636 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1638 msg_print("The view around you begins to change...");
1641 p_ptr->redraw |= (PR_STATUS);
1645 p_ptr->alter_reality = 0;
1647 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1649 msg_print("The view around you got back...");
1652 p_ptr->redraw |= (PR_STATUS);
1659 * Leave a "glyph of warding" which prevents monster movement
1661 bool warding_glyph(void)
1664 if (!cave_clean_bold(py, px))
1667 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1669 msg_print("The object resists the spell.");
1675 /* Create a glyph */
1676 cave[py][px].info |= CAVE_OBJECT;
1677 cave[py][px].mimic = FEAT_GLYPH;
1688 bool warding_mirror(void)
1691 if (!cave_clean_bold(py, px))
1694 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1696 msg_print("The object resists the spell.");
1702 /* Create a mirror */
1703 cave[py][px].info |= CAVE_OBJECT;
1704 cave[py][px].mimic = FEAT_MIRROR;
1706 /* Turn on the light */
1707 cave[py][px].info |= CAVE_GLOW;
1720 * Leave an "explosive rune" which prevents monster movement
1722 bool explosive_rune(void)
1725 if (!cave_clean_bold(py, px))
1728 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1730 msg_print("The object resists the spell.");
1736 /* Create a glyph */
1737 cave[py][px].info |= CAVE_OBJECT;
1738 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1751 * Identify everything being carried.
1752 * Done by a potion of "self knowledge".
1754 void identify_pack(void)
1758 /* Simply identify and know every item */
1759 for (i = 0; i < INVEN_TOTAL; i++)
1761 object_type *o_ptr = &inventory[i];
1763 /* Skip non-objects */
1764 if (!o_ptr->k_idx) continue;
1767 identify_item(o_ptr);
1773 * Used by the "enchant" function (chance of failure)
1774 * (modified for Zangband, we need better stuff there...) -- TY
1776 static int enchant_table[16] =
1778 0, 10, 50, 100, 200,
1779 300, 400, 500, 650, 800,
1780 950, 987, 993, 995, 998,
1786 * Removes curses from items in inventory
1788 * Note that Items which are "Perma-Cursed" (The One Ring,
1789 * The Crown of Morgoth) can NEVER be uncursed.
1791 * Note that if "all" is FALSE, then Items which are
1792 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1793 * will not be uncursed.
1795 static int remove_curse_aux(int all)
1799 /* Attempt to uncurse items being worn */
1800 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1802 object_type *o_ptr = &inventory[i];
1804 /* Skip non-objects */
1805 if (!o_ptr->k_idx) continue;
1807 /* Uncursed already */
1808 if (!cursed_p(o_ptr)) continue;
1810 /* Heavily Cursed Items need a special spell */
1811 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1813 /* Perma-Cursed Items can NEVER be uncursed */
1814 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1817 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1822 o_ptr->curse_flags = 0L;
1824 /* Hack -- Assume felt */
1825 o_ptr->ident |= (IDENT_SENSE);
1828 o_ptr->feeling = FEEL_NONE;
1830 /* Recalculate the bonuses */
1831 p_ptr->update |= (PU_BONUS);
1834 p_ptr->window |= (PW_EQUIP);
1836 /* Count the uncursings */
1840 /* Return "something uncursed" */
1846 * Remove most curses
1848 bool remove_curse(void)
1850 return (remove_curse_aux(FALSE));
1856 bool remove_all_curse(void)
1858 return (remove_curse_aux(TRUE));
1863 * Turns an object into gold, gain some of its value in a shop
1872 char o_name[MAX_NLEN];
1873 char out_val[MAX_NLEN+40];
1877 /* Hack -- force destruction */
1878 if (command_arg > 0) force = TRUE;
1882 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
1883 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
1885 q = "Turn which item to gold? ";
1886 s = "You have nothing to turn to gold.";
1889 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
1891 /* Get the item (in the pack) */
1894 o_ptr = &inventory[item];
1897 /* Get the item (on the floor) */
1900 o_ptr = &o_list[0 - item];
1904 /* See how many items */
1905 if (o_ptr->number > 1)
1907 /* Get a quantity */
1908 amt = get_quantity(NULL, o_ptr->number);
1910 /* Allow user abort */
1911 if (amt <= 0) return FALSE;
1915 /* Describe the object */
1916 old_number = o_ptr->number;
1917 o_ptr->number = amt;
1918 object_desc(o_name, o_ptr, TRUE, 3);
1919 o_ptr->number = old_number;
1921 /* Verify unless quantity given */
1924 if (confirm_destroy || (object_value(o_ptr) > 0))
1926 /* Make a verification */
1928 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
1930 sprintf(out_val, "Really turn %s to gold? ", o_name);
1933 if (!get_check(out_val)) return FALSE;
1937 /* Artifacts cannot be destroyed */
1938 if (!can_player_destroy_object(o_ptr))
1942 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
1944 msg_format("You fail to turn %s to gold!", o_name);
1951 price = object_value_real(o_ptr);
1957 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
1959 msg_format("You turn %s to fool's gold.", o_name);
1967 if (amt > 1) price *= amt;
1969 if (price > 30000) price = 30000;
1971 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
1973 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
1979 p_ptr->redraw |= (PR_GOLD);
1982 p_ptr->window |= (PW_PLAYER);
1986 /* Eliminate the item (from the pack) */
1989 inven_item_increase(item, -amt);
1990 inven_item_describe(item);
1991 inven_item_optimize(item);
1994 /* Eliminate the item (from the floor) */
1997 floor_item_increase(0 - item, -amt);
1998 floor_item_describe(0 - item);
1999 floor_item_optimize(0 - item);
2008 * Hook to specify "weapon"
2010 bool item_tester_hook_weapon(object_type *o_ptr)
2012 switch (o_ptr->tval)
2026 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2033 static bool item_tester_hook_weapon2(object_type *o_ptr)
2035 switch (o_ptr->tval)
2055 * Hook to specify "armour"
2057 bool item_tester_hook_armour(object_type *o_ptr)
2059 switch (o_ptr->tval)
2080 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2082 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2084 switch (o_ptr->tval)
2113 * Check if an object is nameless weapon or armour
2115 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2117 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2120 switch (o_ptr->tval)
2149 * Break the curse of an item
2151 static void break_curse(object_type *o_ptr)
2153 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2156 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2158 msg_print("The curse is broken!");
2161 o_ptr->curse_flags = 0L;
2163 o_ptr->ident |= (IDENT_SENSE);
2165 o_ptr->feeling = FEEL_NONE;
2171 * Enchants a plus onto an item. -RAK-
2173 * Revamped! Now takes item pointer, number of times to try enchanting,
2174 * and a flag of what to try enchanting. Artifacts resist enchantment
2175 * some of the time, and successful enchantment to at least +0 might
2176 * break a curse on the item. -CFT-
2178 * Note that an item can technically be enchanted all the way to +15 if
2179 * you wait a very, very, long time. Going from +9 to +10 only works
2180 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2182 * Note that this function can now be used on "piles" of items, and
2183 * the larger the pile, the lower the chance of success.
2185 bool enchant(object_type *o_ptr, int n, int eflag)
2187 int i, chance, prob;
2189 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2190 bool force = (eflag & ENCH_FORCE);
2193 /* Large piles resist enchantment */
2194 prob = o_ptr->number * 100;
2196 /* Missiles are easy to enchant */
2197 if ((o_ptr->tval == TV_BOLT) ||
2198 (o_ptr->tval == TV_ARROW) ||
2199 (o_ptr->tval == TV_SHOT))
2205 for (i = 0; i < n; i++)
2207 /* Hack -- Roll for pile resistance */
2208 if (!force && randint0(prob) >= 100) continue;
2210 /* Enchant to hit */
2211 if (eflag & ENCH_TOHIT)
2213 if (o_ptr->to_h < 0) chance = 0;
2214 else if (o_ptr->to_h > 15) chance = 1000;
2215 else chance = enchant_table[o_ptr->to_h];
2217 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2222 /* only when you get it above -1 -CFT */
2223 if (o_ptr->to_h >= 0)
2228 /* Enchant to damage */
2229 if (eflag & ENCH_TODAM)
2231 if (o_ptr->to_d < 0) chance = 0;
2232 else if (o_ptr->to_d > 15) chance = 1000;
2233 else chance = enchant_table[o_ptr->to_d];
2235 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2240 /* only when you get it above -1 -CFT */
2241 if (o_ptr->to_d >= 0)
2246 /* Enchant to armor class */
2247 if (eflag & ENCH_TOAC)
2249 if (o_ptr->to_a < 0) chance = 0;
2250 else if (o_ptr->to_a > 15) chance = 1000;
2251 else chance = enchant_table[o_ptr->to_a];
2253 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2258 /* only when you get it above -1 -CFT */
2259 if (o_ptr->to_a >= 0)
2266 if (!res) return (FALSE);
2268 /* Recalculate bonuses */
2269 p_ptr->update |= (PU_BONUS);
2271 /* Combine / Reorder the pack (later) */
2272 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2275 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2286 * Enchant an item (in the inventory or on the floor)
2287 * Note that "num_ac" requires armour, else weapon
2288 * Returns TRUE if attempted, FALSE if cancelled
2290 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2295 char o_name[MAX_NLEN];
2299 /* Assume enchant weapon */
2300 item_tester_hook = item_tester_hook_weapon;
2301 item_tester_no_ryoute = TRUE;
2303 /* Enchant armor if requested */
2304 if (num_ac) item_tester_hook = item_tester_hook_armour;
2308 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2309 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2311 q = "Enchant which item? ";
2312 s = "You have nothing to enchant.";
2315 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2317 /* Get the item (in the pack) */
2320 o_ptr = &inventory[item];
2323 /* Get the item (on the floor) */
2326 o_ptr = &o_list[0 - item];
2331 object_desc(o_name, o_ptr, FALSE, 0);
2335 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2338 msg_format("%s %s glow%s brightly!",
2339 ((item >= 0) ? "Your" : "The"), o_name,
2340 ((o_ptr->number > 1) ? "" : "s"));
2345 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2346 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2347 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2353 if (flush_failure) flush();
2357 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2359 msg_print("The enchantment failed.");
2362 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2365 chg_virtue(V_ENCHANT, 1);
2369 /* Something happened */
2374 bool artifact_scroll(void)
2379 char o_name[MAX_NLEN];
2383 item_tester_no_ryoute = TRUE;
2384 /* Enchant weapon/armour */
2385 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2389 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2390 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2392 q = "Enchant which item? ";
2393 s = "You have nothing to enchant.";
2396 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2398 /* Get the item (in the pack) */
2401 o_ptr = &inventory[item];
2404 /* Get the item (on the floor) */
2407 o_ptr = &o_list[0 - item];
2412 object_desc(o_name, o_ptr, FALSE, 0);
2416 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2418 msg_format("%s %s radiate%s a blinding light!",
2419 ((item >= 0) ? "Your" : "The"), o_name,
2420 ((o_ptr->number > 1) ? "" : "s"));
2423 if (o_ptr->name1 || o_ptr->art_name)
2426 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª",
2429 msg_format("The %s %s already %s!",
2430 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2431 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2437 else if (o_ptr->name2)
2440 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª",
2443 msg_format("The %s %s already %s!",
2444 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2445 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2451 else if (o_ptr->xtra3)
2454 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª",
2457 msg_format("The %s %s already %s!",
2458 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2459 ((o_ptr->number > 1) ? "kaji items" : "an kaji item"));
2465 if (o_ptr->number > 1)
2468 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2469 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2471 msg_print("Not enough enough energy to enchant more than one object!");
2472 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2477 inven_item_increase(item, 1-(o_ptr->number));
2481 floor_item_increase(0-item, 1-(o_ptr->number));
2484 okay = create_artifact(o_ptr, TRUE);
2491 if (flush_failure) flush();
2495 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2497 msg_print("The enchantment failed.");
2500 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2503 chg_virtue(V_ENCHANT, 1);
2507 /* Something happened */
2513 * Identify an object
2515 bool identify_item(object_type *o_ptr)
2517 bool old_known = FALSE;
2518 char o_name[MAX_NLEN];
2521 object_desc(o_name, o_ptr, TRUE, 3);
2523 if (o_ptr->ident & IDENT_KNOWN)
2526 if (!(o_ptr->ident & (IDENT_MENTAL)))
2528 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2529 chg_virtue(V_KNOWLEDGE, 1);
2532 /* Identify it fully */
2533 object_aware(o_ptr);
2534 object_known(o_ptr);
2536 /* Recalculate bonuses */
2537 p_ptr->update |= (PU_BONUS);
2539 /* Combine / Reorder the pack (later) */
2540 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2543 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2545 strcpy(record_o_name, o_name);
2549 object_desc(o_name, o_ptr, TRUE, 0);
2551 if(record_fix_art && !old_known && artifact_p(o_ptr))
2552 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2553 if(record_rand_art && !old_known && o_ptr->art_name)
2554 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2560 static bool item_tester_hook_identify(object_type *o_ptr)
2562 return (bool)!object_known_p(o_ptr);
2565 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2567 if (object_known_p(o_ptr))
2569 return item_tester_hook_weapon_armour(o_ptr);
2573 * Identify an object in the inventory (or on the floor)
2574 * This routine does *not* automatically combine objects.
2575 * Returns TRUE if something was identified, else FALSE.
2577 bool ident_spell(bool only_equip)
2581 char o_name[MAX_NLEN];
2586 item_tester_no_ryoute = TRUE;
2589 item_tester_hook = item_tester_hook_identify_weapon_armour;
2591 item_tester_hook = item_tester_hook_identify;
2593 if (!can_get_item())
2597 item_tester_hook = item_tester_hook_weapon_armour;
2601 item_tester_hook = NULL;
2607 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2608 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2610 q = "Identify which item? ";
2611 s = "You have nothing to identify.";
2614 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2616 /* Get the item (in the pack) */
2619 o_ptr = &inventory[item];
2622 /* Get the item (on the floor) */
2625 o_ptr = &o_list[0 - item];
2629 old_known = identify_item(o_ptr);
2632 object_desc(o_name, o_ptr, TRUE, 3);
2635 if (item >= INVEN_RARM)
2638 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2640 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2646 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2648 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2654 msg_format("¾²¾å: %s¡£", o_name);
2656 msg_format("On the ground: %s.", o_name);
2660 /* Auto-inscription/destroy */
2661 idx = is_autopick(o_ptr);
2662 auto_inscribe_item(item, idx);
2663 if (destroy_identify && !old_known)
2664 auto_destroy_item(item, idx);
2666 /* Something happened */
2672 * Mundanify an object in the inventory (or on the floor)
2673 * This routine does *not* automatically combine objects.
2674 * Returns TRUE if something was mundanified, else FALSE.
2676 bool mundane_spell(bool only_equip)
2682 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
2683 item_tester_no_ryoute = TRUE;
2687 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2688 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2690 q = "Use which item? ";
2691 s = "You have nothing you can use.";
2694 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2696 /* Get the item (in the pack) */
2699 o_ptr = &inventory[item];
2702 /* Get the item (on the floor) */
2705 o_ptr = &o_list[0 - item];
2710 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2712 msg_print("There is a bright flash of light!");
2715 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2716 byte ix = o_ptr->ix; /* X-position on map, or zero */
2717 s16b next_o_idx= o_ptr->next_o_idx; /* Next object in stack (if any) */
2718 byte marked=o_ptr->marked; /* Object is marked */
2719 s16b weight = (o_ptr->number*o_ptr->weight);
2722 object_prep(o_ptr, o_ptr->k_idx);
2726 o_ptr->next_o_idx=next_o_idx;
2727 o_ptr->marked=marked;
2728 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2732 /* Something happened */
2738 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2740 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2743 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2745 if (!item_tester_hook_identify_fully(o_ptr))
2747 return item_tester_hook_weapon_armour(o_ptr);
2751 * Fully "identify" an object in the inventory -BEN-
2752 * This routine returns TRUE if an item was identified.
2754 bool identify_fully(bool only_equip)
2758 char o_name[MAX_NLEN];
2763 item_tester_no_ryoute = TRUE;
2765 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2767 item_tester_hook = item_tester_hook_identify_fully;
2769 if (!can_get_item())
2772 item_tester_hook = item_tester_hook_weapon_armour;
2774 item_tester_hook = NULL;
2779 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2780 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2782 q = "Identify which item? ";
2783 s = "You have nothing to identify.";
2786 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2788 /* Get the item (in the pack) */
2791 o_ptr = &inventory[item];
2794 /* Get the item (on the floor) */
2797 o_ptr = &o_list[0 - item];
2801 old_known = identify_item(o_ptr);
2803 /* Mark the item as fully known */
2804 o_ptr->ident |= (IDENT_MENTAL);
2810 object_desc(o_name, o_ptr, TRUE, 3);
2813 if (item >= INVEN_RARM)
2816 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2818 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2826 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2828 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2834 msg_format("¾²¾å: %s¡£", o_name);
2836 msg_format("On the ground: %s.", o_name);
2840 /* Describe it fully */
2841 (void)screen_object(o_ptr, TRUE);
2843 /* Auto-inscription/destroy */
2844 idx = is_autopick(o_ptr);
2845 auto_inscribe_item(item, idx);
2846 if (destroy_identify && !old_known)
2847 auto_destroy_item(item, idx);
2857 * Hook for "get_item()". Determine if something is rechargable.
2859 bool item_tester_hook_recharge(object_type *o_ptr)
2861 /* Recharge staffs */
2862 if (o_ptr->tval == TV_STAFF) return (TRUE);
2864 /* Recharge wands */
2865 if (o_ptr->tval == TV_WAND) return (TRUE);
2867 /* Hack -- Recharge rods */
2868 if (o_ptr->tval == TV_ROD) return (TRUE);
2876 * Recharge a wand/staff/rod from the pack or on the floor.
2877 * This function has been rewritten in Oangband and ZAngband.
2879 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2880 * Chaos -- Arcane Binding --> recharge(90)
2882 * Scroll of recharging --> recharge(130)
2883 * Artifact activation/Thingol --> recharge(130)
2885 * It is harder to recharge high level, and highly charged wands,
2886 * staffs, and rods. The more wands in a stack, the more easily and
2887 * strongly they recharge. Staffs, however, each get fewer charges if
2890 * XXX XXX XXX Beware of "sliding index errors".
2892 bool recharge(int power)
2895 int recharge_strength, recharge_amount;
2904 char o_name[MAX_NLEN];
2906 /* Only accept legal items */
2907 item_tester_hook = item_tester_hook_recharge;
2911 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
2912 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2914 q = "Recharge which item? ";
2915 s = "You have nothing to recharge.";
2918 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2920 /* Get the item (in the pack) */
2923 o_ptr = &inventory[item];
2926 /* Get the item (on the floor) */
2929 o_ptr = &o_list[0 - item];
2932 /* Get the object kind. */
2933 k_ptr = &k_info[o_ptr->k_idx];
2935 /* Extract the object "level" */
2936 lev = get_object_level(o_ptr);
2939 /* Recharge a rod */
2940 if (o_ptr->tval == TV_ROD)
2942 /* Extract a recharge strength by comparing object level to power. */
2943 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
2947 if (one_in_(recharge_strength))
2949 /* Activate the failure code. */
2956 /* Recharge amount */
2957 recharge_amount = (power * damroll(3, 2));
2959 /* Recharge by that amount */
2960 if (o_ptr->timeout > recharge_amount)
2961 o_ptr->timeout -= recharge_amount;
2968 /* Recharge wand/staff */
2971 /* Extract a recharge strength by comparing object level to power.
2972 * Divide up a stack of wands' charges to calculate charge penalty.
2974 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2975 recharge_strength = (100 + power - lev -
2976 (8 * o_ptr->pval / o_ptr->number)) / 15;
2978 /* All staffs, unstacked wands. */
2979 else recharge_strength = (100 + power - lev -
2980 (8 * o_ptr->pval)) / 15;
2983 if (recharge_strength < 0) recharge_strength = 0;
2986 if (one_in_(recharge_strength))
2988 /* Activate the failure code. */
2992 /* If the spell didn't backfire, recharge the wand or staff. */
2995 /* Recharge based on the standard number of charges. */
2996 recharge_amount = randint1(1 + k_ptr->pval / 2);
2998 /* Multiple wands in a stack increase recharging somewhat. */
2999 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3002 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3003 if (recharge_amount < 1) recharge_amount = 1;
3004 if (recharge_amount > 12) recharge_amount = 12;
3007 /* But each staff in a stack gets fewer additional charges,
3008 * although always at least one.
3010 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3012 recharge_amount /= o_ptr->number;
3013 if (recharge_amount < 1) recharge_amount = 1;
3016 /* Recharge the wand or staff. */
3017 o_ptr->pval += recharge_amount;
3020 /* Hack -- we no longer "know" the item */
3021 o_ptr->ident &= ~(IDENT_KNOWN);
3023 /* Hack -- we no longer think the item is empty */
3024 o_ptr->ident &= ~(IDENT_EMPTY);
3029 /* Inflict the penalties for failing a recharge. */
3032 /* Artifacts are never destroyed. */
3033 if (artifact_p(o_ptr))
3035 object_desc(o_name, o_ptr, TRUE, 0);
3037 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3039 msg_format("The recharging backfires - %s is completely drained!", o_name);
3043 /* Artifact rods. */
3044 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3045 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3047 /* Artifact wands and staffs. */
3048 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3053 /* Get the object description */
3054 object_desc(o_name, o_ptr, FALSE, 0);
3056 /*** Determine Seriousness of Failure ***/
3058 /* Mages recharge objects more safely. */
3059 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)
3061 /* 10% chance to blow up one rod, otherwise draining. */
3062 if (o_ptr->tval == TV_ROD)
3064 if (one_in_(10)) fail_type = 2;
3067 /* 75% chance to blow up one wand, otherwise draining. */
3068 else if (o_ptr->tval == TV_WAND)
3070 if (!one_in_(3)) fail_type = 2;
3073 /* 50% chance to blow up one staff, otherwise no effect. */
3074 else if (o_ptr->tval == TV_STAFF)
3076 if (one_in_(2)) fail_type = 2;
3081 /* All other classes get no special favors. */
3084 /* 33% chance to blow up one rod, otherwise draining. */
3085 if (o_ptr->tval == TV_ROD)
3087 if (one_in_(3)) fail_type = 2;
3090 /* 20% chance of the entire stack, else destroy one wand. */
3091 else if (o_ptr->tval == TV_WAND)
3093 if (one_in_(5)) fail_type = 3;
3096 /* Blow up one staff. */
3097 else if (o_ptr->tval == TV_STAFF)
3103 /*** Apply draining and destruction. ***/
3105 /* Drain object or stack of objects. */
3108 if (o_ptr->tval == TV_ROD)
3111 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3113 msg_print("The recharge backfires, draining the rod further!");
3116 if (o_ptr->timeout < 10000)
3117 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3119 else if (o_ptr->tval == TV_WAND)
3122 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3124 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3129 /* Staffs aren't drained. */
3132 /* Destroy an object or one in a stack of objects. */
3135 if (o_ptr->number > 1)
3137 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3139 msg_format("Wild magic consumes one of your %s!", o_name);
3144 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3146 msg_format("Wild magic consumes your %s!", o_name);
3150 /* Reduce rod stack maximum timeout, drain wands. */
3151 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3152 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3154 /* Reduce and describe inventory */
3157 inven_item_increase(item, -1);
3158 inven_item_describe(item);
3159 inven_item_optimize(item);
3162 /* Reduce and describe floor item */
3165 floor_item_increase(0 - item, -1);
3166 floor_item_describe(0 - item);
3167 floor_item_optimize(0 - item);
3171 /* Destroy all members of a stack of objects. */
3174 if (o_ptr->number > 1)
3176 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3178 msg_format("Wild magic consumes all your %s!", o_name);
3183 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3185 msg_format("Wild magic consumes your %s!", o_name);
3190 /* Reduce and describe inventory */
3193 inven_item_increase(item, -999);
3194 inven_item_describe(item);
3195 inven_item_optimize(item);
3198 /* Reduce and describe floor item */
3201 floor_item_increase(0 - item, -999);
3202 floor_item_describe(0 - item);
3203 floor_item_optimize(0 - item);
3209 /* Combine / Reorder the pack (later) */
3210 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3213 p_ptr->window |= (PW_INVEN);
3215 /* Something was done */
3223 bool bless_weapon(void)
3227 u32b flgs[TR_FLAG_SIZE];
3228 char o_name[MAX_NLEN];
3231 item_tester_no_ryoute = TRUE;
3232 /* Assume enchant weapon */
3233 item_tester_hook = item_tester_hook_weapon2;
3237 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3238 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3240 q = "Bless which weapon? ";
3241 s = "You have weapon to bless.";
3244 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3247 /* Get the item (in the pack) */
3250 o_ptr = &inventory[item];
3253 /* Get the item (on the floor) */
3256 o_ptr = &o_list[0 - item];
3261 object_desc(o_name, o_ptr, FALSE, 0);
3263 /* Extract the flags */
3264 object_flags(o_ptr, flgs);
3266 if (cursed_p(o_ptr))
3268 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3269 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3272 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3275 msg_format("The black aura on %s %s disrupts the blessing!",
3276 ((item >= 0) ? "your" : "the"), o_name);
3283 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3286 msg_format("A malignant aura leaves %s %s.",
3287 ((item >= 0) ? "your" : "the"), o_name);
3292 o_ptr->curse_flags = 0L;
3294 /* Hack -- Assume felt */
3295 o_ptr->ident |= (IDENT_SENSE);
3298 o_ptr->feeling = FEEL_NONE;
3300 /* Recalculate the bonuses */
3301 p_ptr->update |= (PU_BONUS);
3304 p_ptr->window |= (PW_EQUIP);
3308 * Next, we try to bless it. Artifacts have a 1/3 chance of
3309 * being blessed, otherwise, the operation simply disenchants
3310 * them, godly power negating the magic. Ok, the explanation
3311 * is silly, but otherwise priests would always bless every
3312 * artifact weapon they find. Ego weapons and normal weapons
3313 * can be blessed automatically.
3315 if (have_flag(flgs, TR_BLESSED))
3318 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3321 msg_format("%s %s %s blessed already.",
3322 ((item >= 0) ? "Your" : "The"), o_name,
3323 ((o_ptr->number > 1) ? "were" : "was"));
3329 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3333 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3336 msg_format("%s %s shine%s!",
3337 ((item >= 0) ? "Your" : "The"), o_name,
3338 ((o_ptr->number > 1) ? "" : "s"));
3341 add_flag(o_ptr->art_flags, TR_BLESSED);
3342 o_ptr->discount = 99;
3346 bool dis_happened = FALSE;
3349 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3351 msg_print("The weapon resists your blessing!");
3355 /* Disenchant tohit */
3356 if (o_ptr->to_h > 0)
3359 dis_happened = TRUE;
3362 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3364 /* Disenchant todam */
3365 if (o_ptr->to_d > 0)
3368 dis_happened = TRUE;
3371 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3373 /* Disenchant toac */
3374 if (o_ptr->to_a > 0)
3377 dis_happened = TRUE;
3380 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3385 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3387 msg_print("There is a static feeling in the air...");
3391 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3394 msg_format("%s %s %s disenchanted!",
3395 ((item >= 0) ? "Your" : "The"), o_name,
3396 ((o_ptr->number > 1) ? "were" : "was"));
3402 /* Recalculate bonuses */
3403 p_ptr->update |= (PU_BONUS);
3406 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3417 bool pulish_shield(void)
3421 u32b flgs[TR_FLAG_SIZE];
3422 char o_name[MAX_NLEN];
3425 item_tester_no_ryoute = TRUE;
3426 /* Assume enchant weapon */
3427 item_tester_tval = TV_SHIELD;
3431 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3432 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3434 q = "Pulish which weapon? ";
3435 s = "You have weapon to pulish.";
3438 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3441 /* Get the item (in the pack) */
3444 o_ptr = &inventory[item];
3447 /* Get the item (on the floor) */
3450 o_ptr = &o_list[0 - item];
3455 object_desc(o_name, o_ptr, FALSE, 0);
3457 /* Extract the flags */
3458 object_flags(o_ptr, flgs);
3460 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3461 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3464 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3466 msg_format("%s %s shine%s!",
3467 ((item >= 0) ? "Your" : "The"), o_name,
3468 ((o_ptr->number > 1) ? "" : "s"));
3470 o_ptr->name2 = EGO_REFLECTION;
3471 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3473 o_ptr->discount = 99;
3474 chg_virtue(V_ENCHANT, 2);
3480 if (flush_failure) flush();
3483 msg_print("¼ºÇÔ¤·¤¿¡£");
3485 msg_print("Failed.");
3488 chg_virtue(V_ENCHANT, -2);
3497 * Potions "smash open" and cause an area effect when
3498 * (1) they are shattered while in the player's inventory,
3499 * due to cold (etc) attacks;
3500 * (2) they are thrown at a monster, or obstacle;
3501 * (3) they are shattered by a "cold ball" or other such spell
3502 * while lying on the floor.
3505 * who --- who caused the potion to shatter (0=player)
3506 * potions that smash on the floor are assumed to
3507 * be caused by no-one (who = 1), as are those that
3508 * shatter inside the player inventory.
3509 * (Not anymore -- I changed this; TY)
3510 * y, x --- coordinates of the potion (or player if
3511 * the potion was in her inventory);
3512 * o_ptr --- pointer to the potion object.
3514 bool potion_smash_effect(int who, int y, int x, int k_idx)
3521 object_kind *k_ptr = &k_info[k_idx];
3523 switch (k_ptr->sval)
3525 case SV_POTION_SALT_WATER:
3526 case SV_POTION_SLIME_MOLD:
3527 case SV_POTION_LOSE_MEMORIES:
3528 case SV_POTION_DEC_STR:
3529 case SV_POTION_DEC_INT:
3530 case SV_POTION_DEC_WIS:
3531 case SV_POTION_DEC_DEX:
3532 case SV_POTION_DEC_CON:
3533 case SV_POTION_DEC_CHR:
3534 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3535 case SV_POTION_APPLE_JUICE:
3538 case SV_POTION_INFRAVISION:
3539 case SV_POTION_DETECT_INVIS:
3540 case SV_POTION_SLOW_POISON:
3541 case SV_POTION_CURE_POISON:
3542 case SV_POTION_BOLDNESS:
3543 case SV_POTION_RESIST_HEAT:
3544 case SV_POTION_RESIST_COLD:
3545 case SV_POTION_HEROISM:
3546 case SV_POTION_BESERK_STRENGTH:
3547 case SV_POTION_RES_STR:
3548 case SV_POTION_RES_INT:
3549 case SV_POTION_RES_WIS:
3550 case SV_POTION_RES_DEX:
3551 case SV_POTION_RES_CON:
3552 case SV_POTION_RES_CHR:
3553 case SV_POTION_INC_STR:
3554 case SV_POTION_INC_INT:
3555 case SV_POTION_INC_WIS:
3556 case SV_POTION_INC_DEX:
3557 case SV_POTION_INC_CON:
3558 case SV_POTION_INC_CHR:
3559 case SV_POTION_AUGMENTATION:
3560 case SV_POTION_ENLIGHTENMENT:
3561 case SV_POTION_STAR_ENLIGHTENMENT:
3562 case SV_POTION_SELF_KNOWLEDGE:
3563 case SV_POTION_EXPERIENCE:
3564 case SV_POTION_RESISTANCE:
3565 case SV_POTION_INVULNERABILITY:
3566 case SV_POTION_NEW_LIFE:
3567 /* All of the above potions have no effect when shattered */
3569 case SV_POTION_SLOWNESS:
3574 case SV_POTION_POISON:
3579 case SV_POTION_BLINDNESS:
3583 case SV_POTION_CONFUSION: /* Booze */
3587 case SV_POTION_SLEEP:
3591 case SV_POTION_RUINATION:
3592 case SV_POTION_DETONATIONS:
3594 dam = damroll(25, 25);
3597 case SV_POTION_DEATH:
3598 dt = GF_DEATH_RAY; /* !! */
3599 dam = k_ptr->level * 10;
3603 case SV_POTION_SPEED:
3606 case SV_POTION_CURE_LIGHT:
3608 dam = damroll(2, 3);
3610 case SV_POTION_CURE_SERIOUS:
3612 dam = damroll(4, 3);
3614 case SV_POTION_CURE_CRITICAL:
3615 case SV_POTION_CURING:
3617 dam = damroll(6, 3);
3619 case SV_POTION_HEALING:
3621 dam = damroll(10, 10);
3623 case SV_POTION_RESTORE_EXP:
3628 case SV_POTION_LIFE:
3630 dam = damroll(50, 50);
3633 case SV_POTION_STAR_HEALING:
3635 dam = damroll(50, 50);
3638 case SV_POTION_RESTORE_MANA: /* MANA */
3640 dam = damroll(10, 10);
3647 (void)project(who, radius, y, x, dam, dt,
3648 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3650 /* XXX those potions that explode need to become "known" */
3656 * Hack -- Display all known spells in a window
3658 * XXX XXX XXX Need to analyze size of the window.
3660 * XXX XXX XXX Need more color coding.
3662 void display_spell_list(void)
3675 /* They have too many spells to list */
3676 if (p_ptr->pclass == CLASS_SORCERER) return;
3677 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3679 /* mind.c type classes */
3680 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3681 (p_ptr->pclass == CLASS_BERSERKER) ||
3682 (p_ptr->pclass == CLASS_NINJA) ||
3683 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3684 (p_ptr->pclass == CLASS_FORCETRAINER))
3690 int plev = p_ptr->lev;
3696 bool use_hp = FALSE;
3698 /* Display a list of spells */
3701 put_str("̾Á°", y, x + 5);
3702 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3704 put_str("Name", y, x + 5);
3705 put_str("Lv Mana Fail Info", y, x + 35);
3708 switch(p_ptr->pclass)
3710 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3711 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3712 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3713 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3714 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3715 default: use_mind = 0;break;
3718 /* Dump the spells */
3719 for (i = 0; i < MAX_MIND_POWERS; i++)
3721 byte a = TERM_WHITE;
3723 /* Access the available spell */
3724 spell = mind_powers[use_mind].info[i];
3725 if (spell.min_lev > plev) break;
3727 /* Get the failure rate */
3728 chance = spell.fail;
3730 /* Reduce failure rate by "effective" level adjustment */
3731 chance -= 3 * (p_ptr->lev - spell.min_lev);
3733 /* Reduce failure rate by INT/WIS adjustment */
3734 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3738 /* Not enough mana to cast */
3739 if (spell.mana_cost > p_ptr->csp)
3741 chance += 5 * (spell.mana_cost - p_ptr->csp);
3747 /* Not enough hp to cast */
3748 if (spell.mana_cost > p_ptr->chp)
3755 /* Extract the minimum failure rate */
3756 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3758 /* Minimum failure rate */
3759 if (chance < minfail) chance = minfail;
3761 /* Stunning makes spells harder */
3762 if (p_ptr->stun > 50) chance += 25;
3763 else if (p_ptr->stun) chance += 15;
3765 /* Always a 5 percent chance of working */
3766 if (chance > 95) chance = 95;
3769 mindcraft_info(comment, use_mind, i);
3771 /* Dump the spell */
3772 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3774 spell.min_lev, spell.mana_cost, chance, comment);
3776 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3781 /* Cannot read spellbooks */
3782 if (REALM_NONE == p_ptr->realm1) return;
3784 /* Normal spellcaster with books */
3787 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3791 /* Reset vertical */
3794 /* Vertical location */
3795 y = (j < 3) ? 0 : (m[j - 3] + 2);
3797 /* Horizontal location */
3801 for (i = 0; i < 32; i++)
3803 byte a = TERM_WHITE;
3805 /* Access the spell */
3806 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3808 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3812 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3815 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
3818 if (s_ptr->slevel >= 99)
3822 strcpy(name, "(ȽÆÉÉÔǽ)");
3824 strcpy(name, "(illegible)");
3834 ((p_ptr->spell_forgotten1 & (1L << i))) :
3835 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3842 else if (!((j < 1) ?
3843 (p_ptr->spell_learned1 & (1L << i)) :
3844 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3851 else if (!((j < 1) ?
3852 (p_ptr->spell_worked1 & (1L << i)) :
3853 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3859 /* Dump the spell --(-- */
3860 sprintf(out_val, "%c/%c) %-20.20s",
3861 I2A(n / 8), I2A(n % 8), name);
3866 /* Dump onto the window */
3867 Term_putstr(x, m[j], -1, a, out_val);
3877 * Returns experience of a spell
3879 s16b experience_of_spell(int spell, int use_realm)
3881 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3882 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3883 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3884 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3890 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3892 int mod_need_mana(int need_mana, int spell, int realm)
3895 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
3897 need_mana = need_mana * (3800 - experience_of_spell(spell, realm)) + 2399;
3899 if (p_ptr->dec_mana) need_mana *= 3;
3900 else need_mana *= 4;
3903 if (need_mana < 1) need_mana = 1;
3906 /* Non-realm magic */
3909 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * 3 / 4;
3917 * Returns spell chance of failure for spell -RAK-
3919 s16b spell_chance(int spell, int use_realm)
3921 int chance, minfail;
3924 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
3927 /* Paranoia -- must be literate */
3928 if (!mp_ptr->spell_book) return (100);
3930 if (use_realm == REALM_HISSATSU) return 0;
3932 /* Access the spell */
3933 if (!is_magic(use_realm))
3935 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3939 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3942 /* Extract the base spell failure rate */
3943 chance = s_ptr->sfail;
3945 /* Reduce failure rate by "effective" level adjustment */
3946 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
3948 /* Reduce failure rate by INT/WIS adjustment */
3949 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3952 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
3954 /* Extract mana consumption rate */
3955 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3957 /* Not enough mana to cast */
3958 if (need_mana > p_ptr->csp)
3960 chance += 5 * (need_mana - p_ptr->csp);
3963 chance += p_ptr->to_m_chance;
3964 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
3966 /* Extract the minimum failure rate */
3967 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3970 * Non mage/priest characters never get too good
3971 * (added high mage, mindcrafter)
3973 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
3975 if (minfail < 5) minfail = 5;
3978 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
3979 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3980 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
3982 if (p_ptr->heavy_spell) chance += 20;
3983 if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
3984 else if (p_ptr->easy_spell) chance-=3;
3985 else if (p_ptr->dec_mana) chance-=2;
3987 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
3988 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
3989 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
3991 /* Minimum failure rate */
3992 if (chance < minfail) chance = minfail;
3994 /* Stunning makes spells harder */
3995 if (p_ptr->stun > 50) chance += 25;
3996 else if (p_ptr->stun) chance += 15;
3998 /* Always a 5 percent chance of working */
3999 if (chance > 95) chance = 95;
4001 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4002 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4004 s16b exp = experience_of_spell(spell, use_realm);
4005 if (exp >= SPELL_EXP_EXPERT) chance--;
4006 if (exp >= SPELL_EXP_MASTER) chance--;
4008 if(p_ptr->dec_mana) chance--;
4009 if (p_ptr->heavy_spell) chance += 5;
4011 chance = MAX(chance,0);
4013 /* Return the chance */
4020 * Determine if a spell is "okay" for the player to cast or study
4021 * The spell must be legible, not forgotten, and also, to cast,
4022 * it must be known, and to study, it must not be known.
4024 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4028 /* Access the spell */
4029 if (!is_magic(use_realm))
4031 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4035 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4038 /* Spell is illegal */
4039 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4041 /* Spell is forgotten */
4042 if ((use_realm == p_ptr->realm2) ?
4043 (p_ptr->spell_forgotten2 & (1L << spell)) :
4044 (p_ptr->spell_forgotten1 & (1L << spell)))
4050 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4051 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4053 /* Spell is learned */
4054 if ((use_realm == p_ptr->realm2) ?
4055 (p_ptr->spell_learned2 & (1L << spell)) :
4056 (p_ptr->spell_learned1 & (1L << spell)))
4059 return (!study_pray);
4062 /* Okay to study, not to cast */
4069 * Extra information on a spell -DRS-
4071 * We can use up to 14 characters of the buffer 'p'
4073 * The strings in this function were extracted from the code in the
4074 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4076 static void spell_info(char *p, int spell, int use_realm)
4078 int plev = p_ptr->lev;
4081 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4082 p_ptr->pclass == CLASS_HIGH_MAGE ||
4083 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4085 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4086 p_ptr->pclass == CLASS_HIGH_MAGE ||
4087 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4089 cptr s_dam = "»½ý:";
4090 cptr s_dur = "´ü´Ö:";
4091 cptr s_range = "ÈÏ°Ï:";
4092 cptr s_heal = "²óÉü:";
4093 cptr s_random = "¥é¥ó¥À¥à";
4094 cptr s_delay = "ÃÙ±ä:";
4096 cptr s_dam = "dam ";
4097 cptr s_dur = "dur ";
4098 cptr s_range = "range ";
4099 cptr s_heal = "heal ";
4100 cptr s_random = "random";
4101 cptr s_delay = "delay ";
4106 /* Analyze the spell */
4109 case REALM_LIFE: /* Life */
4112 case 0: sprintf(p, " %s2d10", s_heal); break;
4113 case 1: sprintf(p, " %s12+d12", s_dur); break;
4114 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4115 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4116 case 5: sprintf(p, " %s4d10", s_heal); break;
4117 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4118 case 10: sprintf(p, " %s8d10", s_heal); break;
4119 case 11: sprintf(p, " %s20+d20", s_dur); break;
4120 case 14: sprintf(p, " %s300", s_heal); break;
4121 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4122 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4123 case 21: sprintf(p, " %s15+d21", s_delay); break;
4124 case 29: sprintf(p, " %s2000", s_heal); break;
4125 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4129 case REALM_SORCERY: /* Sorcery */
4132 case 1: sprintf(p, " %s10", s_range); break;
4133 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4134 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4135 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4136 case 18: sprintf(p, " %s25+d30", s_dur); break;
4137 case 22: sprintf(p, " %s15+d21", s_delay); break;
4138 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4139 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4141 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4143 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4145 case 27: sprintf(p, " %s25+d30", s_dur); break;
4146 case 31: sprintf(p, " %s4+d4", s_dur); break;
4150 case REALM_NATURE: /* Nature */
4154 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4156 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4158 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4159 case 6: sprintf(p, " %s20+d20", s_dur); break;
4160 case 7: sprintf(p, " %s2d8", s_heal); break;
4161 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4162 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4163 case 12: sprintf(p, " %s6d8", s_dam); break;
4164 case 15: sprintf(p, " %s500", s_heal); break;
4165 case 17: sprintf(p, " %s20+d30", s_dur); break;
4166 case 18: sprintf(p, " %s20+d20", s_dur); break;
4168 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4170 case 24: sprintf(p, " rad 10"); break;
4172 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4173 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4174 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4175 case 29: sprintf(p, " %s75", s_dam); break;
4176 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4180 case REALM_CHAOS: /* Chaos */
4183 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4184 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4185 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4186 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4187 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4188 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4189 case 8: sprintf(p, " %s", s_random); break;
4190 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4191 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4192 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4193 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4194 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4195 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4196 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4197 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4198 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4200 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4202 case 25: sprintf(p, " dam %d each", plev * 2); break;
4204 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4205 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4206 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4207 case 30: sprintf(p, " %s%d", s_dam, p_ptr->chp); break;
4208 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4212 case REALM_DEATH: /* Death */
4215 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4216 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4217 case 5: sprintf(p, " %s20+d20", s_dur); break;
4218 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4219 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4220 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4222 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4224 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4226 case 16: sprintf(p, " %s25+d25", s_dur); break;
4227 case 17: sprintf(p, " %s", s_random); break;
4228 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4229 case 19: sprintf(p, " %s25+d25", s_dur); break;
4230 case 21: sprintf(p, " %s3*100", s_dam); break;
4231 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4232 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4233 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4234 case 30: sprintf(p, " %s666", s_dam); break;
4235 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4239 case REALM_TRUMP: /* Trump */
4242 case 0: sprintf(p, " %s10", s_range); break;
4243 case 2: sprintf(p, " %s", s_random); break;
4244 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4245 case 5: sprintf(p, " %s25+d30", s_dur); break;
4247 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4249 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4251 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4252 case 14: sprintf(p, " %s15+d21", s_delay); break;
4253 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4255 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4257 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4262 case REALM_ARCANE: /* Arcane */
4265 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4266 case 4: sprintf(p, " %s10", s_range); break;
4267 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4268 case 7: sprintf(p, " %s2d8", s_heal); break;
4272 case 17: sprintf(p, " %s20+d20", s_dur); break;
4273 case 18: sprintf(p, " %s4d8", s_heal); break;
4274 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4275 case 21: sprintf(p, " %s6d8", s_dam); break;
4276 case 24: sprintf(p, " %s24+d24", s_dur); break;
4277 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4278 case 30: sprintf(p, " %s15+d21", s_delay); break;
4279 case 31: sprintf(p, " %s25+d30", s_dur); break;
4283 case REALM_ENCHANT: /* Craft */
4286 case 0: sprintf(p, " %s100+d100", s_dur); break;
4287 case 1: sprintf(p, " %s80+d80", s_dur); break;
4293 case 18: sprintf(p, " %s20+d20", s_dur); break;
4294 case 5: sprintf(p, " %s25+d25", s_dur); break;
4295 case 8: sprintf(p, " %s24+d24", s_dur); break;
4296 case 11: sprintf(p, " %s25+d25", s_dur); break;
4297 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4298 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4299 case 16: sprintf(p, " %s25+d30", s_dur); break;
4300 case 17: sprintf(p, " %s30+d20", s_dur); break;
4301 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4302 case 20: sprintf(p, " %s50+d50", s_dur); break;
4303 case 23: sprintf(p, " %s20+d20", s_dur); break;
4304 case 31: sprintf(p, " %s13+d13", s_dur); break;
4308 case REALM_DAEMON: /* Daemon */
4311 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4312 case 2: sprintf(p, " %s12+d12", s_dur); break;
4313 case 3: sprintf(p, " %s20+d20", s_dur); break;
4314 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4315 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4316 case 10: sprintf(p, " %s20+d20", s_dur); break;
4317 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4318 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4319 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4320 case 16: sprintf(p, " %s30+d25", s_dur); break;
4321 case 17: sprintf(p, " %s20+d20", s_dur); break;
4322 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4323 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4324 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4325 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4326 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4327 case 24: sprintf(p, " %s25+d25", s_dur); break;
4328 case 25: sprintf(p, " %s20+d20", s_dur); break;
4329 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4330 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4331 case 30: sprintf(p, " %s600", s_dam); break;
4332 case 31: sprintf(p, " %s15+d15", s_dur); break;
4336 case REALM_CRUSADE: /* Crusade */
4339 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4340 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4342 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4344 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4346 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4347 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4348 case 12: sprintf(p, " %s24+d24", s_dur); break;
4349 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4350 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4352 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4354 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4356 case 18: sprintf(p, " %s18+d18", s_dur); break;
4357 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4358 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4359 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4360 case 24: sprintf(p, " %s25+d25", s_dur); break;
4361 case 28: sprintf(p, " %s10+d10", s_dur); break;
4363 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4365 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4368 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4370 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4375 case REALM_MUSIC: /* Music */
4378 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4379 case 4 : sprintf(p, " %s2d6", s_heal); break;
4380 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4381 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4382 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4383 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4384 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4385 case 28: sprintf(p, " %s15d10", s_heal); break;
4386 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4391 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4393 sprintf(p, "Unknown type: %d.", use_realm);
4400 * Print a list of spells (for browsing or casting or viewing)
4402 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4404 int i, spell, exp_level, increment = 64;
4416 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4418 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4420 msg_print("Warning! print_spells called with null realm");
4424 /* Title the list */
4426 if (use_realm == REALM_HISSATSU)
4428 strcpy(buf," Lv MP");
4430 strcpy(buf," Lv SP");
4434 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4436 strcpy(buf,"Profic Lv SP Fail Effect");
4440 put_str("̾Á°", y, x + 5);
4441 put_str(buf, y, x + 29);
4443 put_str("Name", y, x + 5);
4444 put_str(buf, y, x + 29);
4447 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4448 else if (use_realm == p_ptr->realm1) increment = 0;
4449 else if (use_realm == p_ptr->realm2) increment = 32;
4451 /* Dump the spells */
4452 for (i = 0; i < num; i++)
4454 /* Access the spell */
4457 /* Access the spell */
4458 if (!is_magic(use_realm))
4460 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4464 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4467 if (use_realm == REALM_HISSATSU)
4468 need_mana = s_ptr->smana;
4471 s16b exp = experience_of_spell(spell, use_realm);
4473 /* Extract mana consumption rate */
4474 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4476 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4477 else exp_level = spell_exp_level(exp);
4480 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4481 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4482 else if (s_ptr->slevel >= 99) max = TRUE;
4483 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4485 strncpy(ryakuji, exp_level_str[exp_level], 4);
4490 if (use_menu && target_spell)
4492 if (i == (target_spell-1))
4494 strcpy(out_val, " ¡Õ ");
4496 strcpy(out_val, " > ");
4499 strcpy(out_val, " ");
4501 else sprintf(out_val, " %c) ", I2A(i));
4502 /* Skip illegible spells */
4503 if (s_ptr->slevel >= 99)
4506 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4508 strcat(out_val, format("%-30s", "(illegible)"));
4511 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4515 /* XXX XXX Could label spells above the players level */
4517 /* Get extra info */
4518 spell_info(info, spell, use_realm);
4523 /* Assume spell is known and tried */
4524 line_attr = TERM_WHITE;
4526 /* Analyze the spell */
4527 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4529 if (s_ptr->slevel > p_ptr->max_plv)
4534 comment = " unknown";
4537 line_attr = TERM_L_BLUE;
4539 else if (s_ptr->slevel > p_ptr->lev)
4544 comment = " forgotten";
4547 line_attr = TERM_YELLOW;
4550 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4555 comment = " unknown";
4558 line_attr = TERM_L_BLUE;
4560 else if ((use_realm == p_ptr->realm1) ?
4561 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4562 ((p_ptr->spell_forgotten2 & (1L << spell))))
4567 comment = " forgotten";
4570 line_attr = TERM_YELLOW;
4572 else if (!((use_realm == p_ptr->realm1) ?
4573 (p_ptr->spell_learned1 & (1L << spell)) :
4574 (p_ptr->spell_learned2 & (1L << spell))))
4579 comment = " unknown";
4582 line_attr = TERM_L_BLUE;
4584 else if (!((use_realm == p_ptr->realm1) ?
4585 (p_ptr->spell_worked1 & (1L << spell)) :
4586 (p_ptr->spell_worked2 & (1L << spell))))
4589 comment = " ̤·Ð¸³";
4591 comment = " untried";
4594 line_attr = TERM_L_GREEN;
4597 /* Dump the spell --(-- */
4598 if (use_realm == REALM_HISSATSU)
4600 strcat(out_val, format("%-25s %2d %4d",
4601 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4602 s_ptr->slevel, need_mana));
4606 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4607 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4608 (max ? '!' : ' '), ryakuji,
4609 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4611 c_prt(line_attr, out_val, y + i + 1, x);
4614 /* Clear the bottom line */
4615 prt("", y + i + 1, x);
4620 * Note that amulets, rods, and high-level spell books are immune
4621 * to "inventory damage" of any kind. Also sling ammo and shovels.
4626 * Does a given class of objects (usually) hate acid?
4627 * Note that acid can either melt or corrode something.
4629 bool hates_acid(object_type *o_ptr)
4631 /* Analyze the type */
4632 switch (o_ptr->tval)
4634 /* Wearable items */
4654 /* Staffs/Scrolls are wood/paper */
4667 /* Junk is useless */
4681 * Does a given object (usually) hate electricity?
4683 bool hates_elec(object_type *o_ptr)
4685 switch (o_ptr->tval)
4699 * Does a given object (usually) hate fire?
4700 * Hafted/Polearm weapons have wooden shafts.
4701 * Arrows/Bows are mostly wooden.
4703 bool hates_fire(object_type *o_ptr)
4705 /* Analyze the type */
4706 switch (o_ptr->tval)
4724 case TV_SORCERY_BOOK:
4725 case TV_NATURE_BOOK:
4729 case TV_ARCANE_BOOK:
4730 case TV_ENCHANT_BOOK:
4731 case TV_DAEMON_BOOK:
4732 case TV_CRUSADE_BOOK:
4734 case TV_HISSATSU_BOOK:
4745 /* Staffs/Scrolls burn */
4758 * Does a given object (usually) hate cold?
4760 bool hates_cold(object_type *o_ptr)
4762 switch (o_ptr->tval)
4779 int set_acid_destroy(object_type *o_ptr)
4781 u32b flgs[TR_FLAG_SIZE];
4782 if (!hates_acid(o_ptr)) return (FALSE);
4783 object_flags(o_ptr, flgs);
4784 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4792 int set_elec_destroy(object_type *o_ptr)
4794 u32b flgs[TR_FLAG_SIZE];
4795 if (!hates_elec(o_ptr)) return (FALSE);
4796 object_flags(o_ptr, flgs);
4797 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4805 int set_fire_destroy(object_type *o_ptr)
4807 u32b flgs[TR_FLAG_SIZE];
4808 if (!hates_fire(o_ptr)) return (FALSE);
4809 object_flags(o_ptr, flgs);
4810 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4818 int set_cold_destroy(object_type *o_ptr)
4820 u32b flgs[TR_FLAG_SIZE];
4821 if (!hates_cold(o_ptr)) return (FALSE);
4822 object_flags(o_ptr, flgs);
4823 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4829 * Destroys a type of item on a given percent chance
4830 * Note that missiles are no longer necessarily all destroyed
4831 * Destruction taken from "melee.c" code for "stealing".
4832 * New-style wands and rods handled correctly. -LM-
4833 * Returns number of items destroyed.
4835 int inven_damage(inven_func typ, int perc)
4839 char o_name[MAX_NLEN];
4841 /* Multishadow effects is determined by turn */
4842 if( p_ptr->multishadow && (turn & 1) )return 0;
4844 if (p_ptr->inside_arena) return 0;
4846 /* Count the casualties */
4849 /* Scan through the slots backwards */
4850 for (i = 0; i < INVEN_PACK; i++)
4852 o_ptr = &inventory[i];
4854 /* Skip non-objects */
4855 if (!o_ptr->k_idx) continue;
4857 /* Hack -- for now, skip artifacts */
4858 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
4860 /* Give this item slot a shot at death */
4863 /* Count the casualties */
4864 for (amt = j = 0; j < o_ptr->number; ++j)
4866 if (randint0(100) < perc) amt++;
4869 /* Some casualities */
4872 /* Get a description */
4873 object_desc(o_name, o_ptr, FALSE, 3);
4877 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
4879 msg_format("%sour %s (%c) %s destroyed!",
4883 o_name, index_to_label(i),
4884 ((o_ptr->number > 1) ?
4885 ((amt == o_ptr->number) ? "Á´Éô" :
4886 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
4888 ((o_ptr->number > 1) ?
4889 ((amt == o_ptr->number) ? "All of y" :
4890 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4891 o_name, index_to_label(i),
4892 ((amt > 1) ? "were" : "was"));
4896 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4897 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
4900 /* Potions smash open */
4901 if (object_is_potion(o_ptr))
4903 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
4906 /* Reduce the charges of rods/wands */
4907 reduce_charges(o_ptr, amt);
4909 /* Destroy "amt" items */
4910 inven_item_increase(i, -amt);
4911 inven_item_optimize(i);
4913 /* Count the casualties */
4919 /* Return the casualty count */
4925 * Acid has hit the player, attempt to affect some armor.
4927 * Note that the "base armor" of an object never changes.
4929 * If any armor is damaged (or resists), the player takes less damage.
4931 static int minus_ac(void)
4933 object_type *o_ptr = NULL;
4934 u32b flgs[TR_FLAG_SIZE];
4935 char o_name[MAX_NLEN];
4938 /* Pick a (possibly empty) inventory slot */
4939 switch (randint1(7))
4941 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4942 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4943 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4944 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4945 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4946 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4947 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4950 /* Nothing to damage */
4951 if (!o_ptr->k_idx) return (FALSE);
4953 if (o_ptr->tval < TV_BOOTS) return (FALSE);
4955 /* No damage left to be done */
4956 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4960 object_desc(o_name, o_ptr, FALSE, 0);
4962 /* Extract the flags */
4963 object_flags(o_ptr, flgs);
4965 /* Object resists */
4966 if (have_flag(flgs, TR_IGNORE_ACID))
4969 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
4971 msg_format("Your %s is unaffected!", o_name);
4980 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
4982 msg_format("Your %s is damaged!", o_name);
4986 /* Damage the item */
4989 /* Calculate bonuses */
4990 p_ptr->update |= (PU_BONUS);
4993 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4997 /* Item was damaged */
5003 * Hurt the player with Acid
5005 int acid_dam(int dam, cptr kb_str, int monspell)
5008 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5009 bool double_resist = (p_ptr->oppose_acid || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
5011 /* Total Immunity */
5012 if (p_ptr->immune_acid || (dam <= 0))
5014 learn_spell(monspell);
5018 /* Vulnerability (Ouch!) */
5019 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5020 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5022 /* Resist the damage */
5023 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5024 if (double_resist) dam = (dam + 2) / 3;
5026 if ((!(double_resist || p_ptr->resist_acid)) &&
5027 one_in_(HURT_CHANCE))
5028 (void)do_dec_stat(A_CHR);
5030 /* If any armor gets hit, defend the player */
5031 if (minus_ac()) dam = (dam + 1) / 2;
5034 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5036 /* Inventory damage */
5037 if (!(double_resist && p_ptr->resist_acid))
5038 inven_damage(set_acid_destroy, inv);
5044 * Hurt the player with electricity
5046 int elec_dam(int dam, cptr kb_str, int monspell)
5049 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5050 bool double_resist = (p_ptr->oppose_elec || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
5052 /* Total immunity */
5053 if (p_ptr->immune_elec || (dam <= 0))
5055 learn_spell(monspell);
5059 /* Vulnerability (Ouch!) */
5060 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5061 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5062 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5064 /* Resist the damage */
5065 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5066 if (double_resist) dam = (dam + 2) / 3;
5068 if ((!(double_resist || p_ptr->resist_elec)) &&
5069 one_in_(HURT_CHANCE))
5070 (void)do_dec_stat(A_DEX);
5073 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5075 /* Inventory damage */
5076 if (!(double_resist && p_ptr->resist_elec))
5077 inven_damage(set_elec_destroy, inv);
5084 * Hurt the player with Fire
5086 int fire_dam(int dam, cptr kb_str, int monspell)
5089 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5090 bool double_resist = (p_ptr->oppose_fire || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
5092 /* Totally immune */
5093 if (p_ptr->immune_fire || (dam <= 0))
5095 learn_spell(monspell);
5099 /* Vulnerability (Ouch!) */
5100 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5101 if (prace_is_(RACE_ENT)) dam += dam / 3;
5102 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5104 /* Resist the damage */
5105 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5106 if (double_resist) dam = (dam + 2) / 3;
5108 if ((!(double_resist || p_ptr->resist_fire)) &&
5109 one_in_(HURT_CHANCE))
5110 (void)do_dec_stat(A_STR);
5113 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5115 /* Inventory damage */
5116 if (!(double_resist && p_ptr->resist_fire))
5117 inven_damage(set_fire_destroy, inv);
5124 * Hurt the player with Cold
5126 int cold_dam(int dam, cptr kb_str, int monspell)
5129 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5130 bool double_resist = (p_ptr->oppose_cold || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
5132 /* Total immunity */
5133 if (p_ptr->immune_cold || (dam <= 0))
5135 learn_spell(monspell);
5139 /* Vulnerability (Ouch!) */
5140 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5141 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5143 /* Resist the damage */
5144 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5145 if (double_resist) dam = (dam + 2) / 3;
5147 if ((!(double_resist || p_ptr->resist_cold)) &&
5148 one_in_(HURT_CHANCE))
5149 (void)do_dec_stat(A_STR);
5152 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5154 /* Inventory damage */
5155 if (!(double_resist && p_ptr->resist_cold))
5156 inven_damage(set_cold_destroy, inv);
5162 bool rustproof(void)
5166 char o_name[MAX_NLEN];
5169 item_tester_no_ryoute = TRUE;
5170 /* Select a piece of armour */
5171 item_tester_hook = item_tester_hook_armour;
5175 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5176 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5178 q = "Rustproof which piece of armour? ";
5179 s = "You have nothing to rustproof.";
5182 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5184 /* Get the item (in the pack) */
5187 o_ptr = &inventory[item];
5190 /* Get the item (on the floor) */
5193 o_ptr = &o_list[0 - item];
5198 object_desc(o_name, o_ptr, FALSE, 0);
5200 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5202 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5205 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5207 msg_format("%s %s look%s as good as new!",
5208 ((item >= 0) ? "Your" : "The"), o_name,
5209 ((o_ptr->number > 1) ? "" : "s"));
5216 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5218 msg_format("%s %s %s now protected against corrosion.",
5219 ((item >= 0) ? "Your" : "The"), o_name,
5220 ((o_ptr->number > 1) ? "are" : "is"));
5231 * Curse the players armor
5233 bool curse_armor(void)
5238 char o_name[MAX_NLEN];
5241 /* Curse the body armor */
5242 o_ptr = &inventory[INVEN_BODY];
5244 /* Nothing to curse */
5245 if (!o_ptr->k_idx) return (FALSE);
5249 object_desc(o_name, o_ptr, FALSE, 3);
5251 /* Attempt a saving throw for artifacts */
5252 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5256 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5257 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5259 msg_format("A %s tries to %s, but your %s resists the effects!",
5260 "terrible black aura", "surround your armor", o_name);
5265 /* not artifact or failed save... */
5270 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5272 msg_format("A terrible black aura blasts your %s!", o_name);
5275 chg_virtue(V_ENCHANT, -5);
5277 /* Blast the armor */
5279 o_ptr->name2 = EGO_BLASTED;
5280 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5287 for (i = 0; i < TR_FLAG_SIZE; i++)
5288 o_ptr->art_flags[i] = 0;
5291 o_ptr->curse_flags = TRC_CURSED;
5294 o_ptr->ident |= (IDENT_BROKEN);
5296 /* Recalculate bonuses */
5297 p_ptr->update |= (PU_BONUS);
5299 /* Recalculate mana */
5300 p_ptr->update |= (PU_MANA);
5303 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5311 * Curse the players weapon
5313 bool curse_weapon(bool force, int slot)
5319 char o_name[MAX_NLEN];
5322 /* Curse the weapon */
5323 o_ptr = &inventory[slot];
5325 /* Nothing to curse */
5326 if (!o_ptr->k_idx) return (FALSE);
5330 object_desc(o_name, o_ptr, FALSE, 3);
5332 /* Attempt a saving throw */
5333 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5337 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5338 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5340 msg_format("A %s tries to %s, but your %s resists the effects!",
5341 "terrible black aura", "surround your weapon", o_name);
5346 /* not artifact or failed save... */
5351 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5353 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5356 chg_virtue(V_ENCHANT, -5);
5358 /* Shatter the weapon */
5360 o_ptr->name2 = EGO_SHATTERED;
5361 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5362 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5368 for (i = 0; i < TR_FLAG_SIZE; i++)
5369 o_ptr->art_flags[i] = 0;
5373 o_ptr->curse_flags = TRC_CURSED;
5376 o_ptr->ident |= (IDENT_BROKEN);
5378 /* Recalculate bonuses */
5379 p_ptr->update |= (PU_BONUS);
5381 /* Recalculate mana */
5382 p_ptr->update |= (PU_MANA);
5385 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5394 * Enchant some bolts
5396 bool brand_bolts(void)
5400 /* Use the first acceptable bolts */
5401 for (i = 0; i < INVEN_PACK; i++)
5403 object_type *o_ptr = &inventory[i];
5405 /* Skip non-bolts */
5406 if (o_ptr->tval != TV_BOLT) continue;
5408 /* Skip artifacts and ego-items */
5409 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5412 /* Skip cursed/broken items */
5413 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5416 if (randint0(100) < 75) continue;
5420 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5422 msg_print("Your bolts are covered in a fiery aura!");
5427 o_ptr->name2 = EGO_FLAME;
5430 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5437 if (flush_failure) flush();
5441 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5443 msg_print("The fiery enchantment failed.");
5453 * Helper function -- return a "nearby" race for polymorphing
5455 * Note that this function is one of the more "dangerous" ones...
5457 static s16b poly_r_idx(int r_idx)
5459 monster_race *r_ptr = &r_info[r_idx];
5461 int i, r, lev1, lev2;
5463 /* Hack -- Uniques/Questors never polymorph */
5464 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5465 (r_ptr->flags1 & RF1_QUESTOR))
5468 /* Allowable range of "levels" for resulting monster */
5469 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5470 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5472 /* Pick a (possibly new) non-unique race */
5473 for (i = 0; i < 1000; i++)
5475 /* Pick a new race, using a level calculation */
5476 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5478 /* Handle failure */
5484 /* Ignore unique monsters */
5485 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5487 /* Ignore monsters with incompatible levels */
5488 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5490 /* Use that index */
5502 bool polymorph_monster(int y, int x)
5504 cave_type *c_ptr = &cave[y][x];
5505 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5506 bool polymorphed = FALSE;
5508 int old_r_idx = m_ptr->r_idx;
5509 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5510 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5511 monster_type back_m;
5513 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5515 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG_KAGE)) return (FALSE);
5517 /* Memorize the monster before polymorphing */
5520 /* Pick a "new" monster race */
5521 new_r_idx = poly_r_idx(old_r_idx);
5523 /* Handle polymorph */
5524 if (new_r_idx != old_r_idx)
5528 /* Get the monsters attitude */
5529 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5530 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5531 if (m_ptr->mflag2 & MFLAG_NOPET) mode |= PM_NO_PET;
5533 /* "Kill" the "old" monster */
5534 delete_monster_idx(c_ptr->m_idx);
5536 /* Create a new monster (no groups) */
5537 if (place_monster_aux(0, y, x, new_r_idx, mode))
5544 /* Placing the new monster failed */
5545 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5546 m_list[hack_m_idx_ii] = back_m;
5549 if (targeted) target_who = hack_m_idx_ii;
5550 if (health_tracked) health_track(hack_m_idx_ii);
5560 bool dimension_door(void)
5562 int plev = p_ptr->lev;
5565 if (!tgt_pt(&x, &y)) return FALSE;
5567 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5569 if (!cave_empty_bold(y, x) || (cave[y][x].info & CAVE_ICKY) ||
5570 (distance(y, x, py, px) > plev / 2 + 10) ||
5571 (!randint0(plev / 10 + 10)))
5573 if( p_ptr->pclass != CLASS_MIRROR_MASTER ){
5575 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5577 msg_print("You fail to exit the astral plane correctly!");
5583 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5585 msg_print("You fail to exit the astral plane correctly!");
5588 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5589 teleport_player((plev+2)*2);
5592 teleport_player_to(y, x, TRUE);
5598 bool eat_magic(int power)
5600 object_type * o_ptr;
5603 int recharge_strength = 0;
5609 char o_name[MAX_NLEN];
5611 item_tester_hook = item_tester_hook_recharge;
5615 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5616 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5618 q = "Drain which item? ";
5619 s = "You have nothing to drain.";
5622 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5626 o_ptr = &inventory[item];
5630 o_ptr = &o_list[0 - item];
5633 k_ptr = &k_info[o_ptr->k_idx];
5634 lev = get_object_level(o_ptr);
5636 if (o_ptr->tval == TV_ROD)
5638 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5641 if (one_in_(recharge_strength))
5643 /* Activate the failure code. */
5648 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5651 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5653 msg_print("You can't absorb energy from a discharged rod.");
5660 o_ptr->timeout += k_ptr->pval;
5666 /* All staffs, wands. */
5667 recharge_strength = (100 + power - lev) / 15;
5670 if (recharge_strength < 0) recharge_strength = 0;
5673 if (one_in_(recharge_strength))
5675 /* Activate the failure code. */
5680 if (o_ptr->pval > 0)
5682 p_ptr->csp += lev / 2;
5685 /* XXX Hack -- unstack if necessary */
5686 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5691 /* Get local object */
5694 /* Obtain a local object */
5695 object_copy(q_ptr, o_ptr);
5697 /* Modify quantity */
5700 /* Restore the charges */
5703 /* Unstack the used item */
5705 p_ptr->total_weight -= q_ptr->weight;
5706 item = inven_carry(q_ptr);
5710 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5712 msg_print("You unstack your staff.");
5720 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5722 msg_print("There's no energy there to absorb!");
5726 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5730 /* Inflict the penalties for failing a recharge. */
5733 /* Artifacts are never destroyed. */
5734 if (artifact_p(o_ptr))
5736 object_desc(o_name, o_ptr, TRUE, 0);
5738 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5740 msg_format("The recharging backfires - %s is completely drained!", o_name);
5744 /* Artifact rods. */
5745 if (o_ptr->tval == TV_ROD)
5746 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5748 /* Artifact wands and staffs. */
5749 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5754 /* Get the object description */
5755 object_desc(o_name, o_ptr, FALSE, 0);
5757 /*** Determine Seriousness of Failure ***/
5759 /* Mages recharge objects more safely. */
5760 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)
5762 /* 10% chance to blow up one rod, otherwise draining. */
5763 if (o_ptr->tval == TV_ROD)
5765 if (one_in_(10)) fail_type = 2;
5768 /* 75% chance to blow up one wand, otherwise draining. */
5769 else if (o_ptr->tval == TV_WAND)
5771 if (!one_in_(3)) fail_type = 2;
5774 /* 50% chance to blow up one staff, otherwise no effect. */
5775 else if (o_ptr->tval == TV_STAFF)
5777 if (one_in_(2)) fail_type = 2;
5782 /* All other classes get no special favors. */
5785 /* 33% chance to blow up one rod, otherwise draining. */
5786 if (o_ptr->tval == TV_ROD)
5788 if (one_in_(3)) fail_type = 2;
5791 /* 20% chance of the entire stack, else destroy one wand. */
5792 else if (o_ptr->tval == TV_WAND)
5794 if (one_in_(5)) fail_type = 3;
5797 /* Blow up one staff. */
5798 else if (o_ptr->tval == TV_STAFF)
5804 /*** Apply draining and destruction. ***/
5806 /* Drain object or stack of objects. */
5809 if (o_ptr->tval == TV_ROD)
5812 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
5814 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
5817 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5819 else if (o_ptr->tval == TV_WAND)
5822 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
5824 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
5829 /* Staffs aren't drained. */
5832 /* Destroy an object or one in a stack of objects. */
5835 if (o_ptr->number > 1)
5838 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
5840 msg_format("Wild magic consumes one of your %s!", o_name);
5843 /* Reduce rod stack maximum timeout, drain wands. */
5844 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5845 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5850 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
5852 msg_format("Wild magic consumes your %s!", o_name);
5855 /* Reduce and describe inventory */
5858 inven_item_increase(item, -1);
5859 inven_item_describe(item);
5860 inven_item_optimize(item);
5863 /* Reduce and describe floor item */
5866 floor_item_increase(0 - item, -1);
5867 floor_item_describe(0 - item);
5868 floor_item_optimize(0 - item);
5872 /* Destroy all members of a stack of objects. */
5875 if (o_ptr->number > 1)
5877 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
5879 msg_format("Wild magic consumes all your %s!", o_name);
5884 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
5886 msg_format("Wild magic consumes your %s!", o_name);
5891 /* Reduce and describe inventory */
5894 inven_item_increase(item, -999);
5895 inven_item_describe(item);
5896 inven_item_optimize(item);
5899 /* Reduce and describe floor item */
5902 floor_item_increase(0 - item, -999);
5903 floor_item_describe(0 - item);
5904 floor_item_optimize(0 - item);
5910 if (p_ptr->csp > p_ptr->msp)
5912 p_ptr->csp = p_ptr->msp;
5915 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5916 p_ptr->window |= (PW_INVEN);
5922 bool summon_kin_player(int level, int y, int x, u32b mode)
5924 bool pet = (bool)(mode & PM_FORCE_PET);
5925 if (!pet) mode |= PM_NO_PET;
5927 switch (p_ptr->mimic_form)
5930 switch (p_ptr->prace)
5934 case RACE_BARBARIAN:
5937 summon_kin_type = 'p';
5947 case RACE_MIND_FLAYER:
5950 summon_kin_type = 'h';
5953 summon_kin_type = 'o';
5955 case RACE_HALF_TROLL:
5956 summon_kin_type = 'T';
5958 case RACE_HALF_OGRE:
5959 summon_kin_type = 'O';
5961 case RACE_HALF_GIANT:
5962 case RACE_HALF_TITAN:
5964 summon_kin_type = 'P';
5967 summon_kin_type = 'y';
5970 summon_kin_type = 'K';
5973 summon_kin_type = 'k';
5976 if (one_in_(13)) summon_kin_type = 'U';
5977 else summon_kin_type = 'u';
5979 case RACE_DRACONIAN:
5980 summon_kin_type = 'd';
5984 summon_kin_type = 'g';
5987 if (one_in_(13)) summon_kin_type = 'L';
5988 else summon_kin_type = 's';
5991 summon_kin_type = 'z';
5994 summon_kin_type = 'V';
5997 summon_kin_type = 'G';
6000 summon_kin_type = 'I';
6003 summon_kin_type = '#';
6006 summon_kin_type = 'A';
6009 summon_kin_type = 'U';
6012 summon_kin_type = 'p';
6017 if (one_in_(13)) summon_kin_type = 'U';
6018 else summon_kin_type = 'u';
6020 case MIMIC_DEMON_LORD:
6021 summon_kin_type = 'U';
6024 summon_kin_type = 'V';
6027 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);