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
22 static bool cave_monster_teleportable_bold(int m_idx, int y, int x, bool passive)
24 monster_type *m_ptr = &m_list[m_idx];
25 cave_type *c_ptr = &cave[y][x];
26 feature_type *f_ptr = &f_info[c_ptr->feat];
28 /* Require "teleportable" space */
29 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
31 if (c_ptr->m_idx && (c_ptr->m_idx != m_idx)) return FALSE;
32 if (player_bold(y, x)) return FALSE;
34 /* Hack -- no teleport onto glyph of warding */
35 if (is_glyph_grid(c_ptr)) return FALSE;
36 if (is_explosive_rune_grid(c_ptr)) return FALSE;
40 if (!monster_can_cross_terrain(c_ptr->feat, &r_info[m_ptr->r_idx], 0)) return FALSE;
48 * Teleport a monster, normally up to "dis" grids away.
50 * Attempt to move the monster at least "dis/2" grids away.
52 * But allow variation to prevent infinite loops.
54 bool teleport_away(int m_idx, int dis, bool dec_valour, bool passive)
56 int oy, ox, d, i, min;
62 monster_type *m_ptr = &m_list[m_idx];
65 if (!m_ptr->r_idx) return (FALSE);
67 /* Save the old location */
71 /* Minimum distance */
75 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
76 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
78 chg_virtue(V_VALOUR, -1);
86 /* Verify max distance */
87 if (dis > 200) dis = 200;
89 /* Try several locations */
90 for (i = 0; i < 500; i++)
92 /* Pick a (possibly illegal) location */
95 ny = rand_spread(oy, dis);
96 nx = rand_spread(ox, dis);
97 d = distance(oy, ox, ny, nx);
98 if ((d >= min) && (d <= dis)) break;
101 /* Ignore illegal locations */
102 if (!in_bounds(ny, nx)) continue;
104 if (!cave_monster_teleportable_bold(m_idx, ny, nx, passive)) continue;
106 /* No teleporting into vaults and such */
107 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
108 if (cave[ny][nx].info & CAVE_ICKY) continue;
110 /* This grid looks good */
117 /* Increase the maximum distance */
120 /* Decrease the minimum distance */
123 /* Stop after MAX_TRIES tries */
124 if (tries > MAX_TRIES) return (FALSE);
128 sound(SOUND_TPOTHER);
130 /* Update the new location */
131 cave[ny][nx].m_idx = m_idx;
133 /* Update the old location */
134 cave[oy][ox].m_idx = 0;
136 /* Move the monster */
140 /* Forget the counter target */
143 /* Update the monster (new location) */
144 update_mon(m_idx, TRUE);
146 /* Redraw the old grid */
149 /* Redraw the new grid */
152 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
153 p_ptr->update |= (PU_MON_LITE);
161 * Teleport monster next to a grid near the given location
163 void teleport_monster_to(int m_idx, int ty, int tx, int power, bool passive)
165 int ny, nx, oy, ox, d, i, min;
169 monster_type *m_ptr = &m_list[m_idx];
172 if (!m_ptr->r_idx) return;
175 if (randint1(100) > power) return;
181 /* Save the old location */
185 /* Minimum distance */
188 /* Look until done */
189 while (look && --attempts)
191 /* Verify max distance */
192 if (dis > 200) dis = 200;
194 /* Try several locations */
195 for (i = 0; i < 500; i++)
197 /* Pick a (possibly illegal) location */
200 ny = rand_spread(ty, dis);
201 nx = rand_spread(tx, dis);
202 d = distance(ty, tx, ny, nx);
203 if ((d >= min) && (d <= dis)) break;
206 /* Ignore illegal locations */
207 if (!in_bounds(ny, nx)) continue;
209 if (!cave_monster_teleportable_bold(m_idx, ny, nx, passive)) continue;
211 /* No teleporting into vaults and such */
212 /* if (cave[ny][nx].info & (CAVE_ICKY)) continue; */
214 /* This grid looks good */
221 /* Increase the maximum distance */
224 /* Decrease the minimum distance */
228 if (attempts < 1) return;
231 sound(SOUND_TPOTHER);
233 /* Update the new location */
234 cave[ny][nx].m_idx = m_idx;
236 /* Update the old location */
237 cave[oy][ox].m_idx = 0;
239 /* Move the monster */
243 /* Update the monster (new location) */
244 update_mon(m_idx, TRUE);
246 /* Redraw the old grid */
249 /* Redraw the new grid */
252 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
253 p_ptr->update |= (PU_MON_LITE);
257 bool cave_player_teleportable_bold(int y, int x, bool passive, bool nonmagical)
259 cave_type *c_ptr = &cave[y][x];
260 feature_type *f_ptr = &f_info[c_ptr->feat];
262 /* Require "teleportable" space */
263 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
265 /* No magical teleporting into vaults and such */
266 if (!nonmagical && (c_ptr->info & CAVE_ICKY)) return FALSE;
268 if (c_ptr->m_idx && (c_ptr->m_idx != p_ptr->riding)) return FALSE;
272 if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
274 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
276 if (!p_ptr->levitation && !p_ptr->can_swim) return FALSE;
279 if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
281 /* Always forbid deep lava */
282 if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
284 /* Forbid shallow lava when the player don't have levitation */
285 if (!p_ptr->levitation) return FALSE;
288 if (have_flag(f_ptr->flags, FF_HIT_TRAP))
290 if (!is_known_trap(c_ptr) || !trap_can_be_ignored(c_ptr->feat)) return FALSE;
299 * Teleport the player to a location up to "dis" grids away.
301 * If no such spaces are readily available, the distance may increase.
302 * Try very hard to move the player at least a quarter that distance.
304 * When long-range teleport effects are considered, there is a nasty
305 * tendency to "bounce" the player between two or three different spots
306 * because these are the only spots that are "far enough" way to satisfy
307 * the algorithm. Therefore, if the teleport distance is more than 50,
308 * we decrease the minimum acceptable distance to try to increase randomness.
311 void teleport_player(int dis, bool passive)
313 int d, i, min, ox, oy;
324 if (p_ptr->wild_mode) return;
326 if (p_ptr->anti_tele)
329 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
331 msg_print("A mysterious force prevents you from teleporting!");
337 if (dis > 200) dis = 200; /* To be on the safe side... */
339 /* Minimum distance */
340 min = dis / (dis > 50 ? 3 : 2);
342 /* Look until done */
347 /* Verify max distance */
348 if (dis > 200) dis = 200;
350 /* Try several locations */
351 for (i = 0; i < 500; i++)
353 /* Pick a (possibly illegal) location */
356 y = rand_spread(py, dis);
357 x = rand_spread(px, dis);
358 d = distance(py, px, y, x);
359 if ((d >= min) && (d <= dis)) break;
362 /* Ignore illegal locations */
363 if (!in_bounds(y, x)) continue;
365 if (!cave_player_teleportable_bold(y, x, passive, FALSE)) continue;
367 /* This grid looks good */
374 /* Increase the maximum distance */
377 /* Decrease the minimum distance */
380 /* Stop after MAX_TRIES tries */
381 if (tries > MAX_TRIES) return;
385 sound(SOUND_TELEPORT);
388 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
389 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
392 /* Save the old location */
396 /* Move the player */
397 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
399 /* Monsters with teleport ability may follow the player */
400 for (xx = -1; xx < 2; xx++)
402 for (yy = -1; yy < 2; yy++)
404 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
406 /* A monster except your mount may follow */
407 if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
409 monster_type *m_ptr = &m_list[tmp_m_idx];
410 monster_race *r_ptr = &r_info[m_ptr->r_idx];
413 * The latter limitation is to avoid
414 * totally unkillable suckers...
416 if ((r_ptr->flags6 & RF6_TPORT) &&
417 !(r_ptr->flagsr & RFR_RES_TELE))
419 if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, y, x, r_ptr->level, FALSE);
429 * Teleport player to a grid near the given location
431 * This function is slightly obsessive about correctness.
432 * This function allows teleporting into vaults (!)
434 void teleport_player_to(int ny, int nx, bool no_tele, bool passive)
436 int y, x, dis = 0, ctr = 0;
438 if (p_ptr->anti_tele && no_tele)
441 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
443 msg_print("A mysterious force prevents you from teleporting!");
449 /* Find a usable location */
452 /* Pick a nearby legal location */
455 y = rand_spread(ny, dis);
456 x = rand_spread(nx, dis);
457 if (in_bounds(y, x)) break;
460 /* Accept any grid when wizard mode */
461 if (p_ptr->wizard && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
463 /* Accept teleportable floor grids */
464 if (cave_player_teleportable_bold(y, x, passive, !no_tele)) break;
466 /* Occasionally advance the distance */
467 if (++ctr > (4 * dis * dis + 4 * dis + 1))
475 sound(SOUND_TELEPORT);
477 /* Move the player */
478 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
484 * Teleport the player one level up or down (random when legal)
485 * Note: If m_idx <= 0, target is player.
487 void teleport_level(int m_idx)
493 if (m_idx <= 0) /* To player */
496 strcpy(m_name, "¤¢¤Ê¤¿");
498 strcpy(m_name, "you");
501 else /* To monster */
503 monster_type *m_ptr = &m_list[m_idx];
505 /* Get the monster name (or "it") */
506 monster_desc(m_name, m_ptr, 0);
508 see_m = is_seen(m_ptr);
511 /* No effect in some case */
512 if (TELE_LEVEL_IS_INEFF(m_idx))
515 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
517 if (see_m) msg_print("There is no effect.");
523 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
526 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
528 msg_print("A mysterious force prevents you from teleporting!");
533 /* Choose up or down */
534 if (randint0(100) < 50) go_up = TRUE;
537 if ((m_idx <= 0) && p_ptr->wizard)
539 if (get_check("Force to go up? ")) go_up = TRUE;
540 else if (get_check("Force to go down? ")) go_up = FALSE;
544 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
547 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
549 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
551 if (m_idx <= 0) /* To player */
555 dungeon_type = p_ptr->recall_dungeon;
560 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
562 if (autosave_l) do_cmd_save_game(TRUE);
566 dun_level = d_info[dungeon_type].mindepth;
567 prepare_change_floor_mode(CFM_RAND_PLACE);
571 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
575 p_ptr->leaving = TRUE;
580 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
583 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
585 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
589 if (m_idx <= 0) /* To player */
591 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
593 if (autosave_l) do_cmd_save_game(TRUE);
595 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
600 p_ptr->inside_quest = 0;
601 p_ptr->leaving = TRUE;
607 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
609 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
613 if (m_idx <= 0) /* To player */
615 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
617 if (autosave_l) do_cmd_save_game(TRUE);
619 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
622 p_ptr->leaving = TRUE;
628 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
630 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
633 if (m_idx <= 0) /* To player */
635 /* Never reach this code on the surface */
636 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
638 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
640 if (autosave_l) do_cmd_save_game(TRUE);
642 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
645 p_ptr->leaving = TRUE;
649 /* Monster level teleportation is simple deleting now */
652 monster_type *m_ptr = &m_list[m_idx];
654 /* Check for quest completion */
655 check_quest_completion(m_ptr);
657 delete_monster_idx(m_idx);
661 sound(SOUND_TPLEVEL);
666 int choose_dungeon(cptr note, int y, int x)
672 /* Hack -- No need to choose dungeon in some case */
673 if (lite_town || vanilla_town || ironman_downward)
675 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
679 msg_format("¤Þ¤À%s¤ËÆþ¤Ã¤¿¤³¤È¤Ï¤Ê¤¤¡£", d_name + d_info[DUNGEON_ANGBAND].name);
681 msg_format("You haven't entered %s yet.", d_name + d_info[DUNGEON_ANGBAND].name);
688 /* Allocate the "dun" array */
689 C_MAKE(dun, max_d_idx, s16b);
692 for(i = 1; i < max_d_idx; i++)
697 if (!d_info[i].maxdepth) continue;
698 if (!max_dlv[i]) continue;
699 if (d_info[i].final_guardian)
701 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
703 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
706 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
708 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
710 prt(buf, y + num, x);
717 prt(" Áª¤Ù¤ë¥À¥ó¥¸¥ç¥ó¤¬¤Ê¤¤¡£", y, x);
719 prt(" No dungeon is available.", y, x);
724 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
726 prt(format("Which dungeon do you %s?: ", note), 0, 0);
731 if ((i == ESCAPE) || !num)
733 /* Free the "dun" array */
734 C_KILL(dun, max_d_idx, s16b);
739 if (i >= 'a' && i <('a'+num))
741 select_dungeon = dun[i-'a'];
748 /* Free the "dun" array */
749 C_KILL(dun, max_d_idx, s16b);
751 return select_dungeon;
756 * Recall the player to town or dungeon
758 bool recall_player(int turns)
761 * TODO: Recall the player to the last
762 * visited town when in the wilderness
766 if (p_ptr->inside_arena || ironman_downward)
769 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
771 msg_print("Nothing happens.");
777 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
780 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
782 if (get_check("Reset recall depth? "))
785 max_dlv[dungeon_type] = dun_level;
788 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
790 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
795 if (!p_ptr->word_recall)
801 select_dungeon = choose_dungeon("¤Ëµ¢´Ô", 2, 14);
803 select_dungeon = choose_dungeon("recall", 2, 14);
805 if (!select_dungeon) return FALSE;
806 p_ptr->recall_dungeon = select_dungeon;
808 p_ptr->word_recall = turns;
810 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
812 msg_print("The air about you becomes charged...");
815 p_ptr->redraw |= (PR_STATUS);
819 p_ptr->word_recall = 0;
821 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
823 msg_print("A tension leaves the air around you...");
826 p_ptr->redraw |= (PR_STATUS);
832 bool word_of_recall(void)
834 return(recall_player(randint0(21) + 15));
838 bool reset_recall(void)
840 int select_dungeon, dummy = 0;
845 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È", 2, 14);
847 select_dungeon = choose_dungeon("reset", 2, 14);
851 if (ironman_downward)
854 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
856 msg_print("Nothing happens.");
862 if (!select_dungeon) return FALSE;
865 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
867 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
872 sprintf(tmp_val, "%d", MAX(dun_level, 1));
874 /* Ask for a level */
875 if (get_string(ppp, tmp_val, 10))
877 /* Extract request */
878 dummy = atoi(tmp_val);
881 if (dummy < 1) dummy = 1;
884 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
885 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
887 max_dlv[select_dungeon] = dummy;
891 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
893 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
897 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
899 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
912 * Apply disenchantment to the player's stuff
914 * XXX XXX XXX This function is also called from the "melee" code
916 * Return "TRUE" if the player notices anything
918 bool apply_disenchant(int mode)
922 char o_name[MAX_NLEN];
923 int to_h, to_d, to_a, pval;
925 /* Pick a random slot */
928 case 1: t = INVEN_RARM; break;
929 case 2: t = INVEN_LARM; break;
930 case 3: t = INVEN_BOW; break;
931 case 4: t = INVEN_BODY; break;
932 case 5: t = INVEN_OUTER; break;
933 case 6: t = INVEN_HEAD; break;
934 case 7: t = INVEN_HANDS; break;
935 case 8: t = INVEN_FEET; break;
939 o_ptr = &inventory[t];
941 /* No item, nothing happens */
942 if (!o_ptr->k_idx) return (FALSE);
944 /* Disenchant equipments only -- No disenchant on monster ball */
945 if (!object_is_weapon_armour_ammo(o_ptr))
948 /* Nothing to disenchant */
949 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
951 /* Nothing to notice */
956 /* Describe the object */
957 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
960 /* Artifacts have 71% chance to resist */
961 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
965 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
967 msg_format("Your %s (%c) resist%s disenchantment!",
968 o_name, index_to_label(t),
969 ((o_ptr->number != 1) ? "" : "s"));
978 /* Memorize old value */
984 /* Disenchant tohit */
985 if (o_ptr->to_h > 0) o_ptr->to_h--;
986 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
988 /* Disenchant todam */
989 if (o_ptr->to_d > 0) o_ptr->to_d--;
990 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
992 /* Disenchant toac */
993 if (o_ptr->to_a > 0) o_ptr->to_a--;
994 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
996 /* Disenchant pval (occasionally) */
997 /* Unless called from wild_magic() */
998 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1000 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1001 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1005 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
1006 o_name, index_to_label(t) );
1008 msg_format("Your %s (%c) %s disenchanted!",
1009 o_name, index_to_label(t),
1010 ((o_ptr->number != 1) ? "were" : "was"));
1013 chg_virtue(V_HARMONY, 1);
1014 chg_virtue(V_ENCHANT, -2);
1016 /* Recalculate bonuses */
1017 p_ptr->update |= (PU_BONUS);
1020 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1030 void mutate_player(void)
1032 int max1, cur1, max2, cur2, ii, jj, i;
1034 /* Pick a pair of stats */
1036 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1038 max1 = p_ptr->stat_max[ii];
1039 cur1 = p_ptr->stat_cur[ii];
1040 max2 = p_ptr->stat_max[jj];
1041 cur2 = p_ptr->stat_cur[jj];
1043 p_ptr->stat_max[ii] = max2;
1044 p_ptr->stat_cur[ii] = cur2;
1045 p_ptr->stat_max[jj] = max1;
1046 p_ptr->stat_cur[jj] = cur1;
1050 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1051 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1054 p_ptr->update |= (PU_BONUS);
1061 void apply_nexus(monster_type *m_ptr)
1063 switch (randint1(7))
1065 case 1: case 2: case 3:
1067 teleport_player(200, TRUE);
1073 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE, TRUE);
1079 if (randint0(100) < p_ptr->skill_sav)
1082 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1084 msg_print("You resist the effects!");
1090 /* Teleport Level */
1097 if (randint0(100) < p_ptr->skill_sav)
1100 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1102 msg_print("You resist the effects!");
1109 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1111 msg_print("Your body starts to scramble...");
1122 * Charge a lite (torch or latern)
1124 void phlogiston(void)
1127 object_type * o_ptr = &inventory[INVEN_LITE];
1130 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1132 max_flog = FUEL_LAMP;
1136 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1138 max_flog = FUEL_TORCH;
1141 /* No torch to refill */
1145 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1147 msg_print("You are not wielding anything which uses phlogiston.");
1153 if (o_ptr->xtra4 >= max_flog)
1156 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1158 msg_print("No more phlogiston can be put in this item.");
1165 o_ptr->xtra4 += (max_flog / 2);
1169 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1171 msg_print("You add phlogiston to your light item.");
1176 if (o_ptr->xtra4 >= max_flog)
1178 o_ptr->xtra4 = max_flog;
1180 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1182 msg_print("Your light item is full.");
1187 /* Recalculate torch */
1188 p_ptr->update |= (PU_TORCH);
1193 * Brand the current weapon
1195 void brand_weapon(int brand_type)
1202 /* Assume enchant weapon */
1203 item_tester_hook = object_allow_enchant_melee_weapon;
1204 item_tester_no_ryoute = TRUE;
1208 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1209 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1211 q = "Enchant which weapon? ";
1212 s = "You have nothing to enchant.";
1215 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1217 /* Get the item (in the pack) */
1220 o_ptr = &inventory[item];
1223 /* Get the item (on the floor) */
1226 o_ptr = &o_list[0 - item];
1230 /* you can never modify artifacts / ego-items */
1231 /* you can never modify cursed items */
1232 /* TY: You _can_ modify broken items (if you're silly enough) */
1233 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1234 !object_is_cursed(o_ptr) &&
1235 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1236 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1237 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1241 /* Let's get the name before it is changed... */
1242 char o_name[MAX_NLEN];
1243 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1248 if (o_ptr->tval == TV_SWORD)
1251 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1253 act = "becomes very sharp!";
1256 o_ptr->name2 = EGO_SHARPNESS;
1257 o_ptr->pval = m_bonus(5, dun_level) + 1;
1262 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1264 act = "seems very powerful.";
1267 o_ptr->name2 = EGO_EARTHQUAKES;
1268 o_ptr->pval = m_bonus(3, dun_level);
1273 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1275 act = "seems to be looking for humans!";
1278 o_ptr->name2 = EGO_SLAY_HUMAN;
1282 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1284 act = "covered with lightning!";
1287 o_ptr->name2 = EGO_BRAND_ELEC;
1291 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1293 act = "coated with acid!";
1296 o_ptr->name2 = EGO_BRAND_ACID;
1300 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1302 act = "seems to be looking for evil monsters!";
1305 o_ptr->name2 = EGO_SLAY_EVIL;
1309 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1311 act = "seems to be looking for demons!";
1314 o_ptr->name2 = EGO_SLAY_DEMON;
1318 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1320 act = "seems to be looking for undead!";
1323 o_ptr->name2 = EGO_SLAY_UNDEAD;
1327 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1329 act = "seems to be looking for animals!";
1332 o_ptr->name2 = EGO_SLAY_ANIMAL;
1336 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1338 act = "seems to be looking for dragons!";
1341 o_ptr->name2 = EGO_SLAY_DRAGON;
1345 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1347 act = "seems to be looking for troll!s";
1350 o_ptr->name2 = EGO_SLAY_TROLL;
1354 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1356 act = "seems to be looking for orcs!";
1359 o_ptr->name2 = EGO_SLAY_ORC;
1363 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1365 act = "seems to be looking for giants!";
1368 o_ptr->name2 = EGO_SLAY_GIANT;
1372 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1374 act = "seems very unstable now.";
1377 o_ptr->name2 = EGO_TRUMP;
1378 o_ptr->pval = randint1(2);
1382 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1384 act = "thirsts for blood!";
1387 o_ptr->name2 = EGO_VAMPIRIC;
1391 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1393 act = "is coated with poison.";
1396 o_ptr->name2 = EGO_BRAND_POIS;
1400 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1402 act = "is engulfed in raw Logrus!";
1405 o_ptr->name2 = EGO_CHAOTIC;
1409 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1411 act = "is covered in a fiery shield!";
1414 o_ptr->name2 = EGO_BRAND_FIRE;
1418 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1420 act = "glows deep, icy blue!";
1423 o_ptr->name2 = EGO_BRAND_COLD;
1428 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1430 msg_format("Your %s %s", o_name, act);
1434 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1436 o_ptr->discount = 99;
1437 chg_virtue(V_ENCHANT, 2);
1441 if (flush_failure) flush();
1444 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1446 msg_print("The Branding failed.");
1449 chg_virtue(V_ENCHANT, -2);
1456 * Vanish all walls in this floor
1458 static bool vanish_dungeon(void)
1462 feature_type *f_ptr;
1463 monster_type *m_ptr;
1466 /* Prevent vasishing of quest levels and town */
1467 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1472 /* Scan all normal grids */
1473 for (y = 1; y < cur_hgt - 1; y++)
1475 for (x = 1; x < cur_wid - 1; x++)
1477 c_ptr = &cave[y][x];
1479 /* Seeing true feature code (ignore mimic) */
1480 f_ptr = &f_info[c_ptr->feat];
1482 /* Lose room and vault */
1483 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1485 m_ptr = &m_list[c_ptr->m_idx];
1488 if (c_ptr->m_idx && m_ptr->csleep)
1490 /* Reset sleep counter */
1493 /* Notice the "waking up" */
1496 /* Acquire the monster name */
1497 monster_desc(m_name, m_ptr, 0);
1499 /* Dump a message */
1501 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1503 msg_format("%^s wakes up.", m_name);
1509 /* Redraw the health bar */
1510 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
1511 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
1515 /* Process all walls, doors and patterns */
1516 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1520 /* Special boundary walls -- Top and bottom */
1521 for (x = 0; x < cur_wid; x++)
1523 c_ptr = &cave[0][x];
1524 f_ptr = &f_info[c_ptr->mimic];
1526 /* Lose room and vault */
1527 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1529 /* Set boundary mimic if needed */
1530 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1532 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1534 /* Check for change to boring grid */
1535 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1538 c_ptr = &cave[cur_hgt - 1][x];
1539 f_ptr = &f_info[c_ptr->mimic];
1541 /* Lose room and vault */
1542 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1544 /* Set boundary mimic if needed */
1545 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1547 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1549 /* Check for change to boring grid */
1550 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1554 /* Special boundary walls -- Left and right */
1555 for (y = 1; y < (cur_hgt - 1); y++)
1557 c_ptr = &cave[y][0];
1558 f_ptr = &f_info[c_ptr->mimic];
1560 /* Lose room and vault */
1561 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1563 /* Set boundary mimic if needed */
1564 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1566 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1568 /* Check for change to boring grid */
1569 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1572 c_ptr = &cave[y][cur_wid - 1];
1573 f_ptr = &f_info[c_ptr->mimic];
1575 /* Lose room and vault */
1576 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1578 /* Set boundary mimic if needed */
1579 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1581 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1583 /* Check for change to boring grid */
1584 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1588 /* Mega-Hack -- Forget the view and lite */
1589 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1592 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1594 /* Update the monsters */
1595 p_ptr->update |= (PU_MONSTERS);
1598 p_ptr->redraw |= (PR_MAP);
1601 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1607 void call_the_(void)
1611 bool do_call = TRUE;
1613 for (i = 0; i < 9; i++)
1615 c_ptr = &cave[py + ddy_ddd[i]][px + ddx_ddd[i]];
1617 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1619 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1620 !permanent_wall(&f_info[c_ptr->feat]))
1630 for (i = 1; i < 10; i++)
1632 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1635 for (i = 1; i < 10; i++)
1637 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1640 for (i = 1; i < 10; i++)
1642 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1646 /* Prevent destruction of quest levels and town */
1647 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1650 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1652 msg_print("The ground trembles.");
1659 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1660 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1661 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1663 msg_format("You %s the %s too close to a wall!",
1664 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1665 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1666 msg_print("There is a loud explosion!");
1672 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1674 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1679 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1681 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1683 msg_print("The dungeon collapses...");
1688 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1690 msg_print("The dungeon trembles.");
1695 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1697 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1704 * Fetch an item (teleport it right underneath the caster)
1706 void fetch(int dir, int wgt, bool require_los)
1711 char o_name[MAX_NLEN];
1713 /* Check to see if an object is already there */
1714 if (cave[py][px].o_idx)
1717 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1719 msg_print("You can't fetch when you're already standing on something.");
1726 if (dir == 5 && target_okay())
1731 if (distance(py, px, ty, tx) > MAX_RANGE)
1734 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1736 msg_print("You can't fetch something that far away!");
1742 c_ptr = &cave[ty][tx];
1744 /* We need an item to fetch */
1748 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1750 msg_print("There is no object at this place.");
1756 /* No fetching from vault */
1757 if (c_ptr->info & CAVE_ICKY)
1760 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1762 msg_print("The item slips from your control.");
1768 /* We need to see the item */
1771 if (!player_has_los_bold(ty, tx))
1774 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1776 msg_print("You have no direct line of sight to that location.");
1781 else if (!projectable(py, px, ty, tx))
1784 msg_print("¤½¤³¤ÏÊɤθþ¤³¤¦¤Ç¤¹¡£");
1786 msg_print("You have no direct line of sight to that location.");
1795 /* Use a direction */
1796 ty = py; /* Where to drop the item */
1803 c_ptr = &cave[ty][tx];
1805 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1806 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1808 while (!c_ptr->o_idx);
1811 o_ptr = &o_list[c_ptr->o_idx];
1813 if (o_ptr->weight > wgt)
1815 /* Too heavy to 'fetch' */
1817 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1819 msg_print("The object is too heavy.");
1826 c_ptr->o_idx = o_ptr->next_o_idx;
1827 cave[py][px].o_idx = i; /* 'move' it */
1828 o_ptr->next_o_idx = 0;
1829 o_ptr->iy = (byte)py;
1830 o_ptr->ix = (byte)px;
1832 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1834 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1836 msg_format("%^s flies through the air to your feet.", o_name);
1841 p_ptr->redraw |= PR_MAP;
1845 void alter_reality(void)
1847 /* Ironman option */
1848 if (p_ptr->inside_arena || ironman_downward)
1851 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1853 msg_print("Nothing happens.");
1858 if (!p_ptr->alter_reality)
1860 int turns = randint0(21) + 15;
1862 p_ptr->alter_reality = turns;
1864 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1866 msg_print("The view around you begins to change...");
1869 p_ptr->redraw |= (PR_STATUS);
1873 p_ptr->alter_reality = 0;
1875 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1877 msg_print("The view around you got back...");
1880 p_ptr->redraw |= (PR_STATUS);
1887 * Leave a "glyph of warding" which prevents monster movement
1889 bool warding_glyph(void)
1892 if (!cave_clean_bold(py, px))
1895 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1897 msg_print("The object resists the spell.");
1903 /* Create a glyph */
1904 cave[py][px].info |= CAVE_OBJECT;
1905 cave[py][px].mimic = FEAT_GLYPH;
1916 bool place_mirror(void)
1919 if (!cave_clean_bold(py, px))
1922 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1924 msg_print("The object resists the spell.");
1930 /* Create a mirror */
1931 cave[py][px].info |= CAVE_OBJECT;
1932 cave[py][px].mimic = FEAT_MIRROR;
1934 /* Turn on the light */
1935 cave[py][px].info |= CAVE_GLOW;
1943 update_local_illumination(py, px);
1950 * Leave an "explosive rune" which prevents monster movement
1952 bool explosive_rune(void)
1955 if (!cave_clean_bold(py, px))
1958 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1960 msg_print("The object resists the spell.");
1966 /* Create a glyph */
1967 cave[py][px].info |= CAVE_OBJECT;
1968 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1981 * Identify everything being carried.
1982 * Done by a potion of "self knowledge".
1984 void identify_pack(void)
1988 /* Simply identify and know every item */
1989 for (i = 0; i < INVEN_TOTAL; i++)
1991 object_type *o_ptr = &inventory[i];
1993 /* Skip non-objects */
1994 if (!o_ptr->k_idx) continue;
1997 identify_item(o_ptr);
1999 /* Auto-inscription */
2000 autopick_alter_item(i, FALSE);
2006 * Used by the "enchant" function (chance of failure)
2007 * (modified for Zangband, we need better stuff there...) -- TY
2009 static int enchant_table[16] =
2011 0, 10, 50, 100, 200,
2012 300, 400, 500, 650, 800,
2013 950, 987, 993, 995, 998,
2019 * Removes curses from items in inventory
2021 * Note that Items which are "Perma-Cursed" (The One Ring,
2022 * The Crown of Morgoth) can NEVER be uncursed.
2024 * Note that if "all" is FALSE, then Items which are
2025 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2026 * will not be uncursed.
2028 static int remove_curse_aux(int all)
2032 /* Attempt to uncurse items being worn */
2033 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2035 object_type *o_ptr = &inventory[i];
2037 /* Skip non-objects */
2038 if (!o_ptr->k_idx) continue;
2040 /* Uncursed already */
2041 if (!object_is_cursed(o_ptr)) continue;
2043 /* Heavily Cursed Items need a special spell */
2044 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2046 /* Perma-Cursed Items can NEVER be uncursed */
2047 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2050 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2055 o_ptr->curse_flags = 0L;
2057 /* Hack -- Assume felt */
2058 o_ptr->ident |= (IDENT_SENSE);
2061 o_ptr->feeling = FEEL_NONE;
2063 /* Recalculate the bonuses */
2064 p_ptr->update |= (PU_BONUS);
2067 p_ptr->window |= (PW_EQUIP);
2069 /* Count the uncursings */
2073 /* Return "something uncursed" */
2079 * Remove most curses
2081 bool remove_curse(void)
2083 return (remove_curse_aux(FALSE));
2089 bool remove_all_curse(void)
2091 return (remove_curse_aux(TRUE));
2096 * Turns an object into gold, gain some of its value in a shop
2105 char o_name[MAX_NLEN];
2106 char out_val[MAX_NLEN+40];
2110 /* Hack -- force destruction */
2111 if (command_arg > 0) force = TRUE;
2115 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2116 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2118 q = "Turn which item to gold? ";
2119 s = "You have nothing to turn to gold.";
2122 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2124 /* Get the item (in the pack) */
2127 o_ptr = &inventory[item];
2130 /* Get the item (on the floor) */
2133 o_ptr = &o_list[0 - item];
2137 /* See how many items */
2138 if (o_ptr->number > 1)
2140 /* Get a quantity */
2141 amt = get_quantity(NULL, o_ptr->number);
2143 /* Allow user abort */
2144 if (amt <= 0) return FALSE;
2148 /* Describe the object */
2149 old_number = o_ptr->number;
2150 o_ptr->number = amt;
2151 object_desc(o_name, o_ptr, 0);
2152 o_ptr->number = old_number;
2154 /* Verify unless quantity given */
2157 if (confirm_destroy || (object_value(o_ptr) > 0))
2159 /* Make a verification */
2161 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2163 sprintf(out_val, "Really turn %s to gold? ", o_name);
2166 if (!get_check(out_val)) return FALSE;
2170 /* Artifacts cannot be destroyed */
2171 if (!can_player_destroy_object(o_ptr))
2175 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2177 msg_format("You fail to turn %s to gold!", o_name);
2184 price = object_value_real(o_ptr);
2190 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2192 msg_format("You turn %s to fool's gold.", o_name);
2200 if (amt > 1) price *= amt;
2202 if (price > 30000) price = 30000;
2204 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2206 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2212 p_ptr->redraw |= (PR_GOLD);
2215 p_ptr->window |= (PW_PLAYER);
2219 /* Eliminate the item (from the pack) */
2222 inven_item_increase(item, -amt);
2223 inven_item_describe(item);
2224 inven_item_optimize(item);
2227 /* Eliminate the item (from the floor) */
2230 floor_item_increase(0 - item, -amt);
2231 floor_item_describe(0 - item);
2232 floor_item_optimize(0 - item);
2240 * Break the curse of an item
2242 static void break_curse(object_type *o_ptr)
2244 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2247 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2249 msg_print("The curse is broken!");
2252 o_ptr->curse_flags = 0L;
2254 o_ptr->ident |= (IDENT_SENSE);
2256 o_ptr->feeling = FEEL_NONE;
2262 * Enchants a plus onto an item. -RAK-
2264 * Revamped! Now takes item pointer, number of times to try enchanting,
2265 * and a flag of what to try enchanting. Artifacts resist enchantment
2266 * some of the time, and successful enchantment to at least +0 might
2267 * break a curse on the item. -CFT-
2269 * Note that an item can technically be enchanted all the way to +15 if
2270 * you wait a very, very, long time. Going from +9 to +10 only works
2271 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2273 * Note that this function can now be used on "piles" of items, and
2274 * the larger the pile, the lower the chance of success.
2276 bool enchant(object_type *o_ptr, int n, int eflag)
2278 int i, chance, prob;
2280 bool a = object_is_artifact(o_ptr);
2281 bool force = (eflag & ENCH_FORCE);
2284 /* Large piles resist enchantment */
2285 prob = o_ptr->number * 100;
2287 /* Missiles are easy to enchant */
2288 if ((o_ptr->tval == TV_BOLT) ||
2289 (o_ptr->tval == TV_ARROW) ||
2290 (o_ptr->tval == TV_SHOT))
2296 for (i = 0; i < n; i++)
2298 /* Hack -- Roll for pile resistance */
2299 if (!force && randint0(prob) >= 100) continue;
2301 /* Enchant to hit */
2302 if (eflag & ENCH_TOHIT)
2304 if (o_ptr->to_h < 0) chance = 0;
2305 else if (o_ptr->to_h > 15) chance = 1000;
2306 else chance = enchant_table[o_ptr->to_h];
2308 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2313 /* only when you get it above -1 -CFT */
2314 if (o_ptr->to_h >= 0)
2319 /* Enchant to damage */
2320 if (eflag & ENCH_TODAM)
2322 if (o_ptr->to_d < 0) chance = 0;
2323 else if (o_ptr->to_d > 15) chance = 1000;
2324 else chance = enchant_table[o_ptr->to_d];
2326 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2331 /* only when you get it above -1 -CFT */
2332 if (o_ptr->to_d >= 0)
2337 /* Enchant to armor class */
2338 if (eflag & ENCH_TOAC)
2340 if (o_ptr->to_a < 0) chance = 0;
2341 else if (o_ptr->to_a > 15) chance = 1000;
2342 else chance = enchant_table[o_ptr->to_a];
2344 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2349 /* only when you get it above -1 -CFT */
2350 if (o_ptr->to_a >= 0)
2357 if (!res) return (FALSE);
2359 /* Recalculate bonuses */
2360 p_ptr->update |= (PU_BONUS);
2362 /* Combine / Reorder the pack (later) */
2363 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2366 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2377 * Enchant an item (in the inventory or on the floor)
2378 * Note that "num_ac" requires armour, else weapon
2379 * Returns TRUE if attempted, FALSE if cancelled
2381 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2386 char o_name[MAX_NLEN];
2390 /* Assume enchant weapon */
2391 item_tester_hook = object_allow_enchant_weapon;
2392 item_tester_no_ryoute = TRUE;
2394 /* Enchant armor if requested */
2395 if (num_ac) item_tester_hook = object_is_armour;
2399 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2400 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2402 q = "Enchant which item? ";
2403 s = "You have nothing to enchant.";
2406 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2408 /* Get the item (in the pack) */
2411 o_ptr = &inventory[item];
2414 /* Get the item (on the floor) */
2417 o_ptr = &o_list[0 - item];
2422 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2426 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2429 msg_format("%s %s glow%s brightly!",
2430 ((item >= 0) ? "Your" : "The"), o_name,
2431 ((o_ptr->number > 1) ? "" : "s"));
2436 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2437 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2438 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2444 if (flush_failure) flush();
2448 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2450 msg_print("The enchantment failed.");
2453 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2456 chg_virtue(V_ENCHANT, 1);
2460 /* Something happened */
2466 * Check if an object is nameless weapon or armour
2468 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2470 /* Require weapon or armour */
2471 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2473 /* Require nameless object if the object is well known */
2474 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2481 bool artifact_scroll(void)
2486 char o_name[MAX_NLEN];
2490 item_tester_no_ryoute = TRUE;
2492 /* Enchant weapon/armour */
2493 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2497 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2498 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2500 q = "Enchant which item? ";
2501 s = "You have nothing to enchant.";
2504 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2506 /* Get the item (in the pack) */
2509 o_ptr = &inventory[item];
2512 /* Get the item (on the floor) */
2515 o_ptr = &o_list[0 - item];
2520 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2524 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2526 msg_format("%s %s radiate%s a blinding light!",
2527 ((item >= 0) ? "Your" : "The"), o_name,
2528 ((o_ptr->number > 1) ? "" : "s"));
2531 if (object_is_artifact(o_ptr))
2534 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2536 msg_format("The %s %s already %s!",
2537 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2538 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2544 else if (object_is_ego(o_ptr))
2547 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2549 msg_format("The %s %s already %s!",
2550 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2551 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2557 else if (o_ptr->xtra3)
2560 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2562 msg_format("The %s %s already %s!",
2563 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2564 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2570 if (o_ptr->number > 1)
2573 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2574 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2576 msg_print("Not enough enough energy to enchant more than one object!");
2577 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2582 inven_item_increase(item, 1-(o_ptr->number));
2586 floor_item_increase(0-item, 1-(o_ptr->number));
2589 okay = create_artifact(o_ptr, TRUE);
2596 if (flush_failure) flush();
2600 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2602 msg_print("The enchantment failed.");
2605 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2608 chg_virtue(V_ENCHANT, 1);
2612 /* Something happened */
2618 * Identify an object
2620 bool identify_item(object_type *o_ptr)
2622 bool old_known = FALSE;
2623 char o_name[MAX_NLEN];
2626 object_desc(o_name, o_ptr, 0);
2628 if (o_ptr->ident & IDENT_KNOWN)
2631 if (!(o_ptr->ident & (IDENT_MENTAL)))
2633 if (object_is_artifact(o_ptr) || one_in_(5))
2634 chg_virtue(V_KNOWLEDGE, 1);
2637 /* Identify it fully */
2638 object_aware(o_ptr);
2639 object_known(o_ptr);
2641 /* Recalculate bonuses */
2642 p_ptr->update |= (PU_BONUS);
2644 /* Combine / Reorder the pack (later) */
2645 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2648 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2650 strcpy(record_o_name, o_name);
2654 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2656 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2657 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2658 if(record_rand_art && !old_known && o_ptr->art_name)
2659 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2665 static bool item_tester_hook_identify(object_type *o_ptr)
2667 return (bool)!object_is_known(o_ptr);
2670 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2672 if (object_is_known(o_ptr))
2674 return object_is_weapon_armour_ammo(o_ptr);
2678 * Identify an object in the inventory (or on the floor)
2679 * This routine does *not* automatically combine objects.
2680 * Returns TRUE if something was identified, else FALSE.
2682 bool ident_spell(bool only_equip)
2686 char o_name[MAX_NLEN];
2690 item_tester_no_ryoute = TRUE;
2693 item_tester_hook = item_tester_hook_identify_weapon_armour;
2695 item_tester_hook = item_tester_hook_identify;
2697 if (!can_get_item())
2701 item_tester_hook = object_is_weapon_armour_ammo;
2705 item_tester_hook = NULL;
2711 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2712 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2714 q = "Identify which item? ";
2715 s = "You have nothing to identify.";
2718 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2720 /* Get the item (in the pack) */
2723 o_ptr = &inventory[item];
2726 /* Get the item (on the floor) */
2729 o_ptr = &o_list[0 - item];
2733 old_known = identify_item(o_ptr);
2736 object_desc(o_name, o_ptr, 0);
2739 if (item >= INVEN_RARM)
2742 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2744 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2750 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2752 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2758 msg_format("¾²¾å: %s¡£", o_name);
2760 msg_format("On the ground: %s.", o_name);
2764 /* Auto-inscription/destroy */
2765 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2767 /* Something happened */
2773 * Mundanify an object in the inventory (or on the floor)
2774 * This routine does *not* automatically combine objects.
2775 * Returns TRUE if something was mundanified, else FALSE.
2777 bool mundane_spell(bool only_equip)
2783 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2784 item_tester_no_ryoute = TRUE;
2788 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2789 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2791 q = "Use which item? ";
2792 s = "You have nothing you can use.";
2795 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2797 /* Get the item (in the pack) */
2800 o_ptr = &inventory[item];
2803 /* Get the item (on the floor) */
2806 o_ptr = &o_list[0 - item];
2811 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2813 msg_print("There is a bright flash of light!");
2816 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2817 byte ix = o_ptr->ix; /* X-position on map, or zero */
2818 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2819 byte marked = o_ptr->marked; /* Object is marked */
2820 s16b weight = o_ptr->number * o_ptr->weight;
2821 u16b inscription = o_ptr->inscription;
2824 object_prep(o_ptr, o_ptr->k_idx);
2828 o_ptr->next_o_idx = next_o_idx;
2829 o_ptr->marked = marked;
2830 o_ptr->inscription = inscription;
2831 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2835 /* Something happened */
2841 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2843 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2846 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2848 if (!item_tester_hook_identify_fully(o_ptr))
2850 return object_is_weapon_armour_ammo(o_ptr);
2854 * Fully "identify" an object in the inventory -BEN-
2855 * This routine returns TRUE if an item was identified.
2857 bool identify_fully(bool only_equip)
2861 char o_name[MAX_NLEN];
2865 item_tester_no_ryoute = TRUE;
2867 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2869 item_tester_hook = item_tester_hook_identify_fully;
2871 if (!can_get_item())
2874 item_tester_hook = object_is_weapon_armour_ammo;
2876 item_tester_hook = NULL;
2881 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2882 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2884 q = "Identify which item? ";
2885 s = "You have nothing to identify.";
2888 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2890 /* Get the item (in the pack) */
2893 o_ptr = &inventory[item];
2896 /* Get the item (on the floor) */
2899 o_ptr = &o_list[0 - item];
2903 old_known = identify_item(o_ptr);
2905 /* Mark the item as fully known */
2906 o_ptr->ident |= (IDENT_MENTAL);
2912 object_desc(o_name, o_ptr, 0);
2915 if (item >= INVEN_RARM)
2918 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2920 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2928 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2930 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2936 msg_format("¾²¾å: %s¡£", o_name);
2938 msg_format("On the ground: %s.", o_name);
2942 /* Describe it fully */
2943 (void)screen_object(o_ptr, TRUE);
2945 /* Auto-inscription/destroy */
2946 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2956 * Hook for "get_item()". Determine if something is rechargable.
2958 bool item_tester_hook_recharge(object_type *o_ptr)
2960 /* Recharge staffs */
2961 if (o_ptr->tval == TV_STAFF) return (TRUE);
2963 /* Recharge wands */
2964 if (o_ptr->tval == TV_WAND) return (TRUE);
2966 /* Hack -- Recharge rods */
2967 if (o_ptr->tval == TV_ROD) return (TRUE);
2975 * Recharge a wand/staff/rod from the pack or on the floor.
2976 * This function has been rewritten in Oangband and ZAngband.
2978 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2979 * Chaos -- Arcane Binding --> recharge(90)
2981 * Scroll of recharging --> recharge(130)
2982 * Artifact activation/Thingol --> recharge(130)
2984 * It is harder to recharge high level, and highly charged wands,
2985 * staffs, and rods. The more wands in a stack, the more easily and
2986 * strongly they recharge. Staffs, however, each get fewer charges if
2989 * XXX XXX XXX Beware of "sliding index errors".
2991 bool recharge(int power)
2994 int recharge_strength, recharge_amount;
3003 char o_name[MAX_NLEN];
3005 /* Only accept legal items */
3006 item_tester_hook = item_tester_hook_recharge;
3010 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3011 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3013 q = "Recharge which item? ";
3014 s = "You have nothing to recharge.";
3017 if (!get_item(&item, q, s, (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];
3031 /* Get the object kind. */
3032 k_ptr = &k_info[o_ptr->k_idx];
3034 /* Extract the object "level" */
3035 lev = k_info[o_ptr->k_idx].level;
3038 /* Recharge a rod */
3039 if (o_ptr->tval == TV_ROD)
3041 /* Extract a recharge strength by comparing object level to power. */
3042 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3046 if (one_in_(recharge_strength))
3048 /* Activate the failure code. */
3055 /* Recharge amount */
3056 recharge_amount = (power * damroll(3, 2));
3058 /* Recharge by that amount */
3059 if (o_ptr->timeout > recharge_amount)
3060 o_ptr->timeout -= recharge_amount;
3067 /* Recharge wand/staff */
3070 /* Extract a recharge strength by comparing object level to power.
3071 * Divide up a stack of wands' charges to calculate charge penalty.
3073 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3074 recharge_strength = (100 + power - lev -
3075 (8 * o_ptr->pval / o_ptr->number)) / 15;
3077 /* All staffs, unstacked wands. */
3078 else recharge_strength = (100 + power - lev -
3079 (8 * o_ptr->pval)) / 15;
3082 if (recharge_strength < 0) recharge_strength = 0;
3085 if (one_in_(recharge_strength))
3087 /* Activate the failure code. */
3091 /* If the spell didn't backfire, recharge the wand or staff. */
3094 /* Recharge based on the standard number of charges. */
3095 recharge_amount = randint1(1 + k_ptr->pval / 2);
3097 /* Multiple wands in a stack increase recharging somewhat. */
3098 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3101 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3102 if (recharge_amount < 1) recharge_amount = 1;
3103 if (recharge_amount > 12) recharge_amount = 12;
3106 /* But each staff in a stack gets fewer additional charges,
3107 * although always at least one.
3109 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3111 recharge_amount /= o_ptr->number;
3112 if (recharge_amount < 1) recharge_amount = 1;
3115 /* Recharge the wand or staff. */
3116 o_ptr->pval += recharge_amount;
3119 /* Hack -- we no longer "know" the item */
3120 o_ptr->ident &= ~(IDENT_KNOWN);
3122 /* Hack -- we no longer think the item is empty */
3123 o_ptr->ident &= ~(IDENT_EMPTY);
3128 /* Inflict the penalties for failing a recharge. */
3131 /* Artifacts are never destroyed. */
3132 if (object_is_fixed_artifact(o_ptr))
3134 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3136 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3138 msg_format("The recharging backfires - %s is completely drained!", o_name);
3142 /* Artifact rods. */
3143 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3144 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3146 /* Artifact wands and staffs. */
3147 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3152 /* Get the object description */
3153 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3155 /*** Determine Seriousness of Failure ***/
3157 /* Mages recharge objects more safely. */
3158 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)
3160 /* 10% chance to blow up one rod, otherwise draining. */
3161 if (o_ptr->tval == TV_ROD)
3163 if (one_in_(10)) fail_type = 2;
3166 /* 75% chance to blow up one wand, otherwise draining. */
3167 else if (o_ptr->tval == TV_WAND)
3169 if (!one_in_(3)) fail_type = 2;
3172 /* 50% chance to blow up one staff, otherwise no effect. */
3173 else if (o_ptr->tval == TV_STAFF)
3175 if (one_in_(2)) fail_type = 2;
3180 /* All other classes get no special favors. */
3183 /* 33% chance to blow up one rod, otherwise draining. */
3184 if (o_ptr->tval == TV_ROD)
3186 if (one_in_(3)) fail_type = 2;
3189 /* 20% chance of the entire stack, else destroy one wand. */
3190 else if (o_ptr->tval == TV_WAND)
3192 if (one_in_(5)) fail_type = 3;
3195 /* Blow up one staff. */
3196 else if (o_ptr->tval == TV_STAFF)
3202 /*** Apply draining and destruction. ***/
3204 /* Drain object or stack of objects. */
3207 if (o_ptr->tval == TV_ROD)
3210 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3212 msg_print("The recharge backfires, draining the rod further!");
3215 if (o_ptr->timeout < 10000)
3216 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3218 else if (o_ptr->tval == TV_WAND)
3221 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3223 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3228 /* Staffs aren't drained. */
3231 /* Destroy an object or one in a stack of objects. */
3234 if (o_ptr->number > 1)
3236 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3238 msg_format("Wild magic consumes one of your %s!", o_name);
3243 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3245 msg_format("Wild magic consumes your %s!", o_name);
3249 /* Reduce rod stack maximum timeout, drain wands. */
3250 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3251 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3253 /* Reduce and describe inventory */
3256 inven_item_increase(item, -1);
3257 inven_item_describe(item);
3258 inven_item_optimize(item);
3261 /* Reduce and describe floor item */
3264 floor_item_increase(0 - item, -1);
3265 floor_item_describe(0 - item);
3266 floor_item_optimize(0 - item);
3270 /* Destroy all members of a stack of objects. */
3273 if (o_ptr->number > 1)
3275 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3277 msg_format("Wild magic consumes all your %s!", o_name);
3282 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3284 msg_format("Wild magic consumes your %s!", o_name);
3289 /* Reduce and describe inventory */
3292 inven_item_increase(item, -999);
3293 inven_item_describe(item);
3294 inven_item_optimize(item);
3297 /* Reduce and describe floor item */
3300 floor_item_increase(0 - item, -999);
3301 floor_item_describe(0 - item);
3302 floor_item_optimize(0 - item);
3308 /* Combine / Reorder the pack (later) */
3309 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3312 p_ptr->window |= (PW_INVEN);
3314 /* Something was done */
3322 bool bless_weapon(void)
3326 u32b flgs[TR_FLAG_SIZE];
3327 char o_name[MAX_NLEN];
3330 item_tester_no_ryoute = TRUE;
3332 /* Bless only weapons */
3333 item_tester_hook = object_is_weapon;
3337 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3338 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3340 q = "Bless which weapon? ";
3341 s = "You have weapon to bless.";
3344 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3347 /* Get the item (in the pack) */
3350 o_ptr = &inventory[item];
3353 /* Get the item (on the floor) */
3356 o_ptr = &o_list[0 - item];
3361 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3363 /* Extract the flags */
3364 object_flags(o_ptr, flgs);
3366 if (object_is_cursed(o_ptr))
3368 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3369 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3372 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3375 msg_format("The black aura on %s %s disrupts the blessing!",
3376 ((item >= 0) ? "your" : "the"), o_name);
3383 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3386 msg_format("A malignant aura leaves %s %s.",
3387 ((item >= 0) ? "your" : "the"), o_name);
3392 o_ptr->curse_flags = 0L;
3394 /* Hack -- Assume felt */
3395 o_ptr->ident |= (IDENT_SENSE);
3398 o_ptr->feeling = FEEL_NONE;
3400 /* Recalculate the bonuses */
3401 p_ptr->update |= (PU_BONUS);
3404 p_ptr->window |= (PW_EQUIP);
3408 * Next, we try to bless it. Artifacts have a 1/3 chance of
3409 * being blessed, otherwise, the operation simply disenchants
3410 * them, godly power negating the magic. Ok, the explanation
3411 * is silly, but otherwise priests would always bless every
3412 * artifact weapon they find. Ego weapons and normal weapons
3413 * can be blessed automatically.
3415 if (have_flag(flgs, TR_BLESSED))
3418 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3421 msg_format("%s %s %s blessed already.",
3422 ((item >= 0) ? "Your" : "The"), o_name,
3423 ((o_ptr->number > 1) ? "were" : "was"));
3429 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3433 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3436 msg_format("%s %s shine%s!",
3437 ((item >= 0) ? "Your" : "The"), o_name,
3438 ((o_ptr->number > 1) ? "" : "s"));
3441 add_flag(o_ptr->art_flags, TR_BLESSED);
3442 o_ptr->discount = 99;
3446 bool dis_happened = FALSE;
3449 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3451 msg_print("The weapon resists your blessing!");
3455 /* Disenchant tohit */
3456 if (o_ptr->to_h > 0)
3459 dis_happened = TRUE;
3462 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3464 /* Disenchant todam */
3465 if (o_ptr->to_d > 0)
3468 dis_happened = TRUE;
3471 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3473 /* Disenchant toac */
3474 if (o_ptr->to_a > 0)
3477 dis_happened = TRUE;
3480 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3485 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3487 msg_print("There is a static feeling in the air...");
3491 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3494 msg_format("%s %s %s disenchanted!",
3495 ((item >= 0) ? "Your" : "The"), o_name,
3496 ((o_ptr->number > 1) ? "were" : "was"));
3502 /* Recalculate bonuses */
3503 p_ptr->update |= (PU_BONUS);
3506 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3517 bool pulish_shield(void)
3521 u32b flgs[TR_FLAG_SIZE];
3522 char o_name[MAX_NLEN];
3525 item_tester_no_ryoute = TRUE;
3526 /* Assume enchant weapon */
3527 item_tester_tval = TV_SHIELD;
3531 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3532 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3534 q = "Pulish which weapon? ";
3535 s = "You have weapon to pulish.";
3538 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3541 /* Get the item (in the pack) */
3544 o_ptr = &inventory[item];
3547 /* Get the item (on the floor) */
3550 o_ptr = &o_list[0 - item];
3555 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3557 /* Extract the flags */
3558 object_flags(o_ptr, flgs);
3560 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3561 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3564 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3566 msg_format("%s %s shine%s!",
3567 ((item >= 0) ? "Your" : "The"), o_name,
3568 ((o_ptr->number > 1) ? "" : "s"));
3570 o_ptr->name2 = EGO_REFLECTION;
3571 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3573 o_ptr->discount = 99;
3574 chg_virtue(V_ENCHANT, 2);
3580 if (flush_failure) flush();
3583 msg_print("¼ºÇÔ¤·¤¿¡£");
3585 msg_print("Failed.");
3588 chg_virtue(V_ENCHANT, -2);
3597 * Potions "smash open" and cause an area effect when
3598 * (1) they are shattered while in the player's inventory,
3599 * due to cold (etc) attacks;
3600 * (2) they are thrown at a monster, or obstacle;
3601 * (3) they are shattered by a "cold ball" or other such spell
3602 * while lying on the floor.
3605 * who --- who caused the potion to shatter (0=player)
3606 * potions that smash on the floor are assumed to
3607 * be caused by no-one (who = 1), as are those that
3608 * shatter inside the player inventory.
3609 * (Not anymore -- I changed this; TY)
3610 * y, x --- coordinates of the potion (or player if
3611 * the potion was in her inventory);
3612 * o_ptr --- pointer to the potion object.
3614 bool potion_smash_effect(int who, int y, int x, int k_idx)
3621 object_kind *k_ptr = &k_info[k_idx];
3623 switch (k_ptr->sval)
3625 case SV_POTION_SALT_WATER:
3626 case SV_POTION_SLIME_MOLD:
3627 case SV_POTION_LOSE_MEMORIES:
3628 case SV_POTION_DEC_STR:
3629 case SV_POTION_DEC_INT:
3630 case SV_POTION_DEC_WIS:
3631 case SV_POTION_DEC_DEX:
3632 case SV_POTION_DEC_CON:
3633 case SV_POTION_DEC_CHR:
3634 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3635 case SV_POTION_APPLE_JUICE:
3638 case SV_POTION_INFRAVISION:
3639 case SV_POTION_DETECT_INVIS:
3640 case SV_POTION_SLOW_POISON:
3641 case SV_POTION_CURE_POISON:
3642 case SV_POTION_BOLDNESS:
3643 case SV_POTION_RESIST_HEAT:
3644 case SV_POTION_RESIST_COLD:
3645 case SV_POTION_HEROISM:
3646 case SV_POTION_BESERK_STRENGTH:
3647 case SV_POTION_RES_STR:
3648 case SV_POTION_RES_INT:
3649 case SV_POTION_RES_WIS:
3650 case SV_POTION_RES_DEX:
3651 case SV_POTION_RES_CON:
3652 case SV_POTION_RES_CHR:
3653 case SV_POTION_INC_STR:
3654 case SV_POTION_INC_INT:
3655 case SV_POTION_INC_WIS:
3656 case SV_POTION_INC_DEX:
3657 case SV_POTION_INC_CON:
3658 case SV_POTION_INC_CHR:
3659 case SV_POTION_AUGMENTATION:
3660 case SV_POTION_ENLIGHTENMENT:
3661 case SV_POTION_STAR_ENLIGHTENMENT:
3662 case SV_POTION_SELF_KNOWLEDGE:
3663 case SV_POTION_EXPERIENCE:
3664 case SV_POTION_RESISTANCE:
3665 case SV_POTION_INVULNERABILITY:
3666 case SV_POTION_NEW_LIFE:
3667 /* All of the above potions have no effect when shattered */
3669 case SV_POTION_SLOWNESS:
3674 case SV_POTION_POISON:
3679 case SV_POTION_BLINDNESS:
3683 case SV_POTION_CONFUSION: /* Booze */
3687 case SV_POTION_SLEEP:
3691 case SV_POTION_RUINATION:
3692 case SV_POTION_DETONATIONS:
3694 dam = damroll(25, 25);
3697 case SV_POTION_DEATH:
3698 dt = GF_DEATH_RAY; /* !! */
3699 dam = k_ptr->level * 10;
3703 case SV_POTION_SPEED:
3706 case SV_POTION_CURE_LIGHT:
3708 dam = damroll(2, 3);
3710 case SV_POTION_CURE_SERIOUS:
3712 dam = damroll(4, 3);
3714 case SV_POTION_CURE_CRITICAL:
3715 case SV_POTION_CURING:
3717 dam = damroll(6, 3);
3719 case SV_POTION_HEALING:
3721 dam = damroll(10, 10);
3723 case SV_POTION_RESTORE_EXP:
3728 case SV_POTION_LIFE:
3730 dam = damroll(50, 50);
3733 case SV_POTION_STAR_HEALING:
3735 dam = damroll(50, 50);
3738 case SV_POTION_RESTORE_MANA: /* MANA */
3740 dam = damroll(10, 10);
3747 (void)project(who, radius, y, x, dam, dt,
3748 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3750 /* XXX those potions that explode need to become "known" */
3756 * Hack -- Display all known spells in a window
3758 * XXX XXX XXX Need to analyze size of the window.
3760 * XXX XXX XXX Need more color coding.
3762 void display_spell_list(void)
3775 /* They have too many spells to list */
3776 if (p_ptr->pclass == CLASS_SORCERER) return;
3777 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3779 /* mind.c type classes */
3780 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3781 (p_ptr->pclass == CLASS_BERSERKER) ||
3782 (p_ptr->pclass == CLASS_NINJA) ||
3783 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3784 (p_ptr->pclass == CLASS_FORCETRAINER))
3790 int plev = p_ptr->lev;
3796 bool use_hp = FALSE;
3798 /* Display a list of spells */
3801 put_str("̾Á°", y, x + 5);
3802 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3804 put_str("Name", y, x + 5);
3805 put_str("Lv Mana Fail Info", y, x + 35);
3808 switch(p_ptr->pclass)
3810 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3811 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3812 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3813 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3814 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3815 default: use_mind = 0;break;
3818 /* Dump the spells */
3819 for (i = 0; i < MAX_MIND_POWERS; i++)
3821 byte a = TERM_WHITE;
3823 /* Access the available spell */
3824 spell = mind_powers[use_mind].info[i];
3825 if (spell.min_lev > plev) break;
3827 /* Get the failure rate */
3828 chance = spell.fail;
3830 /* Reduce failure rate by "effective" level adjustment */
3831 chance -= 3 * (p_ptr->lev - spell.min_lev);
3833 /* Reduce failure rate by INT/WIS adjustment */
3834 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3838 /* Not enough mana to cast */
3839 if (spell.mana_cost > p_ptr->csp)
3841 chance += 5 * (spell.mana_cost - p_ptr->csp);
3847 /* Not enough hp to cast */
3848 if (spell.mana_cost > p_ptr->chp)
3855 /* Extract the minimum failure rate */
3856 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3858 /* Minimum failure rate */
3859 if (chance < minfail) chance = minfail;
3861 /* Stunning makes spells harder */
3862 if (p_ptr->stun > 50) chance += 25;
3863 else if (p_ptr->stun) chance += 15;
3865 /* Always a 5 percent chance of working */
3866 if (chance > 95) chance = 95;
3869 mindcraft_info(comment, use_mind, i);
3871 /* Dump the spell */
3872 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3874 spell.min_lev, spell.mana_cost, chance, comment);
3876 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3881 /* Cannot read spellbooks */
3882 if (REALM_NONE == p_ptr->realm1) return;
3884 /* Normal spellcaster with books */
3887 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3891 /* Reset vertical */
3894 /* Vertical location */
3895 y = (j < 3) ? 0 : (m[j - 3] + 2);
3897 /* Horizontal location */
3901 for (i = 0; i < 32; i++)
3903 byte a = TERM_WHITE;
3905 /* Access the spell */
3906 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3908 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3912 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3915 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
3918 if (s_ptr->slevel >= 99)
3922 strcpy(name, "(ȽÆÉÉÔǽ)");
3924 strcpy(name, "(illegible)");
3934 ((p_ptr->spell_forgotten1 & (1L << i))) :
3935 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3942 else if (!((j < 1) ?
3943 (p_ptr->spell_learned1 & (1L << i)) :
3944 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3951 else if (!((j < 1) ?
3952 (p_ptr->spell_worked1 & (1L << i)) :
3953 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3959 /* Dump the spell --(-- */
3960 sprintf(out_val, "%c/%c) %-20.20s",
3961 I2A(n / 8), I2A(n % 8), name);
3966 /* Dump onto the window */
3967 Term_putstr(x, m[j], -1, a, out_val);
3977 * Returns experience of a spell
3979 s16b experience_of_spell(int spell, int use_realm)
3981 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3982 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3983 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3984 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3990 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3992 int mod_need_mana(int need_mana, int spell, int realm)
3994 #define MANA_CONST 2400
3996 #define DEC_MANA_DIV 3
3999 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4002 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4003 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4005 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4006 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4007 need_mana /= MANA_CONST * MANA_DIV;
4008 if (need_mana < 1) need_mana = 1;
4011 /* Non-realm magic */
4014 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4026 * Modify spell fail rate
4027 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4029 int mod_spell_chance_1(int chance)
4031 chance += p_ptr->to_m_chance;
4033 if (p_ptr->heavy_spell) chance += 20;
4035 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4036 else if (p_ptr->easy_spell) chance -= 3;
4037 else if (p_ptr->dec_mana) chance -= 2;
4044 * Modify spell fail rate (as "suffix" process)
4045 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4046 * Note: variable "chance" cannot be negative.
4048 int mod_spell_chance_2(int chance)
4050 if (p_ptr->dec_mana) chance--;
4052 if (p_ptr->heavy_spell) chance += 5;
4054 return MAX(chance, 0);
4059 * Returns spell chance of failure for spell -RAK-
4061 s16b spell_chance(int spell, int use_realm)
4063 int chance, minfail;
4066 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4069 /* Paranoia -- must be literate */
4070 if (!mp_ptr->spell_book) return (100);
4072 if (use_realm == REALM_HISSATSU) return 0;
4074 /* Access the spell */
4075 if (!is_magic(use_realm))
4077 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4081 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4084 /* Extract the base spell failure rate */
4085 chance = s_ptr->sfail;
4087 /* Reduce failure rate by "effective" level adjustment */
4088 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4090 /* Reduce failure rate by INT/WIS adjustment */
4091 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4094 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4096 /* Extract mana consumption rate */
4097 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4099 /* Not enough mana to cast */
4100 if (need_mana > p_ptr->csp)
4102 chance += 5 * (need_mana - p_ptr->csp);
4105 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4107 /* Extract the minimum failure rate */
4108 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4111 * Non mage/priest characters never get too good
4112 * (added high mage, mindcrafter)
4114 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4116 if (minfail < 5) minfail = 5;
4119 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4120 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4121 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4123 chance = mod_spell_chance_1(chance);
4125 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4126 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4127 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4129 /* Minimum failure rate */
4130 if (chance < minfail) chance = minfail;
4132 /* Stunning makes spells harder */
4133 if (p_ptr->stun > 50) chance += 25;
4134 else if (p_ptr->stun) chance += 15;
4136 /* Always a 5 percent chance of working */
4137 if (chance > 95) chance = 95;
4139 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4140 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4142 s16b exp = experience_of_spell(spell, use_realm);
4143 if (exp >= SPELL_EXP_EXPERT) chance--;
4144 if (exp >= SPELL_EXP_MASTER) chance--;
4147 /* Return the chance */
4148 return mod_spell_chance_2(chance);
4154 * Determine if a spell is "okay" for the player to cast or study
4155 * The spell must be legible, not forgotten, and also, to cast,
4156 * it must be known, and to study, it must not be known.
4158 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4162 /* Access the spell */
4163 if (!is_magic(use_realm))
4165 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4169 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4172 /* Spell is illegal */
4173 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4175 /* Spell is forgotten */
4176 if ((use_realm == p_ptr->realm2) ?
4177 (p_ptr->spell_forgotten2 & (1L << spell)) :
4178 (p_ptr->spell_forgotten1 & (1L << spell)))
4184 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4185 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4187 /* Spell is learned */
4188 if ((use_realm == p_ptr->realm2) ?
4189 (p_ptr->spell_learned2 & (1L << spell)) :
4190 (p_ptr->spell_learned1 & (1L << spell)))
4193 return (!study_pray);
4196 /* Okay to study, not to cast */
4203 * Extra information on a spell -DRS-
4205 * We can use up to 14 characters of the buffer 'p'
4207 * The strings in this function were extracted from the code in the
4208 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4210 static void spell_info(char *p, int spell, int use_realm)
4212 int plev = p_ptr->lev;
4215 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4216 p_ptr->pclass == CLASS_HIGH_MAGE ||
4217 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4219 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4220 p_ptr->pclass == CLASS_HIGH_MAGE ||
4221 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4223 cptr s_dam = "»½ý:";
4224 cptr s_dur = "´ü´Ö:";
4225 cptr s_range = "ÈÏ°Ï:";
4226 cptr s_heal = "²óÉü:";
4227 cptr s_random = "¥é¥ó¥À¥à";
4228 cptr s_delay = "ÃÙ±ä:";
4230 cptr s_dam = "dam ";
4231 cptr s_dur = "dur ";
4232 cptr s_range = "range ";
4233 cptr s_heal = "heal ";
4234 cptr s_random = "random";
4235 cptr s_delay = "delay ";
4240 /* Analyze the spell */
4243 case REALM_LIFE: /* Life */
4246 case 0: sprintf(p, " %s2d10", s_heal); break;
4247 case 1: sprintf(p, " %s12+d12", s_dur); break;
4248 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4249 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4250 case 5: sprintf(p, " %s4d10", s_heal); break;
4251 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4252 case 10: sprintf(p, " %s8d10", s_heal); break;
4253 case 11: sprintf(p, " %s20+d20", s_dur); break;
4254 case 14: sprintf(p, " %s300", s_heal); break;
4255 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4256 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4257 case 21: sprintf(p, " %s15+d21", s_delay); break;
4258 case 29: sprintf(p, " %s2000", s_heal); break;
4259 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4263 case REALM_SORCERY: /* Sorcery */
4266 case 1: sprintf(p, " %s10", s_range); break;
4267 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4268 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4269 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4270 case 18: sprintf(p, " %s25+d30", s_dur); break;
4271 case 22: sprintf(p, " %s15+d21", s_delay); break;
4272 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4273 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4275 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4277 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4279 case 27: sprintf(p, " %s25+d30", s_dur); break;
4280 case 31: sprintf(p, " %s4+d4", s_dur); break;
4284 case REALM_NATURE: /* Nature */
4288 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4290 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4292 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4293 case 6: sprintf(p, " %s20+d20", s_dur); break;
4294 case 7: sprintf(p, " %s2d8", s_heal); break;
4295 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4296 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4297 case 12: sprintf(p, " %s6d8", s_dam); break;
4298 case 15: sprintf(p, " %s500", s_heal); break;
4299 case 17: sprintf(p, " %s20+d30", s_dur); break;
4300 case 18: sprintf(p, " %s20+d20", s_dur); break;
4302 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4304 case 24: sprintf(p, " rad 10"); break;
4306 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4307 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4308 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4309 case 29: sprintf(p, " %s75", s_dam); break;
4310 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4314 case REALM_CHAOS: /* Chaos */
4317 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4318 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4319 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4320 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4321 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4322 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4323 case 8: sprintf(p, " %s", s_random); break;
4324 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4325 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4326 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4327 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4328 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4329 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4330 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4331 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4332 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4334 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4336 case 25: sprintf(p, " dam %d each", plev * 2); break;
4338 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4339 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4340 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4341 case 30: sprintf(p, " %s%ld", s_dam, p_ptr->chp); break;
4342 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4346 case REALM_DEATH: /* Death */
4349 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4350 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4351 case 5: sprintf(p, " %s20+d20", s_dur); break;
4352 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4353 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4354 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4356 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4358 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4360 case 16: sprintf(p, " %s25+d25", s_dur); break;
4361 case 17: sprintf(p, " %s", s_random); break;
4362 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4363 case 19: sprintf(p, " %s25+d25", s_dur); break;
4364 case 21: sprintf(p, " %s3*100", s_dam); break;
4365 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4366 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4367 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4368 case 30: sprintf(p, " %s666", s_dam); break;
4369 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4373 case REALM_TRUMP: /* Trump */
4376 case 0: sprintf(p, " %s10", s_range); break;
4377 case 2: sprintf(p, " %s", s_random); break;
4378 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4379 case 5: sprintf(p, " %s25+d30", s_dur); break;
4381 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4383 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4385 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4386 case 14: sprintf(p, " %s15+d21", s_delay); break;
4387 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4389 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4391 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4396 case REALM_ARCANE: /* Arcane */
4399 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4400 case 4: sprintf(p, " %s10", s_range); break;
4401 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4402 case 7: sprintf(p, " %s2d8", s_heal); break;
4406 case 17: sprintf(p, " %s20+d20", s_dur); break;
4407 case 18: sprintf(p, " %s4d8", s_heal); break;
4408 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4409 case 21: sprintf(p, " %s6d8", s_dam); break;
4410 case 24: sprintf(p, " %s24+d24", s_dur); break;
4411 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4412 case 30: sprintf(p, " %s15+d21", s_delay); break;
4413 case 31: sprintf(p, " %s25+d30", s_dur); break;
4417 case REALM_ENCHANT: /* Craft */
4420 case 0: sprintf(p, " %s100+d100", s_dur); break;
4421 case 1: sprintf(p, " %s80+d80", s_dur); break;
4427 case 18: sprintf(p, " %s20+d20", s_dur); break;
4428 case 5: sprintf(p, " %s25+d25", s_dur); break;
4429 case 8: sprintf(p, " %s24+d24", s_dur); break;
4430 case 11: sprintf(p, " %s25+d25", s_dur); break;
4431 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4432 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4433 case 16: sprintf(p, " %s25+d30", s_dur); break;
4434 case 17: sprintf(p, " %s30+d20", s_dur); break;
4435 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4436 case 20: sprintf(p, " %s50+d50", s_dur); break;
4437 case 23: sprintf(p, " %s20+d20", s_dur); break;
4438 case 31: sprintf(p, " %s13+d13", s_dur); break;
4442 case REALM_DAEMON: /* Daemon */
4445 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4446 case 2: sprintf(p, " %s12+d12", s_dur); break;
4447 case 3: sprintf(p, " %s20+d20", s_dur); break;
4448 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4449 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4450 case 10: sprintf(p, " %s20+d20", s_dur); break;
4451 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4452 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4453 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4454 case 16: sprintf(p, " %s30+d25", s_dur); break;
4455 case 17: sprintf(p, " %s20+d20", s_dur); break;
4456 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4457 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4458 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4459 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4460 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4461 case 24: sprintf(p, " %s25+d25", s_dur); break;
4462 case 25: sprintf(p, " %s20+d20", s_dur); break;
4463 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4464 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4465 case 30: sprintf(p, " %s600", s_dam); break;
4466 case 31: sprintf(p, " %s15+d15", s_dur); break;
4470 case REALM_CRUSADE: /* Crusade */
4473 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4474 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4476 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4478 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4480 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4481 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4482 case 12: sprintf(p, " %s24+d24", s_dur); break;
4483 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4484 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4486 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4488 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4490 case 18: sprintf(p, " %s18+d18", s_dur); break;
4491 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4492 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4493 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4494 case 24: sprintf(p, " %s25+d25", s_dur); break;
4495 case 28: sprintf(p, " %s10+d10", s_dur); break;
4497 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4499 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4502 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4504 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4509 case REALM_MUSIC: /* Music */
4512 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4513 case 4 : sprintf(p, " %s2d6", s_heal); break;
4514 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4515 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4516 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4517 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4518 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4519 case 28: sprintf(p, " %s15d10", s_heal); break;
4520 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4525 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4527 sprintf(p, "Unknown type: %d.", use_realm);
4534 * Print a list of spells (for browsing or casting or viewing)
4536 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4538 int i, spell, exp_level, increment = 64;
4550 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4552 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4554 msg_print("Warning! print_spells called with null realm");
4558 /* Title the list */
4560 if (use_realm == REALM_HISSATSU)
4562 strcpy(buf," Lv MP");
4564 strcpy(buf," Lv SP");
4568 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4570 strcpy(buf,"Profic Lv SP Fail Effect");
4574 put_str("̾Á°", y, x + 5);
4575 put_str(buf, y, x + 29);
4577 put_str("Name", y, x + 5);
4578 put_str(buf, y, x + 29);
4581 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4582 else if (use_realm == p_ptr->realm1) increment = 0;
4583 else if (use_realm == p_ptr->realm2) increment = 32;
4585 /* Dump the spells */
4586 for (i = 0; i < num; i++)
4588 /* Access the spell */
4591 /* Access the spell */
4592 if (!is_magic(use_realm))
4594 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4598 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4601 if (use_realm == REALM_HISSATSU)
4602 need_mana = s_ptr->smana;
4605 s16b exp = experience_of_spell(spell, use_realm);
4607 /* Extract mana consumption rate */
4608 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4610 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4611 else exp_level = spell_exp_level(exp);
4614 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4615 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4616 else if (s_ptr->slevel >= 99) max = TRUE;
4617 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4619 strncpy(ryakuji, exp_level_str[exp_level], 4);
4624 if (use_menu && target_spell)
4626 if (i == (target_spell-1))
4628 strcpy(out_val, " ¡Õ ");
4630 strcpy(out_val, " > ");
4633 strcpy(out_val, " ");
4635 else sprintf(out_val, " %c) ", I2A(i));
4636 /* Skip illegible spells */
4637 if (s_ptr->slevel >= 99)
4640 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4642 strcat(out_val, format("%-30s", "(illegible)"));
4645 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4649 /* XXX XXX Could label spells above the players level */
4651 /* Get extra info */
4652 spell_info(info, spell, use_realm);
4657 /* Assume spell is known and tried */
4658 line_attr = TERM_WHITE;
4660 /* Analyze the spell */
4661 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4663 if (s_ptr->slevel > p_ptr->max_plv)
4668 comment = " unknown";
4671 line_attr = TERM_L_BLUE;
4673 else if (s_ptr->slevel > p_ptr->lev)
4678 comment = " forgotten";
4681 line_attr = TERM_YELLOW;
4684 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4689 comment = " unknown";
4692 line_attr = TERM_L_BLUE;
4694 else if ((use_realm == p_ptr->realm1) ?
4695 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4696 ((p_ptr->spell_forgotten2 & (1L << spell))))
4701 comment = " forgotten";
4704 line_attr = TERM_YELLOW;
4706 else if (!((use_realm == p_ptr->realm1) ?
4707 (p_ptr->spell_learned1 & (1L << spell)) :
4708 (p_ptr->spell_learned2 & (1L << spell))))
4713 comment = " unknown";
4716 line_attr = TERM_L_BLUE;
4718 else if (!((use_realm == p_ptr->realm1) ?
4719 (p_ptr->spell_worked1 & (1L << spell)) :
4720 (p_ptr->spell_worked2 & (1L << spell))))
4723 comment = " ̤·Ð¸³";
4725 comment = " untried";
4728 line_attr = TERM_L_GREEN;
4731 /* Dump the spell --(-- */
4732 if (use_realm == REALM_HISSATSU)
4734 strcat(out_val, format("%-25s %2d %4d",
4735 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4736 s_ptr->slevel, need_mana));
4740 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4741 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4742 (max ? '!' : ' '), ryakuji,
4743 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4745 c_prt(line_attr, out_val, y + i + 1, x);
4748 /* Clear the bottom line */
4749 prt("", y + i + 1, x);
4754 * Note that amulets, rods, and high-level spell books are immune
4755 * to "inventory damage" of any kind. Also sling ammo and shovels.
4760 * Does a given class of objects (usually) hate acid?
4761 * Note that acid can either melt or corrode something.
4763 bool hates_acid(object_type *o_ptr)
4765 /* Analyze the type */
4766 switch (o_ptr->tval)
4768 /* Wearable items */
4788 /* Staffs/Scrolls are wood/paper */
4801 /* Junk is useless */
4815 * Does a given object (usually) hate electricity?
4817 bool hates_elec(object_type *o_ptr)
4819 switch (o_ptr->tval)
4833 * Does a given object (usually) hate fire?
4834 * Hafted/Polearm weapons have wooden shafts.
4835 * Arrows/Bows are mostly wooden.
4837 bool hates_fire(object_type *o_ptr)
4839 /* Analyze the type */
4840 switch (o_ptr->tval)
4858 case TV_SORCERY_BOOK:
4859 case TV_NATURE_BOOK:
4863 case TV_ARCANE_BOOK:
4864 case TV_ENCHANT_BOOK:
4865 case TV_DAEMON_BOOK:
4866 case TV_CRUSADE_BOOK:
4868 case TV_HISSATSU_BOOK:
4879 /* Staffs/Scrolls burn */
4892 * Does a given object (usually) hate cold?
4894 bool hates_cold(object_type *o_ptr)
4896 switch (o_ptr->tval)
4913 int set_acid_destroy(object_type *o_ptr)
4915 u32b flgs[TR_FLAG_SIZE];
4916 if (!hates_acid(o_ptr)) return (FALSE);
4917 object_flags(o_ptr, flgs);
4918 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4926 int set_elec_destroy(object_type *o_ptr)
4928 u32b flgs[TR_FLAG_SIZE];
4929 if (!hates_elec(o_ptr)) return (FALSE);
4930 object_flags(o_ptr, flgs);
4931 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4939 int set_fire_destroy(object_type *o_ptr)
4941 u32b flgs[TR_FLAG_SIZE];
4942 if (!hates_fire(o_ptr)) return (FALSE);
4943 object_flags(o_ptr, flgs);
4944 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4952 int set_cold_destroy(object_type *o_ptr)
4954 u32b flgs[TR_FLAG_SIZE];
4955 if (!hates_cold(o_ptr)) return (FALSE);
4956 object_flags(o_ptr, flgs);
4957 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4963 * Destroys a type of item on a given percent chance
4964 * Note that missiles are no longer necessarily all destroyed
4965 * Destruction taken from "melee.c" code for "stealing".
4966 * New-style wands and rods handled correctly. -LM-
4967 * Returns number of items destroyed.
4969 int inven_damage(inven_func typ, int perc)
4973 char o_name[MAX_NLEN];
4975 /* Multishadow effects is determined by turn */
4976 if( p_ptr->multishadow && (turn & 1) )return 0;
4978 if (p_ptr->inside_arena) return 0;
4980 /* Count the casualties */
4983 /* Scan through the slots backwards */
4984 for (i = 0; i < INVEN_PACK; i++)
4986 o_ptr = &inventory[i];
4988 /* Skip non-objects */
4989 if (!o_ptr->k_idx) continue;
4991 /* Hack -- for now, skip artifacts */
4992 if (object_is_artifact(o_ptr)) continue;
4994 /* Give this item slot a shot at death */
4997 /* Count the casualties */
4998 for (amt = j = 0; j < o_ptr->number; ++j)
5000 if (randint0(100) < perc) amt++;
5003 /* Some casualities */
5006 /* Get a description */
5007 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5011 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
5013 msg_format("%sour %s (%c) %s destroyed!",
5017 o_name, index_to_label(i),
5018 ((o_ptr->number > 1) ?
5019 ((amt == o_ptr->number) ? "Á´Éô" :
5020 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
5022 ((o_ptr->number > 1) ?
5023 ((amt == o_ptr->number) ? "All of y" :
5024 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
5025 o_name, index_to_label(i),
5026 ((amt > 1) ? "were" : "was"));
5030 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
5031 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
5034 /* Potions smash open */
5035 if (object_is_potion(o_ptr))
5037 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
5040 /* Reduce the charges of rods/wands */
5041 reduce_charges(o_ptr, amt);
5043 /* Destroy "amt" items */
5044 inven_item_increase(i, -amt);
5045 inven_item_optimize(i);
5047 /* Count the casualties */
5053 /* Return the casualty count */
5059 * Acid has hit the player, attempt to affect some armor.
5061 * Note that the "base armor" of an object never changes.
5063 * If any armor is damaged (or resists), the player takes less damage.
5065 static int minus_ac(void)
5067 object_type *o_ptr = NULL;
5068 u32b flgs[TR_FLAG_SIZE];
5069 char o_name[MAX_NLEN];
5072 /* Pick a (possibly empty) inventory slot */
5073 switch (randint1(7))
5075 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5076 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5077 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5078 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5079 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5080 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5081 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5084 /* Nothing to damage */
5085 if (!o_ptr->k_idx) return (FALSE);
5087 if (!object_is_armour(o_ptr)) return (FALSE);
5089 /* No damage left to be done */
5090 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5094 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5096 /* Extract the flags */
5097 object_flags(o_ptr, flgs);
5099 /* Object resists */
5100 if (have_flag(flgs, TR_IGNORE_ACID))
5103 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5105 msg_format("Your %s is unaffected!", o_name);
5114 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5116 msg_format("Your %s is damaged!", o_name);
5120 /* Damage the item */
5123 /* Calculate bonuses */
5124 p_ptr->update |= (PU_BONUS);
5127 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5131 /* Item was damaged */
5137 * Hurt the player with Acid
5139 int acid_dam(int dam, cptr kb_str, int monspell)
5142 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5143 bool double_resist = IS_OPPOSE_ACID();
5145 /* Total Immunity */
5146 if (p_ptr->immune_acid || (dam <= 0))
5148 learn_spell(monspell);
5152 /* Vulnerability (Ouch!) */
5153 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5154 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5156 /* Resist the damage */
5157 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5158 if (double_resist) dam = (dam + 2) / 3;
5160 if ((!(double_resist || p_ptr->resist_acid)) &&
5161 one_in_(HURT_CHANCE))
5162 (void)do_dec_stat(A_CHR);
5164 /* If any armor gets hit, defend the player */
5165 if (minus_ac()) dam = (dam + 1) / 2;
5168 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5170 /* Inventory damage */
5171 if (!(double_resist && p_ptr->resist_acid))
5172 inven_damage(set_acid_destroy, inv);
5178 * Hurt the player with electricity
5180 int elec_dam(int dam, cptr kb_str, int monspell)
5183 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5184 bool double_resist = IS_OPPOSE_ELEC();
5186 /* Total immunity */
5187 if (p_ptr->immune_elec || (dam <= 0))
5189 learn_spell(monspell);
5193 /* Vulnerability (Ouch!) */
5194 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5195 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5196 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5198 /* Resist the damage */
5199 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5200 if (double_resist) dam = (dam + 2) / 3;
5202 if ((!(double_resist || p_ptr->resist_elec)) &&
5203 one_in_(HURT_CHANCE))
5204 (void)do_dec_stat(A_DEX);
5207 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5209 /* Inventory damage */
5210 if (!(double_resist && p_ptr->resist_elec))
5211 inven_damage(set_elec_destroy, inv);
5218 * Hurt the player with Fire
5220 int fire_dam(int dam, cptr kb_str, int monspell)
5223 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5224 bool double_resist = IS_OPPOSE_FIRE();
5226 /* Totally immune */
5227 if (p_ptr->immune_fire || (dam <= 0))
5229 learn_spell(monspell);
5233 /* Vulnerability (Ouch!) */
5234 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5235 if (prace_is_(RACE_ENT)) dam += dam / 3;
5236 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5238 /* Resist the damage */
5239 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5240 if (double_resist) dam = (dam + 2) / 3;
5242 if ((!(double_resist || p_ptr->resist_fire)) &&
5243 one_in_(HURT_CHANCE))
5244 (void)do_dec_stat(A_STR);
5247 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5249 /* Inventory damage */
5250 if (!(double_resist && p_ptr->resist_fire))
5251 inven_damage(set_fire_destroy, inv);
5258 * Hurt the player with Cold
5260 int cold_dam(int dam, cptr kb_str, int monspell)
5263 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5264 bool double_resist = IS_OPPOSE_COLD();
5266 /* Total immunity */
5267 if (p_ptr->immune_cold || (dam <= 0))
5269 learn_spell(monspell);
5273 /* Vulnerability (Ouch!) */
5274 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5275 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5277 /* Resist the damage */
5278 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5279 if (double_resist) dam = (dam + 2) / 3;
5281 if ((!(double_resist || p_ptr->resist_cold)) &&
5282 one_in_(HURT_CHANCE))
5283 (void)do_dec_stat(A_STR);
5286 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5288 /* Inventory damage */
5289 if (!(double_resist && p_ptr->resist_cold))
5290 inven_damage(set_cold_destroy, inv);
5296 bool rustproof(void)
5300 char o_name[MAX_NLEN];
5303 item_tester_no_ryoute = TRUE;
5304 /* Select a piece of armour */
5305 item_tester_hook = object_is_armour;
5309 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5310 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5312 q = "Rustproof which piece of armour? ";
5313 s = "You have nothing to rustproof.";
5316 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5318 /* Get the item (in the pack) */
5321 o_ptr = &inventory[item];
5324 /* Get the item (on the floor) */
5327 o_ptr = &o_list[0 - item];
5332 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5334 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5336 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
5339 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5341 msg_format("%s %s look%s as good as new!",
5342 ((item >= 0) ? "Your" : "The"), o_name,
5343 ((o_ptr->number > 1) ? "" : "s"));
5350 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5352 msg_format("%s %s %s now protected against corrosion.",
5353 ((item >= 0) ? "Your" : "The"), o_name,
5354 ((o_ptr->number > 1) ? "are" : "is"));
5365 * Curse the players armor
5367 bool curse_armor(void)
5372 char o_name[MAX_NLEN];
5375 /* Curse the body armor */
5376 o_ptr = &inventory[INVEN_BODY];
5378 /* Nothing to curse */
5379 if (!o_ptr->k_idx) return (FALSE);
5383 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5385 /* Attempt a saving throw for artifacts */
5386 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
5390 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5391 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5393 msg_format("A %s tries to %s, but your %s resists the effects!",
5394 "terrible black aura", "surround your armor", o_name);
5399 /* not artifact or failed save... */
5404 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5406 msg_format("A terrible black aura blasts your %s!", o_name);
5409 chg_virtue(V_ENCHANT, -5);
5411 /* Blast the armor */
5413 o_ptr->name2 = EGO_BLASTED;
5414 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5421 for (i = 0; i < TR_FLAG_SIZE; i++)
5422 o_ptr->art_flags[i] = 0;
5425 o_ptr->curse_flags = TRC_CURSED;
5428 o_ptr->ident |= (IDENT_BROKEN);
5430 /* Recalculate bonuses */
5431 p_ptr->update |= (PU_BONUS);
5433 /* Recalculate mana */
5434 p_ptr->update |= (PU_MANA);
5437 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5445 * Curse the players weapon
5447 bool curse_weapon(bool force, int slot)
5453 char o_name[MAX_NLEN];
5456 /* Curse the weapon */
5457 o_ptr = &inventory[slot];
5459 /* Nothing to curse */
5460 if (!o_ptr->k_idx) return (FALSE);
5464 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5466 /* Attempt a saving throw */
5467 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
5471 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5472 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5474 msg_format("A %s tries to %s, but your %s resists the effects!",
5475 "terrible black aura", "surround your weapon", o_name);
5480 /* not artifact or failed save... */
5485 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5487 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5490 chg_virtue(V_ENCHANT, -5);
5492 /* Shatter the weapon */
5494 o_ptr->name2 = EGO_SHATTERED;
5495 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5496 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5502 for (i = 0; i < TR_FLAG_SIZE; i++)
5503 o_ptr->art_flags[i] = 0;
5507 o_ptr->curse_flags = TRC_CURSED;
5510 o_ptr->ident |= (IDENT_BROKEN);
5512 /* Recalculate bonuses */
5513 p_ptr->update |= (PU_BONUS);
5515 /* Recalculate mana */
5516 p_ptr->update |= (PU_MANA);
5519 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5528 * Enchant some bolts
5530 bool brand_bolts(void)
5534 /* Use the first acceptable bolts */
5535 for (i = 0; i < INVEN_PACK; i++)
5537 object_type *o_ptr = &inventory[i];
5539 /* Skip non-bolts */
5540 if (o_ptr->tval != TV_BOLT) continue;
5542 /* Skip artifacts and ego-items */
5543 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5546 /* Skip cursed/broken items */
5547 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5550 if (randint0(100) < 75) continue;
5554 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5556 msg_print("Your bolts are covered in a fiery aura!");
5561 o_ptr->name2 = EGO_FLAME;
5564 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5571 if (flush_failure) flush();
5575 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5577 msg_print("The fiery enchantment failed.");
5587 * Helper function -- return a "nearby" race for polymorphing
5589 * Note that this function is one of the more "dangerous" ones...
5591 static s16b poly_r_idx(int r_idx)
5593 monster_race *r_ptr = &r_info[r_idx];
5595 int i, r, lev1, lev2;
5597 /* Hack -- Uniques/Questors never polymorph */
5598 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5599 (r_ptr->flags1 & RF1_QUESTOR))
5602 /* Allowable range of "levels" for resulting monster */
5603 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5604 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5606 /* Pick a (possibly new) non-unique race */
5607 for (i = 0; i < 1000; i++)
5609 /* Pick a new race, using a level calculation */
5610 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5612 /* Handle failure */
5618 /* Ignore unique monsters */
5619 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5621 /* Ignore monsters with incompatible levels */
5622 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5624 /* Use that index */
5636 bool polymorph_monster(int y, int x)
5638 cave_type *c_ptr = &cave[y][x];
5639 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5640 bool polymorphed = FALSE;
5642 int old_r_idx = m_ptr->r_idx;
5643 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5644 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5645 monster_type back_m;
5647 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5649 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5651 /* Memorize the monster before polymorphing */
5654 /* Pick a "new" monster race */
5655 new_r_idx = poly_r_idx(old_r_idx);
5657 /* Handle polymorph */
5658 if (new_r_idx != old_r_idx)
5662 /* Get the monsters attitude */
5663 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5664 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5665 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5667 /* "Kill" the "old" monster */
5668 delete_monster_idx(c_ptr->m_idx);
5670 /* Create a new monster (no groups) */
5671 if (place_monster_aux(0, y, x, new_r_idx, mode))
5678 /* Placing the new monster failed */
5679 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5680 m_list[hack_m_idx_ii] = back_m;
5683 if (targeted) target_who = hack_m_idx_ii;
5684 if (health_tracked) health_track(hack_m_idx_ii);
5694 static bool dimension_door_aux(int x, int y)
5696 int plev = p_ptr->lev;
5698 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5700 if (!cave_player_teleportable_bold(y, x, FALSE, FALSE) ||
5701 (distance(y, x, py, px) > plev / 2 + 10) ||
5702 (!randint0(plev / 10 + 10)))
5704 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5705 teleport_player((plev + 2) * 2, TRUE);
5712 teleport_player_to(y, x, TRUE, FALSE);
5723 bool dimension_door(void)
5727 /* Rerutn FALSE if cancelled */
5728 if (!tgt_pt(&x, &y)) return FALSE;
5730 if (dimension_door_aux(x, y)) return TRUE;
5733 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5735 msg_print("You fail to exit the astral plane correctly!");
5743 * Mirror Master's Dimension Door
5745 bool mirror_tunnel(void)
5749 /* Rerutn FALSE if cancelled */
5750 if (!tgt_pt(&x, &y)) return FALSE;
5752 if (dimension_door_aux(x, y)) return TRUE;
5755 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5757 msg_print("You fail to pass the mirror plane correctly!");
5764 bool eat_magic(int power)
5766 object_type * o_ptr;
5769 int recharge_strength = 0;
5775 char o_name[MAX_NLEN];
5777 item_tester_hook = item_tester_hook_recharge;
5781 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5782 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5784 q = "Drain which item? ";
5785 s = "You have nothing to drain.";
5788 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5792 o_ptr = &inventory[item];
5796 o_ptr = &o_list[0 - item];
5799 k_ptr = &k_info[o_ptr->k_idx];
5800 lev = k_info[o_ptr->k_idx].level;
5802 if (o_ptr->tval == TV_ROD)
5804 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5807 if (one_in_(recharge_strength))
5809 /* Activate the failure code. */
5814 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5817 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5819 msg_print("You can't absorb energy from a discharged rod.");
5826 o_ptr->timeout += k_ptr->pval;
5832 /* All staffs, wands. */
5833 recharge_strength = (100 + power - lev) / 15;
5836 if (recharge_strength < 0) recharge_strength = 0;
5839 if (one_in_(recharge_strength))
5841 /* Activate the failure code. */
5846 if (o_ptr->pval > 0)
5848 p_ptr->csp += lev / 2;
5851 /* XXX Hack -- unstack if necessary */
5852 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5857 /* Get local object */
5860 /* Obtain a local object */
5861 object_copy(q_ptr, o_ptr);
5863 /* Modify quantity */
5866 /* Restore the charges */
5869 /* Unstack the used item */
5871 p_ptr->total_weight -= q_ptr->weight;
5872 item = inven_carry(q_ptr);
5876 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5878 msg_print("You unstack your staff.");
5886 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5888 msg_print("There's no energy there to absorb!");
5892 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5896 /* Inflict the penalties for failing a recharge. */
5899 /* Artifacts are never destroyed. */
5900 if (object_is_fixed_artifact(o_ptr))
5902 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5904 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5906 msg_format("The recharging backfires - %s is completely drained!", o_name);
5910 /* Artifact rods. */
5911 if (o_ptr->tval == TV_ROD)
5912 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5914 /* Artifact wands and staffs. */
5915 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5920 /* Get the object description */
5921 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5923 /*** Determine Seriousness of Failure ***/
5925 /* Mages recharge objects more safely. */
5926 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)
5928 /* 10% chance to blow up one rod, otherwise draining. */
5929 if (o_ptr->tval == TV_ROD)
5931 if (one_in_(10)) fail_type = 2;
5934 /* 75% chance to blow up one wand, otherwise draining. */
5935 else if (o_ptr->tval == TV_WAND)
5937 if (!one_in_(3)) fail_type = 2;
5940 /* 50% chance to blow up one staff, otherwise no effect. */
5941 else if (o_ptr->tval == TV_STAFF)
5943 if (one_in_(2)) fail_type = 2;
5948 /* All other classes get no special favors. */
5951 /* 33% chance to blow up one rod, otherwise draining. */
5952 if (o_ptr->tval == TV_ROD)
5954 if (one_in_(3)) fail_type = 2;
5957 /* 20% chance of the entire stack, else destroy one wand. */
5958 else if (o_ptr->tval == TV_WAND)
5960 if (one_in_(5)) fail_type = 3;
5963 /* Blow up one staff. */
5964 else if (o_ptr->tval == TV_STAFF)
5970 /*** Apply draining and destruction. ***/
5972 /* Drain object or stack of objects. */
5975 if (o_ptr->tval == TV_ROD)
5978 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
5980 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
5983 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5985 else if (o_ptr->tval == TV_WAND)
5988 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
5990 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
5995 /* Staffs aren't drained. */
5998 /* Destroy an object or one in a stack of objects. */
6001 if (o_ptr->number > 1)
6004 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
6006 msg_format("Wild magic consumes one of your %s!", o_name);
6009 /* Reduce rod stack maximum timeout, drain wands. */
6010 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
6011 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
6016 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
6018 msg_format("Wild magic consumes your %s!", o_name);
6021 /* Reduce and describe inventory */
6024 inven_item_increase(item, -1);
6025 inven_item_describe(item);
6026 inven_item_optimize(item);
6029 /* Reduce and describe floor item */
6032 floor_item_increase(0 - item, -1);
6033 floor_item_describe(0 - item);
6034 floor_item_optimize(0 - item);
6038 /* Destroy all members of a stack of objects. */
6041 if (o_ptr->number > 1)
6043 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
6045 msg_format("Wild magic consumes all your %s!", o_name);
6050 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
6052 msg_format("Wild magic consumes your %s!", o_name);
6057 /* Reduce and describe inventory */
6060 inven_item_increase(item, -999);
6061 inven_item_describe(item);
6062 inven_item_optimize(item);
6065 /* Reduce and describe floor item */
6068 floor_item_increase(0 - item, -999);
6069 floor_item_describe(0 - item);
6070 floor_item_optimize(0 - item);
6076 if (p_ptr->csp > p_ptr->msp)
6078 p_ptr->csp = p_ptr->msp;
6081 /* Redraw mana and hp */
6082 p_ptr->redraw |= (PR_MANA);
6084 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6085 p_ptr->window |= (PW_INVEN);
6091 bool summon_kin_player(int level, int y, int x, u32b mode)
6093 bool pet = (bool)(mode & PM_FORCE_PET);
6094 if (!pet) mode |= PM_NO_PET;
6096 switch (p_ptr->mimic_form)
6099 switch (p_ptr->prace)
6103 case RACE_BARBARIAN:
6106 summon_kin_type = 'p';
6116 case RACE_MIND_FLAYER:
6119 summon_kin_type = 'h';
6122 summon_kin_type = 'o';
6124 case RACE_HALF_TROLL:
6125 summon_kin_type = 'T';
6127 case RACE_HALF_OGRE:
6128 summon_kin_type = 'O';
6130 case RACE_HALF_GIANT:
6131 case RACE_HALF_TITAN:
6133 summon_kin_type = 'P';
6136 summon_kin_type = 'y';
6139 summon_kin_type = 'K';
6142 summon_kin_type = 'k';
6145 if (one_in_(13)) summon_kin_type = 'U';
6146 else summon_kin_type = 'u';
6148 case RACE_DRACONIAN:
6149 summon_kin_type = 'd';
6153 summon_kin_type = 'g';
6156 if (one_in_(13)) summon_kin_type = 'L';
6157 else summon_kin_type = 's';
6160 summon_kin_type = 'z';
6163 summon_kin_type = 'V';
6166 summon_kin_type = 'G';
6169 summon_kin_type = 'I';
6172 summon_kin_type = '#';
6175 summon_kin_type = 'A';
6178 summon_kin_type = 'U';
6181 summon_kin_type = 'p';
6186 if (one_in_(13)) summon_kin_type = 'U';
6187 else summon_kin_type = 'u';
6189 case MIMIC_DEMON_LORD:
6190 summon_kin_type = 'U';
6193 summon_kin_type = 'V';
6196 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);