4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Spell code (part 3) */
15 /* Maximum number of tries for teleporting */
18 /* 1/x chance of reducing stats (for elemental attacks) */
19 #define HURT_CHANCE 16
23 * Teleport a monster, normally up to "dis" grids away.
25 * Attempt to move the monster at least "dis/2" grids away.
27 * But allow variation to prevent infinite loops.
29 bool teleport_away(int m_idx, int dis, bool dec_valour)
31 int oy, ox, d, i, min;
37 monster_type *m_ptr = &m_list[m_idx];
41 if (!m_ptr->r_idx) return (FALSE);
43 /* Save the old location */
47 /* Minimum distance */
51 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
52 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
54 chg_virtue(V_VALOUR, -1);
62 /* Verify max distance */
63 if (dis > 200) dis = 200;
65 /* Try several locations */
66 for (i = 0; i < 500; i++)
68 /* Pick a (possibly illegal) location */
71 ny = rand_spread(oy, dis);
72 nx = rand_spread(ox, dis);
73 d = distance(oy, ox, ny, nx);
74 if ((d >= min) && (d <= dis)) break;
77 /* Ignore illegal locations */
78 if (!in_bounds(ny, nx)) continue;
80 /* Require "empty" floor space */
81 if (!cave_empty_bold(ny, nx)) continue;
83 /* Hack -- no teleport onto glyph of warding */
84 if (is_glyph_grid(&cave[ny][nx])) continue;
85 if (is_explosive_rune_grid(&cave[ny][nx])) continue;
87 /* ...nor onto the Pattern */
88 if (pattern_tile(ny, nx)) continue;
90 /* No teleporting into vaults and such */
91 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
92 if (cave[ny][nx].info & CAVE_ICKY) continue;
94 /* This grid looks good */
101 /* Increase the maximum distance */
104 /* Decrease the minimum distance */
107 /* Stop after MAX_TRIES tries */
108 if (tries > MAX_TRIES) return (FALSE);
112 sound(SOUND_TPOTHER);
114 /* Update the new location */
115 cave[ny][nx].m_idx = m_idx;
117 /* Update the old location */
118 cave[oy][ox].m_idx = 0;
120 /* Move the monster */
124 /* Forget the counter target */
127 /* Update the monster (new location) */
128 update_mon(m_idx, TRUE);
130 /* Redraw the old grid */
133 /* Redraw the new grid */
136 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
137 p_ptr->update |= (PU_MON_LITE);
145 * Teleport monster next to a grid near the given location
147 void teleport_monster_to(int m_idx, int ty, int tx, int power)
149 int ny, nx, oy, ox, d, i, min;
153 monster_type *m_ptr = &m_list[m_idx];
157 if (!m_ptr->r_idx) return;
160 if (randint1(100) > power) return;
166 /* Save the old location */
170 /* Minimum distance */
173 /* Look until done */
174 while (look && --attempts)
176 /* Verify max distance */
177 if (dis > 200) dis = 200;
179 /* Try several locations */
180 for (i = 0; i < 500; i++)
184 /* Pick a (possibly illegal) location */
187 ny = rand_spread(ty, dis);
188 nx = rand_spread(tx, dis);
189 d = distance(ty, tx, ny, nx);
190 if ((d >= min) && (d <= dis)) break;
193 /* Ignore illegal locations */
194 if (!in_bounds(ny, nx)) continue;
196 /* Require "empty" floor space */
197 if (!cave_empty_bold(ny, nx)) continue;
199 c_ptr = &cave[ny][nx];
201 /* Hack -- no teleport onto glyph of warding */
202 if (is_glyph_grid(c_ptr)) continue;
203 if (is_explosive_rune_grid(c_ptr)) continue;
205 /* ...nor onto the Pattern */
206 if (pattern_tile(ny, nx)) continue;
208 /* No teleporting into vaults and such */
209 /* if (c_ptr->info & (CAVE_ICKY)) continue; */
211 /* This grid looks good */
218 /* Increase the maximum distance */
221 /* Decrease the minimum distance */
225 if (attempts < 1) return;
228 sound(SOUND_TPOTHER);
230 /* Update the new location */
231 cave[ny][nx].m_idx = m_idx;
233 /* Update the old location */
234 cave[oy][ox].m_idx = 0;
236 /* Move the monster */
240 /* Update the monster (new location) */
241 update_mon(m_idx, TRUE);
243 /* Redraw the old grid */
246 /* Redraw the new grid */
249 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
250 p_ptr->update |= (PU_MON_LITE);
254 bool cave_teleportable_bold(int y, int x)
256 cave_type *c_ptr = &cave[y][x];
257 feature_type *f_ptr = &f_info[c_ptr->feat];
259 /* Require "teleportable" space */
260 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
262 /* No teleporting into vaults and such */
263 if (c_ptr->info & CAVE_ICKY) return FALSE;
265 if (c_ptr->m_idx) return FALSE;
267 if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
269 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
271 if (!p_ptr->ffall && !p_ptr->can_swim) return FALSE;
274 if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
276 /* Always forbid deep lave */
277 if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
279 /* Forbid shallow lave when the player don't have levitation */
280 if (!p_ptr->ffall) return FALSE;
288 * Teleport the player to a location up to "dis" grids away.
290 * If no such spaces are readily available, the distance may increase.
291 * Try very hard to move the player at least a quarter that distance.
293 * When long-range teleport effects are considered, there is a nasty
294 * tendency to "bounce" the player between two or three different spots
295 * because these are the only spots that are "far enough" way to satisfy
296 * the algorithm. Therefore, if the teleport distance is more than 50,
297 * we decrease the minimum acceptable distance to try to increase randomness.
300 void teleport_player(int dis)
302 int d, i, min, ox, oy;
313 if (p_ptr->wild_mode) return;
315 if (p_ptr->anti_tele)
318 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
320 msg_print("A mysterious force prevents you from teleporting!");
326 if (dis > 200) dis = 200; /* To be on the safe side... */
328 /* Minimum distance */
329 min = dis / (dis > 50 ? 3 : 2);
331 /* Look until done */
336 /* Verify max distance */
337 if (dis > 200) dis = 200;
339 /* Try several locations */
340 for (i = 0; i < 500; i++)
342 /* Pick a (possibly illegal) location */
345 y = rand_spread(py, dis);
346 x = rand_spread(px, dis);
347 d = distance(py, px, y, x);
348 if ((d >= min) && (d <= dis)) break;
351 /* Ignore illegal locations */
352 if (!in_bounds(y, x)) continue;
354 if (!cave_teleportable_bold(y, x)) continue;
356 /* This grid looks good */
363 /* Increase the maximum distance */
366 /* Decrease the minimum distance */
369 /* Stop after MAX_TRIES tries */
370 if (tries > MAX_TRIES) return;
374 sound(SOUND_TELEPORT);
377 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
378 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
381 /* Save the old location */
385 /* Move the player */
391 cave[oy][ox].m_idx = cave[py][px].m_idx;
392 cave[py][px].m_idx = p_ptr->riding;
393 m_list[p_ptr->riding].fy = py;
394 m_list[p_ptr->riding].fx = px;
395 update_mon(p_ptr->riding, TRUE);
398 /* Redraw the old spot */
401 /* Monsters with teleport ability may follow the player */
402 for (xx = -1; xx < 2; xx++)
404 for (yy = -1; yy < 2; yy++)
406 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
408 /* A monster except your mount may follow */
409 if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
411 monster_type *m_ptr = &m_list[tmp_m_idx];
412 monster_race *r_ptr = &r_info[m_ptr->r_idx];
415 * The latter limitation is to avoid
416 * totally unkillable suckers...
418 if ((r_ptr->flags6 & RF6_TPORT) &&
419 !(r_ptr->flagsr & RFR_RES_TELE))
421 if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level);
429 /* Redraw the new spot */
432 /* Check for new panel (redraw map) */
436 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
438 /* Update the monsters */
439 p_ptr->update |= (PU_DISTANCE);
442 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
444 /* Handle stuff XXX XXX XXX */
451 * Teleport player to a grid near the given location
453 * This function is slightly obsessive about correctness.
454 * This function allows teleporting into vaults (!)
456 void teleport_player_to(int ny, int nx, bool no_tele)
458 int y, x, oy, ox, dis = 0, ctr = 0;
460 if (p_ptr->anti_tele && no_tele)
463 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
465 msg_print("A mysterious force prevents you from teleporting!");
471 /* Find a usable location */
474 /* Pick a nearby legal location */
477 y = rand_spread(ny, dis);
478 x = rand_spread(nx, dis);
479 if (in_bounds(y, x)) break;
482 /* Accept any grid when wizard mode */
483 if (p_ptr->wizard) break;
485 /* Accept teleportable floor grids */
486 if (cave_teleportable_bold(y, x)) break;
488 /* Occasionally advance the distance */
489 if (++ctr > (4 * dis * dis + 4 * dis + 1))
497 sound(SOUND_TELEPORT);
499 /* Save the old location */
503 /* Move the player */
509 cave[oy][ox].m_idx = cave[py][px].m_idx;
510 cave[py][px].m_idx = p_ptr->riding;
511 m_list[p_ptr->riding].fy = py;
512 m_list[p_ptr->riding].fx = px;
513 update_mon(p_ptr->riding, TRUE);
518 /* Redraw the old spot */
521 /* Redraw the new spot */
524 /* Check for new panel (redraw map) */
528 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
530 /* Update the monsters */
531 p_ptr->update |= (PU_DISTANCE);
534 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
536 /* Handle stuff XXX XXX XXX */
543 * Teleport the player one level up or down (random when legal)
544 * Note: If m_idx <= 0, target is player.
546 void teleport_level(int m_idx)
552 if (m_idx <= 0) /* To player */
555 strcpy(m_name, "¤¢¤Ê¤¿");
557 strcpy(m_name, "you");
560 else /* To monster */
562 monster_type *m_ptr = &m_list[m_idx];
564 /* Get the monster name (or "it") */
565 monster_desc(m_name, m_ptr, 0);
570 /* No effect in some case */
571 if (TELE_LEVEL_IS_INEFF(m_idx))
574 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
576 if (see_m) msg_print("There is no effect.");
582 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
585 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
587 msg_print("A mysterious force prevents you from teleporting!");
592 /* Choose up or down */
593 if (randint0(100) < 50) go_up = TRUE;
596 if ((m_idx <= 0) && p_ptr->wizard)
598 if (get_check("Force to go up? ")) go_up = TRUE;
599 else if (get_check("Force to go down? ")) go_up = FALSE;
603 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
606 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
608 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
610 if (m_idx <= 0) /* To player */
614 dungeon_type = p_ptr->recall_dungeon;
619 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
621 if (autosave_l) do_cmd_save_game(TRUE);
625 dun_level = d_info[dungeon_type].mindepth;
626 prepare_change_floor_mode(CFM_RAND_PLACE);
630 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
634 p_ptr->leaving = TRUE;
639 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
642 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
644 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
648 if (m_idx <= 0) /* To player */
650 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
652 if (autosave_l) do_cmd_save_game(TRUE);
654 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
659 p_ptr->inside_quest = 0;
660 p_ptr->leaving = TRUE;
666 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
668 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
672 if (m_idx <= 0) /* To player */
674 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
676 if (autosave_l) do_cmd_save_game(TRUE);
678 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
681 p_ptr->leaving = TRUE;
687 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
689 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
692 if (m_idx <= 0) /* To player */
694 /* Never reach this code on the surface */
695 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
697 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
699 if (autosave_l) do_cmd_save_game(TRUE);
701 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
704 p_ptr->leaving = TRUE;
708 /* Monster level teleportation is simple deleting now */
711 monster_type *m_ptr = &m_list[m_idx];
713 /* Check for quest completion */
714 check_quest_completion(m_ptr);
716 delete_monster_idx(m_idx);
720 sound(SOUND_TPLEVEL);
725 int choose_dungeon(cptr note, int y, int x)
731 /* Hack -- No need to choose dungeon in some case */
732 if (lite_town || vanilla_town || ironman_downward)
734 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
738 msg_format("¤Þ¤À%s¤ËÆþ¤Ã¤¿¤³¤È¤Ï¤Ê¤¤¡£", d_name + d_info[DUNGEON_ANGBAND].name);
740 msg_format("You haven't entered %s yet.", d_name + d_info[DUNGEON_ANGBAND].name);
747 /* Allocate the "dun" array */
748 C_MAKE(dun, max_d_idx, s16b);
751 for(i = 1; i < max_d_idx; i++)
756 if (!d_info[i].maxdepth) continue;
757 if (!max_dlv[i]) continue;
758 if (d_info[i].final_guardian)
760 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
762 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
765 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
767 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
769 prt(buf, y + num, x);
776 prt(" Áª¤Ù¤ë¥À¥ó¥¸¥ç¥ó¤¬¤Ê¤¤¡£", y, x);
778 prt(" No dungeon is available.", y, x);
783 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
785 prt(format("Which dungeon do you %s?: ", note), 0, 0);
790 if ((i == ESCAPE) || !num)
792 /* Free the "dun" array */
793 C_KILL(dun, max_d_idx, s16b);
798 if (i >= 'a' && i <('a'+num))
800 select_dungeon = dun[i-'a'];
807 /* Free the "dun" array */
808 C_KILL(dun, max_d_idx, s16b);
810 return select_dungeon;
815 * Recall the player to town or dungeon
817 bool recall_player(int turns)
820 * TODO: Recall the player to the last
821 * visited town when in the wilderness
825 if (p_ptr->inside_arena || ironman_downward)
828 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
830 msg_print("Nothing happens.");
836 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
839 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
841 if (get_check("Reset recall depth? "))
844 max_dlv[dungeon_type] = dun_level;
845 if (record_maxdeapth)
847 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
849 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
854 if (!p_ptr->word_recall)
860 select_dungeon = choose_dungeon("¤Ëµ¢´Ô", 2, 14);
862 select_dungeon = choose_dungeon("recall", 2, 14);
864 if (!select_dungeon) return FALSE;
865 p_ptr->recall_dungeon = select_dungeon;
867 p_ptr->word_recall = turns;
869 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
871 msg_print("The air about you becomes charged...");
874 p_ptr->redraw |= (PR_STATUS);
878 p_ptr->word_recall = 0;
880 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
882 msg_print("A tension leaves the air around you...");
885 p_ptr->redraw |= (PR_STATUS);
891 bool word_of_recall(void)
893 return(recall_player(randint0(21) + 15));
897 bool reset_recall(void)
899 int select_dungeon, dummy = 0;
904 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È", 2, 14);
906 select_dungeon = choose_dungeon("reset", 2, 14);
910 if (ironman_downward)
913 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
915 msg_print("Nothing happens.");
921 if (!select_dungeon) return FALSE;
924 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
926 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
931 sprintf(tmp_val, "%d", MAX(dun_level, 1));
933 /* Ask for a level */
934 if (get_string(ppp, tmp_val, 10))
936 /* Extract request */
937 dummy = atoi(tmp_val);
940 if (dummy < 1) dummy = 1;
943 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
944 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
946 max_dlv[select_dungeon] = dummy;
948 if (record_maxdeapth)
950 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
952 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
956 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
958 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
971 * Apply disenchantment to the player's stuff
973 * XXX XXX XXX This function is also called from the "melee" code
975 * Return "TRUE" if the player notices anything
977 bool apply_disenchant(int mode)
981 char o_name[MAX_NLEN];
982 int to_h, to_d, to_a, pval;
984 /* Pick a random slot */
987 case 1: t = INVEN_RARM; break;
988 case 2: t = INVEN_LARM; break;
989 case 3: t = INVEN_BOW; break;
990 case 4: t = INVEN_BODY; break;
991 case 5: t = INVEN_OUTER; break;
992 case 6: t = INVEN_HEAD; break;
993 case 7: t = INVEN_HANDS; break;
994 case 8: t = INVEN_FEET; break;
998 o_ptr = &inventory[t];
1000 /* No item, nothing happens */
1001 if (!o_ptr->k_idx) return (FALSE);
1004 /* Nothing to disenchant */
1005 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1007 /* Nothing to notice */
1012 /* Describe the object */
1013 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1016 /* Artifacts have 71% chance to resist */
1017 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 71))
1021 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
1023 msg_format("Your %s (%c) resist%s disenchantment!",
1024 o_name, index_to_label(t),
1025 ((o_ptr->number != 1) ? "" : "s"));
1034 /* Memorize old value */
1040 /* Disenchant tohit */
1041 if (o_ptr->to_h > 0) o_ptr->to_h--;
1042 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1044 /* Disenchant todam */
1045 if (o_ptr->to_d > 0) o_ptr->to_d--;
1046 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1048 /* Disenchant toac */
1049 if (o_ptr->to_a > 0) o_ptr->to_a--;
1050 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1052 /* Disenchant pval (occasionally) */
1053 /* Unless called from wild_magic() */
1054 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1056 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1057 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1061 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
1062 o_name, index_to_label(t) );
1064 msg_format("Your %s (%c) %s disenchanted!",
1065 o_name, index_to_label(t),
1066 ((o_ptr->number != 1) ? "were" : "was"));
1069 chg_virtue(V_HARMONY, 1);
1070 chg_virtue(V_ENCHANT, -2);
1072 /* Recalculate bonuses */
1073 p_ptr->update |= (PU_BONUS);
1076 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1086 void mutate_player(void)
1088 int max1, cur1, max2, cur2, ii, jj, i;
1090 /* Pick a pair of stats */
1092 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1094 max1 = p_ptr->stat_max[ii];
1095 cur1 = p_ptr->stat_cur[ii];
1096 max2 = p_ptr->stat_max[jj];
1097 cur2 = p_ptr->stat_cur[jj];
1099 p_ptr->stat_max[ii] = max2;
1100 p_ptr->stat_cur[ii] = cur2;
1101 p_ptr->stat_max[jj] = max1;
1102 p_ptr->stat_cur[jj] = cur1;
1106 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1107 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1110 p_ptr->update |= (PU_BONUS);
1117 void apply_nexus(monster_type *m_ptr)
1119 switch (randint1(7))
1121 case 1: case 2: case 3:
1123 teleport_player(200);
1129 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE);
1135 if (randint0(100) < p_ptr->skill_sav)
1138 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1140 msg_print("You resist the effects!");
1146 /* Teleport Level */
1153 if (randint0(100) < p_ptr->skill_sav)
1156 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1158 msg_print("You resist the effects!");
1165 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1167 msg_print("Your body starts to scramble...");
1178 * Charge a lite (torch or latern)
1180 void phlogiston(void)
1183 object_type * o_ptr = &inventory[INVEN_LITE];
1186 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1188 max_flog = FUEL_LAMP;
1192 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1194 max_flog = FUEL_TORCH;
1197 /* No torch to refill */
1201 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1203 msg_print("You are not wielding anything which uses phlogiston.");
1209 if (o_ptr->xtra4 >= max_flog)
1212 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1214 msg_print("No more phlogiston can be put in this item.");
1221 o_ptr->xtra4 += (max_flog / 2);
1225 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1227 msg_print("You add phlogiston to your light item.");
1232 if (o_ptr->xtra4 >= max_flog)
1234 o_ptr->xtra4 = max_flog;
1236 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1238 msg_print("Your light item is full.");
1243 /* Recalculate torch */
1244 p_ptr->update |= (PU_TORCH);
1248 static bool item_tester_hook_weapon_nobow(object_type *o_ptr)
1250 switch (o_ptr->tval)
1260 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
1268 * Brand the current weapon
1270 void brand_weapon(int brand_type)
1277 /* Assume enchant weapon */
1278 item_tester_hook = item_tester_hook_weapon_nobow;
1279 item_tester_no_ryoute = TRUE;
1283 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1284 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1286 q = "Enchant which weapon? ";
1287 s = "You have nothing to enchant.";
1290 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1292 /* Get the item (in the pack) */
1295 o_ptr = &inventory[item];
1298 /* Get the item (on the floor) */
1301 o_ptr = &o_list[0 - item];
1305 /* you can never modify artifacts / ego-items */
1306 /* you can never modify cursed items */
1307 /* TY: You _can_ modify broken items (if you're silly enough) */
1308 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
1309 !o_ptr->art_name && !cursed_p(o_ptr) &&
1310 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1311 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1312 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1316 /* Let's get the name before it is changed... */
1317 char o_name[MAX_NLEN];
1318 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1323 if (o_ptr->tval == TV_SWORD)
1326 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1328 act = "becomes very sharp!";
1331 o_ptr->name2 = EGO_SHARPNESS;
1332 o_ptr->pval = m_bonus(5, dun_level) + 1;
1337 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1339 act = "seems very powerful.";
1342 o_ptr->name2 = EGO_EARTHQUAKES;
1343 o_ptr->pval = m_bonus(3, dun_level);
1348 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1350 act = "seems to be looking for humans!";
1353 o_ptr->name2 = EGO_SLAY_HUMAN;
1357 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1359 act = "covered with lightning!";
1362 o_ptr->name2 = EGO_BRAND_ELEC;
1366 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1368 act = "coated with acid!";
1371 o_ptr->name2 = EGO_BRAND_ACID;
1375 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1377 act = "seems to be looking for evil monsters!";
1380 o_ptr->name2 = EGO_SLAY_EVIL;
1384 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1386 act = "seems to be looking for demons!";
1389 o_ptr->name2 = EGO_SLAY_DEMON;
1393 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1395 act = "seems to be looking for undead!";
1398 o_ptr->name2 = EGO_SLAY_UNDEAD;
1402 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1404 act = "seems to be looking for animals!";
1407 o_ptr->name2 = EGO_SLAY_ANIMAL;
1411 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1413 act = "seems to be looking for dragons!";
1416 o_ptr->name2 = EGO_SLAY_DRAGON;
1420 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1422 act = "seems to be looking for troll!s";
1425 o_ptr->name2 = EGO_SLAY_TROLL;
1429 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1431 act = "seems to be looking for orcs!";
1434 o_ptr->name2 = EGO_SLAY_ORC;
1438 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1440 act = "seems to be looking for giants!";
1443 o_ptr->name2 = EGO_SLAY_GIANT;
1447 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1449 act = "seems very unstable now.";
1452 o_ptr->name2 = EGO_TRUMP;
1453 o_ptr->pval = randint1(2);
1457 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1459 act = "thirsts for blood!";
1462 o_ptr->name2 = EGO_VAMPIRIC;
1466 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1468 act = "is coated with poison.";
1471 o_ptr->name2 = EGO_BRAND_POIS;
1475 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1477 act = "is engulfed in raw Logrus!";
1480 o_ptr->name2 = EGO_CHAOTIC;
1484 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1486 act = "is covered in a fiery shield!";
1489 o_ptr->name2 = EGO_BRAND_FIRE;
1493 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1495 act = "glows deep, icy blue!";
1498 o_ptr->name2 = EGO_BRAND_COLD;
1503 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1505 msg_format("Your %s %s", o_name, act);
1509 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1511 o_ptr->discount = 99;
1512 chg_virtue(V_ENCHANT, 2);
1516 if (flush_failure) flush();
1519 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1521 msg_print("The Branding failed.");
1524 chg_virtue(V_ENCHANT, -2);
1531 * Vanish all walls in this floor
1533 static bool vanish_dungeon(void)
1537 feature_type *f_ptr;
1538 monster_type *m_ptr;
1541 /* Prevent vasishing of quest levels and town */
1542 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1547 /* Scan all normal grids */
1548 for (y = 1; y < cur_hgt - 1; y++)
1550 for (x = 1; x < cur_wid - 1; x++)
1552 c_ptr = &cave[y][x];
1554 /* Seeing true feature code (ignore mimic) */
1555 f_ptr = &f_info[c_ptr->feat];
1557 /* Lose room and vault */
1558 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1560 m_ptr = &m_list[c_ptr->m_idx];
1563 if (c_ptr->m_idx && m_ptr->csleep)
1565 /* Reset sleep counter */
1568 /* Notice the "waking up" */
1571 /* Acquire the monster name */
1572 monster_desc(m_name, m_ptr, 0);
1574 /* Dump a message */
1576 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1578 msg_format("%^s wakes up.", m_name);
1581 /* Redraw the health bar */
1582 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
1583 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
1587 /* Process all walls, doors and patterns */
1588 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1592 /* Special boundary walls -- Top and bottom */
1593 for (x = 0; x < cur_wid; x++)
1595 c_ptr = &cave[0][x];
1596 f_ptr = &f_info[c_ptr->mimic];
1598 /* Lose room and vault */
1599 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1601 /* Set boundary mimic if needed */
1602 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1604 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1606 /* Check for change to boring grid */
1607 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1610 c_ptr = &cave[cur_hgt - 1][x];
1611 f_ptr = &f_info[c_ptr->mimic];
1613 /* Lose room and vault */
1614 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1616 /* Set boundary mimic if needed */
1617 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1619 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1621 /* Check for change to boring grid */
1622 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1626 /* Special boundary walls -- Left and right */
1627 for (y = 1; y < (cur_hgt - 1); y++)
1629 c_ptr = &cave[y][0];
1630 f_ptr = &f_info[c_ptr->mimic];
1632 /* Lose room and vault */
1633 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1635 /* Set boundary mimic if needed */
1636 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1638 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1640 /* Check for change to boring grid */
1641 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1644 c_ptr = &cave[y][cur_wid - 1];
1645 f_ptr = &f_info[c_ptr->mimic];
1647 /* Lose room and vault */
1648 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1650 /* Set boundary mimic if needed */
1651 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1653 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1655 /* Check for change to boring grid */
1656 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1660 /* Mega-Hack -- Forget the view and lite */
1661 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1664 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1666 /* Update the monsters */
1667 p_ptr->update |= (PU_MONSTERS);
1670 p_ptr->redraw |= (PR_MAP);
1673 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1679 void call_the_(void)
1683 bool do_call = TRUE;
1685 for (i = 0; i < 9; i++)
1687 y = py + ddy_ddd[i];
1688 x = px + ddx_ddd[i];
1690 if (!cave_floor_bold(y, x) && !boundary_floor_bold(y, x))
1699 for (i = 1; i < 10; i++)
1701 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1704 for (i = 1; i < 10; i++)
1706 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1709 for (i = 1; i < 10; i++)
1711 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1715 /* Prevent destruction of quest levels and town */
1716 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1719 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1721 msg_print("The ground trembles.");
1728 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1729 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1730 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1732 msg_format("You %s the %s too close to a wall!",
1733 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1734 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1735 msg_print("There is a loud explosion!");
1741 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1743 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1748 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1750 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1752 msg_print("The dungeon collapses...");
1757 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1759 msg_print("The dungeon trembles.");
1764 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1766 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1773 * Fetch an item (teleport it right underneath the caster)
1775 void fetch(int dir, int wgt, bool require_los)
1780 char o_name[MAX_NLEN];
1782 /* Check to see if an object is already there */
1783 if (cave[py][px].o_idx)
1786 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1788 msg_print("You can't fetch when you're already standing on something.");
1795 if (dir == 5 && target_okay())
1800 if (distance(py, px, ty, tx) > MAX_RANGE)
1803 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1805 msg_print("You can't fetch something that far away!");
1811 c_ptr = &cave[ty][tx];
1813 /* We need an item to fetch */
1817 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1819 msg_print("There is no object at this place.");
1825 /* No fetching from vault */
1826 if (c_ptr->info & CAVE_ICKY)
1829 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1831 msg_print("The item slips from your control.");
1837 /* We need to see the item */
1838 if (require_los && !player_has_los_bold(ty, tx))
1841 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1843 msg_print("You have no direct line of sight to that location.");
1851 /* Use a direction */
1852 ty = py; /* Where to drop the item */
1859 c_ptr = &cave[ty][tx];
1861 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1862 !cave_floor_bold(ty, tx)) return;
1864 while (!c_ptr->o_idx);
1867 o_ptr = &o_list[c_ptr->o_idx];
1869 if (o_ptr->weight > wgt)
1871 /* Too heavy to 'fetch' */
1873 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1875 msg_print("The object is too heavy.");
1882 c_ptr->o_idx = o_ptr->next_o_idx;
1883 cave[py][px].o_idx = i; /* 'move' it */
1884 o_ptr->next_o_idx = 0;
1885 o_ptr->iy = (byte)py;
1886 o_ptr->ix = (byte)px;
1888 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1890 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1892 msg_format("%^s flies through the air to your feet.", o_name);
1897 p_ptr->redraw |= PR_MAP;
1901 void alter_reality(void)
1903 /* Ironman option */
1904 if (p_ptr->inside_arena || ironman_downward)
1907 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1909 msg_print("Nothing happens.");
1914 if (!p_ptr->alter_reality)
1916 int turns = randint0(21) + 15;
1918 p_ptr->alter_reality = turns;
1920 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1922 msg_print("The view around you begins to change...");
1925 p_ptr->redraw |= (PR_STATUS);
1929 p_ptr->alter_reality = 0;
1931 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1933 msg_print("The view around you got back...");
1936 p_ptr->redraw |= (PR_STATUS);
1943 * Leave a "glyph of warding" which prevents monster movement
1945 bool warding_glyph(void)
1948 if (!cave_clean_bold(py, px))
1951 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1953 msg_print("The object resists the spell.");
1959 /* Create a glyph */
1960 cave[py][px].info |= CAVE_OBJECT;
1961 cave[py][px].mimic = FEAT_GLYPH;
1972 bool place_mirror(void)
1975 if (!cave_clean_bold(py, px))
1978 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1980 msg_print("The object resists the spell.");
1986 /* Create a mirror */
1987 cave[py][px].info |= CAVE_OBJECT;
1988 cave[py][px].mimic = FEAT_MIRROR;
1990 /* Turn on the light */
1991 cave[py][px].info |= CAVE_GLOW;
2004 * Leave an "explosive rune" which prevents monster movement
2006 bool explosive_rune(void)
2009 if (!cave_clean_bold(py, px))
2012 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
2014 msg_print("The object resists the spell.");
2020 /* Create a glyph */
2021 cave[py][px].info |= CAVE_OBJECT;
2022 cave[py][px].mimic = FEAT_MINOR_GLYPH;
2035 * Identify everything being carried.
2036 * Done by a potion of "self knowledge".
2038 void identify_pack(void)
2042 /* Simply identify and know every item */
2043 for (i = 0; i < INVEN_TOTAL; i++)
2045 object_type *o_ptr = &inventory[i];
2047 /* Skip non-objects */
2048 if (!o_ptr->k_idx) continue;
2051 identify_item(o_ptr);
2053 /* Auto-inscription */
2054 autopick_alter_item(i, FALSE);
2060 * Used by the "enchant" function (chance of failure)
2061 * (modified for Zangband, we need better stuff there...) -- TY
2063 static int enchant_table[16] =
2065 0, 10, 50, 100, 200,
2066 300, 400, 500, 650, 800,
2067 950, 987, 993, 995, 998,
2073 * Removes curses from items in inventory
2075 * Note that Items which are "Perma-Cursed" (The One Ring,
2076 * The Crown of Morgoth) can NEVER be uncursed.
2078 * Note that if "all" is FALSE, then Items which are
2079 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2080 * will not be uncursed.
2082 static int remove_curse_aux(int all)
2086 /* Attempt to uncurse items being worn */
2087 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2089 object_type *o_ptr = &inventory[i];
2091 /* Skip non-objects */
2092 if (!o_ptr->k_idx) continue;
2094 /* Uncursed already */
2095 if (!cursed_p(o_ptr)) continue;
2097 /* Heavily Cursed Items need a special spell */
2098 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2100 /* Perma-Cursed Items can NEVER be uncursed */
2101 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2104 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2109 o_ptr->curse_flags = 0L;
2111 /* Hack -- Assume felt */
2112 o_ptr->ident |= (IDENT_SENSE);
2115 o_ptr->feeling = FEEL_NONE;
2117 /* Recalculate the bonuses */
2118 p_ptr->update |= (PU_BONUS);
2121 p_ptr->window |= (PW_EQUIP);
2123 /* Count the uncursings */
2127 /* Return "something uncursed" */
2133 * Remove most curses
2135 bool remove_curse(void)
2137 return (remove_curse_aux(FALSE));
2143 bool remove_all_curse(void)
2145 return (remove_curse_aux(TRUE));
2150 * Turns an object into gold, gain some of its value in a shop
2159 char o_name[MAX_NLEN];
2160 char out_val[MAX_NLEN+40];
2164 /* Hack -- force destruction */
2165 if (command_arg > 0) force = TRUE;
2169 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2170 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2172 q = "Turn which item to gold? ";
2173 s = "You have nothing to turn to gold.";
2176 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2178 /* Get the item (in the pack) */
2181 o_ptr = &inventory[item];
2184 /* Get the item (on the floor) */
2187 o_ptr = &o_list[0 - item];
2191 /* See how many items */
2192 if (o_ptr->number > 1)
2194 /* Get a quantity */
2195 amt = get_quantity(NULL, o_ptr->number);
2197 /* Allow user abort */
2198 if (amt <= 0) return FALSE;
2202 /* Describe the object */
2203 old_number = o_ptr->number;
2204 o_ptr->number = amt;
2205 object_desc(o_name, o_ptr, 0);
2206 o_ptr->number = old_number;
2208 /* Verify unless quantity given */
2211 if (confirm_destroy || (object_value(o_ptr) > 0))
2213 /* Make a verification */
2215 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2217 sprintf(out_val, "Really turn %s to gold? ", o_name);
2220 if (!get_check(out_val)) return FALSE;
2224 /* Artifacts cannot be destroyed */
2225 if (!can_player_destroy_object(o_ptr))
2229 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2231 msg_format("You fail to turn %s to gold!", o_name);
2238 price = object_value_real(o_ptr);
2244 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2246 msg_format("You turn %s to fool's gold.", o_name);
2254 if (amt > 1) price *= amt;
2256 if (price > 30000) price = 30000;
2258 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2260 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2266 p_ptr->redraw |= (PR_GOLD);
2269 p_ptr->window |= (PW_PLAYER);
2273 /* Eliminate the item (from the pack) */
2276 inven_item_increase(item, -amt);
2277 inven_item_describe(item);
2278 inven_item_optimize(item);
2281 /* Eliminate the item (from the floor) */
2284 floor_item_increase(0 - item, -amt);
2285 floor_item_describe(0 - item);
2286 floor_item_optimize(0 - item);
2295 * Hook to specify "weapon"
2297 bool item_tester_hook_weapon(object_type *o_ptr)
2299 switch (o_ptr->tval)
2313 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2320 static bool item_tester_hook_weapon2(object_type *o_ptr)
2322 switch (o_ptr->tval)
2342 * Hook to specify "armour"
2344 bool item_tester_hook_armour(object_type *o_ptr)
2346 switch (o_ptr->tval)
2367 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2369 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2371 switch (o_ptr->tval)
2400 * Check if an object is nameless weapon or armour
2402 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2404 switch (o_ptr->tval)
2423 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2425 if (object_known_p(o_ptr)) return FALSE;
2435 * Break the curse of an item
2437 static void break_curse(object_type *o_ptr)
2439 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2442 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2444 msg_print("The curse is broken!");
2447 o_ptr->curse_flags = 0L;
2449 o_ptr->ident |= (IDENT_SENSE);
2451 o_ptr->feeling = FEEL_NONE;
2457 * Enchants a plus onto an item. -RAK-
2459 * Revamped! Now takes item pointer, number of times to try enchanting,
2460 * and a flag of what to try enchanting. Artifacts resist enchantment
2461 * some of the time, and successful enchantment to at least +0 might
2462 * break a curse on the item. -CFT-
2464 * Note that an item can technically be enchanted all the way to +15 if
2465 * you wait a very, very, long time. Going from +9 to +10 only works
2466 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2468 * Note that this function can now be used on "piles" of items, and
2469 * the larger the pile, the lower the chance of success.
2471 bool enchant(object_type *o_ptr, int n, int eflag)
2473 int i, chance, prob;
2475 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2476 bool force = (eflag & ENCH_FORCE);
2479 /* Large piles resist enchantment */
2480 prob = o_ptr->number * 100;
2482 /* Missiles are easy to enchant */
2483 if ((o_ptr->tval == TV_BOLT) ||
2484 (o_ptr->tval == TV_ARROW) ||
2485 (o_ptr->tval == TV_SHOT))
2491 for (i = 0; i < n; i++)
2493 /* Hack -- Roll for pile resistance */
2494 if (!force && randint0(prob) >= 100) continue;
2496 /* Enchant to hit */
2497 if (eflag & ENCH_TOHIT)
2499 if (o_ptr->to_h < 0) chance = 0;
2500 else if (o_ptr->to_h > 15) chance = 1000;
2501 else chance = enchant_table[o_ptr->to_h];
2503 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2508 /* only when you get it above -1 -CFT */
2509 if (o_ptr->to_h >= 0)
2514 /* Enchant to damage */
2515 if (eflag & ENCH_TODAM)
2517 if (o_ptr->to_d < 0) chance = 0;
2518 else if (o_ptr->to_d > 15) chance = 1000;
2519 else chance = enchant_table[o_ptr->to_d];
2521 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2526 /* only when you get it above -1 -CFT */
2527 if (o_ptr->to_d >= 0)
2532 /* Enchant to armor class */
2533 if (eflag & ENCH_TOAC)
2535 if (o_ptr->to_a < 0) chance = 0;
2536 else if (o_ptr->to_a > 15) chance = 1000;
2537 else chance = enchant_table[o_ptr->to_a];
2539 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2544 /* only when you get it above -1 -CFT */
2545 if (o_ptr->to_a >= 0)
2552 if (!res) return (FALSE);
2554 /* Recalculate bonuses */
2555 p_ptr->update |= (PU_BONUS);
2557 /* Combine / Reorder the pack (later) */
2558 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2561 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2572 * Enchant an item (in the inventory or on the floor)
2573 * Note that "num_ac" requires armour, else weapon
2574 * Returns TRUE if attempted, FALSE if cancelled
2576 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2581 char o_name[MAX_NLEN];
2585 /* Assume enchant weapon */
2586 item_tester_hook = item_tester_hook_weapon;
2587 item_tester_no_ryoute = TRUE;
2589 /* Enchant armor if requested */
2590 if (num_ac) item_tester_hook = item_tester_hook_armour;
2594 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2595 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2597 q = "Enchant which item? ";
2598 s = "You have nothing to enchant.";
2601 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2603 /* Get the item (in the pack) */
2606 o_ptr = &inventory[item];
2609 /* Get the item (on the floor) */
2612 o_ptr = &o_list[0 - item];
2617 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2621 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2624 msg_format("%s %s glow%s brightly!",
2625 ((item >= 0) ? "Your" : "The"), o_name,
2626 ((o_ptr->number > 1) ? "" : "s"));
2631 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2632 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2633 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2639 if (flush_failure) flush();
2643 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2645 msg_print("The enchantment failed.");
2648 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2651 chg_virtue(V_ENCHANT, 1);
2655 /* Something happened */
2660 bool artifact_scroll(void)
2665 char o_name[MAX_NLEN];
2669 item_tester_no_ryoute = TRUE;
2670 /* Enchant weapon/armour */
2671 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2675 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2676 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2678 q = "Enchant which item? ";
2679 s = "You have nothing to enchant.";
2682 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2684 /* Get the item (in the pack) */
2687 o_ptr = &inventory[item];
2690 /* Get the item (on the floor) */
2693 o_ptr = &o_list[0 - item];
2698 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2702 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2704 msg_format("%s %s radiate%s a blinding light!",
2705 ((item >= 0) ? "Your" : "The"), o_name,
2706 ((o_ptr->number > 1) ? "" : "s"));
2709 if (o_ptr->name1 || o_ptr->art_name)
2712 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2714 msg_format("The %s %s already %s!",
2715 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2716 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2722 else if (o_ptr->name2)
2725 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2727 msg_format("The %s %s already %s!",
2728 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2729 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2735 else if (o_ptr->xtra3)
2738 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2740 msg_format("The %s %s already %s!",
2741 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2742 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2748 if (o_ptr->number > 1)
2751 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2752 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2754 msg_print("Not enough enough energy to enchant more than one object!");
2755 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2760 inven_item_increase(item, 1-(o_ptr->number));
2764 floor_item_increase(0-item, 1-(o_ptr->number));
2767 okay = create_artifact(o_ptr, TRUE);
2774 if (flush_failure) flush();
2778 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2780 msg_print("The enchantment failed.");
2783 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2786 chg_virtue(V_ENCHANT, 1);
2790 /* Something happened */
2796 * Identify an object
2798 bool identify_item(object_type *o_ptr)
2800 bool old_known = FALSE;
2801 char o_name[MAX_NLEN];
2804 object_desc(o_name, o_ptr, 0);
2806 if (o_ptr->ident & IDENT_KNOWN)
2809 if (!(o_ptr->ident & (IDENT_MENTAL)))
2811 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2812 chg_virtue(V_KNOWLEDGE, 1);
2815 /* Identify it fully */
2816 object_aware(o_ptr);
2817 object_known(o_ptr);
2819 /* Recalculate bonuses */
2820 p_ptr->update |= (PU_BONUS);
2822 /* Combine / Reorder the pack (later) */
2823 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2826 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2828 strcpy(record_o_name, o_name);
2832 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2834 if(record_fix_art && !old_known && artifact_p(o_ptr))
2835 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2836 if(record_rand_art && !old_known && o_ptr->art_name)
2837 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2843 static bool item_tester_hook_identify(object_type *o_ptr)
2845 return (bool)!object_known_p(o_ptr);
2848 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2850 if (object_known_p(o_ptr))
2852 return item_tester_hook_weapon_armour(o_ptr);
2856 * Identify an object in the inventory (or on the floor)
2857 * This routine does *not* automatically combine objects.
2858 * Returns TRUE if something was identified, else FALSE.
2860 bool ident_spell(bool only_equip)
2864 char o_name[MAX_NLEN];
2868 item_tester_no_ryoute = TRUE;
2871 item_tester_hook = item_tester_hook_identify_weapon_armour;
2873 item_tester_hook = item_tester_hook_identify;
2875 if (!can_get_item())
2879 item_tester_hook = item_tester_hook_weapon_armour;
2883 item_tester_hook = NULL;
2889 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2890 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2892 q = "Identify which item? ";
2893 s = "You have nothing to identify.";
2896 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2898 /* Get the item (in the pack) */
2901 o_ptr = &inventory[item];
2904 /* Get the item (on the floor) */
2907 o_ptr = &o_list[0 - item];
2911 old_known = identify_item(o_ptr);
2914 object_desc(o_name, o_ptr, 0);
2917 if (item >= INVEN_RARM)
2920 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2922 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2928 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2930 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2936 msg_format("¾²¾å: %s¡£", o_name);
2938 msg_format("On the ground: %s.", o_name);
2942 /* Auto-inscription/destroy */
2943 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2945 /* Something happened */
2951 * Mundanify an object in the inventory (or on the floor)
2952 * This routine does *not* automatically combine objects.
2953 * Returns TRUE if something was mundanified, else FALSE.
2955 bool mundane_spell(bool only_equip)
2961 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
2962 item_tester_no_ryoute = TRUE;
2966 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2967 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2969 q = "Use which item? ";
2970 s = "You have nothing you can use.";
2973 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2975 /* Get the item (in the pack) */
2978 o_ptr = &inventory[item];
2981 /* Get the item (on the floor) */
2984 o_ptr = &o_list[0 - item];
2989 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2991 msg_print("There is a bright flash of light!");
2994 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2995 byte ix = o_ptr->ix; /* X-position on map, or zero */
2996 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2997 byte marked = o_ptr->marked; /* Object is marked */
2998 s16b weight = o_ptr->number * o_ptr->weight;
2999 u16b inscription = o_ptr->inscription;
3002 object_prep(o_ptr, o_ptr->k_idx);
3006 o_ptr->next_o_idx = next_o_idx;
3007 o_ptr->marked = marked;
3008 o_ptr->inscription = inscription;
3009 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
3013 /* Something happened */
3019 static bool item_tester_hook_identify_fully(object_type *o_ptr)
3021 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
3024 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
3026 if (!item_tester_hook_identify_fully(o_ptr))
3028 return item_tester_hook_weapon_armour(o_ptr);
3032 * Fully "identify" an object in the inventory -BEN-
3033 * This routine returns TRUE if an item was identified.
3035 bool identify_fully(bool only_equip)
3039 char o_name[MAX_NLEN];
3043 item_tester_no_ryoute = TRUE;
3045 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
3047 item_tester_hook = item_tester_hook_identify_fully;
3049 if (!can_get_item())
3052 item_tester_hook = item_tester_hook_weapon_armour;
3054 item_tester_hook = NULL;
3059 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
3060 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3062 q = "Identify which item? ";
3063 s = "You have nothing to identify.";
3066 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
3068 /* Get the item (in the pack) */
3071 o_ptr = &inventory[item];
3074 /* Get the item (on the floor) */
3077 o_ptr = &o_list[0 - item];
3081 old_known = identify_item(o_ptr);
3083 /* Mark the item as fully known */
3084 o_ptr->ident |= (IDENT_MENTAL);
3090 object_desc(o_name, o_ptr, 0);
3093 if (item >= INVEN_RARM)
3096 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
3098 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
3106 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
3108 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3114 msg_format("¾²¾å: %s¡£", o_name);
3116 msg_format("On the ground: %s.", o_name);
3120 /* Describe it fully */
3121 (void)screen_object(o_ptr, TRUE);
3123 /* Auto-inscription/destroy */
3124 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
3134 * Hook for "get_item()". Determine if something is rechargable.
3136 bool item_tester_hook_recharge(object_type *o_ptr)
3138 /* Recharge staffs */
3139 if (o_ptr->tval == TV_STAFF) return (TRUE);
3141 /* Recharge wands */
3142 if (o_ptr->tval == TV_WAND) return (TRUE);
3144 /* Hack -- Recharge rods */
3145 if (o_ptr->tval == TV_ROD) return (TRUE);
3153 * Recharge a wand/staff/rod from the pack or on the floor.
3154 * This function has been rewritten in Oangband and ZAngband.
3156 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3157 * Chaos -- Arcane Binding --> recharge(90)
3159 * Scroll of recharging --> recharge(130)
3160 * Artifact activation/Thingol --> recharge(130)
3162 * It is harder to recharge high level, and highly charged wands,
3163 * staffs, and rods. The more wands in a stack, the more easily and
3164 * strongly they recharge. Staffs, however, each get fewer charges if
3167 * XXX XXX XXX Beware of "sliding index errors".
3169 bool recharge(int power)
3172 int recharge_strength, recharge_amount;
3181 char o_name[MAX_NLEN];
3183 /* Only accept legal items */
3184 item_tester_hook = item_tester_hook_recharge;
3188 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3189 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3191 q = "Recharge which item? ";
3192 s = "You have nothing to recharge.";
3195 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3197 /* Get the item (in the pack) */
3200 o_ptr = &inventory[item];
3203 /* Get the item (on the floor) */
3206 o_ptr = &o_list[0 - item];
3209 /* Get the object kind. */
3210 k_ptr = &k_info[o_ptr->k_idx];
3212 /* Extract the object "level" */
3213 lev = get_object_level(o_ptr);
3216 /* Recharge a rod */
3217 if (o_ptr->tval == TV_ROD)
3219 /* Extract a recharge strength by comparing object level to power. */
3220 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3224 if (one_in_(recharge_strength))
3226 /* Activate the failure code. */
3233 /* Recharge amount */
3234 recharge_amount = (power * damroll(3, 2));
3236 /* Recharge by that amount */
3237 if (o_ptr->timeout > recharge_amount)
3238 o_ptr->timeout -= recharge_amount;
3245 /* Recharge wand/staff */
3248 /* Extract a recharge strength by comparing object level to power.
3249 * Divide up a stack of wands' charges to calculate charge penalty.
3251 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3252 recharge_strength = (100 + power - lev -
3253 (8 * o_ptr->pval / o_ptr->number)) / 15;
3255 /* All staffs, unstacked wands. */
3256 else recharge_strength = (100 + power - lev -
3257 (8 * o_ptr->pval)) / 15;
3260 if (recharge_strength < 0) recharge_strength = 0;
3263 if (one_in_(recharge_strength))
3265 /* Activate the failure code. */
3269 /* If the spell didn't backfire, recharge the wand or staff. */
3272 /* Recharge based on the standard number of charges. */
3273 recharge_amount = randint1(1 + k_ptr->pval / 2);
3275 /* Multiple wands in a stack increase recharging somewhat. */
3276 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3279 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3280 if (recharge_amount < 1) recharge_amount = 1;
3281 if (recharge_amount > 12) recharge_amount = 12;
3284 /* But each staff in a stack gets fewer additional charges,
3285 * although always at least one.
3287 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3289 recharge_amount /= o_ptr->number;
3290 if (recharge_amount < 1) recharge_amount = 1;
3293 /* Recharge the wand or staff. */
3294 o_ptr->pval += recharge_amount;
3297 /* Hack -- we no longer "know" the item */
3298 o_ptr->ident &= ~(IDENT_KNOWN);
3300 /* Hack -- we no longer think the item is empty */
3301 o_ptr->ident &= ~(IDENT_EMPTY);
3306 /* Inflict the penalties for failing a recharge. */
3309 /* Artifacts are never destroyed. */
3310 if (artifact_p(o_ptr))
3312 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3314 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3316 msg_format("The recharging backfires - %s is completely drained!", o_name);
3320 /* Artifact rods. */
3321 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3322 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3324 /* Artifact wands and staffs. */
3325 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3330 /* Get the object description */
3331 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3333 /*** Determine Seriousness of Failure ***/
3335 /* Mages recharge objects more safely. */
3336 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)
3338 /* 10% chance to blow up one rod, otherwise draining. */
3339 if (o_ptr->tval == TV_ROD)
3341 if (one_in_(10)) fail_type = 2;
3344 /* 75% chance to blow up one wand, otherwise draining. */
3345 else if (o_ptr->tval == TV_WAND)
3347 if (!one_in_(3)) fail_type = 2;
3350 /* 50% chance to blow up one staff, otherwise no effect. */
3351 else if (o_ptr->tval == TV_STAFF)
3353 if (one_in_(2)) fail_type = 2;
3358 /* All other classes get no special favors. */
3361 /* 33% chance to blow up one rod, otherwise draining. */
3362 if (o_ptr->tval == TV_ROD)
3364 if (one_in_(3)) fail_type = 2;
3367 /* 20% chance of the entire stack, else destroy one wand. */
3368 else if (o_ptr->tval == TV_WAND)
3370 if (one_in_(5)) fail_type = 3;
3373 /* Blow up one staff. */
3374 else if (o_ptr->tval == TV_STAFF)
3380 /*** Apply draining and destruction. ***/
3382 /* Drain object or stack of objects. */
3385 if (o_ptr->tval == TV_ROD)
3388 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3390 msg_print("The recharge backfires, draining the rod further!");
3393 if (o_ptr->timeout < 10000)
3394 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3396 else if (o_ptr->tval == TV_WAND)
3399 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3401 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3406 /* Staffs aren't drained. */
3409 /* Destroy an object or one in a stack of objects. */
3412 if (o_ptr->number > 1)
3414 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3416 msg_format("Wild magic consumes one of your %s!", o_name);
3421 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3423 msg_format("Wild magic consumes your %s!", o_name);
3427 /* Reduce rod stack maximum timeout, drain wands. */
3428 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3429 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3431 /* Reduce and describe inventory */
3434 inven_item_increase(item, -1);
3435 inven_item_describe(item);
3436 inven_item_optimize(item);
3439 /* Reduce and describe floor item */
3442 floor_item_increase(0 - item, -1);
3443 floor_item_describe(0 - item);
3444 floor_item_optimize(0 - item);
3448 /* Destroy all members of a stack of objects. */
3451 if (o_ptr->number > 1)
3453 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3455 msg_format("Wild magic consumes all your %s!", o_name);
3460 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3462 msg_format("Wild magic consumes your %s!", o_name);
3467 /* Reduce and describe inventory */
3470 inven_item_increase(item, -999);
3471 inven_item_describe(item);
3472 inven_item_optimize(item);
3475 /* Reduce and describe floor item */
3478 floor_item_increase(0 - item, -999);
3479 floor_item_describe(0 - item);
3480 floor_item_optimize(0 - item);
3486 /* Combine / Reorder the pack (later) */
3487 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3490 p_ptr->window |= (PW_INVEN);
3492 /* Something was done */
3500 bool bless_weapon(void)
3504 u32b flgs[TR_FLAG_SIZE];
3505 char o_name[MAX_NLEN];
3508 item_tester_no_ryoute = TRUE;
3509 /* Assume enchant weapon */
3510 item_tester_hook = item_tester_hook_weapon2;
3514 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3515 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3517 q = "Bless which weapon? ";
3518 s = "You have weapon to bless.";
3521 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3524 /* Get the item (in the pack) */
3527 o_ptr = &inventory[item];
3530 /* Get the item (on the floor) */
3533 o_ptr = &o_list[0 - item];
3538 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3540 /* Extract the flags */
3541 object_flags(o_ptr, flgs);
3543 if (cursed_p(o_ptr))
3545 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3546 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3549 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3552 msg_format("The black aura on %s %s disrupts the blessing!",
3553 ((item >= 0) ? "your" : "the"), o_name);
3560 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3563 msg_format("A malignant aura leaves %s %s.",
3564 ((item >= 0) ? "your" : "the"), o_name);
3569 o_ptr->curse_flags = 0L;
3571 /* Hack -- Assume felt */
3572 o_ptr->ident |= (IDENT_SENSE);
3575 o_ptr->feeling = FEEL_NONE;
3577 /* Recalculate the bonuses */
3578 p_ptr->update |= (PU_BONUS);
3581 p_ptr->window |= (PW_EQUIP);
3585 * Next, we try to bless it. Artifacts have a 1/3 chance of
3586 * being blessed, otherwise, the operation simply disenchants
3587 * them, godly power negating the magic. Ok, the explanation
3588 * is silly, but otherwise priests would always bless every
3589 * artifact weapon they find. Ego weapons and normal weapons
3590 * can be blessed automatically.
3592 if (have_flag(flgs, TR_BLESSED))
3595 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3598 msg_format("%s %s %s blessed already.",
3599 ((item >= 0) ? "Your" : "The"), o_name,
3600 ((o_ptr->number > 1) ? "were" : "was"));
3606 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3610 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3613 msg_format("%s %s shine%s!",
3614 ((item >= 0) ? "Your" : "The"), o_name,
3615 ((o_ptr->number > 1) ? "" : "s"));
3618 add_flag(o_ptr->art_flags, TR_BLESSED);
3619 o_ptr->discount = 99;
3623 bool dis_happened = FALSE;
3626 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3628 msg_print("The weapon resists your blessing!");
3632 /* Disenchant tohit */
3633 if (o_ptr->to_h > 0)
3636 dis_happened = TRUE;
3639 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3641 /* Disenchant todam */
3642 if (o_ptr->to_d > 0)
3645 dis_happened = TRUE;
3648 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3650 /* Disenchant toac */
3651 if (o_ptr->to_a > 0)
3654 dis_happened = TRUE;
3657 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3662 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3664 msg_print("There is a static feeling in the air...");
3668 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3671 msg_format("%s %s %s disenchanted!",
3672 ((item >= 0) ? "Your" : "The"), o_name,
3673 ((o_ptr->number > 1) ? "were" : "was"));
3679 /* Recalculate bonuses */
3680 p_ptr->update |= (PU_BONUS);
3683 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3694 bool pulish_shield(void)
3698 u32b flgs[TR_FLAG_SIZE];
3699 char o_name[MAX_NLEN];
3702 item_tester_no_ryoute = TRUE;
3703 /* Assume enchant weapon */
3704 item_tester_tval = TV_SHIELD;
3708 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3709 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3711 q = "Pulish which weapon? ";
3712 s = "You have weapon to pulish.";
3715 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3718 /* Get the item (in the pack) */
3721 o_ptr = &inventory[item];
3724 /* Get the item (on the floor) */
3727 o_ptr = &o_list[0 - item];
3732 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3734 /* Extract the flags */
3735 object_flags(o_ptr, flgs);
3737 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3738 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3741 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3743 msg_format("%s %s shine%s!",
3744 ((item >= 0) ? "Your" : "The"), o_name,
3745 ((o_ptr->number > 1) ? "" : "s"));
3747 o_ptr->name2 = EGO_REFLECTION;
3748 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3750 o_ptr->discount = 99;
3751 chg_virtue(V_ENCHANT, 2);
3757 if (flush_failure) flush();
3760 msg_print("¼ºÇÔ¤·¤¿¡£");
3762 msg_print("Failed.");
3765 chg_virtue(V_ENCHANT, -2);
3774 * Potions "smash open" and cause an area effect when
3775 * (1) they are shattered while in the player's inventory,
3776 * due to cold (etc) attacks;
3777 * (2) they are thrown at a monster, or obstacle;
3778 * (3) they are shattered by a "cold ball" or other such spell
3779 * while lying on the floor.
3782 * who --- who caused the potion to shatter (0=player)
3783 * potions that smash on the floor are assumed to
3784 * be caused by no-one (who = 1), as are those that
3785 * shatter inside the player inventory.
3786 * (Not anymore -- I changed this; TY)
3787 * y, x --- coordinates of the potion (or player if
3788 * the potion was in her inventory);
3789 * o_ptr --- pointer to the potion object.
3791 bool potion_smash_effect(int who, int y, int x, int k_idx)
3798 object_kind *k_ptr = &k_info[k_idx];
3800 switch (k_ptr->sval)
3802 case SV_POTION_SALT_WATER:
3803 case SV_POTION_SLIME_MOLD:
3804 case SV_POTION_LOSE_MEMORIES:
3805 case SV_POTION_DEC_STR:
3806 case SV_POTION_DEC_INT:
3807 case SV_POTION_DEC_WIS:
3808 case SV_POTION_DEC_DEX:
3809 case SV_POTION_DEC_CON:
3810 case SV_POTION_DEC_CHR:
3811 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3812 case SV_POTION_APPLE_JUICE:
3815 case SV_POTION_INFRAVISION:
3816 case SV_POTION_DETECT_INVIS:
3817 case SV_POTION_SLOW_POISON:
3818 case SV_POTION_CURE_POISON:
3819 case SV_POTION_BOLDNESS:
3820 case SV_POTION_RESIST_HEAT:
3821 case SV_POTION_RESIST_COLD:
3822 case SV_POTION_HEROISM:
3823 case SV_POTION_BESERK_STRENGTH:
3824 case SV_POTION_RES_STR:
3825 case SV_POTION_RES_INT:
3826 case SV_POTION_RES_WIS:
3827 case SV_POTION_RES_DEX:
3828 case SV_POTION_RES_CON:
3829 case SV_POTION_RES_CHR:
3830 case SV_POTION_INC_STR:
3831 case SV_POTION_INC_INT:
3832 case SV_POTION_INC_WIS:
3833 case SV_POTION_INC_DEX:
3834 case SV_POTION_INC_CON:
3835 case SV_POTION_INC_CHR:
3836 case SV_POTION_AUGMENTATION:
3837 case SV_POTION_ENLIGHTENMENT:
3838 case SV_POTION_STAR_ENLIGHTENMENT:
3839 case SV_POTION_SELF_KNOWLEDGE:
3840 case SV_POTION_EXPERIENCE:
3841 case SV_POTION_RESISTANCE:
3842 case SV_POTION_INVULNERABILITY:
3843 case SV_POTION_NEW_LIFE:
3844 /* All of the above potions have no effect when shattered */
3846 case SV_POTION_SLOWNESS:
3851 case SV_POTION_POISON:
3856 case SV_POTION_BLINDNESS:
3860 case SV_POTION_CONFUSION: /* Booze */
3864 case SV_POTION_SLEEP:
3868 case SV_POTION_RUINATION:
3869 case SV_POTION_DETONATIONS:
3871 dam = damroll(25, 25);
3874 case SV_POTION_DEATH:
3875 dt = GF_DEATH_RAY; /* !! */
3876 dam = k_ptr->level * 10;
3880 case SV_POTION_SPEED:
3883 case SV_POTION_CURE_LIGHT:
3885 dam = damroll(2, 3);
3887 case SV_POTION_CURE_SERIOUS:
3889 dam = damroll(4, 3);
3891 case SV_POTION_CURE_CRITICAL:
3892 case SV_POTION_CURING:
3894 dam = damroll(6, 3);
3896 case SV_POTION_HEALING:
3898 dam = damroll(10, 10);
3900 case SV_POTION_RESTORE_EXP:
3905 case SV_POTION_LIFE:
3907 dam = damroll(50, 50);
3910 case SV_POTION_STAR_HEALING:
3912 dam = damroll(50, 50);
3915 case SV_POTION_RESTORE_MANA: /* MANA */
3917 dam = damroll(10, 10);
3924 (void)project(who, radius, y, x, dam, dt,
3925 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3927 /* XXX those potions that explode need to become "known" */
3933 * Hack -- Display all known spells in a window
3935 * XXX XXX XXX Need to analyze size of the window.
3937 * XXX XXX XXX Need more color coding.
3939 void display_spell_list(void)
3952 /* They have too many spells to list */
3953 if (p_ptr->pclass == CLASS_SORCERER) return;
3954 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3956 /* mind.c type classes */
3957 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3958 (p_ptr->pclass == CLASS_BERSERKER) ||
3959 (p_ptr->pclass == CLASS_NINJA) ||
3960 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3961 (p_ptr->pclass == CLASS_FORCETRAINER))
3967 int plev = p_ptr->lev;
3973 bool use_hp = FALSE;
3975 /* Display a list of spells */
3978 put_str("̾Á°", y, x + 5);
3979 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3981 put_str("Name", y, x + 5);
3982 put_str("Lv Mana Fail Info", y, x + 35);
3985 switch(p_ptr->pclass)
3987 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3988 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3989 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3990 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3991 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3992 default: use_mind = 0;break;
3995 /* Dump the spells */
3996 for (i = 0; i < MAX_MIND_POWERS; i++)
3998 byte a = TERM_WHITE;
4000 /* Access the available spell */
4001 spell = mind_powers[use_mind].info[i];
4002 if (spell.min_lev > plev) break;
4004 /* Get the failure rate */
4005 chance = spell.fail;
4007 /* Reduce failure rate by "effective" level adjustment */
4008 chance -= 3 * (p_ptr->lev - spell.min_lev);
4010 /* Reduce failure rate by INT/WIS adjustment */
4011 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4015 /* Not enough mana to cast */
4016 if (spell.mana_cost > p_ptr->csp)
4018 chance += 5 * (spell.mana_cost - p_ptr->csp);
4024 /* Not enough hp to cast */
4025 if (spell.mana_cost > p_ptr->chp)
4032 /* Extract the minimum failure rate */
4033 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4035 /* Minimum failure rate */
4036 if (chance < minfail) chance = minfail;
4038 /* Stunning makes spells harder */
4039 if (p_ptr->stun > 50) chance += 25;
4040 else if (p_ptr->stun) chance += 15;
4042 /* Always a 5 percent chance of working */
4043 if (chance > 95) chance = 95;
4046 mindcraft_info(comment, use_mind, i);
4048 /* Dump the spell */
4049 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
4051 spell.min_lev, spell.mana_cost, chance, comment);
4053 Term_putstr(x, y + i + 1, -1, a, psi_desc);
4058 /* Cannot read spellbooks */
4059 if (REALM_NONE == p_ptr->realm1) return;
4061 /* Normal spellcaster with books */
4064 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
4068 /* Reset vertical */
4071 /* Vertical location */
4072 y = (j < 3) ? 0 : (m[j - 3] + 2);
4074 /* Horizontal location */
4078 for (i = 0; i < 32; i++)
4080 byte a = TERM_WHITE;
4082 /* Access the spell */
4083 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
4085 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
4089 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
4092 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
4095 if (s_ptr->slevel >= 99)
4099 strcpy(name, "(ȽÆÉÉÔǽ)");
4101 strcpy(name, "(illegible)");
4111 ((p_ptr->spell_forgotten1 & (1L << i))) :
4112 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4119 else if (!((j < 1) ?
4120 (p_ptr->spell_learned1 & (1L << i)) :
4121 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4128 else if (!((j < 1) ?
4129 (p_ptr->spell_worked1 & (1L << i)) :
4130 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4136 /* Dump the spell --(-- */
4137 sprintf(out_val, "%c/%c) %-20.20s",
4138 I2A(n / 8), I2A(n % 8), name);
4143 /* Dump onto the window */
4144 Term_putstr(x, m[j], -1, a, out_val);
4154 * Returns experience of a spell
4156 s16b experience_of_spell(int spell, int use_realm)
4158 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4159 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4160 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4161 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4167 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4169 int mod_need_mana(int need_mana, int spell, int realm)
4171 #define MANA_CONST 2400
4173 #define DEC_MANA_DIV 3
4176 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4179 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4180 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4182 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4183 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4184 need_mana /= MANA_CONST * MANA_DIV;
4185 if (need_mana < 1) need_mana = 1;
4188 /* Non-realm magic */
4191 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4203 * Modify spell fail rate
4204 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4206 int mod_spell_chance_1(int chance)
4208 chance += p_ptr->to_m_chance;
4210 if (p_ptr->heavy_spell) chance += 20;
4212 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4213 else if (p_ptr->easy_spell) chance -= 3;
4214 else if (p_ptr->dec_mana) chance -= 2;
4221 * Modify spell fail rate (as "suffix" process)
4222 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4223 * Note: variable "chance" cannot be negative.
4225 int mod_spell_chance_2(int chance)
4227 if (p_ptr->dec_mana) chance--;
4229 if (p_ptr->heavy_spell) chance += 5;
4231 return MAX(chance, 0);
4236 * Returns spell chance of failure for spell -RAK-
4238 s16b spell_chance(int spell, int use_realm)
4240 int chance, minfail;
4243 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4246 /* Paranoia -- must be literate */
4247 if (!mp_ptr->spell_book) return (100);
4249 if (use_realm == REALM_HISSATSU) return 0;
4251 /* Access the spell */
4252 if (!is_magic(use_realm))
4254 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4258 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4261 /* Extract the base spell failure rate */
4262 chance = s_ptr->sfail;
4264 /* Reduce failure rate by "effective" level adjustment */
4265 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4267 /* Reduce failure rate by INT/WIS adjustment */
4268 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4271 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4273 /* Extract mana consumption rate */
4274 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4276 /* Not enough mana to cast */
4277 if (need_mana > p_ptr->csp)
4279 chance += 5 * (need_mana - p_ptr->csp);
4282 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4284 /* Extract the minimum failure rate */
4285 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4288 * Non mage/priest characters never get too good
4289 * (added high mage, mindcrafter)
4291 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4293 if (minfail < 5) minfail = 5;
4296 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4297 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4298 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4300 chance = mod_spell_chance_1(chance);
4302 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4303 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4304 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4306 /* Minimum failure rate */
4307 if (chance < minfail) chance = minfail;
4309 /* Stunning makes spells harder */
4310 if (p_ptr->stun > 50) chance += 25;
4311 else if (p_ptr->stun) chance += 15;
4313 /* Always a 5 percent chance of working */
4314 if (chance > 95) chance = 95;
4316 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4317 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4319 s16b exp = experience_of_spell(spell, use_realm);
4320 if (exp >= SPELL_EXP_EXPERT) chance--;
4321 if (exp >= SPELL_EXP_MASTER) chance--;
4324 /* Return the chance */
4325 return mod_spell_chance_2(chance);
4331 * Determine if a spell is "okay" for the player to cast or study
4332 * The spell must be legible, not forgotten, and also, to cast,
4333 * it must be known, and to study, it must not be known.
4335 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4339 /* Access the spell */
4340 if (!is_magic(use_realm))
4342 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4346 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4349 /* Spell is illegal */
4350 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4352 /* Spell is forgotten */
4353 if ((use_realm == p_ptr->realm2) ?
4354 (p_ptr->spell_forgotten2 & (1L << spell)) :
4355 (p_ptr->spell_forgotten1 & (1L << spell)))
4361 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4362 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4364 /* Spell is learned */
4365 if ((use_realm == p_ptr->realm2) ?
4366 (p_ptr->spell_learned2 & (1L << spell)) :
4367 (p_ptr->spell_learned1 & (1L << spell)))
4370 return (!study_pray);
4373 /* Okay to study, not to cast */
4380 * Extra information on a spell -DRS-
4382 * We can use up to 14 characters of the buffer 'p'
4384 * The strings in this function were extracted from the code in the
4385 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4387 static void spell_info(char *p, int spell, int use_realm)
4389 int plev = p_ptr->lev;
4392 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4393 p_ptr->pclass == CLASS_HIGH_MAGE ||
4394 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4396 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4397 p_ptr->pclass == CLASS_HIGH_MAGE ||
4398 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4400 cptr s_dam = "»½ý:";
4401 cptr s_dur = "´ü´Ö:";
4402 cptr s_range = "ÈÏ°Ï:";
4403 cptr s_heal = "²óÉü:";
4404 cptr s_random = "¥é¥ó¥À¥à";
4405 cptr s_delay = "ÃÙ±ä:";
4407 cptr s_dam = "dam ";
4408 cptr s_dur = "dur ";
4409 cptr s_range = "range ";
4410 cptr s_heal = "heal ";
4411 cptr s_random = "random";
4412 cptr s_delay = "delay ";
4417 /* Analyze the spell */
4420 case REALM_LIFE: /* Life */
4423 case 0: sprintf(p, " %s2d10", s_heal); break;
4424 case 1: sprintf(p, " %s12+d12", s_dur); break;
4425 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4426 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4427 case 5: sprintf(p, " %s4d10", s_heal); break;
4428 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4429 case 10: sprintf(p, " %s8d10", s_heal); break;
4430 case 11: sprintf(p, " %s20+d20", s_dur); break;
4431 case 14: sprintf(p, " %s300", s_heal); break;
4432 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4433 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4434 case 21: sprintf(p, " %s15+d21", s_delay); break;
4435 case 29: sprintf(p, " %s2000", s_heal); break;
4436 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4440 case REALM_SORCERY: /* Sorcery */
4443 case 1: sprintf(p, " %s10", s_range); break;
4444 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4445 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4446 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4447 case 18: sprintf(p, " %s25+d30", s_dur); break;
4448 case 22: sprintf(p, " %s15+d21", s_delay); break;
4449 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4450 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4452 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4454 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4456 case 27: sprintf(p, " %s25+d30", s_dur); break;
4457 case 31: sprintf(p, " %s4+d4", s_dur); break;
4461 case REALM_NATURE: /* Nature */
4465 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4467 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4469 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4470 case 6: sprintf(p, " %s20+d20", s_dur); break;
4471 case 7: sprintf(p, " %s2d8", s_heal); break;
4472 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4473 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4474 case 12: sprintf(p, " %s6d8", s_dam); break;
4475 case 15: sprintf(p, " %s500", s_heal); break;
4476 case 17: sprintf(p, " %s20+d30", s_dur); break;
4477 case 18: sprintf(p, " %s20+d20", s_dur); break;
4479 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4481 case 24: sprintf(p, " rad 10"); break;
4483 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4484 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4485 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4486 case 29: sprintf(p, " %s75", s_dam); break;
4487 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4491 case REALM_CHAOS: /* Chaos */
4494 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4495 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4496 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4497 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4498 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4499 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4500 case 8: sprintf(p, " %s", s_random); break;
4501 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4502 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4503 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4504 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4505 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4506 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4507 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4508 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4509 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4511 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4513 case 25: sprintf(p, " dam %d each", plev * 2); break;
4515 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4516 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4517 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4518 case 30: sprintf(p, " %s%d", s_dam, p_ptr->chp); break;
4519 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4523 case REALM_DEATH: /* Death */
4526 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4527 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4528 case 5: sprintf(p, " %s20+d20", s_dur); break;
4529 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4530 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4531 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4533 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4535 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4537 case 16: sprintf(p, " %s25+d25", s_dur); break;
4538 case 17: sprintf(p, " %s", s_random); break;
4539 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4540 case 19: sprintf(p, " %s25+d25", s_dur); break;
4541 case 21: sprintf(p, " %s3*100", s_dam); break;
4542 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4543 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4544 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4545 case 30: sprintf(p, " %s666", s_dam); break;
4546 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4550 case REALM_TRUMP: /* Trump */
4553 case 0: sprintf(p, " %s10", s_range); break;
4554 case 2: sprintf(p, " %s", s_random); break;
4555 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4556 case 5: sprintf(p, " %s25+d30", s_dur); break;
4558 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4560 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4562 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4563 case 14: sprintf(p, " %s15+d21", s_delay); break;
4564 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4566 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4568 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4573 case REALM_ARCANE: /* Arcane */
4576 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4577 case 4: sprintf(p, " %s10", s_range); break;
4578 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4579 case 7: sprintf(p, " %s2d8", s_heal); break;
4583 case 17: sprintf(p, " %s20+d20", s_dur); break;
4584 case 18: sprintf(p, " %s4d8", s_heal); break;
4585 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4586 case 21: sprintf(p, " %s6d8", s_dam); break;
4587 case 24: sprintf(p, " %s24+d24", s_dur); break;
4588 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4589 case 30: sprintf(p, " %s15+d21", s_delay); break;
4590 case 31: sprintf(p, " %s25+d30", s_dur); break;
4594 case REALM_ENCHANT: /* Craft */
4597 case 0: sprintf(p, " %s100+d100", s_dur); break;
4598 case 1: sprintf(p, " %s80+d80", s_dur); break;
4604 case 18: sprintf(p, " %s20+d20", s_dur); break;
4605 case 5: sprintf(p, " %s25+d25", s_dur); break;
4606 case 8: sprintf(p, " %s24+d24", s_dur); break;
4607 case 11: sprintf(p, " %s25+d25", s_dur); break;
4608 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4609 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4610 case 16: sprintf(p, " %s25+d30", s_dur); break;
4611 case 17: sprintf(p, " %s30+d20", s_dur); break;
4612 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4613 case 20: sprintf(p, " %s50+d50", s_dur); break;
4614 case 23: sprintf(p, " %s20+d20", s_dur); break;
4615 case 31: sprintf(p, " %s13+d13", s_dur); break;
4619 case REALM_DAEMON: /* Daemon */
4622 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4623 case 2: sprintf(p, " %s12+d12", s_dur); break;
4624 case 3: sprintf(p, " %s20+d20", s_dur); break;
4625 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4626 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4627 case 10: sprintf(p, " %s20+d20", s_dur); break;
4628 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4629 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4630 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4631 case 16: sprintf(p, " %s30+d25", s_dur); break;
4632 case 17: sprintf(p, " %s20+d20", s_dur); break;
4633 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4634 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4635 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4636 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4637 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4638 case 24: sprintf(p, " %s25+d25", s_dur); break;
4639 case 25: sprintf(p, " %s20+d20", s_dur); break;
4640 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4641 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4642 case 30: sprintf(p, " %s600", s_dam); break;
4643 case 31: sprintf(p, " %s15+d15", s_dur); break;
4647 case REALM_CRUSADE: /* Crusade */
4650 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4651 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4653 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4655 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4657 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4658 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4659 case 12: sprintf(p, " %s24+d24", s_dur); break;
4660 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4661 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4663 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4665 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4667 case 18: sprintf(p, " %s18+d18", s_dur); break;
4668 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4669 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4670 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4671 case 24: sprintf(p, " %s25+d25", s_dur); break;
4672 case 28: sprintf(p, " %s10+d10", s_dur); break;
4674 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4676 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4679 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4681 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4686 case REALM_MUSIC: /* Music */
4689 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4690 case 4 : sprintf(p, " %s2d6", s_heal); break;
4691 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4692 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4693 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4694 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4695 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4696 case 28: sprintf(p, " %s15d10", s_heal); break;
4697 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4702 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4704 sprintf(p, "Unknown type: %d.", use_realm);
4711 * Print a list of spells (for browsing or casting or viewing)
4713 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4715 int i, spell, exp_level, increment = 64;
4727 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4729 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4731 msg_print("Warning! print_spells called with null realm");
4735 /* Title the list */
4737 if (use_realm == REALM_HISSATSU)
4739 strcpy(buf," Lv MP");
4741 strcpy(buf," Lv SP");
4745 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4747 strcpy(buf,"Profic Lv SP Fail Effect");
4751 put_str("̾Á°", y, x + 5);
4752 put_str(buf, y, x + 29);
4754 put_str("Name", y, x + 5);
4755 put_str(buf, y, x + 29);
4758 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4759 else if (use_realm == p_ptr->realm1) increment = 0;
4760 else if (use_realm == p_ptr->realm2) increment = 32;
4762 /* Dump the spells */
4763 for (i = 0; i < num; i++)
4765 /* Access the spell */
4768 /* Access the spell */
4769 if (!is_magic(use_realm))
4771 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4775 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4778 if (use_realm == REALM_HISSATSU)
4779 need_mana = s_ptr->smana;
4782 s16b exp = experience_of_spell(spell, use_realm);
4784 /* Extract mana consumption rate */
4785 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4787 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4788 else exp_level = spell_exp_level(exp);
4791 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4792 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4793 else if (s_ptr->slevel >= 99) max = TRUE;
4794 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4796 strncpy(ryakuji, exp_level_str[exp_level], 4);
4801 if (use_menu && target_spell)
4803 if (i == (target_spell-1))
4805 strcpy(out_val, " ¡Õ ");
4807 strcpy(out_val, " > ");
4810 strcpy(out_val, " ");
4812 else sprintf(out_val, " %c) ", I2A(i));
4813 /* Skip illegible spells */
4814 if (s_ptr->slevel >= 99)
4817 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4819 strcat(out_val, format("%-30s", "(illegible)"));
4822 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4826 /* XXX XXX Could label spells above the players level */
4828 /* Get extra info */
4829 spell_info(info, spell, use_realm);
4834 /* Assume spell is known and tried */
4835 line_attr = TERM_WHITE;
4837 /* Analyze the spell */
4838 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4840 if (s_ptr->slevel > p_ptr->max_plv)
4845 comment = " unknown";
4848 line_attr = TERM_L_BLUE;
4850 else if (s_ptr->slevel > p_ptr->lev)
4855 comment = " forgotten";
4858 line_attr = TERM_YELLOW;
4861 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4866 comment = " unknown";
4869 line_attr = TERM_L_BLUE;
4871 else if ((use_realm == p_ptr->realm1) ?
4872 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4873 ((p_ptr->spell_forgotten2 & (1L << spell))))
4878 comment = " forgotten";
4881 line_attr = TERM_YELLOW;
4883 else if (!((use_realm == p_ptr->realm1) ?
4884 (p_ptr->spell_learned1 & (1L << spell)) :
4885 (p_ptr->spell_learned2 & (1L << spell))))
4890 comment = " unknown";
4893 line_attr = TERM_L_BLUE;
4895 else if (!((use_realm == p_ptr->realm1) ?
4896 (p_ptr->spell_worked1 & (1L << spell)) :
4897 (p_ptr->spell_worked2 & (1L << spell))))
4900 comment = " ̤·Ð¸³";
4902 comment = " untried";
4905 line_attr = TERM_L_GREEN;
4908 /* Dump the spell --(-- */
4909 if (use_realm == REALM_HISSATSU)
4911 strcat(out_val, format("%-25s %2d %4d",
4912 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4913 s_ptr->slevel, need_mana));
4917 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4918 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4919 (max ? '!' : ' '), ryakuji,
4920 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4922 c_prt(line_attr, out_val, y + i + 1, x);
4925 /* Clear the bottom line */
4926 prt("", y + i + 1, x);
4931 * Note that amulets, rods, and high-level spell books are immune
4932 * to "inventory damage" of any kind. Also sling ammo and shovels.
4937 * Does a given class of objects (usually) hate acid?
4938 * Note that acid can either melt or corrode something.
4940 bool hates_acid(object_type *o_ptr)
4942 /* Analyze the type */
4943 switch (o_ptr->tval)
4945 /* Wearable items */
4965 /* Staffs/Scrolls are wood/paper */
4978 /* Junk is useless */
4992 * Does a given object (usually) hate electricity?
4994 bool hates_elec(object_type *o_ptr)
4996 switch (o_ptr->tval)
5010 * Does a given object (usually) hate fire?
5011 * Hafted/Polearm weapons have wooden shafts.
5012 * Arrows/Bows are mostly wooden.
5014 bool hates_fire(object_type *o_ptr)
5016 /* Analyze the type */
5017 switch (o_ptr->tval)
5035 case TV_SORCERY_BOOK:
5036 case TV_NATURE_BOOK:
5040 case TV_ARCANE_BOOK:
5041 case TV_ENCHANT_BOOK:
5042 case TV_DAEMON_BOOK:
5043 case TV_CRUSADE_BOOK:
5045 case TV_HISSATSU_BOOK:
5056 /* Staffs/Scrolls burn */
5069 * Does a given object (usually) hate cold?
5071 bool hates_cold(object_type *o_ptr)
5073 switch (o_ptr->tval)
5090 int set_acid_destroy(object_type *o_ptr)
5092 u32b flgs[TR_FLAG_SIZE];
5093 if (!hates_acid(o_ptr)) return (FALSE);
5094 object_flags(o_ptr, flgs);
5095 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
5103 int set_elec_destroy(object_type *o_ptr)
5105 u32b flgs[TR_FLAG_SIZE];
5106 if (!hates_elec(o_ptr)) return (FALSE);
5107 object_flags(o_ptr, flgs);
5108 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
5116 int set_fire_destroy(object_type *o_ptr)
5118 u32b flgs[TR_FLAG_SIZE];
5119 if (!hates_fire(o_ptr)) return (FALSE);
5120 object_flags(o_ptr, flgs);
5121 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
5129 int set_cold_destroy(object_type *o_ptr)
5131 u32b flgs[TR_FLAG_SIZE];
5132 if (!hates_cold(o_ptr)) return (FALSE);
5133 object_flags(o_ptr, flgs);
5134 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
5140 * Destroys a type of item on a given percent chance
5141 * Note that missiles are no longer necessarily all destroyed
5142 * Destruction taken from "melee.c" code for "stealing".
5143 * New-style wands and rods handled correctly. -LM-
5144 * Returns number of items destroyed.
5146 int inven_damage(inven_func typ, int perc)
5150 char o_name[MAX_NLEN];
5152 /* Multishadow effects is determined by turn */
5153 if( p_ptr->multishadow && (turn & 1) )return 0;
5155 if (p_ptr->inside_arena) return 0;
5157 /* Count the casualties */
5160 /* Scan through the slots backwards */
5161 for (i = 0; i < INVEN_PACK; i++)
5163 o_ptr = &inventory[i];
5165 /* Skip non-objects */
5166 if (!o_ptr->k_idx) continue;
5168 /* Hack -- for now, skip artifacts */
5169 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
5171 /* Give this item slot a shot at death */
5174 /* Count the casualties */
5175 for (amt = j = 0; j < o_ptr->number; ++j)
5177 if (randint0(100) < perc) amt++;
5180 /* Some casualities */
5183 /* Get a description */
5184 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5188 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
5190 msg_format("%sour %s (%c) %s destroyed!",
5194 o_name, index_to_label(i),
5195 ((o_ptr->number > 1) ?
5196 ((amt == o_ptr->number) ? "Á´Éô" :
5197 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
5199 ((o_ptr->number > 1) ?
5200 ((amt == o_ptr->number) ? "All of y" :
5201 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
5202 o_name, index_to_label(i),
5203 ((amt > 1) ? "were" : "was"));
5207 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
5208 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
5211 /* Potions smash open */
5212 if (object_is_potion(o_ptr))
5214 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
5217 /* Reduce the charges of rods/wands */
5218 reduce_charges(o_ptr, amt);
5220 /* Destroy "amt" items */
5221 inven_item_increase(i, -amt);
5222 inven_item_optimize(i);
5224 /* Count the casualties */
5230 /* Return the casualty count */
5236 * Acid has hit the player, attempt to affect some armor.
5238 * Note that the "base armor" of an object never changes.
5240 * If any armor is damaged (or resists), the player takes less damage.
5242 static int minus_ac(void)
5244 object_type *o_ptr = NULL;
5245 u32b flgs[TR_FLAG_SIZE];
5246 char o_name[MAX_NLEN];
5249 /* Pick a (possibly empty) inventory slot */
5250 switch (randint1(7))
5252 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5253 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5254 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5255 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5256 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5257 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5258 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5261 /* Nothing to damage */
5262 if (!o_ptr->k_idx) return (FALSE);
5264 if (o_ptr->tval <= TV_WEAPON_END) return (FALSE);
5266 /* No damage left to be done */
5267 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5271 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5273 /* Extract the flags */
5274 object_flags(o_ptr, flgs);
5276 /* Object resists */
5277 if (have_flag(flgs, TR_IGNORE_ACID))
5280 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5282 msg_format("Your %s is unaffected!", o_name);
5291 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5293 msg_format("Your %s is damaged!", o_name);
5297 /* Damage the item */
5300 /* Calculate bonuses */
5301 p_ptr->update |= (PU_BONUS);
5304 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5308 /* Item was damaged */
5314 * Hurt the player with Acid
5316 int acid_dam(int dam, cptr kb_str, int monspell)
5319 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5320 bool double_resist = IS_OPPOSE_ACID();
5322 /* Total Immunity */
5323 if (p_ptr->immune_acid || (dam <= 0))
5325 learn_spell(monspell);
5329 /* Vulnerability (Ouch!) */
5330 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5331 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5333 /* Resist the damage */
5334 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5335 if (double_resist) dam = (dam + 2) / 3;
5337 if ((!(double_resist || p_ptr->resist_acid)) &&
5338 one_in_(HURT_CHANCE))
5339 (void)do_dec_stat(A_CHR);
5341 /* If any armor gets hit, defend the player */
5342 if (minus_ac()) dam = (dam + 1) / 2;
5345 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5347 /* Inventory damage */
5348 if (!(double_resist && p_ptr->resist_acid))
5349 inven_damage(set_acid_destroy, inv);
5355 * Hurt the player with electricity
5357 int elec_dam(int dam, cptr kb_str, int monspell)
5360 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5361 bool double_resist = IS_OPPOSE_ELEC();
5363 /* Total immunity */
5364 if (p_ptr->immune_elec || (dam <= 0))
5366 learn_spell(monspell);
5370 /* Vulnerability (Ouch!) */
5371 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5372 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5373 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5375 /* Resist the damage */
5376 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5377 if (double_resist) dam = (dam + 2) / 3;
5379 if ((!(double_resist || p_ptr->resist_elec)) &&
5380 one_in_(HURT_CHANCE))
5381 (void)do_dec_stat(A_DEX);
5384 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5386 /* Inventory damage */
5387 if (!(double_resist && p_ptr->resist_elec))
5388 inven_damage(set_elec_destroy, inv);
5395 * Hurt the player with Fire
5397 int fire_dam(int dam, cptr kb_str, int monspell)
5400 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5401 bool double_resist = IS_OPPOSE_FIRE();
5403 /* Totally immune */
5404 if (p_ptr->immune_fire || (dam <= 0))
5406 learn_spell(monspell);
5410 /* Vulnerability (Ouch!) */
5411 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5412 if (prace_is_(RACE_ENT)) dam += dam / 3;
5413 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5415 /* Resist the damage */
5416 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5417 if (double_resist) dam = (dam + 2) / 3;
5419 if ((!(double_resist || p_ptr->resist_fire)) &&
5420 one_in_(HURT_CHANCE))
5421 (void)do_dec_stat(A_STR);
5424 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5426 /* Inventory damage */
5427 if (!(double_resist && p_ptr->resist_fire))
5428 inven_damage(set_fire_destroy, inv);
5435 * Hurt the player with Cold
5437 int cold_dam(int dam, cptr kb_str, int monspell)
5440 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5441 bool double_resist = IS_OPPOSE_COLD();
5443 /* Total immunity */
5444 if (p_ptr->immune_cold || (dam <= 0))
5446 learn_spell(monspell);
5450 /* Vulnerability (Ouch!) */
5451 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5452 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5454 /* Resist the damage */
5455 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5456 if (double_resist) dam = (dam + 2) / 3;
5458 if ((!(double_resist || p_ptr->resist_cold)) &&
5459 one_in_(HURT_CHANCE))
5460 (void)do_dec_stat(A_STR);
5463 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5465 /* Inventory damage */
5466 if (!(double_resist && p_ptr->resist_cold))
5467 inven_damage(set_cold_destroy, inv);
5473 bool rustproof(void)
5477 char o_name[MAX_NLEN];
5480 item_tester_no_ryoute = TRUE;
5481 /* Select a piece of armour */
5482 item_tester_hook = item_tester_hook_armour;
5486 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5487 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5489 q = "Rustproof which piece of armour? ";
5490 s = "You have nothing to rustproof.";
5493 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5495 /* Get the item (in the pack) */
5498 o_ptr = &inventory[item];
5501 /* Get the item (on the floor) */
5504 o_ptr = &o_list[0 - item];
5509 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5511 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5513 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5516 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5518 msg_format("%s %s look%s as good as new!",
5519 ((item >= 0) ? "Your" : "The"), o_name,
5520 ((o_ptr->number > 1) ? "" : "s"));
5527 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5529 msg_format("%s %s %s now protected against corrosion.",
5530 ((item >= 0) ? "Your" : "The"), o_name,
5531 ((o_ptr->number > 1) ? "are" : "is"));
5542 * Curse the players armor
5544 bool curse_armor(void)
5549 char o_name[MAX_NLEN];
5552 /* Curse the body armor */
5553 o_ptr = &inventory[INVEN_BODY];
5555 /* Nothing to curse */
5556 if (!o_ptr->k_idx) return (FALSE);
5560 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5562 /* Attempt a saving throw for artifacts */
5563 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5567 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5568 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5570 msg_format("A %s tries to %s, but your %s resists the effects!",
5571 "terrible black aura", "surround your armor", o_name);
5576 /* not artifact or failed save... */
5581 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5583 msg_format("A terrible black aura blasts your %s!", o_name);
5586 chg_virtue(V_ENCHANT, -5);
5588 /* Blast the armor */
5590 o_ptr->name2 = EGO_BLASTED;
5591 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5598 for (i = 0; i < TR_FLAG_SIZE; i++)
5599 o_ptr->art_flags[i] = 0;
5602 o_ptr->curse_flags = TRC_CURSED;
5605 o_ptr->ident |= (IDENT_BROKEN);
5607 /* Recalculate bonuses */
5608 p_ptr->update |= (PU_BONUS);
5610 /* Recalculate mana */
5611 p_ptr->update |= (PU_MANA);
5614 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5622 * Curse the players weapon
5624 bool curse_weapon(bool force, int slot)
5630 char o_name[MAX_NLEN];
5633 /* Curse the weapon */
5634 o_ptr = &inventory[slot];
5636 /* Nothing to curse */
5637 if (!o_ptr->k_idx) return (FALSE);
5641 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5643 /* Attempt a saving throw */
5644 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5648 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5649 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5651 msg_format("A %s tries to %s, but your %s resists the effects!",
5652 "terrible black aura", "surround your weapon", o_name);
5657 /* not artifact or failed save... */
5662 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5664 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5667 chg_virtue(V_ENCHANT, -5);
5669 /* Shatter the weapon */
5671 o_ptr->name2 = EGO_SHATTERED;
5672 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5673 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5679 for (i = 0; i < TR_FLAG_SIZE; i++)
5680 o_ptr->art_flags[i] = 0;
5684 o_ptr->curse_flags = TRC_CURSED;
5687 o_ptr->ident |= (IDENT_BROKEN);
5689 /* Recalculate bonuses */
5690 p_ptr->update |= (PU_BONUS);
5692 /* Recalculate mana */
5693 p_ptr->update |= (PU_MANA);
5696 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5705 * Enchant some bolts
5707 bool brand_bolts(void)
5711 /* Use the first acceptable bolts */
5712 for (i = 0; i < INVEN_PACK; i++)
5714 object_type *o_ptr = &inventory[i];
5716 /* Skip non-bolts */
5717 if (o_ptr->tval != TV_BOLT) continue;
5719 /* Skip artifacts and ego-items */
5720 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5723 /* Skip cursed/broken items */
5724 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5727 if (randint0(100) < 75) continue;
5731 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5733 msg_print("Your bolts are covered in a fiery aura!");
5738 o_ptr->name2 = EGO_FLAME;
5741 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5748 if (flush_failure) flush();
5752 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5754 msg_print("The fiery enchantment failed.");
5764 * Helper function -- return a "nearby" race for polymorphing
5766 * Note that this function is one of the more "dangerous" ones...
5768 static s16b poly_r_idx(int r_idx)
5770 monster_race *r_ptr = &r_info[r_idx];
5772 int i, r, lev1, lev2;
5774 /* Hack -- Uniques/Questors never polymorph */
5775 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5776 (r_ptr->flags1 & RF1_QUESTOR))
5779 /* Allowable range of "levels" for resulting monster */
5780 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5781 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5783 /* Pick a (possibly new) non-unique race */
5784 for (i = 0; i < 1000; i++)
5786 /* Pick a new race, using a level calculation */
5787 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5789 /* Handle failure */
5795 /* Ignore unique monsters */
5796 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5798 /* Ignore monsters with incompatible levels */
5799 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5801 /* Use that index */
5813 bool polymorph_monster(int y, int x)
5815 cave_type *c_ptr = &cave[y][x];
5816 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5817 bool polymorphed = FALSE;
5819 int old_r_idx = m_ptr->r_idx;
5820 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5821 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5822 monster_type back_m;
5824 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5826 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5828 /* Memorize the monster before polymorphing */
5831 /* Pick a "new" monster race */
5832 new_r_idx = poly_r_idx(old_r_idx);
5834 /* Handle polymorph */
5835 if (new_r_idx != old_r_idx)
5839 /* Get the monsters attitude */
5840 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5841 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5842 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5844 /* "Kill" the "old" monster */
5845 delete_monster_idx(c_ptr->m_idx);
5847 /* Create a new monster (no groups) */
5848 if (place_monster_aux(0, y, x, new_r_idx, mode))
5855 /* Placing the new monster failed */
5856 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5857 m_list[hack_m_idx_ii] = back_m;
5860 if (targeted) target_who = hack_m_idx_ii;
5861 if (health_tracked) health_track(hack_m_idx_ii);
5871 static bool dimension_door_aux(int x, int y)
5873 int plev = p_ptr->lev;
5875 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5877 if (!cave_teleportable_bold(y, x) ||
5878 (distance(y, x, py, px) > plev / 2 + 10) ||
5879 (!randint0(plev / 10 + 10)))
5881 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5882 teleport_player((plev+2)*2);
5889 teleport_player_to(y, x, TRUE);
5900 bool dimension_door(void)
5904 /* Rerutn FALSE if cancelled */
5905 if (!tgt_pt(&x, &y)) return FALSE;
5907 if (dimension_door_aux(x, y)) return TRUE;
5910 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5912 msg_print("You fail to exit the astral plane correctly!");
5920 * Mirror Master's Dimension Door
5922 bool mirror_tunnel(void)
5926 /* Rerutn FALSE if cancelled */
5927 if (!tgt_pt(&x, &y)) return FALSE;
5929 if (dimension_door_aux(x, y)) return TRUE;
5932 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5934 msg_print("You fail to pass the mirror plane correctly!");
5941 bool eat_magic(int power)
5943 object_type * o_ptr;
5946 int recharge_strength = 0;
5952 char o_name[MAX_NLEN];
5954 item_tester_hook = item_tester_hook_recharge;
5958 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5959 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5961 q = "Drain which item? ";
5962 s = "You have nothing to drain.";
5965 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5969 o_ptr = &inventory[item];
5973 o_ptr = &o_list[0 - item];
5976 k_ptr = &k_info[o_ptr->k_idx];
5977 lev = get_object_level(o_ptr);
5979 if (o_ptr->tval == TV_ROD)
5981 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5984 if (one_in_(recharge_strength))
5986 /* Activate the failure code. */
5991 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5994 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5996 msg_print("You can't absorb energy from a discharged rod.");
6003 o_ptr->timeout += k_ptr->pval;
6009 /* All staffs, wands. */
6010 recharge_strength = (100 + power - lev) / 15;
6013 if (recharge_strength < 0) recharge_strength = 0;
6016 if (one_in_(recharge_strength))
6018 /* Activate the failure code. */
6023 if (o_ptr->pval > 0)
6025 p_ptr->csp += lev / 2;
6028 /* XXX Hack -- unstack if necessary */
6029 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
6034 /* Get local object */
6037 /* Obtain a local object */
6038 object_copy(q_ptr, o_ptr);
6040 /* Modify quantity */
6043 /* Restore the charges */
6046 /* Unstack the used item */
6048 p_ptr->total_weight -= q_ptr->weight;
6049 item = inven_carry(q_ptr);
6053 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
6055 msg_print("You unstack your staff.");
6063 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
6065 msg_print("There's no energy there to absorb!");
6069 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
6073 /* Inflict the penalties for failing a recharge. */
6076 /* Artifacts are never destroyed. */
6077 if (artifact_p(o_ptr))
6079 object_desc(o_name, o_ptr, OD_NAME_ONLY);
6081 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
6083 msg_format("The recharging backfires - %s is completely drained!", o_name);
6087 /* Artifact rods. */
6088 if (o_ptr->tval == TV_ROD)
6089 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6091 /* Artifact wands and staffs. */
6092 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
6097 /* Get the object description */
6098 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
6100 /*** Determine Seriousness of Failure ***/
6102 /* Mages recharge objects more safely. */
6103 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)
6105 /* 10% chance to blow up one rod, otherwise draining. */
6106 if (o_ptr->tval == TV_ROD)
6108 if (one_in_(10)) fail_type = 2;
6111 /* 75% chance to blow up one wand, otherwise draining. */
6112 else if (o_ptr->tval == TV_WAND)
6114 if (!one_in_(3)) fail_type = 2;
6117 /* 50% chance to blow up one staff, otherwise no effect. */
6118 else if (o_ptr->tval == TV_STAFF)
6120 if (one_in_(2)) fail_type = 2;
6125 /* All other classes get no special favors. */
6128 /* 33% chance to blow up one rod, otherwise draining. */
6129 if (o_ptr->tval == TV_ROD)
6131 if (one_in_(3)) fail_type = 2;
6134 /* 20% chance of the entire stack, else destroy one wand. */
6135 else if (o_ptr->tval == TV_WAND)
6137 if (one_in_(5)) fail_type = 3;
6140 /* Blow up one staff. */
6141 else if (o_ptr->tval == TV_STAFF)
6147 /*** Apply draining and destruction. ***/
6149 /* Drain object or stack of objects. */
6152 if (o_ptr->tval == TV_ROD)
6155 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
6157 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
6160 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6162 else if (o_ptr->tval == TV_WAND)
6165 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
6167 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
6172 /* Staffs aren't drained. */
6175 /* Destroy an object or one in a stack of objects. */
6178 if (o_ptr->number > 1)
6181 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
6183 msg_format("Wild magic consumes one of your %s!", o_name);
6186 /* Reduce rod stack maximum timeout, drain wands. */
6187 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
6188 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
6193 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
6195 msg_format("Wild magic consumes your %s!", o_name);
6198 /* Reduce and describe inventory */
6201 inven_item_increase(item, -1);
6202 inven_item_describe(item);
6203 inven_item_optimize(item);
6206 /* Reduce and describe floor item */
6209 floor_item_increase(0 - item, -1);
6210 floor_item_describe(0 - item);
6211 floor_item_optimize(0 - item);
6215 /* Destroy all members of a stack of objects. */
6218 if (o_ptr->number > 1)
6220 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
6222 msg_format("Wild magic consumes all your %s!", o_name);
6227 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
6229 msg_format("Wild magic consumes your %s!", o_name);
6234 /* Reduce and describe inventory */
6237 inven_item_increase(item, -999);
6238 inven_item_describe(item);
6239 inven_item_optimize(item);
6242 /* Reduce and describe floor item */
6245 floor_item_increase(0 - item, -999);
6246 floor_item_describe(0 - item);
6247 floor_item_optimize(0 - item);
6253 if (p_ptr->csp > p_ptr->msp)
6255 p_ptr->csp = p_ptr->msp;
6258 /* Redraw mana and hp */
6259 p_ptr->redraw |= (PR_MANA);
6261 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6262 p_ptr->window |= (PW_INVEN);
6268 bool summon_kin_player(int level, int y, int x, u32b mode)
6270 bool pet = (bool)(mode & PM_FORCE_PET);
6271 if (!pet) mode |= PM_NO_PET;
6273 switch (p_ptr->mimic_form)
6276 switch (p_ptr->prace)
6280 case RACE_BARBARIAN:
6283 summon_kin_type = 'p';
6293 case RACE_MIND_FLAYER:
6296 summon_kin_type = 'h';
6299 summon_kin_type = 'o';
6301 case RACE_HALF_TROLL:
6302 summon_kin_type = 'T';
6304 case RACE_HALF_OGRE:
6305 summon_kin_type = 'O';
6307 case RACE_HALF_GIANT:
6308 case RACE_HALF_TITAN:
6310 summon_kin_type = 'P';
6313 summon_kin_type = 'y';
6316 summon_kin_type = 'K';
6319 summon_kin_type = 'k';
6322 if (one_in_(13)) summon_kin_type = 'U';
6323 else summon_kin_type = 'u';
6325 case RACE_DRACONIAN:
6326 summon_kin_type = 'd';
6330 summon_kin_type = 'g';
6333 if (one_in_(13)) summon_kin_type = 'L';
6334 else summon_kin_type = 's';
6337 summon_kin_type = 'z';
6340 summon_kin_type = 'V';
6343 summon_kin_type = 'G';
6346 summon_kin_type = 'I';
6349 summon_kin_type = '#';
6352 summon_kin_type = 'A';
6355 summon_kin_type = 'U';
6358 summon_kin_type = 'p';
6363 if (one_in_(13)) summon_kin_type = 'U';
6364 else summon_kin_type = 'u';
6366 case MIMIC_DEMON_LORD:
6367 summon_kin_type = 'U';
6370 summon_kin_type = 'V';
6373 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);