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;
1948 update_local_illumination(py, px);
1955 * Leave an "explosive rune" which prevents monster movement
1957 bool explosive_rune(void)
1960 if (!cave_clean_bold(py, px))
1963 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1965 msg_print("The object resists the spell.");
1971 /* Create a glyph */
1972 cave[py][px].info |= CAVE_OBJECT;
1973 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1986 * Identify everything being carried.
1987 * Done by a potion of "self knowledge".
1989 void identify_pack(void)
1993 /* Simply identify and know every item */
1994 for (i = 0; i < INVEN_TOTAL; i++)
1996 object_type *o_ptr = &inventory[i];
1998 /* Skip non-objects */
1999 if (!o_ptr->k_idx) continue;
2002 identify_item(o_ptr);
2004 /* Auto-inscription */
2005 autopick_alter_item(i, FALSE);
2011 * Used by the "enchant" function (chance of failure)
2012 * (modified for Zangband, we need better stuff there...) -- TY
2014 static int enchant_table[16] =
2016 0, 10, 50, 100, 200,
2017 300, 400, 500, 650, 800,
2018 950, 987, 993, 995, 998,
2024 * Removes curses from items in inventory
2026 * Note that Items which are "Perma-Cursed" (The One Ring,
2027 * The Crown of Morgoth) can NEVER be uncursed.
2029 * Note that if "all" is FALSE, then Items which are
2030 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2031 * will not be uncursed.
2033 static int remove_curse_aux(int all)
2037 /* Attempt to uncurse items being worn */
2038 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2040 object_type *o_ptr = &inventory[i];
2042 /* Skip non-objects */
2043 if (!o_ptr->k_idx) continue;
2045 /* Uncursed already */
2046 if (!cursed_p(o_ptr)) continue;
2048 /* Heavily Cursed Items need a special spell */
2049 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2051 /* Perma-Cursed Items can NEVER be uncursed */
2052 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2055 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2060 o_ptr->curse_flags = 0L;
2062 /* Hack -- Assume felt */
2063 o_ptr->ident |= (IDENT_SENSE);
2066 o_ptr->feeling = FEEL_NONE;
2068 /* Recalculate the bonuses */
2069 p_ptr->update |= (PU_BONUS);
2072 p_ptr->window |= (PW_EQUIP);
2074 /* Count the uncursings */
2078 /* Return "something uncursed" */
2084 * Remove most curses
2086 bool remove_curse(void)
2088 return (remove_curse_aux(FALSE));
2094 bool remove_all_curse(void)
2096 return (remove_curse_aux(TRUE));
2101 * Turns an object into gold, gain some of its value in a shop
2110 char o_name[MAX_NLEN];
2111 char out_val[MAX_NLEN+40];
2115 /* Hack -- force destruction */
2116 if (command_arg > 0) force = TRUE;
2120 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2121 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2123 q = "Turn which item to gold? ";
2124 s = "You have nothing to turn to gold.";
2127 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2129 /* Get the item (in the pack) */
2132 o_ptr = &inventory[item];
2135 /* Get the item (on the floor) */
2138 o_ptr = &o_list[0 - item];
2142 /* See how many items */
2143 if (o_ptr->number > 1)
2145 /* Get a quantity */
2146 amt = get_quantity(NULL, o_ptr->number);
2148 /* Allow user abort */
2149 if (amt <= 0) return FALSE;
2153 /* Describe the object */
2154 old_number = o_ptr->number;
2155 o_ptr->number = amt;
2156 object_desc(o_name, o_ptr, 0);
2157 o_ptr->number = old_number;
2159 /* Verify unless quantity given */
2162 if (confirm_destroy || (object_value(o_ptr) > 0))
2164 /* Make a verification */
2166 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2168 sprintf(out_val, "Really turn %s to gold? ", o_name);
2171 if (!get_check(out_val)) return FALSE;
2175 /* Artifacts cannot be destroyed */
2176 if (!can_player_destroy_object(o_ptr))
2180 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2182 msg_format("You fail to turn %s to gold!", o_name);
2189 price = object_value_real(o_ptr);
2195 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2197 msg_format("You turn %s to fool's gold.", o_name);
2205 if (amt > 1) price *= amt;
2207 if (price > 30000) price = 30000;
2209 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2211 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2217 p_ptr->redraw |= (PR_GOLD);
2220 p_ptr->window |= (PW_PLAYER);
2224 /* Eliminate the item (from the pack) */
2227 inven_item_increase(item, -amt);
2228 inven_item_describe(item);
2229 inven_item_optimize(item);
2232 /* Eliminate the item (from the floor) */
2235 floor_item_increase(0 - item, -amt);
2236 floor_item_describe(0 - item);
2237 floor_item_optimize(0 - item);
2246 * Hook to specify "weapon"
2248 bool item_tester_hook_weapon(object_type *o_ptr)
2250 switch (o_ptr->tval)
2264 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2271 static bool item_tester_hook_weapon2(object_type *o_ptr)
2273 switch (o_ptr->tval)
2293 * Hook to specify "armour"
2295 bool item_tester_hook_armour(object_type *o_ptr)
2297 switch (o_ptr->tval)
2318 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2320 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2322 switch (o_ptr->tval)
2351 * Check if an object is nameless weapon or armour
2353 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2355 switch (o_ptr->tval)
2374 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2376 if (object_known_p(o_ptr)) return FALSE;
2386 * Break the curse of an item
2388 static void break_curse(object_type *o_ptr)
2390 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2393 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2395 msg_print("The curse is broken!");
2398 o_ptr->curse_flags = 0L;
2400 o_ptr->ident |= (IDENT_SENSE);
2402 o_ptr->feeling = FEEL_NONE;
2408 * Enchants a plus onto an item. -RAK-
2410 * Revamped! Now takes item pointer, number of times to try enchanting,
2411 * and a flag of what to try enchanting. Artifacts resist enchantment
2412 * some of the time, and successful enchantment to at least +0 might
2413 * break a curse on the item. -CFT-
2415 * Note that an item can technically be enchanted all the way to +15 if
2416 * you wait a very, very, long time. Going from +9 to +10 only works
2417 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2419 * Note that this function can now be used on "piles" of items, and
2420 * the larger the pile, the lower the chance of success.
2422 bool enchant(object_type *o_ptr, int n, int eflag)
2424 int i, chance, prob;
2426 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2427 bool force = (eflag & ENCH_FORCE);
2430 /* Large piles resist enchantment */
2431 prob = o_ptr->number * 100;
2433 /* Missiles are easy to enchant */
2434 if ((o_ptr->tval == TV_BOLT) ||
2435 (o_ptr->tval == TV_ARROW) ||
2436 (o_ptr->tval == TV_SHOT))
2442 for (i = 0; i < n; i++)
2444 /* Hack -- Roll for pile resistance */
2445 if (!force && randint0(prob) >= 100) continue;
2447 /* Enchant to hit */
2448 if (eflag & ENCH_TOHIT)
2450 if (o_ptr->to_h < 0) chance = 0;
2451 else if (o_ptr->to_h > 15) chance = 1000;
2452 else chance = enchant_table[o_ptr->to_h];
2454 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2459 /* only when you get it above -1 -CFT */
2460 if (o_ptr->to_h >= 0)
2465 /* Enchant to damage */
2466 if (eflag & ENCH_TODAM)
2468 if (o_ptr->to_d < 0) chance = 0;
2469 else if (o_ptr->to_d > 15) chance = 1000;
2470 else chance = enchant_table[o_ptr->to_d];
2472 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2477 /* only when you get it above -1 -CFT */
2478 if (o_ptr->to_d >= 0)
2483 /* Enchant to armor class */
2484 if (eflag & ENCH_TOAC)
2486 if (o_ptr->to_a < 0) chance = 0;
2487 else if (o_ptr->to_a > 15) chance = 1000;
2488 else chance = enchant_table[o_ptr->to_a];
2490 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2495 /* only when you get it above -1 -CFT */
2496 if (o_ptr->to_a >= 0)
2503 if (!res) return (FALSE);
2505 /* Recalculate bonuses */
2506 p_ptr->update |= (PU_BONUS);
2508 /* Combine / Reorder the pack (later) */
2509 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2512 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2523 * Enchant an item (in the inventory or on the floor)
2524 * Note that "num_ac" requires armour, else weapon
2525 * Returns TRUE if attempted, FALSE if cancelled
2527 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2532 char o_name[MAX_NLEN];
2536 /* Assume enchant weapon */
2537 item_tester_hook = item_tester_hook_weapon;
2538 item_tester_no_ryoute = TRUE;
2540 /* Enchant armor if requested */
2541 if (num_ac) item_tester_hook = item_tester_hook_armour;
2545 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2546 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2548 q = "Enchant which item? ";
2549 s = "You have nothing to enchant.";
2552 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2554 /* Get the item (in the pack) */
2557 o_ptr = &inventory[item];
2560 /* Get the item (on the floor) */
2563 o_ptr = &o_list[0 - item];
2568 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2572 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2575 msg_format("%s %s glow%s brightly!",
2576 ((item >= 0) ? "Your" : "The"), o_name,
2577 ((o_ptr->number > 1) ? "" : "s"));
2582 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2583 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2584 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2590 if (flush_failure) flush();
2594 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2596 msg_print("The enchantment failed.");
2599 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2602 chg_virtue(V_ENCHANT, 1);
2606 /* Something happened */
2611 bool artifact_scroll(void)
2616 char o_name[MAX_NLEN];
2620 item_tester_no_ryoute = TRUE;
2621 /* Enchant weapon/armour */
2622 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2626 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2627 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2629 q = "Enchant which item? ";
2630 s = "You have nothing to enchant.";
2633 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2635 /* Get the item (in the pack) */
2638 o_ptr = &inventory[item];
2641 /* Get the item (on the floor) */
2644 o_ptr = &o_list[0 - item];
2649 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2653 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2655 msg_format("%s %s radiate%s a blinding light!",
2656 ((item >= 0) ? "Your" : "The"), o_name,
2657 ((o_ptr->number > 1) ? "" : "s"));
2660 if (o_ptr->name1 || o_ptr->art_name)
2663 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2665 msg_format("The %s %s already %s!",
2666 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2667 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2673 else if (o_ptr->name2)
2676 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2678 msg_format("The %s %s already %s!",
2679 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2680 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2686 else if (o_ptr->xtra3)
2689 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2691 msg_format("The %s %s already %s!",
2692 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2693 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2699 if (o_ptr->number > 1)
2702 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2703 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2705 msg_print("Not enough enough energy to enchant more than one object!");
2706 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2711 inven_item_increase(item, 1-(o_ptr->number));
2715 floor_item_increase(0-item, 1-(o_ptr->number));
2718 okay = create_artifact(o_ptr, TRUE);
2725 if (flush_failure) flush();
2729 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2731 msg_print("The enchantment failed.");
2734 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2737 chg_virtue(V_ENCHANT, 1);
2741 /* Something happened */
2747 * Identify an object
2749 bool identify_item(object_type *o_ptr)
2751 bool old_known = FALSE;
2752 char o_name[MAX_NLEN];
2755 object_desc(o_name, o_ptr, 0);
2757 if (o_ptr->ident & IDENT_KNOWN)
2760 if (!(o_ptr->ident & (IDENT_MENTAL)))
2762 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2763 chg_virtue(V_KNOWLEDGE, 1);
2766 /* Identify it fully */
2767 object_aware(o_ptr);
2768 object_known(o_ptr);
2770 /* Recalculate bonuses */
2771 p_ptr->update |= (PU_BONUS);
2773 /* Combine / Reorder the pack (later) */
2774 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2777 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2779 strcpy(record_o_name, o_name);
2783 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2785 if(record_fix_art && !old_known && artifact_p(o_ptr))
2786 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2787 if(record_rand_art && !old_known && o_ptr->art_name)
2788 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2794 static bool item_tester_hook_identify(object_type *o_ptr)
2796 return (bool)!object_known_p(o_ptr);
2799 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2801 if (object_known_p(o_ptr))
2803 return item_tester_hook_weapon_armour(o_ptr);
2807 * Identify an object in the inventory (or on the floor)
2808 * This routine does *not* automatically combine objects.
2809 * Returns TRUE if something was identified, else FALSE.
2811 bool ident_spell(bool only_equip)
2815 char o_name[MAX_NLEN];
2819 item_tester_no_ryoute = TRUE;
2822 item_tester_hook = item_tester_hook_identify_weapon_armour;
2824 item_tester_hook = item_tester_hook_identify;
2826 if (!can_get_item())
2830 item_tester_hook = item_tester_hook_weapon_armour;
2834 item_tester_hook = NULL;
2840 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2841 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2843 q = "Identify which item? ";
2844 s = "You have nothing to identify.";
2847 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2849 /* Get the item (in the pack) */
2852 o_ptr = &inventory[item];
2855 /* Get the item (on the floor) */
2858 o_ptr = &o_list[0 - item];
2862 old_known = identify_item(o_ptr);
2865 object_desc(o_name, o_ptr, 0);
2868 if (item >= INVEN_RARM)
2871 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2873 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2879 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2881 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2887 msg_format("¾²¾å: %s¡£", o_name);
2889 msg_format("On the ground: %s.", o_name);
2893 /* Auto-inscription/destroy */
2894 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2896 /* Something happened */
2902 * Mundanify an object in the inventory (or on the floor)
2903 * This routine does *not* automatically combine objects.
2904 * Returns TRUE if something was mundanified, else FALSE.
2906 bool mundane_spell(bool only_equip)
2912 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
2913 item_tester_no_ryoute = TRUE;
2917 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2918 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2920 q = "Use which item? ";
2921 s = "You have nothing you can use.";
2924 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2926 /* Get the item (in the pack) */
2929 o_ptr = &inventory[item];
2932 /* Get the item (on the floor) */
2935 o_ptr = &o_list[0 - item];
2940 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2942 msg_print("There is a bright flash of light!");
2945 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2946 byte ix = o_ptr->ix; /* X-position on map, or zero */
2947 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2948 byte marked = o_ptr->marked; /* Object is marked */
2949 s16b weight = o_ptr->number * o_ptr->weight;
2950 u16b inscription = o_ptr->inscription;
2953 object_prep(o_ptr, o_ptr->k_idx);
2957 o_ptr->next_o_idx = next_o_idx;
2958 o_ptr->marked = marked;
2959 o_ptr->inscription = inscription;
2960 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2964 /* Something happened */
2970 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2972 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2975 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2977 if (!item_tester_hook_identify_fully(o_ptr))
2979 return item_tester_hook_weapon_armour(o_ptr);
2983 * Fully "identify" an object in the inventory -BEN-
2984 * This routine returns TRUE if an item was identified.
2986 bool identify_fully(bool only_equip)
2990 char o_name[MAX_NLEN];
2994 item_tester_no_ryoute = TRUE;
2996 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2998 item_tester_hook = item_tester_hook_identify_fully;
3000 if (!can_get_item())
3003 item_tester_hook = item_tester_hook_weapon_armour;
3005 item_tester_hook = NULL;
3010 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
3011 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3013 q = "Identify which item? ";
3014 s = "You have nothing to identify.";
3017 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
3019 /* Get the item (in the pack) */
3022 o_ptr = &inventory[item];
3025 /* Get the item (on the floor) */
3028 o_ptr = &o_list[0 - item];
3032 old_known = identify_item(o_ptr);
3034 /* Mark the item as fully known */
3035 o_ptr->ident |= (IDENT_MENTAL);
3041 object_desc(o_name, o_ptr, 0);
3044 if (item >= INVEN_RARM)
3047 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
3049 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
3057 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
3059 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3065 msg_format("¾²¾å: %s¡£", o_name);
3067 msg_format("On the ground: %s.", o_name);
3071 /* Describe it fully */
3072 (void)screen_object(o_ptr, TRUE);
3074 /* Auto-inscription/destroy */
3075 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
3085 * Hook for "get_item()". Determine if something is rechargable.
3087 bool item_tester_hook_recharge(object_type *o_ptr)
3089 /* Recharge staffs */
3090 if (o_ptr->tval == TV_STAFF) return (TRUE);
3092 /* Recharge wands */
3093 if (o_ptr->tval == TV_WAND) return (TRUE);
3095 /* Hack -- Recharge rods */
3096 if (o_ptr->tval == TV_ROD) return (TRUE);
3104 * Recharge a wand/staff/rod from the pack or on the floor.
3105 * This function has been rewritten in Oangband and ZAngband.
3107 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3108 * Chaos -- Arcane Binding --> recharge(90)
3110 * Scroll of recharging --> recharge(130)
3111 * Artifact activation/Thingol --> recharge(130)
3113 * It is harder to recharge high level, and highly charged wands,
3114 * staffs, and rods. The more wands in a stack, the more easily and
3115 * strongly they recharge. Staffs, however, each get fewer charges if
3118 * XXX XXX XXX Beware of "sliding index errors".
3120 bool recharge(int power)
3123 int recharge_strength, recharge_amount;
3132 char o_name[MAX_NLEN];
3134 /* Only accept legal items */
3135 item_tester_hook = item_tester_hook_recharge;
3139 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3140 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3142 q = "Recharge which item? ";
3143 s = "You have nothing to recharge.";
3146 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3148 /* Get the item (in the pack) */
3151 o_ptr = &inventory[item];
3154 /* Get the item (on the floor) */
3157 o_ptr = &o_list[0 - item];
3160 /* Get the object kind. */
3161 k_ptr = &k_info[o_ptr->k_idx];
3163 /* Extract the object "level" */
3164 lev = get_object_level(o_ptr);
3167 /* Recharge a rod */
3168 if (o_ptr->tval == TV_ROD)
3170 /* Extract a recharge strength by comparing object level to power. */
3171 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3175 if (one_in_(recharge_strength))
3177 /* Activate the failure code. */
3184 /* Recharge amount */
3185 recharge_amount = (power * damroll(3, 2));
3187 /* Recharge by that amount */
3188 if (o_ptr->timeout > recharge_amount)
3189 o_ptr->timeout -= recharge_amount;
3196 /* Recharge wand/staff */
3199 /* Extract a recharge strength by comparing object level to power.
3200 * Divide up a stack of wands' charges to calculate charge penalty.
3202 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3203 recharge_strength = (100 + power - lev -
3204 (8 * o_ptr->pval / o_ptr->number)) / 15;
3206 /* All staffs, unstacked wands. */
3207 else recharge_strength = (100 + power - lev -
3208 (8 * o_ptr->pval)) / 15;
3211 if (recharge_strength < 0) recharge_strength = 0;
3214 if (one_in_(recharge_strength))
3216 /* Activate the failure code. */
3220 /* If the spell didn't backfire, recharge the wand or staff. */
3223 /* Recharge based on the standard number of charges. */
3224 recharge_amount = randint1(1 + k_ptr->pval / 2);
3226 /* Multiple wands in a stack increase recharging somewhat. */
3227 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3230 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3231 if (recharge_amount < 1) recharge_amount = 1;
3232 if (recharge_amount > 12) recharge_amount = 12;
3235 /* But each staff in a stack gets fewer additional charges,
3236 * although always at least one.
3238 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3240 recharge_amount /= o_ptr->number;
3241 if (recharge_amount < 1) recharge_amount = 1;
3244 /* Recharge the wand or staff. */
3245 o_ptr->pval += recharge_amount;
3248 /* Hack -- we no longer "know" the item */
3249 o_ptr->ident &= ~(IDENT_KNOWN);
3251 /* Hack -- we no longer think the item is empty */
3252 o_ptr->ident &= ~(IDENT_EMPTY);
3257 /* Inflict the penalties for failing a recharge. */
3260 /* Artifacts are never destroyed. */
3261 if (artifact_p(o_ptr))
3263 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3265 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3267 msg_format("The recharging backfires - %s is completely drained!", o_name);
3271 /* Artifact rods. */
3272 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3273 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3275 /* Artifact wands and staffs. */
3276 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3281 /* Get the object description */
3282 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3284 /*** Determine Seriousness of Failure ***/
3286 /* Mages recharge objects more safely. */
3287 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)
3289 /* 10% chance to blow up one rod, otherwise draining. */
3290 if (o_ptr->tval == TV_ROD)
3292 if (one_in_(10)) fail_type = 2;
3295 /* 75% chance to blow up one wand, otherwise draining. */
3296 else if (o_ptr->tval == TV_WAND)
3298 if (!one_in_(3)) fail_type = 2;
3301 /* 50% chance to blow up one staff, otherwise no effect. */
3302 else if (o_ptr->tval == TV_STAFF)
3304 if (one_in_(2)) fail_type = 2;
3309 /* All other classes get no special favors. */
3312 /* 33% chance to blow up one rod, otherwise draining. */
3313 if (o_ptr->tval == TV_ROD)
3315 if (one_in_(3)) fail_type = 2;
3318 /* 20% chance of the entire stack, else destroy one wand. */
3319 else if (o_ptr->tval == TV_WAND)
3321 if (one_in_(5)) fail_type = 3;
3324 /* Blow up one staff. */
3325 else if (o_ptr->tval == TV_STAFF)
3331 /*** Apply draining and destruction. ***/
3333 /* Drain object or stack of objects. */
3336 if (o_ptr->tval == TV_ROD)
3339 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3341 msg_print("The recharge backfires, draining the rod further!");
3344 if (o_ptr->timeout < 10000)
3345 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3347 else if (o_ptr->tval == TV_WAND)
3350 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3352 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3357 /* Staffs aren't drained. */
3360 /* Destroy an object or one in a stack of objects. */
3363 if (o_ptr->number > 1)
3365 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3367 msg_format("Wild magic consumes one of your %s!", o_name);
3372 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3374 msg_format("Wild magic consumes your %s!", o_name);
3378 /* Reduce rod stack maximum timeout, drain wands. */
3379 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3380 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3382 /* Reduce and describe inventory */
3385 inven_item_increase(item, -1);
3386 inven_item_describe(item);
3387 inven_item_optimize(item);
3390 /* Reduce and describe floor item */
3393 floor_item_increase(0 - item, -1);
3394 floor_item_describe(0 - item);
3395 floor_item_optimize(0 - item);
3399 /* Destroy all members of a stack of objects. */
3402 if (o_ptr->number > 1)
3404 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3406 msg_format("Wild magic consumes all your %s!", o_name);
3411 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3413 msg_format("Wild magic consumes your %s!", o_name);
3418 /* Reduce and describe inventory */
3421 inven_item_increase(item, -999);
3422 inven_item_describe(item);
3423 inven_item_optimize(item);
3426 /* Reduce and describe floor item */
3429 floor_item_increase(0 - item, -999);
3430 floor_item_describe(0 - item);
3431 floor_item_optimize(0 - item);
3437 /* Combine / Reorder the pack (later) */
3438 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3441 p_ptr->window |= (PW_INVEN);
3443 /* Something was done */
3451 bool bless_weapon(void)
3455 u32b flgs[TR_FLAG_SIZE];
3456 char o_name[MAX_NLEN];
3459 item_tester_no_ryoute = TRUE;
3460 /* Assume enchant weapon */
3461 item_tester_hook = item_tester_hook_weapon2;
3465 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3466 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3468 q = "Bless which weapon? ";
3469 s = "You have weapon to bless.";
3472 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3475 /* Get the item (in the pack) */
3478 o_ptr = &inventory[item];
3481 /* Get the item (on the floor) */
3484 o_ptr = &o_list[0 - item];
3489 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3491 /* Extract the flags */
3492 object_flags(o_ptr, flgs);
3494 if (cursed_p(o_ptr))
3496 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3497 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3500 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3503 msg_format("The black aura on %s %s disrupts the blessing!",
3504 ((item >= 0) ? "your" : "the"), o_name);
3511 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3514 msg_format("A malignant aura leaves %s %s.",
3515 ((item >= 0) ? "your" : "the"), o_name);
3520 o_ptr->curse_flags = 0L;
3522 /* Hack -- Assume felt */
3523 o_ptr->ident |= (IDENT_SENSE);
3526 o_ptr->feeling = FEEL_NONE;
3528 /* Recalculate the bonuses */
3529 p_ptr->update |= (PU_BONUS);
3532 p_ptr->window |= (PW_EQUIP);
3536 * Next, we try to bless it. Artifacts have a 1/3 chance of
3537 * being blessed, otherwise, the operation simply disenchants
3538 * them, godly power negating the magic. Ok, the explanation
3539 * is silly, but otherwise priests would always bless every
3540 * artifact weapon they find. Ego weapons and normal weapons
3541 * can be blessed automatically.
3543 if (have_flag(flgs, TR_BLESSED))
3546 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3549 msg_format("%s %s %s blessed already.",
3550 ((item >= 0) ? "Your" : "The"), o_name,
3551 ((o_ptr->number > 1) ? "were" : "was"));
3557 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3561 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3564 msg_format("%s %s shine%s!",
3565 ((item >= 0) ? "Your" : "The"), o_name,
3566 ((o_ptr->number > 1) ? "" : "s"));
3569 add_flag(o_ptr->art_flags, TR_BLESSED);
3570 o_ptr->discount = 99;
3574 bool dis_happened = FALSE;
3577 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3579 msg_print("The weapon resists your blessing!");
3583 /* Disenchant tohit */
3584 if (o_ptr->to_h > 0)
3587 dis_happened = TRUE;
3590 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3592 /* Disenchant todam */
3593 if (o_ptr->to_d > 0)
3596 dis_happened = TRUE;
3599 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3601 /* Disenchant toac */
3602 if (o_ptr->to_a > 0)
3605 dis_happened = TRUE;
3608 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3613 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3615 msg_print("There is a static feeling in the air...");
3619 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3622 msg_format("%s %s %s disenchanted!",
3623 ((item >= 0) ? "Your" : "The"), o_name,
3624 ((o_ptr->number > 1) ? "were" : "was"));
3630 /* Recalculate bonuses */
3631 p_ptr->update |= (PU_BONUS);
3634 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3645 bool pulish_shield(void)
3649 u32b flgs[TR_FLAG_SIZE];
3650 char o_name[MAX_NLEN];
3653 item_tester_no_ryoute = TRUE;
3654 /* Assume enchant weapon */
3655 item_tester_tval = TV_SHIELD;
3659 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3660 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3662 q = "Pulish which weapon? ";
3663 s = "You have weapon to pulish.";
3666 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3669 /* Get the item (in the pack) */
3672 o_ptr = &inventory[item];
3675 /* Get the item (on the floor) */
3678 o_ptr = &o_list[0 - item];
3683 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3685 /* Extract the flags */
3686 object_flags(o_ptr, flgs);
3688 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3689 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3692 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3694 msg_format("%s %s shine%s!",
3695 ((item >= 0) ? "Your" : "The"), o_name,
3696 ((o_ptr->number > 1) ? "" : "s"));
3698 o_ptr->name2 = EGO_REFLECTION;
3699 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3701 o_ptr->discount = 99;
3702 chg_virtue(V_ENCHANT, 2);
3708 if (flush_failure) flush();
3711 msg_print("¼ºÇÔ¤·¤¿¡£");
3713 msg_print("Failed.");
3716 chg_virtue(V_ENCHANT, -2);
3725 * Potions "smash open" and cause an area effect when
3726 * (1) they are shattered while in the player's inventory,
3727 * due to cold (etc) attacks;
3728 * (2) they are thrown at a monster, or obstacle;
3729 * (3) they are shattered by a "cold ball" or other such spell
3730 * while lying on the floor.
3733 * who --- who caused the potion to shatter (0=player)
3734 * potions that smash on the floor are assumed to
3735 * be caused by no-one (who = 1), as are those that
3736 * shatter inside the player inventory.
3737 * (Not anymore -- I changed this; TY)
3738 * y, x --- coordinates of the potion (or player if
3739 * the potion was in her inventory);
3740 * o_ptr --- pointer to the potion object.
3742 bool potion_smash_effect(int who, int y, int x, int k_idx)
3749 object_kind *k_ptr = &k_info[k_idx];
3751 switch (k_ptr->sval)
3753 case SV_POTION_SALT_WATER:
3754 case SV_POTION_SLIME_MOLD:
3755 case SV_POTION_LOSE_MEMORIES:
3756 case SV_POTION_DEC_STR:
3757 case SV_POTION_DEC_INT:
3758 case SV_POTION_DEC_WIS:
3759 case SV_POTION_DEC_DEX:
3760 case SV_POTION_DEC_CON:
3761 case SV_POTION_DEC_CHR:
3762 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3763 case SV_POTION_APPLE_JUICE:
3766 case SV_POTION_INFRAVISION:
3767 case SV_POTION_DETECT_INVIS:
3768 case SV_POTION_SLOW_POISON:
3769 case SV_POTION_CURE_POISON:
3770 case SV_POTION_BOLDNESS:
3771 case SV_POTION_RESIST_HEAT:
3772 case SV_POTION_RESIST_COLD:
3773 case SV_POTION_HEROISM:
3774 case SV_POTION_BESERK_STRENGTH:
3775 case SV_POTION_RES_STR:
3776 case SV_POTION_RES_INT:
3777 case SV_POTION_RES_WIS:
3778 case SV_POTION_RES_DEX:
3779 case SV_POTION_RES_CON:
3780 case SV_POTION_RES_CHR:
3781 case SV_POTION_INC_STR:
3782 case SV_POTION_INC_INT:
3783 case SV_POTION_INC_WIS:
3784 case SV_POTION_INC_DEX:
3785 case SV_POTION_INC_CON:
3786 case SV_POTION_INC_CHR:
3787 case SV_POTION_AUGMENTATION:
3788 case SV_POTION_ENLIGHTENMENT:
3789 case SV_POTION_STAR_ENLIGHTENMENT:
3790 case SV_POTION_SELF_KNOWLEDGE:
3791 case SV_POTION_EXPERIENCE:
3792 case SV_POTION_RESISTANCE:
3793 case SV_POTION_INVULNERABILITY:
3794 case SV_POTION_NEW_LIFE:
3795 /* All of the above potions have no effect when shattered */
3797 case SV_POTION_SLOWNESS:
3802 case SV_POTION_POISON:
3807 case SV_POTION_BLINDNESS:
3811 case SV_POTION_CONFUSION: /* Booze */
3815 case SV_POTION_SLEEP:
3819 case SV_POTION_RUINATION:
3820 case SV_POTION_DETONATIONS:
3822 dam = damroll(25, 25);
3825 case SV_POTION_DEATH:
3826 dt = GF_DEATH_RAY; /* !! */
3827 dam = k_ptr->level * 10;
3831 case SV_POTION_SPEED:
3834 case SV_POTION_CURE_LIGHT:
3836 dam = damroll(2, 3);
3838 case SV_POTION_CURE_SERIOUS:
3840 dam = damroll(4, 3);
3842 case SV_POTION_CURE_CRITICAL:
3843 case SV_POTION_CURING:
3845 dam = damroll(6, 3);
3847 case SV_POTION_HEALING:
3849 dam = damroll(10, 10);
3851 case SV_POTION_RESTORE_EXP:
3856 case SV_POTION_LIFE:
3858 dam = damroll(50, 50);
3861 case SV_POTION_STAR_HEALING:
3863 dam = damroll(50, 50);
3866 case SV_POTION_RESTORE_MANA: /* MANA */
3868 dam = damroll(10, 10);
3875 (void)project(who, radius, y, x, dam, dt,
3876 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3878 /* XXX those potions that explode need to become "known" */
3884 * Hack -- Display all known spells in a window
3886 * XXX XXX XXX Need to analyze size of the window.
3888 * XXX XXX XXX Need more color coding.
3890 void display_spell_list(void)
3903 /* They have too many spells to list */
3904 if (p_ptr->pclass == CLASS_SORCERER) return;
3905 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3907 /* mind.c type classes */
3908 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3909 (p_ptr->pclass == CLASS_BERSERKER) ||
3910 (p_ptr->pclass == CLASS_NINJA) ||
3911 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3912 (p_ptr->pclass == CLASS_FORCETRAINER))
3918 int plev = p_ptr->lev;
3924 bool use_hp = FALSE;
3926 /* Display a list of spells */
3929 put_str("̾Á°", y, x + 5);
3930 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3932 put_str("Name", y, x + 5);
3933 put_str("Lv Mana Fail Info", y, x + 35);
3936 switch(p_ptr->pclass)
3938 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3939 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3940 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3941 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3942 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3943 default: use_mind = 0;break;
3946 /* Dump the spells */
3947 for (i = 0; i < MAX_MIND_POWERS; i++)
3949 byte a = TERM_WHITE;
3951 /* Access the available spell */
3952 spell = mind_powers[use_mind].info[i];
3953 if (spell.min_lev > plev) break;
3955 /* Get the failure rate */
3956 chance = spell.fail;
3958 /* Reduce failure rate by "effective" level adjustment */
3959 chance -= 3 * (p_ptr->lev - spell.min_lev);
3961 /* Reduce failure rate by INT/WIS adjustment */
3962 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3966 /* Not enough mana to cast */
3967 if (spell.mana_cost > p_ptr->csp)
3969 chance += 5 * (spell.mana_cost - p_ptr->csp);
3975 /* Not enough hp to cast */
3976 if (spell.mana_cost > p_ptr->chp)
3983 /* Extract the minimum failure rate */
3984 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3986 /* Minimum failure rate */
3987 if (chance < minfail) chance = minfail;
3989 /* Stunning makes spells harder */
3990 if (p_ptr->stun > 50) chance += 25;
3991 else if (p_ptr->stun) chance += 15;
3993 /* Always a 5 percent chance of working */
3994 if (chance > 95) chance = 95;
3997 mindcraft_info(comment, use_mind, i);
3999 /* Dump the spell */
4000 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
4002 spell.min_lev, spell.mana_cost, chance, comment);
4004 Term_putstr(x, y + i + 1, -1, a, psi_desc);
4009 /* Cannot read spellbooks */
4010 if (REALM_NONE == p_ptr->realm1) return;
4012 /* Normal spellcaster with books */
4015 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
4019 /* Reset vertical */
4022 /* Vertical location */
4023 y = (j < 3) ? 0 : (m[j - 3] + 2);
4025 /* Horizontal location */
4029 for (i = 0; i < 32; i++)
4031 byte a = TERM_WHITE;
4033 /* Access the spell */
4034 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
4036 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
4040 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
4043 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
4046 if (s_ptr->slevel >= 99)
4050 strcpy(name, "(ȽÆÉÉÔǽ)");
4052 strcpy(name, "(illegible)");
4062 ((p_ptr->spell_forgotten1 & (1L << i))) :
4063 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4070 else if (!((j < 1) ?
4071 (p_ptr->spell_learned1 & (1L << i)) :
4072 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4079 else if (!((j < 1) ?
4080 (p_ptr->spell_worked1 & (1L << i)) :
4081 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4087 /* Dump the spell --(-- */
4088 sprintf(out_val, "%c/%c) %-20.20s",
4089 I2A(n / 8), I2A(n % 8), name);
4094 /* Dump onto the window */
4095 Term_putstr(x, m[j], -1, a, out_val);
4105 * Returns experience of a spell
4107 s16b experience_of_spell(int spell, int use_realm)
4109 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4110 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4111 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4112 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4118 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4120 int mod_need_mana(int need_mana, int spell, int realm)
4122 #define MANA_CONST 2400
4124 #define DEC_MANA_DIV 3
4127 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4130 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4131 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4133 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4134 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4135 need_mana /= MANA_CONST * MANA_DIV;
4136 if (need_mana < 1) need_mana = 1;
4139 /* Non-realm magic */
4142 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4154 * Modify spell fail rate
4155 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4157 int mod_spell_chance_1(int chance)
4159 chance += p_ptr->to_m_chance;
4161 if (p_ptr->heavy_spell) chance += 20;
4163 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4164 else if (p_ptr->easy_spell) chance -= 3;
4165 else if (p_ptr->dec_mana) chance -= 2;
4172 * Modify spell fail rate (as "suffix" process)
4173 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4174 * Note: variable "chance" cannot be negative.
4176 int mod_spell_chance_2(int chance)
4178 if (p_ptr->dec_mana) chance--;
4180 if (p_ptr->heavy_spell) chance += 5;
4182 return MAX(chance, 0);
4187 * Returns spell chance of failure for spell -RAK-
4189 s16b spell_chance(int spell, int use_realm)
4191 int chance, minfail;
4194 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4197 /* Paranoia -- must be literate */
4198 if (!mp_ptr->spell_book) return (100);
4200 if (use_realm == REALM_HISSATSU) return 0;
4202 /* Access the spell */
4203 if (!is_magic(use_realm))
4205 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4209 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4212 /* Extract the base spell failure rate */
4213 chance = s_ptr->sfail;
4215 /* Reduce failure rate by "effective" level adjustment */
4216 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4218 /* Reduce failure rate by INT/WIS adjustment */
4219 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4222 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4224 /* Extract mana consumption rate */
4225 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4227 /* Not enough mana to cast */
4228 if (need_mana > p_ptr->csp)
4230 chance += 5 * (need_mana - p_ptr->csp);
4233 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4235 /* Extract the minimum failure rate */
4236 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4239 * Non mage/priest characters never get too good
4240 * (added high mage, mindcrafter)
4242 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4244 if (minfail < 5) minfail = 5;
4247 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4248 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4249 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4251 chance = mod_spell_chance_1(chance);
4253 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4254 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4255 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4257 /* Minimum failure rate */
4258 if (chance < minfail) chance = minfail;
4260 /* Stunning makes spells harder */
4261 if (p_ptr->stun > 50) chance += 25;
4262 else if (p_ptr->stun) chance += 15;
4264 /* Always a 5 percent chance of working */
4265 if (chance > 95) chance = 95;
4267 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4268 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4270 s16b exp = experience_of_spell(spell, use_realm);
4271 if (exp >= SPELL_EXP_EXPERT) chance--;
4272 if (exp >= SPELL_EXP_MASTER) chance--;
4275 /* Return the chance */
4276 return mod_spell_chance_2(chance);
4282 * Determine if a spell is "okay" for the player to cast or study
4283 * The spell must be legible, not forgotten, and also, to cast,
4284 * it must be known, and to study, it must not be known.
4286 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4290 /* Access the spell */
4291 if (!is_magic(use_realm))
4293 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4297 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4300 /* Spell is illegal */
4301 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4303 /* Spell is forgotten */
4304 if ((use_realm == p_ptr->realm2) ?
4305 (p_ptr->spell_forgotten2 & (1L << spell)) :
4306 (p_ptr->spell_forgotten1 & (1L << spell)))
4312 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4313 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4315 /* Spell is learned */
4316 if ((use_realm == p_ptr->realm2) ?
4317 (p_ptr->spell_learned2 & (1L << spell)) :
4318 (p_ptr->spell_learned1 & (1L << spell)))
4321 return (!study_pray);
4324 /* Okay to study, not to cast */
4331 * Extra information on a spell -DRS-
4333 * We can use up to 14 characters of the buffer 'p'
4335 * The strings in this function were extracted from the code in the
4336 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4338 static void spell_info(char *p, int spell, int use_realm)
4340 int plev = p_ptr->lev;
4343 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4344 p_ptr->pclass == CLASS_HIGH_MAGE ||
4345 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4347 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4348 p_ptr->pclass == CLASS_HIGH_MAGE ||
4349 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4351 cptr s_dam = "»½ý:";
4352 cptr s_dur = "´ü´Ö:";
4353 cptr s_range = "ÈÏ°Ï:";
4354 cptr s_heal = "²óÉü:";
4355 cptr s_random = "¥é¥ó¥À¥à";
4356 cptr s_delay = "ÃÙ±ä:";
4358 cptr s_dam = "dam ";
4359 cptr s_dur = "dur ";
4360 cptr s_range = "range ";
4361 cptr s_heal = "heal ";
4362 cptr s_random = "random";
4363 cptr s_delay = "delay ";
4368 /* Analyze the spell */
4371 case REALM_LIFE: /* Life */
4374 case 0: sprintf(p, " %s2d10", s_heal); break;
4375 case 1: sprintf(p, " %s12+d12", s_dur); break;
4376 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4377 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4378 case 5: sprintf(p, " %s4d10", s_heal); break;
4379 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4380 case 10: sprintf(p, " %s8d10", s_heal); break;
4381 case 11: sprintf(p, " %s20+d20", s_dur); break;
4382 case 14: sprintf(p, " %s300", s_heal); break;
4383 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4384 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4385 case 21: sprintf(p, " %s15+d21", s_delay); break;
4386 case 29: sprintf(p, " %s2000", s_heal); break;
4387 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4391 case REALM_SORCERY: /* Sorcery */
4394 case 1: sprintf(p, " %s10", s_range); break;
4395 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4396 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4397 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4398 case 18: sprintf(p, " %s25+d30", s_dur); break;
4399 case 22: sprintf(p, " %s15+d21", s_delay); break;
4400 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4401 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4403 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4405 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4407 case 27: sprintf(p, " %s25+d30", s_dur); break;
4408 case 31: sprintf(p, " %s4+d4", s_dur); break;
4412 case REALM_NATURE: /* Nature */
4416 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4418 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4420 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4421 case 6: sprintf(p, " %s20+d20", s_dur); break;
4422 case 7: sprintf(p, " %s2d8", s_heal); break;
4423 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4424 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4425 case 12: sprintf(p, " %s6d8", s_dam); break;
4426 case 15: sprintf(p, " %s500", s_heal); break;
4427 case 17: sprintf(p, " %s20+d30", s_dur); break;
4428 case 18: sprintf(p, " %s20+d20", s_dur); break;
4430 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4432 case 24: sprintf(p, " rad 10"); break;
4434 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4435 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4436 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4437 case 29: sprintf(p, " %s75", s_dam); break;
4438 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4442 case REALM_CHAOS: /* Chaos */
4445 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4446 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4447 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4448 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4449 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4450 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4451 case 8: sprintf(p, " %s", s_random); break;
4452 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4453 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4454 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4455 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4456 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4457 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4458 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4459 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4460 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4462 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4464 case 25: sprintf(p, " dam %d each", plev * 2); break;
4466 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4467 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4468 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4469 case 30: sprintf(p, " %s%ld", s_dam, p_ptr->chp); break;
4470 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4474 case REALM_DEATH: /* Death */
4477 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4478 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4479 case 5: sprintf(p, " %s20+d20", s_dur); break;
4480 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4481 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4482 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4484 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4486 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4488 case 16: sprintf(p, " %s25+d25", s_dur); break;
4489 case 17: sprintf(p, " %s", s_random); break;
4490 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4491 case 19: sprintf(p, " %s25+d25", s_dur); break;
4492 case 21: sprintf(p, " %s3*100", s_dam); break;
4493 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4494 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4495 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4496 case 30: sprintf(p, " %s666", s_dam); break;
4497 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4501 case REALM_TRUMP: /* Trump */
4504 case 0: sprintf(p, " %s10", s_range); break;
4505 case 2: sprintf(p, " %s", s_random); break;
4506 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4507 case 5: sprintf(p, " %s25+d30", s_dur); break;
4509 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4511 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4513 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4514 case 14: sprintf(p, " %s15+d21", s_delay); break;
4515 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4517 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4519 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4524 case REALM_ARCANE: /* Arcane */
4527 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4528 case 4: sprintf(p, " %s10", s_range); break;
4529 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4530 case 7: sprintf(p, " %s2d8", s_heal); break;
4534 case 17: sprintf(p, " %s20+d20", s_dur); break;
4535 case 18: sprintf(p, " %s4d8", s_heal); break;
4536 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4537 case 21: sprintf(p, " %s6d8", s_dam); break;
4538 case 24: sprintf(p, " %s24+d24", s_dur); break;
4539 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4540 case 30: sprintf(p, " %s15+d21", s_delay); break;
4541 case 31: sprintf(p, " %s25+d30", s_dur); break;
4545 case REALM_ENCHANT: /* Craft */
4548 case 0: sprintf(p, " %s100+d100", s_dur); break;
4549 case 1: sprintf(p, " %s80+d80", s_dur); break;
4555 case 18: sprintf(p, " %s20+d20", s_dur); break;
4556 case 5: sprintf(p, " %s25+d25", s_dur); break;
4557 case 8: sprintf(p, " %s24+d24", s_dur); break;
4558 case 11: sprintf(p, " %s25+d25", s_dur); break;
4559 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4560 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4561 case 16: sprintf(p, " %s25+d30", s_dur); break;
4562 case 17: sprintf(p, " %s30+d20", s_dur); break;
4563 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4564 case 20: sprintf(p, " %s50+d50", s_dur); break;
4565 case 23: sprintf(p, " %s20+d20", s_dur); break;
4566 case 31: sprintf(p, " %s13+d13", s_dur); break;
4570 case REALM_DAEMON: /* Daemon */
4573 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4574 case 2: sprintf(p, " %s12+d12", s_dur); break;
4575 case 3: sprintf(p, " %s20+d20", s_dur); break;
4576 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4577 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4578 case 10: sprintf(p, " %s20+d20", s_dur); break;
4579 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4580 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4581 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4582 case 16: sprintf(p, " %s30+d25", s_dur); break;
4583 case 17: sprintf(p, " %s20+d20", s_dur); break;
4584 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4585 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4586 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4587 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4588 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4589 case 24: sprintf(p, " %s25+d25", s_dur); break;
4590 case 25: sprintf(p, " %s20+d20", s_dur); break;
4591 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4592 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4593 case 30: sprintf(p, " %s600", s_dam); break;
4594 case 31: sprintf(p, " %s15+d15", s_dur); break;
4598 case REALM_CRUSADE: /* Crusade */
4601 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4602 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4604 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4606 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4608 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4609 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4610 case 12: sprintf(p, " %s24+d24", s_dur); break;
4611 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4612 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4614 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4616 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4618 case 18: sprintf(p, " %s18+d18", s_dur); break;
4619 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4620 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4621 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4622 case 24: sprintf(p, " %s25+d25", s_dur); break;
4623 case 28: sprintf(p, " %s10+d10", s_dur); break;
4625 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4627 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4630 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4632 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4637 case REALM_MUSIC: /* Music */
4640 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4641 case 4 : sprintf(p, " %s2d6", s_heal); break;
4642 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4643 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4644 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4645 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4646 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4647 case 28: sprintf(p, " %s15d10", s_heal); break;
4648 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4653 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4655 sprintf(p, "Unknown type: %d.", use_realm);
4662 * Print a list of spells (for browsing or casting or viewing)
4664 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4666 int i, spell, exp_level, increment = 64;
4678 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4680 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4682 msg_print("Warning! print_spells called with null realm");
4686 /* Title the list */
4688 if (use_realm == REALM_HISSATSU)
4690 strcpy(buf," Lv MP");
4692 strcpy(buf," Lv SP");
4696 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4698 strcpy(buf,"Profic Lv SP Fail Effect");
4702 put_str("̾Á°", y, x + 5);
4703 put_str(buf, y, x + 29);
4705 put_str("Name", y, x + 5);
4706 put_str(buf, y, x + 29);
4709 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4710 else if (use_realm == p_ptr->realm1) increment = 0;
4711 else if (use_realm == p_ptr->realm2) increment = 32;
4713 /* Dump the spells */
4714 for (i = 0; i < num; i++)
4716 /* Access the spell */
4719 /* Access the spell */
4720 if (!is_magic(use_realm))
4722 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4726 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4729 if (use_realm == REALM_HISSATSU)
4730 need_mana = s_ptr->smana;
4733 s16b exp = experience_of_spell(spell, use_realm);
4735 /* Extract mana consumption rate */
4736 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4738 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4739 else exp_level = spell_exp_level(exp);
4742 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4743 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4744 else if (s_ptr->slevel >= 99) max = TRUE;
4745 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4747 strncpy(ryakuji, exp_level_str[exp_level], 4);
4752 if (use_menu && target_spell)
4754 if (i == (target_spell-1))
4756 strcpy(out_val, " ¡Õ ");
4758 strcpy(out_val, " > ");
4761 strcpy(out_val, " ");
4763 else sprintf(out_val, " %c) ", I2A(i));
4764 /* Skip illegible spells */
4765 if (s_ptr->slevel >= 99)
4768 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4770 strcat(out_val, format("%-30s", "(illegible)"));
4773 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4777 /* XXX XXX Could label spells above the players level */
4779 /* Get extra info */
4780 spell_info(info, spell, use_realm);
4785 /* Assume spell is known and tried */
4786 line_attr = TERM_WHITE;
4788 /* Analyze the spell */
4789 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4791 if (s_ptr->slevel > p_ptr->max_plv)
4796 comment = " unknown";
4799 line_attr = TERM_L_BLUE;
4801 else if (s_ptr->slevel > p_ptr->lev)
4806 comment = " forgotten";
4809 line_attr = TERM_YELLOW;
4812 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4817 comment = " unknown";
4820 line_attr = TERM_L_BLUE;
4822 else if ((use_realm == p_ptr->realm1) ?
4823 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4824 ((p_ptr->spell_forgotten2 & (1L << spell))))
4829 comment = " forgotten";
4832 line_attr = TERM_YELLOW;
4834 else if (!((use_realm == p_ptr->realm1) ?
4835 (p_ptr->spell_learned1 & (1L << spell)) :
4836 (p_ptr->spell_learned2 & (1L << spell))))
4841 comment = " unknown";
4844 line_attr = TERM_L_BLUE;
4846 else if (!((use_realm == p_ptr->realm1) ?
4847 (p_ptr->spell_worked1 & (1L << spell)) :
4848 (p_ptr->spell_worked2 & (1L << spell))))
4851 comment = " ̤·Ð¸³";
4853 comment = " untried";
4856 line_attr = TERM_L_GREEN;
4859 /* Dump the spell --(-- */
4860 if (use_realm == REALM_HISSATSU)
4862 strcat(out_val, format("%-25s %2d %4d",
4863 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4864 s_ptr->slevel, need_mana));
4868 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4869 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4870 (max ? '!' : ' '), ryakuji,
4871 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4873 c_prt(line_attr, out_val, y + i + 1, x);
4876 /* Clear the bottom line */
4877 prt("", y + i + 1, x);
4882 * Note that amulets, rods, and high-level spell books are immune
4883 * to "inventory damage" of any kind. Also sling ammo and shovels.
4888 * Does a given class of objects (usually) hate acid?
4889 * Note that acid can either melt or corrode something.
4891 bool hates_acid(object_type *o_ptr)
4893 /* Analyze the type */
4894 switch (o_ptr->tval)
4896 /* Wearable items */
4916 /* Staffs/Scrolls are wood/paper */
4929 /* Junk is useless */
4943 * Does a given object (usually) hate electricity?
4945 bool hates_elec(object_type *o_ptr)
4947 switch (o_ptr->tval)
4961 * Does a given object (usually) hate fire?
4962 * Hafted/Polearm weapons have wooden shafts.
4963 * Arrows/Bows are mostly wooden.
4965 bool hates_fire(object_type *o_ptr)
4967 /* Analyze the type */
4968 switch (o_ptr->tval)
4986 case TV_SORCERY_BOOK:
4987 case TV_NATURE_BOOK:
4991 case TV_ARCANE_BOOK:
4992 case TV_ENCHANT_BOOK:
4993 case TV_DAEMON_BOOK:
4994 case TV_CRUSADE_BOOK:
4996 case TV_HISSATSU_BOOK:
5007 /* Staffs/Scrolls burn */
5020 * Does a given object (usually) hate cold?
5022 bool hates_cold(object_type *o_ptr)
5024 switch (o_ptr->tval)
5041 int set_acid_destroy(object_type *o_ptr)
5043 u32b flgs[TR_FLAG_SIZE];
5044 if (!hates_acid(o_ptr)) return (FALSE);
5045 object_flags(o_ptr, flgs);
5046 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
5054 int set_elec_destroy(object_type *o_ptr)
5056 u32b flgs[TR_FLAG_SIZE];
5057 if (!hates_elec(o_ptr)) return (FALSE);
5058 object_flags(o_ptr, flgs);
5059 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
5067 int set_fire_destroy(object_type *o_ptr)
5069 u32b flgs[TR_FLAG_SIZE];
5070 if (!hates_fire(o_ptr)) return (FALSE);
5071 object_flags(o_ptr, flgs);
5072 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
5080 int set_cold_destroy(object_type *o_ptr)
5082 u32b flgs[TR_FLAG_SIZE];
5083 if (!hates_cold(o_ptr)) return (FALSE);
5084 object_flags(o_ptr, flgs);
5085 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
5091 * Destroys a type of item on a given percent chance
5092 * Note that missiles are no longer necessarily all destroyed
5093 * Destruction taken from "melee.c" code for "stealing".
5094 * New-style wands and rods handled correctly. -LM-
5095 * Returns number of items destroyed.
5097 int inven_damage(inven_func typ, int perc)
5101 char o_name[MAX_NLEN];
5103 /* Multishadow effects is determined by turn */
5104 if( p_ptr->multishadow && (turn & 1) )return 0;
5106 if (p_ptr->inside_arena) return 0;
5108 /* Count the casualties */
5111 /* Scan through the slots backwards */
5112 for (i = 0; i < INVEN_PACK; i++)
5114 o_ptr = &inventory[i];
5116 /* Skip non-objects */
5117 if (!o_ptr->k_idx) continue;
5119 /* Hack -- for now, skip artifacts */
5120 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
5122 /* Give this item slot a shot at death */
5125 /* Count the casualties */
5126 for (amt = j = 0; j < o_ptr->number; ++j)
5128 if (randint0(100) < perc) amt++;
5131 /* Some casualities */
5134 /* Get a description */
5135 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5139 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
5141 msg_format("%sour %s (%c) %s destroyed!",
5145 o_name, index_to_label(i),
5146 ((o_ptr->number > 1) ?
5147 ((amt == o_ptr->number) ? "Á´Éô" :
5148 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
5150 ((o_ptr->number > 1) ?
5151 ((amt == o_ptr->number) ? "All of y" :
5152 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
5153 o_name, index_to_label(i),
5154 ((amt > 1) ? "were" : "was"));
5158 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
5159 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
5162 /* Potions smash open */
5163 if (object_is_potion(o_ptr))
5165 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
5168 /* Reduce the charges of rods/wands */
5169 reduce_charges(o_ptr, amt);
5171 /* Destroy "amt" items */
5172 inven_item_increase(i, -amt);
5173 inven_item_optimize(i);
5175 /* Count the casualties */
5181 /* Return the casualty count */
5187 * Acid has hit the player, attempt to affect some armor.
5189 * Note that the "base armor" of an object never changes.
5191 * If any armor is damaged (or resists), the player takes less damage.
5193 static int minus_ac(void)
5195 object_type *o_ptr = NULL;
5196 u32b flgs[TR_FLAG_SIZE];
5197 char o_name[MAX_NLEN];
5200 /* Pick a (possibly empty) inventory slot */
5201 switch (randint1(7))
5203 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5204 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5205 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5206 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5207 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5208 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5209 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5212 /* Nothing to damage */
5213 if (!o_ptr->k_idx) return (FALSE);
5215 if (o_ptr->tval <= TV_WEAPON_END) return (FALSE);
5217 /* No damage left to be done */
5218 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5222 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5224 /* Extract the flags */
5225 object_flags(o_ptr, flgs);
5227 /* Object resists */
5228 if (have_flag(flgs, TR_IGNORE_ACID))
5231 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5233 msg_format("Your %s is unaffected!", o_name);
5242 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5244 msg_format("Your %s is damaged!", o_name);
5248 /* Damage the item */
5251 /* Calculate bonuses */
5252 p_ptr->update |= (PU_BONUS);
5255 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5259 /* Item was damaged */
5265 * Hurt the player with Acid
5267 int acid_dam(int dam, cptr kb_str, int monspell)
5270 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5271 bool double_resist = IS_OPPOSE_ACID();
5273 /* Total Immunity */
5274 if (p_ptr->immune_acid || (dam <= 0))
5276 learn_spell(monspell);
5280 /* Vulnerability (Ouch!) */
5281 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5282 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5284 /* Resist the damage */
5285 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5286 if (double_resist) dam = (dam + 2) / 3;
5288 if ((!(double_resist || p_ptr->resist_acid)) &&
5289 one_in_(HURT_CHANCE))
5290 (void)do_dec_stat(A_CHR);
5292 /* If any armor gets hit, defend the player */
5293 if (minus_ac()) dam = (dam + 1) / 2;
5296 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5298 /* Inventory damage */
5299 if (!(double_resist && p_ptr->resist_acid))
5300 inven_damage(set_acid_destroy, inv);
5306 * Hurt the player with electricity
5308 int elec_dam(int dam, cptr kb_str, int monspell)
5311 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5312 bool double_resist = IS_OPPOSE_ELEC();
5314 /* Total immunity */
5315 if (p_ptr->immune_elec || (dam <= 0))
5317 learn_spell(monspell);
5321 /* Vulnerability (Ouch!) */
5322 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5323 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5324 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5326 /* Resist the damage */
5327 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5328 if (double_resist) dam = (dam + 2) / 3;
5330 if ((!(double_resist || p_ptr->resist_elec)) &&
5331 one_in_(HURT_CHANCE))
5332 (void)do_dec_stat(A_DEX);
5335 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5337 /* Inventory damage */
5338 if (!(double_resist && p_ptr->resist_elec))
5339 inven_damage(set_elec_destroy, inv);
5346 * Hurt the player with Fire
5348 int fire_dam(int dam, cptr kb_str, int monspell)
5351 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5352 bool double_resist = IS_OPPOSE_FIRE();
5354 /* Totally immune */
5355 if (p_ptr->immune_fire || (dam <= 0))
5357 learn_spell(monspell);
5361 /* Vulnerability (Ouch!) */
5362 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5363 if (prace_is_(RACE_ENT)) dam += dam / 3;
5364 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5366 /* Resist the damage */
5367 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5368 if (double_resist) dam = (dam + 2) / 3;
5370 if ((!(double_resist || p_ptr->resist_fire)) &&
5371 one_in_(HURT_CHANCE))
5372 (void)do_dec_stat(A_STR);
5375 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5377 /* Inventory damage */
5378 if (!(double_resist && p_ptr->resist_fire))
5379 inven_damage(set_fire_destroy, inv);
5386 * Hurt the player with Cold
5388 int cold_dam(int dam, cptr kb_str, int monspell)
5391 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5392 bool double_resist = IS_OPPOSE_COLD();
5394 /* Total immunity */
5395 if (p_ptr->immune_cold || (dam <= 0))
5397 learn_spell(monspell);
5401 /* Vulnerability (Ouch!) */
5402 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5403 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5405 /* Resist the damage */
5406 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5407 if (double_resist) dam = (dam + 2) / 3;
5409 if ((!(double_resist || p_ptr->resist_cold)) &&
5410 one_in_(HURT_CHANCE))
5411 (void)do_dec_stat(A_STR);
5414 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5416 /* Inventory damage */
5417 if (!(double_resist && p_ptr->resist_cold))
5418 inven_damage(set_cold_destroy, inv);
5424 bool rustproof(void)
5428 char o_name[MAX_NLEN];
5431 item_tester_no_ryoute = TRUE;
5432 /* Select a piece of armour */
5433 item_tester_hook = item_tester_hook_armour;
5437 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5438 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5440 q = "Rustproof which piece of armour? ";
5441 s = "You have nothing to rustproof.";
5444 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5446 /* Get the item (in the pack) */
5449 o_ptr = &inventory[item];
5452 /* Get the item (on the floor) */
5455 o_ptr = &o_list[0 - item];
5460 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5462 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5464 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5467 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5469 msg_format("%s %s look%s as good as new!",
5470 ((item >= 0) ? "Your" : "The"), o_name,
5471 ((o_ptr->number > 1) ? "" : "s"));
5478 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5480 msg_format("%s %s %s now protected against corrosion.",
5481 ((item >= 0) ? "Your" : "The"), o_name,
5482 ((o_ptr->number > 1) ? "are" : "is"));
5493 * Curse the players armor
5495 bool curse_armor(void)
5500 char o_name[MAX_NLEN];
5503 /* Curse the body armor */
5504 o_ptr = &inventory[INVEN_BODY];
5506 /* Nothing to curse */
5507 if (!o_ptr->k_idx) return (FALSE);
5511 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5513 /* Attempt a saving throw for artifacts */
5514 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5518 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5519 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5521 msg_format("A %s tries to %s, but your %s resists the effects!",
5522 "terrible black aura", "surround your armor", o_name);
5527 /* not artifact or failed save... */
5532 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5534 msg_format("A terrible black aura blasts your %s!", o_name);
5537 chg_virtue(V_ENCHANT, -5);
5539 /* Blast the armor */
5541 o_ptr->name2 = EGO_BLASTED;
5542 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5549 for (i = 0; i < TR_FLAG_SIZE; i++)
5550 o_ptr->art_flags[i] = 0;
5553 o_ptr->curse_flags = TRC_CURSED;
5556 o_ptr->ident |= (IDENT_BROKEN);
5558 /* Recalculate bonuses */
5559 p_ptr->update |= (PU_BONUS);
5561 /* Recalculate mana */
5562 p_ptr->update |= (PU_MANA);
5565 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5573 * Curse the players weapon
5575 bool curse_weapon(bool force, int slot)
5581 char o_name[MAX_NLEN];
5584 /* Curse the weapon */
5585 o_ptr = &inventory[slot];
5587 /* Nothing to curse */
5588 if (!o_ptr->k_idx) return (FALSE);
5592 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5594 /* Attempt a saving throw */
5595 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5599 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5600 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5602 msg_format("A %s tries to %s, but your %s resists the effects!",
5603 "terrible black aura", "surround your weapon", o_name);
5608 /* not artifact or failed save... */
5613 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5615 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5618 chg_virtue(V_ENCHANT, -5);
5620 /* Shatter the weapon */
5622 o_ptr->name2 = EGO_SHATTERED;
5623 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5624 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5630 for (i = 0; i < TR_FLAG_SIZE; i++)
5631 o_ptr->art_flags[i] = 0;
5635 o_ptr->curse_flags = TRC_CURSED;
5638 o_ptr->ident |= (IDENT_BROKEN);
5640 /* Recalculate bonuses */
5641 p_ptr->update |= (PU_BONUS);
5643 /* Recalculate mana */
5644 p_ptr->update |= (PU_MANA);
5647 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5656 * Enchant some bolts
5658 bool brand_bolts(void)
5662 /* Use the first acceptable bolts */
5663 for (i = 0; i < INVEN_PACK; i++)
5665 object_type *o_ptr = &inventory[i];
5667 /* Skip non-bolts */
5668 if (o_ptr->tval != TV_BOLT) continue;
5670 /* Skip artifacts and ego-items */
5671 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5674 /* Skip cursed/broken items */
5675 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5678 if (randint0(100) < 75) continue;
5682 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5684 msg_print("Your bolts are covered in a fiery aura!");
5689 o_ptr->name2 = EGO_FLAME;
5692 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5699 if (flush_failure) flush();
5703 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5705 msg_print("The fiery enchantment failed.");
5715 * Helper function -- return a "nearby" race for polymorphing
5717 * Note that this function is one of the more "dangerous" ones...
5719 static s16b poly_r_idx(int r_idx)
5721 monster_race *r_ptr = &r_info[r_idx];
5723 int i, r, lev1, lev2;
5725 /* Hack -- Uniques/Questors never polymorph */
5726 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5727 (r_ptr->flags1 & RF1_QUESTOR))
5730 /* Allowable range of "levels" for resulting monster */
5731 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5732 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5734 /* Pick a (possibly new) non-unique race */
5735 for (i = 0; i < 1000; i++)
5737 /* Pick a new race, using a level calculation */
5738 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5740 /* Handle failure */
5746 /* Ignore unique monsters */
5747 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5749 /* Ignore monsters with incompatible levels */
5750 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5752 /* Use that index */
5764 bool polymorph_monster(int y, int x)
5766 cave_type *c_ptr = &cave[y][x];
5767 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5768 bool polymorphed = FALSE;
5770 int old_r_idx = m_ptr->r_idx;
5771 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5772 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5773 monster_type back_m;
5775 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5777 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5779 /* Memorize the monster before polymorphing */
5782 /* Pick a "new" monster race */
5783 new_r_idx = poly_r_idx(old_r_idx);
5785 /* Handle polymorph */
5786 if (new_r_idx != old_r_idx)
5790 /* Get the monsters attitude */
5791 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5792 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5793 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5795 /* "Kill" the "old" monster */
5796 delete_monster_idx(c_ptr->m_idx);
5798 /* Create a new monster (no groups) */
5799 if (place_monster_aux(0, y, x, new_r_idx, mode))
5806 /* Placing the new monster failed */
5807 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5808 m_list[hack_m_idx_ii] = back_m;
5811 if (targeted) target_who = hack_m_idx_ii;
5812 if (health_tracked) health_track(hack_m_idx_ii);
5822 static bool dimension_door_aux(int x, int y)
5824 int plev = p_ptr->lev;
5826 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5828 if (!cave_teleportable_bold(y, x) ||
5829 (distance(y, x, py, px) > plev / 2 + 10) ||
5830 (!randint0(plev / 10 + 10)))
5832 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5833 teleport_player((plev+2)*2);
5840 teleport_player_to(y, x, TRUE);
5851 bool dimension_door(void)
5855 /* Rerutn FALSE if cancelled */
5856 if (!tgt_pt(&x, &y)) return FALSE;
5858 if (dimension_door_aux(x, y)) return TRUE;
5861 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5863 msg_print("You fail to exit the astral plane correctly!");
5871 * Mirror Master's Dimension Door
5873 bool mirror_tunnel(void)
5877 /* Rerutn FALSE if cancelled */
5878 if (!tgt_pt(&x, &y)) return FALSE;
5880 if (dimension_door_aux(x, y)) return TRUE;
5883 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5885 msg_print("You fail to pass the mirror plane correctly!");
5892 bool eat_magic(int power)
5894 object_type * o_ptr;
5897 int recharge_strength = 0;
5903 char o_name[MAX_NLEN];
5905 item_tester_hook = item_tester_hook_recharge;
5909 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5910 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5912 q = "Drain which item? ";
5913 s = "You have nothing to drain.";
5916 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5920 o_ptr = &inventory[item];
5924 o_ptr = &o_list[0 - item];
5927 k_ptr = &k_info[o_ptr->k_idx];
5928 lev = get_object_level(o_ptr);
5930 if (o_ptr->tval == TV_ROD)
5932 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5935 if (one_in_(recharge_strength))
5937 /* Activate the failure code. */
5942 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5945 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5947 msg_print("You can't absorb energy from a discharged rod.");
5954 o_ptr->timeout += k_ptr->pval;
5960 /* All staffs, wands. */
5961 recharge_strength = (100 + power - lev) / 15;
5964 if (recharge_strength < 0) recharge_strength = 0;
5967 if (one_in_(recharge_strength))
5969 /* Activate the failure code. */
5974 if (o_ptr->pval > 0)
5976 p_ptr->csp += lev / 2;
5979 /* XXX Hack -- unstack if necessary */
5980 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5985 /* Get local object */
5988 /* Obtain a local object */
5989 object_copy(q_ptr, o_ptr);
5991 /* Modify quantity */
5994 /* Restore the charges */
5997 /* Unstack the used item */
5999 p_ptr->total_weight -= q_ptr->weight;
6000 item = inven_carry(q_ptr);
6004 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
6006 msg_print("You unstack your staff.");
6014 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
6016 msg_print("There's no energy there to absorb!");
6020 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
6024 /* Inflict the penalties for failing a recharge. */
6027 /* Artifacts are never destroyed. */
6028 if (artifact_p(o_ptr))
6030 object_desc(o_name, o_ptr, OD_NAME_ONLY);
6032 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
6034 msg_format("The recharging backfires - %s is completely drained!", o_name);
6038 /* Artifact rods. */
6039 if (o_ptr->tval == TV_ROD)
6040 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6042 /* Artifact wands and staffs. */
6043 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
6048 /* Get the object description */
6049 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
6051 /*** Determine Seriousness of Failure ***/
6053 /* Mages recharge objects more safely. */
6054 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)
6056 /* 10% chance to blow up one rod, otherwise draining. */
6057 if (o_ptr->tval == TV_ROD)
6059 if (one_in_(10)) fail_type = 2;
6062 /* 75% chance to blow up one wand, otherwise draining. */
6063 else if (o_ptr->tval == TV_WAND)
6065 if (!one_in_(3)) fail_type = 2;
6068 /* 50% chance to blow up one staff, otherwise no effect. */
6069 else if (o_ptr->tval == TV_STAFF)
6071 if (one_in_(2)) fail_type = 2;
6076 /* All other classes get no special favors. */
6079 /* 33% chance to blow up one rod, otherwise draining. */
6080 if (o_ptr->tval == TV_ROD)
6082 if (one_in_(3)) fail_type = 2;
6085 /* 20% chance of the entire stack, else destroy one wand. */
6086 else if (o_ptr->tval == TV_WAND)
6088 if (one_in_(5)) fail_type = 3;
6091 /* Blow up one staff. */
6092 else if (o_ptr->tval == TV_STAFF)
6098 /*** Apply draining and destruction. ***/
6100 /* Drain object or stack of objects. */
6103 if (o_ptr->tval == TV_ROD)
6106 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
6108 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
6111 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6113 else if (o_ptr->tval == TV_WAND)
6116 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
6118 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
6123 /* Staffs aren't drained. */
6126 /* Destroy an object or one in a stack of objects. */
6129 if (o_ptr->number > 1)
6132 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
6134 msg_format("Wild magic consumes one of your %s!", o_name);
6137 /* Reduce rod stack maximum timeout, drain wands. */
6138 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
6139 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
6144 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
6146 msg_format("Wild magic consumes your %s!", o_name);
6149 /* Reduce and describe inventory */
6152 inven_item_increase(item, -1);
6153 inven_item_describe(item);
6154 inven_item_optimize(item);
6157 /* Reduce and describe floor item */
6160 floor_item_increase(0 - item, -1);
6161 floor_item_describe(0 - item);
6162 floor_item_optimize(0 - item);
6166 /* Destroy all members of a stack of objects. */
6169 if (o_ptr->number > 1)
6171 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
6173 msg_format("Wild magic consumes all your %s!", o_name);
6178 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
6180 msg_format("Wild magic consumes your %s!", o_name);
6185 /* Reduce and describe inventory */
6188 inven_item_increase(item, -999);
6189 inven_item_describe(item);
6190 inven_item_optimize(item);
6193 /* Reduce and describe floor item */
6196 floor_item_increase(0 - item, -999);
6197 floor_item_describe(0 - item);
6198 floor_item_optimize(0 - item);
6204 if (p_ptr->csp > p_ptr->msp)
6206 p_ptr->csp = p_ptr->msp;
6209 /* Redraw mana and hp */
6210 p_ptr->redraw |= (PR_MANA);
6212 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6213 p_ptr->window |= (PW_INVEN);
6219 bool summon_kin_player(int level, int y, int x, u32b mode)
6221 bool pet = (bool)(mode & PM_FORCE_PET);
6222 if (!pet) mode |= PM_NO_PET;
6224 switch (p_ptr->mimic_form)
6227 switch (p_ptr->prace)
6231 case RACE_BARBARIAN:
6234 summon_kin_type = 'p';
6244 case RACE_MIND_FLAYER:
6247 summon_kin_type = 'h';
6250 summon_kin_type = 'o';
6252 case RACE_HALF_TROLL:
6253 summon_kin_type = 'T';
6255 case RACE_HALF_OGRE:
6256 summon_kin_type = 'O';
6258 case RACE_HALF_GIANT:
6259 case RACE_HALF_TITAN:
6261 summon_kin_type = 'P';
6264 summon_kin_type = 'y';
6267 summon_kin_type = 'K';
6270 summon_kin_type = 'k';
6273 if (one_in_(13)) summon_kin_type = 'U';
6274 else summon_kin_type = 'u';
6276 case RACE_DRACONIAN:
6277 summon_kin_type = 'd';
6281 summon_kin_type = 'g';
6284 if (one_in_(13)) summon_kin_type = 'L';
6285 else summon_kin_type = 's';
6288 summon_kin_type = 'z';
6291 summon_kin_type = 'V';
6294 summon_kin_type = 'G';
6297 summon_kin_type = 'I';
6300 summon_kin_type = '#';
6303 summon_kin_type = 'A';
6306 summon_kin_type = 'U';
6309 summon_kin_type = 'p';
6314 if (one_in_(13)) summon_kin_type = 'U';
6315 else summon_kin_type = 'u';
6317 case MIMIC_DEMON_LORD:
6318 summon_kin_type = 'U';
6321 summon_kin_type = 'V';
6324 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);