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 (pattern_tile(ny, nx)) continue;
90 /* No teleporting into vaults and such */
91 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
92 if (cave[ny][nx].info & CAVE_ICKY) continue;
94 /* This grid looks good */
101 /* Increase the maximum distance */
104 /* Decrease the minimum distance */
107 /* Stop after MAX_TRIES tries */
108 if (tries > MAX_TRIES) return (FALSE);
112 sound(SOUND_TPOTHER);
114 /* Update the new location */
115 cave[ny][nx].m_idx = m_idx;
117 /* Update the old location */
118 cave[oy][ox].m_idx = 0;
120 /* Move the monster */
124 /* Forget the counter target */
127 /* Update the monster (new location) */
128 update_mon(m_idx, TRUE);
130 /* Redraw the old grid */
133 /* Redraw the new grid */
136 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
137 p_ptr->update |= (PU_MON_LITE);
145 * Teleport monster next to a grid near the given location
147 void teleport_monster_to(int m_idx, int ty, int tx, int power)
149 int ny, nx, oy, ox, d, i, min;
153 monster_type *m_ptr = &m_list[m_idx];
157 if (!m_ptr->r_idx) return;
160 if (randint1(100) > power) return;
166 /* Save the old location */
170 /* Minimum distance */
173 /* Look until done */
174 while (look && --attempts)
176 /* Verify max distance */
177 if (dis > 200) dis = 200;
179 /* Try several locations */
180 for (i = 0; i < 500; i++)
184 /* Pick a (possibly illegal) location */
187 ny = rand_spread(ty, dis);
188 nx = rand_spread(tx, dis);
189 d = distance(ty, tx, ny, nx);
190 if ((d >= min) && (d <= dis)) break;
193 /* Ignore illegal locations */
194 if (!in_bounds(ny, nx)) continue;
196 /* Require "empty" floor space */
197 if (!cave_empty_bold(ny, nx)) continue;
199 c_ptr = &cave[ny][nx];
201 /* Hack -- no teleport onto glyph of warding */
202 if (is_glyph_grid(c_ptr)) continue;
203 if (is_explosive_rune_grid(c_ptr)) continue;
205 /* ...nor onto the Pattern */
206 if (pattern_tile(ny, nx)) continue;
208 /* No teleporting into vaults and such */
209 /* if (c_ptr->info & (CAVE_ICKY)) continue; */
211 /* This grid looks good */
218 /* Increase the maximum distance */
221 /* Decrease the minimum distance */
225 if (attempts < 1) return;
228 sound(SOUND_TPOTHER);
230 /* Update the new location */
231 cave[ny][nx].m_idx = m_idx;
233 /* Update the old location */
234 cave[oy][ox].m_idx = 0;
236 /* Move the monster */
240 /* Update the monster (new location) */
241 update_mon(m_idx, TRUE);
243 /* Redraw the old grid */
246 /* Redraw the new grid */
249 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
250 p_ptr->update |= (PU_MON_LITE);
254 bool cave_teleportable_bold(int y, int x)
256 cave_type *c_ptr = &cave[y][x];
257 feature_type *f_ptr = &f_info[c_ptr->feat];
259 /* Require "teleportable" space */
260 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
262 /* No teleporting into vaults and such */
263 if (c_ptr->info & CAVE_ICKY) return FALSE;
265 if (c_ptr->m_idx) return FALSE;
267 if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
269 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
271 if (!p_ptr->ffall && !p_ptr->can_swim) return FALSE;
274 if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
276 /* Always forbid deep lave */
277 if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
279 /* Forbid shallow lave when the player don't have levitation */
280 if (!p_ptr->ffall) return FALSE;
288 * Teleport the player to a location up to "dis" grids away.
290 * If no such spaces are readily available, the distance may increase.
291 * Try very hard to move the player at least a quarter that distance.
293 * When long-range teleport effects are considered, there is a nasty
294 * tendency to "bounce" the player between two or three different spots
295 * because these are the only spots that are "far enough" way to satisfy
296 * the algorithm. Therefore, if the teleport distance is more than 50,
297 * we decrease the minimum acceptable distance to try to increase randomness.
300 void teleport_player(int dis)
302 int d, i, min, ox, oy;
313 if (p_ptr->wild_mode) return;
315 if (p_ptr->anti_tele)
318 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
320 msg_print("A mysterious force prevents you from teleporting!");
326 if (dis > 200) dis = 200; /* To be on the safe side... */
328 /* Minimum distance */
329 min = dis / (dis > 50 ? 3 : 2);
331 /* Look until done */
336 /* Verify max distance */
337 if (dis > 200) dis = 200;
339 /* Try several locations */
340 for (i = 0; i < 500; i++)
342 /* Pick a (possibly illegal) location */
345 y = rand_spread(py, dis);
346 x = rand_spread(px, dis);
347 d = distance(py, px, y, x);
348 if ((d >= min) && (d <= dis)) break;
351 /* Ignore illegal locations */
352 if (!in_bounds(y, x)) continue;
354 if (!cave_teleportable_bold(y, x)) continue;
356 /* This grid looks good */
363 /* Increase the maximum distance */
366 /* Decrease the minimum distance */
369 /* Stop after MAX_TRIES tries */
370 if (tries > MAX_TRIES) return;
374 sound(SOUND_TELEPORT);
377 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
378 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
381 /* Save the old location */
385 /* Move the player */
386 (void)move_player_effect(py, px, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
388 /* Monsters with teleport ability may follow the player */
389 for (xx = -1; xx < 2; xx++)
391 for (yy = -1; yy < 2; yy++)
393 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
395 /* A monster except your mount may follow */
396 if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
398 monster_type *m_ptr = &m_list[tmp_m_idx];
399 monster_race *r_ptr = &r_info[m_ptr->r_idx];
402 * The latter limitation is to avoid
403 * totally unkillable suckers...
405 if ((r_ptr->flags6 & RF6_TPORT) &&
406 !(r_ptr->flagsr & RFR_RES_TELE))
408 if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, y, x, r_ptr->level);
418 * Teleport player to a grid near the given location
420 * This function is slightly obsessive about correctness.
421 * This function allows teleporting into vaults (!)
423 void teleport_player_to(int ny, int nx, bool no_tele)
425 int y, x, dis = 0, ctr = 0;
427 if (p_ptr->anti_tele && no_tele)
430 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
432 msg_print("A mysterious force prevents you from teleporting!");
438 /* Find a usable location */
441 /* Pick a nearby legal location */
444 y = rand_spread(ny, dis);
445 x = rand_spread(nx, dis);
446 if (in_bounds(y, x)) break;
449 /* Accept any grid when wizard mode */
450 if (p_ptr->wizard) break;
452 /* Accept teleportable floor grids */
453 if (cave_teleportable_bold(y, x)) break;
455 /* Occasionally advance the distance */
456 if (++ctr > (4 * dis * dis + 4 * dis + 1))
464 sound(SOUND_TELEPORT);
466 /* Move the player */
467 (void)move_player_effect(py, px, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
473 * Teleport the player one level up or down (random when legal)
474 * Note: If m_idx <= 0, target is player.
476 void teleport_level(int m_idx)
482 if (m_idx <= 0) /* To player */
485 strcpy(m_name, "¤¢¤Ê¤¿");
487 strcpy(m_name, "you");
490 else /* To monster */
492 monster_type *m_ptr = &m_list[m_idx];
494 /* Get the monster name (or "it") */
495 monster_desc(m_name, m_ptr, 0);
500 /* No effect in some case */
501 if (TELE_LEVEL_IS_INEFF(m_idx))
504 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
506 if (see_m) msg_print("There is no effect.");
512 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
515 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
517 msg_print("A mysterious force prevents you from teleporting!");
522 /* Choose up or down */
523 if (randint0(100) < 50) go_up = TRUE;
526 if ((m_idx <= 0) && p_ptr->wizard)
528 if (get_check("Force to go up? ")) go_up = TRUE;
529 else if (get_check("Force to go down? ")) go_up = FALSE;
533 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
536 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
538 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
540 if (m_idx <= 0) /* To player */
544 dungeon_type = p_ptr->recall_dungeon;
549 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
551 if (autosave_l) do_cmd_save_game(TRUE);
555 dun_level = d_info[dungeon_type].mindepth;
556 prepare_change_floor_mode(CFM_RAND_PLACE);
560 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
564 p_ptr->leaving = TRUE;
569 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
572 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
574 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
578 if (m_idx <= 0) /* To player */
580 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
582 if (autosave_l) do_cmd_save_game(TRUE);
584 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
589 p_ptr->inside_quest = 0;
590 p_ptr->leaving = TRUE;
596 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
598 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
602 if (m_idx <= 0) /* To player */
604 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
606 if (autosave_l) do_cmd_save_game(TRUE);
608 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
611 p_ptr->leaving = TRUE;
617 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
619 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
622 if (m_idx <= 0) /* To player */
624 /* Never reach this code on the surface */
625 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
627 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
629 if (autosave_l) do_cmd_save_game(TRUE);
631 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
634 p_ptr->leaving = TRUE;
638 /* Monster level teleportation is simple deleting now */
641 monster_type *m_ptr = &m_list[m_idx];
643 /* Check for quest completion */
644 check_quest_completion(m_ptr);
646 delete_monster_idx(m_idx);
650 sound(SOUND_TPLEVEL);
655 int choose_dungeon(cptr note, int y, int x)
661 /* Hack -- No need to choose dungeon in some case */
662 if (lite_town || vanilla_town || ironman_downward)
664 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
668 msg_format("¤Þ¤À%s¤ËÆþ¤Ã¤¿¤³¤È¤Ï¤Ê¤¤¡£", d_name + d_info[DUNGEON_ANGBAND].name);
670 msg_format("You haven't entered %s yet.", d_name + d_info[DUNGEON_ANGBAND].name);
677 /* Allocate the "dun" array */
678 C_MAKE(dun, max_d_idx, s16b);
681 for(i = 1; i < max_d_idx; i++)
686 if (!d_info[i].maxdepth) continue;
687 if (!max_dlv[i]) continue;
688 if (d_info[i].final_guardian)
690 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
692 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
695 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
697 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
699 prt(buf, y + num, x);
706 prt(" Áª¤Ù¤ë¥À¥ó¥¸¥ç¥ó¤¬¤Ê¤¤¡£", y, x);
708 prt(" No dungeon is available.", y, x);
713 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
715 prt(format("Which dungeon do you %s?: ", note), 0, 0);
720 if ((i == ESCAPE) || !num)
722 /* Free the "dun" array */
723 C_KILL(dun, max_d_idx, s16b);
728 if (i >= 'a' && i <('a'+num))
730 select_dungeon = dun[i-'a'];
737 /* Free the "dun" array */
738 C_KILL(dun, max_d_idx, s16b);
740 return select_dungeon;
745 * Recall the player to town or dungeon
747 bool recall_player(int turns)
750 * TODO: Recall the player to the last
751 * visited town when in the wilderness
755 if (p_ptr->inside_arena || ironman_downward)
758 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
760 msg_print("Nothing happens.");
766 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
769 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
771 if (get_check("Reset recall depth? "))
774 max_dlv[dungeon_type] = dun_level;
777 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
779 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
784 if (!p_ptr->word_recall)
790 select_dungeon = choose_dungeon("¤Ëµ¢´Ô", 2, 14);
792 select_dungeon = choose_dungeon("recall", 2, 14);
794 if (!select_dungeon) return FALSE;
795 p_ptr->recall_dungeon = select_dungeon;
797 p_ptr->word_recall = turns;
799 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
801 msg_print("The air about you becomes charged...");
804 p_ptr->redraw |= (PR_STATUS);
808 p_ptr->word_recall = 0;
810 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
812 msg_print("A tension leaves the air around you...");
815 p_ptr->redraw |= (PR_STATUS);
821 bool word_of_recall(void)
823 return(recall_player(randint0(21) + 15));
827 bool reset_recall(void)
829 int select_dungeon, dummy = 0;
834 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È", 2, 14);
836 select_dungeon = choose_dungeon("reset", 2, 14);
840 if (ironman_downward)
843 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
845 msg_print("Nothing happens.");
851 if (!select_dungeon) return FALSE;
854 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
856 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
861 sprintf(tmp_val, "%d", MAX(dun_level, 1));
863 /* Ask for a level */
864 if (get_string(ppp, tmp_val, 10))
866 /* Extract request */
867 dummy = atoi(tmp_val);
870 if (dummy < 1) dummy = 1;
873 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
874 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
876 max_dlv[select_dungeon] = dummy;
880 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
882 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
886 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
888 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
901 * Apply disenchantment to the player's stuff
903 * XXX XXX XXX This function is also called from the "melee" code
905 * Return "TRUE" if the player notices anything
907 bool apply_disenchant(int mode)
911 char o_name[MAX_NLEN];
912 int to_h, to_d, to_a, pval;
914 /* Pick a random slot */
917 case 1: t = INVEN_RARM; break;
918 case 2: t = INVEN_LARM; break;
919 case 3: t = INVEN_BOW; break;
920 case 4: t = INVEN_BODY; break;
921 case 5: t = INVEN_OUTER; break;
922 case 6: t = INVEN_HEAD; break;
923 case 7: t = INVEN_HANDS; break;
924 case 8: t = INVEN_FEET; break;
928 o_ptr = &inventory[t];
930 /* No item, nothing happens */
931 if (!o_ptr->k_idx) return (FALSE);
933 /* Disenchant equipments only -- No disenchant on monster ball */
934 if (o_ptr->tval < TV_EQUIP_BEGIN || TV_EQUIP_END < o_ptr->tval)
937 /* Nothing to disenchant */
938 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
940 /* Nothing to notice */
945 /* Describe the object */
946 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
949 /* Artifacts have 71% chance to resist */
950 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 71))
954 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
956 msg_format("Your %s (%c) resist%s disenchantment!",
957 o_name, index_to_label(t),
958 ((o_ptr->number != 1) ? "" : "s"));
967 /* Memorize old value */
973 /* Disenchant tohit */
974 if (o_ptr->to_h > 0) o_ptr->to_h--;
975 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
977 /* Disenchant todam */
978 if (o_ptr->to_d > 0) o_ptr->to_d--;
979 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
981 /* Disenchant toac */
982 if (o_ptr->to_a > 0) o_ptr->to_a--;
983 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
985 /* Disenchant pval (occasionally) */
986 /* Unless called from wild_magic() */
987 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
989 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
990 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
994 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
995 o_name, index_to_label(t) );
997 msg_format("Your %s (%c) %s disenchanted!",
998 o_name, index_to_label(t),
999 ((o_ptr->number != 1) ? "were" : "was"));
1002 chg_virtue(V_HARMONY, 1);
1003 chg_virtue(V_ENCHANT, -2);
1005 /* Recalculate bonuses */
1006 p_ptr->update |= (PU_BONUS);
1009 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1019 void mutate_player(void)
1021 int max1, cur1, max2, cur2, ii, jj, i;
1023 /* Pick a pair of stats */
1025 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1027 max1 = p_ptr->stat_max[ii];
1028 cur1 = p_ptr->stat_cur[ii];
1029 max2 = p_ptr->stat_max[jj];
1030 cur2 = p_ptr->stat_cur[jj];
1032 p_ptr->stat_max[ii] = max2;
1033 p_ptr->stat_cur[ii] = cur2;
1034 p_ptr->stat_max[jj] = max1;
1035 p_ptr->stat_cur[jj] = cur1;
1039 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1040 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1043 p_ptr->update |= (PU_BONUS);
1050 void apply_nexus(monster_type *m_ptr)
1052 switch (randint1(7))
1054 case 1: case 2: case 3:
1056 teleport_player(200);
1062 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE);
1068 if (randint0(100) < p_ptr->skill_sav)
1071 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1073 msg_print("You resist the effects!");
1079 /* Teleport Level */
1086 if (randint0(100) < p_ptr->skill_sav)
1089 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1091 msg_print("You resist the effects!");
1098 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1100 msg_print("Your body starts to scramble...");
1111 * Charge a lite (torch or latern)
1113 void phlogiston(void)
1116 object_type * o_ptr = &inventory[INVEN_LITE];
1119 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1121 max_flog = FUEL_LAMP;
1125 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1127 max_flog = FUEL_TORCH;
1130 /* No torch to refill */
1134 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1136 msg_print("You are not wielding anything which uses phlogiston.");
1142 if (o_ptr->xtra4 >= max_flog)
1145 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1147 msg_print("No more phlogiston can be put in this item.");
1154 o_ptr->xtra4 += (max_flog / 2);
1158 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1160 msg_print("You add phlogiston to your light item.");
1165 if (o_ptr->xtra4 >= max_flog)
1167 o_ptr->xtra4 = max_flog;
1169 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1171 msg_print("Your light item is full.");
1176 /* Recalculate torch */
1177 p_ptr->update |= (PU_TORCH);
1181 static bool item_tester_hook_weapon_nobow(object_type *o_ptr)
1183 switch (o_ptr->tval)
1193 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
1201 * Brand the current weapon
1203 void brand_weapon(int brand_type)
1210 /* Assume enchant weapon */
1211 item_tester_hook = item_tester_hook_weapon_nobow;
1212 item_tester_no_ryoute = TRUE;
1216 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1217 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1219 q = "Enchant which weapon? ";
1220 s = "You have nothing to enchant.";
1223 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1225 /* Get the item (in the pack) */
1228 o_ptr = &inventory[item];
1231 /* Get the item (on the floor) */
1234 o_ptr = &o_list[0 - item];
1238 /* you can never modify artifacts / ego-items */
1239 /* you can never modify cursed items */
1240 /* TY: You _can_ modify broken items (if you're silly enough) */
1241 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
1242 !o_ptr->art_name && !cursed_p(o_ptr) &&
1243 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1244 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1245 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1249 /* Let's get the name before it is changed... */
1250 char o_name[MAX_NLEN];
1251 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1256 if (o_ptr->tval == TV_SWORD)
1259 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1261 act = "becomes very sharp!";
1264 o_ptr->name2 = EGO_SHARPNESS;
1265 o_ptr->pval = m_bonus(5, dun_level) + 1;
1270 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1272 act = "seems very powerful.";
1275 o_ptr->name2 = EGO_EARTHQUAKES;
1276 o_ptr->pval = m_bonus(3, dun_level);
1281 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1283 act = "seems to be looking for humans!";
1286 o_ptr->name2 = EGO_SLAY_HUMAN;
1290 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1292 act = "covered with lightning!";
1295 o_ptr->name2 = EGO_BRAND_ELEC;
1299 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1301 act = "coated with acid!";
1304 o_ptr->name2 = EGO_BRAND_ACID;
1308 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1310 act = "seems to be looking for evil monsters!";
1313 o_ptr->name2 = EGO_SLAY_EVIL;
1317 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1319 act = "seems to be looking for demons!";
1322 o_ptr->name2 = EGO_SLAY_DEMON;
1326 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1328 act = "seems to be looking for undead!";
1331 o_ptr->name2 = EGO_SLAY_UNDEAD;
1335 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1337 act = "seems to be looking for animals!";
1340 o_ptr->name2 = EGO_SLAY_ANIMAL;
1344 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1346 act = "seems to be looking for dragons!";
1349 o_ptr->name2 = EGO_SLAY_DRAGON;
1353 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1355 act = "seems to be looking for troll!s";
1358 o_ptr->name2 = EGO_SLAY_TROLL;
1362 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1364 act = "seems to be looking for orcs!";
1367 o_ptr->name2 = EGO_SLAY_ORC;
1371 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1373 act = "seems to be looking for giants!";
1376 o_ptr->name2 = EGO_SLAY_GIANT;
1380 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1382 act = "seems very unstable now.";
1385 o_ptr->name2 = EGO_TRUMP;
1386 o_ptr->pval = randint1(2);
1390 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1392 act = "thirsts for blood!";
1395 o_ptr->name2 = EGO_VAMPIRIC;
1399 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1401 act = "is coated with poison.";
1404 o_ptr->name2 = EGO_BRAND_POIS;
1408 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1410 act = "is engulfed in raw Logrus!";
1413 o_ptr->name2 = EGO_CHAOTIC;
1417 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1419 act = "is covered in a fiery shield!";
1422 o_ptr->name2 = EGO_BRAND_FIRE;
1426 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1428 act = "glows deep, icy blue!";
1431 o_ptr->name2 = EGO_BRAND_COLD;
1436 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1438 msg_format("Your %s %s", o_name, act);
1442 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1444 o_ptr->discount = 99;
1445 chg_virtue(V_ENCHANT, 2);
1449 if (flush_failure) flush();
1452 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1454 msg_print("The Branding failed.");
1457 chg_virtue(V_ENCHANT, -2);
1464 * Vanish all walls in this floor
1466 static bool vanish_dungeon(void)
1470 feature_type *f_ptr;
1471 monster_type *m_ptr;
1474 /* Prevent vasishing of quest levels and town */
1475 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1480 /* Scan all normal grids */
1481 for (y = 1; y < cur_hgt - 1; y++)
1483 for (x = 1; x < cur_wid - 1; x++)
1485 c_ptr = &cave[y][x];
1487 /* Seeing true feature code (ignore mimic) */
1488 f_ptr = &f_info[c_ptr->feat];
1490 /* Lose room and vault */
1491 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1493 m_ptr = &m_list[c_ptr->m_idx];
1496 if (c_ptr->m_idx && m_ptr->csleep)
1498 /* Reset sleep counter */
1501 /* Notice the "waking up" */
1504 /* Acquire the monster name */
1505 monster_desc(m_name, m_ptr, 0);
1507 /* Dump a message */
1509 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1511 msg_format("%^s wakes up.", m_name);
1514 /* Redraw the health bar */
1515 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
1516 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
1520 /* Process all walls, doors and patterns */
1521 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1525 /* Special boundary walls -- Top and bottom */
1526 for (x = 0; x < cur_wid; x++)
1528 c_ptr = &cave[0][x];
1529 f_ptr = &f_info[c_ptr->mimic];
1531 /* Lose room and vault */
1532 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1534 /* Set boundary mimic if needed */
1535 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1537 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1539 /* Check for change to boring grid */
1540 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1543 c_ptr = &cave[cur_hgt - 1][x];
1544 f_ptr = &f_info[c_ptr->mimic];
1546 /* Lose room and vault */
1547 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1549 /* Set boundary mimic if needed */
1550 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1552 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1554 /* Check for change to boring grid */
1555 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1559 /* Special boundary walls -- Left and right */
1560 for (y = 1; y < (cur_hgt - 1); y++)
1562 c_ptr = &cave[y][0];
1563 f_ptr = &f_info[c_ptr->mimic];
1565 /* Lose room and vault */
1566 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1568 /* Set boundary mimic if needed */
1569 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1571 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1573 /* Check for change to boring grid */
1574 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1577 c_ptr = &cave[y][cur_wid - 1];
1578 f_ptr = &f_info[c_ptr->mimic];
1580 /* Lose room and vault */
1581 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1583 /* Set boundary mimic if needed */
1584 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1586 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1588 /* Check for change to boring grid */
1589 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1593 /* Mega-Hack -- Forget the view and lite */
1594 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1597 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1599 /* Update the monsters */
1600 p_ptr->update |= (PU_MONSTERS);
1603 p_ptr->redraw |= (PR_MAP);
1606 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1612 void call_the_(void)
1616 bool do_call = TRUE;
1618 for (i = 0; i < 9; i++)
1620 c_ptr = &cave[py + ddy_ddd[i]][px + ddx_ddd[i]];
1622 if (!have_flag(f_flags_grid(c_ptr), FF_PROJECT))
1624 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1625 !permanent_wall(&f_info[c_ptr->feat]))
1635 for (i = 1; i < 10; i++)
1637 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1640 for (i = 1; i < 10; i++)
1642 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1645 for (i = 1; i < 10; i++)
1647 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1651 /* Prevent destruction of quest levels and town */
1652 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1655 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1657 msg_print("The ground trembles.");
1664 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1665 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1666 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1668 msg_format("You %s the %s too close to a wall!",
1669 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1670 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1671 msg_print("There is a loud explosion!");
1677 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1679 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1684 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1686 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1688 msg_print("The dungeon collapses...");
1693 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1695 msg_print("The dungeon trembles.");
1700 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1702 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1709 * Fetch an item (teleport it right underneath the caster)
1711 void fetch(int dir, int wgt, bool require_los)
1716 char o_name[MAX_NLEN];
1718 /* Check to see if an object is already there */
1719 if (cave[py][px].o_idx)
1722 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1724 msg_print("You can't fetch when you're already standing on something.");
1731 if (dir == 5 && target_okay())
1736 if (distance(py, px, ty, tx) > MAX_RANGE)
1739 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1741 msg_print("You can't fetch something that far away!");
1747 c_ptr = &cave[ty][tx];
1749 /* We need an item to fetch */
1753 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1755 msg_print("There is no object at this place.");
1761 /* No fetching from vault */
1762 if (c_ptr->info & CAVE_ICKY)
1765 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1767 msg_print("The item slips from your control.");
1773 /* We need to see the item */
1776 if (!player_has_los_bold(ty, tx))
1779 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1781 msg_print("You have no direct line of sight to that location.");
1786 else if (!projectable(py, px, ty, tx))
1789 msg_print("¤½¤³¤ÏÊɤθþ¤³¤¦¤Ç¤¹¡£");
1791 msg_print("You have no direct line of sight to that location.");
1800 /* Use a direction */
1801 ty = py; /* Where to drop the item */
1808 c_ptr = &cave[ty][tx];
1810 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1811 !have_flag(f_flags_bold(ty, tx), FF_PROJECT)) return;
1813 while (!c_ptr->o_idx);
1816 o_ptr = &o_list[c_ptr->o_idx];
1818 if (o_ptr->weight > wgt)
1820 /* Too heavy to 'fetch' */
1822 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1824 msg_print("The object is too heavy.");
1831 c_ptr->o_idx = o_ptr->next_o_idx;
1832 cave[py][px].o_idx = i; /* 'move' it */
1833 o_ptr->next_o_idx = 0;
1834 o_ptr->iy = (byte)py;
1835 o_ptr->ix = (byte)px;
1837 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1839 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1841 msg_format("%^s flies through the air to your feet.", o_name);
1846 p_ptr->redraw |= PR_MAP;
1850 void alter_reality(void)
1852 /* Ironman option */
1853 if (p_ptr->inside_arena || ironman_downward)
1856 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1858 msg_print("Nothing happens.");
1863 if (!p_ptr->alter_reality)
1865 int turns = randint0(21) + 15;
1867 p_ptr->alter_reality = turns;
1869 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1871 msg_print("The view around you begins to change...");
1874 p_ptr->redraw |= (PR_STATUS);
1878 p_ptr->alter_reality = 0;
1880 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1882 msg_print("The view around you got back...");
1885 p_ptr->redraw |= (PR_STATUS);
1892 * Leave a "glyph of warding" which prevents monster movement
1894 bool warding_glyph(void)
1897 if (!cave_clean_bold(py, px))
1900 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1902 msg_print("The object resists the spell.");
1908 /* Create a glyph */
1909 cave[py][px].info |= CAVE_OBJECT;
1910 cave[py][px].mimic = FEAT_GLYPH;
1921 bool place_mirror(void)
1924 if (!cave_clean_bold(py, px))
1927 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1929 msg_print("The object resists the spell.");
1935 /* Create a mirror */
1936 cave[py][px].info |= CAVE_OBJECT;
1937 cave[py][px].mimic = FEAT_MIRROR;
1939 /* Turn on the light */
1940 cave[py][px].info |= CAVE_GLOW;
1953 * Leave an "explosive rune" which prevents monster movement
1955 bool explosive_rune(void)
1958 if (!cave_clean_bold(py, px))
1961 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1963 msg_print("The object resists the spell.");
1969 /* Create a glyph */
1970 cave[py][px].info |= CAVE_OBJECT;
1971 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1984 * Identify everything being carried.
1985 * Done by a potion of "self knowledge".
1987 void identify_pack(void)
1991 /* Simply identify and know every item */
1992 for (i = 0; i < INVEN_TOTAL; i++)
1994 object_type *o_ptr = &inventory[i];
1996 /* Skip non-objects */
1997 if (!o_ptr->k_idx) continue;
2000 identify_item(o_ptr);
2002 /* Auto-inscription */
2003 autopick_alter_item(i, FALSE);
2009 * Used by the "enchant" function (chance of failure)
2010 * (modified for Zangband, we need better stuff there...) -- TY
2012 static int enchant_table[16] =
2014 0, 10, 50, 100, 200,
2015 300, 400, 500, 650, 800,
2016 950, 987, 993, 995, 998,
2022 * Removes curses from items in inventory
2024 * Note that Items which are "Perma-Cursed" (The One Ring,
2025 * The Crown of Morgoth) can NEVER be uncursed.
2027 * Note that if "all" is FALSE, then Items which are
2028 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2029 * will not be uncursed.
2031 static int remove_curse_aux(int all)
2035 /* Attempt to uncurse items being worn */
2036 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2038 object_type *o_ptr = &inventory[i];
2040 /* Skip non-objects */
2041 if (!o_ptr->k_idx) continue;
2043 /* Uncursed already */
2044 if (!cursed_p(o_ptr)) continue;
2046 /* Heavily Cursed Items need a special spell */
2047 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2049 /* Perma-Cursed Items can NEVER be uncursed */
2050 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2053 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2058 o_ptr->curse_flags = 0L;
2060 /* Hack -- Assume felt */
2061 o_ptr->ident |= (IDENT_SENSE);
2064 o_ptr->feeling = FEEL_NONE;
2066 /* Recalculate the bonuses */
2067 p_ptr->update |= (PU_BONUS);
2070 p_ptr->window |= (PW_EQUIP);
2072 /* Count the uncursings */
2076 /* Return "something uncursed" */
2082 * Remove most curses
2084 bool remove_curse(void)
2086 return (remove_curse_aux(FALSE));
2092 bool remove_all_curse(void)
2094 return (remove_curse_aux(TRUE));
2099 * Turns an object into gold, gain some of its value in a shop
2108 char o_name[MAX_NLEN];
2109 char out_val[MAX_NLEN+40];
2113 /* Hack -- force destruction */
2114 if (command_arg > 0) force = TRUE;
2118 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2119 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2121 q = "Turn which item to gold? ";
2122 s = "You have nothing to turn to gold.";
2125 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2127 /* Get the item (in the pack) */
2130 o_ptr = &inventory[item];
2133 /* Get the item (on the floor) */
2136 o_ptr = &o_list[0 - item];
2140 /* See how many items */
2141 if (o_ptr->number > 1)
2143 /* Get a quantity */
2144 amt = get_quantity(NULL, o_ptr->number);
2146 /* Allow user abort */
2147 if (amt <= 0) return FALSE;
2151 /* Describe the object */
2152 old_number = o_ptr->number;
2153 o_ptr->number = amt;
2154 object_desc(o_name, o_ptr, 0);
2155 o_ptr->number = old_number;
2157 /* Verify unless quantity given */
2160 if (confirm_destroy || (object_value(o_ptr) > 0))
2162 /* Make a verification */
2164 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2166 sprintf(out_val, "Really turn %s to gold? ", o_name);
2169 if (!get_check(out_val)) return FALSE;
2173 /* Artifacts cannot be destroyed */
2174 if (!can_player_destroy_object(o_ptr))
2178 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2180 msg_format("You fail to turn %s to gold!", o_name);
2187 price = object_value_real(o_ptr);
2193 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2195 msg_format("You turn %s to fool's gold.", o_name);
2203 if (amt > 1) price *= amt;
2205 if (price > 30000) price = 30000;
2207 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2209 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2215 p_ptr->redraw |= (PR_GOLD);
2218 p_ptr->window |= (PW_PLAYER);
2222 /* Eliminate the item (from the pack) */
2225 inven_item_increase(item, -amt);
2226 inven_item_describe(item);
2227 inven_item_optimize(item);
2230 /* Eliminate the item (from the floor) */
2233 floor_item_increase(0 - item, -amt);
2234 floor_item_describe(0 - item);
2235 floor_item_optimize(0 - item);
2244 * Hook to specify "weapon"
2246 bool item_tester_hook_weapon(object_type *o_ptr)
2248 switch (o_ptr->tval)
2262 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2269 static bool item_tester_hook_weapon2(object_type *o_ptr)
2271 switch (o_ptr->tval)
2291 * Hook to specify "armour"
2293 bool item_tester_hook_armour(object_type *o_ptr)
2295 switch (o_ptr->tval)
2316 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2318 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2320 switch (o_ptr->tval)
2349 * Check if an object is nameless weapon or armour
2351 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2353 switch (o_ptr->tval)
2372 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2374 if (object_known_p(o_ptr)) return FALSE;
2384 * Break the curse of an item
2386 static void break_curse(object_type *o_ptr)
2388 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2391 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2393 msg_print("The curse is broken!");
2396 o_ptr->curse_flags = 0L;
2398 o_ptr->ident |= (IDENT_SENSE);
2400 o_ptr->feeling = FEEL_NONE;
2406 * Enchants a plus onto an item. -RAK-
2408 * Revamped! Now takes item pointer, number of times to try enchanting,
2409 * and a flag of what to try enchanting. Artifacts resist enchantment
2410 * some of the time, and successful enchantment to at least +0 might
2411 * break a curse on the item. -CFT-
2413 * Note that an item can technically be enchanted all the way to +15 if
2414 * you wait a very, very, long time. Going from +9 to +10 only works
2415 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2417 * Note that this function can now be used on "piles" of items, and
2418 * the larger the pile, the lower the chance of success.
2420 bool enchant(object_type *o_ptr, int n, int eflag)
2422 int i, chance, prob;
2424 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2425 bool force = (eflag & ENCH_FORCE);
2428 /* Large piles resist enchantment */
2429 prob = o_ptr->number * 100;
2431 /* Missiles are easy to enchant */
2432 if ((o_ptr->tval == TV_BOLT) ||
2433 (o_ptr->tval == TV_ARROW) ||
2434 (o_ptr->tval == TV_SHOT))
2440 for (i = 0; i < n; i++)
2442 /* Hack -- Roll for pile resistance */
2443 if (!force && randint0(prob) >= 100) continue;
2445 /* Enchant to hit */
2446 if (eflag & ENCH_TOHIT)
2448 if (o_ptr->to_h < 0) chance = 0;
2449 else if (o_ptr->to_h > 15) chance = 1000;
2450 else chance = enchant_table[o_ptr->to_h];
2452 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2457 /* only when you get it above -1 -CFT */
2458 if (o_ptr->to_h >= 0)
2463 /* Enchant to damage */
2464 if (eflag & ENCH_TODAM)
2466 if (o_ptr->to_d < 0) chance = 0;
2467 else if (o_ptr->to_d > 15) chance = 1000;
2468 else chance = enchant_table[o_ptr->to_d];
2470 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2475 /* only when you get it above -1 -CFT */
2476 if (o_ptr->to_d >= 0)
2481 /* Enchant to armor class */
2482 if (eflag & ENCH_TOAC)
2484 if (o_ptr->to_a < 0) chance = 0;
2485 else if (o_ptr->to_a > 15) chance = 1000;
2486 else chance = enchant_table[o_ptr->to_a];
2488 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2493 /* only when you get it above -1 -CFT */
2494 if (o_ptr->to_a >= 0)
2501 if (!res) return (FALSE);
2503 /* Recalculate bonuses */
2504 p_ptr->update |= (PU_BONUS);
2506 /* Combine / Reorder the pack (later) */
2507 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2510 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2521 * Enchant an item (in the inventory or on the floor)
2522 * Note that "num_ac" requires armour, else weapon
2523 * Returns TRUE if attempted, FALSE if cancelled
2525 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2530 char o_name[MAX_NLEN];
2534 /* Assume enchant weapon */
2535 item_tester_hook = item_tester_hook_weapon;
2536 item_tester_no_ryoute = TRUE;
2538 /* Enchant armor if requested */
2539 if (num_ac) item_tester_hook = item_tester_hook_armour;
2543 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2544 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2546 q = "Enchant which item? ";
2547 s = "You have nothing to enchant.";
2550 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2552 /* Get the item (in the pack) */
2555 o_ptr = &inventory[item];
2558 /* Get the item (on the floor) */
2561 o_ptr = &o_list[0 - item];
2566 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2570 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2573 msg_format("%s %s glow%s brightly!",
2574 ((item >= 0) ? "Your" : "The"), o_name,
2575 ((o_ptr->number > 1) ? "" : "s"));
2580 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2581 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2582 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2588 if (flush_failure) flush();
2592 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2594 msg_print("The enchantment failed.");
2597 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2600 chg_virtue(V_ENCHANT, 1);
2604 /* Something happened */
2609 bool artifact_scroll(void)
2614 char o_name[MAX_NLEN];
2618 item_tester_no_ryoute = TRUE;
2619 /* Enchant weapon/armour */
2620 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2624 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2625 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2627 q = "Enchant which item? ";
2628 s = "You have nothing to enchant.";
2631 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2633 /* Get the item (in the pack) */
2636 o_ptr = &inventory[item];
2639 /* Get the item (on the floor) */
2642 o_ptr = &o_list[0 - item];
2647 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2651 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2653 msg_format("%s %s radiate%s a blinding light!",
2654 ((item >= 0) ? "Your" : "The"), o_name,
2655 ((o_ptr->number > 1) ? "" : "s"));
2658 if (o_ptr->name1 || o_ptr->art_name)
2661 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2663 msg_format("The %s %s already %s!",
2664 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2665 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2671 else if (o_ptr->name2)
2674 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2676 msg_format("The %s %s already %s!",
2677 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2678 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2684 else if (o_ptr->xtra3)
2687 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2689 msg_format("The %s %s already %s!",
2690 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2691 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2697 if (o_ptr->number > 1)
2700 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2701 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2703 msg_print("Not enough enough energy to enchant more than one object!");
2704 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2709 inven_item_increase(item, 1-(o_ptr->number));
2713 floor_item_increase(0-item, 1-(o_ptr->number));
2716 okay = create_artifact(o_ptr, TRUE);
2723 if (flush_failure) flush();
2727 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2729 msg_print("The enchantment failed.");
2732 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2735 chg_virtue(V_ENCHANT, 1);
2739 /* Something happened */
2745 * Identify an object
2747 bool identify_item(object_type *o_ptr)
2749 bool old_known = FALSE;
2750 char o_name[MAX_NLEN];
2753 object_desc(o_name, o_ptr, 0);
2755 if (o_ptr->ident & IDENT_KNOWN)
2758 if (!(o_ptr->ident & (IDENT_MENTAL)))
2760 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2761 chg_virtue(V_KNOWLEDGE, 1);
2764 /* Identify it fully */
2765 object_aware(o_ptr);
2766 object_known(o_ptr);
2768 /* Recalculate bonuses */
2769 p_ptr->update |= (PU_BONUS);
2771 /* Combine / Reorder the pack (later) */
2772 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2775 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2777 strcpy(record_o_name, o_name);
2781 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2783 if(record_fix_art && !old_known && artifact_p(o_ptr))
2784 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2785 if(record_rand_art && !old_known && o_ptr->art_name)
2786 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2792 static bool item_tester_hook_identify(object_type *o_ptr)
2794 return (bool)!object_known_p(o_ptr);
2797 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2799 if (object_known_p(o_ptr))
2801 return item_tester_hook_weapon_armour(o_ptr);
2805 * Identify an object in the inventory (or on the floor)
2806 * This routine does *not* automatically combine objects.
2807 * Returns TRUE if something was identified, else FALSE.
2809 bool ident_spell(bool only_equip)
2813 char o_name[MAX_NLEN];
2817 item_tester_no_ryoute = TRUE;
2820 item_tester_hook = item_tester_hook_identify_weapon_armour;
2822 item_tester_hook = item_tester_hook_identify;
2824 if (!can_get_item())
2828 item_tester_hook = item_tester_hook_weapon_armour;
2832 item_tester_hook = NULL;
2838 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2839 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2841 q = "Identify which item? ";
2842 s = "You have nothing to identify.";
2845 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2847 /* Get the item (in the pack) */
2850 o_ptr = &inventory[item];
2853 /* Get the item (on the floor) */
2856 o_ptr = &o_list[0 - item];
2860 old_known = identify_item(o_ptr);
2863 object_desc(o_name, o_ptr, 0);
2866 if (item >= INVEN_RARM)
2869 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2871 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2877 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2879 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2885 msg_format("¾²¾å: %s¡£", o_name);
2887 msg_format("On the ground: %s.", o_name);
2891 /* Auto-inscription/destroy */
2892 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2894 /* Something happened */
2900 * Mundanify an object in the inventory (or on the floor)
2901 * This routine does *not* automatically combine objects.
2902 * Returns TRUE if something was mundanified, else FALSE.
2904 bool mundane_spell(bool only_equip)
2910 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
2911 item_tester_no_ryoute = TRUE;
2915 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2916 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2918 q = "Use which item? ";
2919 s = "You have nothing you can use.";
2922 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2924 /* Get the item (in the pack) */
2927 o_ptr = &inventory[item];
2930 /* Get the item (on the floor) */
2933 o_ptr = &o_list[0 - item];
2938 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2940 msg_print("There is a bright flash of light!");
2943 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2944 byte ix = o_ptr->ix; /* X-position on map, or zero */
2945 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2946 byte marked = o_ptr->marked; /* Object is marked */
2947 s16b weight = o_ptr->number * o_ptr->weight;
2948 u16b inscription = o_ptr->inscription;
2951 object_prep(o_ptr, o_ptr->k_idx);
2955 o_ptr->next_o_idx = next_o_idx;
2956 o_ptr->marked = marked;
2957 o_ptr->inscription = inscription;
2958 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2962 /* Something happened */
2968 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2970 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2973 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2975 if (!item_tester_hook_identify_fully(o_ptr))
2977 return item_tester_hook_weapon_armour(o_ptr);
2981 * Fully "identify" an object in the inventory -BEN-
2982 * This routine returns TRUE if an item was identified.
2984 bool identify_fully(bool only_equip)
2988 char o_name[MAX_NLEN];
2992 item_tester_no_ryoute = TRUE;
2994 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2996 item_tester_hook = item_tester_hook_identify_fully;
2998 if (!can_get_item())
3001 item_tester_hook = item_tester_hook_weapon_armour;
3003 item_tester_hook = NULL;
3008 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
3009 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3011 q = "Identify which item? ";
3012 s = "You have nothing to identify.";
3015 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
3017 /* Get the item (in the pack) */
3020 o_ptr = &inventory[item];
3023 /* Get the item (on the floor) */
3026 o_ptr = &o_list[0 - item];
3030 old_known = identify_item(o_ptr);
3032 /* Mark the item as fully known */
3033 o_ptr->ident |= (IDENT_MENTAL);
3039 object_desc(o_name, o_ptr, 0);
3042 if (item >= INVEN_RARM)
3045 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
3047 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
3055 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
3057 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3063 msg_format("¾²¾å: %s¡£", o_name);
3065 msg_format("On the ground: %s.", o_name);
3069 /* Describe it fully */
3070 (void)screen_object(o_ptr, TRUE);
3072 /* Auto-inscription/destroy */
3073 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
3083 * Hook for "get_item()". Determine if something is rechargable.
3085 bool item_tester_hook_recharge(object_type *o_ptr)
3087 /* Recharge staffs */
3088 if (o_ptr->tval == TV_STAFF) return (TRUE);
3090 /* Recharge wands */
3091 if (o_ptr->tval == TV_WAND) return (TRUE);
3093 /* Hack -- Recharge rods */
3094 if (o_ptr->tval == TV_ROD) return (TRUE);
3102 * Recharge a wand/staff/rod from the pack or on the floor.
3103 * This function has been rewritten in Oangband and ZAngband.
3105 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3106 * Chaos -- Arcane Binding --> recharge(90)
3108 * Scroll of recharging --> recharge(130)
3109 * Artifact activation/Thingol --> recharge(130)
3111 * It is harder to recharge high level, and highly charged wands,
3112 * staffs, and rods. The more wands in a stack, the more easily and
3113 * strongly they recharge. Staffs, however, each get fewer charges if
3116 * XXX XXX XXX Beware of "sliding index errors".
3118 bool recharge(int power)
3121 int recharge_strength, recharge_amount;
3130 char o_name[MAX_NLEN];
3132 /* Only accept legal items */
3133 item_tester_hook = item_tester_hook_recharge;
3137 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3138 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3140 q = "Recharge which item? ";
3141 s = "You have nothing to recharge.";
3144 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3146 /* Get the item (in the pack) */
3149 o_ptr = &inventory[item];
3152 /* Get the item (on the floor) */
3155 o_ptr = &o_list[0 - item];
3158 /* Get the object kind. */
3159 k_ptr = &k_info[o_ptr->k_idx];
3161 /* Extract the object "level" */
3162 lev = get_object_level(o_ptr);
3165 /* Recharge a rod */
3166 if (o_ptr->tval == TV_ROD)
3168 /* Extract a recharge strength by comparing object level to power. */
3169 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3173 if (one_in_(recharge_strength))
3175 /* Activate the failure code. */
3182 /* Recharge amount */
3183 recharge_amount = (power * damroll(3, 2));
3185 /* Recharge by that amount */
3186 if (o_ptr->timeout > recharge_amount)
3187 o_ptr->timeout -= recharge_amount;
3194 /* Recharge wand/staff */
3197 /* Extract a recharge strength by comparing object level to power.
3198 * Divide up a stack of wands' charges to calculate charge penalty.
3200 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3201 recharge_strength = (100 + power - lev -
3202 (8 * o_ptr->pval / o_ptr->number)) / 15;
3204 /* All staffs, unstacked wands. */
3205 else recharge_strength = (100 + power - lev -
3206 (8 * o_ptr->pval)) / 15;
3209 if (recharge_strength < 0) recharge_strength = 0;
3212 if (one_in_(recharge_strength))
3214 /* Activate the failure code. */
3218 /* If the spell didn't backfire, recharge the wand or staff. */
3221 /* Recharge based on the standard number of charges. */
3222 recharge_amount = randint1(1 + k_ptr->pval / 2);
3224 /* Multiple wands in a stack increase recharging somewhat. */
3225 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3228 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3229 if (recharge_amount < 1) recharge_amount = 1;
3230 if (recharge_amount > 12) recharge_amount = 12;
3233 /* But each staff in a stack gets fewer additional charges,
3234 * although always at least one.
3236 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3238 recharge_amount /= o_ptr->number;
3239 if (recharge_amount < 1) recharge_amount = 1;
3242 /* Recharge the wand or staff. */
3243 o_ptr->pval += recharge_amount;
3246 /* Hack -- we no longer "know" the item */
3247 o_ptr->ident &= ~(IDENT_KNOWN);
3249 /* Hack -- we no longer think the item is empty */
3250 o_ptr->ident &= ~(IDENT_EMPTY);
3255 /* Inflict the penalties for failing a recharge. */
3258 /* Artifacts are never destroyed. */
3259 if (artifact_p(o_ptr))
3261 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3263 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3265 msg_format("The recharging backfires - %s is completely drained!", o_name);
3269 /* Artifact rods. */
3270 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3271 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3273 /* Artifact wands and staffs. */
3274 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3279 /* Get the object description */
3280 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3282 /*** Determine Seriousness of Failure ***/
3284 /* Mages recharge objects more safely. */
3285 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)
3287 /* 10% chance to blow up one rod, otherwise draining. */
3288 if (o_ptr->tval == TV_ROD)
3290 if (one_in_(10)) fail_type = 2;
3293 /* 75% chance to blow up one wand, otherwise draining. */
3294 else if (o_ptr->tval == TV_WAND)
3296 if (!one_in_(3)) fail_type = 2;
3299 /* 50% chance to blow up one staff, otherwise no effect. */
3300 else if (o_ptr->tval == TV_STAFF)
3302 if (one_in_(2)) fail_type = 2;
3307 /* All other classes get no special favors. */
3310 /* 33% chance to blow up one rod, otherwise draining. */
3311 if (o_ptr->tval == TV_ROD)
3313 if (one_in_(3)) fail_type = 2;
3316 /* 20% chance of the entire stack, else destroy one wand. */
3317 else if (o_ptr->tval == TV_WAND)
3319 if (one_in_(5)) fail_type = 3;
3322 /* Blow up one staff. */
3323 else if (o_ptr->tval == TV_STAFF)
3329 /*** Apply draining and destruction. ***/
3331 /* Drain object or stack of objects. */
3334 if (o_ptr->tval == TV_ROD)
3337 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3339 msg_print("The recharge backfires, draining the rod further!");
3342 if (o_ptr->timeout < 10000)
3343 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3345 else if (o_ptr->tval == TV_WAND)
3348 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3350 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3355 /* Staffs aren't drained. */
3358 /* Destroy an object or one in a stack of objects. */
3361 if (o_ptr->number > 1)
3363 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3365 msg_format("Wild magic consumes one of your %s!", o_name);
3370 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3372 msg_format("Wild magic consumes your %s!", o_name);
3376 /* Reduce rod stack maximum timeout, drain wands. */
3377 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3378 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3380 /* Reduce and describe inventory */
3383 inven_item_increase(item, -1);
3384 inven_item_describe(item);
3385 inven_item_optimize(item);
3388 /* Reduce and describe floor item */
3391 floor_item_increase(0 - item, -1);
3392 floor_item_describe(0 - item);
3393 floor_item_optimize(0 - item);
3397 /* Destroy all members of a stack of objects. */
3400 if (o_ptr->number > 1)
3402 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3404 msg_format("Wild magic consumes all your %s!", o_name);
3409 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3411 msg_format("Wild magic consumes your %s!", o_name);
3416 /* Reduce and describe inventory */
3419 inven_item_increase(item, -999);
3420 inven_item_describe(item);
3421 inven_item_optimize(item);
3424 /* Reduce and describe floor item */
3427 floor_item_increase(0 - item, -999);
3428 floor_item_describe(0 - item);
3429 floor_item_optimize(0 - item);
3435 /* Combine / Reorder the pack (later) */
3436 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3439 p_ptr->window |= (PW_INVEN);
3441 /* Something was done */
3449 bool bless_weapon(void)
3453 u32b flgs[TR_FLAG_SIZE];
3454 char o_name[MAX_NLEN];
3457 item_tester_no_ryoute = TRUE;
3458 /* Assume enchant weapon */
3459 item_tester_hook = item_tester_hook_weapon2;
3463 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3464 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3466 q = "Bless which weapon? ";
3467 s = "You have weapon to bless.";
3470 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3473 /* Get the item (in the pack) */
3476 o_ptr = &inventory[item];
3479 /* Get the item (on the floor) */
3482 o_ptr = &o_list[0 - item];
3487 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3489 /* Extract the flags */
3490 object_flags(o_ptr, flgs);
3492 if (cursed_p(o_ptr))
3494 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3495 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3498 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3501 msg_format("The black aura on %s %s disrupts the blessing!",
3502 ((item >= 0) ? "your" : "the"), o_name);
3509 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3512 msg_format("A malignant aura leaves %s %s.",
3513 ((item >= 0) ? "your" : "the"), o_name);
3518 o_ptr->curse_flags = 0L;
3520 /* Hack -- Assume felt */
3521 o_ptr->ident |= (IDENT_SENSE);
3524 o_ptr->feeling = FEEL_NONE;
3526 /* Recalculate the bonuses */
3527 p_ptr->update |= (PU_BONUS);
3530 p_ptr->window |= (PW_EQUIP);
3534 * Next, we try to bless it. Artifacts have a 1/3 chance of
3535 * being blessed, otherwise, the operation simply disenchants
3536 * them, godly power negating the magic. Ok, the explanation
3537 * is silly, but otherwise priests would always bless every
3538 * artifact weapon they find. Ego weapons and normal weapons
3539 * can be blessed automatically.
3541 if (have_flag(flgs, TR_BLESSED))
3544 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3547 msg_format("%s %s %s blessed already.",
3548 ((item >= 0) ? "Your" : "The"), o_name,
3549 ((o_ptr->number > 1) ? "were" : "was"));
3555 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3559 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3562 msg_format("%s %s shine%s!",
3563 ((item >= 0) ? "Your" : "The"), o_name,
3564 ((o_ptr->number > 1) ? "" : "s"));
3567 add_flag(o_ptr->art_flags, TR_BLESSED);
3568 o_ptr->discount = 99;
3572 bool dis_happened = FALSE;
3575 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3577 msg_print("The weapon resists your blessing!");
3581 /* Disenchant tohit */
3582 if (o_ptr->to_h > 0)
3585 dis_happened = TRUE;
3588 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3590 /* Disenchant todam */
3591 if (o_ptr->to_d > 0)
3594 dis_happened = TRUE;
3597 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3599 /* Disenchant toac */
3600 if (o_ptr->to_a > 0)
3603 dis_happened = TRUE;
3606 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3611 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3613 msg_print("There is a static feeling in the air...");
3617 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3620 msg_format("%s %s %s disenchanted!",
3621 ((item >= 0) ? "Your" : "The"), o_name,
3622 ((o_ptr->number > 1) ? "were" : "was"));
3628 /* Recalculate bonuses */
3629 p_ptr->update |= (PU_BONUS);
3632 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3643 bool pulish_shield(void)
3647 u32b flgs[TR_FLAG_SIZE];
3648 char o_name[MAX_NLEN];
3651 item_tester_no_ryoute = TRUE;
3652 /* Assume enchant weapon */
3653 item_tester_tval = TV_SHIELD;
3657 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3658 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3660 q = "Pulish which weapon? ";
3661 s = "You have weapon to pulish.";
3664 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3667 /* Get the item (in the pack) */
3670 o_ptr = &inventory[item];
3673 /* Get the item (on the floor) */
3676 o_ptr = &o_list[0 - item];
3681 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3683 /* Extract the flags */
3684 object_flags(o_ptr, flgs);
3686 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3687 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3690 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3692 msg_format("%s %s shine%s!",
3693 ((item >= 0) ? "Your" : "The"), o_name,
3694 ((o_ptr->number > 1) ? "" : "s"));
3696 o_ptr->name2 = EGO_REFLECTION;
3697 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3699 o_ptr->discount = 99;
3700 chg_virtue(V_ENCHANT, 2);
3706 if (flush_failure) flush();
3709 msg_print("¼ºÇÔ¤·¤¿¡£");
3711 msg_print("Failed.");
3714 chg_virtue(V_ENCHANT, -2);
3723 * Potions "smash open" and cause an area effect when
3724 * (1) they are shattered while in the player's inventory,
3725 * due to cold (etc) attacks;
3726 * (2) they are thrown at a monster, or obstacle;
3727 * (3) they are shattered by a "cold ball" or other such spell
3728 * while lying on the floor.
3731 * who --- who caused the potion to shatter (0=player)
3732 * potions that smash on the floor are assumed to
3733 * be caused by no-one (who = 1), as are those that
3734 * shatter inside the player inventory.
3735 * (Not anymore -- I changed this; TY)
3736 * y, x --- coordinates of the potion (or player if
3737 * the potion was in her inventory);
3738 * o_ptr --- pointer to the potion object.
3740 bool potion_smash_effect(int who, int y, int x, int k_idx)
3747 object_kind *k_ptr = &k_info[k_idx];
3749 switch (k_ptr->sval)
3751 case SV_POTION_SALT_WATER:
3752 case SV_POTION_SLIME_MOLD:
3753 case SV_POTION_LOSE_MEMORIES:
3754 case SV_POTION_DEC_STR:
3755 case SV_POTION_DEC_INT:
3756 case SV_POTION_DEC_WIS:
3757 case SV_POTION_DEC_DEX:
3758 case SV_POTION_DEC_CON:
3759 case SV_POTION_DEC_CHR:
3760 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3761 case SV_POTION_APPLE_JUICE:
3764 case SV_POTION_INFRAVISION:
3765 case SV_POTION_DETECT_INVIS:
3766 case SV_POTION_SLOW_POISON:
3767 case SV_POTION_CURE_POISON:
3768 case SV_POTION_BOLDNESS:
3769 case SV_POTION_RESIST_HEAT:
3770 case SV_POTION_RESIST_COLD:
3771 case SV_POTION_HEROISM:
3772 case SV_POTION_BESERK_STRENGTH:
3773 case SV_POTION_RES_STR:
3774 case SV_POTION_RES_INT:
3775 case SV_POTION_RES_WIS:
3776 case SV_POTION_RES_DEX:
3777 case SV_POTION_RES_CON:
3778 case SV_POTION_RES_CHR:
3779 case SV_POTION_INC_STR:
3780 case SV_POTION_INC_INT:
3781 case SV_POTION_INC_WIS:
3782 case SV_POTION_INC_DEX:
3783 case SV_POTION_INC_CON:
3784 case SV_POTION_INC_CHR:
3785 case SV_POTION_AUGMENTATION:
3786 case SV_POTION_ENLIGHTENMENT:
3787 case SV_POTION_STAR_ENLIGHTENMENT:
3788 case SV_POTION_SELF_KNOWLEDGE:
3789 case SV_POTION_EXPERIENCE:
3790 case SV_POTION_RESISTANCE:
3791 case SV_POTION_INVULNERABILITY:
3792 case SV_POTION_NEW_LIFE:
3793 /* All of the above potions have no effect when shattered */
3795 case SV_POTION_SLOWNESS:
3800 case SV_POTION_POISON:
3805 case SV_POTION_BLINDNESS:
3809 case SV_POTION_CONFUSION: /* Booze */
3813 case SV_POTION_SLEEP:
3817 case SV_POTION_RUINATION:
3818 case SV_POTION_DETONATIONS:
3820 dam = damroll(25, 25);
3823 case SV_POTION_DEATH:
3824 dt = GF_DEATH_RAY; /* !! */
3825 dam = k_ptr->level * 10;
3829 case SV_POTION_SPEED:
3832 case SV_POTION_CURE_LIGHT:
3834 dam = damroll(2, 3);
3836 case SV_POTION_CURE_SERIOUS:
3838 dam = damroll(4, 3);
3840 case SV_POTION_CURE_CRITICAL:
3841 case SV_POTION_CURING:
3843 dam = damroll(6, 3);
3845 case SV_POTION_HEALING:
3847 dam = damroll(10, 10);
3849 case SV_POTION_RESTORE_EXP:
3854 case SV_POTION_LIFE:
3856 dam = damroll(50, 50);
3859 case SV_POTION_STAR_HEALING:
3861 dam = damroll(50, 50);
3864 case SV_POTION_RESTORE_MANA: /* MANA */
3866 dam = damroll(10, 10);
3873 (void)project(who, radius, y, x, dam, dt,
3874 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3876 /* XXX those potions that explode need to become "known" */
3882 * Hack -- Display all known spells in a window
3884 * XXX XXX XXX Need to analyze size of the window.
3886 * XXX XXX XXX Need more color coding.
3888 void display_spell_list(void)
3901 /* They have too many spells to list */
3902 if (p_ptr->pclass == CLASS_SORCERER) return;
3903 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3905 /* mind.c type classes */
3906 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3907 (p_ptr->pclass == CLASS_BERSERKER) ||
3908 (p_ptr->pclass == CLASS_NINJA) ||
3909 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3910 (p_ptr->pclass == CLASS_FORCETRAINER))
3916 int plev = p_ptr->lev;
3922 bool use_hp = FALSE;
3924 /* Display a list of spells */
3927 put_str("̾Á°", y, x + 5);
3928 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3930 put_str("Name", y, x + 5);
3931 put_str("Lv Mana Fail Info", y, x + 35);
3934 switch(p_ptr->pclass)
3936 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3937 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3938 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3939 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3940 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3941 default: use_mind = 0;break;
3944 /* Dump the spells */
3945 for (i = 0; i < MAX_MIND_POWERS; i++)
3947 byte a = TERM_WHITE;
3949 /* Access the available spell */
3950 spell = mind_powers[use_mind].info[i];
3951 if (spell.min_lev > plev) break;
3953 /* Get the failure rate */
3954 chance = spell.fail;
3956 /* Reduce failure rate by "effective" level adjustment */
3957 chance -= 3 * (p_ptr->lev - spell.min_lev);
3959 /* Reduce failure rate by INT/WIS adjustment */
3960 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3964 /* Not enough mana to cast */
3965 if (spell.mana_cost > p_ptr->csp)
3967 chance += 5 * (spell.mana_cost - p_ptr->csp);
3973 /* Not enough hp to cast */
3974 if (spell.mana_cost > p_ptr->chp)
3981 /* Extract the minimum failure rate */
3982 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3984 /* Minimum failure rate */
3985 if (chance < minfail) chance = minfail;
3987 /* Stunning makes spells harder */
3988 if (p_ptr->stun > 50) chance += 25;
3989 else if (p_ptr->stun) chance += 15;
3991 /* Always a 5 percent chance of working */
3992 if (chance > 95) chance = 95;
3995 mindcraft_info(comment, use_mind, i);
3997 /* Dump the spell */
3998 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
4000 spell.min_lev, spell.mana_cost, chance, comment);
4002 Term_putstr(x, y + i + 1, -1, a, psi_desc);
4007 /* Cannot read spellbooks */
4008 if (REALM_NONE == p_ptr->realm1) return;
4010 /* Normal spellcaster with books */
4013 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
4017 /* Reset vertical */
4020 /* Vertical location */
4021 y = (j < 3) ? 0 : (m[j - 3] + 2);
4023 /* Horizontal location */
4027 for (i = 0; i < 32; i++)
4029 byte a = TERM_WHITE;
4031 /* Access the spell */
4032 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
4034 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
4038 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
4041 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
4044 if (s_ptr->slevel >= 99)
4048 strcpy(name, "(ȽÆÉÉÔǽ)");
4050 strcpy(name, "(illegible)");
4060 ((p_ptr->spell_forgotten1 & (1L << i))) :
4061 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4068 else if (!((j < 1) ?
4069 (p_ptr->spell_learned1 & (1L << i)) :
4070 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4077 else if (!((j < 1) ?
4078 (p_ptr->spell_worked1 & (1L << i)) :
4079 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4085 /* Dump the spell --(-- */
4086 sprintf(out_val, "%c/%c) %-20.20s",
4087 I2A(n / 8), I2A(n % 8), name);
4092 /* Dump onto the window */
4093 Term_putstr(x, m[j], -1, a, out_val);
4103 * Returns experience of a spell
4105 s16b experience_of_spell(int spell, int use_realm)
4107 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4108 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4109 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4110 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4116 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4118 int mod_need_mana(int need_mana, int spell, int realm)
4120 #define MANA_CONST 2400
4122 #define DEC_MANA_DIV 3
4125 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4128 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4129 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4131 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4132 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4133 need_mana /= MANA_CONST * MANA_DIV;
4134 if (need_mana < 1) need_mana = 1;
4137 /* Non-realm magic */
4140 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4152 * Modify spell fail rate
4153 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4155 int mod_spell_chance_1(int chance)
4157 chance += p_ptr->to_m_chance;
4159 if (p_ptr->heavy_spell) chance += 20;
4161 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4162 else if (p_ptr->easy_spell) chance -= 3;
4163 else if (p_ptr->dec_mana) chance -= 2;
4170 * Modify spell fail rate (as "suffix" process)
4171 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4172 * Note: variable "chance" cannot be negative.
4174 int mod_spell_chance_2(int chance)
4176 if (p_ptr->dec_mana) chance--;
4178 if (p_ptr->heavy_spell) chance += 5;
4180 return MAX(chance, 0);
4185 * Returns spell chance of failure for spell -RAK-
4187 s16b spell_chance(int spell, int use_realm)
4189 int chance, minfail;
4192 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4195 /* Paranoia -- must be literate */
4196 if (!mp_ptr->spell_book) return (100);
4198 if (use_realm == REALM_HISSATSU) return 0;
4200 /* Access the spell */
4201 if (!is_magic(use_realm))
4203 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4207 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4210 /* Extract the base spell failure rate */
4211 chance = s_ptr->sfail;
4213 /* Reduce failure rate by "effective" level adjustment */
4214 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4216 /* Reduce failure rate by INT/WIS adjustment */
4217 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4220 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4222 /* Extract mana consumption rate */
4223 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4225 /* Not enough mana to cast */
4226 if (need_mana > p_ptr->csp)
4228 chance += 5 * (need_mana - p_ptr->csp);
4231 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4233 /* Extract the minimum failure rate */
4234 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4237 * Non mage/priest characters never get too good
4238 * (added high mage, mindcrafter)
4240 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4242 if (minfail < 5) minfail = 5;
4245 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4246 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4247 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4249 chance = mod_spell_chance_1(chance);
4251 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4252 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4253 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4255 /* Minimum failure rate */
4256 if (chance < minfail) chance = minfail;
4258 /* Stunning makes spells harder */
4259 if (p_ptr->stun > 50) chance += 25;
4260 else if (p_ptr->stun) chance += 15;
4262 /* Always a 5 percent chance of working */
4263 if (chance > 95) chance = 95;
4265 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4266 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4268 s16b exp = experience_of_spell(spell, use_realm);
4269 if (exp >= SPELL_EXP_EXPERT) chance--;
4270 if (exp >= SPELL_EXP_MASTER) chance--;
4273 /* Return the chance */
4274 return mod_spell_chance_2(chance);
4280 * Determine if a spell is "okay" for the player to cast or study
4281 * The spell must be legible, not forgotten, and also, to cast,
4282 * it must be known, and to study, it must not be known.
4284 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4288 /* Access the spell */
4289 if (!is_magic(use_realm))
4291 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4295 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4298 /* Spell is illegal */
4299 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4301 /* Spell is forgotten */
4302 if ((use_realm == p_ptr->realm2) ?
4303 (p_ptr->spell_forgotten2 & (1L << spell)) :
4304 (p_ptr->spell_forgotten1 & (1L << spell)))
4310 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4311 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4313 /* Spell is learned */
4314 if ((use_realm == p_ptr->realm2) ?
4315 (p_ptr->spell_learned2 & (1L << spell)) :
4316 (p_ptr->spell_learned1 & (1L << spell)))
4319 return (!study_pray);
4322 /* Okay to study, not to cast */
4329 * Extra information on a spell -DRS-
4331 * We can use up to 14 characters of the buffer 'p'
4333 * The strings in this function were extracted from the code in the
4334 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4336 static void spell_info(char *p, int spell, int use_realm)
4338 int plev = p_ptr->lev;
4341 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4342 p_ptr->pclass == CLASS_HIGH_MAGE ||
4343 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4345 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4346 p_ptr->pclass == CLASS_HIGH_MAGE ||
4347 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4349 cptr s_dam = "»½ý:";
4350 cptr s_dur = "´ü´Ö:";
4351 cptr s_range = "ÈÏ°Ï:";
4352 cptr s_heal = "²óÉü:";
4353 cptr s_random = "¥é¥ó¥À¥à";
4354 cptr s_delay = "ÃÙ±ä:";
4356 cptr s_dam = "dam ";
4357 cptr s_dur = "dur ";
4358 cptr s_range = "range ";
4359 cptr s_heal = "heal ";
4360 cptr s_random = "random";
4361 cptr s_delay = "delay ";
4366 /* Analyze the spell */
4369 case REALM_LIFE: /* Life */
4372 case 0: sprintf(p, " %s2d10", s_heal); break;
4373 case 1: sprintf(p, " %s12+d12", s_dur); break;
4374 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4375 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4376 case 5: sprintf(p, " %s4d10", s_heal); break;
4377 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4378 case 10: sprintf(p, " %s8d10", s_heal); break;
4379 case 11: sprintf(p, " %s20+d20", s_dur); break;
4380 case 14: sprintf(p, " %s300", s_heal); break;
4381 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4382 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4383 case 21: sprintf(p, " %s15+d21", s_delay); break;
4384 case 29: sprintf(p, " %s2000", s_heal); break;
4385 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4389 case REALM_SORCERY: /* Sorcery */
4392 case 1: sprintf(p, " %s10", s_range); break;
4393 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4394 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4395 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4396 case 18: sprintf(p, " %s25+d30", s_dur); break;
4397 case 22: sprintf(p, " %s15+d21", s_delay); break;
4398 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4399 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4401 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4403 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4405 case 27: sprintf(p, " %s25+d30", s_dur); break;
4406 case 31: sprintf(p, " %s4+d4", s_dur); break;
4410 case REALM_NATURE: /* Nature */
4414 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4416 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4418 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4419 case 6: sprintf(p, " %s20+d20", s_dur); break;
4420 case 7: sprintf(p, " %s2d8", s_heal); break;
4421 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4422 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4423 case 12: sprintf(p, " %s6d8", s_dam); break;
4424 case 15: sprintf(p, " %s500", s_heal); break;
4425 case 17: sprintf(p, " %s20+d30", s_dur); break;
4426 case 18: sprintf(p, " %s20+d20", s_dur); break;
4428 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4430 case 24: sprintf(p, " rad 10"); break;
4432 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4433 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4434 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4435 case 29: sprintf(p, " %s75", s_dam); break;
4436 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4440 case REALM_CHAOS: /* Chaos */
4443 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4444 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4445 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4446 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4447 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4448 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4449 case 8: sprintf(p, " %s", s_random); break;
4450 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4451 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4452 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4453 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4454 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4455 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4456 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4457 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4458 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4460 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4462 case 25: sprintf(p, " dam %d each", plev * 2); break;
4464 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4465 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4466 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4467 case 30: sprintf(p, " %s%ld", s_dam, p_ptr->chp); break;
4468 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4472 case REALM_DEATH: /* Death */
4475 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4476 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4477 case 5: sprintf(p, " %s20+d20", s_dur); break;
4478 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4479 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4480 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4482 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4484 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4486 case 16: sprintf(p, " %s25+d25", s_dur); break;
4487 case 17: sprintf(p, " %s", s_random); break;
4488 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4489 case 19: sprintf(p, " %s25+d25", s_dur); break;
4490 case 21: sprintf(p, " %s3*100", s_dam); break;
4491 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4492 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4493 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4494 case 30: sprintf(p, " %s666", s_dam); break;
4495 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4499 case REALM_TRUMP: /* Trump */
4502 case 0: sprintf(p, " %s10", s_range); break;
4503 case 2: sprintf(p, " %s", s_random); break;
4504 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4505 case 5: sprintf(p, " %s25+d30", s_dur); break;
4507 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4509 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4511 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4512 case 14: sprintf(p, " %s15+d21", s_delay); break;
4513 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4515 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4517 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4522 case REALM_ARCANE: /* Arcane */
4525 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4526 case 4: sprintf(p, " %s10", s_range); break;
4527 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4528 case 7: sprintf(p, " %s2d8", s_heal); break;
4532 case 17: sprintf(p, " %s20+d20", s_dur); break;
4533 case 18: sprintf(p, " %s4d8", s_heal); break;
4534 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4535 case 21: sprintf(p, " %s6d8", s_dam); break;
4536 case 24: sprintf(p, " %s24+d24", s_dur); break;
4537 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4538 case 30: sprintf(p, " %s15+d21", s_delay); break;
4539 case 31: sprintf(p, " %s25+d30", s_dur); break;
4543 case REALM_ENCHANT: /* Craft */
4546 case 0: sprintf(p, " %s100+d100", s_dur); break;
4547 case 1: sprintf(p, " %s80+d80", s_dur); break;
4553 case 18: sprintf(p, " %s20+d20", s_dur); break;
4554 case 5: sprintf(p, " %s25+d25", s_dur); break;
4555 case 8: sprintf(p, " %s24+d24", s_dur); break;
4556 case 11: sprintf(p, " %s25+d25", s_dur); break;
4557 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4558 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4559 case 16: sprintf(p, " %s25+d30", s_dur); break;
4560 case 17: sprintf(p, " %s30+d20", s_dur); break;
4561 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4562 case 20: sprintf(p, " %s50+d50", s_dur); break;
4563 case 23: sprintf(p, " %s20+d20", s_dur); break;
4564 case 31: sprintf(p, " %s13+d13", s_dur); break;
4568 case REALM_DAEMON: /* Daemon */
4571 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4572 case 2: sprintf(p, " %s12+d12", s_dur); break;
4573 case 3: sprintf(p, " %s20+d20", s_dur); break;
4574 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4575 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4576 case 10: sprintf(p, " %s20+d20", s_dur); break;
4577 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4578 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4579 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4580 case 16: sprintf(p, " %s30+d25", s_dur); break;
4581 case 17: sprintf(p, " %s20+d20", s_dur); break;
4582 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4583 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4584 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4585 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4586 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4587 case 24: sprintf(p, " %s25+d25", s_dur); break;
4588 case 25: sprintf(p, " %s20+d20", s_dur); break;
4589 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4590 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4591 case 30: sprintf(p, " %s600", s_dam); break;
4592 case 31: sprintf(p, " %s15+d15", s_dur); break;
4596 case REALM_CRUSADE: /* Crusade */
4599 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4600 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4602 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4604 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4606 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4607 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4608 case 12: sprintf(p, " %s24+d24", s_dur); break;
4609 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4610 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4612 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4614 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4616 case 18: sprintf(p, " %s18+d18", s_dur); break;
4617 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4618 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4619 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4620 case 24: sprintf(p, " %s25+d25", s_dur); break;
4621 case 28: sprintf(p, " %s10+d10", s_dur); break;
4623 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4625 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4628 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4630 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4635 case REALM_MUSIC: /* Music */
4638 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4639 case 4 : sprintf(p, " %s2d6", s_heal); break;
4640 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4641 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4642 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4643 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4644 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4645 case 28: sprintf(p, " %s15d10", s_heal); break;
4646 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4651 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4653 sprintf(p, "Unknown type: %d.", use_realm);
4660 * Print a list of spells (for browsing or casting or viewing)
4662 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4664 int i, spell, exp_level, increment = 64;
4676 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4678 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4680 msg_print("Warning! print_spells called with null realm");
4684 /* Title the list */
4686 if (use_realm == REALM_HISSATSU)
4688 strcpy(buf," Lv MP");
4690 strcpy(buf," Lv SP");
4694 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4696 strcpy(buf,"Profic Lv SP Fail Effect");
4700 put_str("̾Á°", y, x + 5);
4701 put_str(buf, y, x + 29);
4703 put_str("Name", y, x + 5);
4704 put_str(buf, y, x + 29);
4707 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4708 else if (use_realm == p_ptr->realm1) increment = 0;
4709 else if (use_realm == p_ptr->realm2) increment = 32;
4711 /* Dump the spells */
4712 for (i = 0; i < num; i++)
4714 /* Access the spell */
4717 /* Access the spell */
4718 if (!is_magic(use_realm))
4720 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4724 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4727 if (use_realm == REALM_HISSATSU)
4728 need_mana = s_ptr->smana;
4731 s16b exp = experience_of_spell(spell, use_realm);
4733 /* Extract mana consumption rate */
4734 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4736 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4737 else exp_level = spell_exp_level(exp);
4740 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4741 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4742 else if (s_ptr->slevel >= 99) max = TRUE;
4743 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4745 strncpy(ryakuji, exp_level_str[exp_level], 4);
4750 if (use_menu && target_spell)
4752 if (i == (target_spell-1))
4754 strcpy(out_val, " ¡Õ ");
4756 strcpy(out_val, " > ");
4759 strcpy(out_val, " ");
4761 else sprintf(out_val, " %c) ", I2A(i));
4762 /* Skip illegible spells */
4763 if (s_ptr->slevel >= 99)
4766 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4768 strcat(out_val, format("%-30s", "(illegible)"));
4771 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4775 /* XXX XXX Could label spells above the players level */
4777 /* Get extra info */
4778 spell_info(info, spell, use_realm);
4783 /* Assume spell is known and tried */
4784 line_attr = TERM_WHITE;
4786 /* Analyze the spell */
4787 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4789 if (s_ptr->slevel > p_ptr->max_plv)
4794 comment = " unknown";
4797 line_attr = TERM_L_BLUE;
4799 else if (s_ptr->slevel > p_ptr->lev)
4804 comment = " forgotten";
4807 line_attr = TERM_YELLOW;
4810 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4815 comment = " unknown";
4818 line_attr = TERM_L_BLUE;
4820 else if ((use_realm == p_ptr->realm1) ?
4821 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4822 ((p_ptr->spell_forgotten2 & (1L << spell))))
4827 comment = " forgotten";
4830 line_attr = TERM_YELLOW;
4832 else if (!((use_realm == p_ptr->realm1) ?
4833 (p_ptr->spell_learned1 & (1L << spell)) :
4834 (p_ptr->spell_learned2 & (1L << spell))))
4839 comment = " unknown";
4842 line_attr = TERM_L_BLUE;
4844 else if (!((use_realm == p_ptr->realm1) ?
4845 (p_ptr->spell_worked1 & (1L << spell)) :
4846 (p_ptr->spell_worked2 & (1L << spell))))
4849 comment = " ̤·Ð¸³";
4851 comment = " untried";
4854 line_attr = TERM_L_GREEN;
4857 /* Dump the spell --(-- */
4858 if (use_realm == REALM_HISSATSU)
4860 strcat(out_val, format("%-25s %2d %4d",
4861 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4862 s_ptr->slevel, need_mana));
4866 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4867 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4868 (max ? '!' : ' '), ryakuji,
4869 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4871 c_prt(line_attr, out_val, y + i + 1, x);
4874 /* Clear the bottom line */
4875 prt("", y + i + 1, x);
4880 * Note that amulets, rods, and high-level spell books are immune
4881 * to "inventory damage" of any kind. Also sling ammo and shovels.
4886 * Does a given class of objects (usually) hate acid?
4887 * Note that acid can either melt or corrode something.
4889 bool hates_acid(object_type *o_ptr)
4891 /* Analyze the type */
4892 switch (o_ptr->tval)
4894 /* Wearable items */
4914 /* Staffs/Scrolls are wood/paper */
4927 /* Junk is useless */
4941 * Does a given object (usually) hate electricity?
4943 bool hates_elec(object_type *o_ptr)
4945 switch (o_ptr->tval)
4959 * Does a given object (usually) hate fire?
4960 * Hafted/Polearm weapons have wooden shafts.
4961 * Arrows/Bows are mostly wooden.
4963 bool hates_fire(object_type *o_ptr)
4965 /* Analyze the type */
4966 switch (o_ptr->tval)
4984 case TV_SORCERY_BOOK:
4985 case TV_NATURE_BOOK:
4989 case TV_ARCANE_BOOK:
4990 case TV_ENCHANT_BOOK:
4991 case TV_DAEMON_BOOK:
4992 case TV_CRUSADE_BOOK:
4994 case TV_HISSATSU_BOOK:
5005 /* Staffs/Scrolls burn */
5018 * Does a given object (usually) hate cold?
5020 bool hates_cold(object_type *o_ptr)
5022 switch (o_ptr->tval)
5039 int set_acid_destroy(object_type *o_ptr)
5041 u32b flgs[TR_FLAG_SIZE];
5042 if (!hates_acid(o_ptr)) return (FALSE);
5043 object_flags(o_ptr, flgs);
5044 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
5052 int set_elec_destroy(object_type *o_ptr)
5054 u32b flgs[TR_FLAG_SIZE];
5055 if (!hates_elec(o_ptr)) return (FALSE);
5056 object_flags(o_ptr, flgs);
5057 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
5065 int set_fire_destroy(object_type *o_ptr)
5067 u32b flgs[TR_FLAG_SIZE];
5068 if (!hates_fire(o_ptr)) return (FALSE);
5069 object_flags(o_ptr, flgs);
5070 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
5078 int set_cold_destroy(object_type *o_ptr)
5080 u32b flgs[TR_FLAG_SIZE];
5081 if (!hates_cold(o_ptr)) return (FALSE);
5082 object_flags(o_ptr, flgs);
5083 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
5089 * Destroys a type of item on a given percent chance
5090 * Note that missiles are no longer necessarily all destroyed
5091 * Destruction taken from "melee.c" code for "stealing".
5092 * New-style wands and rods handled correctly. -LM-
5093 * Returns number of items destroyed.
5095 int inven_damage(inven_func typ, int perc)
5099 char o_name[MAX_NLEN];
5101 /* Multishadow effects is determined by turn */
5102 if( p_ptr->multishadow && (turn & 1) )return 0;
5104 if (p_ptr->inside_arena) return 0;
5106 /* Count the casualties */
5109 /* Scan through the slots backwards */
5110 for (i = 0; i < INVEN_PACK; i++)
5112 o_ptr = &inventory[i];
5114 /* Skip non-objects */
5115 if (!o_ptr->k_idx) continue;
5117 /* Hack -- for now, skip artifacts */
5118 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
5120 /* Give this item slot a shot at death */
5123 /* Count the casualties */
5124 for (amt = j = 0; j < o_ptr->number; ++j)
5126 if (randint0(100) < perc) amt++;
5129 /* Some casualities */
5132 /* Get a description */
5133 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5137 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
5139 msg_format("%sour %s (%c) %s destroyed!",
5143 o_name, index_to_label(i),
5144 ((o_ptr->number > 1) ?
5145 ((amt == o_ptr->number) ? "Á´Éô" :
5146 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
5148 ((o_ptr->number > 1) ?
5149 ((amt == o_ptr->number) ? "All of y" :
5150 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
5151 o_name, index_to_label(i),
5152 ((amt > 1) ? "were" : "was"));
5156 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
5157 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
5160 /* Potions smash open */
5161 if (object_is_potion(o_ptr))
5163 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
5166 /* Reduce the charges of rods/wands */
5167 reduce_charges(o_ptr, amt);
5169 /* Destroy "amt" items */
5170 inven_item_increase(i, -amt);
5171 inven_item_optimize(i);
5173 /* Count the casualties */
5179 /* Return the casualty count */
5185 * Acid has hit the player, attempt to affect some armor.
5187 * Note that the "base armor" of an object never changes.
5189 * If any armor is damaged (or resists), the player takes less damage.
5191 static int minus_ac(void)
5193 object_type *o_ptr = NULL;
5194 u32b flgs[TR_FLAG_SIZE];
5195 char o_name[MAX_NLEN];
5198 /* Pick a (possibly empty) inventory slot */
5199 switch (randint1(7))
5201 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5202 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5203 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5204 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5205 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5206 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5207 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5210 /* Nothing to damage */
5211 if (!o_ptr->k_idx) return (FALSE);
5213 if (o_ptr->tval <= TV_WEAPON_END) return (FALSE);
5215 /* No damage left to be done */
5216 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5220 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5222 /* Extract the flags */
5223 object_flags(o_ptr, flgs);
5225 /* Object resists */
5226 if (have_flag(flgs, TR_IGNORE_ACID))
5229 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5231 msg_format("Your %s is unaffected!", o_name);
5240 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5242 msg_format("Your %s is damaged!", o_name);
5246 /* Damage the item */
5249 /* Calculate bonuses */
5250 p_ptr->update |= (PU_BONUS);
5253 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5257 /* Item was damaged */
5263 * Hurt the player with Acid
5265 int acid_dam(int dam, cptr kb_str, int monspell)
5268 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5269 bool double_resist = IS_OPPOSE_ACID();
5271 /* Total Immunity */
5272 if (p_ptr->immune_acid || (dam <= 0))
5274 learn_spell(monspell);
5278 /* Vulnerability (Ouch!) */
5279 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5280 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5282 /* Resist the damage */
5283 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5284 if (double_resist) dam = (dam + 2) / 3;
5286 if ((!(double_resist || p_ptr->resist_acid)) &&
5287 one_in_(HURT_CHANCE))
5288 (void)do_dec_stat(A_CHR);
5290 /* If any armor gets hit, defend the player */
5291 if (minus_ac()) dam = (dam + 1) / 2;
5294 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5296 /* Inventory damage */
5297 if (!(double_resist && p_ptr->resist_acid))
5298 inven_damage(set_acid_destroy, inv);
5304 * Hurt the player with electricity
5306 int elec_dam(int dam, cptr kb_str, int monspell)
5309 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5310 bool double_resist = IS_OPPOSE_ELEC();
5312 /* Total immunity */
5313 if (p_ptr->immune_elec || (dam <= 0))
5315 learn_spell(monspell);
5319 /* Vulnerability (Ouch!) */
5320 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5321 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5322 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5324 /* Resist the damage */
5325 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5326 if (double_resist) dam = (dam + 2) / 3;
5328 if ((!(double_resist || p_ptr->resist_elec)) &&
5329 one_in_(HURT_CHANCE))
5330 (void)do_dec_stat(A_DEX);
5333 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5335 /* Inventory damage */
5336 if (!(double_resist && p_ptr->resist_elec))
5337 inven_damage(set_elec_destroy, inv);
5344 * Hurt the player with Fire
5346 int fire_dam(int dam, cptr kb_str, int monspell)
5349 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5350 bool double_resist = IS_OPPOSE_FIRE();
5352 /* Totally immune */
5353 if (p_ptr->immune_fire || (dam <= 0))
5355 learn_spell(monspell);
5359 /* Vulnerability (Ouch!) */
5360 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5361 if (prace_is_(RACE_ENT)) dam += dam / 3;
5362 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5364 /* Resist the damage */
5365 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5366 if (double_resist) dam = (dam + 2) / 3;
5368 if ((!(double_resist || p_ptr->resist_fire)) &&
5369 one_in_(HURT_CHANCE))
5370 (void)do_dec_stat(A_STR);
5373 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5375 /* Inventory damage */
5376 if (!(double_resist && p_ptr->resist_fire))
5377 inven_damage(set_fire_destroy, inv);
5384 * Hurt the player with Cold
5386 int cold_dam(int dam, cptr kb_str, int monspell)
5389 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5390 bool double_resist = IS_OPPOSE_COLD();
5392 /* Total immunity */
5393 if (p_ptr->immune_cold || (dam <= 0))
5395 learn_spell(monspell);
5399 /* Vulnerability (Ouch!) */
5400 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5401 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5403 /* Resist the damage */
5404 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5405 if (double_resist) dam = (dam + 2) / 3;
5407 if ((!(double_resist || p_ptr->resist_cold)) &&
5408 one_in_(HURT_CHANCE))
5409 (void)do_dec_stat(A_STR);
5412 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5414 /* Inventory damage */
5415 if (!(double_resist && p_ptr->resist_cold))
5416 inven_damage(set_cold_destroy, inv);
5422 bool rustproof(void)
5426 char o_name[MAX_NLEN];
5429 item_tester_no_ryoute = TRUE;
5430 /* Select a piece of armour */
5431 item_tester_hook = item_tester_hook_armour;
5435 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5436 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5438 q = "Rustproof which piece of armour? ";
5439 s = "You have nothing to rustproof.";
5442 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5444 /* Get the item (in the pack) */
5447 o_ptr = &inventory[item];
5450 /* Get the item (on the floor) */
5453 o_ptr = &o_list[0 - item];
5458 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5460 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5462 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5465 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5467 msg_format("%s %s look%s as good as new!",
5468 ((item >= 0) ? "Your" : "The"), o_name,
5469 ((o_ptr->number > 1) ? "" : "s"));
5476 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5478 msg_format("%s %s %s now protected against corrosion.",
5479 ((item >= 0) ? "Your" : "The"), o_name,
5480 ((o_ptr->number > 1) ? "are" : "is"));
5491 * Curse the players armor
5493 bool curse_armor(void)
5498 char o_name[MAX_NLEN];
5501 /* Curse the body armor */
5502 o_ptr = &inventory[INVEN_BODY];
5504 /* Nothing to curse */
5505 if (!o_ptr->k_idx) return (FALSE);
5509 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5511 /* Attempt a saving throw for artifacts */
5512 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5516 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5517 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5519 msg_format("A %s tries to %s, but your %s resists the effects!",
5520 "terrible black aura", "surround your armor", o_name);
5525 /* not artifact or failed save... */
5530 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5532 msg_format("A terrible black aura blasts your %s!", o_name);
5535 chg_virtue(V_ENCHANT, -5);
5537 /* Blast the armor */
5539 o_ptr->name2 = EGO_BLASTED;
5540 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5547 for (i = 0; i < TR_FLAG_SIZE; i++)
5548 o_ptr->art_flags[i] = 0;
5551 o_ptr->curse_flags = TRC_CURSED;
5554 o_ptr->ident |= (IDENT_BROKEN);
5556 /* Recalculate bonuses */
5557 p_ptr->update |= (PU_BONUS);
5559 /* Recalculate mana */
5560 p_ptr->update |= (PU_MANA);
5563 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5571 * Curse the players weapon
5573 bool curse_weapon(bool force, int slot)
5579 char o_name[MAX_NLEN];
5582 /* Curse the weapon */
5583 o_ptr = &inventory[slot];
5585 /* Nothing to curse */
5586 if (!o_ptr->k_idx) return (FALSE);
5590 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5592 /* Attempt a saving throw */
5593 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5597 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5598 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5600 msg_format("A %s tries to %s, but your %s resists the effects!",
5601 "terrible black aura", "surround your weapon", o_name);
5606 /* not artifact or failed save... */
5611 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5613 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5616 chg_virtue(V_ENCHANT, -5);
5618 /* Shatter the weapon */
5620 o_ptr->name2 = EGO_SHATTERED;
5621 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5622 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5628 for (i = 0; i < TR_FLAG_SIZE; i++)
5629 o_ptr->art_flags[i] = 0;
5633 o_ptr->curse_flags = TRC_CURSED;
5636 o_ptr->ident |= (IDENT_BROKEN);
5638 /* Recalculate bonuses */
5639 p_ptr->update |= (PU_BONUS);
5641 /* Recalculate mana */
5642 p_ptr->update |= (PU_MANA);
5645 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5654 * Enchant some bolts
5656 bool brand_bolts(void)
5660 /* Use the first acceptable bolts */
5661 for (i = 0; i < INVEN_PACK; i++)
5663 object_type *o_ptr = &inventory[i];
5665 /* Skip non-bolts */
5666 if (o_ptr->tval != TV_BOLT) continue;
5668 /* Skip artifacts and ego-items */
5669 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5672 /* Skip cursed/broken items */
5673 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5676 if (randint0(100) < 75) continue;
5680 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5682 msg_print("Your bolts are covered in a fiery aura!");
5687 o_ptr->name2 = EGO_FLAME;
5690 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5697 if (flush_failure) flush();
5701 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5703 msg_print("The fiery enchantment failed.");
5713 * Helper function -- return a "nearby" race for polymorphing
5715 * Note that this function is one of the more "dangerous" ones...
5717 static s16b poly_r_idx(int r_idx)
5719 monster_race *r_ptr = &r_info[r_idx];
5721 int i, r, lev1, lev2;
5723 /* Hack -- Uniques/Questors never polymorph */
5724 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5725 (r_ptr->flags1 & RF1_QUESTOR))
5728 /* Allowable range of "levels" for resulting monster */
5729 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5730 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5732 /* Pick a (possibly new) non-unique race */
5733 for (i = 0; i < 1000; i++)
5735 /* Pick a new race, using a level calculation */
5736 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5738 /* Handle failure */
5744 /* Ignore unique monsters */
5745 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5747 /* Ignore monsters with incompatible levels */
5748 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5750 /* Use that index */
5762 bool polymorph_monster(int y, int x)
5764 cave_type *c_ptr = &cave[y][x];
5765 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5766 bool polymorphed = FALSE;
5768 int old_r_idx = m_ptr->r_idx;
5769 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5770 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5771 monster_type back_m;
5773 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5775 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5777 /* Memorize the monster before polymorphing */
5780 /* Pick a "new" monster race */
5781 new_r_idx = poly_r_idx(old_r_idx);
5783 /* Handle polymorph */
5784 if (new_r_idx != old_r_idx)
5788 /* Get the monsters attitude */
5789 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5790 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5791 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5793 /* "Kill" the "old" monster */
5794 delete_monster_idx(c_ptr->m_idx);
5796 /* Create a new monster (no groups) */
5797 if (place_monster_aux(0, y, x, new_r_idx, mode))
5804 /* Placing the new monster failed */
5805 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5806 m_list[hack_m_idx_ii] = back_m;
5809 if (targeted) target_who = hack_m_idx_ii;
5810 if (health_tracked) health_track(hack_m_idx_ii);
5820 static bool dimension_door_aux(int x, int y)
5822 int plev = p_ptr->lev;
5824 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5826 if (!cave_teleportable_bold(y, x) ||
5827 (distance(y, x, py, px) > plev / 2 + 10) ||
5828 (!randint0(plev / 10 + 10)))
5830 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5831 teleport_player((plev+2)*2);
5838 teleport_player_to(y, x, TRUE);
5849 bool dimension_door(void)
5853 /* Rerutn FALSE if cancelled */
5854 if (!tgt_pt(&x, &y)) return FALSE;
5856 if (dimension_door_aux(x, y)) return TRUE;
5859 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5861 msg_print("You fail to exit the astral plane correctly!");
5869 * Mirror Master's Dimension Door
5871 bool mirror_tunnel(void)
5875 /* Rerutn FALSE if cancelled */
5876 if (!tgt_pt(&x, &y)) return FALSE;
5878 if (dimension_door_aux(x, y)) return TRUE;
5881 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5883 msg_print("You fail to pass the mirror plane correctly!");
5890 bool eat_magic(int power)
5892 object_type * o_ptr;
5895 int recharge_strength = 0;
5901 char o_name[MAX_NLEN];
5903 item_tester_hook = item_tester_hook_recharge;
5907 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5908 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5910 q = "Drain which item? ";
5911 s = "You have nothing to drain.";
5914 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5918 o_ptr = &inventory[item];
5922 o_ptr = &o_list[0 - item];
5925 k_ptr = &k_info[o_ptr->k_idx];
5926 lev = get_object_level(o_ptr);
5928 if (o_ptr->tval == TV_ROD)
5930 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5933 if (one_in_(recharge_strength))
5935 /* Activate the failure code. */
5940 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5943 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5945 msg_print("You can't absorb energy from a discharged rod.");
5952 o_ptr->timeout += k_ptr->pval;
5958 /* All staffs, wands. */
5959 recharge_strength = (100 + power - lev) / 15;
5962 if (recharge_strength < 0) recharge_strength = 0;
5965 if (one_in_(recharge_strength))
5967 /* Activate the failure code. */
5972 if (o_ptr->pval > 0)
5974 p_ptr->csp += lev / 2;
5977 /* XXX Hack -- unstack if necessary */
5978 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5983 /* Get local object */
5986 /* Obtain a local object */
5987 object_copy(q_ptr, o_ptr);
5989 /* Modify quantity */
5992 /* Restore the charges */
5995 /* Unstack the used item */
5997 p_ptr->total_weight -= q_ptr->weight;
5998 item = inven_carry(q_ptr);
6002 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
6004 msg_print("You unstack your staff.");
6012 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
6014 msg_print("There's no energy there to absorb!");
6018 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
6022 /* Inflict the penalties for failing a recharge. */
6025 /* Artifacts are never destroyed. */
6026 if (artifact_p(o_ptr))
6028 object_desc(o_name, o_ptr, OD_NAME_ONLY);
6030 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
6032 msg_format("The recharging backfires - %s is completely drained!", o_name);
6036 /* Artifact rods. */
6037 if (o_ptr->tval == TV_ROD)
6038 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6040 /* Artifact wands and staffs. */
6041 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
6046 /* Get the object description */
6047 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
6049 /*** Determine Seriousness of Failure ***/
6051 /* Mages recharge objects more safely. */
6052 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)
6054 /* 10% chance to blow up one rod, otherwise draining. */
6055 if (o_ptr->tval == TV_ROD)
6057 if (one_in_(10)) fail_type = 2;
6060 /* 75% chance to blow up one wand, otherwise draining. */
6061 else if (o_ptr->tval == TV_WAND)
6063 if (!one_in_(3)) fail_type = 2;
6066 /* 50% chance to blow up one staff, otherwise no effect. */
6067 else if (o_ptr->tval == TV_STAFF)
6069 if (one_in_(2)) fail_type = 2;
6074 /* All other classes get no special favors. */
6077 /* 33% chance to blow up one rod, otherwise draining. */
6078 if (o_ptr->tval == TV_ROD)
6080 if (one_in_(3)) fail_type = 2;
6083 /* 20% chance of the entire stack, else destroy one wand. */
6084 else if (o_ptr->tval == TV_WAND)
6086 if (one_in_(5)) fail_type = 3;
6089 /* Blow up one staff. */
6090 else if (o_ptr->tval == TV_STAFF)
6096 /*** Apply draining and destruction. ***/
6098 /* Drain object or stack of objects. */
6101 if (o_ptr->tval == TV_ROD)
6104 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
6106 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
6109 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6111 else if (o_ptr->tval == TV_WAND)
6114 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
6116 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
6121 /* Staffs aren't drained. */
6124 /* Destroy an object or one in a stack of objects. */
6127 if (o_ptr->number > 1)
6130 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
6132 msg_format("Wild magic consumes one of your %s!", o_name);
6135 /* Reduce rod stack maximum timeout, drain wands. */
6136 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
6137 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
6142 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
6144 msg_format("Wild magic consumes your %s!", o_name);
6147 /* Reduce and describe inventory */
6150 inven_item_increase(item, -1);
6151 inven_item_describe(item);
6152 inven_item_optimize(item);
6155 /* Reduce and describe floor item */
6158 floor_item_increase(0 - item, -1);
6159 floor_item_describe(0 - item);
6160 floor_item_optimize(0 - item);
6164 /* Destroy all members of a stack of objects. */
6167 if (o_ptr->number > 1)
6169 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
6171 msg_format("Wild magic consumes all your %s!", o_name);
6176 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
6178 msg_format("Wild magic consumes your %s!", o_name);
6183 /* Reduce and describe inventory */
6186 inven_item_increase(item, -999);
6187 inven_item_describe(item);
6188 inven_item_optimize(item);
6191 /* Reduce and describe floor item */
6194 floor_item_increase(0 - item, -999);
6195 floor_item_describe(0 - item);
6196 floor_item_optimize(0 - item);
6202 if (p_ptr->csp > p_ptr->msp)
6204 p_ptr->csp = p_ptr->msp;
6207 /* Redraw mana and hp */
6208 p_ptr->redraw |= (PR_MANA);
6210 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6211 p_ptr->window |= (PW_INVEN);
6217 bool summon_kin_player(int level, int y, int x, u32b mode)
6219 bool pet = (bool)(mode & PM_FORCE_PET);
6220 if (!pet) mode |= PM_NO_PET;
6222 switch (p_ptr->mimic_form)
6225 switch (p_ptr->prace)
6229 case RACE_BARBARIAN:
6232 summon_kin_type = 'p';
6242 case RACE_MIND_FLAYER:
6245 summon_kin_type = 'h';
6248 summon_kin_type = 'o';
6250 case RACE_HALF_TROLL:
6251 summon_kin_type = 'T';
6253 case RACE_HALF_OGRE:
6254 summon_kin_type = 'O';
6256 case RACE_HALF_GIANT:
6257 case RACE_HALF_TITAN:
6259 summon_kin_type = 'P';
6262 summon_kin_type = 'y';
6265 summon_kin_type = 'K';
6268 summon_kin_type = 'k';
6271 if (one_in_(13)) summon_kin_type = 'U';
6272 else summon_kin_type = 'u';
6274 case RACE_DRACONIAN:
6275 summon_kin_type = 'd';
6279 summon_kin_type = 'g';
6282 if (one_in_(13)) summon_kin_type = 'L';
6283 else summon_kin_type = 's';
6286 summon_kin_type = 'z';
6289 summon_kin_type = 'V';
6292 summon_kin_type = 'G';
6295 summon_kin_type = 'I';
6298 summon_kin_type = '#';
6301 summon_kin_type = 'A';
6304 summon_kin_type = 'U';
6307 summon_kin_type = 'p';
6312 if (one_in_(13)) summon_kin_type = 'U';
6313 else summon_kin_type = 'u';
6315 case MIMIC_DEMON_LORD:
6316 summon_kin_type = 'U';
6319 summon_kin_type = 'V';
6322 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);