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)
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 teleporting into vaults and such */
266 if (c_ptr->info & CAVE_ICKY) return FALSE;
268 if (c_ptr->m_idx) 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)) 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 && !passive) break;
463 /* Accept teleportable floor grids */
464 if (cave_player_teleportable_bold(y, x, passive)) 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);
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);
1506 /* Redraw the health bar */
1507 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
1508 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
1512 /* Process all walls, doors and patterns */
1513 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1517 /* Special boundary walls -- Top and bottom */
1518 for (x = 0; x < cur_wid; x++)
1520 c_ptr = &cave[0][x];
1521 f_ptr = &f_info[c_ptr->mimic];
1523 /* Lose room and vault */
1524 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1526 /* Set boundary mimic if needed */
1527 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1529 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1531 /* Check for change to boring grid */
1532 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1535 c_ptr = &cave[cur_hgt - 1][x];
1536 f_ptr = &f_info[c_ptr->mimic];
1538 /* Lose room and vault */
1539 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1541 /* Set boundary mimic if needed */
1542 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1544 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1546 /* Check for change to boring grid */
1547 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1551 /* Special boundary walls -- Left and right */
1552 for (y = 1; y < (cur_hgt - 1); y++)
1554 c_ptr = &cave[y][0];
1555 f_ptr = &f_info[c_ptr->mimic];
1557 /* Lose room and vault */
1558 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1560 /* Set boundary mimic if needed */
1561 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1563 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1565 /* Check for change to boring grid */
1566 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1569 c_ptr = &cave[y][cur_wid - 1];
1570 f_ptr = &f_info[c_ptr->mimic];
1572 /* Lose room and vault */
1573 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1575 /* Set boundary mimic if needed */
1576 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1578 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1580 /* Check for change to boring grid */
1581 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1585 /* Mega-Hack -- Forget the view and lite */
1586 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1589 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1591 /* Update the monsters */
1592 p_ptr->update |= (PU_MONSTERS);
1595 p_ptr->redraw |= (PR_MAP);
1598 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1604 void call_the_(void)
1608 bool do_call = TRUE;
1610 for (i = 0; i < 9; i++)
1612 c_ptr = &cave[py + ddy_ddd[i]][px + ddx_ddd[i]];
1614 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1616 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1617 !permanent_wall(&f_info[c_ptr->feat]))
1627 for (i = 1; i < 10; i++)
1629 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1632 for (i = 1; i < 10; i++)
1634 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1637 for (i = 1; i < 10; i++)
1639 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1643 /* Prevent destruction of quest levels and town */
1644 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1647 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1649 msg_print("The ground trembles.");
1656 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1657 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1658 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1660 msg_format("You %s the %s too close to a wall!",
1661 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1662 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1663 msg_print("There is a loud explosion!");
1669 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1671 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1676 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1678 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1680 msg_print("The dungeon collapses...");
1685 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1687 msg_print("The dungeon trembles.");
1692 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1694 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1701 * Fetch an item (teleport it right underneath the caster)
1703 void fetch(int dir, int wgt, bool require_los)
1708 char o_name[MAX_NLEN];
1710 /* Check to see if an object is already there */
1711 if (cave[py][px].o_idx)
1714 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1716 msg_print("You can't fetch when you're already standing on something.");
1723 if (dir == 5 && target_okay())
1728 if (distance(py, px, ty, tx) > MAX_RANGE)
1731 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1733 msg_print("You can't fetch something that far away!");
1739 c_ptr = &cave[ty][tx];
1741 /* We need an item to fetch */
1745 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1747 msg_print("There is no object at this place.");
1753 /* No fetching from vault */
1754 if (c_ptr->info & CAVE_ICKY)
1757 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1759 msg_print("The item slips from your control.");
1765 /* We need to see the item */
1768 if (!player_has_los_bold(ty, tx))
1771 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1773 msg_print("You have no direct line of sight to that location.");
1778 else if (!projectable(py, px, ty, tx))
1781 msg_print("¤½¤³¤ÏÊɤθþ¤³¤¦¤Ç¤¹¡£");
1783 msg_print("You have no direct line of sight to that location.");
1792 /* Use a direction */
1793 ty = py; /* Where to drop the item */
1800 c_ptr = &cave[ty][tx];
1802 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1803 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1805 while (!c_ptr->o_idx);
1808 o_ptr = &o_list[c_ptr->o_idx];
1810 if (o_ptr->weight > wgt)
1812 /* Too heavy to 'fetch' */
1814 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1816 msg_print("The object is too heavy.");
1823 c_ptr->o_idx = o_ptr->next_o_idx;
1824 cave[py][px].o_idx = i; /* 'move' it */
1825 o_ptr->next_o_idx = 0;
1826 o_ptr->iy = (byte)py;
1827 o_ptr->ix = (byte)px;
1829 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1831 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1833 msg_format("%^s flies through the air to your feet.", o_name);
1838 p_ptr->redraw |= PR_MAP;
1842 void alter_reality(void)
1844 /* Ironman option */
1845 if (p_ptr->inside_arena || ironman_downward)
1848 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1850 msg_print("Nothing happens.");
1855 if (!p_ptr->alter_reality)
1857 int turns = randint0(21) + 15;
1859 p_ptr->alter_reality = turns;
1861 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1863 msg_print("The view around you begins to change...");
1866 p_ptr->redraw |= (PR_STATUS);
1870 p_ptr->alter_reality = 0;
1872 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1874 msg_print("The view around you got back...");
1877 p_ptr->redraw |= (PR_STATUS);
1884 * Leave a "glyph of warding" which prevents monster movement
1886 bool warding_glyph(void)
1889 if (!cave_clean_bold(py, px))
1892 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1894 msg_print("The object resists the spell.");
1900 /* Create a glyph */
1901 cave[py][px].info |= CAVE_OBJECT;
1902 cave[py][px].mimic = FEAT_GLYPH;
1913 bool place_mirror(void)
1916 if (!cave_clean_bold(py, px))
1919 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1921 msg_print("The object resists the spell.");
1927 /* Create a mirror */
1928 cave[py][px].info |= CAVE_OBJECT;
1929 cave[py][px].mimic = FEAT_MIRROR;
1931 /* Turn on the light */
1932 cave[py][px].info |= CAVE_GLOW;
1940 update_local_illumination(py, px);
1947 * Leave an "explosive rune" which prevents monster movement
1949 bool explosive_rune(void)
1952 if (!cave_clean_bold(py, px))
1955 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1957 msg_print("The object resists the spell.");
1963 /* Create a glyph */
1964 cave[py][px].info |= CAVE_OBJECT;
1965 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1978 * Identify everything being carried.
1979 * Done by a potion of "self knowledge".
1981 void identify_pack(void)
1985 /* Simply identify and know every item */
1986 for (i = 0; i < INVEN_TOTAL; i++)
1988 object_type *o_ptr = &inventory[i];
1990 /* Skip non-objects */
1991 if (!o_ptr->k_idx) continue;
1994 identify_item(o_ptr);
1996 /* Auto-inscription */
1997 autopick_alter_item(i, FALSE);
2003 * Used by the "enchant" function (chance of failure)
2004 * (modified for Zangband, we need better stuff there...) -- TY
2006 static int enchant_table[16] =
2008 0, 10, 50, 100, 200,
2009 300, 400, 500, 650, 800,
2010 950, 987, 993, 995, 998,
2016 * Removes curses from items in inventory
2018 * Note that Items which are "Perma-Cursed" (The One Ring,
2019 * The Crown of Morgoth) can NEVER be uncursed.
2021 * Note that if "all" is FALSE, then Items which are
2022 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2023 * will not be uncursed.
2025 static int remove_curse_aux(int all)
2029 /* Attempt to uncurse items being worn */
2030 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2032 object_type *o_ptr = &inventory[i];
2034 /* Skip non-objects */
2035 if (!o_ptr->k_idx) continue;
2037 /* Uncursed already */
2038 if (!object_is_cursed(o_ptr)) continue;
2040 /* Heavily Cursed Items need a special spell */
2041 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2043 /* Perma-Cursed Items can NEVER be uncursed */
2044 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2047 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2052 o_ptr->curse_flags = 0L;
2054 /* Hack -- Assume felt */
2055 o_ptr->ident |= (IDENT_SENSE);
2058 o_ptr->feeling = FEEL_NONE;
2060 /* Recalculate the bonuses */
2061 p_ptr->update |= (PU_BONUS);
2064 p_ptr->window |= (PW_EQUIP);
2066 /* Count the uncursings */
2070 /* Return "something uncursed" */
2076 * Remove most curses
2078 bool remove_curse(void)
2080 return (remove_curse_aux(FALSE));
2086 bool remove_all_curse(void)
2088 return (remove_curse_aux(TRUE));
2093 * Turns an object into gold, gain some of its value in a shop
2102 char o_name[MAX_NLEN];
2103 char out_val[MAX_NLEN+40];
2107 /* Hack -- force destruction */
2108 if (command_arg > 0) force = TRUE;
2112 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2113 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2115 q = "Turn which item to gold? ";
2116 s = "You have nothing to turn to gold.";
2119 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2121 /* Get the item (in the pack) */
2124 o_ptr = &inventory[item];
2127 /* Get the item (on the floor) */
2130 o_ptr = &o_list[0 - item];
2134 /* See how many items */
2135 if (o_ptr->number > 1)
2137 /* Get a quantity */
2138 amt = get_quantity(NULL, o_ptr->number);
2140 /* Allow user abort */
2141 if (amt <= 0) return FALSE;
2145 /* Describe the object */
2146 old_number = o_ptr->number;
2147 o_ptr->number = amt;
2148 object_desc(o_name, o_ptr, 0);
2149 o_ptr->number = old_number;
2151 /* Verify unless quantity given */
2154 if (confirm_destroy || (object_value(o_ptr) > 0))
2156 /* Make a verification */
2158 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2160 sprintf(out_val, "Really turn %s to gold? ", o_name);
2163 if (!get_check(out_val)) return FALSE;
2167 /* Artifacts cannot be destroyed */
2168 if (!can_player_destroy_object(o_ptr))
2172 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2174 msg_format("You fail to turn %s to gold!", o_name);
2181 price = object_value_real(o_ptr);
2187 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2189 msg_format("You turn %s to fool's gold.", o_name);
2197 if (amt > 1) price *= amt;
2199 if (price > 30000) price = 30000;
2201 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2203 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2209 p_ptr->redraw |= (PR_GOLD);
2212 p_ptr->window |= (PW_PLAYER);
2216 /* Eliminate the item (from the pack) */
2219 inven_item_increase(item, -amt);
2220 inven_item_describe(item);
2221 inven_item_optimize(item);
2224 /* Eliminate the item (from the floor) */
2227 floor_item_increase(0 - item, -amt);
2228 floor_item_describe(0 - item);
2229 floor_item_optimize(0 - item);
2237 * Break the curse of an item
2239 static void break_curse(object_type *o_ptr)
2241 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2244 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2246 msg_print("The curse is broken!");
2249 o_ptr->curse_flags = 0L;
2251 o_ptr->ident |= (IDENT_SENSE);
2253 o_ptr->feeling = FEEL_NONE;
2259 * Enchants a plus onto an item. -RAK-
2261 * Revamped! Now takes item pointer, number of times to try enchanting,
2262 * and a flag of what to try enchanting. Artifacts resist enchantment
2263 * some of the time, and successful enchantment to at least +0 might
2264 * break a curse on the item. -CFT-
2266 * Note that an item can technically be enchanted all the way to +15 if
2267 * you wait a very, very, long time. Going from +9 to +10 only works
2268 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2270 * Note that this function can now be used on "piles" of items, and
2271 * the larger the pile, the lower the chance of success.
2273 bool enchant(object_type *o_ptr, int n, int eflag)
2275 int i, chance, prob;
2277 bool a = object_is_artifact(o_ptr);
2278 bool force = (eflag & ENCH_FORCE);
2281 /* Large piles resist enchantment */
2282 prob = o_ptr->number * 100;
2284 /* Missiles are easy to enchant */
2285 if ((o_ptr->tval == TV_BOLT) ||
2286 (o_ptr->tval == TV_ARROW) ||
2287 (o_ptr->tval == TV_SHOT))
2293 for (i = 0; i < n; i++)
2295 /* Hack -- Roll for pile resistance */
2296 if (!force && randint0(prob) >= 100) continue;
2298 /* Enchant to hit */
2299 if (eflag & ENCH_TOHIT)
2301 if (o_ptr->to_h < 0) chance = 0;
2302 else if (o_ptr->to_h > 15) chance = 1000;
2303 else chance = enchant_table[o_ptr->to_h];
2305 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2310 /* only when you get it above -1 -CFT */
2311 if (o_ptr->to_h >= 0)
2316 /* Enchant to damage */
2317 if (eflag & ENCH_TODAM)
2319 if (o_ptr->to_d < 0) chance = 0;
2320 else if (o_ptr->to_d > 15) chance = 1000;
2321 else chance = enchant_table[o_ptr->to_d];
2323 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2328 /* only when you get it above -1 -CFT */
2329 if (o_ptr->to_d >= 0)
2334 /* Enchant to armor class */
2335 if (eflag & ENCH_TOAC)
2337 if (o_ptr->to_a < 0) chance = 0;
2338 else if (o_ptr->to_a > 15) chance = 1000;
2339 else chance = enchant_table[o_ptr->to_a];
2341 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2346 /* only when you get it above -1 -CFT */
2347 if (o_ptr->to_a >= 0)
2354 if (!res) return (FALSE);
2356 /* Recalculate bonuses */
2357 p_ptr->update |= (PU_BONUS);
2359 /* Combine / Reorder the pack (later) */
2360 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2363 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2374 * Enchant an item (in the inventory or on the floor)
2375 * Note that "num_ac" requires armour, else weapon
2376 * Returns TRUE if attempted, FALSE if cancelled
2378 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2383 char o_name[MAX_NLEN];
2387 /* Assume enchant weapon */
2388 item_tester_hook = object_allow_enchant_weapon;
2389 item_tester_no_ryoute = TRUE;
2391 /* Enchant armor if requested */
2392 if (num_ac) item_tester_hook = object_is_armour;
2396 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2397 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2399 q = "Enchant which item? ";
2400 s = "You have nothing to enchant.";
2403 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2405 /* Get the item (in the pack) */
2408 o_ptr = &inventory[item];
2411 /* Get the item (on the floor) */
2414 o_ptr = &o_list[0 - item];
2419 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2423 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2426 msg_format("%s %s glow%s brightly!",
2427 ((item >= 0) ? "Your" : "The"), o_name,
2428 ((o_ptr->number > 1) ? "" : "s"));
2433 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2434 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2435 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2441 if (flush_failure) flush();
2445 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2447 msg_print("The enchantment failed.");
2450 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2453 chg_virtue(V_ENCHANT, 1);
2457 /* Something happened */
2463 * Check if an object is nameless weapon or armour
2465 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2467 /* Require weapon or armour */
2468 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2470 /* Require nameless object if the object is well known */
2471 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2478 bool artifact_scroll(void)
2483 char o_name[MAX_NLEN];
2487 item_tester_no_ryoute = TRUE;
2489 /* Enchant weapon/armour */
2490 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2494 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2495 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2497 q = "Enchant which item? ";
2498 s = "You have nothing to enchant.";
2501 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2503 /* Get the item (in the pack) */
2506 o_ptr = &inventory[item];
2509 /* Get the item (on the floor) */
2512 o_ptr = &o_list[0 - item];
2517 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2521 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2523 msg_format("%s %s radiate%s a blinding light!",
2524 ((item >= 0) ? "Your" : "The"), o_name,
2525 ((o_ptr->number > 1) ? "" : "s"));
2528 if (object_is_artifact(o_ptr))
2531 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2533 msg_format("The %s %s already %s!",
2534 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2535 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2541 else if (object_is_ego(o_ptr))
2544 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2546 msg_format("The %s %s already %s!",
2547 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2548 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2554 else if (o_ptr->xtra3)
2557 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2559 msg_format("The %s %s already %s!",
2560 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2561 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2567 if (o_ptr->number > 1)
2570 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2571 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2573 msg_print("Not enough enough energy to enchant more than one object!");
2574 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2579 inven_item_increase(item, 1-(o_ptr->number));
2583 floor_item_increase(0-item, 1-(o_ptr->number));
2586 okay = create_artifact(o_ptr, TRUE);
2593 if (flush_failure) flush();
2597 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2599 msg_print("The enchantment failed.");
2602 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2605 chg_virtue(V_ENCHANT, 1);
2609 /* Something happened */
2615 * Identify an object
2617 bool identify_item(object_type *o_ptr)
2619 bool old_known = FALSE;
2620 char o_name[MAX_NLEN];
2623 object_desc(o_name, o_ptr, 0);
2625 if (o_ptr->ident & IDENT_KNOWN)
2628 if (!(o_ptr->ident & (IDENT_MENTAL)))
2630 if (object_is_artifact(o_ptr) || one_in_(5))
2631 chg_virtue(V_KNOWLEDGE, 1);
2634 /* Identify it fully */
2635 object_aware(o_ptr);
2636 object_known(o_ptr);
2638 /* Recalculate bonuses */
2639 p_ptr->update |= (PU_BONUS);
2641 /* Combine / Reorder the pack (later) */
2642 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2645 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2647 strcpy(record_o_name, o_name);
2651 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2653 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2654 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2655 if(record_rand_art && !old_known && o_ptr->art_name)
2656 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2662 static bool item_tester_hook_identify(object_type *o_ptr)
2664 return (bool)!object_is_known(o_ptr);
2667 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2669 if (object_is_known(o_ptr))
2671 return object_is_weapon_armour_ammo(o_ptr);
2675 * Identify an object in the inventory (or on the floor)
2676 * This routine does *not* automatically combine objects.
2677 * Returns TRUE if something was identified, else FALSE.
2679 bool ident_spell(bool only_equip)
2683 char o_name[MAX_NLEN];
2687 item_tester_no_ryoute = TRUE;
2690 item_tester_hook = item_tester_hook_identify_weapon_armour;
2692 item_tester_hook = item_tester_hook_identify;
2694 if (!can_get_item())
2698 item_tester_hook = object_is_weapon_armour_ammo;
2702 item_tester_hook = NULL;
2708 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2709 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2711 q = "Identify which item? ";
2712 s = "You have nothing to identify.";
2715 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2717 /* Get the item (in the pack) */
2720 o_ptr = &inventory[item];
2723 /* Get the item (on the floor) */
2726 o_ptr = &o_list[0 - item];
2730 old_known = identify_item(o_ptr);
2733 object_desc(o_name, o_ptr, 0);
2736 if (item >= INVEN_RARM)
2739 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2741 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2747 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2749 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2755 msg_format("¾²¾å: %s¡£", o_name);
2757 msg_format("On the ground: %s.", o_name);
2761 /* Auto-inscription/destroy */
2762 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2764 /* Something happened */
2770 * Mundanify an object in the inventory (or on the floor)
2771 * This routine does *not* automatically combine objects.
2772 * Returns TRUE if something was mundanified, else FALSE.
2774 bool mundane_spell(bool only_equip)
2780 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2781 item_tester_no_ryoute = TRUE;
2785 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2786 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2788 q = "Use which item? ";
2789 s = "You have nothing you can use.";
2792 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2794 /* Get the item (in the pack) */
2797 o_ptr = &inventory[item];
2800 /* Get the item (on the floor) */
2803 o_ptr = &o_list[0 - item];
2808 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2810 msg_print("There is a bright flash of light!");
2813 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2814 byte ix = o_ptr->ix; /* X-position on map, or zero */
2815 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2816 byte marked = o_ptr->marked; /* Object is marked */
2817 s16b weight = o_ptr->number * o_ptr->weight;
2818 u16b inscription = o_ptr->inscription;
2821 object_prep(o_ptr, o_ptr->k_idx);
2825 o_ptr->next_o_idx = next_o_idx;
2826 o_ptr->marked = marked;
2827 o_ptr->inscription = inscription;
2828 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2832 /* Something happened */
2838 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2840 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2843 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2845 if (!item_tester_hook_identify_fully(o_ptr))
2847 return object_is_weapon_armour_ammo(o_ptr);
2851 * Fully "identify" an object in the inventory -BEN-
2852 * This routine returns TRUE if an item was identified.
2854 bool identify_fully(bool only_equip)
2858 char o_name[MAX_NLEN];
2862 item_tester_no_ryoute = TRUE;
2864 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2866 item_tester_hook = item_tester_hook_identify_fully;
2868 if (!can_get_item())
2871 item_tester_hook = object_is_weapon_armour_ammo;
2873 item_tester_hook = NULL;
2878 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2879 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2881 q = "Identify which item? ";
2882 s = "You have nothing to identify.";
2885 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2887 /* Get the item (in the pack) */
2890 o_ptr = &inventory[item];
2893 /* Get the item (on the floor) */
2896 o_ptr = &o_list[0 - item];
2900 old_known = identify_item(o_ptr);
2902 /* Mark the item as fully known */
2903 o_ptr->ident |= (IDENT_MENTAL);
2909 object_desc(o_name, o_ptr, 0);
2912 if (item >= INVEN_RARM)
2915 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2917 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2925 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2927 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2933 msg_format("¾²¾å: %s¡£", o_name);
2935 msg_format("On the ground: %s.", o_name);
2939 /* Describe it fully */
2940 (void)screen_object(o_ptr, TRUE);
2942 /* Auto-inscription/destroy */
2943 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2953 * Hook for "get_item()". Determine if something is rechargable.
2955 bool item_tester_hook_recharge(object_type *o_ptr)
2957 /* Recharge staffs */
2958 if (o_ptr->tval == TV_STAFF) return (TRUE);
2960 /* Recharge wands */
2961 if (o_ptr->tval == TV_WAND) return (TRUE);
2963 /* Hack -- Recharge rods */
2964 if (o_ptr->tval == TV_ROD) return (TRUE);
2972 * Recharge a wand/staff/rod from the pack or on the floor.
2973 * This function has been rewritten in Oangband and ZAngband.
2975 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2976 * Chaos -- Arcane Binding --> recharge(90)
2978 * Scroll of recharging --> recharge(130)
2979 * Artifact activation/Thingol --> recharge(130)
2981 * It is harder to recharge high level, and highly charged wands,
2982 * staffs, and rods. The more wands in a stack, the more easily and
2983 * strongly they recharge. Staffs, however, each get fewer charges if
2986 * XXX XXX XXX Beware of "sliding index errors".
2988 bool recharge(int power)
2991 int recharge_strength, recharge_amount;
3000 char o_name[MAX_NLEN];
3002 /* Only accept legal items */
3003 item_tester_hook = item_tester_hook_recharge;
3007 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3008 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3010 q = "Recharge which item? ";
3011 s = "You have nothing to recharge.";
3014 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3016 /* Get the item (in the pack) */
3019 o_ptr = &inventory[item];
3022 /* Get the item (on the floor) */
3025 o_ptr = &o_list[0 - item];
3028 /* Get the object kind. */
3029 k_ptr = &k_info[o_ptr->k_idx];
3031 /* Extract the object "level" */
3032 lev = k_info[o_ptr->k_idx].level;
3035 /* Recharge a rod */
3036 if (o_ptr->tval == TV_ROD)
3038 /* Extract a recharge strength by comparing object level to power. */
3039 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3043 if (one_in_(recharge_strength))
3045 /* Activate the failure code. */
3052 /* Recharge amount */
3053 recharge_amount = (power * damroll(3, 2));
3055 /* Recharge by that amount */
3056 if (o_ptr->timeout > recharge_amount)
3057 o_ptr->timeout -= recharge_amount;
3064 /* Recharge wand/staff */
3067 /* Extract a recharge strength by comparing object level to power.
3068 * Divide up a stack of wands' charges to calculate charge penalty.
3070 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3071 recharge_strength = (100 + power - lev -
3072 (8 * o_ptr->pval / o_ptr->number)) / 15;
3074 /* All staffs, unstacked wands. */
3075 else recharge_strength = (100 + power - lev -
3076 (8 * o_ptr->pval)) / 15;
3079 if (recharge_strength < 0) recharge_strength = 0;
3082 if (one_in_(recharge_strength))
3084 /* Activate the failure code. */
3088 /* If the spell didn't backfire, recharge the wand or staff. */
3091 /* Recharge based on the standard number of charges. */
3092 recharge_amount = randint1(1 + k_ptr->pval / 2);
3094 /* Multiple wands in a stack increase recharging somewhat. */
3095 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3098 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3099 if (recharge_amount < 1) recharge_amount = 1;
3100 if (recharge_amount > 12) recharge_amount = 12;
3103 /* But each staff in a stack gets fewer additional charges,
3104 * although always at least one.
3106 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3108 recharge_amount /= o_ptr->number;
3109 if (recharge_amount < 1) recharge_amount = 1;
3112 /* Recharge the wand or staff. */
3113 o_ptr->pval += recharge_amount;
3116 /* Hack -- we no longer "know" the item */
3117 o_ptr->ident &= ~(IDENT_KNOWN);
3119 /* Hack -- we no longer think the item is empty */
3120 o_ptr->ident &= ~(IDENT_EMPTY);
3125 /* Inflict the penalties for failing a recharge. */
3128 /* Artifacts are never destroyed. */
3129 if (object_is_fixed_artifact(o_ptr))
3131 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3133 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3135 msg_format("The recharging backfires - %s is completely drained!", o_name);
3139 /* Artifact rods. */
3140 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3141 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3143 /* Artifact wands and staffs. */
3144 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3149 /* Get the object description */
3150 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3152 /*** Determine Seriousness of Failure ***/
3154 /* Mages recharge objects more safely. */
3155 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)
3157 /* 10% chance to blow up one rod, otherwise draining. */
3158 if (o_ptr->tval == TV_ROD)
3160 if (one_in_(10)) fail_type = 2;
3163 /* 75% chance to blow up one wand, otherwise draining. */
3164 else if (o_ptr->tval == TV_WAND)
3166 if (!one_in_(3)) fail_type = 2;
3169 /* 50% chance to blow up one staff, otherwise no effect. */
3170 else if (o_ptr->tval == TV_STAFF)
3172 if (one_in_(2)) fail_type = 2;
3177 /* All other classes get no special favors. */
3180 /* 33% chance to blow up one rod, otherwise draining. */
3181 if (o_ptr->tval == TV_ROD)
3183 if (one_in_(3)) fail_type = 2;
3186 /* 20% chance of the entire stack, else destroy one wand. */
3187 else if (o_ptr->tval == TV_WAND)
3189 if (one_in_(5)) fail_type = 3;
3192 /* Blow up one staff. */
3193 else if (o_ptr->tval == TV_STAFF)
3199 /*** Apply draining and destruction. ***/
3201 /* Drain object or stack of objects. */
3204 if (o_ptr->tval == TV_ROD)
3207 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3209 msg_print("The recharge backfires, draining the rod further!");
3212 if (o_ptr->timeout < 10000)
3213 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3215 else if (o_ptr->tval == TV_WAND)
3218 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3220 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3225 /* Staffs aren't drained. */
3228 /* Destroy an object or one in a stack of objects. */
3231 if (o_ptr->number > 1)
3233 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3235 msg_format("Wild magic consumes one of your %s!", o_name);
3240 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3242 msg_format("Wild magic consumes your %s!", o_name);
3246 /* Reduce rod stack maximum timeout, drain wands. */
3247 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3248 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3250 /* Reduce and describe inventory */
3253 inven_item_increase(item, -1);
3254 inven_item_describe(item);
3255 inven_item_optimize(item);
3258 /* Reduce and describe floor item */
3261 floor_item_increase(0 - item, -1);
3262 floor_item_describe(0 - item);
3263 floor_item_optimize(0 - item);
3267 /* Destroy all members of a stack of objects. */
3270 if (o_ptr->number > 1)
3272 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3274 msg_format("Wild magic consumes all your %s!", o_name);
3279 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3281 msg_format("Wild magic consumes your %s!", o_name);
3286 /* Reduce and describe inventory */
3289 inven_item_increase(item, -999);
3290 inven_item_describe(item);
3291 inven_item_optimize(item);
3294 /* Reduce and describe floor item */
3297 floor_item_increase(0 - item, -999);
3298 floor_item_describe(0 - item);
3299 floor_item_optimize(0 - item);
3305 /* Combine / Reorder the pack (later) */
3306 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3309 p_ptr->window |= (PW_INVEN);
3311 /* Something was done */
3319 bool bless_weapon(void)
3323 u32b flgs[TR_FLAG_SIZE];
3324 char o_name[MAX_NLEN];
3327 item_tester_no_ryoute = TRUE;
3329 /* Bless only weapons */
3330 item_tester_hook = object_is_weapon;
3334 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3335 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3337 q = "Bless which weapon? ";
3338 s = "You have weapon to bless.";
3341 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3344 /* Get the item (in the pack) */
3347 o_ptr = &inventory[item];
3350 /* Get the item (on the floor) */
3353 o_ptr = &o_list[0 - item];
3358 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3360 /* Extract the flags */
3361 object_flags(o_ptr, flgs);
3363 if (object_is_cursed(o_ptr))
3365 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3366 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3369 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3372 msg_format("The black aura on %s %s disrupts the blessing!",
3373 ((item >= 0) ? "your" : "the"), o_name);
3380 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3383 msg_format("A malignant aura leaves %s %s.",
3384 ((item >= 0) ? "your" : "the"), o_name);
3389 o_ptr->curse_flags = 0L;
3391 /* Hack -- Assume felt */
3392 o_ptr->ident |= (IDENT_SENSE);
3395 o_ptr->feeling = FEEL_NONE;
3397 /* Recalculate the bonuses */
3398 p_ptr->update |= (PU_BONUS);
3401 p_ptr->window |= (PW_EQUIP);
3405 * Next, we try to bless it. Artifacts have a 1/3 chance of
3406 * being blessed, otherwise, the operation simply disenchants
3407 * them, godly power negating the magic. Ok, the explanation
3408 * is silly, but otherwise priests would always bless every
3409 * artifact weapon they find. Ego weapons and normal weapons
3410 * can be blessed automatically.
3412 if (have_flag(flgs, TR_BLESSED))
3415 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3418 msg_format("%s %s %s blessed already.",
3419 ((item >= 0) ? "Your" : "The"), o_name,
3420 ((o_ptr->number > 1) ? "were" : "was"));
3426 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3430 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3433 msg_format("%s %s shine%s!",
3434 ((item >= 0) ? "Your" : "The"), o_name,
3435 ((o_ptr->number > 1) ? "" : "s"));
3438 add_flag(o_ptr->art_flags, TR_BLESSED);
3439 o_ptr->discount = 99;
3443 bool dis_happened = FALSE;
3446 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3448 msg_print("The weapon resists your blessing!");
3452 /* Disenchant tohit */
3453 if (o_ptr->to_h > 0)
3456 dis_happened = TRUE;
3459 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3461 /* Disenchant todam */
3462 if (o_ptr->to_d > 0)
3465 dis_happened = TRUE;
3468 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3470 /* Disenchant toac */
3471 if (o_ptr->to_a > 0)
3474 dis_happened = TRUE;
3477 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3482 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3484 msg_print("There is a static feeling in the air...");
3488 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3491 msg_format("%s %s %s disenchanted!",
3492 ((item >= 0) ? "Your" : "The"), o_name,
3493 ((o_ptr->number > 1) ? "were" : "was"));
3499 /* Recalculate bonuses */
3500 p_ptr->update |= (PU_BONUS);
3503 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3514 bool pulish_shield(void)
3518 u32b flgs[TR_FLAG_SIZE];
3519 char o_name[MAX_NLEN];
3522 item_tester_no_ryoute = TRUE;
3523 /* Assume enchant weapon */
3524 item_tester_tval = TV_SHIELD;
3528 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3529 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3531 q = "Pulish which weapon? ";
3532 s = "You have weapon to pulish.";
3535 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3538 /* Get the item (in the pack) */
3541 o_ptr = &inventory[item];
3544 /* Get the item (on the floor) */
3547 o_ptr = &o_list[0 - item];
3552 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3554 /* Extract the flags */
3555 object_flags(o_ptr, flgs);
3557 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3558 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3561 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3563 msg_format("%s %s shine%s!",
3564 ((item >= 0) ? "Your" : "The"), o_name,
3565 ((o_ptr->number > 1) ? "" : "s"));
3567 o_ptr->name2 = EGO_REFLECTION;
3568 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3570 o_ptr->discount = 99;
3571 chg_virtue(V_ENCHANT, 2);
3577 if (flush_failure) flush();
3580 msg_print("¼ºÇÔ¤·¤¿¡£");
3582 msg_print("Failed.");
3585 chg_virtue(V_ENCHANT, -2);
3594 * Potions "smash open" and cause an area effect when
3595 * (1) they are shattered while in the player's inventory,
3596 * due to cold (etc) attacks;
3597 * (2) they are thrown at a monster, or obstacle;
3598 * (3) they are shattered by a "cold ball" or other such spell
3599 * while lying on the floor.
3602 * who --- who caused the potion to shatter (0=player)
3603 * potions that smash on the floor are assumed to
3604 * be caused by no-one (who = 1), as are those that
3605 * shatter inside the player inventory.
3606 * (Not anymore -- I changed this; TY)
3607 * y, x --- coordinates of the potion (or player if
3608 * the potion was in her inventory);
3609 * o_ptr --- pointer to the potion object.
3611 bool potion_smash_effect(int who, int y, int x, int k_idx)
3618 object_kind *k_ptr = &k_info[k_idx];
3620 switch (k_ptr->sval)
3622 case SV_POTION_SALT_WATER:
3623 case SV_POTION_SLIME_MOLD:
3624 case SV_POTION_LOSE_MEMORIES:
3625 case SV_POTION_DEC_STR:
3626 case SV_POTION_DEC_INT:
3627 case SV_POTION_DEC_WIS:
3628 case SV_POTION_DEC_DEX:
3629 case SV_POTION_DEC_CON:
3630 case SV_POTION_DEC_CHR:
3631 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3632 case SV_POTION_APPLE_JUICE:
3635 case SV_POTION_INFRAVISION:
3636 case SV_POTION_DETECT_INVIS:
3637 case SV_POTION_SLOW_POISON:
3638 case SV_POTION_CURE_POISON:
3639 case SV_POTION_BOLDNESS:
3640 case SV_POTION_RESIST_HEAT:
3641 case SV_POTION_RESIST_COLD:
3642 case SV_POTION_HEROISM:
3643 case SV_POTION_BESERK_STRENGTH:
3644 case SV_POTION_RES_STR:
3645 case SV_POTION_RES_INT:
3646 case SV_POTION_RES_WIS:
3647 case SV_POTION_RES_DEX:
3648 case SV_POTION_RES_CON:
3649 case SV_POTION_RES_CHR:
3650 case SV_POTION_INC_STR:
3651 case SV_POTION_INC_INT:
3652 case SV_POTION_INC_WIS:
3653 case SV_POTION_INC_DEX:
3654 case SV_POTION_INC_CON:
3655 case SV_POTION_INC_CHR:
3656 case SV_POTION_AUGMENTATION:
3657 case SV_POTION_ENLIGHTENMENT:
3658 case SV_POTION_STAR_ENLIGHTENMENT:
3659 case SV_POTION_SELF_KNOWLEDGE:
3660 case SV_POTION_EXPERIENCE:
3661 case SV_POTION_RESISTANCE:
3662 case SV_POTION_INVULNERABILITY:
3663 case SV_POTION_NEW_LIFE:
3664 /* All of the above potions have no effect when shattered */
3666 case SV_POTION_SLOWNESS:
3671 case SV_POTION_POISON:
3676 case SV_POTION_BLINDNESS:
3680 case SV_POTION_CONFUSION: /* Booze */
3684 case SV_POTION_SLEEP:
3688 case SV_POTION_RUINATION:
3689 case SV_POTION_DETONATIONS:
3691 dam = damroll(25, 25);
3694 case SV_POTION_DEATH:
3695 dt = GF_DEATH_RAY; /* !! */
3696 dam = k_ptr->level * 10;
3700 case SV_POTION_SPEED:
3703 case SV_POTION_CURE_LIGHT:
3705 dam = damroll(2, 3);
3707 case SV_POTION_CURE_SERIOUS:
3709 dam = damroll(4, 3);
3711 case SV_POTION_CURE_CRITICAL:
3712 case SV_POTION_CURING:
3714 dam = damroll(6, 3);
3716 case SV_POTION_HEALING:
3718 dam = damroll(10, 10);
3720 case SV_POTION_RESTORE_EXP:
3725 case SV_POTION_LIFE:
3727 dam = damroll(50, 50);
3730 case SV_POTION_STAR_HEALING:
3732 dam = damroll(50, 50);
3735 case SV_POTION_RESTORE_MANA: /* MANA */
3737 dam = damroll(10, 10);
3744 (void)project(who, radius, y, x, dam, dt,
3745 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3747 /* XXX those potions that explode need to become "known" */
3753 * Hack -- Display all known spells in a window
3755 * XXX XXX XXX Need to analyze size of the window.
3757 * XXX XXX XXX Need more color coding.
3759 void display_spell_list(void)
3772 /* They have too many spells to list */
3773 if (p_ptr->pclass == CLASS_SORCERER) return;
3774 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3776 /* mind.c type classes */
3777 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3778 (p_ptr->pclass == CLASS_BERSERKER) ||
3779 (p_ptr->pclass == CLASS_NINJA) ||
3780 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3781 (p_ptr->pclass == CLASS_FORCETRAINER))
3787 int plev = p_ptr->lev;
3793 bool use_hp = FALSE;
3795 /* Display a list of spells */
3798 put_str("̾Á°", y, x + 5);
3799 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3801 put_str("Name", y, x + 5);
3802 put_str("Lv Mana Fail Info", y, x + 35);
3805 switch(p_ptr->pclass)
3807 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3808 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3809 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3810 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3811 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3812 default: use_mind = 0;break;
3815 /* Dump the spells */
3816 for (i = 0; i < MAX_MIND_POWERS; i++)
3818 byte a = TERM_WHITE;
3820 /* Access the available spell */
3821 spell = mind_powers[use_mind].info[i];
3822 if (spell.min_lev > plev) break;
3824 /* Get the failure rate */
3825 chance = spell.fail;
3827 /* Reduce failure rate by "effective" level adjustment */
3828 chance -= 3 * (p_ptr->lev - spell.min_lev);
3830 /* Reduce failure rate by INT/WIS adjustment */
3831 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3835 /* Not enough mana to cast */
3836 if (spell.mana_cost > p_ptr->csp)
3838 chance += 5 * (spell.mana_cost - p_ptr->csp);
3844 /* Not enough hp to cast */
3845 if (spell.mana_cost > p_ptr->chp)
3852 /* Extract the minimum failure rate */
3853 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3855 /* Minimum failure rate */
3856 if (chance < minfail) chance = minfail;
3858 /* Stunning makes spells harder */
3859 if (p_ptr->stun > 50) chance += 25;
3860 else if (p_ptr->stun) chance += 15;
3862 /* Always a 5 percent chance of working */
3863 if (chance > 95) chance = 95;
3866 mindcraft_info(comment, use_mind, i);
3868 /* Dump the spell */
3869 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3871 spell.min_lev, spell.mana_cost, chance, comment);
3873 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3878 /* Cannot read spellbooks */
3879 if (REALM_NONE == p_ptr->realm1) return;
3881 /* Normal spellcaster with books */
3884 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3888 /* Reset vertical */
3891 /* Vertical location */
3892 y = (j < 3) ? 0 : (m[j - 3] + 2);
3894 /* Horizontal location */
3898 for (i = 0; i < 32; i++)
3900 byte a = TERM_WHITE;
3902 /* Access the spell */
3903 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3905 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3909 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3912 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
3915 if (s_ptr->slevel >= 99)
3919 strcpy(name, "(ȽÆÉÉÔǽ)");
3921 strcpy(name, "(illegible)");
3931 ((p_ptr->spell_forgotten1 & (1L << i))) :
3932 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3939 else if (!((j < 1) ?
3940 (p_ptr->spell_learned1 & (1L << i)) :
3941 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3948 else if (!((j < 1) ?
3949 (p_ptr->spell_worked1 & (1L << i)) :
3950 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3956 /* Dump the spell --(-- */
3957 sprintf(out_val, "%c/%c) %-20.20s",
3958 I2A(n / 8), I2A(n % 8), name);
3963 /* Dump onto the window */
3964 Term_putstr(x, m[j], -1, a, out_val);
3974 * Returns experience of a spell
3976 s16b experience_of_spell(int spell, int use_realm)
3978 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3979 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3980 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3981 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3987 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3989 int mod_need_mana(int need_mana, int spell, int realm)
3991 #define MANA_CONST 2400
3993 #define DEC_MANA_DIV 3
3996 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
3999 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4000 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4002 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4003 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4004 need_mana /= MANA_CONST * MANA_DIV;
4005 if (need_mana < 1) need_mana = 1;
4008 /* Non-realm magic */
4011 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4023 * Modify spell fail rate
4024 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4026 int mod_spell_chance_1(int chance)
4028 chance += p_ptr->to_m_chance;
4030 if (p_ptr->heavy_spell) chance += 20;
4032 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4033 else if (p_ptr->easy_spell) chance -= 3;
4034 else if (p_ptr->dec_mana) chance -= 2;
4041 * Modify spell fail rate (as "suffix" process)
4042 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4043 * Note: variable "chance" cannot be negative.
4045 int mod_spell_chance_2(int chance)
4047 if (p_ptr->dec_mana) chance--;
4049 if (p_ptr->heavy_spell) chance += 5;
4051 return MAX(chance, 0);
4056 * Returns spell chance of failure for spell -RAK-
4058 s16b spell_chance(int spell, int use_realm)
4060 int chance, minfail;
4063 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4066 /* Paranoia -- must be literate */
4067 if (!mp_ptr->spell_book) return (100);
4069 if (use_realm == REALM_HISSATSU) return 0;
4071 /* Access the spell */
4072 if (!is_magic(use_realm))
4074 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4078 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4081 /* Extract the base spell failure rate */
4082 chance = s_ptr->sfail;
4084 /* Reduce failure rate by "effective" level adjustment */
4085 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4087 /* Reduce failure rate by INT/WIS adjustment */
4088 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4091 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4093 /* Extract mana consumption rate */
4094 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4096 /* Not enough mana to cast */
4097 if (need_mana > p_ptr->csp)
4099 chance += 5 * (need_mana - p_ptr->csp);
4102 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4104 /* Extract the minimum failure rate */
4105 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4108 * Non mage/priest characters never get too good
4109 * (added high mage, mindcrafter)
4111 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4113 if (minfail < 5) minfail = 5;
4116 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4117 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4118 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4120 chance = mod_spell_chance_1(chance);
4122 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4123 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4124 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4126 /* Minimum failure rate */
4127 if (chance < minfail) chance = minfail;
4129 /* Stunning makes spells harder */
4130 if (p_ptr->stun > 50) chance += 25;
4131 else if (p_ptr->stun) chance += 15;
4133 /* Always a 5 percent chance of working */
4134 if (chance > 95) chance = 95;
4136 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4137 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4139 s16b exp = experience_of_spell(spell, use_realm);
4140 if (exp >= SPELL_EXP_EXPERT) chance--;
4141 if (exp >= SPELL_EXP_MASTER) chance--;
4144 /* Return the chance */
4145 return mod_spell_chance_2(chance);
4151 * Determine if a spell is "okay" for the player to cast or study
4152 * The spell must be legible, not forgotten, and also, to cast,
4153 * it must be known, and to study, it must not be known.
4155 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4159 /* Access the spell */
4160 if (!is_magic(use_realm))
4162 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4166 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4169 /* Spell is illegal */
4170 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4172 /* Spell is forgotten */
4173 if ((use_realm == p_ptr->realm2) ?
4174 (p_ptr->spell_forgotten2 & (1L << spell)) :
4175 (p_ptr->spell_forgotten1 & (1L << spell)))
4181 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4182 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4184 /* Spell is learned */
4185 if ((use_realm == p_ptr->realm2) ?
4186 (p_ptr->spell_learned2 & (1L << spell)) :
4187 (p_ptr->spell_learned1 & (1L << spell)))
4190 return (!study_pray);
4193 /* Okay to study, not to cast */
4200 * Extra information on a spell -DRS-
4202 * We can use up to 14 characters of the buffer 'p'
4204 * The strings in this function were extracted from the code in the
4205 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4207 static void spell_info(char *p, int spell, int use_realm)
4209 int plev = p_ptr->lev;
4212 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4213 p_ptr->pclass == CLASS_HIGH_MAGE ||
4214 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4216 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4217 p_ptr->pclass == CLASS_HIGH_MAGE ||
4218 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4220 cptr s_dam = "»½ý:";
4221 cptr s_dur = "´ü´Ö:";
4222 cptr s_range = "ÈÏ°Ï:";
4223 cptr s_heal = "²óÉü:";
4224 cptr s_random = "¥é¥ó¥À¥à";
4225 cptr s_delay = "ÃÙ±ä:";
4227 cptr s_dam = "dam ";
4228 cptr s_dur = "dur ";
4229 cptr s_range = "range ";
4230 cptr s_heal = "heal ";
4231 cptr s_random = "random";
4232 cptr s_delay = "delay ";
4237 /* Analyze the spell */
4240 case REALM_LIFE: /* Life */
4243 case 0: sprintf(p, " %s2d10", s_heal); break;
4244 case 1: sprintf(p, " %s12+d12", s_dur); break;
4245 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4246 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4247 case 5: sprintf(p, " %s4d10", s_heal); break;
4248 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4249 case 10: sprintf(p, " %s8d10", s_heal); break;
4250 case 11: sprintf(p, " %s20+d20", s_dur); break;
4251 case 14: sprintf(p, " %s300", s_heal); break;
4252 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4253 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4254 case 21: sprintf(p, " %s15+d21", s_delay); break;
4255 case 29: sprintf(p, " %s2000", s_heal); break;
4256 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4260 case REALM_SORCERY: /* Sorcery */
4263 case 1: sprintf(p, " %s10", s_range); break;
4264 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4265 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4266 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4267 case 18: sprintf(p, " %s25+d30", s_dur); break;
4268 case 22: sprintf(p, " %s15+d21", s_delay); break;
4269 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4270 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4272 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4274 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4276 case 27: sprintf(p, " %s25+d30", s_dur); break;
4277 case 31: sprintf(p, " %s4+d4", s_dur); break;
4281 case REALM_NATURE: /* Nature */
4285 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4287 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4289 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4290 case 6: sprintf(p, " %s20+d20", s_dur); break;
4291 case 7: sprintf(p, " %s2d8", s_heal); break;
4292 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4293 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4294 case 12: sprintf(p, " %s6d8", s_dam); break;
4295 case 15: sprintf(p, " %s500", s_heal); break;
4296 case 17: sprintf(p, " %s20+d30", s_dur); break;
4297 case 18: sprintf(p, " %s20+d20", s_dur); break;
4299 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4301 case 24: sprintf(p, " rad 10"); break;
4303 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4304 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4305 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4306 case 29: sprintf(p, " %s75", s_dam); break;
4307 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4311 case REALM_CHAOS: /* Chaos */
4314 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4315 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4316 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4317 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4318 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4319 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4320 case 8: sprintf(p, " %s", s_random); break;
4321 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4322 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4323 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4324 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4325 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4326 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4327 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4328 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4329 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4331 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4333 case 25: sprintf(p, " dam %d each", plev * 2); break;
4335 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4336 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4337 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4338 case 30: sprintf(p, " %s%ld", s_dam, p_ptr->chp); break;
4339 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4343 case REALM_DEATH: /* Death */
4346 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4347 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4348 case 5: sprintf(p, " %s20+d20", s_dur); break;
4349 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4350 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4351 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4353 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4355 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4357 case 16: sprintf(p, " %s25+d25", s_dur); break;
4358 case 17: sprintf(p, " %s", s_random); break;
4359 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4360 case 19: sprintf(p, " %s25+d25", s_dur); break;
4361 case 21: sprintf(p, " %s3*100", s_dam); break;
4362 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4363 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4364 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4365 case 30: sprintf(p, " %s666", s_dam); break;
4366 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4370 case REALM_TRUMP: /* Trump */
4373 case 0: sprintf(p, " %s10", s_range); break;
4374 case 2: sprintf(p, " %s", s_random); break;
4375 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4376 case 5: sprintf(p, " %s25+d30", s_dur); break;
4378 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4380 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4382 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4383 case 14: sprintf(p, " %s15+d21", s_delay); break;
4384 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4386 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4388 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4393 case REALM_ARCANE: /* Arcane */
4396 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4397 case 4: sprintf(p, " %s10", s_range); break;
4398 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4399 case 7: sprintf(p, " %s2d8", s_heal); break;
4403 case 17: sprintf(p, " %s20+d20", s_dur); break;
4404 case 18: sprintf(p, " %s4d8", s_heal); break;
4405 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4406 case 21: sprintf(p, " %s6d8", s_dam); break;
4407 case 24: sprintf(p, " %s24+d24", s_dur); break;
4408 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4409 case 30: sprintf(p, " %s15+d21", s_delay); break;
4410 case 31: sprintf(p, " %s25+d30", s_dur); break;
4414 case REALM_ENCHANT: /* Craft */
4417 case 0: sprintf(p, " %s100+d100", s_dur); break;
4418 case 1: sprintf(p, " %s80+d80", s_dur); break;
4424 case 18: sprintf(p, " %s20+d20", s_dur); break;
4425 case 5: sprintf(p, " %s25+d25", s_dur); break;
4426 case 8: sprintf(p, " %s24+d24", s_dur); break;
4427 case 11: sprintf(p, " %s25+d25", s_dur); break;
4428 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4429 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4430 case 16: sprintf(p, " %s25+d30", s_dur); break;
4431 case 17: sprintf(p, " %s30+d20", s_dur); break;
4432 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4433 case 20: sprintf(p, " %s50+d50", s_dur); break;
4434 case 23: sprintf(p, " %s20+d20", s_dur); break;
4435 case 31: sprintf(p, " %s13+d13", s_dur); break;
4439 case REALM_DAEMON: /* Daemon */
4442 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4443 case 2: sprintf(p, " %s12+d12", s_dur); break;
4444 case 3: sprintf(p, " %s20+d20", s_dur); break;
4445 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4446 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4447 case 10: sprintf(p, " %s20+d20", s_dur); break;
4448 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4449 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4450 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4451 case 16: sprintf(p, " %s30+d25", s_dur); break;
4452 case 17: sprintf(p, " %s20+d20", s_dur); break;
4453 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4454 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4455 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4456 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4457 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4458 case 24: sprintf(p, " %s25+d25", s_dur); break;
4459 case 25: sprintf(p, " %s20+d20", s_dur); break;
4460 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4461 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4462 case 30: sprintf(p, " %s600", s_dam); break;
4463 case 31: sprintf(p, " %s15+d15", s_dur); break;
4467 case REALM_CRUSADE: /* Crusade */
4470 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4471 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4473 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4475 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4477 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4478 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4479 case 12: sprintf(p, " %s24+d24", s_dur); break;
4480 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4481 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4483 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4485 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4487 case 18: sprintf(p, " %s18+d18", s_dur); break;
4488 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4489 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4490 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4491 case 24: sprintf(p, " %s25+d25", s_dur); break;
4492 case 28: sprintf(p, " %s10+d10", s_dur); break;
4494 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4496 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4499 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4501 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4506 case REALM_MUSIC: /* Music */
4509 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4510 case 4 : sprintf(p, " %s2d6", s_heal); break;
4511 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4512 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4513 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4514 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4515 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4516 case 28: sprintf(p, " %s15d10", s_heal); break;
4517 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4522 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4524 sprintf(p, "Unknown type: %d.", use_realm);
4531 * Print a list of spells (for browsing or casting or viewing)
4533 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4535 int i, spell, exp_level, increment = 64;
4547 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4549 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4551 msg_print("Warning! print_spells called with null realm");
4555 /* Title the list */
4557 if (use_realm == REALM_HISSATSU)
4559 strcpy(buf," Lv MP");
4561 strcpy(buf," Lv SP");
4565 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4567 strcpy(buf,"Profic Lv SP Fail Effect");
4571 put_str("̾Á°", y, x + 5);
4572 put_str(buf, y, x + 29);
4574 put_str("Name", y, x + 5);
4575 put_str(buf, y, x + 29);
4578 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4579 else if (use_realm == p_ptr->realm1) increment = 0;
4580 else if (use_realm == p_ptr->realm2) increment = 32;
4582 /* Dump the spells */
4583 for (i = 0; i < num; i++)
4585 /* Access the spell */
4588 /* Access the spell */
4589 if (!is_magic(use_realm))
4591 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4595 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4598 if (use_realm == REALM_HISSATSU)
4599 need_mana = s_ptr->smana;
4602 s16b exp = experience_of_spell(spell, use_realm);
4604 /* Extract mana consumption rate */
4605 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4607 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4608 else exp_level = spell_exp_level(exp);
4611 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4612 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4613 else if (s_ptr->slevel >= 99) max = TRUE;
4614 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4616 strncpy(ryakuji, exp_level_str[exp_level], 4);
4621 if (use_menu && target_spell)
4623 if (i == (target_spell-1))
4625 strcpy(out_val, " ¡Õ ");
4627 strcpy(out_val, " > ");
4630 strcpy(out_val, " ");
4632 else sprintf(out_val, " %c) ", I2A(i));
4633 /* Skip illegible spells */
4634 if (s_ptr->slevel >= 99)
4637 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4639 strcat(out_val, format("%-30s", "(illegible)"));
4642 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4646 /* XXX XXX Could label spells above the players level */
4648 /* Get extra info */
4649 spell_info(info, spell, use_realm);
4654 /* Assume spell is known and tried */
4655 line_attr = TERM_WHITE;
4657 /* Analyze the spell */
4658 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4660 if (s_ptr->slevel > p_ptr->max_plv)
4665 comment = " unknown";
4668 line_attr = TERM_L_BLUE;
4670 else if (s_ptr->slevel > p_ptr->lev)
4675 comment = " forgotten";
4678 line_attr = TERM_YELLOW;
4681 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4686 comment = " unknown";
4689 line_attr = TERM_L_BLUE;
4691 else if ((use_realm == p_ptr->realm1) ?
4692 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4693 ((p_ptr->spell_forgotten2 & (1L << spell))))
4698 comment = " forgotten";
4701 line_attr = TERM_YELLOW;
4703 else if (!((use_realm == p_ptr->realm1) ?
4704 (p_ptr->spell_learned1 & (1L << spell)) :
4705 (p_ptr->spell_learned2 & (1L << spell))))
4710 comment = " unknown";
4713 line_attr = TERM_L_BLUE;
4715 else if (!((use_realm == p_ptr->realm1) ?
4716 (p_ptr->spell_worked1 & (1L << spell)) :
4717 (p_ptr->spell_worked2 & (1L << spell))))
4720 comment = " ̤·Ð¸³";
4722 comment = " untried";
4725 line_attr = TERM_L_GREEN;
4728 /* Dump the spell --(-- */
4729 if (use_realm == REALM_HISSATSU)
4731 strcat(out_val, format("%-25s %2d %4d",
4732 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4733 s_ptr->slevel, need_mana));
4737 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4738 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4739 (max ? '!' : ' '), ryakuji,
4740 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4742 c_prt(line_attr, out_val, y + i + 1, x);
4745 /* Clear the bottom line */
4746 prt("", y + i + 1, x);
4751 * Note that amulets, rods, and high-level spell books are immune
4752 * to "inventory damage" of any kind. Also sling ammo and shovels.
4757 * Does a given class of objects (usually) hate acid?
4758 * Note that acid can either melt or corrode something.
4760 bool hates_acid(object_type *o_ptr)
4762 /* Analyze the type */
4763 switch (o_ptr->tval)
4765 /* Wearable items */
4785 /* Staffs/Scrolls are wood/paper */
4798 /* Junk is useless */
4812 * Does a given object (usually) hate electricity?
4814 bool hates_elec(object_type *o_ptr)
4816 switch (o_ptr->tval)
4830 * Does a given object (usually) hate fire?
4831 * Hafted/Polearm weapons have wooden shafts.
4832 * Arrows/Bows are mostly wooden.
4834 bool hates_fire(object_type *o_ptr)
4836 /* Analyze the type */
4837 switch (o_ptr->tval)
4855 case TV_SORCERY_BOOK:
4856 case TV_NATURE_BOOK:
4860 case TV_ARCANE_BOOK:
4861 case TV_ENCHANT_BOOK:
4862 case TV_DAEMON_BOOK:
4863 case TV_CRUSADE_BOOK:
4865 case TV_HISSATSU_BOOK:
4876 /* Staffs/Scrolls burn */
4889 * Does a given object (usually) hate cold?
4891 bool hates_cold(object_type *o_ptr)
4893 switch (o_ptr->tval)
4910 int set_acid_destroy(object_type *o_ptr)
4912 u32b flgs[TR_FLAG_SIZE];
4913 if (!hates_acid(o_ptr)) return (FALSE);
4914 object_flags(o_ptr, flgs);
4915 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4923 int set_elec_destroy(object_type *o_ptr)
4925 u32b flgs[TR_FLAG_SIZE];
4926 if (!hates_elec(o_ptr)) return (FALSE);
4927 object_flags(o_ptr, flgs);
4928 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4936 int set_fire_destroy(object_type *o_ptr)
4938 u32b flgs[TR_FLAG_SIZE];
4939 if (!hates_fire(o_ptr)) return (FALSE);
4940 object_flags(o_ptr, flgs);
4941 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4949 int set_cold_destroy(object_type *o_ptr)
4951 u32b flgs[TR_FLAG_SIZE];
4952 if (!hates_cold(o_ptr)) return (FALSE);
4953 object_flags(o_ptr, flgs);
4954 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4960 * Destroys a type of item on a given percent chance
4961 * Note that missiles are no longer necessarily all destroyed
4962 * Destruction taken from "melee.c" code for "stealing".
4963 * New-style wands and rods handled correctly. -LM-
4964 * Returns number of items destroyed.
4966 int inven_damage(inven_func typ, int perc)
4970 char o_name[MAX_NLEN];
4972 /* Multishadow effects is determined by turn */
4973 if( p_ptr->multishadow && (turn & 1) )return 0;
4975 if (p_ptr->inside_arena) return 0;
4977 /* Count the casualties */
4980 /* Scan through the slots backwards */
4981 for (i = 0; i < INVEN_PACK; i++)
4983 o_ptr = &inventory[i];
4985 /* Skip non-objects */
4986 if (!o_ptr->k_idx) continue;
4988 /* Hack -- for now, skip artifacts */
4989 if (object_is_artifact(o_ptr)) continue;
4991 /* Give this item slot a shot at death */
4994 /* Count the casualties */
4995 for (amt = j = 0; j < o_ptr->number; ++j)
4997 if (randint0(100) < perc) amt++;
5000 /* Some casualities */
5003 /* Get a description */
5004 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5008 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
5010 msg_format("%sour %s (%c) %s destroyed!",
5014 o_name, index_to_label(i),
5015 ((o_ptr->number > 1) ?
5016 ((amt == o_ptr->number) ? "Á´Éô" :
5017 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
5019 ((o_ptr->number > 1) ?
5020 ((amt == o_ptr->number) ? "All of y" :
5021 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
5022 o_name, index_to_label(i),
5023 ((amt > 1) ? "were" : "was"));
5027 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
5028 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
5031 /* Potions smash open */
5032 if (object_is_potion(o_ptr))
5034 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
5037 /* Reduce the charges of rods/wands */
5038 reduce_charges(o_ptr, amt);
5040 /* Destroy "amt" items */
5041 inven_item_increase(i, -amt);
5042 inven_item_optimize(i);
5044 /* Count the casualties */
5050 /* Return the casualty count */
5056 * Acid has hit the player, attempt to affect some armor.
5058 * Note that the "base armor" of an object never changes.
5060 * If any armor is damaged (or resists), the player takes less damage.
5062 static int minus_ac(void)
5064 object_type *o_ptr = NULL;
5065 u32b flgs[TR_FLAG_SIZE];
5066 char o_name[MAX_NLEN];
5069 /* Pick a (possibly empty) inventory slot */
5070 switch (randint1(7))
5072 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5073 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5074 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5075 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5076 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5077 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5078 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5081 /* Nothing to damage */
5082 if (!o_ptr->k_idx) return (FALSE);
5084 if (!object_is_armour(o_ptr)) return (FALSE);
5086 /* No damage left to be done */
5087 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5091 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5093 /* Extract the flags */
5094 object_flags(o_ptr, flgs);
5096 /* Object resists */
5097 if (have_flag(flgs, TR_IGNORE_ACID))
5100 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5102 msg_format("Your %s is unaffected!", o_name);
5111 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5113 msg_format("Your %s is damaged!", o_name);
5117 /* Damage the item */
5120 /* Calculate bonuses */
5121 p_ptr->update |= (PU_BONUS);
5124 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5128 /* Item was damaged */
5134 * Hurt the player with Acid
5136 int acid_dam(int dam, cptr kb_str, int monspell)
5139 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5140 bool double_resist = IS_OPPOSE_ACID();
5142 /* Total Immunity */
5143 if (p_ptr->immune_acid || (dam <= 0))
5145 learn_spell(monspell);
5149 /* Vulnerability (Ouch!) */
5150 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5151 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5153 /* Resist the damage */
5154 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5155 if (double_resist) dam = (dam + 2) / 3;
5157 if ((!(double_resist || p_ptr->resist_acid)) &&
5158 one_in_(HURT_CHANCE))
5159 (void)do_dec_stat(A_CHR);
5161 /* If any armor gets hit, defend the player */
5162 if (minus_ac()) dam = (dam + 1) / 2;
5165 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5167 /* Inventory damage */
5168 if (!(double_resist && p_ptr->resist_acid))
5169 inven_damage(set_acid_destroy, inv);
5175 * Hurt the player with electricity
5177 int elec_dam(int dam, cptr kb_str, int monspell)
5180 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5181 bool double_resist = IS_OPPOSE_ELEC();
5183 /* Total immunity */
5184 if (p_ptr->immune_elec || (dam <= 0))
5186 learn_spell(monspell);
5190 /* Vulnerability (Ouch!) */
5191 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5192 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5193 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5195 /* Resist the damage */
5196 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5197 if (double_resist) dam = (dam + 2) / 3;
5199 if ((!(double_resist || p_ptr->resist_elec)) &&
5200 one_in_(HURT_CHANCE))
5201 (void)do_dec_stat(A_DEX);
5204 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5206 /* Inventory damage */
5207 if (!(double_resist && p_ptr->resist_elec))
5208 inven_damage(set_elec_destroy, inv);
5215 * Hurt the player with Fire
5217 int fire_dam(int dam, cptr kb_str, int monspell)
5220 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5221 bool double_resist = IS_OPPOSE_FIRE();
5223 /* Totally immune */
5224 if (p_ptr->immune_fire || (dam <= 0))
5226 learn_spell(monspell);
5230 /* Vulnerability (Ouch!) */
5231 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5232 if (prace_is_(RACE_ENT)) dam += dam / 3;
5233 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5235 /* Resist the damage */
5236 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5237 if (double_resist) dam = (dam + 2) / 3;
5239 if ((!(double_resist || p_ptr->resist_fire)) &&
5240 one_in_(HURT_CHANCE))
5241 (void)do_dec_stat(A_STR);
5244 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5246 /* Inventory damage */
5247 if (!(double_resist && p_ptr->resist_fire))
5248 inven_damage(set_fire_destroy, inv);
5255 * Hurt the player with Cold
5257 int cold_dam(int dam, cptr kb_str, int monspell)
5260 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5261 bool double_resist = IS_OPPOSE_COLD();
5263 /* Total immunity */
5264 if (p_ptr->immune_cold || (dam <= 0))
5266 learn_spell(monspell);
5270 /* Vulnerability (Ouch!) */
5271 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5272 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5274 /* Resist the damage */
5275 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5276 if (double_resist) dam = (dam + 2) / 3;
5278 if ((!(double_resist || p_ptr->resist_cold)) &&
5279 one_in_(HURT_CHANCE))
5280 (void)do_dec_stat(A_STR);
5283 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5285 /* Inventory damage */
5286 if (!(double_resist && p_ptr->resist_cold))
5287 inven_damage(set_cold_destroy, inv);
5293 bool rustproof(void)
5297 char o_name[MAX_NLEN];
5300 item_tester_no_ryoute = TRUE;
5301 /* Select a piece of armour */
5302 item_tester_hook = object_is_armour;
5306 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5307 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5309 q = "Rustproof which piece of armour? ";
5310 s = "You have nothing to rustproof.";
5313 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5315 /* Get the item (in the pack) */
5318 o_ptr = &inventory[item];
5321 /* Get the item (on the floor) */
5324 o_ptr = &o_list[0 - item];
5329 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5331 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5333 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
5336 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5338 msg_format("%s %s look%s as good as new!",
5339 ((item >= 0) ? "Your" : "The"), o_name,
5340 ((o_ptr->number > 1) ? "" : "s"));
5347 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5349 msg_format("%s %s %s now protected against corrosion.",
5350 ((item >= 0) ? "Your" : "The"), o_name,
5351 ((o_ptr->number > 1) ? "are" : "is"));
5362 * Curse the players armor
5364 bool curse_armor(void)
5369 char o_name[MAX_NLEN];
5372 /* Curse the body armor */
5373 o_ptr = &inventory[INVEN_BODY];
5375 /* Nothing to curse */
5376 if (!o_ptr->k_idx) return (FALSE);
5380 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5382 /* Attempt a saving throw for artifacts */
5383 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
5387 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5388 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5390 msg_format("A %s tries to %s, but your %s resists the effects!",
5391 "terrible black aura", "surround your armor", o_name);
5396 /* not artifact or failed save... */
5401 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5403 msg_format("A terrible black aura blasts your %s!", o_name);
5406 chg_virtue(V_ENCHANT, -5);
5408 /* Blast the armor */
5410 o_ptr->name2 = EGO_BLASTED;
5411 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5418 for (i = 0; i < TR_FLAG_SIZE; i++)
5419 o_ptr->art_flags[i] = 0;
5422 o_ptr->curse_flags = TRC_CURSED;
5425 o_ptr->ident |= (IDENT_BROKEN);
5427 /* Recalculate bonuses */
5428 p_ptr->update |= (PU_BONUS);
5430 /* Recalculate mana */
5431 p_ptr->update |= (PU_MANA);
5434 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5442 * Curse the players weapon
5444 bool curse_weapon(bool force, int slot)
5450 char o_name[MAX_NLEN];
5453 /* Curse the weapon */
5454 o_ptr = &inventory[slot];
5456 /* Nothing to curse */
5457 if (!o_ptr->k_idx) return (FALSE);
5461 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5463 /* Attempt a saving throw */
5464 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
5468 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5469 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5471 msg_format("A %s tries to %s, but your %s resists the effects!",
5472 "terrible black aura", "surround your weapon", o_name);
5477 /* not artifact or failed save... */
5482 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5484 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5487 chg_virtue(V_ENCHANT, -5);
5489 /* Shatter the weapon */
5491 o_ptr->name2 = EGO_SHATTERED;
5492 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5493 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5499 for (i = 0; i < TR_FLAG_SIZE; i++)
5500 o_ptr->art_flags[i] = 0;
5504 o_ptr->curse_flags = TRC_CURSED;
5507 o_ptr->ident |= (IDENT_BROKEN);
5509 /* Recalculate bonuses */
5510 p_ptr->update |= (PU_BONUS);
5512 /* Recalculate mana */
5513 p_ptr->update |= (PU_MANA);
5516 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5525 * Enchant some bolts
5527 bool brand_bolts(void)
5531 /* Use the first acceptable bolts */
5532 for (i = 0; i < INVEN_PACK; i++)
5534 object_type *o_ptr = &inventory[i];
5536 /* Skip non-bolts */
5537 if (o_ptr->tval != TV_BOLT) continue;
5539 /* Skip artifacts and ego-items */
5540 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5543 /* Skip cursed/broken items */
5544 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5547 if (randint0(100) < 75) continue;
5551 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5553 msg_print("Your bolts are covered in a fiery aura!");
5558 o_ptr->name2 = EGO_FLAME;
5561 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5568 if (flush_failure) flush();
5572 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5574 msg_print("The fiery enchantment failed.");
5584 * Helper function -- return a "nearby" race for polymorphing
5586 * Note that this function is one of the more "dangerous" ones...
5588 static s16b poly_r_idx(int r_idx)
5590 monster_race *r_ptr = &r_info[r_idx];
5592 int i, r, lev1, lev2;
5594 /* Hack -- Uniques/Questors never polymorph */
5595 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5596 (r_ptr->flags1 & RF1_QUESTOR))
5599 /* Allowable range of "levels" for resulting monster */
5600 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5601 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5603 /* Pick a (possibly new) non-unique race */
5604 for (i = 0; i < 1000; i++)
5606 /* Pick a new race, using a level calculation */
5607 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5609 /* Handle failure */
5615 /* Ignore unique monsters */
5616 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5618 /* Ignore monsters with incompatible levels */
5619 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5621 /* Use that index */
5633 bool polymorph_monster(int y, int x)
5635 cave_type *c_ptr = &cave[y][x];
5636 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5637 bool polymorphed = FALSE;
5639 int old_r_idx = m_ptr->r_idx;
5640 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5641 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5642 monster_type back_m;
5644 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5646 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5648 /* Memorize the monster before polymorphing */
5651 /* Pick a "new" monster race */
5652 new_r_idx = poly_r_idx(old_r_idx);
5654 /* Handle polymorph */
5655 if (new_r_idx != old_r_idx)
5659 /* Get the monsters attitude */
5660 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5661 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5662 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5664 /* "Kill" the "old" monster */
5665 delete_monster_idx(c_ptr->m_idx);
5667 /* Create a new monster (no groups) */
5668 if (place_monster_aux(0, y, x, new_r_idx, mode))
5675 /* Placing the new monster failed */
5676 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5677 m_list[hack_m_idx_ii] = back_m;
5680 if (targeted) target_who = hack_m_idx_ii;
5681 if (health_tracked) health_track(hack_m_idx_ii);
5691 static bool dimension_door_aux(int x, int y)
5693 int plev = p_ptr->lev;
5695 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5697 if (!cave_player_teleportable_bold(y, x, FALSE) ||
5698 (distance(y, x, py, px) > plev / 2 + 10) ||
5699 (!randint0(plev / 10 + 10)))
5701 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5702 teleport_player((plev + 2) * 2, TRUE);
5709 teleport_player_to(y, x, TRUE, FALSE);
5720 bool dimension_door(void)
5724 /* Rerutn FALSE if cancelled */
5725 if (!tgt_pt(&x, &y)) return FALSE;
5727 if (dimension_door_aux(x, y)) return TRUE;
5730 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5732 msg_print("You fail to exit the astral plane correctly!");
5740 * Mirror Master's Dimension Door
5742 bool mirror_tunnel(void)
5746 /* Rerutn FALSE if cancelled */
5747 if (!tgt_pt(&x, &y)) return FALSE;
5749 if (dimension_door_aux(x, y)) return TRUE;
5752 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5754 msg_print("You fail to pass the mirror plane correctly!");
5761 bool eat_magic(int power)
5763 object_type * o_ptr;
5766 int recharge_strength = 0;
5772 char o_name[MAX_NLEN];
5774 item_tester_hook = item_tester_hook_recharge;
5778 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5779 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5781 q = "Drain which item? ";
5782 s = "You have nothing to drain.";
5785 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5789 o_ptr = &inventory[item];
5793 o_ptr = &o_list[0 - item];
5796 k_ptr = &k_info[o_ptr->k_idx];
5797 lev = k_info[o_ptr->k_idx].level;
5799 if (o_ptr->tval == TV_ROD)
5801 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5804 if (one_in_(recharge_strength))
5806 /* Activate the failure code. */
5811 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5814 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5816 msg_print("You can't absorb energy from a discharged rod.");
5823 o_ptr->timeout += k_ptr->pval;
5829 /* All staffs, wands. */
5830 recharge_strength = (100 + power - lev) / 15;
5833 if (recharge_strength < 0) recharge_strength = 0;
5836 if (one_in_(recharge_strength))
5838 /* Activate the failure code. */
5843 if (o_ptr->pval > 0)
5845 p_ptr->csp += lev / 2;
5848 /* XXX Hack -- unstack if necessary */
5849 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5854 /* Get local object */
5857 /* Obtain a local object */
5858 object_copy(q_ptr, o_ptr);
5860 /* Modify quantity */
5863 /* Restore the charges */
5866 /* Unstack the used item */
5868 p_ptr->total_weight -= q_ptr->weight;
5869 item = inven_carry(q_ptr);
5873 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5875 msg_print("You unstack your staff.");
5883 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5885 msg_print("There's no energy there to absorb!");
5889 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5893 /* Inflict the penalties for failing a recharge. */
5896 /* Artifacts are never destroyed. */
5897 if (object_is_fixed_artifact(o_ptr))
5899 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5901 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5903 msg_format("The recharging backfires - %s is completely drained!", o_name);
5907 /* Artifact rods. */
5908 if (o_ptr->tval == TV_ROD)
5909 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5911 /* Artifact wands and staffs. */
5912 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5917 /* Get the object description */
5918 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5920 /*** Determine Seriousness of Failure ***/
5922 /* Mages recharge objects more safely. */
5923 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)
5925 /* 10% chance to blow up one rod, otherwise draining. */
5926 if (o_ptr->tval == TV_ROD)
5928 if (one_in_(10)) fail_type = 2;
5931 /* 75% chance to blow up one wand, otherwise draining. */
5932 else if (o_ptr->tval == TV_WAND)
5934 if (!one_in_(3)) fail_type = 2;
5937 /* 50% chance to blow up one staff, otherwise no effect. */
5938 else if (o_ptr->tval == TV_STAFF)
5940 if (one_in_(2)) fail_type = 2;
5945 /* All other classes get no special favors. */
5948 /* 33% chance to blow up one rod, otherwise draining. */
5949 if (o_ptr->tval == TV_ROD)
5951 if (one_in_(3)) fail_type = 2;
5954 /* 20% chance of the entire stack, else destroy one wand. */
5955 else if (o_ptr->tval == TV_WAND)
5957 if (one_in_(5)) fail_type = 3;
5960 /* Blow up one staff. */
5961 else if (o_ptr->tval == TV_STAFF)
5967 /*** Apply draining and destruction. ***/
5969 /* Drain object or stack of objects. */
5972 if (o_ptr->tval == TV_ROD)
5975 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
5977 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
5980 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5982 else if (o_ptr->tval == TV_WAND)
5985 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
5987 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
5992 /* Staffs aren't drained. */
5995 /* Destroy an object or one in a stack of objects. */
5998 if (o_ptr->number > 1)
6001 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
6003 msg_format("Wild magic consumes one of your %s!", o_name);
6006 /* Reduce rod stack maximum timeout, drain wands. */
6007 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
6008 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
6013 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
6015 msg_format("Wild magic consumes your %s!", o_name);
6018 /* Reduce and describe inventory */
6021 inven_item_increase(item, -1);
6022 inven_item_describe(item);
6023 inven_item_optimize(item);
6026 /* Reduce and describe floor item */
6029 floor_item_increase(0 - item, -1);
6030 floor_item_describe(0 - item);
6031 floor_item_optimize(0 - item);
6035 /* Destroy all members of a stack of objects. */
6038 if (o_ptr->number > 1)
6040 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
6042 msg_format("Wild magic consumes all your %s!", o_name);
6047 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
6049 msg_format("Wild magic consumes your %s!", o_name);
6054 /* Reduce and describe inventory */
6057 inven_item_increase(item, -999);
6058 inven_item_describe(item);
6059 inven_item_optimize(item);
6062 /* Reduce and describe floor item */
6065 floor_item_increase(0 - item, -999);
6066 floor_item_describe(0 - item);
6067 floor_item_optimize(0 - item);
6073 if (p_ptr->csp > p_ptr->msp)
6075 p_ptr->csp = p_ptr->msp;
6078 /* Redraw mana and hp */
6079 p_ptr->redraw |= (PR_MANA);
6081 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6082 p_ptr->window |= (PW_INVEN);
6088 bool summon_kin_player(int level, int y, int x, u32b mode)
6090 bool pet = (bool)(mode & PM_FORCE_PET);
6091 if (!pet) mode |= PM_NO_PET;
6093 switch (p_ptr->mimic_form)
6096 switch (p_ptr->prace)
6100 case RACE_BARBARIAN:
6103 summon_kin_type = 'p';
6113 case RACE_MIND_FLAYER:
6116 summon_kin_type = 'h';
6119 summon_kin_type = 'o';
6121 case RACE_HALF_TROLL:
6122 summon_kin_type = 'T';
6124 case RACE_HALF_OGRE:
6125 summon_kin_type = 'O';
6127 case RACE_HALF_GIANT:
6128 case RACE_HALF_TITAN:
6130 summon_kin_type = 'P';
6133 summon_kin_type = 'y';
6136 summon_kin_type = 'K';
6139 summon_kin_type = 'k';
6142 if (one_in_(13)) summon_kin_type = 'U';
6143 else summon_kin_type = 'u';
6145 case RACE_DRACONIAN:
6146 summon_kin_type = 'd';
6150 summon_kin_type = 'g';
6153 if (one_in_(13)) summon_kin_type = 'L';
6154 else summon_kin_type = 's';
6157 summon_kin_type = 'z';
6160 summon_kin_type = 'V';
6163 summon_kin_type = 'G';
6166 summon_kin_type = 'I';
6169 summon_kin_type = '#';
6172 summon_kin_type = 'A';
6175 summon_kin_type = 'U';
6178 summon_kin_type = 'p';
6183 if (one_in_(13)) summon_kin_type = 'U';
6184 else summon_kin_type = 'u';
6186 case MIMIC_DEMON_LORD:
6187 summon_kin_type = 'U';
6190 summon_kin_type = 'V';
6193 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);