4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Spell code (part 3) */
15 /* Maximum number of tries for teleporting */
18 /* 1/x chance of reducing stats (for elemental attacks) */
19 #define HURT_CHANCE 16
23 * Teleport a monster, normally up to "dis" grids away.
25 * Attempt to move the monster at least "dis/2" grids away.
27 * But allow variation to prevent infinite loops.
29 bool teleport_away(int m_idx, int dis, bool dec_valour)
31 int oy, ox, d, i, min;
37 monster_type *m_ptr = &m_list[m_idx];
41 if (!m_ptr->r_idx) return (FALSE);
43 /* Save the old location */
47 /* Minimum distance */
51 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
52 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
54 chg_virtue(V_VALOUR, -1);
62 /* Verify max distance */
63 if (dis > 200) dis = 200;
65 /* Try several locations */
66 for (i = 0; i < 500; i++)
68 /* Pick a (possibly illegal) location */
71 ny = rand_spread(oy, dis);
72 nx = rand_spread(ox, dis);
73 d = distance(oy, ox, ny, nx);
74 if ((d >= min) && (d <= dis)) break;
77 /* Ignore illegal locations */
78 if (!in_bounds(ny, nx)) continue;
80 /* Require "empty" floor space */
81 if (!cave_empty_bold(ny, nx)) continue;
83 /* Hack -- no teleport onto glyph of warding */
84 if (is_glyph_grid(&cave[ny][nx])) continue;
85 if (is_explosive_rune_grid(&cave[ny][nx])) continue;
87 /* ...nor onto the Pattern */
88 if (pattern_tile(ny, nx)) continue;
90 /* No teleporting into vaults and such */
91 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
92 if (cave[ny][nx].info & CAVE_ICKY) continue;
94 /* This grid looks good */
101 /* Increase the maximum distance */
104 /* Decrease the minimum distance */
107 /* Stop after MAX_TRIES tries */
108 if (tries > MAX_TRIES) return (FALSE);
112 sound(SOUND_TPOTHER);
114 /* Update the new location */
115 cave[ny][nx].m_idx = m_idx;
117 /* Update the old location */
118 cave[oy][ox].m_idx = 0;
120 /* Move the monster */
124 /* Forget the counter target */
127 /* Update the monster (new location) */
128 update_mon(m_idx, TRUE);
130 /* Redraw the old grid */
133 /* Redraw the new grid */
136 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
137 p_ptr->update |= (PU_MON_LITE);
145 * Teleport monster next to a grid near the given location
147 void teleport_monster_to(int m_idx, int ty, int tx, int power)
149 int ny, nx, oy, ox, d, i, min;
153 monster_type *m_ptr = &m_list[m_idx];
157 if (!m_ptr->r_idx) return;
160 if (randint1(100) > power) return;
166 /* Save the old location */
170 /* Minimum distance */
173 /* Look until done */
174 while (look && --attempts)
176 /* Verify max distance */
177 if (dis > 200) dis = 200;
179 /* Try several locations */
180 for (i = 0; i < 500; i++)
184 /* Pick a (possibly illegal) location */
187 ny = rand_spread(ty, dis);
188 nx = rand_spread(tx, dis);
189 d = distance(ty, tx, ny, nx);
190 if ((d >= min) && (d <= dis)) break;
193 /* Ignore illegal locations */
194 if (!in_bounds(ny, nx)) continue;
196 /* Require "empty" floor space */
197 if (!cave_empty_bold(ny, nx)) continue;
199 c_ptr = &cave[ny][nx];
201 /* Hack -- no teleport onto glyph of warding */
202 if (is_glyph_grid(c_ptr)) continue;
203 if (is_explosive_rune_grid(c_ptr)) continue;
205 /* ...nor onto the Pattern */
206 if (pattern_tile(ny, nx)) continue;
208 /* No teleporting into vaults and such */
209 /* if (c_ptr->info & (CAVE_ICKY)) continue; */
211 /* This grid looks good */
218 /* Increase the maximum distance */
221 /* Decrease the minimum distance */
225 if (attempts < 1) return;
228 sound(SOUND_TPOTHER);
230 /* Update the new location */
231 cave[ny][nx].m_idx = m_idx;
233 /* Update the old location */
234 cave[oy][ox].m_idx = 0;
236 /* Move the monster */
240 /* Update the monster (new location) */
241 update_mon(m_idx, TRUE);
243 /* Redraw the old grid */
246 /* Redraw the new grid */
249 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
250 p_ptr->update |= (PU_MON_LITE);
254 bool cave_teleportable_bold(int y, int x, bool passive)
256 cave_type *c_ptr = &cave[y][x];
257 feature_type *f_ptr = &f_info[c_ptr->feat];
259 /* Require "teleportable" space */
260 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
262 /* No teleporting into vaults and such */
263 if (c_ptr->info & CAVE_ICKY) return FALSE;
265 if (c_ptr->m_idx) return FALSE;
269 if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
271 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
273 if (!p_ptr->ffall && !p_ptr->can_swim) return FALSE;
276 if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
278 /* Always forbid deep lava */
279 if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
281 /* Forbid shallow lava when the player don't have levitation */
282 if (!p_ptr->ffall) return FALSE;
285 if (have_flag(f_ptr->flags, FF_HIT_TRAP))
287 if (!is_known_trap(c_ptr) || !trap_can_be_ignored(c_ptr->feat)) return FALSE;
296 * Teleport the player to a location up to "dis" grids away.
298 * If no such spaces are readily available, the distance may increase.
299 * Try very hard to move the player at least a quarter that distance.
301 * When long-range teleport effects are considered, there is a nasty
302 * tendency to "bounce" the player between two or three different spots
303 * because these are the only spots that are "far enough" way to satisfy
304 * the algorithm. Therefore, if the teleport distance is more than 50,
305 * we decrease the minimum acceptable distance to try to increase randomness.
308 void teleport_player(int dis, bool passive)
310 int d, i, min, ox, oy;
321 if (p_ptr->wild_mode) return;
323 if (p_ptr->anti_tele)
326 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
328 msg_print("A mysterious force prevents you from teleporting!");
334 if (dis > 200) dis = 200; /* To be on the safe side... */
336 /* Minimum distance */
337 min = dis / (dis > 50 ? 3 : 2);
339 /* Look until done */
344 /* Verify max distance */
345 if (dis > 200) dis = 200;
347 /* Try several locations */
348 for (i = 0; i < 500; i++)
350 /* Pick a (possibly illegal) location */
353 y = rand_spread(py, dis);
354 x = rand_spread(px, dis);
355 d = distance(py, px, y, x);
356 if ((d >= min) && (d <= dis)) break;
359 /* Ignore illegal locations */
360 if (!in_bounds(y, x)) continue;
362 if (!cave_teleportable_bold(y, x, passive)) continue;
364 /* This grid looks good */
371 /* Increase the maximum distance */
374 /* Decrease the minimum distance */
377 /* Stop after MAX_TRIES tries */
378 if (tries > MAX_TRIES) return;
382 sound(SOUND_TELEPORT);
385 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
386 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
389 /* Save the old location */
393 /* Move the player */
394 (void)move_player_effect(py, px, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
396 /* Monsters with teleport ability may follow the player */
397 for (xx = -1; xx < 2; xx++)
399 for (yy = -1; yy < 2; yy++)
401 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
403 /* A monster except your mount may follow */
404 if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
406 monster_type *m_ptr = &m_list[tmp_m_idx];
407 monster_race *r_ptr = &r_info[m_ptr->r_idx];
410 * The latter limitation is to avoid
411 * totally unkillable suckers...
413 if ((r_ptr->flags6 & RF6_TPORT) &&
414 !(r_ptr->flagsr & RFR_RES_TELE))
416 if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, y, x, r_ptr->level);
426 * Teleport player to a grid near the given location
428 * This function is slightly obsessive about correctness.
429 * This function allows teleporting into vaults (!)
431 void teleport_player_to(int ny, int nx, bool no_tele, bool passive)
433 int y, x, dis = 0, ctr = 0;
435 if (p_ptr->anti_tele && no_tele)
438 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
440 msg_print("A mysterious force prevents you from teleporting!");
446 /* Find a usable location */
449 /* Pick a nearby legal location */
452 y = rand_spread(ny, dis);
453 x = rand_spread(nx, dis);
454 if (in_bounds(y, x)) break;
457 /* Accept any grid when wizard mode */
458 if (p_ptr->wizard) break;
460 /* Accept teleportable floor grids */
461 if (cave_teleportable_bold(y, x, passive)) break;
463 /* Occasionally advance the distance */
464 if (++ctr > (4 * dis * dis + 4 * dis + 1))
472 sound(SOUND_TELEPORT);
474 /* Move the player */
475 (void)move_player_effect(py, px, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
481 * Teleport the player one level up or down (random when legal)
482 * Note: If m_idx <= 0, target is player.
484 void teleport_level(int m_idx)
490 if (m_idx <= 0) /* To player */
493 strcpy(m_name, "¤¢¤Ê¤¿");
495 strcpy(m_name, "you");
498 else /* To monster */
500 monster_type *m_ptr = &m_list[m_idx];
502 /* Get the monster name (or "it") */
503 monster_desc(m_name, m_ptr, 0);
508 /* No effect in some case */
509 if (TELE_LEVEL_IS_INEFF(m_idx))
512 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
514 if (see_m) msg_print("There is no effect.");
520 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
523 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
525 msg_print("A mysterious force prevents you from teleporting!");
530 /* Choose up or down */
531 if (randint0(100) < 50) go_up = TRUE;
534 if ((m_idx <= 0) && p_ptr->wizard)
536 if (get_check("Force to go up? ")) go_up = TRUE;
537 else if (get_check("Force to go down? ")) go_up = FALSE;
541 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
544 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
546 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
548 if (m_idx <= 0) /* To player */
552 dungeon_type = p_ptr->recall_dungeon;
557 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
559 if (autosave_l) do_cmd_save_game(TRUE);
563 dun_level = d_info[dungeon_type].mindepth;
564 prepare_change_floor_mode(CFM_RAND_PLACE);
568 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
572 p_ptr->leaving = TRUE;
577 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
580 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
582 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
586 if (m_idx <= 0) /* To player */
588 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
590 if (autosave_l) do_cmd_save_game(TRUE);
592 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
597 p_ptr->inside_quest = 0;
598 p_ptr->leaving = TRUE;
604 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
606 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
610 if (m_idx <= 0) /* To player */
612 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
614 if (autosave_l) do_cmd_save_game(TRUE);
616 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
619 p_ptr->leaving = TRUE;
625 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
627 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
630 if (m_idx <= 0) /* To player */
632 /* Never reach this code on the surface */
633 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
635 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
637 if (autosave_l) do_cmd_save_game(TRUE);
639 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
642 p_ptr->leaving = TRUE;
646 /* Monster level teleportation is simple deleting now */
649 monster_type *m_ptr = &m_list[m_idx];
651 /* Check for quest completion */
652 check_quest_completion(m_ptr);
654 delete_monster_idx(m_idx);
658 sound(SOUND_TPLEVEL);
663 int choose_dungeon(cptr note, int y, int x)
669 /* Hack -- No need to choose dungeon in some case */
670 if (lite_town || vanilla_town || ironman_downward)
672 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
676 msg_format("¤Þ¤À%s¤ËÆþ¤Ã¤¿¤³¤È¤Ï¤Ê¤¤¡£", d_name + d_info[DUNGEON_ANGBAND].name);
678 msg_format("You haven't entered %s yet.", d_name + d_info[DUNGEON_ANGBAND].name);
685 /* Allocate the "dun" array */
686 C_MAKE(dun, max_d_idx, s16b);
689 for(i = 1; i < max_d_idx; i++)
694 if (!d_info[i].maxdepth) continue;
695 if (!max_dlv[i]) continue;
696 if (d_info[i].final_guardian)
698 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
700 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
703 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
705 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
707 prt(buf, y + num, x);
714 prt(" Áª¤Ù¤ë¥À¥ó¥¸¥ç¥ó¤¬¤Ê¤¤¡£", y, x);
716 prt(" No dungeon is available.", y, x);
721 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
723 prt(format("Which dungeon do you %s?: ", note), 0, 0);
728 if ((i == ESCAPE) || !num)
730 /* Free the "dun" array */
731 C_KILL(dun, max_d_idx, s16b);
736 if (i >= 'a' && i <('a'+num))
738 select_dungeon = dun[i-'a'];
745 /* Free the "dun" array */
746 C_KILL(dun, max_d_idx, s16b);
748 return select_dungeon;
753 * Recall the player to town or dungeon
755 bool recall_player(int turns)
758 * TODO: Recall the player to the last
759 * visited town when in the wilderness
763 if (p_ptr->inside_arena || ironman_downward)
766 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
768 msg_print("Nothing happens.");
774 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
777 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
779 if (get_check("Reset recall depth? "))
782 max_dlv[dungeon_type] = dun_level;
785 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
787 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
792 if (!p_ptr->word_recall)
798 select_dungeon = choose_dungeon("¤Ëµ¢´Ô", 2, 14);
800 select_dungeon = choose_dungeon("recall", 2, 14);
802 if (!select_dungeon) return FALSE;
803 p_ptr->recall_dungeon = select_dungeon;
805 p_ptr->word_recall = turns;
807 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
809 msg_print("The air about you becomes charged...");
812 p_ptr->redraw |= (PR_STATUS);
816 p_ptr->word_recall = 0;
818 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
820 msg_print("A tension leaves the air around you...");
823 p_ptr->redraw |= (PR_STATUS);
829 bool word_of_recall(void)
831 return(recall_player(randint0(21) + 15));
835 bool reset_recall(void)
837 int select_dungeon, dummy = 0;
842 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È", 2, 14);
844 select_dungeon = choose_dungeon("reset", 2, 14);
848 if (ironman_downward)
851 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
853 msg_print("Nothing happens.");
859 if (!select_dungeon) return FALSE;
862 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
864 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
869 sprintf(tmp_val, "%d", MAX(dun_level, 1));
871 /* Ask for a level */
872 if (get_string(ppp, tmp_val, 10))
874 /* Extract request */
875 dummy = atoi(tmp_val);
878 if (dummy < 1) dummy = 1;
881 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
882 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
884 max_dlv[select_dungeon] = dummy;
888 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
890 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
894 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
896 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
909 * Apply disenchantment to the player's stuff
911 * XXX XXX XXX This function is also called from the "melee" code
913 * Return "TRUE" if the player notices anything
915 bool apply_disenchant(int mode)
919 char o_name[MAX_NLEN];
920 int to_h, to_d, to_a, pval;
922 /* Pick a random slot */
925 case 1: t = INVEN_RARM; break;
926 case 2: t = INVEN_LARM; break;
927 case 3: t = INVEN_BOW; break;
928 case 4: t = INVEN_BODY; break;
929 case 5: t = INVEN_OUTER; break;
930 case 6: t = INVEN_HEAD; break;
931 case 7: t = INVEN_HANDS; break;
932 case 8: t = INVEN_FEET; break;
936 o_ptr = &inventory[t];
938 /* No item, nothing happens */
939 if (!o_ptr->k_idx) return (FALSE);
941 /* Disenchant equipments only -- No disenchant on monster ball */
942 if (!object_is_weapon_armour_ammo(o_ptr))
945 /* Nothing to disenchant */
946 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
948 /* Nothing to notice */
953 /* Describe the object */
954 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
957 /* Artifacts have 71% chance to resist */
958 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
962 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
964 msg_format("Your %s (%c) resist%s disenchantment!",
965 o_name, index_to_label(t),
966 ((o_ptr->number != 1) ? "" : "s"));
975 /* Memorize old value */
981 /* Disenchant tohit */
982 if (o_ptr->to_h > 0) o_ptr->to_h--;
983 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
985 /* Disenchant todam */
986 if (o_ptr->to_d > 0) o_ptr->to_d--;
987 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
989 /* Disenchant toac */
990 if (o_ptr->to_a > 0) o_ptr->to_a--;
991 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
993 /* Disenchant pval (occasionally) */
994 /* Unless called from wild_magic() */
995 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
997 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
998 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1002 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
1003 o_name, index_to_label(t) );
1005 msg_format("Your %s (%c) %s disenchanted!",
1006 o_name, index_to_label(t),
1007 ((o_ptr->number != 1) ? "were" : "was"));
1010 chg_virtue(V_HARMONY, 1);
1011 chg_virtue(V_ENCHANT, -2);
1013 /* Recalculate bonuses */
1014 p_ptr->update |= (PU_BONUS);
1017 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1027 void mutate_player(void)
1029 int max1, cur1, max2, cur2, ii, jj, i;
1031 /* Pick a pair of stats */
1033 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1035 max1 = p_ptr->stat_max[ii];
1036 cur1 = p_ptr->stat_cur[ii];
1037 max2 = p_ptr->stat_max[jj];
1038 cur2 = p_ptr->stat_cur[jj];
1040 p_ptr->stat_max[ii] = max2;
1041 p_ptr->stat_cur[ii] = cur2;
1042 p_ptr->stat_max[jj] = max1;
1043 p_ptr->stat_cur[jj] = cur1;
1047 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1048 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1051 p_ptr->update |= (PU_BONUS);
1058 void apply_nexus(monster_type *m_ptr)
1060 switch (randint1(7))
1062 case 1: case 2: case 3:
1064 teleport_player(200, TRUE);
1070 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE, TRUE);
1076 if (randint0(100) < p_ptr->skill_sav)
1079 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1081 msg_print("You resist the effects!");
1087 /* Teleport Level */
1094 if (randint0(100) < p_ptr->skill_sav)
1097 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1099 msg_print("You resist the effects!");
1106 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1108 msg_print("Your body starts to scramble...");
1119 * Charge a lite (torch or latern)
1121 void phlogiston(void)
1124 object_type * o_ptr = &inventory[INVEN_LITE];
1127 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1129 max_flog = FUEL_LAMP;
1133 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1135 max_flog = FUEL_TORCH;
1138 /* No torch to refill */
1142 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1144 msg_print("You are not wielding anything which uses phlogiston.");
1150 if (o_ptr->xtra4 >= max_flog)
1153 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1155 msg_print("No more phlogiston can be put in this item.");
1162 o_ptr->xtra4 += (max_flog / 2);
1166 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1168 msg_print("You add phlogiston to your light item.");
1173 if (o_ptr->xtra4 >= max_flog)
1175 o_ptr->xtra4 = max_flog;
1177 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1179 msg_print("Your light item is full.");
1184 /* Recalculate torch */
1185 p_ptr->update |= (PU_TORCH);
1190 * Brand the current weapon
1192 void brand_weapon(int brand_type)
1199 /* Assume enchant weapon */
1200 item_tester_hook = object_allow_enchant_melee_weapon;
1201 item_tester_no_ryoute = TRUE;
1205 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1206 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1208 q = "Enchant which weapon? ";
1209 s = "You have nothing to enchant.";
1212 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1214 /* Get the item (in the pack) */
1217 o_ptr = &inventory[item];
1220 /* Get the item (on the floor) */
1223 o_ptr = &o_list[0 - item];
1227 /* you can never modify artifacts / ego-items */
1228 /* you can never modify cursed items */
1229 /* TY: You _can_ modify broken items (if you're silly enough) */
1230 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1231 !object_is_cursed(o_ptr) &&
1232 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1233 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1234 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1238 /* Let's get the name before it is changed... */
1239 char o_name[MAX_NLEN];
1240 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1245 if (o_ptr->tval == TV_SWORD)
1248 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1250 act = "becomes very sharp!";
1253 o_ptr->name2 = EGO_SHARPNESS;
1254 o_ptr->pval = m_bonus(5, dun_level) + 1;
1259 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1261 act = "seems very powerful.";
1264 o_ptr->name2 = EGO_EARTHQUAKES;
1265 o_ptr->pval = m_bonus(3, dun_level);
1270 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1272 act = "seems to be looking for humans!";
1275 o_ptr->name2 = EGO_SLAY_HUMAN;
1279 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1281 act = "covered with lightning!";
1284 o_ptr->name2 = EGO_BRAND_ELEC;
1288 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1290 act = "coated with acid!";
1293 o_ptr->name2 = EGO_BRAND_ACID;
1297 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1299 act = "seems to be looking for evil monsters!";
1302 o_ptr->name2 = EGO_SLAY_EVIL;
1306 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1308 act = "seems to be looking for demons!";
1311 o_ptr->name2 = EGO_SLAY_DEMON;
1315 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1317 act = "seems to be looking for undead!";
1320 o_ptr->name2 = EGO_SLAY_UNDEAD;
1324 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1326 act = "seems to be looking for animals!";
1329 o_ptr->name2 = EGO_SLAY_ANIMAL;
1333 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1335 act = "seems to be looking for dragons!";
1338 o_ptr->name2 = EGO_SLAY_DRAGON;
1342 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1344 act = "seems to be looking for troll!s";
1347 o_ptr->name2 = EGO_SLAY_TROLL;
1351 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1353 act = "seems to be looking for orcs!";
1356 o_ptr->name2 = EGO_SLAY_ORC;
1360 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1362 act = "seems to be looking for giants!";
1365 o_ptr->name2 = EGO_SLAY_GIANT;
1369 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1371 act = "seems very unstable now.";
1374 o_ptr->name2 = EGO_TRUMP;
1375 o_ptr->pval = randint1(2);
1379 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1381 act = "thirsts for blood!";
1384 o_ptr->name2 = EGO_VAMPIRIC;
1388 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1390 act = "is coated with poison.";
1393 o_ptr->name2 = EGO_BRAND_POIS;
1397 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1399 act = "is engulfed in raw Logrus!";
1402 o_ptr->name2 = EGO_CHAOTIC;
1406 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1408 act = "is covered in a fiery shield!";
1411 o_ptr->name2 = EGO_BRAND_FIRE;
1415 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1417 act = "glows deep, icy blue!";
1420 o_ptr->name2 = EGO_BRAND_COLD;
1425 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1427 msg_format("Your %s %s", o_name, act);
1431 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1433 o_ptr->discount = 99;
1434 chg_virtue(V_ENCHANT, 2);
1438 if (flush_failure) flush();
1441 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1443 msg_print("The Branding failed.");
1446 chg_virtue(V_ENCHANT, -2);
1453 * Vanish all walls in this floor
1455 static bool vanish_dungeon(void)
1459 feature_type *f_ptr;
1460 monster_type *m_ptr;
1463 /* Prevent vasishing of quest levels and town */
1464 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1469 /* Scan all normal grids */
1470 for (y = 1; y < cur_hgt - 1; y++)
1472 for (x = 1; x < cur_wid - 1; x++)
1474 c_ptr = &cave[y][x];
1476 /* Seeing true feature code (ignore mimic) */
1477 f_ptr = &f_info[c_ptr->feat];
1479 /* Lose room and vault */
1480 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1482 m_ptr = &m_list[c_ptr->m_idx];
1485 if (c_ptr->m_idx && m_ptr->csleep)
1487 /* Reset sleep counter */
1490 /* Notice the "waking up" */
1493 /* Acquire the monster name */
1494 monster_desc(m_name, m_ptr, 0);
1496 /* Dump a message */
1498 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1500 msg_format("%^s wakes up.", m_name);
1503 /* Redraw the health bar */
1504 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
1505 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
1509 /* Process all walls, doors and patterns */
1510 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1514 /* Special boundary walls -- Top and bottom */
1515 for (x = 0; x < cur_wid; x++)
1517 c_ptr = &cave[0][x];
1518 f_ptr = &f_info[c_ptr->mimic];
1520 /* Lose room and vault */
1521 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1523 /* Set boundary mimic if needed */
1524 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1526 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1528 /* Check for change to boring grid */
1529 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1532 c_ptr = &cave[cur_hgt - 1][x];
1533 f_ptr = &f_info[c_ptr->mimic];
1535 /* Lose room and vault */
1536 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1538 /* Set boundary mimic if needed */
1539 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1541 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1543 /* Check for change to boring grid */
1544 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1548 /* Special boundary walls -- Left and right */
1549 for (y = 1; y < (cur_hgt - 1); y++)
1551 c_ptr = &cave[y][0];
1552 f_ptr = &f_info[c_ptr->mimic];
1554 /* Lose room and vault */
1555 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1557 /* Set boundary mimic if needed */
1558 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1560 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1562 /* Check for change to boring grid */
1563 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1566 c_ptr = &cave[y][cur_wid - 1];
1567 f_ptr = &f_info[c_ptr->mimic];
1569 /* Lose room and vault */
1570 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1572 /* Set boundary mimic if needed */
1573 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1575 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1577 /* Check for change to boring grid */
1578 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1582 /* Mega-Hack -- Forget the view and lite */
1583 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1586 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1588 /* Update the monsters */
1589 p_ptr->update |= (PU_MONSTERS);
1592 p_ptr->redraw |= (PR_MAP);
1595 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1601 void call_the_(void)
1605 bool do_call = TRUE;
1607 for (i = 0; i < 9; i++)
1609 c_ptr = &cave[py + ddy_ddd[i]][px + ddx_ddd[i]];
1611 if (!have_flag(f_flags_grid(c_ptr), FF_PROJECT))
1613 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1614 !permanent_wall(&f_info[c_ptr->feat]))
1624 for (i = 1; i < 10; i++)
1626 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1629 for (i = 1; i < 10; i++)
1631 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1634 for (i = 1; i < 10; i++)
1636 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1640 /* Prevent destruction of quest levels and town */
1641 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1644 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1646 msg_print("The ground trembles.");
1653 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1654 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1655 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1657 msg_format("You %s the %s too close to a wall!",
1658 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1659 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1660 msg_print("There is a loud explosion!");
1666 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1668 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1673 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1675 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1677 msg_print("The dungeon collapses...");
1682 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1684 msg_print("The dungeon trembles.");
1689 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1691 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1698 * Fetch an item (teleport it right underneath the caster)
1700 void fetch(int dir, int wgt, bool require_los)
1705 char o_name[MAX_NLEN];
1707 /* Check to see if an object is already there */
1708 if (cave[py][px].o_idx)
1711 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1713 msg_print("You can't fetch when you're already standing on something.");
1720 if (dir == 5 && target_okay())
1725 if (distance(py, px, ty, tx) > MAX_RANGE)
1728 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1730 msg_print("You can't fetch something that far away!");
1736 c_ptr = &cave[ty][tx];
1738 /* We need an item to fetch */
1742 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1744 msg_print("There is no object at this place.");
1750 /* No fetching from vault */
1751 if (c_ptr->info & CAVE_ICKY)
1754 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1756 msg_print("The item slips from your control.");
1762 /* We need to see the item */
1765 if (!player_has_los_bold(ty, tx))
1768 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1770 msg_print("You have no direct line of sight to that location.");
1775 else if (!projectable(py, px, ty, tx))
1778 msg_print("¤½¤³¤ÏÊɤθþ¤³¤¦¤Ç¤¹¡£");
1780 msg_print("You have no direct line of sight to that location.");
1789 /* Use a direction */
1790 ty = py; /* Where to drop the item */
1797 c_ptr = &cave[ty][tx];
1799 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1800 !have_flag(f_flags_bold(ty, tx), FF_PROJECT)) return;
1802 while (!c_ptr->o_idx);
1805 o_ptr = &o_list[c_ptr->o_idx];
1807 if (o_ptr->weight > wgt)
1809 /* Too heavy to 'fetch' */
1811 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1813 msg_print("The object is too heavy.");
1820 c_ptr->o_idx = o_ptr->next_o_idx;
1821 cave[py][px].o_idx = i; /* 'move' it */
1822 o_ptr->next_o_idx = 0;
1823 o_ptr->iy = (byte)py;
1824 o_ptr->ix = (byte)px;
1826 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1828 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1830 msg_format("%^s flies through the air to your feet.", o_name);
1835 p_ptr->redraw |= PR_MAP;
1839 void alter_reality(void)
1841 /* Ironman option */
1842 if (p_ptr->inside_arena || ironman_downward)
1845 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1847 msg_print("Nothing happens.");
1852 if (!p_ptr->alter_reality)
1854 int turns = randint0(21) + 15;
1856 p_ptr->alter_reality = turns;
1858 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1860 msg_print("The view around you begins to change...");
1863 p_ptr->redraw |= (PR_STATUS);
1867 p_ptr->alter_reality = 0;
1869 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1871 msg_print("The view around you got back...");
1874 p_ptr->redraw |= (PR_STATUS);
1881 * Leave a "glyph of warding" which prevents monster movement
1883 bool warding_glyph(void)
1886 if (!cave_clean_bold(py, px))
1889 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1891 msg_print("The object resists the spell.");
1897 /* Create a glyph */
1898 cave[py][px].info |= CAVE_OBJECT;
1899 cave[py][px].mimic = FEAT_GLYPH;
1910 bool place_mirror(void)
1913 if (!cave_clean_bold(py, px))
1916 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1918 msg_print("The object resists the spell.");
1924 /* Create a mirror */
1925 cave[py][px].info |= CAVE_OBJECT;
1926 cave[py][px].mimic = FEAT_MIRROR;
1928 /* Turn on the light */
1929 cave[py][px].info |= CAVE_GLOW;
1937 update_local_illumination(py, px);
1944 * Leave an "explosive rune" which prevents monster movement
1946 bool explosive_rune(void)
1949 if (!cave_clean_bold(py, px))
1952 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1954 msg_print("The object resists the spell.");
1960 /* Create a glyph */
1961 cave[py][px].info |= CAVE_OBJECT;
1962 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1975 * Identify everything being carried.
1976 * Done by a potion of "self knowledge".
1978 void identify_pack(void)
1982 /* Simply identify and know every item */
1983 for (i = 0; i < INVEN_TOTAL; i++)
1985 object_type *o_ptr = &inventory[i];
1987 /* Skip non-objects */
1988 if (!o_ptr->k_idx) continue;
1991 identify_item(o_ptr);
1993 /* Auto-inscription */
1994 autopick_alter_item(i, FALSE);
2000 * Used by the "enchant" function (chance of failure)
2001 * (modified for Zangband, we need better stuff there...) -- TY
2003 static int enchant_table[16] =
2005 0, 10, 50, 100, 200,
2006 300, 400, 500, 650, 800,
2007 950, 987, 993, 995, 998,
2013 * Removes curses from items in inventory
2015 * Note that Items which are "Perma-Cursed" (The One Ring,
2016 * The Crown of Morgoth) can NEVER be uncursed.
2018 * Note that if "all" is FALSE, then Items which are
2019 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2020 * will not be uncursed.
2022 static int remove_curse_aux(int all)
2026 /* Attempt to uncurse items being worn */
2027 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2029 object_type *o_ptr = &inventory[i];
2031 /* Skip non-objects */
2032 if (!o_ptr->k_idx) continue;
2034 /* Uncursed already */
2035 if (!object_is_cursed(o_ptr)) continue;
2037 /* Heavily Cursed Items need a special spell */
2038 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2040 /* Perma-Cursed Items can NEVER be uncursed */
2041 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2044 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2049 o_ptr->curse_flags = 0L;
2051 /* Hack -- Assume felt */
2052 o_ptr->ident |= (IDENT_SENSE);
2055 o_ptr->feeling = FEEL_NONE;
2057 /* Recalculate the bonuses */
2058 p_ptr->update |= (PU_BONUS);
2061 p_ptr->window |= (PW_EQUIP);
2063 /* Count the uncursings */
2067 /* Return "something uncursed" */
2073 * Remove most curses
2075 bool remove_curse(void)
2077 return (remove_curse_aux(FALSE));
2083 bool remove_all_curse(void)
2085 return (remove_curse_aux(TRUE));
2090 * Turns an object into gold, gain some of its value in a shop
2099 char o_name[MAX_NLEN];
2100 char out_val[MAX_NLEN+40];
2104 /* Hack -- force destruction */
2105 if (command_arg > 0) force = TRUE;
2109 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2110 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2112 q = "Turn which item to gold? ";
2113 s = "You have nothing to turn to gold.";
2116 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2118 /* Get the item (in the pack) */
2121 o_ptr = &inventory[item];
2124 /* Get the item (on the floor) */
2127 o_ptr = &o_list[0 - item];
2131 /* See how many items */
2132 if (o_ptr->number > 1)
2134 /* Get a quantity */
2135 amt = get_quantity(NULL, o_ptr->number);
2137 /* Allow user abort */
2138 if (amt <= 0) return FALSE;
2142 /* Describe the object */
2143 old_number = o_ptr->number;
2144 o_ptr->number = amt;
2145 object_desc(o_name, o_ptr, 0);
2146 o_ptr->number = old_number;
2148 /* Verify unless quantity given */
2151 if (confirm_destroy || (object_value(o_ptr) > 0))
2153 /* Make a verification */
2155 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2157 sprintf(out_val, "Really turn %s to gold? ", o_name);
2160 if (!get_check(out_val)) return FALSE;
2164 /* Artifacts cannot be destroyed */
2165 if (!can_player_destroy_object(o_ptr))
2169 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2171 msg_format("You fail to turn %s to gold!", o_name);
2178 price = object_value_real(o_ptr);
2184 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2186 msg_format("You turn %s to fool's gold.", o_name);
2194 if (amt > 1) price *= amt;
2196 if (price > 30000) price = 30000;
2198 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2200 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2206 p_ptr->redraw |= (PR_GOLD);
2209 p_ptr->window |= (PW_PLAYER);
2213 /* Eliminate the item (from the pack) */
2216 inven_item_increase(item, -amt);
2217 inven_item_describe(item);
2218 inven_item_optimize(item);
2221 /* Eliminate the item (from the floor) */
2224 floor_item_increase(0 - item, -amt);
2225 floor_item_describe(0 - item);
2226 floor_item_optimize(0 - item);
2234 * Break the curse of an item
2236 static void break_curse(object_type *o_ptr)
2238 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2241 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2243 msg_print("The curse is broken!");
2246 o_ptr->curse_flags = 0L;
2248 o_ptr->ident |= (IDENT_SENSE);
2250 o_ptr->feeling = FEEL_NONE;
2256 * Enchants a plus onto an item. -RAK-
2258 * Revamped! Now takes item pointer, number of times to try enchanting,
2259 * and a flag of what to try enchanting. Artifacts resist enchantment
2260 * some of the time, and successful enchantment to at least +0 might
2261 * break a curse on the item. -CFT-
2263 * Note that an item can technically be enchanted all the way to +15 if
2264 * you wait a very, very, long time. Going from +9 to +10 only works
2265 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2267 * Note that this function can now be used on "piles" of items, and
2268 * the larger the pile, the lower the chance of success.
2270 bool enchant(object_type *o_ptr, int n, int eflag)
2272 int i, chance, prob;
2274 bool a = object_is_artifact(o_ptr);
2275 bool force = (eflag & ENCH_FORCE);
2278 /* Large piles resist enchantment */
2279 prob = o_ptr->number * 100;
2281 /* Missiles are easy to enchant */
2282 if ((o_ptr->tval == TV_BOLT) ||
2283 (o_ptr->tval == TV_ARROW) ||
2284 (o_ptr->tval == TV_SHOT))
2290 for (i = 0; i < n; i++)
2292 /* Hack -- Roll for pile resistance */
2293 if (!force && randint0(prob) >= 100) continue;
2295 /* Enchant to hit */
2296 if (eflag & ENCH_TOHIT)
2298 if (o_ptr->to_h < 0) chance = 0;
2299 else if (o_ptr->to_h > 15) chance = 1000;
2300 else chance = enchant_table[o_ptr->to_h];
2302 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2307 /* only when you get it above -1 -CFT */
2308 if (o_ptr->to_h >= 0)
2313 /* Enchant to damage */
2314 if (eflag & ENCH_TODAM)
2316 if (o_ptr->to_d < 0) chance = 0;
2317 else if (o_ptr->to_d > 15) chance = 1000;
2318 else chance = enchant_table[o_ptr->to_d];
2320 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2325 /* only when you get it above -1 -CFT */
2326 if (o_ptr->to_d >= 0)
2331 /* Enchant to armor class */
2332 if (eflag & ENCH_TOAC)
2334 if (o_ptr->to_a < 0) chance = 0;
2335 else if (o_ptr->to_a > 15) chance = 1000;
2336 else chance = enchant_table[o_ptr->to_a];
2338 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2343 /* only when you get it above -1 -CFT */
2344 if (o_ptr->to_a >= 0)
2351 if (!res) return (FALSE);
2353 /* Recalculate bonuses */
2354 p_ptr->update |= (PU_BONUS);
2356 /* Combine / Reorder the pack (later) */
2357 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2360 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2371 * Enchant an item (in the inventory or on the floor)
2372 * Note that "num_ac" requires armour, else weapon
2373 * Returns TRUE if attempted, FALSE if cancelled
2375 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2380 char o_name[MAX_NLEN];
2384 /* Assume enchant weapon */
2385 item_tester_hook = object_allow_enchant_weapon;
2386 item_tester_no_ryoute = TRUE;
2388 /* Enchant armor if requested */
2389 if (num_ac) item_tester_hook = object_is_armour;
2393 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2394 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2396 q = "Enchant which item? ";
2397 s = "You have nothing to enchant.";
2400 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2402 /* Get the item (in the pack) */
2405 o_ptr = &inventory[item];
2408 /* Get the item (on the floor) */
2411 o_ptr = &o_list[0 - item];
2416 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2420 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2423 msg_format("%s %s glow%s brightly!",
2424 ((item >= 0) ? "Your" : "The"), o_name,
2425 ((o_ptr->number > 1) ? "" : "s"));
2430 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2431 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2432 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2438 if (flush_failure) flush();
2442 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2444 msg_print("The enchantment failed.");
2447 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2450 chg_virtue(V_ENCHANT, 1);
2454 /* Something happened */
2460 * Check if an object is nameless weapon or armour
2462 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2464 /* Require weapon or armour */
2465 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2467 /* Require nameless object if the object is well known */
2468 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2475 bool artifact_scroll(void)
2480 char o_name[MAX_NLEN];
2484 item_tester_no_ryoute = TRUE;
2486 /* Enchant weapon/armour */
2487 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2491 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2492 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2494 q = "Enchant which item? ";
2495 s = "You have nothing to enchant.";
2498 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2500 /* Get the item (in the pack) */
2503 o_ptr = &inventory[item];
2506 /* Get the item (on the floor) */
2509 o_ptr = &o_list[0 - item];
2514 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2518 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2520 msg_format("%s %s radiate%s a blinding light!",
2521 ((item >= 0) ? "Your" : "The"), o_name,
2522 ((o_ptr->number > 1) ? "" : "s"));
2525 if (object_is_artifact(o_ptr))
2528 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2530 msg_format("The %s %s already %s!",
2531 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2532 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2538 else if (object_is_ego(o_ptr))
2541 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2543 msg_format("The %s %s already %s!",
2544 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2545 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2551 else if (o_ptr->xtra3)
2554 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2556 msg_format("The %s %s already %s!",
2557 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2558 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2564 if (o_ptr->number > 1)
2567 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2568 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2570 msg_print("Not enough enough energy to enchant more than one object!");
2571 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2576 inven_item_increase(item, 1-(o_ptr->number));
2580 floor_item_increase(0-item, 1-(o_ptr->number));
2583 okay = create_artifact(o_ptr, TRUE);
2590 if (flush_failure) flush();
2594 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2596 msg_print("The enchantment failed.");
2599 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2602 chg_virtue(V_ENCHANT, 1);
2606 /* Something happened */
2612 * Identify an object
2614 bool identify_item(object_type *o_ptr)
2616 bool old_known = FALSE;
2617 char o_name[MAX_NLEN];
2620 object_desc(o_name, o_ptr, 0);
2622 if (o_ptr->ident & IDENT_KNOWN)
2625 if (!(o_ptr->ident & (IDENT_MENTAL)))
2627 if (object_is_artifact(o_ptr) || one_in_(5))
2628 chg_virtue(V_KNOWLEDGE, 1);
2631 /* Identify it fully */
2632 object_aware(o_ptr);
2633 object_known(o_ptr);
2635 /* Recalculate bonuses */
2636 p_ptr->update |= (PU_BONUS);
2638 /* Combine / Reorder the pack (later) */
2639 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2642 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2644 strcpy(record_o_name, o_name);
2648 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2650 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2651 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2652 if(record_rand_art && !old_known && o_ptr->art_name)
2653 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2659 static bool item_tester_hook_identify(object_type *o_ptr)
2661 return (bool)!object_is_known(o_ptr);
2664 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2666 if (object_is_known(o_ptr))
2668 return object_is_weapon_armour_ammo(o_ptr);
2672 * Identify an object in the inventory (or on the floor)
2673 * This routine does *not* automatically combine objects.
2674 * Returns TRUE if something was identified, else FALSE.
2676 bool ident_spell(bool only_equip)
2680 char o_name[MAX_NLEN];
2684 item_tester_no_ryoute = TRUE;
2687 item_tester_hook = item_tester_hook_identify_weapon_armour;
2689 item_tester_hook = item_tester_hook_identify;
2691 if (!can_get_item())
2695 item_tester_hook = object_is_weapon_armour_ammo;
2699 item_tester_hook = NULL;
2705 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2706 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2708 q = "Identify which item? ";
2709 s = "You have nothing to identify.";
2712 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2714 /* Get the item (in the pack) */
2717 o_ptr = &inventory[item];
2720 /* Get the item (on the floor) */
2723 o_ptr = &o_list[0 - item];
2727 old_known = identify_item(o_ptr);
2730 object_desc(o_name, o_ptr, 0);
2733 if (item >= INVEN_RARM)
2736 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2738 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2744 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2746 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2752 msg_format("¾²¾å: %s¡£", o_name);
2754 msg_format("On the ground: %s.", o_name);
2758 /* Auto-inscription/destroy */
2759 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2761 /* Something happened */
2767 * Mundanify an object in the inventory (or on the floor)
2768 * This routine does *not* automatically combine objects.
2769 * Returns TRUE if something was mundanified, else FALSE.
2771 bool mundane_spell(bool only_equip)
2777 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2778 item_tester_no_ryoute = TRUE;
2782 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2783 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2785 q = "Use which item? ";
2786 s = "You have nothing you can use.";
2789 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2791 /* Get the item (in the pack) */
2794 o_ptr = &inventory[item];
2797 /* Get the item (on the floor) */
2800 o_ptr = &o_list[0 - item];
2805 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2807 msg_print("There is a bright flash of light!");
2810 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2811 byte ix = o_ptr->ix; /* X-position on map, or zero */
2812 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2813 byte marked = o_ptr->marked; /* Object is marked */
2814 s16b weight = o_ptr->number * o_ptr->weight;
2815 u16b inscription = o_ptr->inscription;
2818 object_prep(o_ptr, o_ptr->k_idx);
2822 o_ptr->next_o_idx = next_o_idx;
2823 o_ptr->marked = marked;
2824 o_ptr->inscription = inscription;
2825 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2829 /* Something happened */
2835 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2837 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2840 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2842 if (!item_tester_hook_identify_fully(o_ptr))
2844 return object_is_weapon_armour_ammo(o_ptr);
2848 * Fully "identify" an object in the inventory -BEN-
2849 * This routine returns TRUE if an item was identified.
2851 bool identify_fully(bool only_equip)
2855 char o_name[MAX_NLEN];
2859 item_tester_no_ryoute = TRUE;
2861 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2863 item_tester_hook = item_tester_hook_identify_fully;
2865 if (!can_get_item())
2868 item_tester_hook = object_is_weapon_armour_ammo;
2870 item_tester_hook = NULL;
2875 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2876 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2878 q = "Identify which item? ";
2879 s = "You have nothing to identify.";
2882 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2884 /* Get the item (in the pack) */
2887 o_ptr = &inventory[item];
2890 /* Get the item (on the floor) */
2893 o_ptr = &o_list[0 - item];
2897 old_known = identify_item(o_ptr);
2899 /* Mark the item as fully known */
2900 o_ptr->ident |= (IDENT_MENTAL);
2906 object_desc(o_name, o_ptr, 0);
2909 if (item >= INVEN_RARM)
2912 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2914 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2922 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2924 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2930 msg_format("¾²¾å: %s¡£", o_name);
2932 msg_format("On the ground: %s.", o_name);
2936 /* Describe it fully */
2937 (void)screen_object(o_ptr, TRUE);
2939 /* Auto-inscription/destroy */
2940 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2950 * Hook for "get_item()". Determine if something is rechargable.
2952 bool item_tester_hook_recharge(object_type *o_ptr)
2954 /* Recharge staffs */
2955 if (o_ptr->tval == TV_STAFF) return (TRUE);
2957 /* Recharge wands */
2958 if (o_ptr->tval == TV_WAND) return (TRUE);
2960 /* Hack -- Recharge rods */
2961 if (o_ptr->tval == TV_ROD) return (TRUE);
2969 * Recharge a wand/staff/rod from the pack or on the floor.
2970 * This function has been rewritten in Oangband and ZAngband.
2972 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2973 * Chaos -- Arcane Binding --> recharge(90)
2975 * Scroll of recharging --> recharge(130)
2976 * Artifact activation/Thingol --> recharge(130)
2978 * It is harder to recharge high level, and highly charged wands,
2979 * staffs, and rods. The more wands in a stack, the more easily and
2980 * strongly they recharge. Staffs, however, each get fewer charges if
2983 * XXX XXX XXX Beware of "sliding index errors".
2985 bool recharge(int power)
2988 int recharge_strength, recharge_amount;
2997 char o_name[MAX_NLEN];
2999 /* Only accept legal items */
3000 item_tester_hook = item_tester_hook_recharge;
3004 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3005 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3007 q = "Recharge which item? ";
3008 s = "You have nothing to recharge.";
3011 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3013 /* Get the item (in the pack) */
3016 o_ptr = &inventory[item];
3019 /* Get the item (on the floor) */
3022 o_ptr = &o_list[0 - item];
3025 /* Get the object kind. */
3026 k_ptr = &k_info[o_ptr->k_idx];
3028 /* Extract the object "level" */
3029 lev = k_info[o_ptr->k_idx].level;
3032 /* Recharge a rod */
3033 if (o_ptr->tval == TV_ROD)
3035 /* Extract a recharge strength by comparing object level to power. */
3036 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3040 if (one_in_(recharge_strength))
3042 /* Activate the failure code. */
3049 /* Recharge amount */
3050 recharge_amount = (power * damroll(3, 2));
3052 /* Recharge by that amount */
3053 if (o_ptr->timeout > recharge_amount)
3054 o_ptr->timeout -= recharge_amount;
3061 /* Recharge wand/staff */
3064 /* Extract a recharge strength by comparing object level to power.
3065 * Divide up a stack of wands' charges to calculate charge penalty.
3067 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3068 recharge_strength = (100 + power - lev -
3069 (8 * o_ptr->pval / o_ptr->number)) / 15;
3071 /* All staffs, unstacked wands. */
3072 else recharge_strength = (100 + power - lev -
3073 (8 * o_ptr->pval)) / 15;
3076 if (recharge_strength < 0) recharge_strength = 0;
3079 if (one_in_(recharge_strength))
3081 /* Activate the failure code. */
3085 /* If the spell didn't backfire, recharge the wand or staff. */
3088 /* Recharge based on the standard number of charges. */
3089 recharge_amount = randint1(1 + k_ptr->pval / 2);
3091 /* Multiple wands in a stack increase recharging somewhat. */
3092 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3095 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3096 if (recharge_amount < 1) recharge_amount = 1;
3097 if (recharge_amount > 12) recharge_amount = 12;
3100 /* But each staff in a stack gets fewer additional charges,
3101 * although always at least one.
3103 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3105 recharge_amount /= o_ptr->number;
3106 if (recharge_amount < 1) recharge_amount = 1;
3109 /* Recharge the wand or staff. */
3110 o_ptr->pval += recharge_amount;
3113 /* Hack -- we no longer "know" the item */
3114 o_ptr->ident &= ~(IDENT_KNOWN);
3116 /* Hack -- we no longer think the item is empty */
3117 o_ptr->ident &= ~(IDENT_EMPTY);
3122 /* Inflict the penalties for failing a recharge. */
3125 /* Artifacts are never destroyed. */
3126 if (object_is_fixed_artifact(o_ptr))
3128 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3130 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3132 msg_format("The recharging backfires - %s is completely drained!", o_name);
3136 /* Artifact rods. */
3137 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3138 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3140 /* Artifact wands and staffs. */
3141 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3146 /* Get the object description */
3147 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3149 /*** Determine Seriousness of Failure ***/
3151 /* Mages recharge objects more safely. */
3152 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)
3154 /* 10% chance to blow up one rod, otherwise draining. */
3155 if (o_ptr->tval == TV_ROD)
3157 if (one_in_(10)) fail_type = 2;
3160 /* 75% chance to blow up one wand, otherwise draining. */
3161 else if (o_ptr->tval == TV_WAND)
3163 if (!one_in_(3)) fail_type = 2;
3166 /* 50% chance to blow up one staff, otherwise no effect. */
3167 else if (o_ptr->tval == TV_STAFF)
3169 if (one_in_(2)) fail_type = 2;
3174 /* All other classes get no special favors. */
3177 /* 33% chance to blow up one rod, otherwise draining. */
3178 if (o_ptr->tval == TV_ROD)
3180 if (one_in_(3)) fail_type = 2;
3183 /* 20% chance of the entire stack, else destroy one wand. */
3184 else if (o_ptr->tval == TV_WAND)
3186 if (one_in_(5)) fail_type = 3;
3189 /* Blow up one staff. */
3190 else if (o_ptr->tval == TV_STAFF)
3196 /*** Apply draining and destruction. ***/
3198 /* Drain object or stack of objects. */
3201 if (o_ptr->tval == TV_ROD)
3204 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3206 msg_print("The recharge backfires, draining the rod further!");
3209 if (o_ptr->timeout < 10000)
3210 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3212 else if (o_ptr->tval == TV_WAND)
3215 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3217 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3222 /* Staffs aren't drained. */
3225 /* Destroy an object or one in a stack of objects. */
3228 if (o_ptr->number > 1)
3230 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3232 msg_format("Wild magic consumes one of your %s!", o_name);
3237 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3239 msg_format("Wild magic consumes your %s!", o_name);
3243 /* Reduce rod stack maximum timeout, drain wands. */
3244 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3245 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3247 /* Reduce and describe inventory */
3250 inven_item_increase(item, -1);
3251 inven_item_describe(item);
3252 inven_item_optimize(item);
3255 /* Reduce and describe floor item */
3258 floor_item_increase(0 - item, -1);
3259 floor_item_describe(0 - item);
3260 floor_item_optimize(0 - item);
3264 /* Destroy all members of a stack of objects. */
3267 if (o_ptr->number > 1)
3269 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3271 msg_format("Wild magic consumes all your %s!", o_name);
3276 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3278 msg_format("Wild magic consumes your %s!", o_name);
3283 /* Reduce and describe inventory */
3286 inven_item_increase(item, -999);
3287 inven_item_describe(item);
3288 inven_item_optimize(item);
3291 /* Reduce and describe floor item */
3294 floor_item_increase(0 - item, -999);
3295 floor_item_describe(0 - item);
3296 floor_item_optimize(0 - item);
3302 /* Combine / Reorder the pack (later) */
3303 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3306 p_ptr->window |= (PW_INVEN);
3308 /* Something was done */
3316 bool bless_weapon(void)
3320 u32b flgs[TR_FLAG_SIZE];
3321 char o_name[MAX_NLEN];
3324 item_tester_no_ryoute = TRUE;
3326 /* Bless only weapons */
3327 item_tester_hook = object_is_weapon;
3331 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3332 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3334 q = "Bless which weapon? ";
3335 s = "You have weapon to bless.";
3338 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3341 /* Get the item (in the pack) */
3344 o_ptr = &inventory[item];
3347 /* Get the item (on the floor) */
3350 o_ptr = &o_list[0 - item];
3355 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3357 /* Extract the flags */
3358 object_flags(o_ptr, flgs);
3360 if (object_is_cursed(o_ptr))
3362 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3363 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3366 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3369 msg_format("The black aura on %s %s disrupts the blessing!",
3370 ((item >= 0) ? "your" : "the"), o_name);
3377 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3380 msg_format("A malignant aura leaves %s %s.",
3381 ((item >= 0) ? "your" : "the"), o_name);
3386 o_ptr->curse_flags = 0L;
3388 /* Hack -- Assume felt */
3389 o_ptr->ident |= (IDENT_SENSE);
3392 o_ptr->feeling = FEEL_NONE;
3394 /* Recalculate the bonuses */
3395 p_ptr->update |= (PU_BONUS);
3398 p_ptr->window |= (PW_EQUIP);
3402 * Next, we try to bless it. Artifacts have a 1/3 chance of
3403 * being blessed, otherwise, the operation simply disenchants
3404 * them, godly power negating the magic. Ok, the explanation
3405 * is silly, but otherwise priests would always bless every
3406 * artifact weapon they find. Ego weapons and normal weapons
3407 * can be blessed automatically.
3409 if (have_flag(flgs, TR_BLESSED))
3412 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3415 msg_format("%s %s %s blessed already.",
3416 ((item >= 0) ? "Your" : "The"), o_name,
3417 ((o_ptr->number > 1) ? "were" : "was"));
3423 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3427 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3430 msg_format("%s %s shine%s!",
3431 ((item >= 0) ? "Your" : "The"), o_name,
3432 ((o_ptr->number > 1) ? "" : "s"));
3435 add_flag(o_ptr->art_flags, TR_BLESSED);
3436 o_ptr->discount = 99;
3440 bool dis_happened = FALSE;
3443 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3445 msg_print("The weapon resists your blessing!");
3449 /* Disenchant tohit */
3450 if (o_ptr->to_h > 0)
3453 dis_happened = TRUE;
3456 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3458 /* Disenchant todam */
3459 if (o_ptr->to_d > 0)
3462 dis_happened = TRUE;
3465 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3467 /* Disenchant toac */
3468 if (o_ptr->to_a > 0)
3471 dis_happened = TRUE;
3474 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3479 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3481 msg_print("There is a static feeling in the air...");
3485 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3488 msg_format("%s %s %s disenchanted!",
3489 ((item >= 0) ? "Your" : "The"), o_name,
3490 ((o_ptr->number > 1) ? "were" : "was"));
3496 /* Recalculate bonuses */
3497 p_ptr->update |= (PU_BONUS);
3500 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3511 bool pulish_shield(void)
3515 u32b flgs[TR_FLAG_SIZE];
3516 char o_name[MAX_NLEN];
3519 item_tester_no_ryoute = TRUE;
3520 /* Assume enchant weapon */
3521 item_tester_tval = TV_SHIELD;
3525 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3526 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3528 q = "Pulish which weapon? ";
3529 s = "You have weapon to pulish.";
3532 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3535 /* Get the item (in the pack) */
3538 o_ptr = &inventory[item];
3541 /* Get the item (on the floor) */
3544 o_ptr = &o_list[0 - item];
3549 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3551 /* Extract the flags */
3552 object_flags(o_ptr, flgs);
3554 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3555 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3558 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3560 msg_format("%s %s shine%s!",
3561 ((item >= 0) ? "Your" : "The"), o_name,
3562 ((o_ptr->number > 1) ? "" : "s"));
3564 o_ptr->name2 = EGO_REFLECTION;
3565 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3567 o_ptr->discount = 99;
3568 chg_virtue(V_ENCHANT, 2);
3574 if (flush_failure) flush();
3577 msg_print("¼ºÇÔ¤·¤¿¡£");
3579 msg_print("Failed.");
3582 chg_virtue(V_ENCHANT, -2);
3591 * Potions "smash open" and cause an area effect when
3592 * (1) they are shattered while in the player's inventory,
3593 * due to cold (etc) attacks;
3594 * (2) they are thrown at a monster, or obstacle;
3595 * (3) they are shattered by a "cold ball" or other such spell
3596 * while lying on the floor.
3599 * who --- who caused the potion to shatter (0=player)
3600 * potions that smash on the floor are assumed to
3601 * be caused by no-one (who = 1), as are those that
3602 * shatter inside the player inventory.
3603 * (Not anymore -- I changed this; TY)
3604 * y, x --- coordinates of the potion (or player if
3605 * the potion was in her inventory);
3606 * o_ptr --- pointer to the potion object.
3608 bool potion_smash_effect(int who, int y, int x, int k_idx)
3615 object_kind *k_ptr = &k_info[k_idx];
3617 switch (k_ptr->sval)
3619 case SV_POTION_SALT_WATER:
3620 case SV_POTION_SLIME_MOLD:
3621 case SV_POTION_LOSE_MEMORIES:
3622 case SV_POTION_DEC_STR:
3623 case SV_POTION_DEC_INT:
3624 case SV_POTION_DEC_WIS:
3625 case SV_POTION_DEC_DEX:
3626 case SV_POTION_DEC_CON:
3627 case SV_POTION_DEC_CHR:
3628 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3629 case SV_POTION_APPLE_JUICE:
3632 case SV_POTION_INFRAVISION:
3633 case SV_POTION_DETECT_INVIS:
3634 case SV_POTION_SLOW_POISON:
3635 case SV_POTION_CURE_POISON:
3636 case SV_POTION_BOLDNESS:
3637 case SV_POTION_RESIST_HEAT:
3638 case SV_POTION_RESIST_COLD:
3639 case SV_POTION_HEROISM:
3640 case SV_POTION_BESERK_STRENGTH:
3641 case SV_POTION_RES_STR:
3642 case SV_POTION_RES_INT:
3643 case SV_POTION_RES_WIS:
3644 case SV_POTION_RES_DEX:
3645 case SV_POTION_RES_CON:
3646 case SV_POTION_RES_CHR:
3647 case SV_POTION_INC_STR:
3648 case SV_POTION_INC_INT:
3649 case SV_POTION_INC_WIS:
3650 case SV_POTION_INC_DEX:
3651 case SV_POTION_INC_CON:
3652 case SV_POTION_INC_CHR:
3653 case SV_POTION_AUGMENTATION:
3654 case SV_POTION_ENLIGHTENMENT:
3655 case SV_POTION_STAR_ENLIGHTENMENT:
3656 case SV_POTION_SELF_KNOWLEDGE:
3657 case SV_POTION_EXPERIENCE:
3658 case SV_POTION_RESISTANCE:
3659 case SV_POTION_INVULNERABILITY:
3660 case SV_POTION_NEW_LIFE:
3661 /* All of the above potions have no effect when shattered */
3663 case SV_POTION_SLOWNESS:
3668 case SV_POTION_POISON:
3673 case SV_POTION_BLINDNESS:
3677 case SV_POTION_CONFUSION: /* Booze */
3681 case SV_POTION_SLEEP:
3685 case SV_POTION_RUINATION:
3686 case SV_POTION_DETONATIONS:
3688 dam = damroll(25, 25);
3691 case SV_POTION_DEATH:
3692 dt = GF_DEATH_RAY; /* !! */
3693 dam = k_ptr->level * 10;
3697 case SV_POTION_SPEED:
3700 case SV_POTION_CURE_LIGHT:
3702 dam = damroll(2, 3);
3704 case SV_POTION_CURE_SERIOUS:
3706 dam = damroll(4, 3);
3708 case SV_POTION_CURE_CRITICAL:
3709 case SV_POTION_CURING:
3711 dam = damroll(6, 3);
3713 case SV_POTION_HEALING:
3715 dam = damroll(10, 10);
3717 case SV_POTION_RESTORE_EXP:
3722 case SV_POTION_LIFE:
3724 dam = damroll(50, 50);
3727 case SV_POTION_STAR_HEALING:
3729 dam = damroll(50, 50);
3732 case SV_POTION_RESTORE_MANA: /* MANA */
3734 dam = damroll(10, 10);
3741 (void)project(who, radius, y, x, dam, dt,
3742 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3744 /* XXX those potions that explode need to become "known" */
3750 * Hack -- Display all known spells in a window
3752 * XXX XXX XXX Need to analyze size of the window.
3754 * XXX XXX XXX Need more color coding.
3756 void display_spell_list(void)
3769 /* They have too many spells to list */
3770 if (p_ptr->pclass == CLASS_SORCERER) return;
3771 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3773 /* mind.c type classes */
3774 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3775 (p_ptr->pclass == CLASS_BERSERKER) ||
3776 (p_ptr->pclass == CLASS_NINJA) ||
3777 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3778 (p_ptr->pclass == CLASS_FORCETRAINER))
3784 int plev = p_ptr->lev;
3790 bool use_hp = FALSE;
3792 /* Display a list of spells */
3795 put_str("̾Á°", y, x + 5);
3796 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3798 put_str("Name", y, x + 5);
3799 put_str("Lv Mana Fail Info", y, x + 35);
3802 switch(p_ptr->pclass)
3804 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3805 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3806 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3807 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3808 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3809 default: use_mind = 0;break;
3812 /* Dump the spells */
3813 for (i = 0; i < MAX_MIND_POWERS; i++)
3815 byte a = TERM_WHITE;
3817 /* Access the available spell */
3818 spell = mind_powers[use_mind].info[i];
3819 if (spell.min_lev > plev) break;
3821 /* Get the failure rate */
3822 chance = spell.fail;
3824 /* Reduce failure rate by "effective" level adjustment */
3825 chance -= 3 * (p_ptr->lev - spell.min_lev);
3827 /* Reduce failure rate by INT/WIS adjustment */
3828 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3832 /* Not enough mana to cast */
3833 if (spell.mana_cost > p_ptr->csp)
3835 chance += 5 * (spell.mana_cost - p_ptr->csp);
3841 /* Not enough hp to cast */
3842 if (spell.mana_cost > p_ptr->chp)
3849 /* Extract the minimum failure rate */
3850 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3852 /* Minimum failure rate */
3853 if (chance < minfail) chance = minfail;
3855 /* Stunning makes spells harder */
3856 if (p_ptr->stun > 50) chance += 25;
3857 else if (p_ptr->stun) chance += 15;
3859 /* Always a 5 percent chance of working */
3860 if (chance > 95) chance = 95;
3863 mindcraft_info(comment, use_mind, i);
3865 /* Dump the spell */
3866 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3868 spell.min_lev, spell.mana_cost, chance, comment);
3870 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3875 /* Cannot read spellbooks */
3876 if (REALM_NONE == p_ptr->realm1) return;
3878 /* Normal spellcaster with books */
3881 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3885 /* Reset vertical */
3888 /* Vertical location */
3889 y = (j < 3) ? 0 : (m[j - 3] + 2);
3891 /* Horizontal location */
3895 for (i = 0; i < 32; i++)
3897 byte a = TERM_WHITE;
3899 /* Access the spell */
3900 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3902 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3906 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3909 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
3912 if (s_ptr->slevel >= 99)
3916 strcpy(name, "(ȽÆÉÉÔǽ)");
3918 strcpy(name, "(illegible)");
3928 ((p_ptr->spell_forgotten1 & (1L << i))) :
3929 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3936 else if (!((j < 1) ?
3937 (p_ptr->spell_learned1 & (1L << i)) :
3938 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3945 else if (!((j < 1) ?
3946 (p_ptr->spell_worked1 & (1L << i)) :
3947 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3953 /* Dump the spell --(-- */
3954 sprintf(out_val, "%c/%c) %-20.20s",
3955 I2A(n / 8), I2A(n % 8), name);
3960 /* Dump onto the window */
3961 Term_putstr(x, m[j], -1, a, out_val);
3971 * Returns experience of a spell
3973 s16b experience_of_spell(int spell, int use_realm)
3975 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3976 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3977 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3978 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3984 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3986 int mod_need_mana(int need_mana, int spell, int realm)
3988 #define MANA_CONST 2400
3990 #define DEC_MANA_DIV 3
3993 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
3996 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
3997 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
3999 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4000 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4001 need_mana /= MANA_CONST * MANA_DIV;
4002 if (need_mana < 1) need_mana = 1;
4005 /* Non-realm magic */
4008 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4020 * Modify spell fail rate
4021 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4023 int mod_spell_chance_1(int chance)
4025 chance += p_ptr->to_m_chance;
4027 if (p_ptr->heavy_spell) chance += 20;
4029 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4030 else if (p_ptr->easy_spell) chance -= 3;
4031 else if (p_ptr->dec_mana) chance -= 2;
4038 * Modify spell fail rate (as "suffix" process)
4039 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4040 * Note: variable "chance" cannot be negative.
4042 int mod_spell_chance_2(int chance)
4044 if (p_ptr->dec_mana) chance--;
4046 if (p_ptr->heavy_spell) chance += 5;
4048 return MAX(chance, 0);
4053 * Returns spell chance of failure for spell -RAK-
4055 s16b spell_chance(int spell, int use_realm)
4057 int chance, minfail;
4060 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4063 /* Paranoia -- must be literate */
4064 if (!mp_ptr->spell_book) return (100);
4066 if (use_realm == REALM_HISSATSU) return 0;
4068 /* Access the spell */
4069 if (!is_magic(use_realm))
4071 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4075 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4078 /* Extract the base spell failure rate */
4079 chance = s_ptr->sfail;
4081 /* Reduce failure rate by "effective" level adjustment */
4082 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4084 /* Reduce failure rate by INT/WIS adjustment */
4085 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4088 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4090 /* Extract mana consumption rate */
4091 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4093 /* Not enough mana to cast */
4094 if (need_mana > p_ptr->csp)
4096 chance += 5 * (need_mana - p_ptr->csp);
4099 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4101 /* Extract the minimum failure rate */
4102 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4105 * Non mage/priest characters never get too good
4106 * (added high mage, mindcrafter)
4108 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4110 if (minfail < 5) minfail = 5;
4113 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4114 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4115 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4117 chance = mod_spell_chance_1(chance);
4119 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4120 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4121 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4123 /* Minimum failure rate */
4124 if (chance < minfail) chance = minfail;
4126 /* Stunning makes spells harder */
4127 if (p_ptr->stun > 50) chance += 25;
4128 else if (p_ptr->stun) chance += 15;
4130 /* Always a 5 percent chance of working */
4131 if (chance > 95) chance = 95;
4133 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4134 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4136 s16b exp = experience_of_spell(spell, use_realm);
4137 if (exp >= SPELL_EXP_EXPERT) chance--;
4138 if (exp >= SPELL_EXP_MASTER) chance--;
4141 /* Return the chance */
4142 return mod_spell_chance_2(chance);
4148 * Determine if a spell is "okay" for the player to cast or study
4149 * The spell must be legible, not forgotten, and also, to cast,
4150 * it must be known, and to study, it must not be known.
4152 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4156 /* Access the spell */
4157 if (!is_magic(use_realm))
4159 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4163 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4166 /* Spell is illegal */
4167 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4169 /* Spell is forgotten */
4170 if ((use_realm == p_ptr->realm2) ?
4171 (p_ptr->spell_forgotten2 & (1L << spell)) :
4172 (p_ptr->spell_forgotten1 & (1L << spell)))
4178 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4179 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4181 /* Spell is learned */
4182 if ((use_realm == p_ptr->realm2) ?
4183 (p_ptr->spell_learned2 & (1L << spell)) :
4184 (p_ptr->spell_learned1 & (1L << spell)))
4187 return (!study_pray);
4190 /* Okay to study, not to cast */
4197 * Extra information on a spell -DRS-
4199 * We can use up to 14 characters of the buffer 'p'
4201 * The strings in this function were extracted from the code in the
4202 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4204 static void spell_info(char *p, int spell, int use_realm)
4206 int plev = p_ptr->lev;
4209 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4210 p_ptr->pclass == CLASS_HIGH_MAGE ||
4211 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4213 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4214 p_ptr->pclass == CLASS_HIGH_MAGE ||
4215 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4217 cptr s_dam = "»½ý:";
4218 cptr s_dur = "´ü´Ö:";
4219 cptr s_range = "ÈÏ°Ï:";
4220 cptr s_heal = "²óÉü:";
4221 cptr s_random = "¥é¥ó¥À¥à";
4222 cptr s_delay = "ÃÙ±ä:";
4224 cptr s_dam = "dam ";
4225 cptr s_dur = "dur ";
4226 cptr s_range = "range ";
4227 cptr s_heal = "heal ";
4228 cptr s_random = "random";
4229 cptr s_delay = "delay ";
4234 /* Analyze the spell */
4237 case REALM_LIFE: /* Life */
4240 case 0: sprintf(p, " %s2d10", s_heal); break;
4241 case 1: sprintf(p, " %s12+d12", s_dur); break;
4242 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4243 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4244 case 5: sprintf(p, " %s4d10", s_heal); break;
4245 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4246 case 10: sprintf(p, " %s8d10", s_heal); break;
4247 case 11: sprintf(p, " %s20+d20", s_dur); break;
4248 case 14: sprintf(p, " %s300", s_heal); break;
4249 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4250 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4251 case 21: sprintf(p, " %s15+d21", s_delay); break;
4252 case 29: sprintf(p, " %s2000", s_heal); break;
4253 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4257 case REALM_SORCERY: /* Sorcery */
4260 case 1: sprintf(p, " %s10", s_range); break;
4261 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4262 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4263 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4264 case 18: sprintf(p, " %s25+d30", s_dur); break;
4265 case 22: sprintf(p, " %s15+d21", s_delay); break;
4266 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4267 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4269 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4271 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4273 case 27: sprintf(p, " %s25+d30", s_dur); break;
4274 case 31: sprintf(p, " %s4+d4", s_dur); break;
4278 case REALM_NATURE: /* Nature */
4282 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4284 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4286 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4287 case 6: sprintf(p, " %s20+d20", s_dur); break;
4288 case 7: sprintf(p, " %s2d8", s_heal); break;
4289 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4290 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4291 case 12: sprintf(p, " %s6d8", s_dam); break;
4292 case 15: sprintf(p, " %s500", s_heal); break;
4293 case 17: sprintf(p, " %s20+d30", s_dur); break;
4294 case 18: sprintf(p, " %s20+d20", s_dur); break;
4296 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4298 case 24: sprintf(p, " rad 10"); break;
4300 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4301 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4302 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4303 case 29: sprintf(p, " %s75", s_dam); break;
4304 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4308 case REALM_CHAOS: /* Chaos */
4311 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4312 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4313 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4314 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4315 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4316 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4317 case 8: sprintf(p, " %s", s_random); break;
4318 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4319 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4320 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4321 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4322 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4323 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4324 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4325 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4326 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4328 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4330 case 25: sprintf(p, " dam %d each", plev * 2); break;
4332 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4333 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4334 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4335 case 30: sprintf(p, " %s%ld", s_dam, p_ptr->chp); break;
4336 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4340 case REALM_DEATH: /* Death */
4343 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4344 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4345 case 5: sprintf(p, " %s20+d20", s_dur); break;
4346 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4347 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4348 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4350 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4352 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4354 case 16: sprintf(p, " %s25+d25", s_dur); break;
4355 case 17: sprintf(p, " %s", s_random); break;
4356 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4357 case 19: sprintf(p, " %s25+d25", s_dur); break;
4358 case 21: sprintf(p, " %s3*100", s_dam); break;
4359 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4360 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4361 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4362 case 30: sprintf(p, " %s666", s_dam); break;
4363 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4367 case REALM_TRUMP: /* Trump */
4370 case 0: sprintf(p, " %s10", s_range); break;
4371 case 2: sprintf(p, " %s", s_random); break;
4372 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4373 case 5: sprintf(p, " %s25+d30", s_dur); break;
4375 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4377 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4379 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4380 case 14: sprintf(p, " %s15+d21", s_delay); break;
4381 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4383 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4385 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4390 case REALM_ARCANE: /* Arcane */
4393 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4394 case 4: sprintf(p, " %s10", s_range); break;
4395 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4396 case 7: sprintf(p, " %s2d8", s_heal); break;
4400 case 17: sprintf(p, " %s20+d20", s_dur); break;
4401 case 18: sprintf(p, " %s4d8", s_heal); break;
4402 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4403 case 21: sprintf(p, " %s6d8", s_dam); break;
4404 case 24: sprintf(p, " %s24+d24", s_dur); break;
4405 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4406 case 30: sprintf(p, " %s15+d21", s_delay); break;
4407 case 31: sprintf(p, " %s25+d30", s_dur); break;
4411 case REALM_ENCHANT: /* Craft */
4414 case 0: sprintf(p, " %s100+d100", s_dur); break;
4415 case 1: sprintf(p, " %s80+d80", s_dur); break;
4421 case 18: sprintf(p, " %s20+d20", s_dur); break;
4422 case 5: sprintf(p, " %s25+d25", s_dur); break;
4423 case 8: sprintf(p, " %s24+d24", s_dur); break;
4424 case 11: sprintf(p, " %s25+d25", s_dur); break;
4425 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4426 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4427 case 16: sprintf(p, " %s25+d30", s_dur); break;
4428 case 17: sprintf(p, " %s30+d20", s_dur); break;
4429 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4430 case 20: sprintf(p, " %s50+d50", s_dur); break;
4431 case 23: sprintf(p, " %s20+d20", s_dur); break;
4432 case 31: sprintf(p, " %s13+d13", s_dur); break;
4436 case REALM_DAEMON: /* Daemon */
4439 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4440 case 2: sprintf(p, " %s12+d12", s_dur); break;
4441 case 3: sprintf(p, " %s20+d20", s_dur); break;
4442 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4443 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4444 case 10: sprintf(p, " %s20+d20", s_dur); break;
4445 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4446 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4447 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4448 case 16: sprintf(p, " %s30+d25", s_dur); break;
4449 case 17: sprintf(p, " %s20+d20", s_dur); break;
4450 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4451 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4452 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4453 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4454 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4455 case 24: sprintf(p, " %s25+d25", s_dur); break;
4456 case 25: sprintf(p, " %s20+d20", s_dur); break;
4457 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4458 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4459 case 30: sprintf(p, " %s600", s_dam); break;
4460 case 31: sprintf(p, " %s15+d15", s_dur); break;
4464 case REALM_CRUSADE: /* Crusade */
4467 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4468 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4470 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4472 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4474 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4475 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4476 case 12: sprintf(p, " %s24+d24", s_dur); break;
4477 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4478 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4480 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4482 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4484 case 18: sprintf(p, " %s18+d18", s_dur); break;
4485 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4486 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4487 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4488 case 24: sprintf(p, " %s25+d25", s_dur); break;
4489 case 28: sprintf(p, " %s10+d10", s_dur); break;
4491 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4493 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4496 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4498 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4503 case REALM_MUSIC: /* Music */
4506 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4507 case 4 : sprintf(p, " %s2d6", s_heal); break;
4508 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4509 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4510 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4511 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4512 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4513 case 28: sprintf(p, " %s15d10", s_heal); break;
4514 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4519 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4521 sprintf(p, "Unknown type: %d.", use_realm);
4528 * Print a list of spells (for browsing or casting or viewing)
4530 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4532 int i, spell, exp_level, increment = 64;
4544 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4546 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4548 msg_print("Warning! print_spells called with null realm");
4552 /* Title the list */
4554 if (use_realm == REALM_HISSATSU)
4556 strcpy(buf," Lv MP");
4558 strcpy(buf," Lv SP");
4562 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4564 strcpy(buf,"Profic Lv SP Fail Effect");
4568 put_str("̾Á°", y, x + 5);
4569 put_str(buf, y, x + 29);
4571 put_str("Name", y, x + 5);
4572 put_str(buf, y, x + 29);
4575 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4576 else if (use_realm == p_ptr->realm1) increment = 0;
4577 else if (use_realm == p_ptr->realm2) increment = 32;
4579 /* Dump the spells */
4580 for (i = 0; i < num; i++)
4582 /* Access the spell */
4585 /* Access the spell */
4586 if (!is_magic(use_realm))
4588 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4592 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4595 if (use_realm == REALM_HISSATSU)
4596 need_mana = s_ptr->smana;
4599 s16b exp = experience_of_spell(spell, use_realm);
4601 /* Extract mana consumption rate */
4602 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4604 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4605 else exp_level = spell_exp_level(exp);
4608 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4609 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4610 else if (s_ptr->slevel >= 99) max = TRUE;
4611 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4613 strncpy(ryakuji, exp_level_str[exp_level], 4);
4618 if (use_menu && target_spell)
4620 if (i == (target_spell-1))
4622 strcpy(out_val, " ¡Õ ");
4624 strcpy(out_val, " > ");
4627 strcpy(out_val, " ");
4629 else sprintf(out_val, " %c) ", I2A(i));
4630 /* Skip illegible spells */
4631 if (s_ptr->slevel >= 99)
4634 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4636 strcat(out_val, format("%-30s", "(illegible)"));
4639 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4643 /* XXX XXX Could label spells above the players level */
4645 /* Get extra info */
4646 spell_info(info, spell, use_realm);
4651 /* Assume spell is known and tried */
4652 line_attr = TERM_WHITE;
4654 /* Analyze the spell */
4655 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4657 if (s_ptr->slevel > p_ptr->max_plv)
4662 comment = " unknown";
4665 line_attr = TERM_L_BLUE;
4667 else if (s_ptr->slevel > p_ptr->lev)
4672 comment = " forgotten";
4675 line_attr = TERM_YELLOW;
4678 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4683 comment = " unknown";
4686 line_attr = TERM_L_BLUE;
4688 else if ((use_realm == p_ptr->realm1) ?
4689 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4690 ((p_ptr->spell_forgotten2 & (1L << spell))))
4695 comment = " forgotten";
4698 line_attr = TERM_YELLOW;
4700 else if (!((use_realm == p_ptr->realm1) ?
4701 (p_ptr->spell_learned1 & (1L << spell)) :
4702 (p_ptr->spell_learned2 & (1L << spell))))
4707 comment = " unknown";
4710 line_attr = TERM_L_BLUE;
4712 else if (!((use_realm == p_ptr->realm1) ?
4713 (p_ptr->spell_worked1 & (1L << spell)) :
4714 (p_ptr->spell_worked2 & (1L << spell))))
4717 comment = " ̤·Ð¸³";
4719 comment = " untried";
4722 line_attr = TERM_L_GREEN;
4725 /* Dump the spell --(-- */
4726 if (use_realm == REALM_HISSATSU)
4728 strcat(out_val, format("%-25s %2d %4d",
4729 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4730 s_ptr->slevel, need_mana));
4734 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4735 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4736 (max ? '!' : ' '), ryakuji,
4737 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4739 c_prt(line_attr, out_val, y + i + 1, x);
4742 /* Clear the bottom line */
4743 prt("", y + i + 1, x);
4748 * Note that amulets, rods, and high-level spell books are immune
4749 * to "inventory damage" of any kind. Also sling ammo and shovels.
4754 * Does a given class of objects (usually) hate acid?
4755 * Note that acid can either melt or corrode something.
4757 bool hates_acid(object_type *o_ptr)
4759 /* Analyze the type */
4760 switch (o_ptr->tval)
4762 /* Wearable items */
4782 /* Staffs/Scrolls are wood/paper */
4795 /* Junk is useless */
4809 * Does a given object (usually) hate electricity?
4811 bool hates_elec(object_type *o_ptr)
4813 switch (o_ptr->tval)
4827 * Does a given object (usually) hate fire?
4828 * Hafted/Polearm weapons have wooden shafts.
4829 * Arrows/Bows are mostly wooden.
4831 bool hates_fire(object_type *o_ptr)
4833 /* Analyze the type */
4834 switch (o_ptr->tval)
4852 case TV_SORCERY_BOOK:
4853 case TV_NATURE_BOOK:
4857 case TV_ARCANE_BOOK:
4858 case TV_ENCHANT_BOOK:
4859 case TV_DAEMON_BOOK:
4860 case TV_CRUSADE_BOOK:
4862 case TV_HISSATSU_BOOK:
4873 /* Staffs/Scrolls burn */
4886 * Does a given object (usually) hate cold?
4888 bool hates_cold(object_type *o_ptr)
4890 switch (o_ptr->tval)
4907 int set_acid_destroy(object_type *o_ptr)
4909 u32b flgs[TR_FLAG_SIZE];
4910 if (!hates_acid(o_ptr)) return (FALSE);
4911 object_flags(o_ptr, flgs);
4912 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4920 int set_elec_destroy(object_type *o_ptr)
4922 u32b flgs[TR_FLAG_SIZE];
4923 if (!hates_elec(o_ptr)) return (FALSE);
4924 object_flags(o_ptr, flgs);
4925 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4933 int set_fire_destroy(object_type *o_ptr)
4935 u32b flgs[TR_FLAG_SIZE];
4936 if (!hates_fire(o_ptr)) return (FALSE);
4937 object_flags(o_ptr, flgs);
4938 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4946 int set_cold_destroy(object_type *o_ptr)
4948 u32b flgs[TR_FLAG_SIZE];
4949 if (!hates_cold(o_ptr)) return (FALSE);
4950 object_flags(o_ptr, flgs);
4951 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4957 * Destroys a type of item on a given percent chance
4958 * Note that missiles are no longer necessarily all destroyed
4959 * Destruction taken from "melee.c" code for "stealing".
4960 * New-style wands and rods handled correctly. -LM-
4961 * Returns number of items destroyed.
4963 int inven_damage(inven_func typ, int perc)
4967 char o_name[MAX_NLEN];
4969 /* Multishadow effects is determined by turn */
4970 if( p_ptr->multishadow && (turn & 1) )return 0;
4972 if (p_ptr->inside_arena) return 0;
4974 /* Count the casualties */
4977 /* Scan through the slots backwards */
4978 for (i = 0; i < INVEN_PACK; i++)
4980 o_ptr = &inventory[i];
4982 /* Skip non-objects */
4983 if (!o_ptr->k_idx) continue;
4985 /* Hack -- for now, skip artifacts */
4986 if (object_is_artifact(o_ptr)) continue;
4988 /* Give this item slot a shot at death */
4991 /* Count the casualties */
4992 for (amt = j = 0; j < o_ptr->number; ++j)
4994 if (randint0(100) < perc) amt++;
4997 /* Some casualities */
5000 /* Get a description */
5001 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5005 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
5007 msg_format("%sour %s (%c) %s destroyed!",
5011 o_name, index_to_label(i),
5012 ((o_ptr->number > 1) ?
5013 ((amt == o_ptr->number) ? "Á´Éô" :
5014 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
5016 ((o_ptr->number > 1) ?
5017 ((amt == o_ptr->number) ? "All of y" :
5018 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
5019 o_name, index_to_label(i),
5020 ((amt > 1) ? "were" : "was"));
5024 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
5025 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
5028 /* Potions smash open */
5029 if (object_is_potion(o_ptr))
5031 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
5034 /* Reduce the charges of rods/wands */
5035 reduce_charges(o_ptr, amt);
5037 /* Destroy "amt" items */
5038 inven_item_increase(i, -amt);
5039 inven_item_optimize(i);
5041 /* Count the casualties */
5047 /* Return the casualty count */
5053 * Acid has hit the player, attempt to affect some armor.
5055 * Note that the "base armor" of an object never changes.
5057 * If any armor is damaged (or resists), the player takes less damage.
5059 static int minus_ac(void)
5061 object_type *o_ptr = NULL;
5062 u32b flgs[TR_FLAG_SIZE];
5063 char o_name[MAX_NLEN];
5066 /* Pick a (possibly empty) inventory slot */
5067 switch (randint1(7))
5069 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5070 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5071 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5072 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5073 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5074 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5075 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5078 /* Nothing to damage */
5079 if (!o_ptr->k_idx) return (FALSE);
5081 if (!object_is_armour(o_ptr)) return (FALSE);
5083 /* No damage left to be done */
5084 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5088 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5090 /* Extract the flags */
5091 object_flags(o_ptr, flgs);
5093 /* Object resists */
5094 if (have_flag(flgs, TR_IGNORE_ACID))
5097 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5099 msg_format("Your %s is unaffected!", o_name);
5108 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5110 msg_format("Your %s is damaged!", o_name);
5114 /* Damage the item */
5117 /* Calculate bonuses */
5118 p_ptr->update |= (PU_BONUS);
5121 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5125 /* Item was damaged */
5131 * Hurt the player with Acid
5133 int acid_dam(int dam, cptr kb_str, int monspell)
5136 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5137 bool double_resist = IS_OPPOSE_ACID();
5139 /* Total Immunity */
5140 if (p_ptr->immune_acid || (dam <= 0))
5142 learn_spell(monspell);
5146 /* Vulnerability (Ouch!) */
5147 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5148 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5150 /* Resist the damage */
5151 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5152 if (double_resist) dam = (dam + 2) / 3;
5154 if ((!(double_resist || p_ptr->resist_acid)) &&
5155 one_in_(HURT_CHANCE))
5156 (void)do_dec_stat(A_CHR);
5158 /* If any armor gets hit, defend the player */
5159 if (minus_ac()) dam = (dam + 1) / 2;
5162 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5164 /* Inventory damage */
5165 if (!(double_resist && p_ptr->resist_acid))
5166 inven_damage(set_acid_destroy, inv);
5172 * Hurt the player with electricity
5174 int elec_dam(int dam, cptr kb_str, int monspell)
5177 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5178 bool double_resist = IS_OPPOSE_ELEC();
5180 /* Total immunity */
5181 if (p_ptr->immune_elec || (dam <= 0))
5183 learn_spell(monspell);
5187 /* Vulnerability (Ouch!) */
5188 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5189 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5190 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5192 /* Resist the damage */
5193 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5194 if (double_resist) dam = (dam + 2) / 3;
5196 if ((!(double_resist || p_ptr->resist_elec)) &&
5197 one_in_(HURT_CHANCE))
5198 (void)do_dec_stat(A_DEX);
5201 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5203 /* Inventory damage */
5204 if (!(double_resist && p_ptr->resist_elec))
5205 inven_damage(set_elec_destroy, inv);
5212 * Hurt the player with Fire
5214 int fire_dam(int dam, cptr kb_str, int monspell)
5217 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5218 bool double_resist = IS_OPPOSE_FIRE();
5220 /* Totally immune */
5221 if (p_ptr->immune_fire || (dam <= 0))
5223 learn_spell(monspell);
5227 /* Vulnerability (Ouch!) */
5228 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5229 if (prace_is_(RACE_ENT)) dam += dam / 3;
5230 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5232 /* Resist the damage */
5233 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5234 if (double_resist) dam = (dam + 2) / 3;
5236 if ((!(double_resist || p_ptr->resist_fire)) &&
5237 one_in_(HURT_CHANCE))
5238 (void)do_dec_stat(A_STR);
5241 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5243 /* Inventory damage */
5244 if (!(double_resist && p_ptr->resist_fire))
5245 inven_damage(set_fire_destroy, inv);
5252 * Hurt the player with Cold
5254 int cold_dam(int dam, cptr kb_str, int monspell)
5257 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5258 bool double_resist = IS_OPPOSE_COLD();
5260 /* Total immunity */
5261 if (p_ptr->immune_cold || (dam <= 0))
5263 learn_spell(monspell);
5267 /* Vulnerability (Ouch!) */
5268 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5269 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5271 /* Resist the damage */
5272 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5273 if (double_resist) dam = (dam + 2) / 3;
5275 if ((!(double_resist || p_ptr->resist_cold)) &&
5276 one_in_(HURT_CHANCE))
5277 (void)do_dec_stat(A_STR);
5280 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5282 /* Inventory damage */
5283 if (!(double_resist && p_ptr->resist_cold))
5284 inven_damage(set_cold_destroy, inv);
5290 bool rustproof(void)
5294 char o_name[MAX_NLEN];
5297 item_tester_no_ryoute = TRUE;
5298 /* Select a piece of armour */
5299 item_tester_hook = object_is_armour;
5303 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5304 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5306 q = "Rustproof which piece of armour? ";
5307 s = "You have nothing to rustproof.";
5310 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5312 /* Get the item (in the pack) */
5315 o_ptr = &inventory[item];
5318 /* Get the item (on the floor) */
5321 o_ptr = &o_list[0 - item];
5326 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5328 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5330 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
5333 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5335 msg_format("%s %s look%s as good as new!",
5336 ((item >= 0) ? "Your" : "The"), o_name,
5337 ((o_ptr->number > 1) ? "" : "s"));
5344 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5346 msg_format("%s %s %s now protected against corrosion.",
5347 ((item >= 0) ? "Your" : "The"), o_name,
5348 ((o_ptr->number > 1) ? "are" : "is"));
5359 * Curse the players armor
5361 bool curse_armor(void)
5366 char o_name[MAX_NLEN];
5369 /* Curse the body armor */
5370 o_ptr = &inventory[INVEN_BODY];
5372 /* Nothing to curse */
5373 if (!o_ptr->k_idx) return (FALSE);
5377 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5379 /* Attempt a saving throw for artifacts */
5380 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
5384 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5385 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5387 msg_format("A %s tries to %s, but your %s resists the effects!",
5388 "terrible black aura", "surround your armor", o_name);
5393 /* not artifact or failed save... */
5398 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5400 msg_format("A terrible black aura blasts your %s!", o_name);
5403 chg_virtue(V_ENCHANT, -5);
5405 /* Blast the armor */
5407 o_ptr->name2 = EGO_BLASTED;
5408 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5415 for (i = 0; i < TR_FLAG_SIZE; i++)
5416 o_ptr->art_flags[i] = 0;
5419 o_ptr->curse_flags = TRC_CURSED;
5422 o_ptr->ident |= (IDENT_BROKEN);
5424 /* Recalculate bonuses */
5425 p_ptr->update |= (PU_BONUS);
5427 /* Recalculate mana */
5428 p_ptr->update |= (PU_MANA);
5431 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5439 * Curse the players weapon
5441 bool curse_weapon(bool force, int slot)
5447 char o_name[MAX_NLEN];
5450 /* Curse the weapon */
5451 o_ptr = &inventory[slot];
5453 /* Nothing to curse */
5454 if (!o_ptr->k_idx) return (FALSE);
5458 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5460 /* Attempt a saving throw */
5461 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
5465 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5466 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5468 msg_format("A %s tries to %s, but your %s resists the effects!",
5469 "terrible black aura", "surround your weapon", o_name);
5474 /* not artifact or failed save... */
5479 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5481 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5484 chg_virtue(V_ENCHANT, -5);
5486 /* Shatter the weapon */
5488 o_ptr->name2 = EGO_SHATTERED;
5489 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5490 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5496 for (i = 0; i < TR_FLAG_SIZE; i++)
5497 o_ptr->art_flags[i] = 0;
5501 o_ptr->curse_flags = TRC_CURSED;
5504 o_ptr->ident |= (IDENT_BROKEN);
5506 /* Recalculate bonuses */
5507 p_ptr->update |= (PU_BONUS);
5509 /* Recalculate mana */
5510 p_ptr->update |= (PU_MANA);
5513 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5522 * Enchant some bolts
5524 bool brand_bolts(void)
5528 /* Use the first acceptable bolts */
5529 for (i = 0; i < INVEN_PACK; i++)
5531 object_type *o_ptr = &inventory[i];
5533 /* Skip non-bolts */
5534 if (o_ptr->tval != TV_BOLT) continue;
5536 /* Skip artifacts and ego-items */
5537 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5540 /* Skip cursed/broken items */
5541 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5544 if (randint0(100) < 75) continue;
5548 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5550 msg_print("Your bolts are covered in a fiery aura!");
5555 o_ptr->name2 = EGO_FLAME;
5558 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5565 if (flush_failure) flush();
5569 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5571 msg_print("The fiery enchantment failed.");
5581 * Helper function -- return a "nearby" race for polymorphing
5583 * Note that this function is one of the more "dangerous" ones...
5585 static s16b poly_r_idx(int r_idx)
5587 monster_race *r_ptr = &r_info[r_idx];
5589 int i, r, lev1, lev2;
5591 /* Hack -- Uniques/Questors never polymorph */
5592 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5593 (r_ptr->flags1 & RF1_QUESTOR))
5596 /* Allowable range of "levels" for resulting monster */
5597 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5598 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5600 /* Pick a (possibly new) non-unique race */
5601 for (i = 0; i < 1000; i++)
5603 /* Pick a new race, using a level calculation */
5604 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5606 /* Handle failure */
5612 /* Ignore unique monsters */
5613 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5615 /* Ignore monsters with incompatible levels */
5616 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5618 /* Use that index */
5630 bool polymorph_monster(int y, int x)
5632 cave_type *c_ptr = &cave[y][x];
5633 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5634 bool polymorphed = FALSE;
5636 int old_r_idx = m_ptr->r_idx;
5637 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5638 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5639 monster_type back_m;
5641 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5643 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5645 /* Memorize the monster before polymorphing */
5648 /* Pick a "new" monster race */
5649 new_r_idx = poly_r_idx(old_r_idx);
5651 /* Handle polymorph */
5652 if (new_r_idx != old_r_idx)
5656 /* Get the monsters attitude */
5657 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5658 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5659 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5661 /* "Kill" the "old" monster */
5662 delete_monster_idx(c_ptr->m_idx);
5664 /* Create a new monster (no groups) */
5665 if (place_monster_aux(0, y, x, new_r_idx, mode))
5672 /* Placing the new monster failed */
5673 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5674 m_list[hack_m_idx_ii] = back_m;
5677 if (targeted) target_who = hack_m_idx_ii;
5678 if (health_tracked) health_track(hack_m_idx_ii);
5688 static bool dimension_door_aux(int x, int y)
5690 int plev = p_ptr->lev;
5692 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5694 if (!cave_teleportable_bold(y, x, FALSE) ||
5695 (distance(y, x, py, px) > plev / 2 + 10) ||
5696 (!randint0(plev / 10 + 10)))
5698 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5699 teleport_player((plev + 2) * 2, TRUE);
5706 teleport_player_to(y, x, TRUE, FALSE);
5717 bool dimension_door(void)
5721 /* Rerutn FALSE if cancelled */
5722 if (!tgt_pt(&x, &y)) return FALSE;
5724 if (dimension_door_aux(x, y)) return TRUE;
5727 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5729 msg_print("You fail to exit the astral plane correctly!");
5737 * Mirror Master's Dimension Door
5739 bool mirror_tunnel(void)
5743 /* Rerutn FALSE if cancelled */
5744 if (!tgt_pt(&x, &y)) return FALSE;
5746 if (dimension_door_aux(x, y)) return TRUE;
5749 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5751 msg_print("You fail to pass the mirror plane correctly!");
5758 bool eat_magic(int power)
5760 object_type * o_ptr;
5763 int recharge_strength = 0;
5769 char o_name[MAX_NLEN];
5771 item_tester_hook = item_tester_hook_recharge;
5775 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5776 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5778 q = "Drain which item? ";
5779 s = "You have nothing to drain.";
5782 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5786 o_ptr = &inventory[item];
5790 o_ptr = &o_list[0 - item];
5793 k_ptr = &k_info[o_ptr->k_idx];
5794 lev = k_info[o_ptr->k_idx].level;
5796 if (o_ptr->tval == TV_ROD)
5798 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5801 if (one_in_(recharge_strength))
5803 /* Activate the failure code. */
5808 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5811 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5813 msg_print("You can't absorb energy from a discharged rod.");
5820 o_ptr->timeout += k_ptr->pval;
5826 /* All staffs, wands. */
5827 recharge_strength = (100 + power - lev) / 15;
5830 if (recharge_strength < 0) recharge_strength = 0;
5833 if (one_in_(recharge_strength))
5835 /* Activate the failure code. */
5840 if (o_ptr->pval > 0)
5842 p_ptr->csp += lev / 2;
5845 /* XXX Hack -- unstack if necessary */
5846 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5851 /* Get local object */
5854 /* Obtain a local object */
5855 object_copy(q_ptr, o_ptr);
5857 /* Modify quantity */
5860 /* Restore the charges */
5863 /* Unstack the used item */
5865 p_ptr->total_weight -= q_ptr->weight;
5866 item = inven_carry(q_ptr);
5870 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5872 msg_print("You unstack your staff.");
5880 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5882 msg_print("There's no energy there to absorb!");
5886 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5890 /* Inflict the penalties for failing a recharge. */
5893 /* Artifacts are never destroyed. */
5894 if (object_is_fixed_artifact(o_ptr))
5896 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5898 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5900 msg_format("The recharging backfires - %s is completely drained!", o_name);
5904 /* Artifact rods. */
5905 if (o_ptr->tval == TV_ROD)
5906 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5908 /* Artifact wands and staffs. */
5909 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5914 /* Get the object description */
5915 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5917 /*** Determine Seriousness of Failure ***/
5919 /* Mages recharge objects more safely. */
5920 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)
5922 /* 10% chance to blow up one rod, otherwise draining. */
5923 if (o_ptr->tval == TV_ROD)
5925 if (one_in_(10)) fail_type = 2;
5928 /* 75% chance to blow up one wand, otherwise draining. */
5929 else if (o_ptr->tval == TV_WAND)
5931 if (!one_in_(3)) fail_type = 2;
5934 /* 50% chance to blow up one staff, otherwise no effect. */
5935 else if (o_ptr->tval == TV_STAFF)
5937 if (one_in_(2)) fail_type = 2;
5942 /* All other classes get no special favors. */
5945 /* 33% chance to blow up one rod, otherwise draining. */
5946 if (o_ptr->tval == TV_ROD)
5948 if (one_in_(3)) fail_type = 2;
5951 /* 20% chance of the entire stack, else destroy one wand. */
5952 else if (o_ptr->tval == TV_WAND)
5954 if (one_in_(5)) fail_type = 3;
5957 /* Blow up one staff. */
5958 else if (o_ptr->tval == TV_STAFF)
5964 /*** Apply draining and destruction. ***/
5966 /* Drain object or stack of objects. */
5969 if (o_ptr->tval == TV_ROD)
5972 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
5974 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
5977 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5979 else if (o_ptr->tval == TV_WAND)
5982 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
5984 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
5989 /* Staffs aren't drained. */
5992 /* Destroy an object or one in a stack of objects. */
5995 if (o_ptr->number > 1)
5998 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
6000 msg_format("Wild magic consumes one of your %s!", o_name);
6003 /* Reduce rod stack maximum timeout, drain wands. */
6004 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
6005 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
6010 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
6012 msg_format("Wild magic consumes your %s!", o_name);
6015 /* Reduce and describe inventory */
6018 inven_item_increase(item, -1);
6019 inven_item_describe(item);
6020 inven_item_optimize(item);
6023 /* Reduce and describe floor item */
6026 floor_item_increase(0 - item, -1);
6027 floor_item_describe(0 - item);
6028 floor_item_optimize(0 - item);
6032 /* Destroy all members of a stack of objects. */
6035 if (o_ptr->number > 1)
6037 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
6039 msg_format("Wild magic consumes all your %s!", o_name);
6044 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
6046 msg_format("Wild magic consumes your %s!", o_name);
6051 /* Reduce and describe inventory */
6054 inven_item_increase(item, -999);
6055 inven_item_describe(item);
6056 inven_item_optimize(item);
6059 /* Reduce and describe floor item */
6062 floor_item_increase(0 - item, -999);
6063 floor_item_describe(0 - item);
6064 floor_item_optimize(0 - item);
6070 if (p_ptr->csp > p_ptr->msp)
6072 p_ptr->csp = p_ptr->msp;
6075 /* Redraw mana and hp */
6076 p_ptr->redraw |= (PR_MANA);
6078 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6079 p_ptr->window |= (PW_INVEN);
6085 bool summon_kin_player(int level, int y, int x, u32b mode)
6087 bool pet = (bool)(mode & PM_FORCE_PET);
6088 if (!pet) mode |= PM_NO_PET;
6090 switch (p_ptr->mimic_form)
6093 switch (p_ptr->prace)
6097 case RACE_BARBARIAN:
6100 summon_kin_type = 'p';
6110 case RACE_MIND_FLAYER:
6113 summon_kin_type = 'h';
6116 summon_kin_type = 'o';
6118 case RACE_HALF_TROLL:
6119 summon_kin_type = 'T';
6121 case RACE_HALF_OGRE:
6122 summon_kin_type = 'O';
6124 case RACE_HALF_GIANT:
6125 case RACE_HALF_TITAN:
6127 summon_kin_type = 'P';
6130 summon_kin_type = 'y';
6133 summon_kin_type = 'K';
6136 summon_kin_type = 'k';
6139 if (one_in_(13)) summon_kin_type = 'U';
6140 else summon_kin_type = 'u';
6142 case RACE_DRACONIAN:
6143 summon_kin_type = 'd';
6147 summon_kin_type = 'g';
6150 if (one_in_(13)) summon_kin_type = 'L';
6151 else summon_kin_type = 's';
6154 summon_kin_type = 'z';
6157 summon_kin_type = 'V';
6160 summon_kin_type = 'G';
6163 summon_kin_type = 'I';
6166 summon_kin_type = '#';
6169 summon_kin_type = 'A';
6172 summon_kin_type = 'U';
6175 summon_kin_type = 'p';
6180 if (one_in_(13)) summon_kin_type = 'U';
6181 else summon_kin_type = 'u';
6183 case MIMIC_DEMON_LORD:
6184 summon_kin_type = 'U';
6187 summon_kin_type = 'V';
6190 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);