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 c_ptr = &cave[py + ddy_ddd[i]][px + ddx_ddd[i]];
1689 if (!have_flag(f_flags_grid(c_ptr), FF_PROJECT))
1691 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1692 !permanent_wall(&f_info[c_ptr->feat]))
1702 for (i = 1; i < 10; i++)
1704 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1707 for (i = 1; i < 10; i++)
1709 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1712 for (i = 1; i < 10; i++)
1714 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1718 /* Prevent destruction of quest levels and town */
1719 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1722 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1724 msg_print("The ground trembles.");
1731 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1732 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1733 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1735 msg_format("You %s the %s too close to a wall!",
1736 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1737 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1738 msg_print("There is a loud explosion!");
1744 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1746 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1751 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1753 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1755 msg_print("The dungeon collapses...");
1760 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1762 msg_print("The dungeon trembles.");
1767 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1769 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1776 * Fetch an item (teleport it right underneath the caster)
1778 void fetch(int dir, int wgt, bool require_los)
1783 char o_name[MAX_NLEN];
1785 /* Check to see if an object is already there */
1786 if (cave[py][px].o_idx)
1789 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1791 msg_print("You can't fetch when you're already standing on something.");
1798 if (dir == 5 && target_okay())
1803 if (distance(py, px, ty, tx) > MAX_RANGE)
1806 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1808 msg_print("You can't fetch something that far away!");
1814 c_ptr = &cave[ty][tx];
1816 /* We need an item to fetch */
1820 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1822 msg_print("There is no object at this place.");
1828 /* No fetching from vault */
1829 if (c_ptr->info & CAVE_ICKY)
1832 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1834 msg_print("The item slips from your control.");
1840 /* We need to see the item */
1843 if (!player_has_los_bold(ty, tx))
1846 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1848 msg_print("You have no direct line of sight to that location.");
1853 else if (!projectable(py, px, ty, tx))
1856 msg_print("¤½¤³¤ÏÊɤθþ¤³¤¦¤Ç¤¹¡£");
1858 msg_print("You have no direct line of sight to that location.");
1867 /* Use a direction */
1868 ty = py; /* Where to drop the item */
1875 c_ptr = &cave[ty][tx];
1877 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1878 !have_flag(f_flags_bold(ty, tx), FF_PROJECT)) return;
1880 while (!c_ptr->o_idx);
1883 o_ptr = &o_list[c_ptr->o_idx];
1885 if (o_ptr->weight > wgt)
1887 /* Too heavy to 'fetch' */
1889 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1891 msg_print("The object is too heavy.");
1898 c_ptr->o_idx = o_ptr->next_o_idx;
1899 cave[py][px].o_idx = i; /* 'move' it */
1900 o_ptr->next_o_idx = 0;
1901 o_ptr->iy = (byte)py;
1902 o_ptr->ix = (byte)px;
1904 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1906 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1908 msg_format("%^s flies through the air to your feet.", o_name);
1913 p_ptr->redraw |= PR_MAP;
1917 void alter_reality(void)
1919 /* Ironman option */
1920 if (p_ptr->inside_arena || ironman_downward)
1923 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1925 msg_print("Nothing happens.");
1930 if (!p_ptr->alter_reality)
1932 int turns = randint0(21) + 15;
1934 p_ptr->alter_reality = turns;
1936 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1938 msg_print("The view around you begins to change...");
1941 p_ptr->redraw |= (PR_STATUS);
1945 p_ptr->alter_reality = 0;
1947 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1949 msg_print("The view around you got back...");
1952 p_ptr->redraw |= (PR_STATUS);
1959 * Leave a "glyph of warding" which prevents monster movement
1961 bool warding_glyph(void)
1964 if (!cave_clean_bold(py, px))
1967 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1969 msg_print("The object resists the spell.");
1975 /* Create a glyph */
1976 cave[py][px].info |= CAVE_OBJECT;
1977 cave[py][px].mimic = FEAT_GLYPH;
1988 bool place_mirror(void)
1991 if (!cave_clean_bold(py, px))
1994 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1996 msg_print("The object resists the spell.");
2002 /* Create a mirror */
2003 cave[py][px].info |= CAVE_OBJECT;
2004 cave[py][px].mimic = FEAT_MIRROR;
2006 /* Turn on the light */
2007 cave[py][px].info |= CAVE_GLOW;
2020 * Leave an "explosive rune" which prevents monster movement
2022 bool explosive_rune(void)
2025 if (!cave_clean_bold(py, px))
2028 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
2030 msg_print("The object resists the spell.");
2036 /* Create a glyph */
2037 cave[py][px].info |= CAVE_OBJECT;
2038 cave[py][px].mimic = FEAT_MINOR_GLYPH;
2051 * Identify everything being carried.
2052 * Done by a potion of "self knowledge".
2054 void identify_pack(void)
2058 /* Simply identify and know every item */
2059 for (i = 0; i < INVEN_TOTAL; i++)
2061 object_type *o_ptr = &inventory[i];
2063 /* Skip non-objects */
2064 if (!o_ptr->k_idx) continue;
2067 identify_item(o_ptr);
2069 /* Auto-inscription */
2070 autopick_alter_item(i, FALSE);
2076 * Used by the "enchant" function (chance of failure)
2077 * (modified for Zangband, we need better stuff there...) -- TY
2079 static int enchant_table[16] =
2081 0, 10, 50, 100, 200,
2082 300, 400, 500, 650, 800,
2083 950, 987, 993, 995, 998,
2089 * Removes curses from items in inventory
2091 * Note that Items which are "Perma-Cursed" (The One Ring,
2092 * The Crown of Morgoth) can NEVER be uncursed.
2094 * Note that if "all" is FALSE, then Items which are
2095 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2096 * will not be uncursed.
2098 static int remove_curse_aux(int all)
2102 /* Attempt to uncurse items being worn */
2103 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2105 object_type *o_ptr = &inventory[i];
2107 /* Skip non-objects */
2108 if (!o_ptr->k_idx) continue;
2110 /* Uncursed already */
2111 if (!cursed_p(o_ptr)) continue;
2113 /* Heavily Cursed Items need a special spell */
2114 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2116 /* Perma-Cursed Items can NEVER be uncursed */
2117 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2120 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2125 o_ptr->curse_flags = 0L;
2127 /* Hack -- Assume felt */
2128 o_ptr->ident |= (IDENT_SENSE);
2131 o_ptr->feeling = FEEL_NONE;
2133 /* Recalculate the bonuses */
2134 p_ptr->update |= (PU_BONUS);
2137 p_ptr->window |= (PW_EQUIP);
2139 /* Count the uncursings */
2143 /* Return "something uncursed" */
2149 * Remove most curses
2151 bool remove_curse(void)
2153 return (remove_curse_aux(FALSE));
2159 bool remove_all_curse(void)
2161 return (remove_curse_aux(TRUE));
2166 * Turns an object into gold, gain some of its value in a shop
2175 char o_name[MAX_NLEN];
2176 char out_val[MAX_NLEN+40];
2180 /* Hack -- force destruction */
2181 if (command_arg > 0) force = TRUE;
2185 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2186 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2188 q = "Turn which item to gold? ";
2189 s = "You have nothing to turn to gold.";
2192 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2194 /* Get the item (in the pack) */
2197 o_ptr = &inventory[item];
2200 /* Get the item (on the floor) */
2203 o_ptr = &o_list[0 - item];
2207 /* See how many items */
2208 if (o_ptr->number > 1)
2210 /* Get a quantity */
2211 amt = get_quantity(NULL, o_ptr->number);
2213 /* Allow user abort */
2214 if (amt <= 0) return FALSE;
2218 /* Describe the object */
2219 old_number = o_ptr->number;
2220 o_ptr->number = amt;
2221 object_desc(o_name, o_ptr, 0);
2222 o_ptr->number = old_number;
2224 /* Verify unless quantity given */
2227 if (confirm_destroy || (object_value(o_ptr) > 0))
2229 /* Make a verification */
2231 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2233 sprintf(out_val, "Really turn %s to gold? ", o_name);
2236 if (!get_check(out_val)) return FALSE;
2240 /* Artifacts cannot be destroyed */
2241 if (!can_player_destroy_object(o_ptr))
2245 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2247 msg_format("You fail to turn %s to gold!", o_name);
2254 price = object_value_real(o_ptr);
2260 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2262 msg_format("You turn %s to fool's gold.", o_name);
2270 if (amt > 1) price *= amt;
2272 if (price > 30000) price = 30000;
2274 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2276 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2282 p_ptr->redraw |= (PR_GOLD);
2285 p_ptr->window |= (PW_PLAYER);
2289 /* Eliminate the item (from the pack) */
2292 inven_item_increase(item, -amt);
2293 inven_item_describe(item);
2294 inven_item_optimize(item);
2297 /* Eliminate the item (from the floor) */
2300 floor_item_increase(0 - item, -amt);
2301 floor_item_describe(0 - item);
2302 floor_item_optimize(0 - item);
2311 * Hook to specify "weapon"
2313 bool item_tester_hook_weapon(object_type *o_ptr)
2315 switch (o_ptr->tval)
2329 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2336 static bool item_tester_hook_weapon2(object_type *o_ptr)
2338 switch (o_ptr->tval)
2358 * Hook to specify "armour"
2360 bool item_tester_hook_armour(object_type *o_ptr)
2362 switch (o_ptr->tval)
2383 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2385 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2387 switch (o_ptr->tval)
2416 * Check if an object is nameless weapon or armour
2418 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2420 switch (o_ptr->tval)
2439 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2441 if (object_known_p(o_ptr)) return FALSE;
2451 * Break the curse of an item
2453 static void break_curse(object_type *o_ptr)
2455 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2458 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2460 msg_print("The curse is broken!");
2463 o_ptr->curse_flags = 0L;
2465 o_ptr->ident |= (IDENT_SENSE);
2467 o_ptr->feeling = FEEL_NONE;
2473 * Enchants a plus onto an item. -RAK-
2475 * Revamped! Now takes item pointer, number of times to try enchanting,
2476 * and a flag of what to try enchanting. Artifacts resist enchantment
2477 * some of the time, and successful enchantment to at least +0 might
2478 * break a curse on the item. -CFT-
2480 * Note that an item can technically be enchanted all the way to +15 if
2481 * you wait a very, very, long time. Going from +9 to +10 only works
2482 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2484 * Note that this function can now be used on "piles" of items, and
2485 * the larger the pile, the lower the chance of success.
2487 bool enchant(object_type *o_ptr, int n, int eflag)
2489 int i, chance, prob;
2491 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2492 bool force = (eflag & ENCH_FORCE);
2495 /* Large piles resist enchantment */
2496 prob = o_ptr->number * 100;
2498 /* Missiles are easy to enchant */
2499 if ((o_ptr->tval == TV_BOLT) ||
2500 (o_ptr->tval == TV_ARROW) ||
2501 (o_ptr->tval == TV_SHOT))
2507 for (i = 0; i < n; i++)
2509 /* Hack -- Roll for pile resistance */
2510 if (!force && randint0(prob) >= 100) continue;
2512 /* Enchant to hit */
2513 if (eflag & ENCH_TOHIT)
2515 if (o_ptr->to_h < 0) chance = 0;
2516 else if (o_ptr->to_h > 15) chance = 1000;
2517 else chance = enchant_table[o_ptr->to_h];
2519 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2524 /* only when you get it above -1 -CFT */
2525 if (o_ptr->to_h >= 0)
2530 /* Enchant to damage */
2531 if (eflag & ENCH_TODAM)
2533 if (o_ptr->to_d < 0) chance = 0;
2534 else if (o_ptr->to_d > 15) chance = 1000;
2535 else chance = enchant_table[o_ptr->to_d];
2537 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2542 /* only when you get it above -1 -CFT */
2543 if (o_ptr->to_d >= 0)
2548 /* Enchant to armor class */
2549 if (eflag & ENCH_TOAC)
2551 if (o_ptr->to_a < 0) chance = 0;
2552 else if (o_ptr->to_a > 15) chance = 1000;
2553 else chance = enchant_table[o_ptr->to_a];
2555 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2560 /* only when you get it above -1 -CFT */
2561 if (o_ptr->to_a >= 0)
2568 if (!res) return (FALSE);
2570 /* Recalculate bonuses */
2571 p_ptr->update |= (PU_BONUS);
2573 /* Combine / Reorder the pack (later) */
2574 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2577 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2588 * Enchant an item (in the inventory or on the floor)
2589 * Note that "num_ac" requires armour, else weapon
2590 * Returns TRUE if attempted, FALSE if cancelled
2592 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2597 char o_name[MAX_NLEN];
2601 /* Assume enchant weapon */
2602 item_tester_hook = item_tester_hook_weapon;
2603 item_tester_no_ryoute = TRUE;
2605 /* Enchant armor if requested */
2606 if (num_ac) item_tester_hook = item_tester_hook_armour;
2610 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2611 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2613 q = "Enchant which item? ";
2614 s = "You have nothing to enchant.";
2617 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2619 /* Get the item (in the pack) */
2622 o_ptr = &inventory[item];
2625 /* Get the item (on the floor) */
2628 o_ptr = &o_list[0 - item];
2633 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2637 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2640 msg_format("%s %s glow%s brightly!",
2641 ((item >= 0) ? "Your" : "The"), o_name,
2642 ((o_ptr->number > 1) ? "" : "s"));
2647 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2648 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2649 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2655 if (flush_failure) flush();
2659 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2661 msg_print("The enchantment failed.");
2664 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2667 chg_virtue(V_ENCHANT, 1);
2671 /* Something happened */
2676 bool artifact_scroll(void)
2681 char o_name[MAX_NLEN];
2685 item_tester_no_ryoute = TRUE;
2686 /* Enchant weapon/armour */
2687 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2691 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2692 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2694 q = "Enchant which item? ";
2695 s = "You have nothing to enchant.";
2698 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2700 /* Get the item (in the pack) */
2703 o_ptr = &inventory[item];
2706 /* Get the item (on the floor) */
2709 o_ptr = &o_list[0 - item];
2714 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2718 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2720 msg_format("%s %s radiate%s a blinding light!",
2721 ((item >= 0) ? "Your" : "The"), o_name,
2722 ((o_ptr->number > 1) ? "" : "s"));
2725 if (o_ptr->name1 || o_ptr->art_name)
2728 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2730 msg_format("The %s %s already %s!",
2731 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2732 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2738 else if (o_ptr->name2)
2741 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2743 msg_format("The %s %s already %s!",
2744 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2745 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2751 else if (o_ptr->xtra3)
2754 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2756 msg_format("The %s %s already %s!",
2757 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2758 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2764 if (o_ptr->number > 1)
2767 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2768 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2770 msg_print("Not enough enough energy to enchant more than one object!");
2771 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2776 inven_item_increase(item, 1-(o_ptr->number));
2780 floor_item_increase(0-item, 1-(o_ptr->number));
2783 okay = create_artifact(o_ptr, TRUE);
2790 if (flush_failure) flush();
2794 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2796 msg_print("The enchantment failed.");
2799 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2802 chg_virtue(V_ENCHANT, 1);
2806 /* Something happened */
2812 * Identify an object
2814 bool identify_item(object_type *o_ptr)
2816 bool old_known = FALSE;
2817 char o_name[MAX_NLEN];
2820 object_desc(o_name, o_ptr, 0);
2822 if (o_ptr->ident & IDENT_KNOWN)
2825 if (!(o_ptr->ident & (IDENT_MENTAL)))
2827 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2828 chg_virtue(V_KNOWLEDGE, 1);
2831 /* Identify it fully */
2832 object_aware(o_ptr);
2833 object_known(o_ptr);
2835 /* Recalculate bonuses */
2836 p_ptr->update |= (PU_BONUS);
2838 /* Combine / Reorder the pack (later) */
2839 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2842 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2844 strcpy(record_o_name, o_name);
2848 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2850 if(record_fix_art && !old_known && artifact_p(o_ptr))
2851 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2852 if(record_rand_art && !old_known && o_ptr->art_name)
2853 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2859 static bool item_tester_hook_identify(object_type *o_ptr)
2861 return (bool)!object_known_p(o_ptr);
2864 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2866 if (object_known_p(o_ptr))
2868 return item_tester_hook_weapon_armour(o_ptr);
2872 * Identify an object in the inventory (or on the floor)
2873 * This routine does *not* automatically combine objects.
2874 * Returns TRUE if something was identified, else FALSE.
2876 bool ident_spell(bool only_equip)
2880 char o_name[MAX_NLEN];
2884 item_tester_no_ryoute = TRUE;
2887 item_tester_hook = item_tester_hook_identify_weapon_armour;
2889 item_tester_hook = item_tester_hook_identify;
2891 if (!can_get_item())
2895 item_tester_hook = item_tester_hook_weapon_armour;
2899 item_tester_hook = NULL;
2905 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2906 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2908 q = "Identify which item? ";
2909 s = "You have nothing to identify.";
2912 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2914 /* Get the item (in the pack) */
2917 o_ptr = &inventory[item];
2920 /* Get the item (on the floor) */
2923 o_ptr = &o_list[0 - item];
2927 old_known = identify_item(o_ptr);
2930 object_desc(o_name, o_ptr, 0);
2933 if (item >= INVEN_RARM)
2936 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2938 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2944 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2946 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2952 msg_format("¾²¾å: %s¡£", o_name);
2954 msg_format("On the ground: %s.", o_name);
2958 /* Auto-inscription/destroy */
2959 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2961 /* Something happened */
2967 * Mundanify an object in the inventory (or on the floor)
2968 * This routine does *not* automatically combine objects.
2969 * Returns TRUE if something was mundanified, else FALSE.
2971 bool mundane_spell(bool only_equip)
2977 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
2978 item_tester_no_ryoute = TRUE;
2982 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2983 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2985 q = "Use which item? ";
2986 s = "You have nothing you can use.";
2989 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2991 /* Get the item (in the pack) */
2994 o_ptr = &inventory[item];
2997 /* Get the item (on the floor) */
3000 o_ptr = &o_list[0 - item];
3005 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
3007 msg_print("There is a bright flash of light!");
3010 byte iy = o_ptr->iy; /* Y-position on map, or zero */
3011 byte ix = o_ptr->ix; /* X-position on map, or zero */
3012 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
3013 byte marked = o_ptr->marked; /* Object is marked */
3014 s16b weight = o_ptr->number * o_ptr->weight;
3015 u16b inscription = o_ptr->inscription;
3018 object_prep(o_ptr, o_ptr->k_idx);
3022 o_ptr->next_o_idx = next_o_idx;
3023 o_ptr->marked = marked;
3024 o_ptr->inscription = inscription;
3025 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
3029 /* Something happened */
3035 static bool item_tester_hook_identify_fully(object_type *o_ptr)
3037 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
3040 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
3042 if (!item_tester_hook_identify_fully(o_ptr))
3044 return item_tester_hook_weapon_armour(o_ptr);
3048 * Fully "identify" an object in the inventory -BEN-
3049 * This routine returns TRUE if an item was identified.
3051 bool identify_fully(bool only_equip)
3055 char o_name[MAX_NLEN];
3059 item_tester_no_ryoute = TRUE;
3061 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
3063 item_tester_hook = item_tester_hook_identify_fully;
3065 if (!can_get_item())
3068 item_tester_hook = item_tester_hook_weapon_armour;
3070 item_tester_hook = NULL;
3075 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
3076 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3078 q = "Identify which item? ";
3079 s = "You have nothing to identify.";
3082 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
3084 /* Get the item (in the pack) */
3087 o_ptr = &inventory[item];
3090 /* Get the item (on the floor) */
3093 o_ptr = &o_list[0 - item];
3097 old_known = identify_item(o_ptr);
3099 /* Mark the item as fully known */
3100 o_ptr->ident |= (IDENT_MENTAL);
3106 object_desc(o_name, o_ptr, 0);
3109 if (item >= INVEN_RARM)
3112 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
3114 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
3122 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
3124 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3130 msg_format("¾²¾å: %s¡£", o_name);
3132 msg_format("On the ground: %s.", o_name);
3136 /* Describe it fully */
3137 (void)screen_object(o_ptr, TRUE);
3139 /* Auto-inscription/destroy */
3140 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
3150 * Hook for "get_item()". Determine if something is rechargable.
3152 bool item_tester_hook_recharge(object_type *o_ptr)
3154 /* Recharge staffs */
3155 if (o_ptr->tval == TV_STAFF) return (TRUE);
3157 /* Recharge wands */
3158 if (o_ptr->tval == TV_WAND) return (TRUE);
3160 /* Hack -- Recharge rods */
3161 if (o_ptr->tval == TV_ROD) return (TRUE);
3169 * Recharge a wand/staff/rod from the pack or on the floor.
3170 * This function has been rewritten in Oangband and ZAngband.
3172 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3173 * Chaos -- Arcane Binding --> recharge(90)
3175 * Scroll of recharging --> recharge(130)
3176 * Artifact activation/Thingol --> recharge(130)
3178 * It is harder to recharge high level, and highly charged wands,
3179 * staffs, and rods. The more wands in a stack, the more easily and
3180 * strongly they recharge. Staffs, however, each get fewer charges if
3183 * XXX XXX XXX Beware of "sliding index errors".
3185 bool recharge(int power)
3188 int recharge_strength, recharge_amount;
3197 char o_name[MAX_NLEN];
3199 /* Only accept legal items */
3200 item_tester_hook = item_tester_hook_recharge;
3204 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3205 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3207 q = "Recharge which item? ";
3208 s = "You have nothing to recharge.";
3211 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3213 /* Get the item (in the pack) */
3216 o_ptr = &inventory[item];
3219 /* Get the item (on the floor) */
3222 o_ptr = &o_list[0 - item];
3225 /* Get the object kind. */
3226 k_ptr = &k_info[o_ptr->k_idx];
3228 /* Extract the object "level" */
3229 lev = get_object_level(o_ptr);
3232 /* Recharge a rod */
3233 if (o_ptr->tval == TV_ROD)
3235 /* Extract a recharge strength by comparing object level to power. */
3236 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3240 if (one_in_(recharge_strength))
3242 /* Activate the failure code. */
3249 /* Recharge amount */
3250 recharge_amount = (power * damroll(3, 2));
3252 /* Recharge by that amount */
3253 if (o_ptr->timeout > recharge_amount)
3254 o_ptr->timeout -= recharge_amount;
3261 /* Recharge wand/staff */
3264 /* Extract a recharge strength by comparing object level to power.
3265 * Divide up a stack of wands' charges to calculate charge penalty.
3267 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3268 recharge_strength = (100 + power - lev -
3269 (8 * o_ptr->pval / o_ptr->number)) / 15;
3271 /* All staffs, unstacked wands. */
3272 else recharge_strength = (100 + power - lev -
3273 (8 * o_ptr->pval)) / 15;
3276 if (recharge_strength < 0) recharge_strength = 0;
3279 if (one_in_(recharge_strength))
3281 /* Activate the failure code. */
3285 /* If the spell didn't backfire, recharge the wand or staff. */
3288 /* Recharge based on the standard number of charges. */
3289 recharge_amount = randint1(1 + k_ptr->pval / 2);
3291 /* Multiple wands in a stack increase recharging somewhat. */
3292 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3295 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3296 if (recharge_amount < 1) recharge_amount = 1;
3297 if (recharge_amount > 12) recharge_amount = 12;
3300 /* But each staff in a stack gets fewer additional charges,
3301 * although always at least one.
3303 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3305 recharge_amount /= o_ptr->number;
3306 if (recharge_amount < 1) recharge_amount = 1;
3309 /* Recharge the wand or staff. */
3310 o_ptr->pval += recharge_amount;
3313 /* Hack -- we no longer "know" the item */
3314 o_ptr->ident &= ~(IDENT_KNOWN);
3316 /* Hack -- we no longer think the item is empty */
3317 o_ptr->ident &= ~(IDENT_EMPTY);
3322 /* Inflict the penalties for failing a recharge. */
3325 /* Artifacts are never destroyed. */
3326 if (artifact_p(o_ptr))
3328 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3330 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3332 msg_format("The recharging backfires - %s is completely drained!", o_name);
3336 /* Artifact rods. */
3337 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3338 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3340 /* Artifact wands and staffs. */
3341 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3346 /* Get the object description */
3347 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3349 /*** Determine Seriousness of Failure ***/
3351 /* Mages recharge objects more safely. */
3352 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)
3354 /* 10% chance to blow up one rod, otherwise draining. */
3355 if (o_ptr->tval == TV_ROD)
3357 if (one_in_(10)) fail_type = 2;
3360 /* 75% chance to blow up one wand, otherwise draining. */
3361 else if (o_ptr->tval == TV_WAND)
3363 if (!one_in_(3)) fail_type = 2;
3366 /* 50% chance to blow up one staff, otherwise no effect. */
3367 else if (o_ptr->tval == TV_STAFF)
3369 if (one_in_(2)) fail_type = 2;
3374 /* All other classes get no special favors. */
3377 /* 33% chance to blow up one rod, otherwise draining. */
3378 if (o_ptr->tval == TV_ROD)
3380 if (one_in_(3)) fail_type = 2;
3383 /* 20% chance of the entire stack, else destroy one wand. */
3384 else if (o_ptr->tval == TV_WAND)
3386 if (one_in_(5)) fail_type = 3;
3389 /* Blow up one staff. */
3390 else if (o_ptr->tval == TV_STAFF)
3396 /*** Apply draining and destruction. ***/
3398 /* Drain object or stack of objects. */
3401 if (o_ptr->tval == TV_ROD)
3404 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3406 msg_print("The recharge backfires, draining the rod further!");
3409 if (o_ptr->timeout < 10000)
3410 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3412 else if (o_ptr->tval == TV_WAND)
3415 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3417 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3422 /* Staffs aren't drained. */
3425 /* Destroy an object or one in a stack of objects. */
3428 if (o_ptr->number > 1)
3430 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3432 msg_format("Wild magic consumes one of your %s!", o_name);
3437 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3439 msg_format("Wild magic consumes your %s!", o_name);
3443 /* Reduce rod stack maximum timeout, drain wands. */
3444 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3445 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3447 /* Reduce and describe inventory */
3450 inven_item_increase(item, -1);
3451 inven_item_describe(item);
3452 inven_item_optimize(item);
3455 /* Reduce and describe floor item */
3458 floor_item_increase(0 - item, -1);
3459 floor_item_describe(0 - item);
3460 floor_item_optimize(0 - item);
3464 /* Destroy all members of a stack of objects. */
3467 if (o_ptr->number > 1)
3469 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3471 msg_format("Wild magic consumes all your %s!", o_name);
3476 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3478 msg_format("Wild magic consumes your %s!", o_name);
3483 /* Reduce and describe inventory */
3486 inven_item_increase(item, -999);
3487 inven_item_describe(item);
3488 inven_item_optimize(item);
3491 /* Reduce and describe floor item */
3494 floor_item_increase(0 - item, -999);
3495 floor_item_describe(0 - item);
3496 floor_item_optimize(0 - item);
3502 /* Combine / Reorder the pack (later) */
3503 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3506 p_ptr->window |= (PW_INVEN);
3508 /* Something was done */
3516 bool bless_weapon(void)
3520 u32b flgs[TR_FLAG_SIZE];
3521 char o_name[MAX_NLEN];
3524 item_tester_no_ryoute = TRUE;
3525 /* Assume enchant weapon */
3526 item_tester_hook = item_tester_hook_weapon2;
3530 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3531 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3533 q = "Bless which weapon? ";
3534 s = "You have weapon to bless.";
3537 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3540 /* Get the item (in the pack) */
3543 o_ptr = &inventory[item];
3546 /* Get the item (on the floor) */
3549 o_ptr = &o_list[0 - item];
3554 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3556 /* Extract the flags */
3557 object_flags(o_ptr, flgs);
3559 if (cursed_p(o_ptr))
3561 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3562 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3565 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3568 msg_format("The black aura on %s %s disrupts the blessing!",
3569 ((item >= 0) ? "your" : "the"), o_name);
3576 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3579 msg_format("A malignant aura leaves %s %s.",
3580 ((item >= 0) ? "your" : "the"), o_name);
3585 o_ptr->curse_flags = 0L;
3587 /* Hack -- Assume felt */
3588 o_ptr->ident |= (IDENT_SENSE);
3591 o_ptr->feeling = FEEL_NONE;
3593 /* Recalculate the bonuses */
3594 p_ptr->update |= (PU_BONUS);
3597 p_ptr->window |= (PW_EQUIP);
3601 * Next, we try to bless it. Artifacts have a 1/3 chance of
3602 * being blessed, otherwise, the operation simply disenchants
3603 * them, godly power negating the magic. Ok, the explanation
3604 * is silly, but otherwise priests would always bless every
3605 * artifact weapon they find. Ego weapons and normal weapons
3606 * can be blessed automatically.
3608 if (have_flag(flgs, TR_BLESSED))
3611 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3614 msg_format("%s %s %s blessed already.",
3615 ((item >= 0) ? "Your" : "The"), o_name,
3616 ((o_ptr->number > 1) ? "were" : "was"));
3622 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3626 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3629 msg_format("%s %s shine%s!",
3630 ((item >= 0) ? "Your" : "The"), o_name,
3631 ((o_ptr->number > 1) ? "" : "s"));
3634 add_flag(o_ptr->art_flags, TR_BLESSED);
3635 o_ptr->discount = 99;
3639 bool dis_happened = FALSE;
3642 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3644 msg_print("The weapon resists your blessing!");
3648 /* Disenchant tohit */
3649 if (o_ptr->to_h > 0)
3652 dis_happened = TRUE;
3655 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3657 /* Disenchant todam */
3658 if (o_ptr->to_d > 0)
3661 dis_happened = TRUE;
3664 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3666 /* Disenchant toac */
3667 if (o_ptr->to_a > 0)
3670 dis_happened = TRUE;
3673 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3678 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3680 msg_print("There is a static feeling in the air...");
3684 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3687 msg_format("%s %s %s disenchanted!",
3688 ((item >= 0) ? "Your" : "The"), o_name,
3689 ((o_ptr->number > 1) ? "were" : "was"));
3695 /* Recalculate bonuses */
3696 p_ptr->update |= (PU_BONUS);
3699 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3710 bool pulish_shield(void)
3714 u32b flgs[TR_FLAG_SIZE];
3715 char o_name[MAX_NLEN];
3718 item_tester_no_ryoute = TRUE;
3719 /* Assume enchant weapon */
3720 item_tester_tval = TV_SHIELD;
3724 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3725 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3727 q = "Pulish which weapon? ";
3728 s = "You have weapon to pulish.";
3731 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3734 /* Get the item (in the pack) */
3737 o_ptr = &inventory[item];
3740 /* Get the item (on the floor) */
3743 o_ptr = &o_list[0 - item];
3748 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3750 /* Extract the flags */
3751 object_flags(o_ptr, flgs);
3753 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3754 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3757 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3759 msg_format("%s %s shine%s!",
3760 ((item >= 0) ? "Your" : "The"), o_name,
3761 ((o_ptr->number > 1) ? "" : "s"));
3763 o_ptr->name2 = EGO_REFLECTION;
3764 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3766 o_ptr->discount = 99;
3767 chg_virtue(V_ENCHANT, 2);
3773 if (flush_failure) flush();
3776 msg_print("¼ºÇÔ¤·¤¿¡£");
3778 msg_print("Failed.");
3781 chg_virtue(V_ENCHANT, -2);
3790 * Potions "smash open" and cause an area effect when
3791 * (1) they are shattered while in the player's inventory,
3792 * due to cold (etc) attacks;
3793 * (2) they are thrown at a monster, or obstacle;
3794 * (3) they are shattered by a "cold ball" or other such spell
3795 * while lying on the floor.
3798 * who --- who caused the potion to shatter (0=player)
3799 * potions that smash on the floor are assumed to
3800 * be caused by no-one (who = 1), as are those that
3801 * shatter inside the player inventory.
3802 * (Not anymore -- I changed this; TY)
3803 * y, x --- coordinates of the potion (or player if
3804 * the potion was in her inventory);
3805 * o_ptr --- pointer to the potion object.
3807 bool potion_smash_effect(int who, int y, int x, int k_idx)
3814 object_kind *k_ptr = &k_info[k_idx];
3816 switch (k_ptr->sval)
3818 case SV_POTION_SALT_WATER:
3819 case SV_POTION_SLIME_MOLD:
3820 case SV_POTION_LOSE_MEMORIES:
3821 case SV_POTION_DEC_STR:
3822 case SV_POTION_DEC_INT:
3823 case SV_POTION_DEC_WIS:
3824 case SV_POTION_DEC_DEX:
3825 case SV_POTION_DEC_CON:
3826 case SV_POTION_DEC_CHR:
3827 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3828 case SV_POTION_APPLE_JUICE:
3831 case SV_POTION_INFRAVISION:
3832 case SV_POTION_DETECT_INVIS:
3833 case SV_POTION_SLOW_POISON:
3834 case SV_POTION_CURE_POISON:
3835 case SV_POTION_BOLDNESS:
3836 case SV_POTION_RESIST_HEAT:
3837 case SV_POTION_RESIST_COLD:
3838 case SV_POTION_HEROISM:
3839 case SV_POTION_BESERK_STRENGTH:
3840 case SV_POTION_RES_STR:
3841 case SV_POTION_RES_INT:
3842 case SV_POTION_RES_WIS:
3843 case SV_POTION_RES_DEX:
3844 case SV_POTION_RES_CON:
3845 case SV_POTION_RES_CHR:
3846 case SV_POTION_INC_STR:
3847 case SV_POTION_INC_INT:
3848 case SV_POTION_INC_WIS:
3849 case SV_POTION_INC_DEX:
3850 case SV_POTION_INC_CON:
3851 case SV_POTION_INC_CHR:
3852 case SV_POTION_AUGMENTATION:
3853 case SV_POTION_ENLIGHTENMENT:
3854 case SV_POTION_STAR_ENLIGHTENMENT:
3855 case SV_POTION_SELF_KNOWLEDGE:
3856 case SV_POTION_EXPERIENCE:
3857 case SV_POTION_RESISTANCE:
3858 case SV_POTION_INVULNERABILITY:
3859 case SV_POTION_NEW_LIFE:
3860 /* All of the above potions have no effect when shattered */
3862 case SV_POTION_SLOWNESS:
3867 case SV_POTION_POISON:
3872 case SV_POTION_BLINDNESS:
3876 case SV_POTION_CONFUSION: /* Booze */
3880 case SV_POTION_SLEEP:
3884 case SV_POTION_RUINATION:
3885 case SV_POTION_DETONATIONS:
3887 dam = damroll(25, 25);
3890 case SV_POTION_DEATH:
3891 dt = GF_DEATH_RAY; /* !! */
3892 dam = k_ptr->level * 10;
3896 case SV_POTION_SPEED:
3899 case SV_POTION_CURE_LIGHT:
3901 dam = damroll(2, 3);
3903 case SV_POTION_CURE_SERIOUS:
3905 dam = damroll(4, 3);
3907 case SV_POTION_CURE_CRITICAL:
3908 case SV_POTION_CURING:
3910 dam = damroll(6, 3);
3912 case SV_POTION_HEALING:
3914 dam = damroll(10, 10);
3916 case SV_POTION_RESTORE_EXP:
3921 case SV_POTION_LIFE:
3923 dam = damroll(50, 50);
3926 case SV_POTION_STAR_HEALING:
3928 dam = damroll(50, 50);
3931 case SV_POTION_RESTORE_MANA: /* MANA */
3933 dam = damroll(10, 10);
3940 (void)project(who, radius, y, x, dam, dt,
3941 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3943 /* XXX those potions that explode need to become "known" */
3949 * Hack -- Display all known spells in a window
3951 * XXX XXX XXX Need to analyze size of the window.
3953 * XXX XXX XXX Need more color coding.
3955 void display_spell_list(void)
3968 /* They have too many spells to list */
3969 if (p_ptr->pclass == CLASS_SORCERER) return;
3970 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3972 /* mind.c type classes */
3973 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3974 (p_ptr->pclass == CLASS_BERSERKER) ||
3975 (p_ptr->pclass == CLASS_NINJA) ||
3976 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3977 (p_ptr->pclass == CLASS_FORCETRAINER))
3983 int plev = p_ptr->lev;
3989 bool use_hp = FALSE;
3991 /* Display a list of spells */
3994 put_str("̾Á°", y, x + 5);
3995 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3997 put_str("Name", y, x + 5);
3998 put_str("Lv Mana Fail Info", y, x + 35);
4001 switch(p_ptr->pclass)
4003 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
4004 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
4005 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
4006 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
4007 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
4008 default: use_mind = 0;break;
4011 /* Dump the spells */
4012 for (i = 0; i < MAX_MIND_POWERS; i++)
4014 byte a = TERM_WHITE;
4016 /* Access the available spell */
4017 spell = mind_powers[use_mind].info[i];
4018 if (spell.min_lev > plev) break;
4020 /* Get the failure rate */
4021 chance = spell.fail;
4023 /* Reduce failure rate by "effective" level adjustment */
4024 chance -= 3 * (p_ptr->lev - spell.min_lev);
4026 /* Reduce failure rate by INT/WIS adjustment */
4027 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4031 /* Not enough mana to cast */
4032 if (spell.mana_cost > p_ptr->csp)
4034 chance += 5 * (spell.mana_cost - p_ptr->csp);
4040 /* Not enough hp to cast */
4041 if (spell.mana_cost > p_ptr->chp)
4048 /* Extract the minimum failure rate */
4049 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4051 /* Minimum failure rate */
4052 if (chance < minfail) chance = minfail;
4054 /* Stunning makes spells harder */
4055 if (p_ptr->stun > 50) chance += 25;
4056 else if (p_ptr->stun) chance += 15;
4058 /* Always a 5 percent chance of working */
4059 if (chance > 95) chance = 95;
4062 mindcraft_info(comment, use_mind, i);
4064 /* Dump the spell */
4065 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
4067 spell.min_lev, spell.mana_cost, chance, comment);
4069 Term_putstr(x, y + i + 1, -1, a, psi_desc);
4074 /* Cannot read spellbooks */
4075 if (REALM_NONE == p_ptr->realm1) return;
4077 /* Normal spellcaster with books */
4080 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
4084 /* Reset vertical */
4087 /* Vertical location */
4088 y = (j < 3) ? 0 : (m[j - 3] + 2);
4090 /* Horizontal location */
4094 for (i = 0; i < 32; i++)
4096 byte a = TERM_WHITE;
4098 /* Access the spell */
4099 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
4101 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
4105 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
4108 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
4111 if (s_ptr->slevel >= 99)
4115 strcpy(name, "(ȽÆÉÉÔǽ)");
4117 strcpy(name, "(illegible)");
4127 ((p_ptr->spell_forgotten1 & (1L << i))) :
4128 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4135 else if (!((j < 1) ?
4136 (p_ptr->spell_learned1 & (1L << i)) :
4137 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4144 else if (!((j < 1) ?
4145 (p_ptr->spell_worked1 & (1L << i)) :
4146 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4152 /* Dump the spell --(-- */
4153 sprintf(out_val, "%c/%c) %-20.20s",
4154 I2A(n / 8), I2A(n % 8), name);
4159 /* Dump onto the window */
4160 Term_putstr(x, m[j], -1, a, out_val);
4170 * Returns experience of a spell
4172 s16b experience_of_spell(int spell, int use_realm)
4174 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4175 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4176 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4177 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4183 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4185 int mod_need_mana(int need_mana, int spell, int realm)
4187 #define MANA_CONST 2400
4189 #define DEC_MANA_DIV 3
4192 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4195 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4196 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4198 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4199 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4200 need_mana /= MANA_CONST * MANA_DIV;
4201 if (need_mana < 1) need_mana = 1;
4204 /* Non-realm magic */
4207 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4219 * Modify spell fail rate
4220 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4222 int mod_spell_chance_1(int chance)
4224 chance += p_ptr->to_m_chance;
4226 if (p_ptr->heavy_spell) chance += 20;
4228 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4229 else if (p_ptr->easy_spell) chance -= 3;
4230 else if (p_ptr->dec_mana) chance -= 2;
4237 * Modify spell fail rate (as "suffix" process)
4238 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4239 * Note: variable "chance" cannot be negative.
4241 int mod_spell_chance_2(int chance)
4243 if (p_ptr->dec_mana) chance--;
4245 if (p_ptr->heavy_spell) chance += 5;
4247 return MAX(chance, 0);
4252 * Returns spell chance of failure for spell -RAK-
4254 s16b spell_chance(int spell, int use_realm)
4256 int chance, minfail;
4259 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4262 /* Paranoia -- must be literate */
4263 if (!mp_ptr->spell_book) return (100);
4265 if (use_realm == REALM_HISSATSU) return 0;
4267 /* Access the spell */
4268 if (!is_magic(use_realm))
4270 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4274 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4277 /* Extract the base spell failure rate */
4278 chance = s_ptr->sfail;
4280 /* Reduce failure rate by "effective" level adjustment */
4281 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4283 /* Reduce failure rate by INT/WIS adjustment */
4284 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4287 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4289 /* Extract mana consumption rate */
4290 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4292 /* Not enough mana to cast */
4293 if (need_mana > p_ptr->csp)
4295 chance += 5 * (need_mana - p_ptr->csp);
4298 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4300 /* Extract the minimum failure rate */
4301 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4304 * Non mage/priest characters never get too good
4305 * (added high mage, mindcrafter)
4307 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4309 if (minfail < 5) minfail = 5;
4312 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4313 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4314 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4316 chance = mod_spell_chance_1(chance);
4318 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4319 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4320 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4322 /* Minimum failure rate */
4323 if (chance < minfail) chance = minfail;
4325 /* Stunning makes spells harder */
4326 if (p_ptr->stun > 50) chance += 25;
4327 else if (p_ptr->stun) chance += 15;
4329 /* Always a 5 percent chance of working */
4330 if (chance > 95) chance = 95;
4332 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4333 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4335 s16b exp = experience_of_spell(spell, use_realm);
4336 if (exp >= SPELL_EXP_EXPERT) chance--;
4337 if (exp >= SPELL_EXP_MASTER) chance--;
4340 /* Return the chance */
4341 return mod_spell_chance_2(chance);
4347 * Determine if a spell is "okay" for the player to cast or study
4348 * The spell must be legible, not forgotten, and also, to cast,
4349 * it must be known, and to study, it must not be known.
4351 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4355 /* Access the spell */
4356 if (!is_magic(use_realm))
4358 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4362 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4365 /* Spell is illegal */
4366 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4368 /* Spell is forgotten */
4369 if ((use_realm == p_ptr->realm2) ?
4370 (p_ptr->spell_forgotten2 & (1L << spell)) :
4371 (p_ptr->spell_forgotten1 & (1L << spell)))
4377 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4378 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4380 /* Spell is learned */
4381 if ((use_realm == p_ptr->realm2) ?
4382 (p_ptr->spell_learned2 & (1L << spell)) :
4383 (p_ptr->spell_learned1 & (1L << spell)))
4386 return (!study_pray);
4389 /* Okay to study, not to cast */
4396 * Extra information on a spell -DRS-
4398 * We can use up to 14 characters of the buffer 'p'
4400 * The strings in this function were extracted from the code in the
4401 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4403 static void spell_info(char *p, int spell, int use_realm)
4405 int plev = p_ptr->lev;
4408 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4409 p_ptr->pclass == CLASS_HIGH_MAGE ||
4410 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4412 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4413 p_ptr->pclass == CLASS_HIGH_MAGE ||
4414 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4416 cptr s_dam = "»½ý:";
4417 cptr s_dur = "´ü´Ö:";
4418 cptr s_range = "ÈÏ°Ï:";
4419 cptr s_heal = "²óÉü:";
4420 cptr s_random = "¥é¥ó¥À¥à";
4421 cptr s_delay = "ÃÙ±ä:";
4423 cptr s_dam = "dam ";
4424 cptr s_dur = "dur ";
4425 cptr s_range = "range ";
4426 cptr s_heal = "heal ";
4427 cptr s_random = "random";
4428 cptr s_delay = "delay ";
4433 /* Analyze the spell */
4436 case REALM_LIFE: /* Life */
4439 case 0: sprintf(p, " %s2d10", s_heal); break;
4440 case 1: sprintf(p, " %s12+d12", s_dur); break;
4441 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4442 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4443 case 5: sprintf(p, " %s4d10", s_heal); break;
4444 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4445 case 10: sprintf(p, " %s8d10", s_heal); break;
4446 case 11: sprintf(p, " %s20+d20", s_dur); break;
4447 case 14: sprintf(p, " %s300", s_heal); break;
4448 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4449 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4450 case 21: sprintf(p, " %s15+d21", s_delay); break;
4451 case 29: sprintf(p, " %s2000", s_heal); break;
4452 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4456 case REALM_SORCERY: /* Sorcery */
4459 case 1: sprintf(p, " %s10", s_range); break;
4460 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4461 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4462 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4463 case 18: sprintf(p, " %s25+d30", s_dur); break;
4464 case 22: sprintf(p, " %s15+d21", s_delay); break;
4465 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4466 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4468 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4470 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4472 case 27: sprintf(p, " %s25+d30", s_dur); break;
4473 case 31: sprintf(p, " %s4+d4", s_dur); break;
4477 case REALM_NATURE: /* Nature */
4481 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4483 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4485 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4486 case 6: sprintf(p, " %s20+d20", s_dur); break;
4487 case 7: sprintf(p, " %s2d8", s_heal); break;
4488 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4489 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4490 case 12: sprintf(p, " %s6d8", s_dam); break;
4491 case 15: sprintf(p, " %s500", s_heal); break;
4492 case 17: sprintf(p, " %s20+d30", s_dur); break;
4493 case 18: sprintf(p, " %s20+d20", s_dur); break;
4495 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4497 case 24: sprintf(p, " rad 10"); break;
4499 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4500 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4501 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4502 case 29: sprintf(p, " %s75", s_dam); break;
4503 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4507 case REALM_CHAOS: /* Chaos */
4510 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4511 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4512 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4513 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4514 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4515 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4516 case 8: sprintf(p, " %s", s_random); break;
4517 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4518 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4519 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4520 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4521 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4522 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4523 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4524 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4525 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4527 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4529 case 25: sprintf(p, " dam %d each", plev * 2); break;
4531 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4532 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4533 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4534 case 30: sprintf(p, " %s%d", s_dam, p_ptr->chp); break;
4535 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4539 case REALM_DEATH: /* Death */
4542 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4543 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4544 case 5: sprintf(p, " %s20+d20", s_dur); break;
4545 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4546 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4547 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4549 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4551 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4553 case 16: sprintf(p, " %s25+d25", s_dur); break;
4554 case 17: sprintf(p, " %s", s_random); break;
4555 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4556 case 19: sprintf(p, " %s25+d25", s_dur); break;
4557 case 21: sprintf(p, " %s3*100", s_dam); break;
4558 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4559 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4560 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4561 case 30: sprintf(p, " %s666", s_dam); break;
4562 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4566 case REALM_TRUMP: /* Trump */
4569 case 0: sprintf(p, " %s10", s_range); break;
4570 case 2: sprintf(p, " %s", s_random); break;
4571 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4572 case 5: sprintf(p, " %s25+d30", s_dur); break;
4574 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4576 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4578 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4579 case 14: sprintf(p, " %s15+d21", s_delay); break;
4580 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4582 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4584 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4589 case REALM_ARCANE: /* Arcane */
4592 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4593 case 4: sprintf(p, " %s10", s_range); break;
4594 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4595 case 7: sprintf(p, " %s2d8", s_heal); break;
4599 case 17: sprintf(p, " %s20+d20", s_dur); break;
4600 case 18: sprintf(p, " %s4d8", s_heal); break;
4601 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4602 case 21: sprintf(p, " %s6d8", s_dam); break;
4603 case 24: sprintf(p, " %s24+d24", s_dur); break;
4604 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4605 case 30: sprintf(p, " %s15+d21", s_delay); break;
4606 case 31: sprintf(p, " %s25+d30", s_dur); break;
4610 case REALM_ENCHANT: /* Craft */
4613 case 0: sprintf(p, " %s100+d100", s_dur); break;
4614 case 1: sprintf(p, " %s80+d80", s_dur); break;
4620 case 18: sprintf(p, " %s20+d20", s_dur); break;
4621 case 5: sprintf(p, " %s25+d25", s_dur); break;
4622 case 8: sprintf(p, " %s24+d24", s_dur); break;
4623 case 11: sprintf(p, " %s25+d25", s_dur); break;
4624 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4625 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4626 case 16: sprintf(p, " %s25+d30", s_dur); break;
4627 case 17: sprintf(p, " %s30+d20", s_dur); break;
4628 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4629 case 20: sprintf(p, " %s50+d50", s_dur); break;
4630 case 23: sprintf(p, " %s20+d20", s_dur); break;
4631 case 31: sprintf(p, " %s13+d13", s_dur); break;
4635 case REALM_DAEMON: /* Daemon */
4638 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4639 case 2: sprintf(p, " %s12+d12", s_dur); break;
4640 case 3: sprintf(p, " %s20+d20", s_dur); break;
4641 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4642 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4643 case 10: sprintf(p, " %s20+d20", s_dur); break;
4644 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4645 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4646 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4647 case 16: sprintf(p, " %s30+d25", s_dur); break;
4648 case 17: sprintf(p, " %s20+d20", s_dur); break;
4649 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4650 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4651 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4652 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4653 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4654 case 24: sprintf(p, " %s25+d25", s_dur); break;
4655 case 25: sprintf(p, " %s20+d20", s_dur); break;
4656 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4657 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4658 case 30: sprintf(p, " %s600", s_dam); break;
4659 case 31: sprintf(p, " %s15+d15", s_dur); break;
4663 case REALM_CRUSADE: /* Crusade */
4666 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4667 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4669 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4671 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4673 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4674 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4675 case 12: sprintf(p, " %s24+d24", s_dur); break;
4676 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4677 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4679 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4681 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4683 case 18: sprintf(p, " %s18+d18", s_dur); break;
4684 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4685 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4686 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4687 case 24: sprintf(p, " %s25+d25", s_dur); break;
4688 case 28: sprintf(p, " %s10+d10", s_dur); break;
4690 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4692 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4695 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4697 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4702 case REALM_MUSIC: /* Music */
4705 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4706 case 4 : sprintf(p, " %s2d6", s_heal); break;
4707 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4708 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4709 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4710 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4711 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4712 case 28: sprintf(p, " %s15d10", s_heal); break;
4713 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4718 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4720 sprintf(p, "Unknown type: %d.", use_realm);
4727 * Print a list of spells (for browsing or casting or viewing)
4729 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4731 int i, spell, exp_level, increment = 64;
4743 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4745 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4747 msg_print("Warning! print_spells called with null realm");
4751 /* Title the list */
4753 if (use_realm == REALM_HISSATSU)
4755 strcpy(buf," Lv MP");
4757 strcpy(buf," Lv SP");
4761 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4763 strcpy(buf,"Profic Lv SP Fail Effect");
4767 put_str("̾Á°", y, x + 5);
4768 put_str(buf, y, x + 29);
4770 put_str("Name", y, x + 5);
4771 put_str(buf, y, x + 29);
4774 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4775 else if (use_realm == p_ptr->realm1) increment = 0;
4776 else if (use_realm == p_ptr->realm2) increment = 32;
4778 /* Dump the spells */
4779 for (i = 0; i < num; i++)
4781 /* Access the spell */
4784 /* Access the spell */
4785 if (!is_magic(use_realm))
4787 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4791 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4794 if (use_realm == REALM_HISSATSU)
4795 need_mana = s_ptr->smana;
4798 s16b exp = experience_of_spell(spell, use_realm);
4800 /* Extract mana consumption rate */
4801 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4803 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4804 else exp_level = spell_exp_level(exp);
4807 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4808 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4809 else if (s_ptr->slevel >= 99) max = TRUE;
4810 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4812 strncpy(ryakuji, exp_level_str[exp_level], 4);
4817 if (use_menu && target_spell)
4819 if (i == (target_spell-1))
4821 strcpy(out_val, " ¡Õ ");
4823 strcpy(out_val, " > ");
4826 strcpy(out_val, " ");
4828 else sprintf(out_val, " %c) ", I2A(i));
4829 /* Skip illegible spells */
4830 if (s_ptr->slevel >= 99)
4833 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4835 strcat(out_val, format("%-30s", "(illegible)"));
4838 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4842 /* XXX XXX Could label spells above the players level */
4844 /* Get extra info */
4845 spell_info(info, spell, use_realm);
4850 /* Assume spell is known and tried */
4851 line_attr = TERM_WHITE;
4853 /* Analyze the spell */
4854 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4856 if (s_ptr->slevel > p_ptr->max_plv)
4861 comment = " unknown";
4864 line_attr = TERM_L_BLUE;
4866 else if (s_ptr->slevel > p_ptr->lev)
4871 comment = " forgotten";
4874 line_attr = TERM_YELLOW;
4877 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4882 comment = " unknown";
4885 line_attr = TERM_L_BLUE;
4887 else if ((use_realm == p_ptr->realm1) ?
4888 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4889 ((p_ptr->spell_forgotten2 & (1L << spell))))
4894 comment = " forgotten";
4897 line_attr = TERM_YELLOW;
4899 else if (!((use_realm == p_ptr->realm1) ?
4900 (p_ptr->spell_learned1 & (1L << spell)) :
4901 (p_ptr->spell_learned2 & (1L << spell))))
4906 comment = " unknown";
4909 line_attr = TERM_L_BLUE;
4911 else if (!((use_realm == p_ptr->realm1) ?
4912 (p_ptr->spell_worked1 & (1L << spell)) :
4913 (p_ptr->spell_worked2 & (1L << spell))))
4916 comment = " ̤·Ð¸³";
4918 comment = " untried";
4921 line_attr = TERM_L_GREEN;
4924 /* Dump the spell --(-- */
4925 if (use_realm == REALM_HISSATSU)
4927 strcat(out_val, format("%-25s %2d %4d",
4928 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4929 s_ptr->slevel, need_mana));
4933 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4934 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4935 (max ? '!' : ' '), ryakuji,
4936 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4938 c_prt(line_attr, out_val, y + i + 1, x);
4941 /* Clear the bottom line */
4942 prt("", y + i + 1, x);
4947 * Note that amulets, rods, and high-level spell books are immune
4948 * to "inventory damage" of any kind. Also sling ammo and shovels.
4953 * Does a given class of objects (usually) hate acid?
4954 * Note that acid can either melt or corrode something.
4956 bool hates_acid(object_type *o_ptr)
4958 /* Analyze the type */
4959 switch (o_ptr->tval)
4961 /* Wearable items */
4981 /* Staffs/Scrolls are wood/paper */
4994 /* Junk is useless */
5008 * Does a given object (usually) hate electricity?
5010 bool hates_elec(object_type *o_ptr)
5012 switch (o_ptr->tval)
5026 * Does a given object (usually) hate fire?
5027 * Hafted/Polearm weapons have wooden shafts.
5028 * Arrows/Bows are mostly wooden.
5030 bool hates_fire(object_type *o_ptr)
5032 /* Analyze the type */
5033 switch (o_ptr->tval)
5051 case TV_SORCERY_BOOK:
5052 case TV_NATURE_BOOK:
5056 case TV_ARCANE_BOOK:
5057 case TV_ENCHANT_BOOK:
5058 case TV_DAEMON_BOOK:
5059 case TV_CRUSADE_BOOK:
5061 case TV_HISSATSU_BOOK:
5072 /* Staffs/Scrolls burn */
5085 * Does a given object (usually) hate cold?
5087 bool hates_cold(object_type *o_ptr)
5089 switch (o_ptr->tval)
5106 int set_acid_destroy(object_type *o_ptr)
5108 u32b flgs[TR_FLAG_SIZE];
5109 if (!hates_acid(o_ptr)) return (FALSE);
5110 object_flags(o_ptr, flgs);
5111 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
5119 int set_elec_destroy(object_type *o_ptr)
5121 u32b flgs[TR_FLAG_SIZE];
5122 if (!hates_elec(o_ptr)) return (FALSE);
5123 object_flags(o_ptr, flgs);
5124 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
5132 int set_fire_destroy(object_type *o_ptr)
5134 u32b flgs[TR_FLAG_SIZE];
5135 if (!hates_fire(o_ptr)) return (FALSE);
5136 object_flags(o_ptr, flgs);
5137 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
5145 int set_cold_destroy(object_type *o_ptr)
5147 u32b flgs[TR_FLAG_SIZE];
5148 if (!hates_cold(o_ptr)) return (FALSE);
5149 object_flags(o_ptr, flgs);
5150 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
5156 * Destroys a type of item on a given percent chance
5157 * Note that missiles are no longer necessarily all destroyed
5158 * Destruction taken from "melee.c" code for "stealing".
5159 * New-style wands and rods handled correctly. -LM-
5160 * Returns number of items destroyed.
5162 int inven_damage(inven_func typ, int perc)
5166 char o_name[MAX_NLEN];
5168 /* Multishadow effects is determined by turn */
5169 if( p_ptr->multishadow && (turn & 1) )return 0;
5171 if (p_ptr->inside_arena) return 0;
5173 /* Count the casualties */
5176 /* Scan through the slots backwards */
5177 for (i = 0; i < INVEN_PACK; i++)
5179 o_ptr = &inventory[i];
5181 /* Skip non-objects */
5182 if (!o_ptr->k_idx) continue;
5184 /* Hack -- for now, skip artifacts */
5185 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
5187 /* Give this item slot a shot at death */
5190 /* Count the casualties */
5191 for (amt = j = 0; j < o_ptr->number; ++j)
5193 if (randint0(100) < perc) amt++;
5196 /* Some casualities */
5199 /* Get a description */
5200 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5204 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
5206 msg_format("%sour %s (%c) %s destroyed!",
5210 o_name, index_to_label(i),
5211 ((o_ptr->number > 1) ?
5212 ((amt == o_ptr->number) ? "Á´Éô" :
5213 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
5215 ((o_ptr->number > 1) ?
5216 ((amt == o_ptr->number) ? "All of y" :
5217 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
5218 o_name, index_to_label(i),
5219 ((amt > 1) ? "were" : "was"));
5223 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
5224 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
5227 /* Potions smash open */
5228 if (object_is_potion(o_ptr))
5230 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
5233 /* Reduce the charges of rods/wands */
5234 reduce_charges(o_ptr, amt);
5236 /* Destroy "amt" items */
5237 inven_item_increase(i, -amt);
5238 inven_item_optimize(i);
5240 /* Count the casualties */
5246 /* Return the casualty count */
5252 * Acid has hit the player, attempt to affect some armor.
5254 * Note that the "base armor" of an object never changes.
5256 * If any armor is damaged (or resists), the player takes less damage.
5258 static int minus_ac(void)
5260 object_type *o_ptr = NULL;
5261 u32b flgs[TR_FLAG_SIZE];
5262 char o_name[MAX_NLEN];
5265 /* Pick a (possibly empty) inventory slot */
5266 switch (randint1(7))
5268 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5269 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5270 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5271 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5272 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5273 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5274 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5277 /* Nothing to damage */
5278 if (!o_ptr->k_idx) return (FALSE);
5280 if (o_ptr->tval <= TV_WEAPON_END) return (FALSE);
5282 /* No damage left to be done */
5283 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5287 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5289 /* Extract the flags */
5290 object_flags(o_ptr, flgs);
5292 /* Object resists */
5293 if (have_flag(flgs, TR_IGNORE_ACID))
5296 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5298 msg_format("Your %s is unaffected!", o_name);
5307 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5309 msg_format("Your %s is damaged!", o_name);
5313 /* Damage the item */
5316 /* Calculate bonuses */
5317 p_ptr->update |= (PU_BONUS);
5320 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5324 /* Item was damaged */
5330 * Hurt the player with Acid
5332 int acid_dam(int dam, cptr kb_str, int monspell)
5335 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5336 bool double_resist = IS_OPPOSE_ACID();
5338 /* Total Immunity */
5339 if (p_ptr->immune_acid || (dam <= 0))
5341 learn_spell(monspell);
5345 /* Vulnerability (Ouch!) */
5346 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5347 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5349 /* Resist the damage */
5350 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5351 if (double_resist) dam = (dam + 2) / 3;
5353 if ((!(double_resist || p_ptr->resist_acid)) &&
5354 one_in_(HURT_CHANCE))
5355 (void)do_dec_stat(A_CHR);
5357 /* If any armor gets hit, defend the player */
5358 if (minus_ac()) dam = (dam + 1) / 2;
5361 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5363 /* Inventory damage */
5364 if (!(double_resist && p_ptr->resist_acid))
5365 inven_damage(set_acid_destroy, inv);
5371 * Hurt the player with electricity
5373 int elec_dam(int dam, cptr kb_str, int monspell)
5376 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5377 bool double_resist = IS_OPPOSE_ELEC();
5379 /* Total immunity */
5380 if (p_ptr->immune_elec || (dam <= 0))
5382 learn_spell(monspell);
5386 /* Vulnerability (Ouch!) */
5387 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5388 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5389 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5391 /* Resist the damage */
5392 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5393 if (double_resist) dam = (dam + 2) / 3;
5395 if ((!(double_resist || p_ptr->resist_elec)) &&
5396 one_in_(HURT_CHANCE))
5397 (void)do_dec_stat(A_DEX);
5400 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5402 /* Inventory damage */
5403 if (!(double_resist && p_ptr->resist_elec))
5404 inven_damage(set_elec_destroy, inv);
5411 * Hurt the player with Fire
5413 int fire_dam(int dam, cptr kb_str, int monspell)
5416 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5417 bool double_resist = IS_OPPOSE_FIRE();
5419 /* Totally immune */
5420 if (p_ptr->immune_fire || (dam <= 0))
5422 learn_spell(monspell);
5426 /* Vulnerability (Ouch!) */
5427 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5428 if (prace_is_(RACE_ENT)) dam += dam / 3;
5429 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5431 /* Resist the damage */
5432 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5433 if (double_resist) dam = (dam + 2) / 3;
5435 if ((!(double_resist || p_ptr->resist_fire)) &&
5436 one_in_(HURT_CHANCE))
5437 (void)do_dec_stat(A_STR);
5440 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5442 /* Inventory damage */
5443 if (!(double_resist && p_ptr->resist_fire))
5444 inven_damage(set_fire_destroy, inv);
5451 * Hurt the player with Cold
5453 int cold_dam(int dam, cptr kb_str, int monspell)
5456 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5457 bool double_resist = IS_OPPOSE_COLD();
5459 /* Total immunity */
5460 if (p_ptr->immune_cold || (dam <= 0))
5462 learn_spell(monspell);
5466 /* Vulnerability (Ouch!) */
5467 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5468 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5470 /* Resist the damage */
5471 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5472 if (double_resist) dam = (dam + 2) / 3;
5474 if ((!(double_resist || p_ptr->resist_cold)) &&
5475 one_in_(HURT_CHANCE))
5476 (void)do_dec_stat(A_STR);
5479 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5481 /* Inventory damage */
5482 if (!(double_resist && p_ptr->resist_cold))
5483 inven_damage(set_cold_destroy, inv);
5489 bool rustproof(void)
5493 char o_name[MAX_NLEN];
5496 item_tester_no_ryoute = TRUE;
5497 /* Select a piece of armour */
5498 item_tester_hook = item_tester_hook_armour;
5502 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5503 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5505 q = "Rustproof which piece of armour? ";
5506 s = "You have nothing to rustproof.";
5509 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5511 /* Get the item (in the pack) */
5514 o_ptr = &inventory[item];
5517 /* Get the item (on the floor) */
5520 o_ptr = &o_list[0 - item];
5525 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5527 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5529 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5532 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5534 msg_format("%s %s look%s as good as new!",
5535 ((item >= 0) ? "Your" : "The"), o_name,
5536 ((o_ptr->number > 1) ? "" : "s"));
5543 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5545 msg_format("%s %s %s now protected against corrosion.",
5546 ((item >= 0) ? "Your" : "The"), o_name,
5547 ((o_ptr->number > 1) ? "are" : "is"));
5558 * Curse the players armor
5560 bool curse_armor(void)
5565 char o_name[MAX_NLEN];
5568 /* Curse the body armor */
5569 o_ptr = &inventory[INVEN_BODY];
5571 /* Nothing to curse */
5572 if (!o_ptr->k_idx) return (FALSE);
5576 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5578 /* Attempt a saving throw for artifacts */
5579 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5583 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5584 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5586 msg_format("A %s tries to %s, but your %s resists the effects!",
5587 "terrible black aura", "surround your armor", o_name);
5592 /* not artifact or failed save... */
5597 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5599 msg_format("A terrible black aura blasts your %s!", o_name);
5602 chg_virtue(V_ENCHANT, -5);
5604 /* Blast the armor */
5606 o_ptr->name2 = EGO_BLASTED;
5607 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5614 for (i = 0; i < TR_FLAG_SIZE; i++)
5615 o_ptr->art_flags[i] = 0;
5618 o_ptr->curse_flags = TRC_CURSED;
5621 o_ptr->ident |= (IDENT_BROKEN);
5623 /* Recalculate bonuses */
5624 p_ptr->update |= (PU_BONUS);
5626 /* Recalculate mana */
5627 p_ptr->update |= (PU_MANA);
5630 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5638 * Curse the players weapon
5640 bool curse_weapon(bool force, int slot)
5646 char o_name[MAX_NLEN];
5649 /* Curse the weapon */
5650 o_ptr = &inventory[slot];
5652 /* Nothing to curse */
5653 if (!o_ptr->k_idx) return (FALSE);
5657 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5659 /* Attempt a saving throw */
5660 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5664 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5665 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5667 msg_format("A %s tries to %s, but your %s resists the effects!",
5668 "terrible black aura", "surround your weapon", o_name);
5673 /* not artifact or failed save... */
5678 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5680 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5683 chg_virtue(V_ENCHANT, -5);
5685 /* Shatter the weapon */
5687 o_ptr->name2 = EGO_SHATTERED;
5688 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5689 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5695 for (i = 0; i < TR_FLAG_SIZE; i++)
5696 o_ptr->art_flags[i] = 0;
5700 o_ptr->curse_flags = TRC_CURSED;
5703 o_ptr->ident |= (IDENT_BROKEN);
5705 /* Recalculate bonuses */
5706 p_ptr->update |= (PU_BONUS);
5708 /* Recalculate mana */
5709 p_ptr->update |= (PU_MANA);
5712 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5721 * Enchant some bolts
5723 bool brand_bolts(void)
5727 /* Use the first acceptable bolts */
5728 for (i = 0; i < INVEN_PACK; i++)
5730 object_type *o_ptr = &inventory[i];
5732 /* Skip non-bolts */
5733 if (o_ptr->tval != TV_BOLT) continue;
5735 /* Skip artifacts and ego-items */
5736 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5739 /* Skip cursed/broken items */
5740 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5743 if (randint0(100) < 75) continue;
5747 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5749 msg_print("Your bolts are covered in a fiery aura!");
5754 o_ptr->name2 = EGO_FLAME;
5757 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5764 if (flush_failure) flush();
5768 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5770 msg_print("The fiery enchantment failed.");
5780 * Helper function -- return a "nearby" race for polymorphing
5782 * Note that this function is one of the more "dangerous" ones...
5784 static s16b poly_r_idx(int r_idx)
5786 monster_race *r_ptr = &r_info[r_idx];
5788 int i, r, lev1, lev2;
5790 /* Hack -- Uniques/Questors never polymorph */
5791 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5792 (r_ptr->flags1 & RF1_QUESTOR))
5795 /* Allowable range of "levels" for resulting monster */
5796 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5797 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5799 /* Pick a (possibly new) non-unique race */
5800 for (i = 0; i < 1000; i++)
5802 /* Pick a new race, using a level calculation */
5803 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5805 /* Handle failure */
5811 /* Ignore unique monsters */
5812 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5814 /* Ignore monsters with incompatible levels */
5815 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5817 /* Use that index */
5829 bool polymorph_monster(int y, int x)
5831 cave_type *c_ptr = &cave[y][x];
5832 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5833 bool polymorphed = FALSE;
5835 int old_r_idx = m_ptr->r_idx;
5836 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5837 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5838 monster_type back_m;
5840 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5842 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5844 /* Memorize the monster before polymorphing */
5847 /* Pick a "new" monster race */
5848 new_r_idx = poly_r_idx(old_r_idx);
5850 /* Handle polymorph */
5851 if (new_r_idx != old_r_idx)
5855 /* Get the monsters attitude */
5856 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5857 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5858 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5860 /* "Kill" the "old" monster */
5861 delete_monster_idx(c_ptr->m_idx);
5863 /* Create a new monster (no groups) */
5864 if (place_monster_aux(0, y, x, new_r_idx, mode))
5871 /* Placing the new monster failed */
5872 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5873 m_list[hack_m_idx_ii] = back_m;
5876 if (targeted) target_who = hack_m_idx_ii;
5877 if (health_tracked) health_track(hack_m_idx_ii);
5887 static bool dimension_door_aux(int x, int y)
5889 int plev = p_ptr->lev;
5891 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5893 if (!cave_teleportable_bold(y, x) ||
5894 (distance(y, x, py, px) > plev / 2 + 10) ||
5895 (!randint0(plev / 10 + 10)))
5897 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5898 teleport_player((plev+2)*2);
5905 teleport_player_to(y, x, TRUE);
5916 bool dimension_door(void)
5920 /* Rerutn FALSE if cancelled */
5921 if (!tgt_pt(&x, &y)) return FALSE;
5923 if (dimension_door_aux(x, y)) return TRUE;
5926 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5928 msg_print("You fail to exit the astral plane correctly!");
5936 * Mirror Master's Dimension Door
5938 bool mirror_tunnel(void)
5942 /* Rerutn FALSE if cancelled */
5943 if (!tgt_pt(&x, &y)) return FALSE;
5945 if (dimension_door_aux(x, y)) return TRUE;
5948 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5950 msg_print("You fail to pass the mirror plane correctly!");
5957 bool eat_magic(int power)
5959 object_type * o_ptr;
5962 int recharge_strength = 0;
5968 char o_name[MAX_NLEN];
5970 item_tester_hook = item_tester_hook_recharge;
5974 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5975 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5977 q = "Drain which item? ";
5978 s = "You have nothing to drain.";
5981 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5985 o_ptr = &inventory[item];
5989 o_ptr = &o_list[0 - item];
5992 k_ptr = &k_info[o_ptr->k_idx];
5993 lev = get_object_level(o_ptr);
5995 if (o_ptr->tval == TV_ROD)
5997 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
6000 if (one_in_(recharge_strength))
6002 /* Activate the failure code. */
6007 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
6010 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
6012 msg_print("You can't absorb energy from a discharged rod.");
6019 o_ptr->timeout += k_ptr->pval;
6025 /* All staffs, wands. */
6026 recharge_strength = (100 + power - lev) / 15;
6029 if (recharge_strength < 0) recharge_strength = 0;
6032 if (one_in_(recharge_strength))
6034 /* Activate the failure code. */
6039 if (o_ptr->pval > 0)
6041 p_ptr->csp += lev / 2;
6044 /* XXX Hack -- unstack if necessary */
6045 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
6050 /* Get local object */
6053 /* Obtain a local object */
6054 object_copy(q_ptr, o_ptr);
6056 /* Modify quantity */
6059 /* Restore the charges */
6062 /* Unstack the used item */
6064 p_ptr->total_weight -= q_ptr->weight;
6065 item = inven_carry(q_ptr);
6069 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
6071 msg_print("You unstack your staff.");
6079 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
6081 msg_print("There's no energy there to absorb!");
6085 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
6089 /* Inflict the penalties for failing a recharge. */
6092 /* Artifacts are never destroyed. */
6093 if (artifact_p(o_ptr))
6095 object_desc(o_name, o_ptr, OD_NAME_ONLY);
6097 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
6099 msg_format("The recharging backfires - %s is completely drained!", o_name);
6103 /* Artifact rods. */
6104 if (o_ptr->tval == TV_ROD)
6105 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6107 /* Artifact wands and staffs. */
6108 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
6113 /* Get the object description */
6114 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
6116 /*** Determine Seriousness of Failure ***/
6118 /* Mages recharge objects more safely. */
6119 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)
6121 /* 10% chance to blow up one rod, otherwise draining. */
6122 if (o_ptr->tval == TV_ROD)
6124 if (one_in_(10)) fail_type = 2;
6127 /* 75% chance to blow up one wand, otherwise draining. */
6128 else if (o_ptr->tval == TV_WAND)
6130 if (!one_in_(3)) fail_type = 2;
6133 /* 50% chance to blow up one staff, otherwise no effect. */
6134 else if (o_ptr->tval == TV_STAFF)
6136 if (one_in_(2)) fail_type = 2;
6141 /* All other classes get no special favors. */
6144 /* 33% chance to blow up one rod, otherwise draining. */
6145 if (o_ptr->tval == TV_ROD)
6147 if (one_in_(3)) fail_type = 2;
6150 /* 20% chance of the entire stack, else destroy one wand. */
6151 else if (o_ptr->tval == TV_WAND)
6153 if (one_in_(5)) fail_type = 3;
6156 /* Blow up one staff. */
6157 else if (o_ptr->tval == TV_STAFF)
6163 /*** Apply draining and destruction. ***/
6165 /* Drain object or stack of objects. */
6168 if (o_ptr->tval == TV_ROD)
6171 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
6173 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
6176 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6178 else if (o_ptr->tval == TV_WAND)
6181 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
6183 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
6188 /* Staffs aren't drained. */
6191 /* Destroy an object or one in a stack of objects. */
6194 if (o_ptr->number > 1)
6197 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
6199 msg_format("Wild magic consumes one of your %s!", o_name);
6202 /* Reduce rod stack maximum timeout, drain wands. */
6203 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
6204 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
6209 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
6211 msg_format("Wild magic consumes your %s!", o_name);
6214 /* Reduce and describe inventory */
6217 inven_item_increase(item, -1);
6218 inven_item_describe(item);
6219 inven_item_optimize(item);
6222 /* Reduce and describe floor item */
6225 floor_item_increase(0 - item, -1);
6226 floor_item_describe(0 - item);
6227 floor_item_optimize(0 - item);
6231 /* Destroy all members of a stack of objects. */
6234 if (o_ptr->number > 1)
6236 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
6238 msg_format("Wild magic consumes all your %s!", o_name);
6243 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
6245 msg_format("Wild magic consumes your %s!", o_name);
6250 /* Reduce and describe inventory */
6253 inven_item_increase(item, -999);
6254 inven_item_describe(item);
6255 inven_item_optimize(item);
6258 /* Reduce and describe floor item */
6261 floor_item_increase(0 - item, -999);
6262 floor_item_describe(0 - item);
6263 floor_item_optimize(0 - item);
6269 if (p_ptr->csp > p_ptr->msp)
6271 p_ptr->csp = p_ptr->msp;
6274 /* Redraw mana and hp */
6275 p_ptr->redraw |= (PR_MANA);
6277 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6278 p_ptr->window |= (PW_INVEN);
6284 bool summon_kin_player(int level, int y, int x, u32b mode)
6286 bool pet = (bool)(mode & PM_FORCE_PET);
6287 if (!pet) mode |= PM_NO_PET;
6289 switch (p_ptr->mimic_form)
6292 switch (p_ptr->prace)
6296 case RACE_BARBARIAN:
6299 summon_kin_type = 'p';
6309 case RACE_MIND_FLAYER:
6312 summon_kin_type = 'h';
6315 summon_kin_type = 'o';
6317 case RACE_HALF_TROLL:
6318 summon_kin_type = 'T';
6320 case RACE_HALF_OGRE:
6321 summon_kin_type = 'O';
6323 case RACE_HALF_GIANT:
6324 case RACE_HALF_TITAN:
6326 summon_kin_type = 'P';
6329 summon_kin_type = 'y';
6332 summon_kin_type = 'K';
6335 summon_kin_type = 'k';
6338 if (one_in_(13)) summon_kin_type = 'U';
6339 else summon_kin_type = 'u';
6341 case RACE_DRACONIAN:
6342 summon_kin_type = 'd';
6346 summon_kin_type = 'g';
6349 if (one_in_(13)) summon_kin_type = 'L';
6350 else summon_kin_type = 's';
6353 summon_kin_type = 'z';
6356 summon_kin_type = 'V';
6359 summon_kin_type = 'G';
6362 summon_kin_type = 'I';
6365 summon_kin_type = '#';
6368 summon_kin_type = 'A';
6371 summon_kin_type = 'U';
6374 summon_kin_type = 'p';
6379 if (one_in_(13)) summon_kin_type = 'U';
6380 else summon_kin_type = 'u';
6382 case MIMIC_DEMON_LORD:
6383 summon_kin_type = 'U';
6386 summon_kin_type = 'V';
6389 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);