4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Spell code (part 3) */
15 /* Maximum number of tries for teleporting */
18 /* 1/x chance of reducing stats (for elemental attacks) */
19 #define HURT_CHANCE 16
23 * Teleport a monster, normally up to "dis" grids away.
25 * Attempt to move the monster at least "dis/2" grids away.
27 * But allow variation to prevent infinite loops.
29 bool teleport_away(int m_idx, int dis, bool dec_valour)
31 int oy, ox, d, i, min;
37 monster_type *m_ptr = &m_list[m_idx];
41 if (!m_ptr->r_idx) return (FALSE);
43 /* Save the old location */
47 /* Minimum distance */
51 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
52 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
54 chg_virtue(V_VALOUR, -1);
62 /* Verify max distance */
63 if (dis > 200) dis = 200;
65 /* Try several locations */
66 for (i = 0; i < 500; i++)
68 /* Pick a (possibly illegal) location */
71 ny = rand_spread(oy, dis);
72 nx = rand_spread(ox, dis);
73 d = distance(oy, ox, ny, nx);
74 if ((d >= min) && (d <= dis)) break;
77 /* Ignore illegal locations */
78 if (!in_bounds(ny, nx)) continue;
80 /* Require "empty" floor space */
81 if (!cave_empty_bold(ny, nx)) continue;
83 /* Hack -- no teleport onto glyph of warding */
84 if (is_glyph_grid(&cave[ny][nx])) continue;
85 if (is_explosive_rune_grid(&cave[ny][nx])) continue;
87 /* ...nor onto the Pattern */
88 if (pattern_tile(ny, nx)) continue;
90 /* No teleporting into vaults and such */
91 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
92 if (cave[ny][nx].info & CAVE_ICKY) continue;
94 /* This grid looks good */
101 /* Increase the maximum distance */
104 /* Decrease the minimum distance */
107 /* Stop after MAX_TRIES tries */
108 if (tries > MAX_TRIES) return (FALSE);
112 sound(SOUND_TPOTHER);
114 /* Update the new location */
115 cave[ny][nx].m_idx = m_idx;
117 /* Update the old location */
118 cave[oy][ox].m_idx = 0;
120 /* Move the monster */
124 /* Forget the counter target */
127 /* Update the monster (new location) */
128 update_mon(m_idx, TRUE);
130 /* Redraw the old grid */
133 /* Redraw the new grid */
136 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
137 p_ptr->update |= (PU_MON_LITE);
145 * Teleport monster next to a grid near the given location
147 void teleport_monster_to(int m_idx, int ty, int tx, int power)
149 int ny, nx, oy, ox, d, i, min;
153 monster_type *m_ptr = &m_list[m_idx];
157 if (!m_ptr->r_idx) return;
160 if (randint1(100) > power) return;
166 /* Save the old location */
170 /* Minimum distance */
173 /* Look until done */
174 while (look && --attempts)
176 /* Verify max distance */
177 if (dis > 200) dis = 200;
179 /* Try several locations */
180 for (i = 0; i < 500; i++)
184 /* Pick a (possibly illegal) location */
187 ny = rand_spread(ty, dis);
188 nx = rand_spread(tx, dis);
189 d = distance(ty, tx, ny, nx);
190 if ((d >= min) && (d <= dis)) break;
193 /* Ignore illegal locations */
194 if (!in_bounds(ny, nx)) continue;
196 /* Require "empty" floor space */
197 if (!cave_empty_bold(ny, nx)) continue;
199 c_ptr = &cave[ny][nx];
201 /* Hack -- no teleport onto glyph of warding */
202 if (is_glyph_grid(c_ptr)) continue;
203 if (is_explosive_rune_grid(c_ptr)) continue;
205 /* ...nor onto the Pattern */
206 if (pattern_tile(ny, nx)) continue;
208 /* No teleporting into vaults and such */
209 /* if (c_ptr->info & (CAVE_ICKY)) continue; */
211 /* This grid looks good */
218 /* Increase the maximum distance */
221 /* Decrease the minimum distance */
225 if (attempts < 1) return;
228 sound(SOUND_TPOTHER);
230 /* Update the new location */
231 cave[ny][nx].m_idx = m_idx;
233 /* Update the old location */
234 cave[oy][ox].m_idx = 0;
236 /* Move the monster */
240 /* Update the monster (new location) */
241 update_mon(m_idx, TRUE);
243 /* Redraw the old grid */
246 /* Redraw the new grid */
249 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
250 p_ptr->update |= (PU_MON_LITE);
254 bool cave_teleportable_bold(int y, int x, bool passive)
256 cave_type *c_ptr = &cave[y][x];
257 feature_type *f_ptr = &f_info[c_ptr->feat];
259 /* Require "teleportable" space */
260 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
262 /* No teleporting into vaults and such */
263 if (c_ptr->info & CAVE_ICKY) return FALSE;
265 if (c_ptr->m_idx) return FALSE;
269 if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
271 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
273 if (!p_ptr->ffall && !p_ptr->can_swim) return FALSE;
276 if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
278 /* Always forbid deep lava */
279 if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
281 /* Forbid shallow lava when the player don't have levitation */
282 if (!p_ptr->ffall) return FALSE;
285 if (have_flag(f_ptr->flags, FF_HIT_TRAP))
287 if (!is_known_trap(c_ptr) || !trap_can_be_ignored(c_ptr->feat)) return FALSE;
296 * Teleport the player to a location up to "dis" grids away.
298 * If no such spaces are readily available, the distance may increase.
299 * Try very hard to move the player at least a quarter that distance.
301 * When long-range teleport effects are considered, there is a nasty
302 * tendency to "bounce" the player between two or three different spots
303 * because these are the only spots that are "far enough" way to satisfy
304 * the algorithm. Therefore, if the teleport distance is more than 50,
305 * we decrease the minimum acceptable distance to try to increase randomness.
308 void teleport_player(int dis, bool passive)
310 int d, i, min, ox, oy;
321 if (p_ptr->wild_mode) return;
323 if (p_ptr->anti_tele)
326 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
328 msg_print("A mysterious force prevents you from teleporting!");
334 if (dis > 200) dis = 200; /* To be on the safe side... */
336 /* Minimum distance */
337 min = dis / (dis > 50 ? 3 : 2);
339 /* Look until done */
344 /* Verify max distance */
345 if (dis > 200) dis = 200;
347 /* Try several locations */
348 for (i = 0; i < 500; i++)
350 /* Pick a (possibly illegal) location */
353 y = rand_spread(py, dis);
354 x = rand_spread(px, dis);
355 d = distance(py, px, y, x);
356 if ((d >= min) && (d <= dis)) break;
359 /* Ignore illegal locations */
360 if (!in_bounds(y, x)) continue;
362 if (!cave_teleportable_bold(y, x, passive)) continue;
364 /* This grid looks good */
371 /* Increase the maximum distance */
374 /* Decrease the minimum distance */
377 /* Stop after MAX_TRIES tries */
378 if (tries > MAX_TRIES) return;
382 sound(SOUND_TELEPORT);
385 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
386 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
389 /* Save the old location */
393 /* Move the player */
394 (void)move_player_effect(py, px, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
396 /* Monsters with teleport ability may follow the player */
397 for (xx = -1; xx < 2; xx++)
399 for (yy = -1; yy < 2; yy++)
401 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
403 /* A monster except your mount may follow */
404 if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
406 monster_type *m_ptr = &m_list[tmp_m_idx];
407 monster_race *r_ptr = &r_info[m_ptr->r_idx];
410 * The latter limitation is to avoid
411 * totally unkillable suckers...
413 if ((r_ptr->flags6 & RF6_TPORT) &&
414 !(r_ptr->flagsr & RFR_RES_TELE))
416 if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, y, x, r_ptr->level);
426 * Teleport player to a grid near the given location
428 * This function is slightly obsessive about correctness.
429 * This function allows teleporting into vaults (!)
431 void teleport_player_to(int ny, int nx, bool no_tele, bool passive)
433 int y, x, dis = 0, ctr = 0;
435 if (p_ptr->anti_tele && no_tele)
438 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
440 msg_print("A mysterious force prevents you from teleporting!");
446 /* Find a usable location */
449 /* Pick a nearby legal location */
452 y = rand_spread(ny, dis);
453 x = rand_spread(nx, dis);
454 if (in_bounds(y, x)) break;
457 /* Accept any grid when wizard mode */
458 if (p_ptr->wizard) break;
460 /* Accept teleportable floor grids */
461 if (cave_teleportable_bold(y, x, passive)) break;
463 /* Occasionally advance the distance */
464 if (++ctr > (4 * dis * dis + 4 * dis + 1))
472 sound(SOUND_TELEPORT);
474 /* Move the player */
475 (void)move_player_effect(py, px, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
481 * Teleport the player one level up or down (random when legal)
482 * Note: If m_idx <= 0, target is player.
484 void teleport_level(int m_idx)
490 if (m_idx <= 0) /* To player */
493 strcpy(m_name, "¤¢¤Ê¤¿");
495 strcpy(m_name, "you");
498 else /* To monster */
500 monster_type *m_ptr = &m_list[m_idx];
502 /* Get the monster name (or "it") */
503 monster_desc(m_name, m_ptr, 0);
508 /* No effect in some case */
509 if (TELE_LEVEL_IS_INEFF(m_idx))
512 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
514 if (see_m) msg_print("There is no effect.");
520 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
523 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
525 msg_print("A mysterious force prevents you from teleporting!");
530 /* Choose up or down */
531 if (randint0(100) < 50) go_up = TRUE;
534 if ((m_idx <= 0) && p_ptr->wizard)
536 if (get_check("Force to go up? ")) go_up = TRUE;
537 else if (get_check("Force to go down? ")) go_up = FALSE;
541 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
544 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
546 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
548 if (m_idx <= 0) /* To player */
552 dungeon_type = p_ptr->recall_dungeon;
557 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
559 if (autosave_l) do_cmd_save_game(TRUE);
563 dun_level = d_info[dungeon_type].mindepth;
564 prepare_change_floor_mode(CFM_RAND_PLACE);
568 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
572 p_ptr->leaving = TRUE;
577 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
580 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
582 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
586 if (m_idx <= 0) /* To player */
588 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
590 if (autosave_l) do_cmd_save_game(TRUE);
592 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
597 p_ptr->inside_quest = 0;
598 p_ptr->leaving = TRUE;
604 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
606 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
610 if (m_idx <= 0) /* To player */
612 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
614 if (autosave_l) do_cmd_save_game(TRUE);
616 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
619 p_ptr->leaving = TRUE;
625 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
627 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
630 if (m_idx <= 0) /* To player */
632 /* Never reach this code on the surface */
633 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
635 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
637 if (autosave_l) do_cmd_save_game(TRUE);
639 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
642 p_ptr->leaving = TRUE;
646 /* Monster level teleportation is simple deleting now */
649 monster_type *m_ptr = &m_list[m_idx];
651 /* Check for quest completion */
652 check_quest_completion(m_ptr);
654 delete_monster_idx(m_idx);
658 sound(SOUND_TPLEVEL);
663 int choose_dungeon(cptr note, int y, int x)
669 /* Hack -- No need to choose dungeon in some case */
670 if (lite_town || vanilla_town || ironman_downward)
672 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
676 msg_format("¤Þ¤À%s¤ËÆþ¤Ã¤¿¤³¤È¤Ï¤Ê¤¤¡£", d_name + d_info[DUNGEON_ANGBAND].name);
678 msg_format("You haven't entered %s yet.", d_name + d_info[DUNGEON_ANGBAND].name);
685 /* Allocate the "dun" array */
686 C_MAKE(dun, max_d_idx, s16b);
689 for(i = 1; i < max_d_idx; i++)
694 if (!d_info[i].maxdepth) continue;
695 if (!max_dlv[i]) continue;
696 if (d_info[i].final_guardian)
698 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
700 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
703 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
705 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
707 prt(buf, y + num, x);
714 prt(" Áª¤Ù¤ë¥À¥ó¥¸¥ç¥ó¤¬¤Ê¤¤¡£", y, x);
716 prt(" No dungeon is available.", y, x);
721 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
723 prt(format("Which dungeon do you %s?: ", note), 0, 0);
728 if ((i == ESCAPE) || !num)
730 /* Free the "dun" array */
731 C_KILL(dun, max_d_idx, s16b);
736 if (i >= 'a' && i <('a'+num))
738 select_dungeon = dun[i-'a'];
745 /* Free the "dun" array */
746 C_KILL(dun, max_d_idx, s16b);
748 return select_dungeon;
753 * Recall the player to town or dungeon
755 bool recall_player(int turns)
758 * TODO: Recall the player to the last
759 * visited town when in the wilderness
763 if (p_ptr->inside_arena || ironman_downward)
766 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
768 msg_print("Nothing happens.");
774 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
777 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
779 if (get_check("Reset recall depth? "))
782 max_dlv[dungeon_type] = dun_level;
785 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
787 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
792 if (!p_ptr->word_recall)
798 select_dungeon = choose_dungeon("¤Ëµ¢´Ô", 2, 14);
800 select_dungeon = choose_dungeon("recall", 2, 14);
802 if (!select_dungeon) return FALSE;
803 p_ptr->recall_dungeon = select_dungeon;
805 p_ptr->word_recall = turns;
807 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
809 msg_print("The air about you becomes charged...");
812 p_ptr->redraw |= (PR_STATUS);
816 p_ptr->word_recall = 0;
818 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
820 msg_print("A tension leaves the air around you...");
823 p_ptr->redraw |= (PR_STATUS);
829 bool word_of_recall(void)
831 return(recall_player(randint0(21) + 15));
835 bool reset_recall(void)
837 int select_dungeon, dummy = 0;
842 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È", 2, 14);
844 select_dungeon = choose_dungeon("reset", 2, 14);
848 if (ironman_downward)
851 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
853 msg_print("Nothing happens.");
859 if (!select_dungeon) return FALSE;
862 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
864 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
869 sprintf(tmp_val, "%d", MAX(dun_level, 1));
871 /* Ask for a level */
872 if (get_string(ppp, tmp_val, 10))
874 /* Extract request */
875 dummy = atoi(tmp_val);
878 if (dummy < 1) dummy = 1;
881 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
882 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
884 max_dlv[select_dungeon] = dummy;
888 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
890 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
894 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
896 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
909 * Apply disenchantment to the player's stuff
911 * XXX XXX XXX This function is also called from the "melee" code
913 * Return "TRUE" if the player notices anything
915 bool apply_disenchant(int mode)
919 char o_name[MAX_NLEN];
920 int to_h, to_d, to_a, pval;
922 /* Pick a random slot */
925 case 1: t = INVEN_RARM; break;
926 case 2: t = INVEN_LARM; break;
927 case 3: t = INVEN_BOW; break;
928 case 4: t = INVEN_BODY; break;
929 case 5: t = INVEN_OUTER; break;
930 case 6: t = INVEN_HEAD; break;
931 case 7: t = INVEN_HANDS; break;
932 case 8: t = INVEN_FEET; break;
936 o_ptr = &inventory[t];
938 /* No item, nothing happens */
939 if (!o_ptr->k_idx) return (FALSE);
941 /* Disenchant equipments only -- No disenchant on monster ball */
942 if (o_ptr->tval < TV_EQUIP_BEGIN || TV_EQUIP_END < o_ptr->tval)
945 /* Nothing to disenchant */
946 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
948 /* Nothing to notice */
953 /* Describe the object */
954 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
957 /* Artifacts have 71% chance to resist */
958 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 71))
962 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
964 msg_format("Your %s (%c) resist%s disenchantment!",
965 o_name, index_to_label(t),
966 ((o_ptr->number != 1) ? "" : "s"));
975 /* Memorize old value */
981 /* Disenchant tohit */
982 if (o_ptr->to_h > 0) o_ptr->to_h--;
983 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
985 /* Disenchant todam */
986 if (o_ptr->to_d > 0) o_ptr->to_d--;
987 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
989 /* Disenchant toac */
990 if (o_ptr->to_a > 0) o_ptr->to_a--;
991 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
993 /* Disenchant pval (occasionally) */
994 /* Unless called from wild_magic() */
995 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
997 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
998 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1002 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
1003 o_name, index_to_label(t) );
1005 msg_format("Your %s (%c) %s disenchanted!",
1006 o_name, index_to_label(t),
1007 ((o_ptr->number != 1) ? "were" : "was"));
1010 chg_virtue(V_HARMONY, 1);
1011 chg_virtue(V_ENCHANT, -2);
1013 /* Recalculate bonuses */
1014 p_ptr->update |= (PU_BONUS);
1017 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1027 void mutate_player(void)
1029 int max1, cur1, max2, cur2, ii, jj, i;
1031 /* Pick a pair of stats */
1033 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1035 max1 = p_ptr->stat_max[ii];
1036 cur1 = p_ptr->stat_cur[ii];
1037 max2 = p_ptr->stat_max[jj];
1038 cur2 = p_ptr->stat_cur[jj];
1040 p_ptr->stat_max[ii] = max2;
1041 p_ptr->stat_cur[ii] = cur2;
1042 p_ptr->stat_max[jj] = max1;
1043 p_ptr->stat_cur[jj] = cur1;
1047 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1048 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1051 p_ptr->update |= (PU_BONUS);
1058 void apply_nexus(monster_type *m_ptr)
1060 switch (randint1(7))
1062 case 1: case 2: case 3:
1064 teleport_player(200, TRUE);
1070 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE, TRUE);
1076 if (randint0(100) < p_ptr->skill_sav)
1079 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1081 msg_print("You resist the effects!");
1087 /* Teleport Level */
1094 if (randint0(100) < p_ptr->skill_sav)
1097 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1099 msg_print("You resist the effects!");
1106 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1108 msg_print("Your body starts to scramble...");
1119 * Charge a lite (torch or latern)
1121 void phlogiston(void)
1124 object_type * o_ptr = &inventory[INVEN_LITE];
1127 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1129 max_flog = FUEL_LAMP;
1133 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1135 max_flog = FUEL_TORCH;
1138 /* No torch to refill */
1142 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1144 msg_print("You are not wielding anything which uses phlogiston.");
1150 if (o_ptr->xtra4 >= max_flog)
1153 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1155 msg_print("No more phlogiston can be put in this item.");
1162 o_ptr->xtra4 += (max_flog / 2);
1166 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1168 msg_print("You add phlogiston to your light item.");
1173 if (o_ptr->xtra4 >= max_flog)
1175 o_ptr->xtra4 = max_flog;
1177 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1179 msg_print("Your light item is full.");
1184 /* Recalculate torch */
1185 p_ptr->update |= (PU_TORCH);
1189 static bool item_tester_hook_weapon_nobow(object_type *o_ptr)
1191 switch (o_ptr->tval)
1201 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
1209 * Brand the current weapon
1211 void brand_weapon(int brand_type)
1218 /* Assume enchant weapon */
1219 item_tester_hook = item_tester_hook_weapon_nobow;
1220 item_tester_no_ryoute = TRUE;
1224 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1225 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1227 q = "Enchant which weapon? ";
1228 s = "You have nothing to enchant.";
1231 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1233 /* Get the item (in the pack) */
1236 o_ptr = &inventory[item];
1239 /* Get the item (on the floor) */
1242 o_ptr = &o_list[0 - item];
1246 /* you can never modify artifacts / ego-items */
1247 /* you can never modify cursed items */
1248 /* TY: You _can_ modify broken items (if you're silly enough) */
1249 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
1250 !o_ptr->art_name && !cursed_p(o_ptr) &&
1251 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1252 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1253 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1257 /* Let's get the name before it is changed... */
1258 char o_name[MAX_NLEN];
1259 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1264 if (o_ptr->tval == TV_SWORD)
1267 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1269 act = "becomes very sharp!";
1272 o_ptr->name2 = EGO_SHARPNESS;
1273 o_ptr->pval = m_bonus(5, dun_level) + 1;
1278 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1280 act = "seems very powerful.";
1283 o_ptr->name2 = EGO_EARTHQUAKES;
1284 o_ptr->pval = m_bonus(3, dun_level);
1289 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1291 act = "seems to be looking for humans!";
1294 o_ptr->name2 = EGO_SLAY_HUMAN;
1298 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1300 act = "covered with lightning!";
1303 o_ptr->name2 = EGO_BRAND_ELEC;
1307 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1309 act = "coated with acid!";
1312 o_ptr->name2 = EGO_BRAND_ACID;
1316 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1318 act = "seems to be looking for evil monsters!";
1321 o_ptr->name2 = EGO_SLAY_EVIL;
1325 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1327 act = "seems to be looking for demons!";
1330 o_ptr->name2 = EGO_SLAY_DEMON;
1334 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1336 act = "seems to be looking for undead!";
1339 o_ptr->name2 = EGO_SLAY_UNDEAD;
1343 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1345 act = "seems to be looking for animals!";
1348 o_ptr->name2 = EGO_SLAY_ANIMAL;
1352 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1354 act = "seems to be looking for dragons!";
1357 o_ptr->name2 = EGO_SLAY_DRAGON;
1361 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1363 act = "seems to be looking for troll!s";
1366 o_ptr->name2 = EGO_SLAY_TROLL;
1370 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1372 act = "seems to be looking for orcs!";
1375 o_ptr->name2 = EGO_SLAY_ORC;
1379 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1381 act = "seems to be looking for giants!";
1384 o_ptr->name2 = EGO_SLAY_GIANT;
1388 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1390 act = "seems very unstable now.";
1393 o_ptr->name2 = EGO_TRUMP;
1394 o_ptr->pval = randint1(2);
1398 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1400 act = "thirsts for blood!";
1403 o_ptr->name2 = EGO_VAMPIRIC;
1407 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1409 act = "is coated with poison.";
1412 o_ptr->name2 = EGO_BRAND_POIS;
1416 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1418 act = "is engulfed in raw Logrus!";
1421 o_ptr->name2 = EGO_CHAOTIC;
1425 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1427 act = "is covered in a fiery shield!";
1430 o_ptr->name2 = EGO_BRAND_FIRE;
1434 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1436 act = "glows deep, icy blue!";
1439 o_ptr->name2 = EGO_BRAND_COLD;
1444 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1446 msg_format("Your %s %s", o_name, act);
1450 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1452 o_ptr->discount = 99;
1453 chg_virtue(V_ENCHANT, 2);
1457 if (flush_failure) flush();
1460 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1462 msg_print("The Branding failed.");
1465 chg_virtue(V_ENCHANT, -2);
1472 * Vanish all walls in this floor
1474 static bool vanish_dungeon(void)
1478 feature_type *f_ptr;
1479 monster_type *m_ptr;
1482 /* Prevent vasishing of quest levels and town */
1483 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1488 /* Scan all normal grids */
1489 for (y = 1; y < cur_hgt - 1; y++)
1491 for (x = 1; x < cur_wid - 1; x++)
1493 c_ptr = &cave[y][x];
1495 /* Seeing true feature code (ignore mimic) */
1496 f_ptr = &f_info[c_ptr->feat];
1498 /* Lose room and vault */
1499 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1501 m_ptr = &m_list[c_ptr->m_idx];
1504 if (c_ptr->m_idx && m_ptr->csleep)
1506 /* Reset sleep counter */
1509 /* Notice the "waking up" */
1512 /* Acquire the monster name */
1513 monster_desc(m_name, m_ptr, 0);
1515 /* Dump a message */
1517 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1519 msg_format("%^s wakes up.", m_name);
1522 /* Redraw the health bar */
1523 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
1524 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
1528 /* Process all walls, doors and patterns */
1529 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1533 /* Special boundary walls -- Top and bottom */
1534 for (x = 0; x < cur_wid; x++)
1536 c_ptr = &cave[0][x];
1537 f_ptr = &f_info[c_ptr->mimic];
1539 /* Lose room and vault */
1540 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1542 /* Set boundary mimic if needed */
1543 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1545 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1547 /* Check for change to boring grid */
1548 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1551 c_ptr = &cave[cur_hgt - 1][x];
1552 f_ptr = &f_info[c_ptr->mimic];
1554 /* Lose room and vault */
1555 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1557 /* Set boundary mimic if needed */
1558 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1560 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1562 /* Check for change to boring grid */
1563 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1567 /* Special boundary walls -- Left and right */
1568 for (y = 1; y < (cur_hgt - 1); y++)
1570 c_ptr = &cave[y][0];
1571 f_ptr = &f_info[c_ptr->mimic];
1573 /* Lose room and vault */
1574 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1576 /* Set boundary mimic if needed */
1577 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1579 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1581 /* Check for change to boring grid */
1582 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1585 c_ptr = &cave[y][cur_wid - 1];
1586 f_ptr = &f_info[c_ptr->mimic];
1588 /* Lose room and vault */
1589 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1591 /* Set boundary mimic if needed */
1592 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1594 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1596 /* Check for change to boring grid */
1597 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1601 /* Mega-Hack -- Forget the view and lite */
1602 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1605 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1607 /* Update the monsters */
1608 p_ptr->update |= (PU_MONSTERS);
1611 p_ptr->redraw |= (PR_MAP);
1614 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1620 void call_the_(void)
1624 bool do_call = TRUE;
1626 for (i = 0; i < 9; i++)
1628 c_ptr = &cave[py + ddy_ddd[i]][px + ddx_ddd[i]];
1630 if (!have_flag(f_flags_grid(c_ptr), FF_PROJECT))
1632 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1633 !permanent_wall(&f_info[c_ptr->feat]))
1643 for (i = 1; i < 10; i++)
1645 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1648 for (i = 1; i < 10; i++)
1650 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1653 for (i = 1; i < 10; i++)
1655 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1659 /* Prevent destruction of quest levels and town */
1660 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1663 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1665 msg_print("The ground trembles.");
1672 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1673 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1674 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1676 msg_format("You %s the %s too close to a wall!",
1677 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1678 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1679 msg_print("There is a loud explosion!");
1685 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1687 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1692 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1694 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1696 msg_print("The dungeon collapses...");
1701 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1703 msg_print("The dungeon trembles.");
1708 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1710 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1717 * Fetch an item (teleport it right underneath the caster)
1719 void fetch(int dir, int wgt, bool require_los)
1724 char o_name[MAX_NLEN];
1726 /* Check to see if an object is already there */
1727 if (cave[py][px].o_idx)
1730 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1732 msg_print("You can't fetch when you're already standing on something.");
1739 if (dir == 5 && target_okay())
1744 if (distance(py, px, ty, tx) > MAX_RANGE)
1747 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1749 msg_print("You can't fetch something that far away!");
1755 c_ptr = &cave[ty][tx];
1757 /* We need an item to fetch */
1761 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1763 msg_print("There is no object at this place.");
1769 /* No fetching from vault */
1770 if (c_ptr->info & CAVE_ICKY)
1773 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1775 msg_print("The item slips from your control.");
1781 /* We need to see the item */
1784 if (!player_has_los_bold(ty, tx))
1787 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1789 msg_print("You have no direct line of sight to that location.");
1794 else if (!projectable(py, px, ty, tx))
1797 msg_print("¤½¤³¤ÏÊɤθþ¤³¤¦¤Ç¤¹¡£");
1799 msg_print("You have no direct line of sight to that location.");
1808 /* Use a direction */
1809 ty = py; /* Where to drop the item */
1816 c_ptr = &cave[ty][tx];
1818 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1819 !have_flag(f_flags_bold(ty, tx), FF_PROJECT)) return;
1821 while (!c_ptr->o_idx);
1824 o_ptr = &o_list[c_ptr->o_idx];
1826 if (o_ptr->weight > wgt)
1828 /* Too heavy to 'fetch' */
1830 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1832 msg_print("The object is too heavy.");
1839 c_ptr->o_idx = o_ptr->next_o_idx;
1840 cave[py][px].o_idx = i; /* 'move' it */
1841 o_ptr->next_o_idx = 0;
1842 o_ptr->iy = (byte)py;
1843 o_ptr->ix = (byte)px;
1845 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1847 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1849 msg_format("%^s flies through the air to your feet.", o_name);
1854 p_ptr->redraw |= PR_MAP;
1858 void alter_reality(void)
1860 /* Ironman option */
1861 if (p_ptr->inside_arena || ironman_downward)
1864 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1866 msg_print("Nothing happens.");
1871 if (!p_ptr->alter_reality)
1873 int turns = randint0(21) + 15;
1875 p_ptr->alter_reality = turns;
1877 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1879 msg_print("The view around you begins to change...");
1882 p_ptr->redraw |= (PR_STATUS);
1886 p_ptr->alter_reality = 0;
1888 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1890 msg_print("The view around you got back...");
1893 p_ptr->redraw |= (PR_STATUS);
1900 * Leave a "glyph of warding" which prevents monster movement
1902 bool warding_glyph(void)
1905 if (!cave_clean_bold(py, px))
1908 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1910 msg_print("The object resists the spell.");
1916 /* Create a glyph */
1917 cave[py][px].info |= CAVE_OBJECT;
1918 cave[py][px].mimic = FEAT_GLYPH;
1929 bool place_mirror(void)
1932 if (!cave_clean_bold(py, px))
1935 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1937 msg_print("The object resists the spell.");
1943 /* Create a mirror */
1944 cave[py][px].info |= CAVE_OBJECT;
1945 cave[py][px].mimic = FEAT_MIRROR;
1947 /* Turn on the light */
1948 cave[py][px].info |= CAVE_GLOW;
1956 update_local_illumination(py, px);
1963 * Leave an "explosive rune" which prevents monster movement
1965 bool explosive_rune(void)
1968 if (!cave_clean_bold(py, px))
1971 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1973 msg_print("The object resists the spell.");
1979 /* Create a glyph */
1980 cave[py][px].info |= CAVE_OBJECT;
1981 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1994 * Identify everything being carried.
1995 * Done by a potion of "self knowledge".
1997 void identify_pack(void)
2001 /* Simply identify and know every item */
2002 for (i = 0; i < INVEN_TOTAL; i++)
2004 object_type *o_ptr = &inventory[i];
2006 /* Skip non-objects */
2007 if (!o_ptr->k_idx) continue;
2010 identify_item(o_ptr);
2012 /* Auto-inscription */
2013 autopick_alter_item(i, FALSE);
2019 * Used by the "enchant" function (chance of failure)
2020 * (modified for Zangband, we need better stuff there...) -- TY
2022 static int enchant_table[16] =
2024 0, 10, 50, 100, 200,
2025 300, 400, 500, 650, 800,
2026 950, 987, 993, 995, 998,
2032 * Removes curses from items in inventory
2034 * Note that Items which are "Perma-Cursed" (The One Ring,
2035 * The Crown of Morgoth) can NEVER be uncursed.
2037 * Note that if "all" is FALSE, then Items which are
2038 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2039 * will not be uncursed.
2041 static int remove_curse_aux(int all)
2045 /* Attempt to uncurse items being worn */
2046 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2048 object_type *o_ptr = &inventory[i];
2050 /* Skip non-objects */
2051 if (!o_ptr->k_idx) continue;
2053 /* Uncursed already */
2054 if (!cursed_p(o_ptr)) continue;
2056 /* Heavily Cursed Items need a special spell */
2057 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2059 /* Perma-Cursed Items can NEVER be uncursed */
2060 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2063 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2068 o_ptr->curse_flags = 0L;
2070 /* Hack -- Assume felt */
2071 o_ptr->ident |= (IDENT_SENSE);
2074 o_ptr->feeling = FEEL_NONE;
2076 /* Recalculate the bonuses */
2077 p_ptr->update |= (PU_BONUS);
2080 p_ptr->window |= (PW_EQUIP);
2082 /* Count the uncursings */
2086 /* Return "something uncursed" */
2092 * Remove most curses
2094 bool remove_curse(void)
2096 return (remove_curse_aux(FALSE));
2102 bool remove_all_curse(void)
2104 return (remove_curse_aux(TRUE));
2109 * Turns an object into gold, gain some of its value in a shop
2118 char o_name[MAX_NLEN];
2119 char out_val[MAX_NLEN+40];
2123 /* Hack -- force destruction */
2124 if (command_arg > 0) force = TRUE;
2128 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2129 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2131 q = "Turn which item to gold? ";
2132 s = "You have nothing to turn to gold.";
2135 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2137 /* Get the item (in the pack) */
2140 o_ptr = &inventory[item];
2143 /* Get the item (on the floor) */
2146 o_ptr = &o_list[0 - item];
2150 /* See how many items */
2151 if (o_ptr->number > 1)
2153 /* Get a quantity */
2154 amt = get_quantity(NULL, o_ptr->number);
2156 /* Allow user abort */
2157 if (amt <= 0) return FALSE;
2161 /* Describe the object */
2162 old_number = o_ptr->number;
2163 o_ptr->number = amt;
2164 object_desc(o_name, o_ptr, 0);
2165 o_ptr->number = old_number;
2167 /* Verify unless quantity given */
2170 if (confirm_destroy || (object_value(o_ptr) > 0))
2172 /* Make a verification */
2174 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2176 sprintf(out_val, "Really turn %s to gold? ", o_name);
2179 if (!get_check(out_val)) return FALSE;
2183 /* Artifacts cannot be destroyed */
2184 if (!can_player_destroy_object(o_ptr))
2188 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2190 msg_format("You fail to turn %s to gold!", o_name);
2197 price = object_value_real(o_ptr);
2203 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2205 msg_format("You turn %s to fool's gold.", o_name);
2213 if (amt > 1) price *= amt;
2215 if (price > 30000) price = 30000;
2217 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2219 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2225 p_ptr->redraw |= (PR_GOLD);
2228 p_ptr->window |= (PW_PLAYER);
2232 /* Eliminate the item (from the pack) */
2235 inven_item_increase(item, -amt);
2236 inven_item_describe(item);
2237 inven_item_optimize(item);
2240 /* Eliminate the item (from the floor) */
2243 floor_item_increase(0 - item, -amt);
2244 floor_item_describe(0 - item);
2245 floor_item_optimize(0 - item);
2254 * Hook to specify "weapon"
2256 bool item_tester_hook_weapon(object_type *o_ptr)
2258 switch (o_ptr->tval)
2272 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2279 static bool item_tester_hook_weapon2(object_type *o_ptr)
2281 switch (o_ptr->tval)
2301 * Hook to specify "armour"
2303 bool item_tester_hook_armour(object_type *o_ptr)
2305 switch (o_ptr->tval)
2326 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2328 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2330 switch (o_ptr->tval)
2359 * Check if an object is nameless weapon or armour
2361 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2363 switch (o_ptr->tval)
2382 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2384 if (object_known_p(o_ptr)) return FALSE;
2394 * Break the curse of an item
2396 static void break_curse(object_type *o_ptr)
2398 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2401 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2403 msg_print("The curse is broken!");
2406 o_ptr->curse_flags = 0L;
2408 o_ptr->ident |= (IDENT_SENSE);
2410 o_ptr->feeling = FEEL_NONE;
2416 * Enchants a plus onto an item. -RAK-
2418 * Revamped! Now takes item pointer, number of times to try enchanting,
2419 * and a flag of what to try enchanting. Artifacts resist enchantment
2420 * some of the time, and successful enchantment to at least +0 might
2421 * break a curse on the item. -CFT-
2423 * Note that an item can technically be enchanted all the way to +15 if
2424 * you wait a very, very, long time. Going from +9 to +10 only works
2425 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2427 * Note that this function can now be used on "piles" of items, and
2428 * the larger the pile, the lower the chance of success.
2430 bool enchant(object_type *o_ptr, int n, int eflag)
2432 int i, chance, prob;
2434 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2435 bool force = (eflag & ENCH_FORCE);
2438 /* Large piles resist enchantment */
2439 prob = o_ptr->number * 100;
2441 /* Missiles are easy to enchant */
2442 if ((o_ptr->tval == TV_BOLT) ||
2443 (o_ptr->tval == TV_ARROW) ||
2444 (o_ptr->tval == TV_SHOT))
2450 for (i = 0; i < n; i++)
2452 /* Hack -- Roll for pile resistance */
2453 if (!force && randint0(prob) >= 100) continue;
2455 /* Enchant to hit */
2456 if (eflag & ENCH_TOHIT)
2458 if (o_ptr->to_h < 0) chance = 0;
2459 else if (o_ptr->to_h > 15) chance = 1000;
2460 else chance = enchant_table[o_ptr->to_h];
2462 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2467 /* only when you get it above -1 -CFT */
2468 if (o_ptr->to_h >= 0)
2473 /* Enchant to damage */
2474 if (eflag & ENCH_TODAM)
2476 if (o_ptr->to_d < 0) chance = 0;
2477 else if (o_ptr->to_d > 15) chance = 1000;
2478 else chance = enchant_table[o_ptr->to_d];
2480 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2485 /* only when you get it above -1 -CFT */
2486 if (o_ptr->to_d >= 0)
2491 /* Enchant to armor class */
2492 if (eflag & ENCH_TOAC)
2494 if (o_ptr->to_a < 0) chance = 0;
2495 else if (o_ptr->to_a > 15) chance = 1000;
2496 else chance = enchant_table[o_ptr->to_a];
2498 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2503 /* only when you get it above -1 -CFT */
2504 if (o_ptr->to_a >= 0)
2511 if (!res) return (FALSE);
2513 /* Recalculate bonuses */
2514 p_ptr->update |= (PU_BONUS);
2516 /* Combine / Reorder the pack (later) */
2517 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2520 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2531 * Enchant an item (in the inventory or on the floor)
2532 * Note that "num_ac" requires armour, else weapon
2533 * Returns TRUE if attempted, FALSE if cancelled
2535 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2540 char o_name[MAX_NLEN];
2544 /* Assume enchant weapon */
2545 item_tester_hook = item_tester_hook_weapon;
2546 item_tester_no_ryoute = TRUE;
2548 /* Enchant armor if requested */
2549 if (num_ac) item_tester_hook = item_tester_hook_armour;
2553 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2554 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2556 q = "Enchant which item? ";
2557 s = "You have nothing to enchant.";
2560 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2562 /* Get the item (in the pack) */
2565 o_ptr = &inventory[item];
2568 /* Get the item (on the floor) */
2571 o_ptr = &o_list[0 - item];
2576 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2580 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2583 msg_format("%s %s glow%s brightly!",
2584 ((item >= 0) ? "Your" : "The"), o_name,
2585 ((o_ptr->number > 1) ? "" : "s"));
2590 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2591 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2592 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2598 if (flush_failure) flush();
2602 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2604 msg_print("The enchantment failed.");
2607 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2610 chg_virtue(V_ENCHANT, 1);
2614 /* Something happened */
2619 bool artifact_scroll(void)
2624 char o_name[MAX_NLEN];
2628 item_tester_no_ryoute = TRUE;
2629 /* Enchant weapon/armour */
2630 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2634 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2635 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2637 q = "Enchant which item? ";
2638 s = "You have nothing to enchant.";
2641 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2643 /* Get the item (in the pack) */
2646 o_ptr = &inventory[item];
2649 /* Get the item (on the floor) */
2652 o_ptr = &o_list[0 - item];
2657 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2661 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2663 msg_format("%s %s radiate%s a blinding light!",
2664 ((item >= 0) ? "Your" : "The"), o_name,
2665 ((o_ptr->number > 1) ? "" : "s"));
2668 if (o_ptr->name1 || o_ptr->art_name)
2671 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2673 msg_format("The %s %s already %s!",
2674 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2675 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2681 else if (o_ptr->name2)
2684 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2686 msg_format("The %s %s already %s!",
2687 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2688 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2694 else if (o_ptr->xtra3)
2697 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2699 msg_format("The %s %s already %s!",
2700 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2701 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2707 if (o_ptr->number > 1)
2710 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2711 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2713 msg_print("Not enough enough energy to enchant more than one object!");
2714 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2719 inven_item_increase(item, 1-(o_ptr->number));
2723 floor_item_increase(0-item, 1-(o_ptr->number));
2726 okay = create_artifact(o_ptr, TRUE);
2733 if (flush_failure) flush();
2737 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2739 msg_print("The enchantment failed.");
2742 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2745 chg_virtue(V_ENCHANT, 1);
2749 /* Something happened */
2755 * Identify an object
2757 bool identify_item(object_type *o_ptr)
2759 bool old_known = FALSE;
2760 char o_name[MAX_NLEN];
2763 object_desc(o_name, o_ptr, 0);
2765 if (o_ptr->ident & IDENT_KNOWN)
2768 if (!(o_ptr->ident & (IDENT_MENTAL)))
2770 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2771 chg_virtue(V_KNOWLEDGE, 1);
2774 /* Identify it fully */
2775 object_aware(o_ptr);
2776 object_known(o_ptr);
2778 /* Recalculate bonuses */
2779 p_ptr->update |= (PU_BONUS);
2781 /* Combine / Reorder the pack (later) */
2782 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2785 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2787 strcpy(record_o_name, o_name);
2791 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2793 if(record_fix_art && !old_known && artifact_p(o_ptr))
2794 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2795 if(record_rand_art && !old_known && o_ptr->art_name)
2796 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2802 static bool item_tester_hook_identify(object_type *o_ptr)
2804 return (bool)!object_known_p(o_ptr);
2807 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2809 if (object_known_p(o_ptr))
2811 return item_tester_hook_weapon_armour(o_ptr);
2815 * Identify an object in the inventory (or on the floor)
2816 * This routine does *not* automatically combine objects.
2817 * Returns TRUE if something was identified, else FALSE.
2819 bool ident_spell(bool only_equip)
2823 char o_name[MAX_NLEN];
2827 item_tester_no_ryoute = TRUE;
2830 item_tester_hook = item_tester_hook_identify_weapon_armour;
2832 item_tester_hook = item_tester_hook_identify;
2834 if (!can_get_item())
2838 item_tester_hook = item_tester_hook_weapon_armour;
2842 item_tester_hook = NULL;
2848 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2849 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2851 q = "Identify which item? ";
2852 s = "You have nothing to identify.";
2855 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2857 /* Get the item (in the pack) */
2860 o_ptr = &inventory[item];
2863 /* Get the item (on the floor) */
2866 o_ptr = &o_list[0 - item];
2870 old_known = identify_item(o_ptr);
2873 object_desc(o_name, o_ptr, 0);
2876 if (item >= INVEN_RARM)
2879 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2881 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2887 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2889 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2895 msg_format("¾²¾å: %s¡£", o_name);
2897 msg_format("On the ground: %s.", o_name);
2901 /* Auto-inscription/destroy */
2902 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2904 /* Something happened */
2910 * Mundanify an object in the inventory (or on the floor)
2911 * This routine does *not* automatically combine objects.
2912 * Returns TRUE if something was mundanified, else FALSE.
2914 bool mundane_spell(bool only_equip)
2920 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
2921 item_tester_no_ryoute = TRUE;
2925 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2926 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2928 q = "Use which item? ";
2929 s = "You have nothing you can use.";
2932 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2934 /* Get the item (in the pack) */
2937 o_ptr = &inventory[item];
2940 /* Get the item (on the floor) */
2943 o_ptr = &o_list[0 - item];
2948 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2950 msg_print("There is a bright flash of light!");
2953 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2954 byte ix = o_ptr->ix; /* X-position on map, or zero */
2955 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2956 byte marked = o_ptr->marked; /* Object is marked */
2957 s16b weight = o_ptr->number * o_ptr->weight;
2958 u16b inscription = o_ptr->inscription;
2961 object_prep(o_ptr, o_ptr->k_idx);
2965 o_ptr->next_o_idx = next_o_idx;
2966 o_ptr->marked = marked;
2967 o_ptr->inscription = inscription;
2968 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2972 /* Something happened */
2978 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2980 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2983 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2985 if (!item_tester_hook_identify_fully(o_ptr))
2987 return item_tester_hook_weapon_armour(o_ptr);
2991 * Fully "identify" an object in the inventory -BEN-
2992 * This routine returns TRUE if an item was identified.
2994 bool identify_fully(bool only_equip)
2998 char o_name[MAX_NLEN];
3002 item_tester_no_ryoute = TRUE;
3004 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
3006 item_tester_hook = item_tester_hook_identify_fully;
3008 if (!can_get_item())
3011 item_tester_hook = item_tester_hook_weapon_armour;
3013 item_tester_hook = NULL;
3018 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
3019 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3021 q = "Identify which item? ";
3022 s = "You have nothing to identify.";
3025 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
3027 /* Get the item (in the pack) */
3030 o_ptr = &inventory[item];
3033 /* Get the item (on the floor) */
3036 o_ptr = &o_list[0 - item];
3040 old_known = identify_item(o_ptr);
3042 /* Mark the item as fully known */
3043 o_ptr->ident |= (IDENT_MENTAL);
3049 object_desc(o_name, o_ptr, 0);
3052 if (item >= INVEN_RARM)
3055 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
3057 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
3065 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
3067 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3073 msg_format("¾²¾å: %s¡£", o_name);
3075 msg_format("On the ground: %s.", o_name);
3079 /* Describe it fully */
3080 (void)screen_object(o_ptr, TRUE);
3082 /* Auto-inscription/destroy */
3083 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
3093 * Hook for "get_item()". Determine if something is rechargable.
3095 bool item_tester_hook_recharge(object_type *o_ptr)
3097 /* Recharge staffs */
3098 if (o_ptr->tval == TV_STAFF) return (TRUE);
3100 /* Recharge wands */
3101 if (o_ptr->tval == TV_WAND) return (TRUE);
3103 /* Hack -- Recharge rods */
3104 if (o_ptr->tval == TV_ROD) return (TRUE);
3112 * Recharge a wand/staff/rod from the pack or on the floor.
3113 * This function has been rewritten in Oangband and ZAngband.
3115 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3116 * Chaos -- Arcane Binding --> recharge(90)
3118 * Scroll of recharging --> recharge(130)
3119 * Artifact activation/Thingol --> recharge(130)
3121 * It is harder to recharge high level, and highly charged wands,
3122 * staffs, and rods. The more wands in a stack, the more easily and
3123 * strongly they recharge. Staffs, however, each get fewer charges if
3126 * XXX XXX XXX Beware of "sliding index errors".
3128 bool recharge(int power)
3131 int recharge_strength, recharge_amount;
3140 char o_name[MAX_NLEN];
3142 /* Only accept legal items */
3143 item_tester_hook = item_tester_hook_recharge;
3147 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3148 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3150 q = "Recharge which item? ";
3151 s = "You have nothing to recharge.";
3154 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3156 /* Get the item (in the pack) */
3159 o_ptr = &inventory[item];
3162 /* Get the item (on the floor) */
3165 o_ptr = &o_list[0 - item];
3168 /* Get the object kind. */
3169 k_ptr = &k_info[o_ptr->k_idx];
3171 /* Extract the object "level" */
3172 lev = k_info[o_ptr->k_idx].level;
3175 /* Recharge a rod */
3176 if (o_ptr->tval == TV_ROD)
3178 /* Extract a recharge strength by comparing object level to power. */
3179 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3183 if (one_in_(recharge_strength))
3185 /* Activate the failure code. */
3192 /* Recharge amount */
3193 recharge_amount = (power * damroll(3, 2));
3195 /* Recharge by that amount */
3196 if (o_ptr->timeout > recharge_amount)
3197 o_ptr->timeout -= recharge_amount;
3204 /* Recharge wand/staff */
3207 /* Extract a recharge strength by comparing object level to power.
3208 * Divide up a stack of wands' charges to calculate charge penalty.
3210 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3211 recharge_strength = (100 + power - lev -
3212 (8 * o_ptr->pval / o_ptr->number)) / 15;
3214 /* All staffs, unstacked wands. */
3215 else recharge_strength = (100 + power - lev -
3216 (8 * o_ptr->pval)) / 15;
3219 if (recharge_strength < 0) recharge_strength = 0;
3222 if (one_in_(recharge_strength))
3224 /* Activate the failure code. */
3228 /* If the spell didn't backfire, recharge the wand or staff. */
3231 /* Recharge based on the standard number of charges. */
3232 recharge_amount = randint1(1 + k_ptr->pval / 2);
3234 /* Multiple wands in a stack increase recharging somewhat. */
3235 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3238 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3239 if (recharge_amount < 1) recharge_amount = 1;
3240 if (recharge_amount > 12) recharge_amount = 12;
3243 /* But each staff in a stack gets fewer additional charges,
3244 * although always at least one.
3246 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3248 recharge_amount /= o_ptr->number;
3249 if (recharge_amount < 1) recharge_amount = 1;
3252 /* Recharge the wand or staff. */
3253 o_ptr->pval += recharge_amount;
3256 /* Hack -- we no longer "know" the item */
3257 o_ptr->ident &= ~(IDENT_KNOWN);
3259 /* Hack -- we no longer think the item is empty */
3260 o_ptr->ident &= ~(IDENT_EMPTY);
3265 /* Inflict the penalties for failing a recharge. */
3268 /* Artifacts are never destroyed. */
3269 if (artifact_p(o_ptr))
3271 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3273 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3275 msg_format("The recharging backfires - %s is completely drained!", o_name);
3279 /* Artifact rods. */
3280 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3281 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3283 /* Artifact wands and staffs. */
3284 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3289 /* Get the object description */
3290 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3292 /*** Determine Seriousness of Failure ***/
3294 /* Mages recharge objects more safely. */
3295 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)
3297 /* 10% chance to blow up one rod, otherwise draining. */
3298 if (o_ptr->tval == TV_ROD)
3300 if (one_in_(10)) fail_type = 2;
3303 /* 75% chance to blow up one wand, otherwise draining. */
3304 else if (o_ptr->tval == TV_WAND)
3306 if (!one_in_(3)) fail_type = 2;
3309 /* 50% chance to blow up one staff, otherwise no effect. */
3310 else if (o_ptr->tval == TV_STAFF)
3312 if (one_in_(2)) fail_type = 2;
3317 /* All other classes get no special favors. */
3320 /* 33% chance to blow up one rod, otherwise draining. */
3321 if (o_ptr->tval == TV_ROD)
3323 if (one_in_(3)) fail_type = 2;
3326 /* 20% chance of the entire stack, else destroy one wand. */
3327 else if (o_ptr->tval == TV_WAND)
3329 if (one_in_(5)) fail_type = 3;
3332 /* Blow up one staff. */
3333 else if (o_ptr->tval == TV_STAFF)
3339 /*** Apply draining and destruction. ***/
3341 /* Drain object or stack of objects. */
3344 if (o_ptr->tval == TV_ROD)
3347 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3349 msg_print("The recharge backfires, draining the rod further!");
3352 if (o_ptr->timeout < 10000)
3353 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3355 else if (o_ptr->tval == TV_WAND)
3358 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3360 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3365 /* Staffs aren't drained. */
3368 /* Destroy an object or one in a stack of objects. */
3371 if (o_ptr->number > 1)
3373 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3375 msg_format("Wild magic consumes one of your %s!", o_name);
3380 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3382 msg_format("Wild magic consumes your %s!", o_name);
3386 /* Reduce rod stack maximum timeout, drain wands. */
3387 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3388 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3390 /* Reduce and describe inventory */
3393 inven_item_increase(item, -1);
3394 inven_item_describe(item);
3395 inven_item_optimize(item);
3398 /* Reduce and describe floor item */
3401 floor_item_increase(0 - item, -1);
3402 floor_item_describe(0 - item);
3403 floor_item_optimize(0 - item);
3407 /* Destroy all members of a stack of objects. */
3410 if (o_ptr->number > 1)
3412 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3414 msg_format("Wild magic consumes all your %s!", o_name);
3419 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3421 msg_format("Wild magic consumes your %s!", o_name);
3426 /* Reduce and describe inventory */
3429 inven_item_increase(item, -999);
3430 inven_item_describe(item);
3431 inven_item_optimize(item);
3434 /* Reduce and describe floor item */
3437 floor_item_increase(0 - item, -999);
3438 floor_item_describe(0 - item);
3439 floor_item_optimize(0 - item);
3445 /* Combine / Reorder the pack (later) */
3446 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3449 p_ptr->window |= (PW_INVEN);
3451 /* Something was done */
3459 bool bless_weapon(void)
3463 u32b flgs[TR_FLAG_SIZE];
3464 char o_name[MAX_NLEN];
3467 item_tester_no_ryoute = TRUE;
3468 /* Assume enchant weapon */
3469 item_tester_hook = item_tester_hook_weapon2;
3473 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3474 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3476 q = "Bless which weapon? ";
3477 s = "You have weapon to bless.";
3480 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3483 /* Get the item (in the pack) */
3486 o_ptr = &inventory[item];
3489 /* Get the item (on the floor) */
3492 o_ptr = &o_list[0 - item];
3497 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3499 /* Extract the flags */
3500 object_flags(o_ptr, flgs);
3502 if (cursed_p(o_ptr))
3504 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3505 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3508 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3511 msg_format("The black aura on %s %s disrupts the blessing!",
3512 ((item >= 0) ? "your" : "the"), o_name);
3519 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3522 msg_format("A malignant aura leaves %s %s.",
3523 ((item >= 0) ? "your" : "the"), o_name);
3528 o_ptr->curse_flags = 0L;
3530 /* Hack -- Assume felt */
3531 o_ptr->ident |= (IDENT_SENSE);
3534 o_ptr->feeling = FEEL_NONE;
3536 /* Recalculate the bonuses */
3537 p_ptr->update |= (PU_BONUS);
3540 p_ptr->window |= (PW_EQUIP);
3544 * Next, we try to bless it. Artifacts have a 1/3 chance of
3545 * being blessed, otherwise, the operation simply disenchants
3546 * them, godly power negating the magic. Ok, the explanation
3547 * is silly, but otherwise priests would always bless every
3548 * artifact weapon they find. Ego weapons and normal weapons
3549 * can be blessed automatically.
3551 if (have_flag(flgs, TR_BLESSED))
3554 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3557 msg_format("%s %s %s blessed already.",
3558 ((item >= 0) ? "Your" : "The"), o_name,
3559 ((o_ptr->number > 1) ? "were" : "was"));
3565 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3569 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3572 msg_format("%s %s shine%s!",
3573 ((item >= 0) ? "Your" : "The"), o_name,
3574 ((o_ptr->number > 1) ? "" : "s"));
3577 add_flag(o_ptr->art_flags, TR_BLESSED);
3578 o_ptr->discount = 99;
3582 bool dis_happened = FALSE;
3585 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3587 msg_print("The weapon resists your blessing!");
3591 /* Disenchant tohit */
3592 if (o_ptr->to_h > 0)
3595 dis_happened = TRUE;
3598 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3600 /* Disenchant todam */
3601 if (o_ptr->to_d > 0)
3604 dis_happened = TRUE;
3607 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3609 /* Disenchant toac */
3610 if (o_ptr->to_a > 0)
3613 dis_happened = TRUE;
3616 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3621 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3623 msg_print("There is a static feeling in the air...");
3627 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3630 msg_format("%s %s %s disenchanted!",
3631 ((item >= 0) ? "Your" : "The"), o_name,
3632 ((o_ptr->number > 1) ? "were" : "was"));
3638 /* Recalculate bonuses */
3639 p_ptr->update |= (PU_BONUS);
3642 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3653 bool pulish_shield(void)
3657 u32b flgs[TR_FLAG_SIZE];
3658 char o_name[MAX_NLEN];
3661 item_tester_no_ryoute = TRUE;
3662 /* Assume enchant weapon */
3663 item_tester_tval = TV_SHIELD;
3667 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3668 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3670 q = "Pulish which weapon? ";
3671 s = "You have weapon to pulish.";
3674 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3677 /* Get the item (in the pack) */
3680 o_ptr = &inventory[item];
3683 /* Get the item (on the floor) */
3686 o_ptr = &o_list[0 - item];
3691 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3693 /* Extract the flags */
3694 object_flags(o_ptr, flgs);
3696 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3697 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3700 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3702 msg_format("%s %s shine%s!",
3703 ((item >= 0) ? "Your" : "The"), o_name,
3704 ((o_ptr->number > 1) ? "" : "s"));
3706 o_ptr->name2 = EGO_REFLECTION;
3707 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3709 o_ptr->discount = 99;
3710 chg_virtue(V_ENCHANT, 2);
3716 if (flush_failure) flush();
3719 msg_print("¼ºÇÔ¤·¤¿¡£");
3721 msg_print("Failed.");
3724 chg_virtue(V_ENCHANT, -2);
3733 * Potions "smash open" and cause an area effect when
3734 * (1) they are shattered while in the player's inventory,
3735 * due to cold (etc) attacks;
3736 * (2) they are thrown at a monster, or obstacle;
3737 * (3) they are shattered by a "cold ball" or other such spell
3738 * while lying on the floor.
3741 * who --- who caused the potion to shatter (0=player)
3742 * potions that smash on the floor are assumed to
3743 * be caused by no-one (who = 1), as are those that
3744 * shatter inside the player inventory.
3745 * (Not anymore -- I changed this; TY)
3746 * y, x --- coordinates of the potion (or player if
3747 * the potion was in her inventory);
3748 * o_ptr --- pointer to the potion object.
3750 bool potion_smash_effect(int who, int y, int x, int k_idx)
3757 object_kind *k_ptr = &k_info[k_idx];
3759 switch (k_ptr->sval)
3761 case SV_POTION_SALT_WATER:
3762 case SV_POTION_SLIME_MOLD:
3763 case SV_POTION_LOSE_MEMORIES:
3764 case SV_POTION_DEC_STR:
3765 case SV_POTION_DEC_INT:
3766 case SV_POTION_DEC_WIS:
3767 case SV_POTION_DEC_DEX:
3768 case SV_POTION_DEC_CON:
3769 case SV_POTION_DEC_CHR:
3770 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3771 case SV_POTION_APPLE_JUICE:
3774 case SV_POTION_INFRAVISION:
3775 case SV_POTION_DETECT_INVIS:
3776 case SV_POTION_SLOW_POISON:
3777 case SV_POTION_CURE_POISON:
3778 case SV_POTION_BOLDNESS:
3779 case SV_POTION_RESIST_HEAT:
3780 case SV_POTION_RESIST_COLD:
3781 case SV_POTION_HEROISM:
3782 case SV_POTION_BESERK_STRENGTH:
3783 case SV_POTION_RES_STR:
3784 case SV_POTION_RES_INT:
3785 case SV_POTION_RES_WIS:
3786 case SV_POTION_RES_DEX:
3787 case SV_POTION_RES_CON:
3788 case SV_POTION_RES_CHR:
3789 case SV_POTION_INC_STR:
3790 case SV_POTION_INC_INT:
3791 case SV_POTION_INC_WIS:
3792 case SV_POTION_INC_DEX:
3793 case SV_POTION_INC_CON:
3794 case SV_POTION_INC_CHR:
3795 case SV_POTION_AUGMENTATION:
3796 case SV_POTION_ENLIGHTENMENT:
3797 case SV_POTION_STAR_ENLIGHTENMENT:
3798 case SV_POTION_SELF_KNOWLEDGE:
3799 case SV_POTION_EXPERIENCE:
3800 case SV_POTION_RESISTANCE:
3801 case SV_POTION_INVULNERABILITY:
3802 case SV_POTION_NEW_LIFE:
3803 /* All of the above potions have no effect when shattered */
3805 case SV_POTION_SLOWNESS:
3810 case SV_POTION_POISON:
3815 case SV_POTION_BLINDNESS:
3819 case SV_POTION_CONFUSION: /* Booze */
3823 case SV_POTION_SLEEP:
3827 case SV_POTION_RUINATION:
3828 case SV_POTION_DETONATIONS:
3830 dam = damroll(25, 25);
3833 case SV_POTION_DEATH:
3834 dt = GF_DEATH_RAY; /* !! */
3835 dam = k_ptr->level * 10;
3839 case SV_POTION_SPEED:
3842 case SV_POTION_CURE_LIGHT:
3844 dam = damroll(2, 3);
3846 case SV_POTION_CURE_SERIOUS:
3848 dam = damroll(4, 3);
3850 case SV_POTION_CURE_CRITICAL:
3851 case SV_POTION_CURING:
3853 dam = damroll(6, 3);
3855 case SV_POTION_HEALING:
3857 dam = damroll(10, 10);
3859 case SV_POTION_RESTORE_EXP:
3864 case SV_POTION_LIFE:
3866 dam = damroll(50, 50);
3869 case SV_POTION_STAR_HEALING:
3871 dam = damroll(50, 50);
3874 case SV_POTION_RESTORE_MANA: /* MANA */
3876 dam = damroll(10, 10);
3883 (void)project(who, radius, y, x, dam, dt,
3884 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3886 /* XXX those potions that explode need to become "known" */
3892 * Hack -- Display all known spells in a window
3894 * XXX XXX XXX Need to analyze size of the window.
3896 * XXX XXX XXX Need more color coding.
3898 void display_spell_list(void)
3911 /* They have too many spells to list */
3912 if (p_ptr->pclass == CLASS_SORCERER) return;
3913 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3915 /* mind.c type classes */
3916 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3917 (p_ptr->pclass == CLASS_BERSERKER) ||
3918 (p_ptr->pclass == CLASS_NINJA) ||
3919 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3920 (p_ptr->pclass == CLASS_FORCETRAINER))
3926 int plev = p_ptr->lev;
3932 bool use_hp = FALSE;
3934 /* Display a list of spells */
3937 put_str("̾Á°", y, x + 5);
3938 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3940 put_str("Name", y, x + 5);
3941 put_str("Lv Mana Fail Info", y, x + 35);
3944 switch(p_ptr->pclass)
3946 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3947 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3948 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3949 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3950 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3951 default: use_mind = 0;break;
3954 /* Dump the spells */
3955 for (i = 0; i < MAX_MIND_POWERS; i++)
3957 byte a = TERM_WHITE;
3959 /* Access the available spell */
3960 spell = mind_powers[use_mind].info[i];
3961 if (spell.min_lev > plev) break;
3963 /* Get the failure rate */
3964 chance = spell.fail;
3966 /* Reduce failure rate by "effective" level adjustment */
3967 chance -= 3 * (p_ptr->lev - spell.min_lev);
3969 /* Reduce failure rate by INT/WIS adjustment */
3970 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3974 /* Not enough mana to cast */
3975 if (spell.mana_cost > p_ptr->csp)
3977 chance += 5 * (spell.mana_cost - p_ptr->csp);
3983 /* Not enough hp to cast */
3984 if (spell.mana_cost > p_ptr->chp)
3991 /* Extract the minimum failure rate */
3992 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3994 /* Minimum failure rate */
3995 if (chance < minfail) chance = minfail;
3997 /* Stunning makes spells harder */
3998 if (p_ptr->stun > 50) chance += 25;
3999 else if (p_ptr->stun) chance += 15;
4001 /* Always a 5 percent chance of working */
4002 if (chance > 95) chance = 95;
4005 mindcraft_info(comment, use_mind, i);
4007 /* Dump the spell */
4008 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
4010 spell.min_lev, spell.mana_cost, chance, comment);
4012 Term_putstr(x, y + i + 1, -1, a, psi_desc);
4017 /* Cannot read spellbooks */
4018 if (REALM_NONE == p_ptr->realm1) return;
4020 /* Normal spellcaster with books */
4023 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
4027 /* Reset vertical */
4030 /* Vertical location */
4031 y = (j < 3) ? 0 : (m[j - 3] + 2);
4033 /* Horizontal location */
4037 for (i = 0; i < 32; i++)
4039 byte a = TERM_WHITE;
4041 /* Access the spell */
4042 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
4044 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
4048 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
4051 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
4054 if (s_ptr->slevel >= 99)
4058 strcpy(name, "(ȽÆÉÉÔǽ)");
4060 strcpy(name, "(illegible)");
4070 ((p_ptr->spell_forgotten1 & (1L << i))) :
4071 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4078 else if (!((j < 1) ?
4079 (p_ptr->spell_learned1 & (1L << i)) :
4080 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4087 else if (!((j < 1) ?
4088 (p_ptr->spell_worked1 & (1L << i)) :
4089 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4095 /* Dump the spell --(-- */
4096 sprintf(out_val, "%c/%c) %-20.20s",
4097 I2A(n / 8), I2A(n % 8), name);
4102 /* Dump onto the window */
4103 Term_putstr(x, m[j], -1, a, out_val);
4113 * Returns experience of a spell
4115 s16b experience_of_spell(int spell, int use_realm)
4117 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4118 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4119 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4120 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4126 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4128 int mod_need_mana(int need_mana, int spell, int realm)
4130 #define MANA_CONST 2400
4132 #define DEC_MANA_DIV 3
4135 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4138 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4139 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4141 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4142 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4143 need_mana /= MANA_CONST * MANA_DIV;
4144 if (need_mana < 1) need_mana = 1;
4147 /* Non-realm magic */
4150 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4162 * Modify spell fail rate
4163 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4165 int mod_spell_chance_1(int chance)
4167 chance += p_ptr->to_m_chance;
4169 if (p_ptr->heavy_spell) chance += 20;
4171 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4172 else if (p_ptr->easy_spell) chance -= 3;
4173 else if (p_ptr->dec_mana) chance -= 2;
4180 * Modify spell fail rate (as "suffix" process)
4181 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4182 * Note: variable "chance" cannot be negative.
4184 int mod_spell_chance_2(int chance)
4186 if (p_ptr->dec_mana) chance--;
4188 if (p_ptr->heavy_spell) chance += 5;
4190 return MAX(chance, 0);
4195 * Returns spell chance of failure for spell -RAK-
4197 s16b spell_chance(int spell, int use_realm)
4199 int chance, minfail;
4202 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4205 /* Paranoia -- must be literate */
4206 if (!mp_ptr->spell_book) return (100);
4208 if (use_realm == REALM_HISSATSU) return 0;
4210 /* Access the spell */
4211 if (!is_magic(use_realm))
4213 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4217 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4220 /* Extract the base spell failure rate */
4221 chance = s_ptr->sfail;
4223 /* Reduce failure rate by "effective" level adjustment */
4224 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4226 /* Reduce failure rate by INT/WIS adjustment */
4227 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4230 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4232 /* Extract mana consumption rate */
4233 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4235 /* Not enough mana to cast */
4236 if (need_mana > p_ptr->csp)
4238 chance += 5 * (need_mana - p_ptr->csp);
4241 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4243 /* Extract the minimum failure rate */
4244 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4247 * Non mage/priest characters never get too good
4248 * (added high mage, mindcrafter)
4250 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4252 if (minfail < 5) minfail = 5;
4255 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4256 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4257 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4259 chance = mod_spell_chance_1(chance);
4261 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4262 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4263 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4265 /* Minimum failure rate */
4266 if (chance < minfail) chance = minfail;
4268 /* Stunning makes spells harder */
4269 if (p_ptr->stun > 50) chance += 25;
4270 else if (p_ptr->stun) chance += 15;
4272 /* Always a 5 percent chance of working */
4273 if (chance > 95) chance = 95;
4275 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4276 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4278 s16b exp = experience_of_spell(spell, use_realm);
4279 if (exp >= SPELL_EXP_EXPERT) chance--;
4280 if (exp >= SPELL_EXP_MASTER) chance--;
4283 /* Return the chance */
4284 return mod_spell_chance_2(chance);
4290 * Determine if a spell is "okay" for the player to cast or study
4291 * The spell must be legible, not forgotten, and also, to cast,
4292 * it must be known, and to study, it must not be known.
4294 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4298 /* Access the spell */
4299 if (!is_magic(use_realm))
4301 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4305 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4308 /* Spell is illegal */
4309 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4311 /* Spell is forgotten */
4312 if ((use_realm == p_ptr->realm2) ?
4313 (p_ptr->spell_forgotten2 & (1L << spell)) :
4314 (p_ptr->spell_forgotten1 & (1L << spell)))
4320 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4321 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4323 /* Spell is learned */
4324 if ((use_realm == p_ptr->realm2) ?
4325 (p_ptr->spell_learned2 & (1L << spell)) :
4326 (p_ptr->spell_learned1 & (1L << spell)))
4329 return (!study_pray);
4332 /* Okay to study, not to cast */
4339 * Extra information on a spell -DRS-
4341 * We can use up to 14 characters of the buffer 'p'
4343 * The strings in this function were extracted from the code in the
4344 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4346 static void spell_info(char *p, int spell, int use_realm)
4348 int plev = p_ptr->lev;
4351 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4352 p_ptr->pclass == CLASS_HIGH_MAGE ||
4353 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4355 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4356 p_ptr->pclass == CLASS_HIGH_MAGE ||
4357 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4359 cptr s_dam = "»½ý:";
4360 cptr s_dur = "´ü´Ö:";
4361 cptr s_range = "ÈÏ°Ï:";
4362 cptr s_heal = "²óÉü:";
4363 cptr s_random = "¥é¥ó¥À¥à";
4364 cptr s_delay = "ÃÙ±ä:";
4366 cptr s_dam = "dam ";
4367 cptr s_dur = "dur ";
4368 cptr s_range = "range ";
4369 cptr s_heal = "heal ";
4370 cptr s_random = "random";
4371 cptr s_delay = "delay ";
4376 /* Analyze the spell */
4379 case REALM_LIFE: /* Life */
4382 case 0: sprintf(p, " %s2d10", s_heal); break;
4383 case 1: sprintf(p, " %s12+d12", s_dur); break;
4384 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4385 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4386 case 5: sprintf(p, " %s4d10", s_heal); break;
4387 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4388 case 10: sprintf(p, " %s8d10", s_heal); break;
4389 case 11: sprintf(p, " %s20+d20", s_dur); break;
4390 case 14: sprintf(p, " %s300", s_heal); break;
4391 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4392 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4393 case 21: sprintf(p, " %s15+d21", s_delay); break;
4394 case 29: sprintf(p, " %s2000", s_heal); break;
4395 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4399 case REALM_SORCERY: /* Sorcery */
4402 case 1: sprintf(p, " %s10", s_range); break;
4403 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4404 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4405 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4406 case 18: sprintf(p, " %s25+d30", s_dur); break;
4407 case 22: sprintf(p, " %s15+d21", s_delay); break;
4408 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4409 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4411 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4413 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4415 case 27: sprintf(p, " %s25+d30", s_dur); break;
4416 case 31: sprintf(p, " %s4+d4", s_dur); break;
4420 case REALM_NATURE: /* Nature */
4424 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4426 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4428 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4429 case 6: sprintf(p, " %s20+d20", s_dur); break;
4430 case 7: sprintf(p, " %s2d8", s_heal); break;
4431 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4432 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4433 case 12: sprintf(p, " %s6d8", s_dam); break;
4434 case 15: sprintf(p, " %s500", s_heal); break;
4435 case 17: sprintf(p, " %s20+d30", s_dur); break;
4436 case 18: sprintf(p, " %s20+d20", s_dur); break;
4438 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4440 case 24: sprintf(p, " rad 10"); break;
4442 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4443 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4444 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4445 case 29: sprintf(p, " %s75", s_dam); break;
4446 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4450 case REALM_CHAOS: /* Chaos */
4453 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4454 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4455 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4456 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4457 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4458 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4459 case 8: sprintf(p, " %s", s_random); break;
4460 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4461 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4462 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4463 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4464 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4465 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4466 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4467 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4468 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4470 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4472 case 25: sprintf(p, " dam %d each", plev * 2); break;
4474 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4475 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4476 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4477 case 30: sprintf(p, " %s%ld", s_dam, p_ptr->chp); break;
4478 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4482 case REALM_DEATH: /* Death */
4485 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4486 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4487 case 5: sprintf(p, " %s20+d20", s_dur); break;
4488 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4489 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4490 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4492 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4494 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4496 case 16: sprintf(p, " %s25+d25", s_dur); break;
4497 case 17: sprintf(p, " %s", s_random); break;
4498 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4499 case 19: sprintf(p, " %s25+d25", s_dur); break;
4500 case 21: sprintf(p, " %s3*100", s_dam); break;
4501 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4502 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4503 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4504 case 30: sprintf(p, " %s666", s_dam); break;
4505 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4509 case REALM_TRUMP: /* Trump */
4512 case 0: sprintf(p, " %s10", s_range); break;
4513 case 2: sprintf(p, " %s", s_random); break;
4514 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4515 case 5: sprintf(p, " %s25+d30", s_dur); break;
4517 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4519 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4521 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4522 case 14: sprintf(p, " %s15+d21", s_delay); break;
4523 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4525 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4527 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4532 case REALM_ARCANE: /* Arcane */
4535 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4536 case 4: sprintf(p, " %s10", s_range); break;
4537 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4538 case 7: sprintf(p, " %s2d8", s_heal); break;
4542 case 17: sprintf(p, " %s20+d20", s_dur); break;
4543 case 18: sprintf(p, " %s4d8", s_heal); break;
4544 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4545 case 21: sprintf(p, " %s6d8", s_dam); break;
4546 case 24: sprintf(p, " %s24+d24", s_dur); break;
4547 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4548 case 30: sprintf(p, " %s15+d21", s_delay); break;
4549 case 31: sprintf(p, " %s25+d30", s_dur); break;
4553 case REALM_ENCHANT: /* Craft */
4556 case 0: sprintf(p, " %s100+d100", s_dur); break;
4557 case 1: sprintf(p, " %s80+d80", s_dur); break;
4563 case 18: sprintf(p, " %s20+d20", s_dur); break;
4564 case 5: sprintf(p, " %s25+d25", s_dur); break;
4565 case 8: sprintf(p, " %s24+d24", s_dur); break;
4566 case 11: sprintf(p, " %s25+d25", s_dur); break;
4567 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4568 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4569 case 16: sprintf(p, " %s25+d30", s_dur); break;
4570 case 17: sprintf(p, " %s30+d20", s_dur); break;
4571 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4572 case 20: sprintf(p, " %s50+d50", s_dur); break;
4573 case 23: sprintf(p, " %s20+d20", s_dur); break;
4574 case 31: sprintf(p, " %s13+d13", s_dur); break;
4578 case REALM_DAEMON: /* Daemon */
4581 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4582 case 2: sprintf(p, " %s12+d12", s_dur); break;
4583 case 3: sprintf(p, " %s20+d20", s_dur); break;
4584 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4585 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4586 case 10: sprintf(p, " %s20+d20", s_dur); break;
4587 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4588 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4589 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4590 case 16: sprintf(p, " %s30+d25", s_dur); break;
4591 case 17: sprintf(p, " %s20+d20", s_dur); break;
4592 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4593 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4594 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4595 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4596 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4597 case 24: sprintf(p, " %s25+d25", s_dur); break;
4598 case 25: sprintf(p, " %s20+d20", s_dur); break;
4599 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4600 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4601 case 30: sprintf(p, " %s600", s_dam); break;
4602 case 31: sprintf(p, " %s15+d15", s_dur); break;
4606 case REALM_CRUSADE: /* Crusade */
4609 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4610 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4612 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4614 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4616 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4617 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4618 case 12: sprintf(p, " %s24+d24", s_dur); break;
4619 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4620 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4622 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4624 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4626 case 18: sprintf(p, " %s18+d18", s_dur); break;
4627 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4628 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4629 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4630 case 24: sprintf(p, " %s25+d25", s_dur); break;
4631 case 28: sprintf(p, " %s10+d10", s_dur); break;
4633 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4635 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4638 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4640 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4645 case REALM_MUSIC: /* Music */
4648 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4649 case 4 : sprintf(p, " %s2d6", s_heal); break;
4650 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4651 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4652 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4653 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4654 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4655 case 28: sprintf(p, " %s15d10", s_heal); break;
4656 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4661 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4663 sprintf(p, "Unknown type: %d.", use_realm);
4670 * Print a list of spells (for browsing or casting or viewing)
4672 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4674 int i, spell, exp_level, increment = 64;
4686 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4688 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4690 msg_print("Warning! print_spells called with null realm");
4694 /* Title the list */
4696 if (use_realm == REALM_HISSATSU)
4698 strcpy(buf," Lv MP");
4700 strcpy(buf," Lv SP");
4704 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4706 strcpy(buf,"Profic Lv SP Fail Effect");
4710 put_str("̾Á°", y, x + 5);
4711 put_str(buf, y, x + 29);
4713 put_str("Name", y, x + 5);
4714 put_str(buf, y, x + 29);
4717 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4718 else if (use_realm == p_ptr->realm1) increment = 0;
4719 else if (use_realm == p_ptr->realm2) increment = 32;
4721 /* Dump the spells */
4722 for (i = 0; i < num; i++)
4724 /* Access the spell */
4727 /* Access the spell */
4728 if (!is_magic(use_realm))
4730 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4734 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4737 if (use_realm == REALM_HISSATSU)
4738 need_mana = s_ptr->smana;
4741 s16b exp = experience_of_spell(spell, use_realm);
4743 /* Extract mana consumption rate */
4744 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4746 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4747 else exp_level = spell_exp_level(exp);
4750 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4751 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4752 else if (s_ptr->slevel >= 99) max = TRUE;
4753 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4755 strncpy(ryakuji, exp_level_str[exp_level], 4);
4760 if (use_menu && target_spell)
4762 if (i == (target_spell-1))
4764 strcpy(out_val, " ¡Õ ");
4766 strcpy(out_val, " > ");
4769 strcpy(out_val, " ");
4771 else sprintf(out_val, " %c) ", I2A(i));
4772 /* Skip illegible spells */
4773 if (s_ptr->slevel >= 99)
4776 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4778 strcat(out_val, format("%-30s", "(illegible)"));
4781 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4785 /* XXX XXX Could label spells above the players level */
4787 /* Get extra info */
4788 spell_info(info, spell, use_realm);
4793 /* Assume spell is known and tried */
4794 line_attr = TERM_WHITE;
4796 /* Analyze the spell */
4797 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4799 if (s_ptr->slevel > p_ptr->max_plv)
4804 comment = " unknown";
4807 line_attr = TERM_L_BLUE;
4809 else if (s_ptr->slevel > p_ptr->lev)
4814 comment = " forgotten";
4817 line_attr = TERM_YELLOW;
4820 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4825 comment = " unknown";
4828 line_attr = TERM_L_BLUE;
4830 else if ((use_realm == p_ptr->realm1) ?
4831 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4832 ((p_ptr->spell_forgotten2 & (1L << spell))))
4837 comment = " forgotten";
4840 line_attr = TERM_YELLOW;
4842 else if (!((use_realm == p_ptr->realm1) ?
4843 (p_ptr->spell_learned1 & (1L << spell)) :
4844 (p_ptr->spell_learned2 & (1L << spell))))
4849 comment = " unknown";
4852 line_attr = TERM_L_BLUE;
4854 else if (!((use_realm == p_ptr->realm1) ?
4855 (p_ptr->spell_worked1 & (1L << spell)) :
4856 (p_ptr->spell_worked2 & (1L << spell))))
4859 comment = " ̤·Ð¸³";
4861 comment = " untried";
4864 line_attr = TERM_L_GREEN;
4867 /* Dump the spell --(-- */
4868 if (use_realm == REALM_HISSATSU)
4870 strcat(out_val, format("%-25s %2d %4d",
4871 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4872 s_ptr->slevel, need_mana));
4876 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4877 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4878 (max ? '!' : ' '), ryakuji,
4879 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4881 c_prt(line_attr, out_val, y + i + 1, x);
4884 /* Clear the bottom line */
4885 prt("", y + i + 1, x);
4890 * Note that amulets, rods, and high-level spell books are immune
4891 * to "inventory damage" of any kind. Also sling ammo and shovels.
4896 * Does a given class of objects (usually) hate acid?
4897 * Note that acid can either melt or corrode something.
4899 bool hates_acid(object_type *o_ptr)
4901 /* Analyze the type */
4902 switch (o_ptr->tval)
4904 /* Wearable items */
4924 /* Staffs/Scrolls are wood/paper */
4937 /* Junk is useless */
4951 * Does a given object (usually) hate electricity?
4953 bool hates_elec(object_type *o_ptr)
4955 switch (o_ptr->tval)
4969 * Does a given object (usually) hate fire?
4970 * Hafted/Polearm weapons have wooden shafts.
4971 * Arrows/Bows are mostly wooden.
4973 bool hates_fire(object_type *o_ptr)
4975 /* Analyze the type */
4976 switch (o_ptr->tval)
4994 case TV_SORCERY_BOOK:
4995 case TV_NATURE_BOOK:
4999 case TV_ARCANE_BOOK:
5000 case TV_ENCHANT_BOOK:
5001 case TV_DAEMON_BOOK:
5002 case TV_CRUSADE_BOOK:
5004 case TV_HISSATSU_BOOK:
5015 /* Staffs/Scrolls burn */
5028 * Does a given object (usually) hate cold?
5030 bool hates_cold(object_type *o_ptr)
5032 switch (o_ptr->tval)
5049 int set_acid_destroy(object_type *o_ptr)
5051 u32b flgs[TR_FLAG_SIZE];
5052 if (!hates_acid(o_ptr)) return (FALSE);
5053 object_flags(o_ptr, flgs);
5054 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
5062 int set_elec_destroy(object_type *o_ptr)
5064 u32b flgs[TR_FLAG_SIZE];
5065 if (!hates_elec(o_ptr)) return (FALSE);
5066 object_flags(o_ptr, flgs);
5067 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
5075 int set_fire_destroy(object_type *o_ptr)
5077 u32b flgs[TR_FLAG_SIZE];
5078 if (!hates_fire(o_ptr)) return (FALSE);
5079 object_flags(o_ptr, flgs);
5080 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
5088 int set_cold_destroy(object_type *o_ptr)
5090 u32b flgs[TR_FLAG_SIZE];
5091 if (!hates_cold(o_ptr)) return (FALSE);
5092 object_flags(o_ptr, flgs);
5093 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
5099 * Destroys a type of item on a given percent chance
5100 * Note that missiles are no longer necessarily all destroyed
5101 * Destruction taken from "melee.c" code for "stealing".
5102 * New-style wands and rods handled correctly. -LM-
5103 * Returns number of items destroyed.
5105 int inven_damage(inven_func typ, int perc)
5109 char o_name[MAX_NLEN];
5111 /* Multishadow effects is determined by turn */
5112 if( p_ptr->multishadow && (turn & 1) )return 0;
5114 if (p_ptr->inside_arena) return 0;
5116 /* Count the casualties */
5119 /* Scan through the slots backwards */
5120 for (i = 0; i < INVEN_PACK; i++)
5122 o_ptr = &inventory[i];
5124 /* Skip non-objects */
5125 if (!o_ptr->k_idx) continue;
5127 /* Hack -- for now, skip artifacts */
5128 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
5130 /* Give this item slot a shot at death */
5133 /* Count the casualties */
5134 for (amt = j = 0; j < o_ptr->number; ++j)
5136 if (randint0(100) < perc) amt++;
5139 /* Some casualities */
5142 /* Get a description */
5143 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5147 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
5149 msg_format("%sour %s (%c) %s destroyed!",
5153 o_name, index_to_label(i),
5154 ((o_ptr->number > 1) ?
5155 ((amt == o_ptr->number) ? "Á´Éô" :
5156 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
5158 ((o_ptr->number > 1) ?
5159 ((amt == o_ptr->number) ? "All of y" :
5160 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
5161 o_name, index_to_label(i),
5162 ((amt > 1) ? "were" : "was"));
5166 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
5167 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
5170 /* Potions smash open */
5171 if (object_is_potion(o_ptr))
5173 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
5176 /* Reduce the charges of rods/wands */
5177 reduce_charges(o_ptr, amt);
5179 /* Destroy "amt" items */
5180 inven_item_increase(i, -amt);
5181 inven_item_optimize(i);
5183 /* Count the casualties */
5189 /* Return the casualty count */
5195 * Acid has hit the player, attempt to affect some armor.
5197 * Note that the "base armor" of an object never changes.
5199 * If any armor is damaged (or resists), the player takes less damage.
5201 static int minus_ac(void)
5203 object_type *o_ptr = NULL;
5204 u32b flgs[TR_FLAG_SIZE];
5205 char o_name[MAX_NLEN];
5208 /* Pick a (possibly empty) inventory slot */
5209 switch (randint1(7))
5211 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5212 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5213 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5214 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5215 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5216 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5217 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5220 /* Nothing to damage */
5221 if (!o_ptr->k_idx) return (FALSE);
5223 if (o_ptr->tval <= TV_WEAPON_END) return (FALSE);
5225 /* No damage left to be done */
5226 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5230 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5232 /* Extract the flags */
5233 object_flags(o_ptr, flgs);
5235 /* Object resists */
5236 if (have_flag(flgs, TR_IGNORE_ACID))
5239 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5241 msg_format("Your %s is unaffected!", o_name);
5250 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5252 msg_format("Your %s is damaged!", o_name);
5256 /* Damage the item */
5259 /* Calculate bonuses */
5260 p_ptr->update |= (PU_BONUS);
5263 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5267 /* Item was damaged */
5273 * Hurt the player with Acid
5275 int acid_dam(int dam, cptr kb_str, int monspell)
5278 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5279 bool double_resist = IS_OPPOSE_ACID();
5281 /* Total Immunity */
5282 if (p_ptr->immune_acid || (dam <= 0))
5284 learn_spell(monspell);
5288 /* Vulnerability (Ouch!) */
5289 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5290 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5292 /* Resist the damage */
5293 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5294 if (double_resist) dam = (dam + 2) / 3;
5296 if ((!(double_resist || p_ptr->resist_acid)) &&
5297 one_in_(HURT_CHANCE))
5298 (void)do_dec_stat(A_CHR);
5300 /* If any armor gets hit, defend the player */
5301 if (minus_ac()) dam = (dam + 1) / 2;
5304 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5306 /* Inventory damage */
5307 if (!(double_resist && p_ptr->resist_acid))
5308 inven_damage(set_acid_destroy, inv);
5314 * Hurt the player with electricity
5316 int elec_dam(int dam, cptr kb_str, int monspell)
5319 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5320 bool double_resist = IS_OPPOSE_ELEC();
5322 /* Total immunity */
5323 if (p_ptr->immune_elec || (dam <= 0))
5325 learn_spell(monspell);
5329 /* Vulnerability (Ouch!) */
5330 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5331 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5332 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5334 /* Resist the damage */
5335 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5336 if (double_resist) dam = (dam + 2) / 3;
5338 if ((!(double_resist || p_ptr->resist_elec)) &&
5339 one_in_(HURT_CHANCE))
5340 (void)do_dec_stat(A_DEX);
5343 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5345 /* Inventory damage */
5346 if (!(double_resist && p_ptr->resist_elec))
5347 inven_damage(set_elec_destroy, inv);
5354 * Hurt the player with Fire
5356 int fire_dam(int dam, cptr kb_str, int monspell)
5359 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5360 bool double_resist = IS_OPPOSE_FIRE();
5362 /* Totally immune */
5363 if (p_ptr->immune_fire || (dam <= 0))
5365 learn_spell(monspell);
5369 /* Vulnerability (Ouch!) */
5370 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5371 if (prace_is_(RACE_ENT)) dam += dam / 3;
5372 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5374 /* Resist the damage */
5375 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5376 if (double_resist) dam = (dam + 2) / 3;
5378 if ((!(double_resist || p_ptr->resist_fire)) &&
5379 one_in_(HURT_CHANCE))
5380 (void)do_dec_stat(A_STR);
5383 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5385 /* Inventory damage */
5386 if (!(double_resist && p_ptr->resist_fire))
5387 inven_damage(set_fire_destroy, inv);
5394 * Hurt the player with Cold
5396 int cold_dam(int dam, cptr kb_str, int monspell)
5399 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5400 bool double_resist = IS_OPPOSE_COLD();
5402 /* Total immunity */
5403 if (p_ptr->immune_cold || (dam <= 0))
5405 learn_spell(monspell);
5409 /* Vulnerability (Ouch!) */
5410 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5411 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5413 /* Resist the damage */
5414 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5415 if (double_resist) dam = (dam + 2) / 3;
5417 if ((!(double_resist || p_ptr->resist_cold)) &&
5418 one_in_(HURT_CHANCE))
5419 (void)do_dec_stat(A_STR);
5422 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5424 /* Inventory damage */
5425 if (!(double_resist && p_ptr->resist_cold))
5426 inven_damage(set_cold_destroy, inv);
5432 bool rustproof(void)
5436 char o_name[MAX_NLEN];
5439 item_tester_no_ryoute = TRUE;
5440 /* Select a piece of armour */
5441 item_tester_hook = item_tester_hook_armour;
5445 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5446 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5448 q = "Rustproof which piece of armour? ";
5449 s = "You have nothing to rustproof.";
5452 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5454 /* Get the item (in the pack) */
5457 o_ptr = &inventory[item];
5460 /* Get the item (on the floor) */
5463 o_ptr = &o_list[0 - item];
5468 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5470 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5472 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5475 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5477 msg_format("%s %s look%s as good as new!",
5478 ((item >= 0) ? "Your" : "The"), o_name,
5479 ((o_ptr->number > 1) ? "" : "s"));
5486 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5488 msg_format("%s %s %s now protected against corrosion.",
5489 ((item >= 0) ? "Your" : "The"), o_name,
5490 ((o_ptr->number > 1) ? "are" : "is"));
5501 * Curse the players armor
5503 bool curse_armor(void)
5508 char o_name[MAX_NLEN];
5511 /* Curse the body armor */
5512 o_ptr = &inventory[INVEN_BODY];
5514 /* Nothing to curse */
5515 if (!o_ptr->k_idx) return (FALSE);
5519 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5521 /* Attempt a saving throw for artifacts */
5522 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5526 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5527 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5529 msg_format("A %s tries to %s, but your %s resists the effects!",
5530 "terrible black aura", "surround your armor", o_name);
5535 /* not artifact or failed save... */
5540 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5542 msg_format("A terrible black aura blasts your %s!", o_name);
5545 chg_virtue(V_ENCHANT, -5);
5547 /* Blast the armor */
5549 o_ptr->name2 = EGO_BLASTED;
5550 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5557 for (i = 0; i < TR_FLAG_SIZE; i++)
5558 o_ptr->art_flags[i] = 0;
5561 o_ptr->curse_flags = TRC_CURSED;
5564 o_ptr->ident |= (IDENT_BROKEN);
5566 /* Recalculate bonuses */
5567 p_ptr->update |= (PU_BONUS);
5569 /* Recalculate mana */
5570 p_ptr->update |= (PU_MANA);
5573 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5581 * Curse the players weapon
5583 bool curse_weapon(bool force, int slot)
5589 char o_name[MAX_NLEN];
5592 /* Curse the weapon */
5593 o_ptr = &inventory[slot];
5595 /* Nothing to curse */
5596 if (!o_ptr->k_idx) return (FALSE);
5600 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5602 /* Attempt a saving throw */
5603 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5607 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5608 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5610 msg_format("A %s tries to %s, but your %s resists the effects!",
5611 "terrible black aura", "surround your weapon", o_name);
5616 /* not artifact or failed save... */
5621 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5623 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5626 chg_virtue(V_ENCHANT, -5);
5628 /* Shatter the weapon */
5630 o_ptr->name2 = EGO_SHATTERED;
5631 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5632 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5638 for (i = 0; i < TR_FLAG_SIZE; i++)
5639 o_ptr->art_flags[i] = 0;
5643 o_ptr->curse_flags = TRC_CURSED;
5646 o_ptr->ident |= (IDENT_BROKEN);
5648 /* Recalculate bonuses */
5649 p_ptr->update |= (PU_BONUS);
5651 /* Recalculate mana */
5652 p_ptr->update |= (PU_MANA);
5655 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5664 * Enchant some bolts
5666 bool brand_bolts(void)
5670 /* Use the first acceptable bolts */
5671 for (i = 0; i < INVEN_PACK; i++)
5673 object_type *o_ptr = &inventory[i];
5675 /* Skip non-bolts */
5676 if (o_ptr->tval != TV_BOLT) continue;
5678 /* Skip artifacts and ego-items */
5679 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5682 /* Skip cursed/broken items */
5683 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5686 if (randint0(100) < 75) continue;
5690 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5692 msg_print("Your bolts are covered in a fiery aura!");
5697 o_ptr->name2 = EGO_FLAME;
5700 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5707 if (flush_failure) flush();
5711 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5713 msg_print("The fiery enchantment failed.");
5723 * Helper function -- return a "nearby" race for polymorphing
5725 * Note that this function is one of the more "dangerous" ones...
5727 static s16b poly_r_idx(int r_idx)
5729 monster_race *r_ptr = &r_info[r_idx];
5731 int i, r, lev1, lev2;
5733 /* Hack -- Uniques/Questors never polymorph */
5734 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5735 (r_ptr->flags1 & RF1_QUESTOR))
5738 /* Allowable range of "levels" for resulting monster */
5739 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5740 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5742 /* Pick a (possibly new) non-unique race */
5743 for (i = 0; i < 1000; i++)
5745 /* Pick a new race, using a level calculation */
5746 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5748 /* Handle failure */
5754 /* Ignore unique monsters */
5755 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5757 /* Ignore monsters with incompatible levels */
5758 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5760 /* Use that index */
5772 bool polymorph_monster(int y, int x)
5774 cave_type *c_ptr = &cave[y][x];
5775 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5776 bool polymorphed = FALSE;
5778 int old_r_idx = m_ptr->r_idx;
5779 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5780 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5781 monster_type back_m;
5783 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5785 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5787 /* Memorize the monster before polymorphing */
5790 /* Pick a "new" monster race */
5791 new_r_idx = poly_r_idx(old_r_idx);
5793 /* Handle polymorph */
5794 if (new_r_idx != old_r_idx)
5798 /* Get the monsters attitude */
5799 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5800 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5801 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5803 /* "Kill" the "old" monster */
5804 delete_monster_idx(c_ptr->m_idx);
5806 /* Create a new monster (no groups) */
5807 if (place_monster_aux(0, y, x, new_r_idx, mode))
5814 /* Placing the new monster failed */
5815 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5816 m_list[hack_m_idx_ii] = back_m;
5819 if (targeted) target_who = hack_m_idx_ii;
5820 if (health_tracked) health_track(hack_m_idx_ii);
5830 static bool dimension_door_aux(int x, int y)
5832 int plev = p_ptr->lev;
5834 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5836 if (!cave_teleportable_bold(y, x, FALSE) ||
5837 (distance(y, x, py, px) > plev / 2 + 10) ||
5838 (!randint0(plev / 10 + 10)))
5840 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5841 teleport_player((plev + 2) * 2, TRUE);
5848 teleport_player_to(y, x, TRUE, FALSE);
5859 bool dimension_door(void)
5863 /* Rerutn FALSE if cancelled */
5864 if (!tgt_pt(&x, &y)) return FALSE;
5866 if (dimension_door_aux(x, y)) return TRUE;
5869 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5871 msg_print("You fail to exit the astral plane correctly!");
5879 * Mirror Master's Dimension Door
5881 bool mirror_tunnel(void)
5885 /* Rerutn FALSE if cancelled */
5886 if (!tgt_pt(&x, &y)) return FALSE;
5888 if (dimension_door_aux(x, y)) return TRUE;
5891 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5893 msg_print("You fail to pass the mirror plane correctly!");
5900 bool eat_magic(int power)
5902 object_type * o_ptr;
5905 int recharge_strength = 0;
5911 char o_name[MAX_NLEN];
5913 item_tester_hook = item_tester_hook_recharge;
5917 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5918 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5920 q = "Drain which item? ";
5921 s = "You have nothing to drain.";
5924 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5928 o_ptr = &inventory[item];
5932 o_ptr = &o_list[0 - item];
5935 k_ptr = &k_info[o_ptr->k_idx];
5936 lev = k_info[o_ptr->k_idx].level;
5938 if (o_ptr->tval == TV_ROD)
5940 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5943 if (one_in_(recharge_strength))
5945 /* Activate the failure code. */
5950 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5953 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5955 msg_print("You can't absorb energy from a discharged rod.");
5962 o_ptr->timeout += k_ptr->pval;
5968 /* All staffs, wands. */
5969 recharge_strength = (100 + power - lev) / 15;
5972 if (recharge_strength < 0) recharge_strength = 0;
5975 if (one_in_(recharge_strength))
5977 /* Activate the failure code. */
5982 if (o_ptr->pval > 0)
5984 p_ptr->csp += lev / 2;
5987 /* XXX Hack -- unstack if necessary */
5988 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5993 /* Get local object */
5996 /* Obtain a local object */
5997 object_copy(q_ptr, o_ptr);
5999 /* Modify quantity */
6002 /* Restore the charges */
6005 /* Unstack the used item */
6007 p_ptr->total_weight -= q_ptr->weight;
6008 item = inven_carry(q_ptr);
6012 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
6014 msg_print("You unstack your staff.");
6022 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
6024 msg_print("There's no energy there to absorb!");
6028 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
6032 /* Inflict the penalties for failing a recharge. */
6035 /* Artifacts are never destroyed. */
6036 if (artifact_p(o_ptr))
6038 object_desc(o_name, o_ptr, OD_NAME_ONLY);
6040 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
6042 msg_format("The recharging backfires - %s is completely drained!", o_name);
6046 /* Artifact rods. */
6047 if (o_ptr->tval == TV_ROD)
6048 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6050 /* Artifact wands and staffs. */
6051 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
6056 /* Get the object description */
6057 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
6059 /*** Determine Seriousness of Failure ***/
6061 /* Mages recharge objects more safely. */
6062 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)
6064 /* 10% chance to blow up one rod, otherwise draining. */
6065 if (o_ptr->tval == TV_ROD)
6067 if (one_in_(10)) fail_type = 2;
6070 /* 75% chance to blow up one wand, otherwise draining. */
6071 else if (o_ptr->tval == TV_WAND)
6073 if (!one_in_(3)) fail_type = 2;
6076 /* 50% chance to blow up one staff, otherwise no effect. */
6077 else if (o_ptr->tval == TV_STAFF)
6079 if (one_in_(2)) fail_type = 2;
6084 /* All other classes get no special favors. */
6087 /* 33% chance to blow up one rod, otherwise draining. */
6088 if (o_ptr->tval == TV_ROD)
6090 if (one_in_(3)) fail_type = 2;
6093 /* 20% chance of the entire stack, else destroy one wand. */
6094 else if (o_ptr->tval == TV_WAND)
6096 if (one_in_(5)) fail_type = 3;
6099 /* Blow up one staff. */
6100 else if (o_ptr->tval == TV_STAFF)
6106 /*** Apply draining and destruction. ***/
6108 /* Drain object or stack of objects. */
6111 if (o_ptr->tval == TV_ROD)
6114 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
6116 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
6119 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6121 else if (o_ptr->tval == TV_WAND)
6124 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
6126 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
6131 /* Staffs aren't drained. */
6134 /* Destroy an object or one in a stack of objects. */
6137 if (o_ptr->number > 1)
6140 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
6142 msg_format("Wild magic consumes one of your %s!", o_name);
6145 /* Reduce rod stack maximum timeout, drain wands. */
6146 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
6147 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
6152 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
6154 msg_format("Wild magic consumes your %s!", o_name);
6157 /* Reduce and describe inventory */
6160 inven_item_increase(item, -1);
6161 inven_item_describe(item);
6162 inven_item_optimize(item);
6165 /* Reduce and describe floor item */
6168 floor_item_increase(0 - item, -1);
6169 floor_item_describe(0 - item);
6170 floor_item_optimize(0 - item);
6174 /* Destroy all members of a stack of objects. */
6177 if (o_ptr->number > 1)
6179 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
6181 msg_format("Wild magic consumes all your %s!", o_name);
6186 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
6188 msg_format("Wild magic consumes your %s!", o_name);
6193 /* Reduce and describe inventory */
6196 inven_item_increase(item, -999);
6197 inven_item_describe(item);
6198 inven_item_optimize(item);
6201 /* Reduce and describe floor item */
6204 floor_item_increase(0 - item, -999);
6205 floor_item_describe(0 - item);
6206 floor_item_optimize(0 - item);
6212 if (p_ptr->csp > p_ptr->msp)
6214 p_ptr->csp = p_ptr->msp;
6217 /* Redraw mana and hp */
6218 p_ptr->redraw |= (PR_MANA);
6220 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6221 p_ptr->window |= (PW_INVEN);
6227 bool summon_kin_player(int level, int y, int x, u32b mode)
6229 bool pet = (bool)(mode & PM_FORCE_PET);
6230 if (!pet) mode |= PM_NO_PET;
6232 switch (p_ptr->mimic_form)
6235 switch (p_ptr->prace)
6239 case RACE_BARBARIAN:
6242 summon_kin_type = 'p';
6252 case RACE_MIND_FLAYER:
6255 summon_kin_type = 'h';
6258 summon_kin_type = 'o';
6260 case RACE_HALF_TROLL:
6261 summon_kin_type = 'T';
6263 case RACE_HALF_OGRE:
6264 summon_kin_type = 'O';
6266 case RACE_HALF_GIANT:
6267 case RACE_HALF_TITAN:
6269 summon_kin_type = 'P';
6272 summon_kin_type = 'y';
6275 summon_kin_type = 'K';
6278 summon_kin_type = 'k';
6281 if (one_in_(13)) summon_kin_type = 'U';
6282 else summon_kin_type = 'u';
6284 case RACE_DRACONIAN:
6285 summon_kin_type = 'd';
6289 summon_kin_type = 'g';
6292 if (one_in_(13)) summon_kin_type = 'L';
6293 else summon_kin_type = 's';
6296 summon_kin_type = 'z';
6299 summon_kin_type = 'V';
6302 summon_kin_type = 'G';
6305 summon_kin_type = 'I';
6308 summon_kin_type = '#';
6311 summon_kin_type = 'A';
6314 summon_kin_type = 'U';
6317 summon_kin_type = 'p';
6322 if (one_in_(13)) summon_kin_type = 'U';
6323 else summon_kin_type = 'u';
6325 case MIMIC_DEMON_LORD:
6326 summon_kin_type = 'U';
6329 summon_kin_type = 'V';
6332 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);