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, u16b mode)
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 if (!(mode & TELEPORT_ALLOW_OBJECT) && (c_ptr->info & CAVE_OBJECT)) return FALSE;
264 if (c_ptr->m_idx) return FALSE;
265 if (player_bold(y, x)) return FALSE;
267 if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
269 if ((mode & TELEPORT_REQUIRE_PROJECT) && !have_flag(f_ptr->flags, FF_PROJECT)) return FALSE;
271 if (!(mode & TELEPORT_ALLOW_DEEP))
273 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
275 if (!p_ptr->ffall && !p_ptr->can_swim) return FALSE;
277 if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
279 if (have_flag(f_ptr->flags, FF_DEEP) || !p_ptr->ffall) return FALSE;
288 * Teleport the player to a location up to "dis" grids away.
290 * If no such spaces are readily available, the distance may increase.
291 * Try very hard to move the player at least a quarter that distance.
293 * When long-range teleport effects are considered, there is a nasty
294 * tendency to "bounce" the player between two or three different spots
295 * because these are the only spots that are "far enough" way to satisfy
296 * the algorithm. Therefore, if the teleport distance is more than 50,
297 * we decrease the minimum acceptable distance to try to increase randomness.
300 void teleport_player(int dis)
302 int d, i, min, ox, oy;
313 if (p_ptr->wild_mode) return;
315 if (p_ptr->anti_tele)
318 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
320 msg_print("A mysterious force prevents you from teleporting!");
326 if (dis > 200) dis = 200; /* To be on the safe side... */
328 /* Minimum distance */
329 min = dis / (dis > 50 ? 3 : 2);
331 /* Look until done */
336 /* Verify max distance */
337 if (dis > 200) dis = 200;
339 /* Try several locations */
340 for (i = 0; i < 500; i++)
342 /* Pick a (possibly illegal) location */
345 y = rand_spread(py, dis);
346 x = rand_spread(px, dis);
347 d = distance(py, px, y, x);
348 if ((d >= min) && (d <= dis)) break;
351 /* Ignore illegal locations */
352 if (!in_bounds(y, x)) continue;
354 /* No teleporting into vaults and such */
355 if (cave[y][x].info & CAVE_ICKY) continue;
357 if (!cave_teleportable_bold(y, x, 0)) continue;
359 /* This grid looks good */
366 /* Increase the maximum distance */
369 /* Decrease the minimum distance */
372 /* Stop after MAX_TRIES tries */
373 if (tries > MAX_TRIES) return;
377 sound(SOUND_TELEPORT);
380 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
381 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
384 /* Save the old location */
388 /* Move the player */
394 cave[oy][ox].m_idx = cave[py][px].m_idx;
395 cave[py][px].m_idx = p_ptr->riding;
396 m_list[p_ptr->riding].fy = py;
397 m_list[p_ptr->riding].fx = px;
398 update_mon(p_ptr->riding, TRUE);
401 /* Redraw the old spot */
404 /* Monsters with teleport ability may follow the player */
405 for (xx = -1; xx < 2; xx++)
407 for (yy = -1; yy < 2; yy++)
409 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
411 /* A monster except your mount may follow */
412 if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
414 monster_type *m_ptr = &m_list[tmp_m_idx];
415 monster_race *r_ptr = &r_info[m_ptr->r_idx];
418 * The latter limitation is to avoid
419 * totally unkillable suckers...
421 if ((r_ptr->flags6 & RF6_TPORT) &&
422 !(r_ptr->flagsr & RFR_RES_TELE))
424 if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level);
432 /* Redraw the new spot */
435 /* Check for new panel (redraw map) */
439 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
441 /* Update the monsters */
442 p_ptr->update |= (PU_DISTANCE);
445 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
447 /* Handle stuff XXX XXX XXX */
454 * Teleport player to a grid near the given location
456 * This function is slightly obsessive about correctness.
457 * This function allows teleporting into vaults (!)
459 void teleport_player_to(int ny, int nx, bool no_tele)
461 int y, x, oy, ox, dis = 0, ctr = 0;
463 if (p_ptr->anti_tele && no_tele)
466 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
468 msg_print("A mysterious force prevents you from teleporting!");
474 /* Find a usable location */
477 /* Pick a nearby legal location */
480 y = rand_spread(ny, dis);
481 x = rand_spread(nx, dis);
482 if (in_bounds(y, x)) break;
485 /* Accept "naked" floor grids */
486 if (!no_tele && player_bold(y, x)) break;
487 if (cave_teleportable_bold(y, x, TELEPORT_ALLOW_DEEP | (no_tele ? 0 : TELEPORT_ALLOW_OBJECT))) break;
489 /* Occasionally advance the distance */
490 if (++ctr > (4 * dis * dis + 4 * dis + 1))
498 sound(SOUND_TELEPORT);
500 /* Save the old location */
504 /* Move the player */
510 cave[oy][ox].m_idx = cave[py][px].m_idx;
511 cave[py][px].m_idx = p_ptr->riding;
512 m_list[p_ptr->riding].fy = py;
513 m_list[p_ptr->riding].fx = px;
514 update_mon(p_ptr->riding, TRUE);
519 /* Redraw the old spot */
522 /* Redraw the new spot */
525 /* Check for new panel (redraw map) */
529 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
531 /* Update the monsters */
532 p_ptr->update |= (PU_DISTANCE);
535 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
537 /* Handle stuff XXX XXX XXX */
544 * Teleport the player one level up or down (random when legal)
545 * Note: If m_idx <= 0, target is player.
547 void teleport_level(int m_idx)
553 if (m_idx <= 0) /* To player */
556 strcpy(m_name, "¤¢¤Ê¤¿");
558 strcpy(m_name, "you");
561 else /* To monster */
563 monster_type *m_ptr = &m_list[m_idx];
565 /* Get the monster name (or "it") */
566 monster_desc(m_name, m_ptr, 0);
571 /* No effect in some case */
572 if (TELE_LEVEL_IS_INEFF(m_idx))
575 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
577 if (see_m) msg_print("There is no effect.");
583 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
586 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
588 msg_print("A mysterious force prevents you from teleporting!");
593 /* Choose up or down */
594 if (randint0(100) < 50) go_up = TRUE;
597 if ((m_idx <= 0) && p_ptr->wizard)
599 if (get_check("Force to go up? ")) go_up = TRUE;
600 else if (get_check("Force to go down? ")) go_up = FALSE;
604 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
607 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
609 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
611 if (m_idx <= 0) /* To player */
615 dungeon_type = p_ptr->recall_dungeon;
620 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
622 if (autosave_l) do_cmd_save_game(TRUE);
626 dun_level = d_info[dungeon_type].mindepth;
627 prepare_change_floor_mode(CFM_RAND_PLACE);
631 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
635 p_ptr->leaving = TRUE;
640 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
643 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
645 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
649 if (m_idx <= 0) /* To player */
651 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
653 if (autosave_l) do_cmd_save_game(TRUE);
655 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
660 p_ptr->inside_quest = 0;
661 p_ptr->leaving = TRUE;
667 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
669 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
673 if (m_idx <= 0) /* To player */
675 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
677 if (autosave_l) do_cmd_save_game(TRUE);
679 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
682 p_ptr->leaving = TRUE;
688 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
690 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
693 if (m_idx <= 0) /* To player */
695 /* Never reach this code on the surface */
696 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
698 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
700 if (autosave_l) do_cmd_save_game(TRUE);
702 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
705 p_ptr->leaving = TRUE;
709 /* Monster level teleportation is simple deleting now */
712 monster_type *m_ptr = &m_list[m_idx];
714 /* Check for quest completion */
715 check_quest_completion(m_ptr);
717 delete_monster_idx(m_idx);
721 sound(SOUND_TPLEVEL);
726 int choose_dungeon(cptr note, int y, int x)
732 /* Hack -- No need to choose dungeon in some case */
733 if (lite_town || vanilla_town || ironman_downward)
735 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
739 msg_format("¤Þ¤À%s¤ËÆþ¤Ã¤¿¤³¤È¤Ï¤Ê¤¤¡£", d_name + d_info[DUNGEON_ANGBAND].name);
741 msg_format("You haven't entered %s yet.", d_name + d_info[DUNGEON_ANGBAND].name);
748 /* Allocate the "dun" array */
749 C_MAKE(dun, max_d_idx, s16b);
752 for(i = 1; i < max_d_idx; i++)
757 if (!d_info[i].maxdepth) continue;
758 if (!max_dlv[i]) continue;
759 if (d_info[i].final_guardian)
761 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
763 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
766 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
768 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
770 prt(buf, y + num, x);
777 prt(" Áª¤Ù¤ë¥À¥ó¥¸¥ç¥ó¤¬¤Ê¤¤¡£", y, x);
779 prt(" No dungeon is available.", y, x);
784 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
786 prt(format("Which dungeon do you %s?: ", note), 0, 0);
791 if ((i == ESCAPE) || !num)
793 /* Free the "dun" array */
794 C_KILL(dun, max_d_idx, s16b);
799 if (i >= 'a' && i <('a'+num))
801 select_dungeon = dun[i-'a'];
808 /* Free the "dun" array */
809 C_KILL(dun, max_d_idx, s16b);
811 return select_dungeon;
816 * Recall the player to town or dungeon
818 bool recall_player(int turns)
821 * TODO: Recall the player to the last
822 * visited town when in the wilderness
826 if (p_ptr->inside_arena || ironman_downward)
829 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
831 msg_print("Nothing happens.");
837 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
840 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
842 if (get_check("Reset recall depth? "))
845 max_dlv[dungeon_type] = dun_level;
846 if (record_maxdeapth)
848 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
850 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
855 if (!p_ptr->word_recall)
861 select_dungeon = choose_dungeon("¤Ëµ¢´Ô", 2, 14);
863 select_dungeon = choose_dungeon("recall", 2, 14);
865 if (!select_dungeon) return FALSE;
866 p_ptr->recall_dungeon = select_dungeon;
868 p_ptr->word_recall = turns;
870 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
872 msg_print("The air about you becomes charged...");
875 p_ptr->redraw |= (PR_STATUS);
879 p_ptr->word_recall = 0;
881 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
883 msg_print("A tension leaves the air around you...");
886 p_ptr->redraw |= (PR_STATUS);
892 bool word_of_recall(void)
894 return(recall_player(randint0(21) + 15));
898 bool reset_recall(void)
900 int select_dungeon, dummy = 0;
905 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È", 2, 14);
907 select_dungeon = choose_dungeon("reset", 2, 14);
911 if (ironman_downward)
914 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
916 msg_print("Nothing happens.");
922 if (!select_dungeon) return FALSE;
925 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
927 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
932 sprintf(tmp_val, "%d", MAX(dun_level, 1));
934 /* Ask for a level */
935 if (get_string(ppp, tmp_val, 10))
937 /* Extract request */
938 dummy = atoi(tmp_val);
941 if (dummy < 1) dummy = 1;
944 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
945 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
947 max_dlv[select_dungeon] = dummy;
949 if (record_maxdeapth)
951 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
953 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
957 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
959 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
972 * Apply disenchantment to the player's stuff
974 * XXX XXX XXX This function is also called from the "melee" code
976 * Return "TRUE" if the player notices anything
978 bool apply_disenchant(int mode)
982 char o_name[MAX_NLEN];
983 int to_h, to_d, to_a, pval;
985 /* Pick a random slot */
988 case 1: t = INVEN_RARM; break;
989 case 2: t = INVEN_LARM; break;
990 case 3: t = INVEN_BOW; break;
991 case 4: t = INVEN_BODY; break;
992 case 5: t = INVEN_OUTER; break;
993 case 6: t = INVEN_HEAD; break;
994 case 7: t = INVEN_HANDS; break;
995 case 8: t = INVEN_FEET; break;
999 o_ptr = &inventory[t];
1001 /* No item, nothing happens */
1002 if (!o_ptr->k_idx) return (FALSE);
1005 /* Nothing to disenchant */
1006 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1008 /* Nothing to notice */
1013 /* Describe the object */
1014 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1017 /* Artifacts have 71% chance to resist */
1018 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 71))
1022 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
1024 msg_format("Your %s (%c) resist%s disenchantment!",
1025 o_name, index_to_label(t),
1026 ((o_ptr->number != 1) ? "" : "s"));
1035 /* Memorize old value */
1041 /* Disenchant tohit */
1042 if (o_ptr->to_h > 0) o_ptr->to_h--;
1043 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1045 /* Disenchant todam */
1046 if (o_ptr->to_d > 0) o_ptr->to_d--;
1047 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1049 /* Disenchant toac */
1050 if (o_ptr->to_a > 0) o_ptr->to_a--;
1051 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1053 /* Disenchant pval (occasionally) */
1054 /* Unless called from wild_magic() */
1055 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1057 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1058 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1062 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
1063 o_name, index_to_label(t) );
1065 msg_format("Your %s (%c) %s disenchanted!",
1066 o_name, index_to_label(t),
1067 ((o_ptr->number != 1) ? "were" : "was"));
1070 chg_virtue(V_HARMONY, 1);
1071 chg_virtue(V_ENCHANT, -2);
1073 /* Recalculate bonuses */
1074 p_ptr->update |= (PU_BONUS);
1077 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1087 void mutate_player(void)
1089 int max1, cur1, max2, cur2, ii, jj, i;
1091 /* Pick a pair of stats */
1093 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1095 max1 = p_ptr->stat_max[ii];
1096 cur1 = p_ptr->stat_cur[ii];
1097 max2 = p_ptr->stat_max[jj];
1098 cur2 = p_ptr->stat_cur[jj];
1100 p_ptr->stat_max[ii] = max2;
1101 p_ptr->stat_cur[ii] = cur2;
1102 p_ptr->stat_max[jj] = max1;
1103 p_ptr->stat_cur[jj] = cur1;
1107 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1108 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1111 p_ptr->update |= (PU_BONUS);
1118 void apply_nexus(monster_type *m_ptr)
1120 switch (randint1(7))
1122 case 1: case 2: case 3:
1124 teleport_player(200);
1130 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE);
1136 if (randint0(100) < p_ptr->skill_sav)
1139 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1141 msg_print("You resist the effects!");
1147 /* Teleport Level */
1154 if (randint0(100) < p_ptr->skill_sav)
1157 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1159 msg_print("You resist the effects!");
1166 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1168 msg_print("Your body starts to scramble...");
1179 * Charge a lite (torch or latern)
1181 void phlogiston(void)
1184 object_type * o_ptr = &inventory[INVEN_LITE];
1187 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1189 max_flog = FUEL_LAMP;
1193 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1195 max_flog = FUEL_TORCH;
1198 /* No torch to refill */
1202 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1204 msg_print("You are not wielding anything which uses phlogiston.");
1210 if (o_ptr->xtra4 >= max_flog)
1213 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1215 msg_print("No more phlogiston can be put in this item.");
1222 o_ptr->xtra4 += (max_flog / 2);
1226 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1228 msg_print("You add phlogiston to your light item.");
1233 if (o_ptr->xtra4 >= max_flog)
1235 o_ptr->xtra4 = max_flog;
1237 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1239 msg_print("Your light item is full.");
1244 /* Recalculate torch */
1245 p_ptr->update |= (PU_TORCH);
1249 static bool item_tester_hook_weapon_nobow(object_type *o_ptr)
1251 switch (o_ptr->tval)
1261 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
1269 * Brand the current weapon
1271 void brand_weapon(int brand_type)
1278 /* Assume enchant weapon */
1279 item_tester_hook = item_tester_hook_weapon_nobow;
1280 item_tester_no_ryoute = TRUE;
1284 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1285 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1287 q = "Enchant which weapon? ";
1288 s = "You have nothing to enchant.";
1291 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1293 /* Get the item (in the pack) */
1296 o_ptr = &inventory[item];
1299 /* Get the item (on the floor) */
1302 o_ptr = &o_list[0 - item];
1306 /* you can never modify artifacts / ego-items */
1307 /* you can never modify cursed items */
1308 /* TY: You _can_ modify broken items (if you're silly enough) */
1309 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
1310 !o_ptr->art_name && !cursed_p(o_ptr) &&
1311 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1312 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1313 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1317 /* Let's get the name before it is changed... */
1318 char o_name[MAX_NLEN];
1319 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1324 if (o_ptr->tval == TV_SWORD)
1327 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1329 act = "becomes very sharp!";
1332 o_ptr->name2 = EGO_SHARPNESS;
1333 o_ptr->pval = m_bonus(5, dun_level) + 1;
1338 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1340 act = "seems very powerful.";
1343 o_ptr->name2 = EGO_EARTHQUAKES;
1344 o_ptr->pval = m_bonus(3, dun_level);
1349 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1351 act = "seems to be looking for humans!";
1354 o_ptr->name2 = EGO_SLAY_HUMAN;
1358 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1360 act = "covered with lightning!";
1363 o_ptr->name2 = EGO_BRAND_ELEC;
1367 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1369 act = "coated with acid!";
1372 o_ptr->name2 = EGO_BRAND_ACID;
1376 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1378 act = "seems to be looking for evil monsters!";
1381 o_ptr->name2 = EGO_SLAY_EVIL;
1385 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1387 act = "seems to be looking for demons!";
1390 o_ptr->name2 = EGO_SLAY_DEMON;
1394 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1396 act = "seems to be looking for undead!";
1399 o_ptr->name2 = EGO_SLAY_UNDEAD;
1403 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1405 act = "seems to be looking for animals!";
1408 o_ptr->name2 = EGO_SLAY_ANIMAL;
1412 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1414 act = "seems to be looking for dragons!";
1417 o_ptr->name2 = EGO_SLAY_DRAGON;
1421 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1423 act = "seems to be looking for troll!s";
1426 o_ptr->name2 = EGO_SLAY_TROLL;
1430 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1432 act = "seems to be looking for orcs!";
1435 o_ptr->name2 = EGO_SLAY_ORC;
1439 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1441 act = "seems to be looking for giants!";
1444 o_ptr->name2 = EGO_SLAY_GIANT;
1448 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1450 act = "seems very unstable now.";
1453 o_ptr->name2 = EGO_TRUMP;
1454 o_ptr->pval = randint1(2);
1458 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1460 act = "thirsts for blood!";
1463 o_ptr->name2 = EGO_VAMPIRIC;
1467 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1469 act = "is coated with poison.";
1472 o_ptr->name2 = EGO_BRAND_POIS;
1476 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1478 act = "is engulfed in raw Logrus!";
1481 o_ptr->name2 = EGO_CHAOTIC;
1485 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1487 act = "is covered in a fiery shield!";
1490 o_ptr->name2 = EGO_BRAND_FIRE;
1494 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1496 act = "glows deep, icy blue!";
1499 o_ptr->name2 = EGO_BRAND_COLD;
1504 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1506 msg_format("Your %s %s", o_name, act);
1510 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1512 o_ptr->discount = 99;
1513 chg_virtue(V_ENCHANT, 2);
1517 if (flush_failure) flush();
1520 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1522 msg_print("The Branding failed.");
1525 chg_virtue(V_ENCHANT, -2);
1532 * Determine if a "feature" is a "vanishable"
1533 * Non-permanent walls, trees, mountains, or doors
1535 #define vanishable_feat(F) \
1536 (have_flag((F)->flags, FF_HURT_DISI) || \
1537 have_flag((F)->flags, FF_PATTERN))
1540 * Vanish all walls in this floor
1542 static bool vanish_dungeon(void)
1546 feature_type *f_ptr;
1547 monster_type *m_ptr;
1550 /* Prevent vasishing of quest levels and town */
1551 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1556 /* Scan all normal grids */
1557 for (y = 1; y < cur_hgt - 1; y++)
1559 for (x = 1; x < cur_wid - 1; x++)
1561 c_ptr = &cave[y][x];
1563 /* Seeing true feature code (ignore mimic) */
1564 f_ptr = &f_info[c_ptr->feat];
1566 /* Lose room and vault */
1567 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1569 m_ptr = &m_list[c_ptr->m_idx];
1572 if (c_ptr->m_idx && m_ptr->csleep)
1574 /* Reset sleep counter */
1577 /* Notice the "waking up" */
1580 /* Acquire the monster name */
1581 monster_desc(m_name, m_ptr, 0);
1583 /* Dump a message */
1585 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1587 msg_format("%^s wakes up.", m_name);
1590 /* Redraw the health bar */
1591 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
1592 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
1596 /* Process all walls, doors and patterns */
1597 if (vanishable_feat(f_ptr)) cave_alter_feat(y, x, FF_HURT_DISI);
1601 /* Special boundary walls -- Top and bottom */
1602 for (x = 0; x < cur_wid; x++)
1604 c_ptr = &cave[0][x];
1605 f_ptr = &f_info[c_ptr->mimic];
1607 /* Lose room and vault */
1608 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1610 /* Set boundary mimic if needed */
1611 if (c_ptr->mimic && vanishable_feat(f_ptr))
1613 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1615 /* Check for change to boring grid */
1616 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1619 c_ptr = &cave[cur_hgt - 1][x];
1620 f_ptr = &f_info[c_ptr->mimic];
1622 /* Lose room and vault */
1623 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1625 /* Set boundary mimic if needed */
1626 if (c_ptr->mimic && vanishable_feat(f_ptr))
1628 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1630 /* Check for change to boring grid */
1631 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1635 /* Special boundary walls -- Left and right */
1636 for (y = 1; y < (cur_hgt - 1); y++)
1638 c_ptr = &cave[y][0];
1639 f_ptr = &f_info[c_ptr->mimic];
1641 /* Lose room and vault */
1642 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1644 /* Set boundary mimic if needed */
1645 if (c_ptr->mimic && vanishable_feat(f_ptr))
1647 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1649 /* Check for change to boring grid */
1650 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1653 c_ptr = &cave[y][cur_wid - 1];
1654 f_ptr = &f_info[c_ptr->mimic];
1656 /* Lose room and vault */
1657 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1659 /* Set boundary mimic if needed */
1660 if (c_ptr->mimic && vanishable_feat(f_ptr))
1662 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1664 /* Check for change to boring grid */
1665 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1669 /* Mega-Hack -- Forget the view and lite */
1670 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1673 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1675 /* Update the monsters */
1676 p_ptr->update |= (PU_MONSTERS);
1679 p_ptr->redraw |= (PR_MAP);
1682 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1688 void call_the_(void)
1692 bool do_call = TRUE;
1694 for (i = 0; i < 9; i++)
1696 y = py + ddy_ddd[i];
1697 x = px + ddx_ddd[i];
1699 if (!cave_floor_bold(y, x) && !boundary_floor_bold(y, x))
1708 for (i = 1; i < 10; i++)
1710 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1713 for (i = 1; i < 10; i++)
1715 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1718 for (i = 1; i < 10; i++)
1720 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1724 /* Prevent destruction of quest levels and town */
1725 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1728 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1730 msg_print("The ground trembles.");
1737 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1738 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1739 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1741 msg_format("You %s the %s too close to a wall!",
1742 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1743 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1744 msg_print("There is a loud explosion!");
1750 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1752 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1757 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1759 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1761 msg_print("The dungeon collapses...");
1766 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1768 msg_print("The dungeon trembles.");
1773 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1775 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1782 * Fetch an item (teleport it right underneath the caster)
1784 void fetch(int dir, int wgt, bool require_los)
1789 char o_name[MAX_NLEN];
1791 /* Check to see if an object is already there */
1792 if (cave[py][px].o_idx)
1795 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1797 msg_print("You can't fetch when you're already standing on something.");
1804 if (dir == 5 && target_okay())
1809 if (distance(py, px, ty, tx) > MAX_RANGE)
1812 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1814 msg_print("You can't fetch something that far away!");
1820 c_ptr = &cave[ty][tx];
1822 /* We need an item to fetch */
1826 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1828 msg_print("There is no object at this place.");
1834 /* No fetching from vault */
1835 if (c_ptr->info & CAVE_ICKY)
1838 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1840 msg_print("The item slips from your control.");
1846 /* We need to see the item */
1847 if (require_los && !player_has_los_bold(ty, tx))
1850 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1852 msg_print("You have no direct line of sight to that location.");
1860 /* Use a direction */
1861 ty = py; /* Where to drop the item */
1868 c_ptr = &cave[ty][tx];
1870 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1871 !cave_floor_bold(ty, tx)) return;
1873 while (!c_ptr->o_idx);
1876 o_ptr = &o_list[c_ptr->o_idx];
1878 if (o_ptr->weight > wgt)
1880 /* Too heavy to 'fetch' */
1882 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1884 msg_print("The object is too heavy.");
1891 c_ptr->o_idx = o_ptr->next_o_idx;
1892 cave[py][px].o_idx = i; /* 'move' it */
1893 o_ptr->next_o_idx = 0;
1894 o_ptr->iy = (byte)py;
1895 o_ptr->ix = (byte)px;
1897 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1899 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1901 msg_format("%^s flies through the air to your feet.", o_name);
1906 p_ptr->redraw |= PR_MAP;
1910 void alter_reality(void)
1912 /* Ironman option */
1913 if (p_ptr->inside_arena || ironman_downward)
1916 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1918 msg_print("Nothing happens.");
1923 if (!p_ptr->alter_reality)
1925 int turns = randint0(21) + 15;
1927 p_ptr->alter_reality = turns;
1929 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1931 msg_print("The view around you begins to change...");
1934 p_ptr->redraw |= (PR_STATUS);
1938 p_ptr->alter_reality = 0;
1940 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1942 msg_print("The view around you got back...");
1945 p_ptr->redraw |= (PR_STATUS);
1952 * Leave a "glyph of warding" which prevents monster movement
1954 bool warding_glyph(void)
1957 if (!cave_clean_bold(py, px))
1960 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1962 msg_print("The object resists the spell.");
1968 /* Create a glyph */
1969 cave[py][px].info |= CAVE_OBJECT;
1970 cave[py][px].mimic = FEAT_GLYPH;
1981 bool warding_mirror(void)
1984 if (!cave_clean_bold(py, px))
1987 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1989 msg_print("The object resists the spell.");
1995 /* Create a mirror */
1996 cave[py][px].info |= CAVE_OBJECT;
1997 cave[py][px].mimic = FEAT_MIRROR;
1999 /* Turn on the light */
2000 cave[py][px].info |= CAVE_GLOW;
2013 * Leave an "explosive rune" which prevents monster movement
2015 bool explosive_rune(void)
2018 if (!cave_clean_bold(py, px))
2021 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
2023 msg_print("The object resists the spell.");
2029 /* Create a glyph */
2030 cave[py][px].info |= CAVE_OBJECT;
2031 cave[py][px].mimic = FEAT_MINOR_GLYPH;
2044 * Identify everything being carried.
2045 * Done by a potion of "self knowledge".
2047 void identify_pack(void)
2051 /* Simply identify and know every item */
2052 for (i = 0; i < INVEN_TOTAL; i++)
2054 object_type *o_ptr = &inventory[i];
2056 /* Skip non-objects */
2057 if (!o_ptr->k_idx) continue;
2060 identify_item(o_ptr);
2062 /* Auto-inscription */
2063 autopick_alter_item(i, FALSE);
2069 * Used by the "enchant" function (chance of failure)
2070 * (modified for Zangband, we need better stuff there...) -- TY
2072 static int enchant_table[16] =
2074 0, 10, 50, 100, 200,
2075 300, 400, 500, 650, 800,
2076 950, 987, 993, 995, 998,
2082 * Removes curses from items in inventory
2084 * Note that Items which are "Perma-Cursed" (The One Ring,
2085 * The Crown of Morgoth) can NEVER be uncursed.
2087 * Note that if "all" is FALSE, then Items which are
2088 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2089 * will not be uncursed.
2091 static int remove_curse_aux(int all)
2095 /* Attempt to uncurse items being worn */
2096 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2098 object_type *o_ptr = &inventory[i];
2100 /* Skip non-objects */
2101 if (!o_ptr->k_idx) continue;
2103 /* Uncursed already */
2104 if (!cursed_p(o_ptr)) continue;
2106 /* Heavily Cursed Items need a special spell */
2107 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2109 /* Perma-Cursed Items can NEVER be uncursed */
2110 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2113 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2118 o_ptr->curse_flags = 0L;
2120 /* Hack -- Assume felt */
2121 o_ptr->ident |= (IDENT_SENSE);
2124 o_ptr->feeling = FEEL_NONE;
2126 /* Recalculate the bonuses */
2127 p_ptr->update |= (PU_BONUS);
2130 p_ptr->window |= (PW_EQUIP);
2132 /* Count the uncursings */
2136 /* Return "something uncursed" */
2142 * Remove most curses
2144 bool remove_curse(void)
2146 return (remove_curse_aux(FALSE));
2152 bool remove_all_curse(void)
2154 return (remove_curse_aux(TRUE));
2159 * Turns an object into gold, gain some of its value in a shop
2168 char o_name[MAX_NLEN];
2169 char out_val[MAX_NLEN+40];
2173 /* Hack -- force destruction */
2174 if (command_arg > 0) force = TRUE;
2178 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2179 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2181 q = "Turn which item to gold? ";
2182 s = "You have nothing to turn to gold.";
2185 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2187 /* Get the item (in the pack) */
2190 o_ptr = &inventory[item];
2193 /* Get the item (on the floor) */
2196 o_ptr = &o_list[0 - item];
2200 /* See how many items */
2201 if (o_ptr->number > 1)
2203 /* Get a quantity */
2204 amt = get_quantity(NULL, o_ptr->number);
2206 /* Allow user abort */
2207 if (amt <= 0) return FALSE;
2211 /* Describe the object */
2212 old_number = o_ptr->number;
2213 o_ptr->number = amt;
2214 object_desc(o_name, o_ptr, 0);
2215 o_ptr->number = old_number;
2217 /* Verify unless quantity given */
2220 if (confirm_destroy || (object_value(o_ptr) > 0))
2222 /* Make a verification */
2224 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2226 sprintf(out_val, "Really turn %s to gold? ", o_name);
2229 if (!get_check(out_val)) return FALSE;
2233 /* Artifacts cannot be destroyed */
2234 if (!can_player_destroy_object(o_ptr))
2238 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2240 msg_format("You fail to turn %s to gold!", o_name);
2247 price = object_value_real(o_ptr);
2253 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2255 msg_format("You turn %s to fool's gold.", o_name);
2263 if (amt > 1) price *= amt;
2265 if (price > 30000) price = 30000;
2267 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2269 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2275 p_ptr->redraw |= (PR_GOLD);
2278 p_ptr->window |= (PW_PLAYER);
2282 /* Eliminate the item (from the pack) */
2285 inven_item_increase(item, -amt);
2286 inven_item_describe(item);
2287 inven_item_optimize(item);
2290 /* Eliminate the item (from the floor) */
2293 floor_item_increase(0 - item, -amt);
2294 floor_item_describe(0 - item);
2295 floor_item_optimize(0 - item);
2304 * Hook to specify "weapon"
2306 bool item_tester_hook_weapon(object_type *o_ptr)
2308 switch (o_ptr->tval)
2322 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2329 static bool item_tester_hook_weapon2(object_type *o_ptr)
2331 switch (o_ptr->tval)
2351 * Hook to specify "armour"
2353 bool item_tester_hook_armour(object_type *o_ptr)
2355 switch (o_ptr->tval)
2376 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2378 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2380 switch (o_ptr->tval)
2409 * Check if an object is nameless weapon or armour
2411 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2413 switch (o_ptr->tval)
2432 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2434 if (object_known_p(o_ptr)) return FALSE;
2444 * Break the curse of an item
2446 static void break_curse(object_type *o_ptr)
2448 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2451 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2453 msg_print("The curse is broken!");
2456 o_ptr->curse_flags = 0L;
2458 o_ptr->ident |= (IDENT_SENSE);
2460 o_ptr->feeling = FEEL_NONE;
2466 * Enchants a plus onto an item. -RAK-
2468 * Revamped! Now takes item pointer, number of times to try enchanting,
2469 * and a flag of what to try enchanting. Artifacts resist enchantment
2470 * some of the time, and successful enchantment to at least +0 might
2471 * break a curse on the item. -CFT-
2473 * Note that an item can technically be enchanted all the way to +15 if
2474 * you wait a very, very, long time. Going from +9 to +10 only works
2475 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2477 * Note that this function can now be used on "piles" of items, and
2478 * the larger the pile, the lower the chance of success.
2480 bool enchant(object_type *o_ptr, int n, int eflag)
2482 int i, chance, prob;
2484 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2485 bool force = (eflag & ENCH_FORCE);
2488 /* Large piles resist enchantment */
2489 prob = o_ptr->number * 100;
2491 /* Missiles are easy to enchant */
2492 if ((o_ptr->tval == TV_BOLT) ||
2493 (o_ptr->tval == TV_ARROW) ||
2494 (o_ptr->tval == TV_SHOT))
2500 for (i = 0; i < n; i++)
2502 /* Hack -- Roll for pile resistance */
2503 if (!force && randint0(prob) >= 100) continue;
2505 /* Enchant to hit */
2506 if (eflag & ENCH_TOHIT)
2508 if (o_ptr->to_h < 0) chance = 0;
2509 else if (o_ptr->to_h > 15) chance = 1000;
2510 else chance = enchant_table[o_ptr->to_h];
2512 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2517 /* only when you get it above -1 -CFT */
2518 if (o_ptr->to_h >= 0)
2523 /* Enchant to damage */
2524 if (eflag & ENCH_TODAM)
2526 if (o_ptr->to_d < 0) chance = 0;
2527 else if (o_ptr->to_d > 15) chance = 1000;
2528 else chance = enchant_table[o_ptr->to_d];
2530 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2535 /* only when you get it above -1 -CFT */
2536 if (o_ptr->to_d >= 0)
2541 /* Enchant to armor class */
2542 if (eflag & ENCH_TOAC)
2544 if (o_ptr->to_a < 0) chance = 0;
2545 else if (o_ptr->to_a > 15) chance = 1000;
2546 else chance = enchant_table[o_ptr->to_a];
2548 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2553 /* only when you get it above -1 -CFT */
2554 if (o_ptr->to_a >= 0)
2561 if (!res) return (FALSE);
2563 /* Recalculate bonuses */
2564 p_ptr->update |= (PU_BONUS);
2566 /* Combine / Reorder the pack (later) */
2567 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2570 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2581 * Enchant an item (in the inventory or on the floor)
2582 * Note that "num_ac" requires armour, else weapon
2583 * Returns TRUE if attempted, FALSE if cancelled
2585 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2590 char o_name[MAX_NLEN];
2594 /* Assume enchant weapon */
2595 item_tester_hook = item_tester_hook_weapon;
2596 item_tester_no_ryoute = TRUE;
2598 /* Enchant armor if requested */
2599 if (num_ac) item_tester_hook = item_tester_hook_armour;
2603 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2604 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2606 q = "Enchant which item? ";
2607 s = "You have nothing to enchant.";
2610 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2612 /* Get the item (in the pack) */
2615 o_ptr = &inventory[item];
2618 /* Get the item (on the floor) */
2621 o_ptr = &o_list[0 - item];
2626 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2630 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2633 msg_format("%s %s glow%s brightly!",
2634 ((item >= 0) ? "Your" : "The"), o_name,
2635 ((o_ptr->number > 1) ? "" : "s"));
2640 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2641 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2642 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2648 if (flush_failure) flush();
2652 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2654 msg_print("The enchantment failed.");
2657 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2660 chg_virtue(V_ENCHANT, 1);
2664 /* Something happened */
2669 bool artifact_scroll(void)
2674 char o_name[MAX_NLEN];
2678 item_tester_no_ryoute = TRUE;
2679 /* Enchant weapon/armour */
2680 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2684 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2685 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2687 q = "Enchant which item? ";
2688 s = "You have nothing to enchant.";
2691 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2693 /* Get the item (in the pack) */
2696 o_ptr = &inventory[item];
2699 /* Get the item (on the floor) */
2702 o_ptr = &o_list[0 - item];
2707 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2711 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2713 msg_format("%s %s radiate%s a blinding light!",
2714 ((item >= 0) ? "Your" : "The"), o_name,
2715 ((o_ptr->number > 1) ? "" : "s"));
2718 if (o_ptr->name1 || o_ptr->art_name)
2721 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2723 msg_format("The %s %s already %s!",
2724 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2725 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2731 else if (o_ptr->name2)
2734 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2736 msg_format("The %s %s already %s!",
2737 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2738 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2744 else if (o_ptr->xtra3)
2747 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2749 msg_format("The %s %s already %s!",
2750 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2751 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2757 if (o_ptr->number > 1)
2760 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2761 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2763 msg_print("Not enough enough energy to enchant more than one object!");
2764 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2769 inven_item_increase(item, 1-(o_ptr->number));
2773 floor_item_increase(0-item, 1-(o_ptr->number));
2776 okay = create_artifact(o_ptr, TRUE);
2783 if (flush_failure) flush();
2787 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2789 msg_print("The enchantment failed.");
2792 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2795 chg_virtue(V_ENCHANT, 1);
2799 /* Something happened */
2805 * Identify an object
2807 bool identify_item(object_type *o_ptr)
2809 bool old_known = FALSE;
2810 char o_name[MAX_NLEN];
2813 object_desc(o_name, o_ptr, 0);
2815 if (o_ptr->ident & IDENT_KNOWN)
2818 if (!(o_ptr->ident & (IDENT_MENTAL)))
2820 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2821 chg_virtue(V_KNOWLEDGE, 1);
2824 /* Identify it fully */
2825 object_aware(o_ptr);
2826 object_known(o_ptr);
2828 /* Recalculate bonuses */
2829 p_ptr->update |= (PU_BONUS);
2831 /* Combine / Reorder the pack (later) */
2832 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2835 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2837 strcpy(record_o_name, o_name);
2841 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2843 if(record_fix_art && !old_known && artifact_p(o_ptr))
2844 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2845 if(record_rand_art && !old_known && o_ptr->art_name)
2846 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2852 static bool item_tester_hook_identify(object_type *o_ptr)
2854 return (bool)!object_known_p(o_ptr);
2857 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2859 if (object_known_p(o_ptr))
2861 return item_tester_hook_weapon_armour(o_ptr);
2865 * Identify an object in the inventory (or on the floor)
2866 * This routine does *not* automatically combine objects.
2867 * Returns TRUE if something was identified, else FALSE.
2869 bool ident_spell(bool only_equip)
2873 char o_name[MAX_NLEN];
2877 item_tester_no_ryoute = TRUE;
2880 item_tester_hook = item_tester_hook_identify_weapon_armour;
2882 item_tester_hook = item_tester_hook_identify;
2884 if (!can_get_item())
2888 item_tester_hook = item_tester_hook_weapon_armour;
2892 item_tester_hook = NULL;
2898 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2899 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2901 q = "Identify which item? ";
2902 s = "You have nothing to identify.";
2905 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2907 /* Get the item (in the pack) */
2910 o_ptr = &inventory[item];
2913 /* Get the item (on the floor) */
2916 o_ptr = &o_list[0 - item];
2920 old_known = identify_item(o_ptr);
2923 object_desc(o_name, o_ptr, 0);
2926 if (item >= INVEN_RARM)
2929 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2931 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2937 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2939 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2945 msg_format("¾²¾å: %s¡£", o_name);
2947 msg_format("On the ground: %s.", o_name);
2951 /* Auto-inscription/destroy */
2952 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2954 /* Something happened */
2960 * Mundanify an object in the inventory (or on the floor)
2961 * This routine does *not* automatically combine objects.
2962 * Returns TRUE if something was mundanified, else FALSE.
2964 bool mundane_spell(bool only_equip)
2970 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
2971 item_tester_no_ryoute = TRUE;
2975 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2976 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2978 q = "Use which item? ";
2979 s = "You have nothing you can use.";
2982 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2984 /* Get the item (in the pack) */
2987 o_ptr = &inventory[item];
2990 /* Get the item (on the floor) */
2993 o_ptr = &o_list[0 - item];
2998 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
3000 msg_print("There is a bright flash of light!");
3003 byte iy = o_ptr->iy; /* Y-position on map, or zero */
3004 byte ix = o_ptr->ix; /* X-position on map, or zero */
3005 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
3006 byte marked = o_ptr->marked; /* Object is marked */
3007 s16b weight = o_ptr->number * o_ptr->weight;
3008 u16b inscription = o_ptr->inscription;
3011 object_prep(o_ptr, o_ptr->k_idx);
3015 o_ptr->next_o_idx = next_o_idx;
3016 o_ptr->marked = marked;
3017 o_ptr->inscription = inscription;
3018 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
3022 /* Something happened */
3028 static bool item_tester_hook_identify_fully(object_type *o_ptr)
3030 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
3033 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
3035 if (!item_tester_hook_identify_fully(o_ptr))
3037 return item_tester_hook_weapon_armour(o_ptr);
3041 * Fully "identify" an object in the inventory -BEN-
3042 * This routine returns TRUE if an item was identified.
3044 bool identify_fully(bool only_equip)
3048 char o_name[MAX_NLEN];
3052 item_tester_no_ryoute = TRUE;
3054 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
3056 item_tester_hook = item_tester_hook_identify_fully;
3058 if (!can_get_item())
3061 item_tester_hook = item_tester_hook_weapon_armour;
3063 item_tester_hook = NULL;
3068 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
3069 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3071 q = "Identify which item? ";
3072 s = "You have nothing to identify.";
3075 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
3077 /* Get the item (in the pack) */
3080 o_ptr = &inventory[item];
3083 /* Get the item (on the floor) */
3086 o_ptr = &o_list[0 - item];
3090 old_known = identify_item(o_ptr);
3092 /* Mark the item as fully known */
3093 o_ptr->ident |= (IDENT_MENTAL);
3099 object_desc(o_name, o_ptr, 0);
3102 if (item >= INVEN_RARM)
3105 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
3107 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
3115 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
3117 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3123 msg_format("¾²¾å: %s¡£", o_name);
3125 msg_format("On the ground: %s.", o_name);
3129 /* Describe it fully */
3130 (void)screen_object(o_ptr, TRUE);
3132 /* Auto-inscription/destroy */
3133 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
3143 * Hook for "get_item()". Determine if something is rechargable.
3145 bool item_tester_hook_recharge(object_type *o_ptr)
3147 /* Recharge staffs */
3148 if (o_ptr->tval == TV_STAFF) return (TRUE);
3150 /* Recharge wands */
3151 if (o_ptr->tval == TV_WAND) return (TRUE);
3153 /* Hack -- Recharge rods */
3154 if (o_ptr->tval == TV_ROD) return (TRUE);
3162 * Recharge a wand/staff/rod from the pack or on the floor.
3163 * This function has been rewritten in Oangband and ZAngband.
3165 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3166 * Chaos -- Arcane Binding --> recharge(90)
3168 * Scroll of recharging --> recharge(130)
3169 * Artifact activation/Thingol --> recharge(130)
3171 * It is harder to recharge high level, and highly charged wands,
3172 * staffs, and rods. The more wands in a stack, the more easily and
3173 * strongly they recharge. Staffs, however, each get fewer charges if
3176 * XXX XXX XXX Beware of "sliding index errors".
3178 bool recharge(int power)
3181 int recharge_strength, recharge_amount;
3190 char o_name[MAX_NLEN];
3192 /* Only accept legal items */
3193 item_tester_hook = item_tester_hook_recharge;
3197 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3198 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3200 q = "Recharge which item? ";
3201 s = "You have nothing to recharge.";
3204 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3206 /* Get the item (in the pack) */
3209 o_ptr = &inventory[item];
3212 /* Get the item (on the floor) */
3215 o_ptr = &o_list[0 - item];
3218 /* Get the object kind. */
3219 k_ptr = &k_info[o_ptr->k_idx];
3221 /* Extract the object "level" */
3222 lev = get_object_level(o_ptr);
3225 /* Recharge a rod */
3226 if (o_ptr->tval == TV_ROD)
3228 /* Extract a recharge strength by comparing object level to power. */
3229 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3233 if (one_in_(recharge_strength))
3235 /* Activate the failure code. */
3242 /* Recharge amount */
3243 recharge_amount = (power * damroll(3, 2));
3245 /* Recharge by that amount */
3246 if (o_ptr->timeout > recharge_amount)
3247 o_ptr->timeout -= recharge_amount;
3254 /* Recharge wand/staff */
3257 /* Extract a recharge strength by comparing object level to power.
3258 * Divide up a stack of wands' charges to calculate charge penalty.
3260 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3261 recharge_strength = (100 + power - lev -
3262 (8 * o_ptr->pval / o_ptr->number)) / 15;
3264 /* All staffs, unstacked wands. */
3265 else recharge_strength = (100 + power - lev -
3266 (8 * o_ptr->pval)) / 15;
3269 if (recharge_strength < 0) recharge_strength = 0;
3272 if (one_in_(recharge_strength))
3274 /* Activate the failure code. */
3278 /* If the spell didn't backfire, recharge the wand or staff. */
3281 /* Recharge based on the standard number of charges. */
3282 recharge_amount = randint1(1 + k_ptr->pval / 2);
3284 /* Multiple wands in a stack increase recharging somewhat. */
3285 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3288 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3289 if (recharge_amount < 1) recharge_amount = 1;
3290 if (recharge_amount > 12) recharge_amount = 12;
3293 /* But each staff in a stack gets fewer additional charges,
3294 * although always at least one.
3296 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3298 recharge_amount /= o_ptr->number;
3299 if (recharge_amount < 1) recharge_amount = 1;
3302 /* Recharge the wand or staff. */
3303 o_ptr->pval += recharge_amount;
3306 /* Hack -- we no longer "know" the item */
3307 o_ptr->ident &= ~(IDENT_KNOWN);
3309 /* Hack -- we no longer think the item is empty */
3310 o_ptr->ident &= ~(IDENT_EMPTY);
3315 /* Inflict the penalties for failing a recharge. */
3318 /* Artifacts are never destroyed. */
3319 if (artifact_p(o_ptr))
3321 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3323 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3325 msg_format("The recharging backfires - %s is completely drained!", o_name);
3329 /* Artifact rods. */
3330 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3331 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3333 /* Artifact wands and staffs. */
3334 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3339 /* Get the object description */
3340 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3342 /*** Determine Seriousness of Failure ***/
3344 /* Mages recharge objects more safely. */
3345 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)
3347 /* 10% chance to blow up one rod, otherwise draining. */
3348 if (o_ptr->tval == TV_ROD)
3350 if (one_in_(10)) fail_type = 2;
3353 /* 75% chance to blow up one wand, otherwise draining. */
3354 else if (o_ptr->tval == TV_WAND)
3356 if (!one_in_(3)) fail_type = 2;
3359 /* 50% chance to blow up one staff, otherwise no effect. */
3360 else if (o_ptr->tval == TV_STAFF)
3362 if (one_in_(2)) fail_type = 2;
3367 /* All other classes get no special favors. */
3370 /* 33% chance to blow up one rod, otherwise draining. */
3371 if (o_ptr->tval == TV_ROD)
3373 if (one_in_(3)) fail_type = 2;
3376 /* 20% chance of the entire stack, else destroy one wand. */
3377 else if (o_ptr->tval == TV_WAND)
3379 if (one_in_(5)) fail_type = 3;
3382 /* Blow up one staff. */
3383 else if (o_ptr->tval == TV_STAFF)
3389 /*** Apply draining and destruction. ***/
3391 /* Drain object or stack of objects. */
3394 if (o_ptr->tval == TV_ROD)
3397 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3399 msg_print("The recharge backfires, draining the rod further!");
3402 if (o_ptr->timeout < 10000)
3403 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3405 else if (o_ptr->tval == TV_WAND)
3408 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3410 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3415 /* Staffs aren't drained. */
3418 /* Destroy an object or one in a stack of objects. */
3421 if (o_ptr->number > 1)
3423 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3425 msg_format("Wild magic consumes one of your %s!", o_name);
3430 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3432 msg_format("Wild magic consumes your %s!", o_name);
3436 /* Reduce rod stack maximum timeout, drain wands. */
3437 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3438 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3440 /* Reduce and describe inventory */
3443 inven_item_increase(item, -1);
3444 inven_item_describe(item);
3445 inven_item_optimize(item);
3448 /* Reduce and describe floor item */
3451 floor_item_increase(0 - item, -1);
3452 floor_item_describe(0 - item);
3453 floor_item_optimize(0 - item);
3457 /* Destroy all members of a stack of objects. */
3460 if (o_ptr->number > 1)
3462 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3464 msg_format("Wild magic consumes all your %s!", o_name);
3469 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3471 msg_format("Wild magic consumes your %s!", o_name);
3476 /* Reduce and describe inventory */
3479 inven_item_increase(item, -999);
3480 inven_item_describe(item);
3481 inven_item_optimize(item);
3484 /* Reduce and describe floor item */
3487 floor_item_increase(0 - item, -999);
3488 floor_item_describe(0 - item);
3489 floor_item_optimize(0 - item);
3495 /* Combine / Reorder the pack (later) */
3496 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3499 p_ptr->window |= (PW_INVEN);
3501 /* Something was done */
3509 bool bless_weapon(void)
3513 u32b flgs[TR_FLAG_SIZE];
3514 char o_name[MAX_NLEN];
3517 item_tester_no_ryoute = TRUE;
3518 /* Assume enchant weapon */
3519 item_tester_hook = item_tester_hook_weapon2;
3523 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3524 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3526 q = "Bless which weapon? ";
3527 s = "You have weapon to bless.";
3530 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3533 /* Get the item (in the pack) */
3536 o_ptr = &inventory[item];
3539 /* Get the item (on the floor) */
3542 o_ptr = &o_list[0 - item];
3547 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3549 /* Extract the flags */
3550 object_flags(o_ptr, flgs);
3552 if (cursed_p(o_ptr))
3554 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3555 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3558 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3561 msg_format("The black aura on %s %s disrupts the blessing!",
3562 ((item >= 0) ? "your" : "the"), o_name);
3569 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3572 msg_format("A malignant aura leaves %s %s.",
3573 ((item >= 0) ? "your" : "the"), o_name);
3578 o_ptr->curse_flags = 0L;
3580 /* Hack -- Assume felt */
3581 o_ptr->ident |= (IDENT_SENSE);
3584 o_ptr->feeling = FEEL_NONE;
3586 /* Recalculate the bonuses */
3587 p_ptr->update |= (PU_BONUS);
3590 p_ptr->window |= (PW_EQUIP);
3594 * Next, we try to bless it. Artifacts have a 1/3 chance of
3595 * being blessed, otherwise, the operation simply disenchants
3596 * them, godly power negating the magic. Ok, the explanation
3597 * is silly, but otherwise priests would always bless every
3598 * artifact weapon they find. Ego weapons and normal weapons
3599 * can be blessed automatically.
3601 if (have_flag(flgs, TR_BLESSED))
3604 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3607 msg_format("%s %s %s blessed already.",
3608 ((item >= 0) ? "Your" : "The"), o_name,
3609 ((o_ptr->number > 1) ? "were" : "was"));
3615 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3619 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3622 msg_format("%s %s shine%s!",
3623 ((item >= 0) ? "Your" : "The"), o_name,
3624 ((o_ptr->number > 1) ? "" : "s"));
3627 add_flag(o_ptr->art_flags, TR_BLESSED);
3628 o_ptr->discount = 99;
3632 bool dis_happened = FALSE;
3635 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3637 msg_print("The weapon resists your blessing!");
3641 /* Disenchant tohit */
3642 if (o_ptr->to_h > 0)
3645 dis_happened = TRUE;
3648 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3650 /* Disenchant todam */
3651 if (o_ptr->to_d > 0)
3654 dis_happened = TRUE;
3657 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3659 /* Disenchant toac */
3660 if (o_ptr->to_a > 0)
3663 dis_happened = TRUE;
3666 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3671 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3673 msg_print("There is a static feeling in the air...");
3677 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3680 msg_format("%s %s %s disenchanted!",
3681 ((item >= 0) ? "Your" : "The"), o_name,
3682 ((o_ptr->number > 1) ? "were" : "was"));
3688 /* Recalculate bonuses */
3689 p_ptr->update |= (PU_BONUS);
3692 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3703 bool pulish_shield(void)
3707 u32b flgs[TR_FLAG_SIZE];
3708 char o_name[MAX_NLEN];
3711 item_tester_no_ryoute = TRUE;
3712 /* Assume enchant weapon */
3713 item_tester_tval = TV_SHIELD;
3717 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3718 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3720 q = "Pulish which weapon? ";
3721 s = "You have weapon to pulish.";
3724 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3727 /* Get the item (in the pack) */
3730 o_ptr = &inventory[item];
3733 /* Get the item (on the floor) */
3736 o_ptr = &o_list[0 - item];
3741 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3743 /* Extract the flags */
3744 object_flags(o_ptr, flgs);
3746 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3747 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3750 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3752 msg_format("%s %s shine%s!",
3753 ((item >= 0) ? "Your" : "The"), o_name,
3754 ((o_ptr->number > 1) ? "" : "s"));
3756 o_ptr->name2 = EGO_REFLECTION;
3757 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3759 o_ptr->discount = 99;
3760 chg_virtue(V_ENCHANT, 2);
3766 if (flush_failure) flush();
3769 msg_print("¼ºÇÔ¤·¤¿¡£");
3771 msg_print("Failed.");
3774 chg_virtue(V_ENCHANT, -2);
3783 * Potions "smash open" and cause an area effect when
3784 * (1) they are shattered while in the player's inventory,
3785 * due to cold (etc) attacks;
3786 * (2) they are thrown at a monster, or obstacle;
3787 * (3) they are shattered by a "cold ball" or other such spell
3788 * while lying on the floor.
3791 * who --- who caused the potion to shatter (0=player)
3792 * potions that smash on the floor are assumed to
3793 * be caused by no-one (who = 1), as are those that
3794 * shatter inside the player inventory.
3795 * (Not anymore -- I changed this; TY)
3796 * y, x --- coordinates of the potion (or player if
3797 * the potion was in her inventory);
3798 * o_ptr --- pointer to the potion object.
3800 bool potion_smash_effect(int who, int y, int x, int k_idx)
3807 object_kind *k_ptr = &k_info[k_idx];
3809 switch (k_ptr->sval)
3811 case SV_POTION_SALT_WATER:
3812 case SV_POTION_SLIME_MOLD:
3813 case SV_POTION_LOSE_MEMORIES:
3814 case SV_POTION_DEC_STR:
3815 case SV_POTION_DEC_INT:
3816 case SV_POTION_DEC_WIS:
3817 case SV_POTION_DEC_DEX:
3818 case SV_POTION_DEC_CON:
3819 case SV_POTION_DEC_CHR:
3820 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3821 case SV_POTION_APPLE_JUICE:
3824 case SV_POTION_INFRAVISION:
3825 case SV_POTION_DETECT_INVIS:
3826 case SV_POTION_SLOW_POISON:
3827 case SV_POTION_CURE_POISON:
3828 case SV_POTION_BOLDNESS:
3829 case SV_POTION_RESIST_HEAT:
3830 case SV_POTION_RESIST_COLD:
3831 case SV_POTION_HEROISM:
3832 case SV_POTION_BESERK_STRENGTH:
3833 case SV_POTION_RES_STR:
3834 case SV_POTION_RES_INT:
3835 case SV_POTION_RES_WIS:
3836 case SV_POTION_RES_DEX:
3837 case SV_POTION_RES_CON:
3838 case SV_POTION_RES_CHR:
3839 case SV_POTION_INC_STR:
3840 case SV_POTION_INC_INT:
3841 case SV_POTION_INC_WIS:
3842 case SV_POTION_INC_DEX:
3843 case SV_POTION_INC_CON:
3844 case SV_POTION_INC_CHR:
3845 case SV_POTION_AUGMENTATION:
3846 case SV_POTION_ENLIGHTENMENT:
3847 case SV_POTION_STAR_ENLIGHTENMENT:
3848 case SV_POTION_SELF_KNOWLEDGE:
3849 case SV_POTION_EXPERIENCE:
3850 case SV_POTION_RESISTANCE:
3851 case SV_POTION_INVULNERABILITY:
3852 case SV_POTION_NEW_LIFE:
3853 /* All of the above potions have no effect when shattered */
3855 case SV_POTION_SLOWNESS:
3860 case SV_POTION_POISON:
3865 case SV_POTION_BLINDNESS:
3869 case SV_POTION_CONFUSION: /* Booze */
3873 case SV_POTION_SLEEP:
3877 case SV_POTION_RUINATION:
3878 case SV_POTION_DETONATIONS:
3880 dam = damroll(25, 25);
3883 case SV_POTION_DEATH:
3884 dt = GF_DEATH_RAY; /* !! */
3885 dam = k_ptr->level * 10;
3889 case SV_POTION_SPEED:
3892 case SV_POTION_CURE_LIGHT:
3894 dam = damroll(2, 3);
3896 case SV_POTION_CURE_SERIOUS:
3898 dam = damroll(4, 3);
3900 case SV_POTION_CURE_CRITICAL:
3901 case SV_POTION_CURING:
3903 dam = damroll(6, 3);
3905 case SV_POTION_HEALING:
3907 dam = damroll(10, 10);
3909 case SV_POTION_RESTORE_EXP:
3914 case SV_POTION_LIFE:
3916 dam = damroll(50, 50);
3919 case SV_POTION_STAR_HEALING:
3921 dam = damroll(50, 50);
3924 case SV_POTION_RESTORE_MANA: /* MANA */
3926 dam = damroll(10, 10);
3933 (void)project(who, radius, y, x, dam, dt,
3934 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3936 /* XXX those potions that explode need to become "known" */
3942 * Hack -- Display all known spells in a window
3944 * XXX XXX XXX Need to analyze size of the window.
3946 * XXX XXX XXX Need more color coding.
3948 void display_spell_list(void)
3961 /* They have too many spells to list */
3962 if (p_ptr->pclass == CLASS_SORCERER) return;
3963 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3965 /* mind.c type classes */
3966 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3967 (p_ptr->pclass == CLASS_BERSERKER) ||
3968 (p_ptr->pclass == CLASS_NINJA) ||
3969 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3970 (p_ptr->pclass == CLASS_FORCETRAINER))
3976 int plev = p_ptr->lev;
3982 bool use_hp = FALSE;
3984 /* Display a list of spells */
3987 put_str("̾Á°", y, x + 5);
3988 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3990 put_str("Name", y, x + 5);
3991 put_str("Lv Mana Fail Info", y, x + 35);
3994 switch(p_ptr->pclass)
3996 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3997 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3998 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3999 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
4000 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
4001 default: use_mind = 0;break;
4004 /* Dump the spells */
4005 for (i = 0; i < MAX_MIND_POWERS; i++)
4007 byte a = TERM_WHITE;
4009 /* Access the available spell */
4010 spell = mind_powers[use_mind].info[i];
4011 if (spell.min_lev > plev) break;
4013 /* Get the failure rate */
4014 chance = spell.fail;
4016 /* Reduce failure rate by "effective" level adjustment */
4017 chance -= 3 * (p_ptr->lev - spell.min_lev);
4019 /* Reduce failure rate by INT/WIS adjustment */
4020 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4024 /* Not enough mana to cast */
4025 if (spell.mana_cost > p_ptr->csp)
4027 chance += 5 * (spell.mana_cost - p_ptr->csp);
4033 /* Not enough hp to cast */
4034 if (spell.mana_cost > p_ptr->chp)
4041 /* Extract the minimum failure rate */
4042 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4044 /* Minimum failure rate */
4045 if (chance < minfail) chance = minfail;
4047 /* Stunning makes spells harder */
4048 if (p_ptr->stun > 50) chance += 25;
4049 else if (p_ptr->stun) chance += 15;
4051 /* Always a 5 percent chance of working */
4052 if (chance > 95) chance = 95;
4055 mindcraft_info(comment, use_mind, i);
4057 /* Dump the spell */
4058 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
4060 spell.min_lev, spell.mana_cost, chance, comment);
4062 Term_putstr(x, y + i + 1, -1, a, psi_desc);
4067 /* Cannot read spellbooks */
4068 if (REALM_NONE == p_ptr->realm1) return;
4070 /* Normal spellcaster with books */
4073 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
4077 /* Reset vertical */
4080 /* Vertical location */
4081 y = (j < 3) ? 0 : (m[j - 3] + 2);
4083 /* Horizontal location */
4087 for (i = 0; i < 32; i++)
4089 byte a = TERM_WHITE;
4091 /* Access the spell */
4092 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
4094 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
4098 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
4101 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
4104 if (s_ptr->slevel >= 99)
4108 strcpy(name, "(ȽÆÉÉÔǽ)");
4110 strcpy(name, "(illegible)");
4120 ((p_ptr->spell_forgotten1 & (1L << i))) :
4121 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4128 else if (!((j < 1) ?
4129 (p_ptr->spell_learned1 & (1L << i)) :
4130 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4137 else if (!((j < 1) ?
4138 (p_ptr->spell_worked1 & (1L << i)) :
4139 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4145 /* Dump the spell --(-- */
4146 sprintf(out_val, "%c/%c) %-20.20s",
4147 I2A(n / 8), I2A(n % 8), name);
4152 /* Dump onto the window */
4153 Term_putstr(x, m[j], -1, a, out_val);
4163 * Returns experience of a spell
4165 s16b experience_of_spell(int spell, int use_realm)
4167 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4168 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4169 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4170 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4176 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4178 int mod_need_mana(int need_mana, int spell, int realm)
4180 #define MANA_CONST 2400
4182 #define DEC_MANA_DIV 3
4185 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4188 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4189 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4191 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4192 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4193 need_mana /= MANA_CONST * MANA_DIV;
4194 if (need_mana < 1) need_mana = 1;
4197 /* Non-realm magic */
4200 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4212 * Modify spell fail rate
4213 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4215 int mod_spell_chance_1(int chance)
4217 chance += p_ptr->to_m_chance;
4219 if (p_ptr->heavy_spell) chance += 20;
4221 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4222 else if (p_ptr->easy_spell) chance -= 3;
4223 else if (p_ptr->dec_mana) chance -= 2;
4230 * Modify spell fail rate (as "suffix" process)
4231 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4232 * Note: variable "chance" cannot be negative.
4234 int mod_spell_chance_2(int chance)
4236 if (p_ptr->dec_mana) chance--;
4238 if (p_ptr->heavy_spell) chance += 5;
4240 return MAX(chance, 0);
4245 * Returns spell chance of failure for spell -RAK-
4247 s16b spell_chance(int spell, int use_realm)
4249 int chance, minfail;
4252 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4255 /* Paranoia -- must be literate */
4256 if (!mp_ptr->spell_book) return (100);
4258 if (use_realm == REALM_HISSATSU) return 0;
4260 /* Access the spell */
4261 if (!is_magic(use_realm))
4263 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4267 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4270 /* Extract the base spell failure rate */
4271 chance = s_ptr->sfail;
4273 /* Reduce failure rate by "effective" level adjustment */
4274 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4276 /* Reduce failure rate by INT/WIS adjustment */
4277 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4280 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4282 /* Extract mana consumption rate */
4283 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4285 /* Not enough mana to cast */
4286 if (need_mana > p_ptr->csp)
4288 chance += 5 * (need_mana - p_ptr->csp);
4291 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4293 /* Extract the minimum failure rate */
4294 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4297 * Non mage/priest characters never get too good
4298 * (added high mage, mindcrafter)
4300 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4302 if (minfail < 5) minfail = 5;
4305 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4306 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4307 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4309 chance = mod_spell_chance_1(chance);
4311 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4312 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4313 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4315 /* Minimum failure rate */
4316 if (chance < minfail) chance = minfail;
4318 /* Stunning makes spells harder */
4319 if (p_ptr->stun > 50) chance += 25;
4320 else if (p_ptr->stun) chance += 15;
4322 /* Always a 5 percent chance of working */
4323 if (chance > 95) chance = 95;
4325 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4326 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4328 s16b exp = experience_of_spell(spell, use_realm);
4329 if (exp >= SPELL_EXP_EXPERT) chance--;
4330 if (exp >= SPELL_EXP_MASTER) chance--;
4333 /* Return the chance */
4334 return mod_spell_chance_2(chance);
4340 * Determine if a spell is "okay" for the player to cast or study
4341 * The spell must be legible, not forgotten, and also, to cast,
4342 * it must be known, and to study, it must not be known.
4344 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4348 /* Access the spell */
4349 if (!is_magic(use_realm))
4351 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4355 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4358 /* Spell is illegal */
4359 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4361 /* Spell is forgotten */
4362 if ((use_realm == p_ptr->realm2) ?
4363 (p_ptr->spell_forgotten2 & (1L << spell)) :
4364 (p_ptr->spell_forgotten1 & (1L << spell)))
4370 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4371 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4373 /* Spell is learned */
4374 if ((use_realm == p_ptr->realm2) ?
4375 (p_ptr->spell_learned2 & (1L << spell)) :
4376 (p_ptr->spell_learned1 & (1L << spell)))
4379 return (!study_pray);
4382 /* Okay to study, not to cast */
4389 * Extra information on a spell -DRS-
4391 * We can use up to 14 characters of the buffer 'p'
4393 * The strings in this function were extracted from the code in the
4394 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4396 static void spell_info(char *p, int spell, int use_realm)
4398 int plev = p_ptr->lev;
4401 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4402 p_ptr->pclass == CLASS_HIGH_MAGE ||
4403 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4405 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4406 p_ptr->pclass == CLASS_HIGH_MAGE ||
4407 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4409 cptr s_dam = "»½ý:";
4410 cptr s_dur = "´ü´Ö:";
4411 cptr s_range = "ÈÏ°Ï:";
4412 cptr s_heal = "²óÉü:";
4413 cptr s_random = "¥é¥ó¥À¥à";
4414 cptr s_delay = "ÃÙ±ä:";
4416 cptr s_dam = "dam ";
4417 cptr s_dur = "dur ";
4418 cptr s_range = "range ";
4419 cptr s_heal = "heal ";
4420 cptr s_random = "random";
4421 cptr s_delay = "delay ";
4426 /* Analyze the spell */
4429 case REALM_LIFE: /* Life */
4432 case 0: sprintf(p, " %s2d10", s_heal); break;
4433 case 1: sprintf(p, " %s12+d12", s_dur); break;
4434 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4435 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4436 case 5: sprintf(p, " %s4d10", s_heal); break;
4437 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4438 case 10: sprintf(p, " %s8d10", s_heal); break;
4439 case 11: sprintf(p, " %s20+d20", s_dur); break;
4440 case 14: sprintf(p, " %s300", s_heal); break;
4441 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4442 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4443 case 21: sprintf(p, " %s15+d21", s_delay); break;
4444 case 29: sprintf(p, " %s2000", s_heal); break;
4445 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4449 case REALM_SORCERY: /* Sorcery */
4452 case 1: sprintf(p, " %s10", s_range); break;
4453 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4454 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4455 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4456 case 18: sprintf(p, " %s25+d30", s_dur); break;
4457 case 22: sprintf(p, " %s15+d21", s_delay); break;
4458 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4459 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4461 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4463 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4465 case 27: sprintf(p, " %s25+d30", s_dur); break;
4466 case 31: sprintf(p, " %s4+d4", s_dur); break;
4470 case REALM_NATURE: /* Nature */
4474 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4476 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4478 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4479 case 6: sprintf(p, " %s20+d20", s_dur); break;
4480 case 7: sprintf(p, " %s2d8", s_heal); break;
4481 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4482 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4483 case 12: sprintf(p, " %s6d8", s_dam); break;
4484 case 15: sprintf(p, " %s500", s_heal); break;
4485 case 17: sprintf(p, " %s20+d30", s_dur); break;
4486 case 18: sprintf(p, " %s20+d20", s_dur); break;
4488 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4490 case 24: sprintf(p, " rad 10"); break;
4492 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4493 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4494 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4495 case 29: sprintf(p, " %s75", s_dam); break;
4496 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4500 case REALM_CHAOS: /* Chaos */
4503 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4504 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4505 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4506 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4507 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4508 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4509 case 8: sprintf(p, " %s", s_random); break;
4510 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4511 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4512 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4513 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4514 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4515 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4516 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4517 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4518 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4520 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4522 case 25: sprintf(p, " dam %d each", plev * 2); break;
4524 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4525 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4526 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4527 case 30: sprintf(p, " %s%d", s_dam, p_ptr->chp); break;
4528 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4532 case REALM_DEATH: /* Death */
4535 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4536 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4537 case 5: sprintf(p, " %s20+d20", s_dur); break;
4538 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4539 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4540 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4542 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4544 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4546 case 16: sprintf(p, " %s25+d25", s_dur); break;
4547 case 17: sprintf(p, " %s", s_random); break;
4548 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4549 case 19: sprintf(p, " %s25+d25", s_dur); break;
4550 case 21: sprintf(p, " %s3*100", s_dam); break;
4551 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4552 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4553 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4554 case 30: sprintf(p, " %s666", s_dam); break;
4555 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4559 case REALM_TRUMP: /* Trump */
4562 case 0: sprintf(p, " %s10", s_range); break;
4563 case 2: sprintf(p, " %s", s_random); break;
4564 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4565 case 5: sprintf(p, " %s25+d30", s_dur); break;
4567 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4569 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4571 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4572 case 14: sprintf(p, " %s15+d21", s_delay); break;
4573 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4575 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4577 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4582 case REALM_ARCANE: /* Arcane */
4585 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4586 case 4: sprintf(p, " %s10", s_range); break;
4587 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4588 case 7: sprintf(p, " %s2d8", s_heal); break;
4592 case 17: sprintf(p, " %s20+d20", s_dur); break;
4593 case 18: sprintf(p, " %s4d8", s_heal); break;
4594 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4595 case 21: sprintf(p, " %s6d8", s_dam); break;
4596 case 24: sprintf(p, " %s24+d24", s_dur); break;
4597 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4598 case 30: sprintf(p, " %s15+d21", s_delay); break;
4599 case 31: sprintf(p, " %s25+d30", s_dur); break;
4603 case REALM_ENCHANT: /* Craft */
4606 case 0: sprintf(p, " %s100+d100", s_dur); break;
4607 case 1: sprintf(p, " %s80+d80", s_dur); break;
4613 case 18: sprintf(p, " %s20+d20", s_dur); break;
4614 case 5: sprintf(p, " %s25+d25", s_dur); break;
4615 case 8: sprintf(p, " %s24+d24", s_dur); break;
4616 case 11: sprintf(p, " %s25+d25", s_dur); break;
4617 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4618 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4619 case 16: sprintf(p, " %s25+d30", s_dur); break;
4620 case 17: sprintf(p, " %s30+d20", s_dur); break;
4621 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4622 case 20: sprintf(p, " %s50+d50", s_dur); break;
4623 case 23: sprintf(p, " %s20+d20", s_dur); break;
4624 case 31: sprintf(p, " %s13+d13", s_dur); break;
4628 case REALM_DAEMON: /* Daemon */
4631 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4632 case 2: sprintf(p, " %s12+d12", s_dur); break;
4633 case 3: sprintf(p, " %s20+d20", s_dur); break;
4634 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4635 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4636 case 10: sprintf(p, " %s20+d20", s_dur); break;
4637 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4638 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4639 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4640 case 16: sprintf(p, " %s30+d25", s_dur); break;
4641 case 17: sprintf(p, " %s20+d20", s_dur); break;
4642 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4643 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4644 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4645 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4646 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4647 case 24: sprintf(p, " %s25+d25", s_dur); break;
4648 case 25: sprintf(p, " %s20+d20", s_dur); break;
4649 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4650 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4651 case 30: sprintf(p, " %s600", s_dam); break;
4652 case 31: sprintf(p, " %s15+d15", s_dur); break;
4656 case REALM_CRUSADE: /* Crusade */
4659 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4660 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4662 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4664 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4666 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4667 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4668 case 12: sprintf(p, " %s24+d24", s_dur); break;
4669 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4670 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4672 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4674 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4676 case 18: sprintf(p, " %s18+d18", s_dur); break;
4677 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4678 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4679 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4680 case 24: sprintf(p, " %s25+d25", s_dur); break;
4681 case 28: sprintf(p, " %s10+d10", s_dur); break;
4683 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4685 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4688 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4690 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4695 case REALM_MUSIC: /* Music */
4698 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4699 case 4 : sprintf(p, " %s2d6", s_heal); break;
4700 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4701 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4702 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4703 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4704 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4705 case 28: sprintf(p, " %s15d10", s_heal); break;
4706 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4711 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4713 sprintf(p, "Unknown type: %d.", use_realm);
4720 * Print a list of spells (for browsing or casting or viewing)
4722 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4724 int i, spell, exp_level, increment = 64;
4736 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4738 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4740 msg_print("Warning! print_spells called with null realm");
4744 /* Title the list */
4746 if (use_realm == REALM_HISSATSU)
4748 strcpy(buf," Lv MP");
4750 strcpy(buf," Lv SP");
4754 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4756 strcpy(buf,"Profic Lv SP Fail Effect");
4760 put_str("̾Á°", y, x + 5);
4761 put_str(buf, y, x + 29);
4763 put_str("Name", y, x + 5);
4764 put_str(buf, y, x + 29);
4767 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4768 else if (use_realm == p_ptr->realm1) increment = 0;
4769 else if (use_realm == p_ptr->realm2) increment = 32;
4771 /* Dump the spells */
4772 for (i = 0; i < num; i++)
4774 /* Access the spell */
4777 /* Access the spell */
4778 if (!is_magic(use_realm))
4780 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4784 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4787 if (use_realm == REALM_HISSATSU)
4788 need_mana = s_ptr->smana;
4791 s16b exp = experience_of_spell(spell, use_realm);
4793 /* Extract mana consumption rate */
4794 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4796 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4797 else exp_level = spell_exp_level(exp);
4800 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4801 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4802 else if (s_ptr->slevel >= 99) max = TRUE;
4803 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4805 strncpy(ryakuji, exp_level_str[exp_level], 4);
4810 if (use_menu && target_spell)
4812 if (i == (target_spell-1))
4814 strcpy(out_val, " ¡Õ ");
4816 strcpy(out_val, " > ");
4819 strcpy(out_val, " ");
4821 else sprintf(out_val, " %c) ", I2A(i));
4822 /* Skip illegible spells */
4823 if (s_ptr->slevel >= 99)
4826 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4828 strcat(out_val, format("%-30s", "(illegible)"));
4831 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4835 /* XXX XXX Could label spells above the players level */
4837 /* Get extra info */
4838 spell_info(info, spell, use_realm);
4843 /* Assume spell is known and tried */
4844 line_attr = TERM_WHITE;
4846 /* Analyze the spell */
4847 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4849 if (s_ptr->slevel > p_ptr->max_plv)
4854 comment = " unknown";
4857 line_attr = TERM_L_BLUE;
4859 else if (s_ptr->slevel > p_ptr->lev)
4864 comment = " forgotten";
4867 line_attr = TERM_YELLOW;
4870 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4875 comment = " unknown";
4878 line_attr = TERM_L_BLUE;
4880 else if ((use_realm == p_ptr->realm1) ?
4881 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4882 ((p_ptr->spell_forgotten2 & (1L << spell))))
4887 comment = " forgotten";
4890 line_attr = TERM_YELLOW;
4892 else if (!((use_realm == p_ptr->realm1) ?
4893 (p_ptr->spell_learned1 & (1L << spell)) :
4894 (p_ptr->spell_learned2 & (1L << spell))))
4899 comment = " unknown";
4902 line_attr = TERM_L_BLUE;
4904 else if (!((use_realm == p_ptr->realm1) ?
4905 (p_ptr->spell_worked1 & (1L << spell)) :
4906 (p_ptr->spell_worked2 & (1L << spell))))
4909 comment = " ̤·Ð¸³";
4911 comment = " untried";
4914 line_attr = TERM_L_GREEN;
4917 /* Dump the spell --(-- */
4918 if (use_realm == REALM_HISSATSU)
4920 strcat(out_val, format("%-25s %2d %4d",
4921 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4922 s_ptr->slevel, need_mana));
4926 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4927 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4928 (max ? '!' : ' '), ryakuji,
4929 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4931 c_prt(line_attr, out_val, y + i + 1, x);
4934 /* Clear the bottom line */
4935 prt("", y + i + 1, x);
4940 * Note that amulets, rods, and high-level spell books are immune
4941 * to "inventory damage" of any kind. Also sling ammo and shovels.
4946 * Does a given class of objects (usually) hate acid?
4947 * Note that acid can either melt or corrode something.
4949 bool hates_acid(object_type *o_ptr)
4951 /* Analyze the type */
4952 switch (o_ptr->tval)
4954 /* Wearable items */
4974 /* Staffs/Scrolls are wood/paper */
4987 /* Junk is useless */
5001 * Does a given object (usually) hate electricity?
5003 bool hates_elec(object_type *o_ptr)
5005 switch (o_ptr->tval)
5019 * Does a given object (usually) hate fire?
5020 * Hafted/Polearm weapons have wooden shafts.
5021 * Arrows/Bows are mostly wooden.
5023 bool hates_fire(object_type *o_ptr)
5025 /* Analyze the type */
5026 switch (o_ptr->tval)
5044 case TV_SORCERY_BOOK:
5045 case TV_NATURE_BOOK:
5049 case TV_ARCANE_BOOK:
5050 case TV_ENCHANT_BOOK:
5051 case TV_DAEMON_BOOK:
5052 case TV_CRUSADE_BOOK:
5054 case TV_HISSATSU_BOOK:
5065 /* Staffs/Scrolls burn */
5078 * Does a given object (usually) hate cold?
5080 bool hates_cold(object_type *o_ptr)
5082 switch (o_ptr->tval)
5099 int set_acid_destroy(object_type *o_ptr)
5101 u32b flgs[TR_FLAG_SIZE];
5102 if (!hates_acid(o_ptr)) return (FALSE);
5103 object_flags(o_ptr, flgs);
5104 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
5112 int set_elec_destroy(object_type *o_ptr)
5114 u32b flgs[TR_FLAG_SIZE];
5115 if (!hates_elec(o_ptr)) return (FALSE);
5116 object_flags(o_ptr, flgs);
5117 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
5125 int set_fire_destroy(object_type *o_ptr)
5127 u32b flgs[TR_FLAG_SIZE];
5128 if (!hates_fire(o_ptr)) return (FALSE);
5129 object_flags(o_ptr, flgs);
5130 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
5138 int set_cold_destroy(object_type *o_ptr)
5140 u32b flgs[TR_FLAG_SIZE];
5141 if (!hates_cold(o_ptr)) return (FALSE);
5142 object_flags(o_ptr, flgs);
5143 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
5149 * Destroys a type of item on a given percent chance
5150 * Note that missiles are no longer necessarily all destroyed
5151 * Destruction taken from "melee.c" code for "stealing".
5152 * New-style wands and rods handled correctly. -LM-
5153 * Returns number of items destroyed.
5155 int inven_damage(inven_func typ, int perc)
5159 char o_name[MAX_NLEN];
5161 /* Multishadow effects is determined by turn */
5162 if( p_ptr->multishadow && (turn & 1) )return 0;
5164 if (p_ptr->inside_arena) return 0;
5166 /* Count the casualties */
5169 /* Scan through the slots backwards */
5170 for (i = 0; i < INVEN_PACK; i++)
5172 o_ptr = &inventory[i];
5174 /* Skip non-objects */
5175 if (!o_ptr->k_idx) continue;
5177 /* Hack -- for now, skip artifacts */
5178 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
5180 /* Give this item slot a shot at death */
5183 /* Count the casualties */
5184 for (amt = j = 0; j < o_ptr->number; ++j)
5186 if (randint0(100) < perc) amt++;
5189 /* Some casualities */
5192 /* Get a description */
5193 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5197 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
5199 msg_format("%sour %s (%c) %s destroyed!",
5203 o_name, index_to_label(i),
5204 ((o_ptr->number > 1) ?
5205 ((amt == o_ptr->number) ? "Á´Éô" :
5206 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
5208 ((o_ptr->number > 1) ?
5209 ((amt == o_ptr->number) ? "All of y" :
5210 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
5211 o_name, index_to_label(i),
5212 ((amt > 1) ? "were" : "was"));
5216 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
5217 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
5220 /* Potions smash open */
5221 if (object_is_potion(o_ptr))
5223 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
5226 /* Reduce the charges of rods/wands */
5227 reduce_charges(o_ptr, amt);
5229 /* Destroy "amt" items */
5230 inven_item_increase(i, -amt);
5231 inven_item_optimize(i);
5233 /* Count the casualties */
5239 /* Return the casualty count */
5245 * Acid has hit the player, attempt to affect some armor.
5247 * Note that the "base armor" of an object never changes.
5249 * If any armor is damaged (or resists), the player takes less damage.
5251 static int minus_ac(void)
5253 object_type *o_ptr = NULL;
5254 u32b flgs[TR_FLAG_SIZE];
5255 char o_name[MAX_NLEN];
5258 /* Pick a (possibly empty) inventory slot */
5259 switch (randint1(7))
5261 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5262 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5263 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5264 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5265 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5266 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5267 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5270 /* Nothing to damage */
5271 if (!o_ptr->k_idx) return (FALSE);
5273 if (o_ptr->tval <= TV_WEAPON_END) return (FALSE);
5275 /* No damage left to be done */
5276 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5280 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5282 /* Extract the flags */
5283 object_flags(o_ptr, flgs);
5285 /* Object resists */
5286 if (have_flag(flgs, TR_IGNORE_ACID))
5289 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5291 msg_format("Your %s is unaffected!", o_name);
5300 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5302 msg_format("Your %s is damaged!", o_name);
5306 /* Damage the item */
5309 /* Calculate bonuses */
5310 p_ptr->update |= (PU_BONUS);
5313 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5317 /* Item was damaged */
5323 * Hurt the player with Acid
5325 int acid_dam(int dam, cptr kb_str, int monspell)
5328 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5329 bool double_resist = IS_OPPOSE_ACID();
5331 /* Total Immunity */
5332 if (p_ptr->immune_acid || (dam <= 0))
5334 learn_spell(monspell);
5338 /* Vulnerability (Ouch!) */
5339 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5340 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5342 /* Resist the damage */
5343 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5344 if (double_resist) dam = (dam + 2) / 3;
5346 if ((!(double_resist || p_ptr->resist_acid)) &&
5347 one_in_(HURT_CHANCE))
5348 (void)do_dec_stat(A_CHR);
5350 /* If any armor gets hit, defend the player */
5351 if (minus_ac()) dam = (dam + 1) / 2;
5354 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5356 /* Inventory damage */
5357 if (!(double_resist && p_ptr->resist_acid))
5358 inven_damage(set_acid_destroy, inv);
5364 * Hurt the player with electricity
5366 int elec_dam(int dam, cptr kb_str, int monspell)
5369 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5370 bool double_resist = IS_OPPOSE_ELEC();
5372 /* Total immunity */
5373 if (p_ptr->immune_elec || (dam <= 0))
5375 learn_spell(monspell);
5379 /* Vulnerability (Ouch!) */
5380 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5381 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5382 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5384 /* Resist the damage */
5385 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5386 if (double_resist) dam = (dam + 2) / 3;
5388 if ((!(double_resist || p_ptr->resist_elec)) &&
5389 one_in_(HURT_CHANCE))
5390 (void)do_dec_stat(A_DEX);
5393 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5395 /* Inventory damage */
5396 if (!(double_resist && p_ptr->resist_elec))
5397 inven_damage(set_elec_destroy, inv);
5404 * Hurt the player with Fire
5406 int fire_dam(int dam, cptr kb_str, int monspell)
5409 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5410 bool double_resist = IS_OPPOSE_FIRE();
5412 /* Totally immune */
5413 if (p_ptr->immune_fire || (dam <= 0))
5415 learn_spell(monspell);
5419 /* Vulnerability (Ouch!) */
5420 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5421 if (prace_is_(RACE_ENT)) dam += dam / 3;
5422 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5424 /* Resist the damage */
5425 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5426 if (double_resist) dam = (dam + 2) / 3;
5428 if ((!(double_resist || p_ptr->resist_fire)) &&
5429 one_in_(HURT_CHANCE))
5430 (void)do_dec_stat(A_STR);
5433 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5435 /* Inventory damage */
5436 if (!(double_resist && p_ptr->resist_fire))
5437 inven_damage(set_fire_destroy, inv);
5444 * Hurt the player with Cold
5446 int cold_dam(int dam, cptr kb_str, int monspell)
5449 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5450 bool double_resist = IS_OPPOSE_COLD();
5452 /* Total immunity */
5453 if (p_ptr->immune_cold || (dam <= 0))
5455 learn_spell(monspell);
5459 /* Vulnerability (Ouch!) */
5460 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5461 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5463 /* Resist the damage */
5464 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5465 if (double_resist) dam = (dam + 2) / 3;
5467 if ((!(double_resist || p_ptr->resist_cold)) &&
5468 one_in_(HURT_CHANCE))
5469 (void)do_dec_stat(A_STR);
5472 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5474 /* Inventory damage */
5475 if (!(double_resist && p_ptr->resist_cold))
5476 inven_damage(set_cold_destroy, inv);
5482 bool rustproof(void)
5486 char o_name[MAX_NLEN];
5489 item_tester_no_ryoute = TRUE;
5490 /* Select a piece of armour */
5491 item_tester_hook = item_tester_hook_armour;
5495 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5496 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5498 q = "Rustproof which piece of armour? ";
5499 s = "You have nothing to rustproof.";
5502 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5504 /* Get the item (in the pack) */
5507 o_ptr = &inventory[item];
5510 /* Get the item (on the floor) */
5513 o_ptr = &o_list[0 - item];
5518 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5520 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5522 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5525 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5527 msg_format("%s %s look%s as good as new!",
5528 ((item >= 0) ? "Your" : "The"), o_name,
5529 ((o_ptr->number > 1) ? "" : "s"));
5536 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5538 msg_format("%s %s %s now protected against corrosion.",
5539 ((item >= 0) ? "Your" : "The"), o_name,
5540 ((o_ptr->number > 1) ? "are" : "is"));
5551 * Curse the players armor
5553 bool curse_armor(void)
5558 char o_name[MAX_NLEN];
5561 /* Curse the body armor */
5562 o_ptr = &inventory[INVEN_BODY];
5564 /* Nothing to curse */
5565 if (!o_ptr->k_idx) return (FALSE);
5569 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5571 /* Attempt a saving throw for artifacts */
5572 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5576 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5577 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5579 msg_format("A %s tries to %s, but your %s resists the effects!",
5580 "terrible black aura", "surround your armor", o_name);
5585 /* not artifact or failed save... */
5590 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5592 msg_format("A terrible black aura blasts your %s!", o_name);
5595 chg_virtue(V_ENCHANT, -5);
5597 /* Blast the armor */
5599 o_ptr->name2 = EGO_BLASTED;
5600 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5607 for (i = 0; i < TR_FLAG_SIZE; i++)
5608 o_ptr->art_flags[i] = 0;
5611 o_ptr->curse_flags = TRC_CURSED;
5614 o_ptr->ident |= (IDENT_BROKEN);
5616 /* Recalculate bonuses */
5617 p_ptr->update |= (PU_BONUS);
5619 /* Recalculate mana */
5620 p_ptr->update |= (PU_MANA);
5623 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5631 * Curse the players weapon
5633 bool curse_weapon(bool force, int slot)
5639 char o_name[MAX_NLEN];
5642 /* Curse the weapon */
5643 o_ptr = &inventory[slot];
5645 /* Nothing to curse */
5646 if (!o_ptr->k_idx) return (FALSE);
5650 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5652 /* Attempt a saving throw */
5653 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5657 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5658 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5660 msg_format("A %s tries to %s, but your %s resists the effects!",
5661 "terrible black aura", "surround your weapon", o_name);
5666 /* not artifact or failed save... */
5671 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5673 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5676 chg_virtue(V_ENCHANT, -5);
5678 /* Shatter the weapon */
5680 o_ptr->name2 = EGO_SHATTERED;
5681 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5682 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5688 for (i = 0; i < TR_FLAG_SIZE; i++)
5689 o_ptr->art_flags[i] = 0;
5693 o_ptr->curse_flags = TRC_CURSED;
5696 o_ptr->ident |= (IDENT_BROKEN);
5698 /* Recalculate bonuses */
5699 p_ptr->update |= (PU_BONUS);
5701 /* Recalculate mana */
5702 p_ptr->update |= (PU_MANA);
5705 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5714 * Enchant some bolts
5716 bool brand_bolts(void)
5720 /* Use the first acceptable bolts */
5721 for (i = 0; i < INVEN_PACK; i++)
5723 object_type *o_ptr = &inventory[i];
5725 /* Skip non-bolts */
5726 if (o_ptr->tval != TV_BOLT) continue;
5728 /* Skip artifacts and ego-items */
5729 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5732 /* Skip cursed/broken items */
5733 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5736 if (randint0(100) < 75) continue;
5740 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5742 msg_print("Your bolts are covered in a fiery aura!");
5747 o_ptr->name2 = EGO_FLAME;
5750 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5757 if (flush_failure) flush();
5761 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5763 msg_print("The fiery enchantment failed.");
5773 * Helper function -- return a "nearby" race for polymorphing
5775 * Note that this function is one of the more "dangerous" ones...
5777 static s16b poly_r_idx(int r_idx)
5779 monster_race *r_ptr = &r_info[r_idx];
5781 int i, r, lev1, lev2;
5783 /* Hack -- Uniques/Questors never polymorph */
5784 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5785 (r_ptr->flags1 & RF1_QUESTOR))
5788 /* Allowable range of "levels" for resulting monster */
5789 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5790 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5792 /* Pick a (possibly new) non-unique race */
5793 for (i = 0; i < 1000; i++)
5795 /* Pick a new race, using a level calculation */
5796 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5798 /* Handle failure */
5804 /* Ignore unique monsters */
5805 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5807 /* Ignore monsters with incompatible levels */
5808 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5810 /* Use that index */
5822 bool polymorph_monster(int y, int x)
5824 cave_type *c_ptr = &cave[y][x];
5825 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5826 bool polymorphed = FALSE;
5828 int old_r_idx = m_ptr->r_idx;
5829 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5830 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5831 monster_type back_m;
5833 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5835 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5837 /* Memorize the monster before polymorphing */
5840 /* Pick a "new" monster race */
5841 new_r_idx = poly_r_idx(old_r_idx);
5843 /* Handle polymorph */
5844 if (new_r_idx != old_r_idx)
5848 /* Get the monsters attitude */
5849 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5850 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5851 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5853 /* "Kill" the "old" monster */
5854 delete_monster_idx(c_ptr->m_idx);
5856 /* Create a new monster (no groups) */
5857 if (place_monster_aux(0, y, x, new_r_idx, mode))
5864 /* Placing the new monster failed */
5865 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5866 m_list[hack_m_idx_ii] = back_m;
5869 if (targeted) target_who = hack_m_idx_ii;
5870 if (health_tracked) health_track(hack_m_idx_ii);
5880 static bool dimension_door_aux(int x, int y)
5882 int plev = p_ptr->lev;
5884 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5886 if (!cave_teleportable_bold(y, x, TELEPORT_ALLOW_DEEP | TELEPORT_ALLOW_OBJECT | TELEPORT_REQUIRE_PROJECT) ||
5887 (cave[y][x].info & CAVE_ICKY) ||
5888 (distance(y, x, py, px) > plev / 2 + 10) ||
5889 (!randint0(plev / 10 + 10)))
5891 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5892 teleport_player((plev+2)*2);
5899 teleport_player_to(y, x, TRUE);
5910 bool dimension_door(void)
5914 /* Rerutn FALSE if cancelled */
5915 if (!tgt_pt(&x, &y)) return FALSE;
5917 if (dimension_door_aux(x, y)) return TRUE;
5920 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5922 msg_print("You fail to exit the astral plane correctly!");
5930 * Mirror Master's Dimension Door
5932 bool mirror_tunnel(void)
5936 /* Rerutn FALSE if cancelled */
5937 if (!tgt_pt(&x, &y)) return FALSE;
5939 if (dimension_door_aux(x, y)) return TRUE;
5942 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5944 msg_print("You fail to pass the mirror plane correctly!");
5951 bool eat_magic(int power)
5953 object_type * o_ptr;
5956 int recharge_strength = 0;
5962 char o_name[MAX_NLEN];
5964 item_tester_hook = item_tester_hook_recharge;
5968 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5969 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5971 q = "Drain which item? ";
5972 s = "You have nothing to drain.";
5975 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5979 o_ptr = &inventory[item];
5983 o_ptr = &o_list[0 - item];
5986 k_ptr = &k_info[o_ptr->k_idx];
5987 lev = get_object_level(o_ptr);
5989 if (o_ptr->tval == TV_ROD)
5991 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5994 if (one_in_(recharge_strength))
5996 /* Activate the failure code. */
6001 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
6004 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
6006 msg_print("You can't absorb energy from a discharged rod.");
6013 o_ptr->timeout += k_ptr->pval;
6019 /* All staffs, wands. */
6020 recharge_strength = (100 + power - lev) / 15;
6023 if (recharge_strength < 0) recharge_strength = 0;
6026 if (one_in_(recharge_strength))
6028 /* Activate the failure code. */
6033 if (o_ptr->pval > 0)
6035 p_ptr->csp += lev / 2;
6038 /* XXX Hack -- unstack if necessary */
6039 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
6044 /* Get local object */
6047 /* Obtain a local object */
6048 object_copy(q_ptr, o_ptr);
6050 /* Modify quantity */
6053 /* Restore the charges */
6056 /* Unstack the used item */
6058 p_ptr->total_weight -= q_ptr->weight;
6059 item = inven_carry(q_ptr);
6063 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
6065 msg_print("You unstack your staff.");
6073 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
6075 msg_print("There's no energy there to absorb!");
6079 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
6083 /* Inflict the penalties for failing a recharge. */
6086 /* Artifacts are never destroyed. */
6087 if (artifact_p(o_ptr))
6089 object_desc(o_name, o_ptr, OD_NAME_ONLY);
6091 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
6093 msg_format("The recharging backfires - %s is completely drained!", o_name);
6097 /* Artifact rods. */
6098 if (o_ptr->tval == TV_ROD)
6099 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6101 /* Artifact wands and staffs. */
6102 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
6107 /* Get the object description */
6108 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
6110 /*** Determine Seriousness of Failure ***/
6112 /* Mages recharge objects more safely. */
6113 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)
6115 /* 10% chance to blow up one rod, otherwise draining. */
6116 if (o_ptr->tval == TV_ROD)
6118 if (one_in_(10)) fail_type = 2;
6121 /* 75% chance to blow up one wand, otherwise draining. */
6122 else if (o_ptr->tval == TV_WAND)
6124 if (!one_in_(3)) fail_type = 2;
6127 /* 50% chance to blow up one staff, otherwise no effect. */
6128 else if (o_ptr->tval == TV_STAFF)
6130 if (one_in_(2)) fail_type = 2;
6135 /* All other classes get no special favors. */
6138 /* 33% chance to blow up one rod, otherwise draining. */
6139 if (o_ptr->tval == TV_ROD)
6141 if (one_in_(3)) fail_type = 2;
6144 /* 20% chance of the entire stack, else destroy one wand. */
6145 else if (o_ptr->tval == TV_WAND)
6147 if (one_in_(5)) fail_type = 3;
6150 /* Blow up one staff. */
6151 else if (o_ptr->tval == TV_STAFF)
6157 /*** Apply draining and destruction. ***/
6159 /* Drain object or stack of objects. */
6162 if (o_ptr->tval == TV_ROD)
6165 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
6167 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
6170 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6172 else if (o_ptr->tval == TV_WAND)
6175 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
6177 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
6182 /* Staffs aren't drained. */
6185 /* Destroy an object or one in a stack of objects. */
6188 if (o_ptr->number > 1)
6191 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
6193 msg_format("Wild magic consumes one of your %s!", o_name);
6196 /* Reduce rod stack maximum timeout, drain wands. */
6197 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
6198 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
6203 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
6205 msg_format("Wild magic consumes your %s!", o_name);
6208 /* Reduce and describe inventory */
6211 inven_item_increase(item, -1);
6212 inven_item_describe(item);
6213 inven_item_optimize(item);
6216 /* Reduce and describe floor item */
6219 floor_item_increase(0 - item, -1);
6220 floor_item_describe(0 - item);
6221 floor_item_optimize(0 - item);
6225 /* Destroy all members of a stack of objects. */
6228 if (o_ptr->number > 1)
6230 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
6232 msg_format("Wild magic consumes all your %s!", o_name);
6237 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
6239 msg_format("Wild magic consumes your %s!", o_name);
6244 /* Reduce and describe inventory */
6247 inven_item_increase(item, -999);
6248 inven_item_describe(item);
6249 inven_item_optimize(item);
6252 /* Reduce and describe floor item */
6255 floor_item_increase(0 - item, -999);
6256 floor_item_describe(0 - item);
6257 floor_item_optimize(0 - item);
6263 if (p_ptr->csp > p_ptr->msp)
6265 p_ptr->csp = p_ptr->msp;
6268 /* Redraw mana and hp */
6269 p_ptr->redraw |= (PR_MANA);
6271 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6272 p_ptr->window |= (PW_INVEN);
6278 bool summon_kin_player(int level, int y, int x, u32b mode)
6280 bool pet = (bool)(mode & PM_FORCE_PET);
6281 if (!pet) mode |= PM_NO_PET;
6283 switch (p_ptr->mimic_form)
6286 switch (p_ptr->prace)
6290 case RACE_BARBARIAN:
6293 summon_kin_type = 'p';
6303 case RACE_MIND_FLAYER:
6306 summon_kin_type = 'h';
6309 summon_kin_type = 'o';
6311 case RACE_HALF_TROLL:
6312 summon_kin_type = 'T';
6314 case RACE_HALF_OGRE:
6315 summon_kin_type = 'O';
6317 case RACE_HALF_GIANT:
6318 case RACE_HALF_TITAN:
6320 summon_kin_type = 'P';
6323 summon_kin_type = 'y';
6326 summon_kin_type = 'K';
6329 summon_kin_type = 'k';
6332 if (one_in_(13)) summon_kin_type = 'U';
6333 else summon_kin_type = 'u';
6335 case RACE_DRACONIAN:
6336 summon_kin_type = 'd';
6340 summon_kin_type = 'g';
6343 if (one_in_(13)) summon_kin_type = 'L';
6344 else summon_kin_type = 's';
6347 summon_kin_type = 'z';
6350 summon_kin_type = 'V';
6353 summon_kin_type = 'G';
6356 summon_kin_type = 'I';
6359 summon_kin_type = '#';
6362 summon_kin_type = 'A';
6365 summon_kin_type = 'U';
6368 summon_kin_type = 'p';
6373 if (one_in_(13)) summon_kin_type = 'U';
6374 else summon_kin_type = 'u';
6376 case MIMIC_DEMON_LORD:
6377 summon_kin_type = 'U';
6380 summon_kin_type = 'V';
6383 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);