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 ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
89 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2)) continue;
91 /* No teleporting into vaults and such */
92 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
93 if (cave[ny][nx].info & CAVE_ICKY) continue;
95 /* This grid looks good */
102 /* Increase the maximum distance */
105 /* Decrease the minimum distance */
108 /* Stop after MAX_TRIES tries */
109 if (tries > MAX_TRIES) return (FALSE);
113 sound(SOUND_TPOTHER);
115 /* Update the new location */
116 cave[ny][nx].m_idx = m_idx;
118 /* Update the old location */
119 cave[oy][ox].m_idx = 0;
121 /* Move the monster */
125 /* Forget the counter target */
128 /* Update the monster (new location) */
129 update_mon(m_idx, TRUE);
131 /* Redraw the old grid */
134 /* Redraw the new grid */
143 * Teleport monster next to a grid near the given location
145 void teleport_monster_to(int m_idx, int ty, int tx, int power)
147 int ny, nx, oy, ox, d, i, min;
152 monster_type *m_ptr = &m_list[m_idx];
156 if (!m_ptr->r_idx) return;
159 if (randint1(100) > power) return;
165 /* Save the old location */
169 /* Minimum distance */
172 /* Look until done */
173 while (look && --attempts)
175 /* Verify max distance */
176 if (dis > 200) dis = 200;
178 /* Try several locations */
179 for (i = 0; i < 500; i++)
181 /* Pick a (possibly illegal) location */
184 ny = rand_spread(ty, dis);
185 nx = rand_spread(tx, dis);
186 d = distance(ty, tx, ny, nx);
187 if ((d >= min) && (d <= dis)) break;
190 /* Ignore illegal locations */
191 if (!in_bounds(ny, nx)) continue;
193 /* Require "empty" floor space */
194 if (!cave_empty_bold(ny, nx)) continue;
196 c_ptr = &cave[ny][nx];
198 /* Hack -- no teleport onto glyph of warding */
199 if (is_glyph_grid(c_ptr)) continue;
200 if (is_explosive_rune_grid(c_ptr)) continue;
202 /* ...nor onto the Pattern */
203 if ((c_ptr->feat >= FEAT_PATTERN_START) &&
204 (c_ptr->feat <= FEAT_PATTERN_XTRA2)) continue;
206 /* No teleporting into vaults and such */
207 /* if (c_ptr->info & (CAVE_ICKY)) continue; */
209 /* This grid looks good */
216 /* Increase the maximum distance */
219 /* Decrease the minimum distance */
223 if (attempts < 1) return;
226 sound(SOUND_TPOTHER);
228 /* Update the new location */
229 c_ptr->m_idx = m_idx;
231 /* Update the old location */
232 cave[oy][ox].m_idx = 0;
234 /* Move the monster */
238 /* Update the monster (new location) */
239 update_mon(m_idx, TRUE);
241 /* Redraw the old grid */
244 /* Redraw the new grid */
247 p_ptr->update |= (PU_MON_LITE);
252 * Teleport the player to a location up to "dis" grids away.
254 * If no such spaces are readily available, the distance may increase.
255 * Try very hard to move the player at least a quarter that distance.
257 * When long-range teleport effects are considered, there is a nasty
258 * tendency to "bounce" the player between two or three different spots
259 * because these are the only spots that are "far enough" way to satisfy
260 * the algorithm. Therefore, if the teleport distance is more than 50,
261 * we decrease the minimum acceptable distance to try to increase randomness.
264 void teleport_player(int dis)
266 int d, i, min, ox, oy;
277 if (p_ptr->wild_mode) return;
279 if (p_ptr->anti_tele)
282 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
284 msg_print("A mysterious force prevents you from teleporting!");
290 if (dis > 200) dis = 200; /* To be on the safe side... */
292 /* Minimum distance */
293 min = dis / (dis > 50 ? 3 : 2);
295 /* Look until done */
300 /* Verify max distance */
301 if (dis > 200) dis = 200;
303 /* Try several locations */
304 for (i = 0; i < 500; i++)
306 /* Pick a (possibly illegal) location */
309 y = rand_spread(py, dis);
310 x = rand_spread(px, dis);
311 d = distance(py, px, y, x);
312 if ((d >= min) && (d <= dis)) break;
315 /* Ignore illegal locations */
316 if (!in_bounds(y, x)) continue;
318 /* Require "naked" floor space or trees */
319 if (!(cave_naked_bold(y, x) ||
320 (cave[y][x].feat == FEAT_TREES))) continue;
322 /* No teleporting into vaults and such */
323 if (cave[y][x].info & CAVE_ICKY) continue;
325 /* This grid looks good */
332 /* Increase the maximum distance */
335 /* Decrease the minimum distance */
338 /* Stop after MAX_TRIES tries */
339 if (tries > MAX_TRIES) return;
343 sound(SOUND_TELEPORT);
346 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
347 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
350 /* Save the old location */
354 /* Move the player */
361 tmp = cave[py][px].m_idx;
362 cave[py][px].m_idx = cave[oy][ox].m_idx;
363 cave[oy][ox].m_idx = tmp;
364 m_list[p_ptr->riding].fy = py;
365 m_list[p_ptr->riding].fx = px;
366 update_mon(cave[py][px].m_idx, TRUE);
369 /* Redraw the old spot */
372 /* Monsters with teleport ability may follow the player */
373 for (xx = -1; xx < 2; xx++)
375 for (yy = -1; yy < 2; yy++)
377 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
379 /* A monster except your mount may follow */
380 if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
382 monster_type *m_ptr = &m_list[tmp_m_idx];
383 monster_race *r_ptr = &r_info[m_ptr->r_idx];
386 * The latter limitation is to avoid
387 * totally unkillable suckers...
389 if ((r_ptr->flags6 & RF6_TPORT) &&
390 !(r_ptr->flagsr & RFR_RES_TELE))
392 if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level);
400 /* Redraw the new spot */
403 /* Check for new panel (redraw map) */
407 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
409 /* Update the monsters */
410 p_ptr->update |= (PU_DISTANCE);
413 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
415 /* Handle stuff XXX XXX XXX */
422 * Teleport player to a grid near the given location
424 * This function is slightly obsessive about correctness.
425 * This function allows teleporting into vaults (!)
427 void teleport_player_to(int ny, int nx, bool no_tele)
429 int y, x, oy, ox, dis = 0, ctr = 0;
431 if (p_ptr->anti_tele && no_tele)
434 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
436 msg_print("A mysterious force prevents you from teleporting!");
442 /* Find a usable location */
445 /* Pick a nearby legal location */
448 y = rand_spread(ny, dis);
449 x = rand_spread(nx, dis);
450 if (in_bounds(y, x)) break;
453 /* Accept "naked" floor grids */
456 if (cave_naked_bold(y, x) || (((cave[y][x].feat == FEAT_DEEP_LAVA) || (cave[y][x].feat == FEAT_DEEP_WATER)) && !cave[y][x].m_idx)) break;
458 else if (cave_empty_bold(y, x) || player_bold(y, x)) break;
460 /* Occasionally advance the distance */
461 if (++ctr > (4 * dis * dis + 4 * dis + 1))
469 sound(SOUND_TELEPORT);
471 /* Save the old location */
475 /* Move the player */
482 tmp = cave[py][px].m_idx;
483 cave[py][px].m_idx = cave[oy][ox].m_idx;
484 cave[oy][ox].m_idx = tmp;
485 m_list[p_ptr->riding].fy = py;
486 m_list[p_ptr->riding].fx = px;
487 update_mon(cave[py][px].m_idx, TRUE);
492 /* Redraw the old spot */
495 /* Redraw the new spot */
498 /* Check for new panel (redraw map) */
502 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
504 /* Update the monsters */
505 p_ptr->update |= (PU_DISTANCE);
508 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
510 /* Handle stuff XXX XXX XXX */
517 * Teleport the player one level up or down (random when legal)
518 * Note: If m_idx <= 0, target is player.
520 void teleport_level(int m_idx)
527 if (m_idx <= 0) /* To player */
530 strcpy(m_name, "¤¢¤Ê¤¿");
532 strcpy(m_name, "you");
535 else /* To monster */
537 m_ptr = &m_list[m_idx];
539 /* Get the monster name (or "it") */
540 monster_desc(m_name, m_ptr, 0);
545 /* No effect in arena or quest */
546 if (p_ptr->inside_arena || p_ptr->inside_battle || (p_ptr->inside_quest && !random_quest_number(dun_level)) ||
547 ((quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth)) && (dun_level > 1) && ironman_downward && (m_idx <= 0)))
550 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
552 if (see_m) msg_print("There is no effect.");
558 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
561 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
563 msg_print("A mysterious force prevents you from teleporting!");
568 /* Choose up or down */
569 if (randint0(100) < 50) go_up = TRUE;
572 if ((m_idx <= 0) && p_ptr->wizard)
574 if (get_check("Force to go up? ")) go_up = TRUE;
575 else if (get_check("Force to go down? ")) go_up = FALSE;
579 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
582 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
584 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
586 if (m_idx <= 0) /* To player */
590 dungeon_type = p_ptr->recall_dungeon;
595 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
597 if (autosave_l) do_cmd_save_game(TRUE);
601 dun_level = d_info[dungeon_type].mindepth;
602 prepare_change_floor_mode(CFM_RAND_PLACE | CFM_CLEAR_ALL);
606 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
610 p_ptr->leaving = TRUE;
615 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
618 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
620 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
624 if (m_idx <= 0) /* To player */
626 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
628 if (autosave_l) do_cmd_save_game(TRUE);
630 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
635 p_ptr->inside_quest = 0;
636 p_ptr->leaving = TRUE;
642 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
644 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
648 if (m_idx <= 0) /* To player */
650 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
652 if (autosave_l) do_cmd_save_game(TRUE);
654 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
657 p_ptr->leaving = TRUE;
663 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
665 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
668 if (m_idx <= 0) /* To player */
670 /* Never reach this code on the surface */
671 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
673 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
675 if (autosave_l) do_cmd_save_game(TRUE);
677 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
680 p_ptr->leaving = TRUE;
684 /* Monster level teleportation is simple deleting now */
687 /* Check for quest completion */
688 check_quest_completion(m_ptr);
690 delete_monster_idx(m_idx);
694 sound(SOUND_TPLEVEL);
699 static int choose_dungeon(cptr note)
705 /* Allocate the "dun" array */
706 C_MAKE(dun, max_d_idx, s16b);
709 for(i = 1; i < max_d_idx; i++)
714 if (!d_info[i].maxdepth) continue;
715 if (!max_dlv[i]) continue;
716 if (d_info[i].final_guardian)
718 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
720 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
723 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
725 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
731 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
733 prt(format("Which dungeon do you %s?: ", note), 0, 0);
740 /* Free the "dun" array */
741 C_KILL(dun, max_d_idx, s16b);
746 if (i >= 'a' && i <('a'+num))
748 select_dungeon = dun[i-'a'];
755 /* Free the "dun" array */
756 C_KILL(dun, max_d_idx, s16b);
758 return select_dungeon;
763 * Recall the player to town or dungeon
765 bool recall_player(int turns)
768 * TODO: Recall the player to the last
769 * visited town when in the wilderness
773 if (p_ptr->inside_arena || ironman_downward)
776 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
778 msg_print("Nothing happens.");
784 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
787 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
789 if (get_check("Reset recall depth? "))
792 max_dlv[dungeon_type] = dun_level;
793 if (record_maxdeapth)
795 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
797 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
802 if (!p_ptr->word_recall)
808 select_dungeon = choose_dungeon("¤Ëµ¢´Ô");
810 select_dungeon = choose_dungeon("recall");
812 if (!select_dungeon) return FALSE;
813 p_ptr->recall_dungeon = select_dungeon;
815 p_ptr->word_recall = turns;
817 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
819 msg_print("The air about you becomes charged...");
822 p_ptr->redraw |= (PR_STATUS);
826 p_ptr->word_recall = 0;
828 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
830 msg_print("A tension leaves the air around you...");
833 p_ptr->redraw |= (PR_STATUS);
839 bool word_of_recall(void)
841 return(recall_player(randint0(21) + 15));
845 bool reset_recall(void)
847 int select_dungeon, dummy = 0;
852 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È");
854 select_dungeon = choose_dungeon("reset");
858 if (ironman_downward)
861 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
863 msg_print("Nothing happens.");
869 if (!select_dungeon) return FALSE;
872 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
874 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
879 sprintf(tmp_val, "%d", MAX(dun_level, 1));
881 /* Ask for a level */
882 if (get_string(ppp, tmp_val, 10))
884 /* Extract request */
885 dummy = atoi(tmp_val);
888 if (dummy < 1) dummy = 1;
891 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
892 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
894 max_dlv[select_dungeon] = dummy;
896 if (record_maxdeapth)
898 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
900 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
904 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
906 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
919 * Apply disenchantment to the player's stuff
921 * XXX XXX XXX This function is also called from the "melee" code
923 * Return "TRUE" if the player notices anything
925 bool apply_disenchant(int mode)
929 char o_name[MAX_NLEN];
930 int to_h, to_d, to_a, pval;
932 /* Pick a random slot */
935 case 1: t = INVEN_RARM; break;
936 case 2: t = INVEN_LARM; break;
937 case 3: t = INVEN_BOW; break;
938 case 4: t = INVEN_BODY; break;
939 case 5: t = INVEN_OUTER; break;
940 case 6: t = INVEN_HEAD; break;
941 case 7: t = INVEN_HANDS; break;
942 case 8: t = INVEN_FEET; break;
946 o_ptr = &inventory[t];
948 /* No item, nothing happens */
949 if (!o_ptr->k_idx) return (FALSE);
952 /* Nothing to disenchant */
953 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
955 /* Nothing to notice */
960 /* Describe the object */
961 object_desc(o_name, o_ptr, FALSE, 0);
964 /* Artifacts have 71% chance to resist */
965 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 71))
969 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
971 msg_format("Your %s (%c) resist%s disenchantment!",
972 o_name, index_to_label(t),
973 ((o_ptr->number != 1) ? "" : "s"));
982 /* Memorize old value */
988 /* Disenchant tohit */
989 if (o_ptr->to_h > 0) o_ptr->to_h--;
990 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
992 /* Disenchant todam */
993 if (o_ptr->to_d > 0) o_ptr->to_d--;
994 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
996 /* Disenchant toac */
997 if (o_ptr->to_a > 0) o_ptr->to_a--;
998 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1000 /* Disenchant pval (occasionally) */
1001 /* Unless called from wild_magic() */
1002 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1004 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1005 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1009 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
1010 o_name, index_to_label(t) );
1012 msg_format("Your %s (%c) %s disenchanted!",
1013 o_name, index_to_label(t),
1014 ((o_ptr->number != 1) ? "were" : "was"));
1017 chg_virtue(V_HARMONY, 1);
1018 chg_virtue(V_ENCHANT, -2);
1020 /* Recalculate bonuses */
1021 p_ptr->update |= (PU_BONUS);
1024 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1034 void mutate_player(void)
1036 int max1, cur1, max2, cur2, ii, jj, i;
1038 /* Pick a pair of stats */
1040 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1042 max1 = p_ptr->stat_max[ii];
1043 cur1 = p_ptr->stat_cur[ii];
1044 max2 = p_ptr->stat_max[jj];
1045 cur2 = p_ptr->stat_cur[jj];
1047 p_ptr->stat_max[ii] = max2;
1048 p_ptr->stat_cur[ii] = cur2;
1049 p_ptr->stat_max[jj] = max1;
1050 p_ptr->stat_cur[jj] = cur1;
1054 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1055 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1058 p_ptr->update |= (PU_BONUS);
1065 void apply_nexus(monster_type *m_ptr)
1067 switch (randint1(7))
1069 case 1: case 2: case 3:
1071 teleport_player(200);
1077 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE);
1083 if (randint0(100) < p_ptr->skill_sav)
1086 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1088 msg_print("You resist the effects!");
1094 /* Teleport Level */
1101 if (randint0(100) < p_ptr->skill_sav)
1104 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1106 msg_print("You resist the effects!");
1113 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1115 msg_print("Your body starts to scramble...");
1126 * Charge a lite (torch or latern)
1128 void phlogiston(void)
1131 object_type * o_ptr = &inventory[INVEN_LITE];
1134 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1136 max_flog = FUEL_LAMP;
1140 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1142 max_flog = FUEL_TORCH;
1145 /* No torch to refill */
1149 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1151 msg_print("You are not wielding anything which uses phlogiston.");
1157 if (o_ptr->xtra4 >= max_flog)
1160 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1162 msg_print("No more phlogiston can be put in this item.");
1169 o_ptr->xtra4 += (max_flog / 2);
1173 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1175 msg_print("You add phlogiston to your light item.");
1180 if (o_ptr->xtra4 >= max_flog)
1182 o_ptr->xtra4 = max_flog;
1184 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1186 msg_print("Your light item is full.");
1191 /* Recalculate torch */
1192 p_ptr->update |= (PU_TORCH);
1196 static bool item_tester_hook_weapon_nobow(object_type *o_ptr)
1198 switch (o_ptr->tval)
1208 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
1216 * Brand the current weapon
1218 void brand_weapon(int brand_type)
1225 /* Assume enchant weapon */
1226 item_tester_hook = item_tester_hook_weapon_nobow;
1227 item_tester_no_ryoute = TRUE;
1231 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1232 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1234 q = "Enchant which weapon? ";
1235 s = "You have nothing to enchant.";
1238 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1240 /* Get the item (in the pack) */
1243 o_ptr = &inventory[item];
1246 /* Get the item (on the floor) */
1249 o_ptr = &o_list[0 - item];
1253 /* you can never modify artifacts / ego-items */
1254 /* you can never modify cursed items */
1255 /* TY: You _can_ modify broken items (if you're silly enough) */
1256 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
1257 !o_ptr->art_name && !cursed_p(o_ptr) &&
1258 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1259 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1260 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1264 /* Let's get the name before it is changed... */
1265 char o_name[MAX_NLEN];
1266 object_desc(o_name, o_ptr, FALSE, 0);
1271 if (o_ptr->tval == TV_SWORD)
1274 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1276 act = "becomes very sharp!";
1279 o_ptr->name2 = EGO_SHARPNESS;
1280 o_ptr->pval = m_bonus(5, dun_level) + 1;
1285 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1287 act = "seems very powerful.";
1290 o_ptr->name2 = EGO_EARTHQUAKES;
1291 o_ptr->pval = m_bonus(3, dun_level);
1296 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1298 act = "seems to be looking for humans!";
1301 o_ptr->name2 = EGO_SLAY_HUMAN;
1305 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1307 act = "covered with lightning!";
1310 o_ptr->name2 = EGO_BRAND_ELEC;
1314 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1316 act = "coated with acid!";
1319 o_ptr->name2 = EGO_BRAND_ACID;
1323 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1325 act = "seems to be looking for evil monsters!";
1328 o_ptr->name2 = EGO_SLAY_EVIL;
1332 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1334 act = "seems to be looking for demons!";
1337 o_ptr->name2 = EGO_SLAY_DEMON;
1341 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1343 act = "seems to be looking for undead!";
1346 o_ptr->name2 = EGO_SLAY_UNDEAD;
1350 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1352 act = "seems to be looking for animals!";
1355 o_ptr->name2 = EGO_SLAY_ANIMAL;
1359 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1361 act = "seems to be looking for dragons!";
1364 o_ptr->name2 = EGO_SLAY_DRAGON;
1368 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1370 act = "seems to be looking for troll!s";
1373 o_ptr->name2 = EGO_SLAY_TROLL;
1377 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1379 act = "seems to be looking for orcs!";
1382 o_ptr->name2 = EGO_SLAY_ORC;
1386 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1388 act = "seems to be looking for giants!";
1391 o_ptr->name2 = EGO_SLAY_GIANT;
1395 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1397 act = "seems very unstable now.";
1400 o_ptr->name2 = EGO_TRUMP;
1401 o_ptr->pval = randint1(2);
1405 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1407 act = "thirsts for blood!";
1410 o_ptr->name2 = EGO_VAMPIRIC;
1414 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1416 act = "is coated with poison.";
1419 o_ptr->name2 = EGO_BRAND_POIS;
1423 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1425 act = "is engulfed in raw Logrus!";
1428 o_ptr->name2 = EGO_CHAOTIC;
1432 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1434 act = "is covered in a fiery shield!";
1437 o_ptr->name2 = EGO_BRAND_FIRE;
1441 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1443 act = "glows deep, icy blue!";
1446 o_ptr->name2 = EGO_BRAND_COLD;
1451 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1453 msg_format("Your %s %s", o_name, act);
1457 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1459 o_ptr->discount = 99;
1460 chg_virtue(V_ENCHANT, 2);
1464 if (flush_failure) flush();
1467 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1469 msg_print("The Branding failed.");
1472 chg_virtue(V_ENCHANT, -2);
1479 * Determine if a "feature" is a "vanishable"
1480 * Non-permanent walls, trees, mountains, or doors
1482 #define vanishable_feat(F) \
1483 ((!feat_floor(F) && (((F) < FEAT_PERM_EXTRA) || ((F) > FEAT_PERM_SOLID))) || \
1484 ((F) == FEAT_OPEN) || ((F) == FEAT_BROKEN))
1487 * Vanish all walls in this floor
1489 static bool vanish_dungeon(void)
1493 monster_type *m_ptr;
1497 /* Prevent vasishing of quest levels and town */
1498 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1503 /* Scan all normal grids */
1504 for (y = 1; y < cur_hgt - 1; y++)
1506 for (x = 1; x < cur_wid - 1; x++)
1508 c_ptr = &cave[y][x];
1510 /* Seeing true feature code (ignore mimic) */
1513 /* Lose room and vault */
1514 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1519 m_ptr = &m_list[c_ptr->m_idx];
1521 /* Reset sleep counter */
1524 /* Notice the "waking up" */
1527 /* Acquire the monster name */
1528 monster_desc(m_name, m_ptr, 0);
1530 /* Dump a message */
1532 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1534 msg_format("%^s wakes up.", m_name);
1537 /* Redraw the health bar */
1538 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
1539 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
1543 /* Process all walls, doors and patterns */
1544 if (vanishable_feat(feat) || pattern_tile(y, x))
1547 cave_set_feat(y, x, floor_type[randint0(100)]);
1552 /* Special boundary walls -- Top and bottom */
1553 for (x = 0; x < cur_wid; x++)
1555 c_ptr = &cave[0][x];
1557 /* Lose room and vault */
1558 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1560 /* Set boundary mimic if needed */
1561 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1563 c_ptr = &cave[cur_hgt - 1][x];
1565 /* Lose room and vault */
1566 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1568 /* Set boundary mimic if needed */
1569 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1572 /* Special boundary walls -- Left and right */
1573 for (y = 1; y < (cur_hgt - 1); y++)
1575 c_ptr = &cave[y][0];
1577 /* Lose room and vault */
1578 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1580 /* Set boundary mimic if needed */
1581 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1583 c_ptr = &cave[y][cur_wid - 1];
1585 /* Lose room and vault */
1586 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1588 /* Set boundary mimic if needed */
1589 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1592 /* Mega-Hack -- Forget the view and lite */
1593 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1596 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1598 /* Update the monsters */
1599 p_ptr->update |= (PU_MONSTERS);
1602 p_ptr->redraw |= (PR_MAP);
1605 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1611 void call_the_(void)
1615 bool do_call = TRUE;
1617 for (i = 0; i < 9; i++)
1619 y = py + ddy_ddd[i];
1620 x = px + ddx_ddd[i];
1622 if (!cave_floor_bold(y, x) && !boundary_floor_bold(y, x))
1631 for (i = 1; i < 10; i++)
1633 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1636 for (i = 1; i < 10; i++)
1638 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1641 for (i = 1; i < 10; i++)
1643 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1647 /* Prevent destruction of quest levels and town */
1648 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1651 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1653 msg_print("The ground trembles.");
1660 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1661 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1662 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1664 msg_format("You %s the %s too close to a wall!",
1665 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1666 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1667 msg_print("There is a loud explosion!");
1673 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1675 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1680 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1682 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1684 msg_print("The dungeon collapses...");
1689 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1691 msg_print("The dungeon trembles.");
1696 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1698 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1705 * Fetch an item (teleport it right underneath the caster)
1707 void fetch(int dir, int wgt, bool require_los)
1712 char o_name[MAX_NLEN];
1714 /* Check to see if an object is already there */
1715 if (cave[py][px].o_idx)
1718 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1720 msg_print("You can't fetch when you're already standing on something.");
1727 if (dir == 5 && target_okay())
1732 if (distance(py, px, ty, tx) > MAX_RANGE)
1735 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1737 msg_print("You can't fetch something that far away!");
1743 c_ptr = &cave[ty][tx];
1745 /* We need an item to fetch */
1749 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1751 msg_print("There is no object at this place.");
1757 /* No fetching from vault */
1758 if (c_ptr->info & CAVE_ICKY)
1761 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1763 msg_print("The item slips from your control.");
1769 /* We need to see the item */
1770 if (require_los && !player_has_los_bold(ty, tx))
1773 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1775 msg_print("You have no direct line of sight to that location.");
1783 /* Use a direction */
1784 ty = py; /* Where to drop the item */
1791 c_ptr = &cave[ty][tx];
1793 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1794 !cave_floor_bold(ty, tx)) return;
1796 while (!c_ptr->o_idx);
1799 o_ptr = &o_list[c_ptr->o_idx];
1801 if (o_ptr->weight > wgt)
1803 /* Too heavy to 'fetch' */
1805 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1807 msg_print("The object is too heavy.");
1814 c_ptr->o_idx = o_ptr->next_o_idx;
1815 cave[py][px].o_idx = i; /* 'move' it */
1816 o_ptr->next_o_idx = 0;
1817 o_ptr->iy = (byte)py;
1818 o_ptr->ix = (byte)px;
1820 object_desc(o_name, o_ptr, TRUE, 0);
1822 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1824 msg_format("%^s flies through the air to your feet.", o_name);
1829 p_ptr->redraw |= PR_MAP;
1833 void alter_reality(void)
1835 /* Ironman option */
1836 if (p_ptr->inside_arena || ironman_downward)
1839 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1841 msg_print("Nothing happens.");
1846 if (!p_ptr->alter_reality)
1848 int turns = randint0(21) + 15;
1850 p_ptr->alter_reality = turns;
1852 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1854 msg_print("The view around you begins to change...");
1857 p_ptr->redraw |= (PR_STATUS);
1861 p_ptr->alter_reality = 0;
1863 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1865 msg_print("The view around you got back...");
1868 p_ptr->redraw |= (PR_STATUS);
1875 * Leave a "glyph of warding" which prevents monster movement
1877 bool warding_glyph(void)
1880 if (!cave_clean_bold(py, px))
1883 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1885 msg_print("The object resists the spell.");
1891 /* Create a glyph */
1892 cave[py][px].info |= CAVE_OBJECT;
1893 cave[py][px].mimic = FEAT_GLYPH;
1904 bool warding_mirror(void)
1907 if (!cave_clean_bold(py, px))
1910 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1912 msg_print("The object resists the spell.");
1918 /* Create a mirror */
1919 cave[py][px].info |= CAVE_OBJECT;
1920 cave[py][px].mimic = FEAT_MIRROR;
1922 /* Turn on the light */
1923 cave[py][px].info |= CAVE_GLOW;
1936 * Leave an "explosive rune" which prevents monster movement
1938 bool explosive_rune(void)
1941 if (!cave_clean_bold(py, px))
1944 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1946 msg_print("The object resists the spell.");
1952 /* Create a glyph */
1953 cave[py][px].info |= CAVE_OBJECT;
1954 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1967 * Identify everything being carried.
1968 * Done by a potion of "self knowledge".
1970 void identify_pack(void)
1974 /* Simply identify and know every item */
1975 for (i = 0; i < INVEN_TOTAL; i++)
1977 object_type *o_ptr = &inventory[i];
1979 /* Skip non-objects */
1980 if (!o_ptr->k_idx) continue;
1983 identify_item(o_ptr);
1989 * Used by the "enchant" function (chance of failure)
1990 * (modified for Zangband, we need better stuff there...) -- TY
1992 static int enchant_table[16] =
1994 0, 10, 50, 100, 200,
1995 300, 400, 500, 650, 800,
1996 950, 987, 993, 995, 998,
2002 * Removes curses from items in inventory
2004 * Note that Items which are "Perma-Cursed" (The One Ring,
2005 * The Crown of Morgoth) can NEVER be uncursed.
2007 * Note that if "all" is FALSE, then Items which are
2008 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2009 * will not be uncursed.
2011 static int remove_curse_aux(int all)
2015 /* Attempt to uncurse items being worn */
2016 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2018 object_type *o_ptr = &inventory[i];
2020 /* Skip non-objects */
2021 if (!o_ptr->k_idx) continue;
2023 /* Uncursed already */
2024 if (!cursed_p(o_ptr)) continue;
2026 /* Heavily Cursed Items need a special spell */
2027 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2029 /* Perma-Cursed Items can NEVER be uncursed */
2030 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2033 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2038 o_ptr->curse_flags = 0L;
2040 /* Hack -- Assume felt */
2041 o_ptr->ident |= (IDENT_SENSE);
2044 o_ptr->feeling = FEEL_NONE;
2046 /* Recalculate the bonuses */
2047 p_ptr->update |= (PU_BONUS);
2050 p_ptr->window |= (PW_EQUIP);
2052 /* Count the uncursings */
2056 /* Return "something uncursed" */
2062 * Remove most curses
2064 bool remove_curse(void)
2066 return (remove_curse_aux(FALSE));
2072 bool remove_all_curse(void)
2074 return (remove_curse_aux(TRUE));
2079 * Turns an object into gold, gain some of its value in a shop
2088 char o_name[MAX_NLEN];
2089 char out_val[MAX_NLEN+40];
2093 /* Hack -- force destruction */
2094 if (command_arg > 0) force = TRUE;
2098 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2099 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2101 q = "Turn which item to gold? ";
2102 s = "You have nothing to turn to gold.";
2105 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2107 /* Get the item (in the pack) */
2110 o_ptr = &inventory[item];
2113 /* Get the item (on the floor) */
2116 o_ptr = &o_list[0 - item];
2120 /* See how many items */
2121 if (o_ptr->number > 1)
2123 /* Get a quantity */
2124 amt = get_quantity(NULL, o_ptr->number);
2126 /* Allow user abort */
2127 if (amt <= 0) return FALSE;
2131 /* Describe the object */
2132 old_number = o_ptr->number;
2133 o_ptr->number = amt;
2134 object_desc(o_name, o_ptr, TRUE, 3);
2135 o_ptr->number = old_number;
2137 /* Verify unless quantity given */
2140 if (confirm_destroy || (object_value(o_ptr) > 0))
2142 /* Make a verification */
2144 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2146 sprintf(out_val, "Really turn %s to gold? ", o_name);
2149 if (!get_check(out_val)) return FALSE;
2153 /* Artifacts cannot be destroyed */
2154 if (!can_player_destroy_object(o_ptr))
2158 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2160 msg_format("You fail to turn %s to gold!", o_name);
2167 price = object_value_real(o_ptr);
2173 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2175 msg_format("You turn %s to fool's gold.", o_name);
2183 if (amt > 1) price *= amt;
2185 if (price > 30000) price = 30000;
2187 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2189 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2195 p_ptr->redraw |= (PR_GOLD);
2198 p_ptr->window |= (PW_PLAYER);
2202 /* Eliminate the item (from the pack) */
2205 inven_item_increase(item, -amt);
2206 inven_item_describe(item);
2207 inven_item_optimize(item);
2210 /* Eliminate the item (from the floor) */
2213 floor_item_increase(0 - item, -amt);
2214 floor_item_describe(0 - item);
2215 floor_item_optimize(0 - item);
2224 * Hook to specify "weapon"
2226 bool item_tester_hook_weapon(object_type *o_ptr)
2228 switch (o_ptr->tval)
2242 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2249 static bool item_tester_hook_weapon2(object_type *o_ptr)
2251 switch (o_ptr->tval)
2271 * Hook to specify "armour"
2273 bool item_tester_hook_armour(object_type *o_ptr)
2275 switch (o_ptr->tval)
2296 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2298 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2300 switch (o_ptr->tval)
2329 * Check if an object is nameless weapon or armour
2331 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2333 switch (o_ptr->tval)
2352 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2354 if (object_known_p(o_ptr)) return FALSE;
2364 * Break the curse of an item
2366 static void break_curse(object_type *o_ptr)
2368 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2371 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2373 msg_print("The curse is broken!");
2376 o_ptr->curse_flags = 0L;
2378 o_ptr->ident |= (IDENT_SENSE);
2380 o_ptr->feeling = FEEL_NONE;
2386 * Enchants a plus onto an item. -RAK-
2388 * Revamped! Now takes item pointer, number of times to try enchanting,
2389 * and a flag of what to try enchanting. Artifacts resist enchantment
2390 * some of the time, and successful enchantment to at least +0 might
2391 * break a curse on the item. -CFT-
2393 * Note that an item can technically be enchanted all the way to +15 if
2394 * you wait a very, very, long time. Going from +9 to +10 only works
2395 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2397 * Note that this function can now be used on "piles" of items, and
2398 * the larger the pile, the lower the chance of success.
2400 bool enchant(object_type *o_ptr, int n, int eflag)
2402 int i, chance, prob;
2404 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2405 bool force = (eflag & ENCH_FORCE);
2408 /* Large piles resist enchantment */
2409 prob = o_ptr->number * 100;
2411 /* Missiles are easy to enchant */
2412 if ((o_ptr->tval == TV_BOLT) ||
2413 (o_ptr->tval == TV_ARROW) ||
2414 (o_ptr->tval == TV_SHOT))
2420 for (i = 0; i < n; i++)
2422 /* Hack -- Roll for pile resistance */
2423 if (!force && randint0(prob) >= 100) continue;
2425 /* Enchant to hit */
2426 if (eflag & ENCH_TOHIT)
2428 if (o_ptr->to_h < 0) chance = 0;
2429 else if (o_ptr->to_h > 15) chance = 1000;
2430 else chance = enchant_table[o_ptr->to_h];
2432 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2437 /* only when you get it above -1 -CFT */
2438 if (o_ptr->to_h >= 0)
2443 /* Enchant to damage */
2444 if (eflag & ENCH_TODAM)
2446 if (o_ptr->to_d < 0) chance = 0;
2447 else if (o_ptr->to_d > 15) chance = 1000;
2448 else chance = enchant_table[o_ptr->to_d];
2450 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2455 /* only when you get it above -1 -CFT */
2456 if (o_ptr->to_d >= 0)
2461 /* Enchant to armor class */
2462 if (eflag & ENCH_TOAC)
2464 if (o_ptr->to_a < 0) chance = 0;
2465 else if (o_ptr->to_a > 15) chance = 1000;
2466 else chance = enchant_table[o_ptr->to_a];
2468 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2473 /* only when you get it above -1 -CFT */
2474 if (o_ptr->to_a >= 0)
2481 if (!res) return (FALSE);
2483 /* Recalculate bonuses */
2484 p_ptr->update |= (PU_BONUS);
2486 /* Combine / Reorder the pack (later) */
2487 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2490 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2501 * Enchant an item (in the inventory or on the floor)
2502 * Note that "num_ac" requires armour, else weapon
2503 * Returns TRUE if attempted, FALSE if cancelled
2505 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2510 char o_name[MAX_NLEN];
2514 /* Assume enchant weapon */
2515 item_tester_hook = item_tester_hook_weapon;
2516 item_tester_no_ryoute = TRUE;
2518 /* Enchant armor if requested */
2519 if (num_ac) item_tester_hook = item_tester_hook_armour;
2523 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2524 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2526 q = "Enchant which item? ";
2527 s = "You have nothing to enchant.";
2530 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2532 /* Get the item (in the pack) */
2535 o_ptr = &inventory[item];
2538 /* Get the item (on the floor) */
2541 o_ptr = &o_list[0 - item];
2546 object_desc(o_name, o_ptr, FALSE, 0);
2550 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2553 msg_format("%s %s glow%s brightly!",
2554 ((item >= 0) ? "Your" : "The"), o_name,
2555 ((o_ptr->number > 1) ? "" : "s"));
2560 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2561 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2562 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2568 if (flush_failure) flush();
2572 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2574 msg_print("The enchantment failed.");
2577 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2580 chg_virtue(V_ENCHANT, 1);
2584 /* Something happened */
2589 bool artifact_scroll(void)
2594 char o_name[MAX_NLEN];
2598 item_tester_no_ryoute = TRUE;
2599 /* Enchant weapon/armour */
2600 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2604 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2605 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2607 q = "Enchant which item? ";
2608 s = "You have nothing to enchant.";
2611 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2613 /* Get the item (in the pack) */
2616 o_ptr = &inventory[item];
2619 /* Get the item (on the floor) */
2622 o_ptr = &o_list[0 - item];
2627 object_desc(o_name, o_ptr, FALSE, 0);
2631 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2633 msg_format("%s %s radiate%s a blinding light!",
2634 ((item >= 0) ? "Your" : "The"), o_name,
2635 ((o_ptr->number > 1) ? "" : "s"));
2638 if (o_ptr->name1 || o_ptr->art_name)
2641 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2643 msg_format("The %s %s already %s!",
2644 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2645 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2651 else if (o_ptr->name2)
2654 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2656 msg_format("The %s %s already %s!",
2657 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2658 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2664 else if (o_ptr->xtra3)
2667 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2669 msg_format("The %s %s already %s!",
2670 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2671 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2677 if (o_ptr->number > 1)
2680 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2681 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2683 msg_print("Not enough enough energy to enchant more than one object!");
2684 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2689 inven_item_increase(item, 1-(o_ptr->number));
2693 floor_item_increase(0-item, 1-(o_ptr->number));
2696 okay = create_artifact(o_ptr, TRUE);
2703 if (flush_failure) flush();
2707 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2709 msg_print("The enchantment failed.");
2712 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2715 chg_virtue(V_ENCHANT, 1);
2719 /* Something happened */
2725 * Identify an object
2727 bool identify_item(object_type *o_ptr)
2729 bool old_known = FALSE;
2730 char o_name[MAX_NLEN];
2733 object_desc(o_name, o_ptr, TRUE, 3);
2735 if (o_ptr->ident & IDENT_KNOWN)
2738 if (!(o_ptr->ident & (IDENT_MENTAL)))
2740 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2741 chg_virtue(V_KNOWLEDGE, 1);
2744 /* Identify it fully */
2745 object_aware(o_ptr);
2746 object_known(o_ptr);
2748 /* Recalculate bonuses */
2749 p_ptr->update |= (PU_BONUS);
2751 /* Combine / Reorder the pack (later) */
2752 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2755 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2757 strcpy(record_o_name, o_name);
2761 object_desc(o_name, o_ptr, TRUE, 0);
2763 if(record_fix_art && !old_known && artifact_p(o_ptr))
2764 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2765 if(record_rand_art && !old_known && o_ptr->art_name)
2766 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2772 static bool item_tester_hook_identify(object_type *o_ptr)
2774 return (bool)!object_known_p(o_ptr);
2777 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2779 if (object_known_p(o_ptr))
2781 return item_tester_hook_weapon_armour(o_ptr);
2785 * Identify an object in the inventory (or on the floor)
2786 * This routine does *not* automatically combine objects.
2787 * Returns TRUE if something was identified, else FALSE.
2789 bool ident_spell(bool only_equip)
2793 char o_name[MAX_NLEN];
2798 item_tester_no_ryoute = TRUE;
2801 item_tester_hook = item_tester_hook_identify_weapon_armour;
2803 item_tester_hook = item_tester_hook_identify;
2805 if (!can_get_item())
2809 item_tester_hook = item_tester_hook_weapon_armour;
2813 item_tester_hook = NULL;
2819 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2820 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2822 q = "Identify which item? ";
2823 s = "You have nothing to identify.";
2826 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2828 /* Get the item (in the pack) */
2831 o_ptr = &inventory[item];
2834 /* Get the item (on the floor) */
2837 o_ptr = &o_list[0 - item];
2841 old_known = identify_item(o_ptr);
2844 object_desc(o_name, o_ptr, TRUE, 3);
2847 if (item >= INVEN_RARM)
2850 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2852 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2858 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2860 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2866 msg_format("¾²¾å: %s¡£", o_name);
2868 msg_format("On the ground: %s.", o_name);
2872 /* Auto-inscription/destroy */
2873 idx = is_autopick(o_ptr);
2874 auto_inscribe_item(item, idx);
2875 if (destroy_identify && !old_known)
2876 auto_destroy_item(item, idx);
2878 /* Something happened */
2884 * Mundanify an object in the inventory (or on the floor)
2885 * This routine does *not* automatically combine objects.
2886 * Returns TRUE if something was mundanified, else FALSE.
2888 bool mundane_spell(bool only_equip)
2894 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
2895 item_tester_no_ryoute = TRUE;
2899 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2900 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2902 q = "Use which item? ";
2903 s = "You have nothing you can use.";
2906 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2908 /* Get the item (in the pack) */
2911 o_ptr = &inventory[item];
2914 /* Get the item (on the floor) */
2917 o_ptr = &o_list[0 - item];
2922 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2924 msg_print("There is a bright flash of light!");
2927 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2928 byte ix = o_ptr->ix; /* X-position on map, or zero */
2929 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2930 byte marked = o_ptr->marked; /* Object is marked */
2931 s16b weight = o_ptr->number * o_ptr->weight;
2932 u16b inscription = o_ptr->inscription;
2935 object_prep(o_ptr, o_ptr->k_idx);
2939 o_ptr->next_o_idx = next_o_idx;
2940 o_ptr->marked = marked;
2941 o_ptr->inscription = inscription;
2942 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2946 /* Something happened */
2952 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2954 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2957 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2959 if (!item_tester_hook_identify_fully(o_ptr))
2961 return item_tester_hook_weapon_armour(o_ptr);
2965 * Fully "identify" an object in the inventory -BEN-
2966 * This routine returns TRUE if an item was identified.
2968 bool identify_fully(bool only_equip)
2972 char o_name[MAX_NLEN];
2977 item_tester_no_ryoute = TRUE;
2979 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2981 item_tester_hook = item_tester_hook_identify_fully;
2983 if (!can_get_item())
2986 item_tester_hook = item_tester_hook_weapon_armour;
2988 item_tester_hook = NULL;
2993 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2994 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2996 q = "Identify which item? ";
2997 s = "You have nothing to identify.";
3000 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
3002 /* Get the item (in the pack) */
3005 o_ptr = &inventory[item];
3008 /* Get the item (on the floor) */
3011 o_ptr = &o_list[0 - item];
3015 old_known = identify_item(o_ptr);
3017 /* Mark the item as fully known */
3018 o_ptr->ident |= (IDENT_MENTAL);
3024 object_desc(o_name, o_ptr, TRUE, 3);
3027 if (item >= INVEN_RARM)
3030 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
3032 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
3040 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
3042 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3048 msg_format("¾²¾å: %s¡£", o_name);
3050 msg_format("On the ground: %s.", o_name);
3054 /* Describe it fully */
3055 (void)screen_object(o_ptr, TRUE);
3057 /* Auto-inscription/destroy */
3058 idx = is_autopick(o_ptr);
3059 auto_inscribe_item(item, idx);
3060 if (destroy_identify && !old_known)
3061 auto_destroy_item(item, idx);
3071 * Hook for "get_item()". Determine if something is rechargable.
3073 bool item_tester_hook_recharge(object_type *o_ptr)
3075 /* Recharge staffs */
3076 if (o_ptr->tval == TV_STAFF) return (TRUE);
3078 /* Recharge wands */
3079 if (o_ptr->tval == TV_WAND) return (TRUE);
3081 /* Hack -- Recharge rods */
3082 if (o_ptr->tval == TV_ROD) return (TRUE);
3090 * Recharge a wand/staff/rod from the pack or on the floor.
3091 * This function has been rewritten in Oangband and ZAngband.
3093 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3094 * Chaos -- Arcane Binding --> recharge(90)
3096 * Scroll of recharging --> recharge(130)
3097 * Artifact activation/Thingol --> recharge(130)
3099 * It is harder to recharge high level, and highly charged wands,
3100 * staffs, and rods. The more wands in a stack, the more easily and
3101 * strongly they recharge. Staffs, however, each get fewer charges if
3104 * XXX XXX XXX Beware of "sliding index errors".
3106 bool recharge(int power)
3109 int recharge_strength, recharge_amount;
3118 char o_name[MAX_NLEN];
3120 /* Only accept legal items */
3121 item_tester_hook = item_tester_hook_recharge;
3125 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3126 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3128 q = "Recharge which item? ";
3129 s = "You have nothing to recharge.";
3132 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3134 /* Get the item (in the pack) */
3137 o_ptr = &inventory[item];
3140 /* Get the item (on the floor) */
3143 o_ptr = &o_list[0 - item];
3146 /* Get the object kind. */
3147 k_ptr = &k_info[o_ptr->k_idx];
3149 /* Extract the object "level" */
3150 lev = get_object_level(o_ptr);
3153 /* Recharge a rod */
3154 if (o_ptr->tval == TV_ROD)
3156 /* Extract a recharge strength by comparing object level to power. */
3157 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3161 if (one_in_(recharge_strength))
3163 /* Activate the failure code. */
3170 /* Recharge amount */
3171 recharge_amount = (power * damroll(3, 2));
3173 /* Recharge by that amount */
3174 if (o_ptr->timeout > recharge_amount)
3175 o_ptr->timeout -= recharge_amount;
3182 /* Recharge wand/staff */
3185 /* Extract a recharge strength by comparing object level to power.
3186 * Divide up a stack of wands' charges to calculate charge penalty.
3188 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3189 recharge_strength = (100 + power - lev -
3190 (8 * o_ptr->pval / o_ptr->number)) / 15;
3192 /* All staffs, unstacked wands. */
3193 else recharge_strength = (100 + power - lev -
3194 (8 * o_ptr->pval)) / 15;
3197 if (recharge_strength < 0) recharge_strength = 0;
3200 if (one_in_(recharge_strength))
3202 /* Activate the failure code. */
3206 /* If the spell didn't backfire, recharge the wand or staff. */
3209 /* Recharge based on the standard number of charges. */
3210 recharge_amount = randint1(1 + k_ptr->pval / 2);
3212 /* Multiple wands in a stack increase recharging somewhat. */
3213 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3216 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3217 if (recharge_amount < 1) recharge_amount = 1;
3218 if (recharge_amount > 12) recharge_amount = 12;
3221 /* But each staff in a stack gets fewer additional charges,
3222 * although always at least one.
3224 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3226 recharge_amount /= o_ptr->number;
3227 if (recharge_amount < 1) recharge_amount = 1;
3230 /* Recharge the wand or staff. */
3231 o_ptr->pval += recharge_amount;
3234 /* Hack -- we no longer "know" the item */
3235 o_ptr->ident &= ~(IDENT_KNOWN);
3237 /* Hack -- we no longer think the item is empty */
3238 o_ptr->ident &= ~(IDENT_EMPTY);
3243 /* Inflict the penalties for failing a recharge. */
3246 /* Artifacts are never destroyed. */
3247 if (artifact_p(o_ptr))
3249 object_desc(o_name, o_ptr, TRUE, 0);
3251 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3253 msg_format("The recharging backfires - %s is completely drained!", o_name);
3257 /* Artifact rods. */
3258 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3259 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3261 /* Artifact wands and staffs. */
3262 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3267 /* Get the object description */
3268 object_desc(o_name, o_ptr, FALSE, 0);
3270 /*** Determine Seriousness of Failure ***/
3272 /* Mages recharge objects more safely. */
3273 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)
3275 /* 10% chance to blow up one rod, otherwise draining. */
3276 if (o_ptr->tval == TV_ROD)
3278 if (one_in_(10)) fail_type = 2;
3281 /* 75% chance to blow up one wand, otherwise draining. */
3282 else if (o_ptr->tval == TV_WAND)
3284 if (!one_in_(3)) fail_type = 2;
3287 /* 50% chance to blow up one staff, otherwise no effect. */
3288 else if (o_ptr->tval == TV_STAFF)
3290 if (one_in_(2)) fail_type = 2;
3295 /* All other classes get no special favors. */
3298 /* 33% chance to blow up one rod, otherwise draining. */
3299 if (o_ptr->tval == TV_ROD)
3301 if (one_in_(3)) fail_type = 2;
3304 /* 20% chance of the entire stack, else destroy one wand. */
3305 else if (o_ptr->tval == TV_WAND)
3307 if (one_in_(5)) fail_type = 3;
3310 /* Blow up one staff. */
3311 else if (o_ptr->tval == TV_STAFF)
3317 /*** Apply draining and destruction. ***/
3319 /* Drain object or stack of objects. */
3322 if (o_ptr->tval == TV_ROD)
3325 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3327 msg_print("The recharge backfires, draining the rod further!");
3330 if (o_ptr->timeout < 10000)
3331 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3333 else if (o_ptr->tval == TV_WAND)
3336 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3338 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3343 /* Staffs aren't drained. */
3346 /* Destroy an object or one in a stack of objects. */
3349 if (o_ptr->number > 1)
3351 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3353 msg_format("Wild magic consumes one of your %s!", o_name);
3358 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3360 msg_format("Wild magic consumes your %s!", o_name);
3364 /* Reduce rod stack maximum timeout, drain wands. */
3365 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3366 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3368 /* Reduce and describe inventory */
3371 inven_item_increase(item, -1);
3372 inven_item_describe(item);
3373 inven_item_optimize(item);
3376 /* Reduce and describe floor item */
3379 floor_item_increase(0 - item, -1);
3380 floor_item_describe(0 - item);
3381 floor_item_optimize(0 - item);
3385 /* Destroy all members of a stack of objects. */
3388 if (o_ptr->number > 1)
3390 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3392 msg_format("Wild magic consumes all your %s!", o_name);
3397 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3399 msg_format("Wild magic consumes your %s!", o_name);
3404 /* Reduce and describe inventory */
3407 inven_item_increase(item, -999);
3408 inven_item_describe(item);
3409 inven_item_optimize(item);
3412 /* Reduce and describe floor item */
3415 floor_item_increase(0 - item, -999);
3416 floor_item_describe(0 - item);
3417 floor_item_optimize(0 - item);
3423 /* Combine / Reorder the pack (later) */
3424 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3427 p_ptr->window |= (PW_INVEN);
3429 /* Something was done */
3437 bool bless_weapon(void)
3441 u32b flgs[TR_FLAG_SIZE];
3442 char o_name[MAX_NLEN];
3445 item_tester_no_ryoute = TRUE;
3446 /* Assume enchant weapon */
3447 item_tester_hook = item_tester_hook_weapon2;
3451 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3452 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3454 q = "Bless which weapon? ";
3455 s = "You have weapon to bless.";
3458 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3461 /* Get the item (in the pack) */
3464 o_ptr = &inventory[item];
3467 /* Get the item (on the floor) */
3470 o_ptr = &o_list[0 - item];
3475 object_desc(o_name, o_ptr, FALSE, 0);
3477 /* Extract the flags */
3478 object_flags(o_ptr, flgs);
3480 if (cursed_p(o_ptr))
3482 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3483 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3486 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3489 msg_format("The black aura on %s %s disrupts the blessing!",
3490 ((item >= 0) ? "your" : "the"), o_name);
3497 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3500 msg_format("A malignant aura leaves %s %s.",
3501 ((item >= 0) ? "your" : "the"), o_name);
3506 o_ptr->curse_flags = 0L;
3508 /* Hack -- Assume felt */
3509 o_ptr->ident |= (IDENT_SENSE);
3512 o_ptr->feeling = FEEL_NONE;
3514 /* Recalculate the bonuses */
3515 p_ptr->update |= (PU_BONUS);
3518 p_ptr->window |= (PW_EQUIP);
3522 * Next, we try to bless it. Artifacts have a 1/3 chance of
3523 * being blessed, otherwise, the operation simply disenchants
3524 * them, godly power negating the magic. Ok, the explanation
3525 * is silly, but otherwise priests would always bless every
3526 * artifact weapon they find. Ego weapons and normal weapons
3527 * can be blessed automatically.
3529 if (have_flag(flgs, TR_BLESSED))
3532 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3535 msg_format("%s %s %s blessed already.",
3536 ((item >= 0) ? "Your" : "The"), o_name,
3537 ((o_ptr->number > 1) ? "were" : "was"));
3543 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3547 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3550 msg_format("%s %s shine%s!",
3551 ((item >= 0) ? "Your" : "The"), o_name,
3552 ((o_ptr->number > 1) ? "" : "s"));
3555 add_flag(o_ptr->art_flags, TR_BLESSED);
3556 o_ptr->discount = 99;
3560 bool dis_happened = FALSE;
3563 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3565 msg_print("The weapon resists your blessing!");
3569 /* Disenchant tohit */
3570 if (o_ptr->to_h > 0)
3573 dis_happened = TRUE;
3576 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3578 /* Disenchant todam */
3579 if (o_ptr->to_d > 0)
3582 dis_happened = TRUE;
3585 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3587 /* Disenchant toac */
3588 if (o_ptr->to_a > 0)
3591 dis_happened = TRUE;
3594 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3599 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3601 msg_print("There is a static feeling in the air...");
3605 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3608 msg_format("%s %s %s disenchanted!",
3609 ((item >= 0) ? "Your" : "The"), o_name,
3610 ((o_ptr->number > 1) ? "were" : "was"));
3616 /* Recalculate bonuses */
3617 p_ptr->update |= (PU_BONUS);
3620 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3631 bool pulish_shield(void)
3635 u32b flgs[TR_FLAG_SIZE];
3636 char o_name[MAX_NLEN];
3639 item_tester_no_ryoute = TRUE;
3640 /* Assume enchant weapon */
3641 item_tester_tval = TV_SHIELD;
3645 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3646 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3648 q = "Pulish which weapon? ";
3649 s = "You have weapon to pulish.";
3652 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3655 /* Get the item (in the pack) */
3658 o_ptr = &inventory[item];
3661 /* Get the item (on the floor) */
3664 o_ptr = &o_list[0 - item];
3669 object_desc(o_name, o_ptr, FALSE, 0);
3671 /* Extract the flags */
3672 object_flags(o_ptr, flgs);
3674 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3675 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3678 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3680 msg_format("%s %s shine%s!",
3681 ((item >= 0) ? "Your" : "The"), o_name,
3682 ((o_ptr->number > 1) ? "" : "s"));
3684 o_ptr->name2 = EGO_REFLECTION;
3685 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3687 o_ptr->discount = 99;
3688 chg_virtue(V_ENCHANT, 2);
3694 if (flush_failure) flush();
3697 msg_print("¼ºÇÔ¤·¤¿¡£");
3699 msg_print("Failed.");
3702 chg_virtue(V_ENCHANT, -2);
3711 * Potions "smash open" and cause an area effect when
3712 * (1) they are shattered while in the player's inventory,
3713 * due to cold (etc) attacks;
3714 * (2) they are thrown at a monster, or obstacle;
3715 * (3) they are shattered by a "cold ball" or other such spell
3716 * while lying on the floor.
3719 * who --- who caused the potion to shatter (0=player)
3720 * potions that smash on the floor are assumed to
3721 * be caused by no-one (who = 1), as are those that
3722 * shatter inside the player inventory.
3723 * (Not anymore -- I changed this; TY)
3724 * y, x --- coordinates of the potion (or player if
3725 * the potion was in her inventory);
3726 * o_ptr --- pointer to the potion object.
3728 bool potion_smash_effect(int who, int y, int x, int k_idx)
3735 object_kind *k_ptr = &k_info[k_idx];
3737 switch (k_ptr->sval)
3739 case SV_POTION_SALT_WATER:
3740 case SV_POTION_SLIME_MOLD:
3741 case SV_POTION_LOSE_MEMORIES:
3742 case SV_POTION_DEC_STR:
3743 case SV_POTION_DEC_INT:
3744 case SV_POTION_DEC_WIS:
3745 case SV_POTION_DEC_DEX:
3746 case SV_POTION_DEC_CON:
3747 case SV_POTION_DEC_CHR:
3748 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3749 case SV_POTION_APPLE_JUICE:
3752 case SV_POTION_INFRAVISION:
3753 case SV_POTION_DETECT_INVIS:
3754 case SV_POTION_SLOW_POISON:
3755 case SV_POTION_CURE_POISON:
3756 case SV_POTION_BOLDNESS:
3757 case SV_POTION_RESIST_HEAT:
3758 case SV_POTION_RESIST_COLD:
3759 case SV_POTION_HEROISM:
3760 case SV_POTION_BESERK_STRENGTH:
3761 case SV_POTION_RES_STR:
3762 case SV_POTION_RES_INT:
3763 case SV_POTION_RES_WIS:
3764 case SV_POTION_RES_DEX:
3765 case SV_POTION_RES_CON:
3766 case SV_POTION_RES_CHR:
3767 case SV_POTION_INC_STR:
3768 case SV_POTION_INC_INT:
3769 case SV_POTION_INC_WIS:
3770 case SV_POTION_INC_DEX:
3771 case SV_POTION_INC_CON:
3772 case SV_POTION_INC_CHR:
3773 case SV_POTION_AUGMENTATION:
3774 case SV_POTION_ENLIGHTENMENT:
3775 case SV_POTION_STAR_ENLIGHTENMENT:
3776 case SV_POTION_SELF_KNOWLEDGE:
3777 case SV_POTION_EXPERIENCE:
3778 case SV_POTION_RESISTANCE:
3779 case SV_POTION_INVULNERABILITY:
3780 case SV_POTION_NEW_LIFE:
3781 /* All of the above potions have no effect when shattered */
3783 case SV_POTION_SLOWNESS:
3788 case SV_POTION_POISON:
3793 case SV_POTION_BLINDNESS:
3797 case SV_POTION_CONFUSION: /* Booze */
3801 case SV_POTION_SLEEP:
3805 case SV_POTION_RUINATION:
3806 case SV_POTION_DETONATIONS:
3808 dam = damroll(25, 25);
3811 case SV_POTION_DEATH:
3812 dt = GF_DEATH_RAY; /* !! */
3813 dam = k_ptr->level * 10;
3817 case SV_POTION_SPEED:
3820 case SV_POTION_CURE_LIGHT:
3822 dam = damroll(2, 3);
3824 case SV_POTION_CURE_SERIOUS:
3826 dam = damroll(4, 3);
3828 case SV_POTION_CURE_CRITICAL:
3829 case SV_POTION_CURING:
3831 dam = damroll(6, 3);
3833 case SV_POTION_HEALING:
3835 dam = damroll(10, 10);
3837 case SV_POTION_RESTORE_EXP:
3842 case SV_POTION_LIFE:
3844 dam = damroll(50, 50);
3847 case SV_POTION_STAR_HEALING:
3849 dam = damroll(50, 50);
3852 case SV_POTION_RESTORE_MANA: /* MANA */
3854 dam = damroll(10, 10);
3861 (void)project(who, radius, y, x, dam, dt,
3862 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3864 /* XXX those potions that explode need to become "known" */
3870 * Hack -- Display all known spells in a window
3872 * XXX XXX XXX Need to analyze size of the window.
3874 * XXX XXX XXX Need more color coding.
3876 void display_spell_list(void)
3889 /* They have too many spells to list */
3890 if (p_ptr->pclass == CLASS_SORCERER) return;
3891 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3893 /* mind.c type classes */
3894 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3895 (p_ptr->pclass == CLASS_BERSERKER) ||
3896 (p_ptr->pclass == CLASS_NINJA) ||
3897 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3898 (p_ptr->pclass == CLASS_FORCETRAINER))
3904 int plev = p_ptr->lev;
3910 bool use_hp = FALSE;
3912 /* Display a list of spells */
3915 put_str("̾Á°", y, x + 5);
3916 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3918 put_str("Name", y, x + 5);
3919 put_str("Lv Mana Fail Info", y, x + 35);
3922 switch(p_ptr->pclass)
3924 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3925 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3926 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3927 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3928 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3929 default: use_mind = 0;break;
3932 /* Dump the spells */
3933 for (i = 0; i < MAX_MIND_POWERS; i++)
3935 byte a = TERM_WHITE;
3937 /* Access the available spell */
3938 spell = mind_powers[use_mind].info[i];
3939 if (spell.min_lev > plev) break;
3941 /* Get the failure rate */
3942 chance = spell.fail;
3944 /* Reduce failure rate by "effective" level adjustment */
3945 chance -= 3 * (p_ptr->lev - spell.min_lev);
3947 /* Reduce failure rate by INT/WIS adjustment */
3948 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3952 /* Not enough mana to cast */
3953 if (spell.mana_cost > p_ptr->csp)
3955 chance += 5 * (spell.mana_cost - p_ptr->csp);
3961 /* Not enough hp to cast */
3962 if (spell.mana_cost > p_ptr->chp)
3969 /* Extract the minimum failure rate */
3970 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3972 /* Minimum failure rate */
3973 if (chance < minfail) chance = minfail;
3975 /* Stunning makes spells harder */
3976 if (p_ptr->stun > 50) chance += 25;
3977 else if (p_ptr->stun) chance += 15;
3979 /* Always a 5 percent chance of working */
3980 if (chance > 95) chance = 95;
3983 mindcraft_info(comment, use_mind, i);
3985 /* Dump the spell */
3986 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3988 spell.min_lev, spell.mana_cost, chance, comment);
3990 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3995 /* Cannot read spellbooks */
3996 if (REALM_NONE == p_ptr->realm1) return;
3998 /* Normal spellcaster with books */
4001 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
4005 /* Reset vertical */
4008 /* Vertical location */
4009 y = (j < 3) ? 0 : (m[j - 3] + 2);
4011 /* Horizontal location */
4015 for (i = 0; i < 32; i++)
4017 byte a = TERM_WHITE;
4019 /* Access the spell */
4020 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
4022 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
4026 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
4029 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
4032 if (s_ptr->slevel >= 99)
4036 strcpy(name, "(ȽÆÉÉÔǽ)");
4038 strcpy(name, "(illegible)");
4048 ((p_ptr->spell_forgotten1 & (1L << i))) :
4049 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4056 else if (!((j < 1) ?
4057 (p_ptr->spell_learned1 & (1L << i)) :
4058 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4065 else if (!((j < 1) ?
4066 (p_ptr->spell_worked1 & (1L << i)) :
4067 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4073 /* Dump the spell --(-- */
4074 sprintf(out_val, "%c/%c) %-20.20s",
4075 I2A(n / 8), I2A(n % 8), name);
4080 /* Dump onto the window */
4081 Term_putstr(x, m[j], -1, a, out_val);
4091 * Returns experience of a spell
4093 s16b experience_of_spell(int spell, int use_realm)
4095 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4096 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4097 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4098 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4104 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4106 int mod_need_mana(int need_mana, int spell, int realm)
4108 #define MANA_CONST 2400
4110 #define DEC_MANA_DIV 3
4113 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4116 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4117 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4119 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4120 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4121 need_mana /= MANA_CONST * MANA_DIV;
4122 if (need_mana < 1) need_mana = 1;
4125 /* Non-realm magic */
4128 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4140 * Returns spell chance of failure for spell -RAK-
4142 s16b spell_chance(int spell, int use_realm)
4144 int chance, minfail;
4147 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4150 /* Paranoia -- must be literate */
4151 if (!mp_ptr->spell_book) return (100);
4153 if (use_realm == REALM_HISSATSU) return 0;
4155 /* Access the spell */
4156 if (!is_magic(use_realm))
4158 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4162 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4165 /* Extract the base spell failure rate */
4166 chance = s_ptr->sfail;
4168 /* Reduce failure rate by "effective" level adjustment */
4169 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4171 /* Reduce failure rate by INT/WIS adjustment */
4172 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4175 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4177 /* Extract mana consumption rate */
4178 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4180 /* Not enough mana to cast */
4181 if (need_mana > p_ptr->csp)
4183 chance += 5 * (need_mana - p_ptr->csp);
4186 chance += p_ptr->to_m_chance;
4187 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4189 /* Extract the minimum failure rate */
4190 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4193 * Non mage/priest characters never get too good
4194 * (added high mage, mindcrafter)
4196 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4198 if (minfail < 5) minfail = 5;
4201 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4202 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4203 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4205 if (p_ptr->heavy_spell) chance += 20;
4206 if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
4207 else if (p_ptr->easy_spell) chance-=3;
4208 else if (p_ptr->dec_mana) chance-=2;
4210 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4211 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4212 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4214 /* Minimum failure rate */
4215 if (chance < minfail) chance = minfail;
4217 /* Stunning makes spells harder */
4218 if (p_ptr->stun > 50) chance += 25;
4219 else if (p_ptr->stun) chance += 15;
4221 /* Always a 5 percent chance of working */
4222 if (chance > 95) chance = 95;
4224 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4225 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4227 s16b exp = experience_of_spell(spell, use_realm);
4228 if (exp >= SPELL_EXP_EXPERT) chance--;
4229 if (exp >= SPELL_EXP_MASTER) chance--;
4231 if(p_ptr->dec_mana) chance--;
4232 if (p_ptr->heavy_spell) chance += 5;
4234 chance = MAX(chance,0);
4236 /* Return the chance */
4243 * Determine if a spell is "okay" for the player to cast or study
4244 * The spell must be legible, not forgotten, and also, to cast,
4245 * it must be known, and to study, it must not be known.
4247 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4251 /* Access the spell */
4252 if (!is_magic(use_realm))
4254 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4258 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4261 /* Spell is illegal */
4262 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4264 /* Spell is forgotten */
4265 if ((use_realm == p_ptr->realm2) ?
4266 (p_ptr->spell_forgotten2 & (1L << spell)) :
4267 (p_ptr->spell_forgotten1 & (1L << spell)))
4273 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4274 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4276 /* Spell is learned */
4277 if ((use_realm == p_ptr->realm2) ?
4278 (p_ptr->spell_learned2 & (1L << spell)) :
4279 (p_ptr->spell_learned1 & (1L << spell)))
4282 return (!study_pray);
4285 /* Okay to study, not to cast */
4292 * Extra information on a spell -DRS-
4294 * We can use up to 14 characters of the buffer 'p'
4296 * The strings in this function were extracted from the code in the
4297 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4299 static void spell_info(char *p, int spell, int use_realm)
4301 int plev = p_ptr->lev;
4304 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4305 p_ptr->pclass == CLASS_HIGH_MAGE ||
4306 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4308 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4309 p_ptr->pclass == CLASS_HIGH_MAGE ||
4310 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4312 cptr s_dam = "»½ý:";
4313 cptr s_dur = "´ü´Ö:";
4314 cptr s_range = "ÈÏ°Ï:";
4315 cptr s_heal = "²óÉü:";
4316 cptr s_random = "¥é¥ó¥À¥à";
4317 cptr s_delay = "ÃÙ±ä:";
4319 cptr s_dam = "dam ";
4320 cptr s_dur = "dur ";
4321 cptr s_range = "range ";
4322 cptr s_heal = "heal ";
4323 cptr s_random = "random";
4324 cptr s_delay = "delay ";
4329 /* Analyze the spell */
4332 case REALM_LIFE: /* Life */
4335 case 0: sprintf(p, " %s2d10", s_heal); break;
4336 case 1: sprintf(p, " %s12+d12", s_dur); break;
4337 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4338 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4339 case 5: sprintf(p, " %s4d10", s_heal); break;
4340 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4341 case 10: sprintf(p, " %s8d10", s_heal); break;
4342 case 11: sprintf(p, " %s20+d20", s_dur); break;
4343 case 14: sprintf(p, " %s300", s_heal); break;
4344 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4345 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4346 case 21: sprintf(p, " %s15+d21", s_delay); break;
4347 case 29: sprintf(p, " %s2000", s_heal); break;
4348 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4352 case REALM_SORCERY: /* Sorcery */
4355 case 1: sprintf(p, " %s10", s_range); break;
4356 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4357 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4358 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4359 case 18: sprintf(p, " %s25+d30", s_dur); break;
4360 case 22: sprintf(p, " %s15+d21", s_delay); break;
4361 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4362 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4364 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4366 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4368 case 27: sprintf(p, " %s25+d30", s_dur); break;
4369 case 31: sprintf(p, " %s4+d4", s_dur); break;
4373 case REALM_NATURE: /* Nature */
4377 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4379 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4381 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4382 case 6: sprintf(p, " %s20+d20", s_dur); break;
4383 case 7: sprintf(p, " %s2d8", s_heal); break;
4384 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4385 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4386 case 12: sprintf(p, " %s6d8", s_dam); break;
4387 case 15: sprintf(p, " %s500", s_heal); break;
4388 case 17: sprintf(p, " %s20+d30", s_dur); break;
4389 case 18: sprintf(p, " %s20+d20", s_dur); break;
4391 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4393 case 24: sprintf(p, " rad 10"); break;
4395 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4396 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4397 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4398 case 29: sprintf(p, " %s75", s_dam); break;
4399 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4403 case REALM_CHAOS: /* Chaos */
4406 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4407 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4408 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4409 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4410 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4411 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4412 case 8: sprintf(p, " %s", s_random); break;
4413 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4414 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4415 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4416 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4417 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4418 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4419 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4420 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4421 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4423 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4425 case 25: sprintf(p, " dam %d each", plev * 2); break;
4427 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4428 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4429 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4430 case 30: sprintf(p, " %s%d", s_dam, p_ptr->chp); break;
4431 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4435 case REALM_DEATH: /* Death */
4438 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4439 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4440 case 5: sprintf(p, " %s20+d20", s_dur); break;
4441 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4442 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4443 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4445 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4447 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4449 case 16: sprintf(p, " %s25+d25", s_dur); break;
4450 case 17: sprintf(p, " %s", s_random); break;
4451 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4452 case 19: sprintf(p, " %s25+d25", s_dur); break;
4453 case 21: sprintf(p, " %s3*100", s_dam); break;
4454 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4455 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4456 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4457 case 30: sprintf(p, " %s666", s_dam); break;
4458 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4462 case REALM_TRUMP: /* Trump */
4465 case 0: sprintf(p, " %s10", s_range); break;
4466 case 2: sprintf(p, " %s", s_random); break;
4467 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4468 case 5: sprintf(p, " %s25+d30", s_dur); break;
4470 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4472 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4474 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4475 case 14: sprintf(p, " %s15+d21", s_delay); break;
4476 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4478 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4480 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4485 case REALM_ARCANE: /* Arcane */
4488 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4489 case 4: sprintf(p, " %s10", s_range); break;
4490 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4491 case 7: sprintf(p, " %s2d8", s_heal); break;
4495 case 17: sprintf(p, " %s20+d20", s_dur); break;
4496 case 18: sprintf(p, " %s4d8", s_heal); break;
4497 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4498 case 21: sprintf(p, " %s6d8", s_dam); break;
4499 case 24: sprintf(p, " %s24+d24", s_dur); break;
4500 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4501 case 30: sprintf(p, " %s15+d21", s_delay); break;
4502 case 31: sprintf(p, " %s25+d30", s_dur); break;
4506 case REALM_ENCHANT: /* Craft */
4509 case 0: sprintf(p, " %s100+d100", s_dur); break;
4510 case 1: sprintf(p, " %s80+d80", s_dur); break;
4516 case 18: sprintf(p, " %s20+d20", s_dur); break;
4517 case 5: sprintf(p, " %s25+d25", s_dur); break;
4518 case 8: sprintf(p, " %s24+d24", s_dur); break;
4519 case 11: sprintf(p, " %s25+d25", s_dur); break;
4520 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4521 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4522 case 16: sprintf(p, " %s25+d30", s_dur); break;
4523 case 17: sprintf(p, " %s30+d20", s_dur); break;
4524 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4525 case 20: sprintf(p, " %s50+d50", s_dur); break;
4526 case 23: sprintf(p, " %s20+d20", s_dur); break;
4527 case 31: sprintf(p, " %s13+d13", s_dur); break;
4531 case REALM_DAEMON: /* Daemon */
4534 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4535 case 2: sprintf(p, " %s12+d12", s_dur); break;
4536 case 3: sprintf(p, " %s20+d20", s_dur); break;
4537 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4538 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4539 case 10: sprintf(p, " %s20+d20", s_dur); break;
4540 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4541 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4542 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4543 case 16: sprintf(p, " %s30+d25", s_dur); break;
4544 case 17: sprintf(p, " %s20+d20", s_dur); break;
4545 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4546 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4547 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4548 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4549 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4550 case 24: sprintf(p, " %s25+d25", s_dur); break;
4551 case 25: sprintf(p, " %s20+d20", s_dur); break;
4552 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4553 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4554 case 30: sprintf(p, " %s600", s_dam); break;
4555 case 31: sprintf(p, " %s15+d15", s_dur); break;
4559 case REALM_CRUSADE: /* Crusade */
4562 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4563 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4565 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4567 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4569 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4570 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4571 case 12: sprintf(p, " %s24+d24", s_dur); break;
4572 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4573 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4575 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4577 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4579 case 18: sprintf(p, " %s18+d18", s_dur); break;
4580 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4581 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4582 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4583 case 24: sprintf(p, " %s25+d25", s_dur); break;
4584 case 28: sprintf(p, " %s10+d10", s_dur); break;
4586 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4588 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4591 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4593 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4598 case REALM_MUSIC: /* Music */
4601 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4602 case 4 : sprintf(p, " %s2d6", s_heal); break;
4603 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4604 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4605 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4606 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4607 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4608 case 28: sprintf(p, " %s15d10", s_heal); break;
4609 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4614 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4616 sprintf(p, "Unknown type: %d.", use_realm);
4623 * Print a list of spells (for browsing or casting or viewing)
4625 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4627 int i, spell, exp_level, increment = 64;
4639 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4641 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4643 msg_print("Warning! print_spells called with null realm");
4647 /* Title the list */
4649 if (use_realm == REALM_HISSATSU)
4651 strcpy(buf," Lv MP");
4653 strcpy(buf," Lv SP");
4657 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4659 strcpy(buf,"Profic Lv SP Fail Effect");
4663 put_str("̾Á°", y, x + 5);
4664 put_str(buf, y, x + 29);
4666 put_str("Name", y, x + 5);
4667 put_str(buf, y, x + 29);
4670 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4671 else if (use_realm == p_ptr->realm1) increment = 0;
4672 else if (use_realm == p_ptr->realm2) increment = 32;
4674 /* Dump the spells */
4675 for (i = 0; i < num; i++)
4677 /* Access the spell */
4680 /* Access the spell */
4681 if (!is_magic(use_realm))
4683 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4687 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4690 if (use_realm == REALM_HISSATSU)
4691 need_mana = s_ptr->smana;
4694 s16b exp = experience_of_spell(spell, use_realm);
4696 /* Extract mana consumption rate */
4697 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4699 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4700 else exp_level = spell_exp_level(exp);
4703 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4704 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4705 else if (s_ptr->slevel >= 99) max = TRUE;
4706 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4708 strncpy(ryakuji, exp_level_str[exp_level], 4);
4713 if (use_menu && target_spell)
4715 if (i == (target_spell-1))
4717 strcpy(out_val, " ¡Õ ");
4719 strcpy(out_val, " > ");
4722 strcpy(out_val, " ");
4724 else sprintf(out_val, " %c) ", I2A(i));
4725 /* Skip illegible spells */
4726 if (s_ptr->slevel >= 99)
4729 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4731 strcat(out_val, format("%-30s", "(illegible)"));
4734 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4738 /* XXX XXX Could label spells above the players level */
4740 /* Get extra info */
4741 spell_info(info, spell, use_realm);
4746 /* Assume spell is known and tried */
4747 line_attr = TERM_WHITE;
4749 /* Analyze the spell */
4750 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4752 if (s_ptr->slevel > p_ptr->max_plv)
4757 comment = " unknown";
4760 line_attr = TERM_L_BLUE;
4762 else if (s_ptr->slevel > p_ptr->lev)
4767 comment = " forgotten";
4770 line_attr = TERM_YELLOW;
4773 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4778 comment = " unknown";
4781 line_attr = TERM_L_BLUE;
4783 else if ((use_realm == p_ptr->realm1) ?
4784 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4785 ((p_ptr->spell_forgotten2 & (1L << spell))))
4790 comment = " forgotten";
4793 line_attr = TERM_YELLOW;
4795 else if (!((use_realm == p_ptr->realm1) ?
4796 (p_ptr->spell_learned1 & (1L << spell)) :
4797 (p_ptr->spell_learned2 & (1L << spell))))
4802 comment = " unknown";
4805 line_attr = TERM_L_BLUE;
4807 else if (!((use_realm == p_ptr->realm1) ?
4808 (p_ptr->spell_worked1 & (1L << spell)) :
4809 (p_ptr->spell_worked2 & (1L << spell))))
4812 comment = " ̤·Ð¸³";
4814 comment = " untried";
4817 line_attr = TERM_L_GREEN;
4820 /* Dump the spell --(-- */
4821 if (use_realm == REALM_HISSATSU)
4823 strcat(out_val, format("%-25s %2d %4d",
4824 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4825 s_ptr->slevel, need_mana));
4829 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4830 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4831 (max ? '!' : ' '), ryakuji,
4832 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4834 c_prt(line_attr, out_val, y + i + 1, x);
4837 /* Clear the bottom line */
4838 prt("", y + i + 1, x);
4843 * Note that amulets, rods, and high-level spell books are immune
4844 * to "inventory damage" of any kind. Also sling ammo and shovels.
4849 * Does a given class of objects (usually) hate acid?
4850 * Note that acid can either melt or corrode something.
4852 bool hates_acid(object_type *o_ptr)
4854 /* Analyze the type */
4855 switch (o_ptr->tval)
4857 /* Wearable items */
4877 /* Staffs/Scrolls are wood/paper */
4890 /* Junk is useless */
4904 * Does a given object (usually) hate electricity?
4906 bool hates_elec(object_type *o_ptr)
4908 switch (o_ptr->tval)
4922 * Does a given object (usually) hate fire?
4923 * Hafted/Polearm weapons have wooden shafts.
4924 * Arrows/Bows are mostly wooden.
4926 bool hates_fire(object_type *o_ptr)
4928 /* Analyze the type */
4929 switch (o_ptr->tval)
4947 case TV_SORCERY_BOOK:
4948 case TV_NATURE_BOOK:
4952 case TV_ARCANE_BOOK:
4953 case TV_ENCHANT_BOOK:
4954 case TV_DAEMON_BOOK:
4955 case TV_CRUSADE_BOOK:
4957 case TV_HISSATSU_BOOK:
4968 /* Staffs/Scrolls burn */
4981 * Does a given object (usually) hate cold?
4983 bool hates_cold(object_type *o_ptr)
4985 switch (o_ptr->tval)
5002 int set_acid_destroy(object_type *o_ptr)
5004 u32b flgs[TR_FLAG_SIZE];
5005 if (!hates_acid(o_ptr)) return (FALSE);
5006 object_flags(o_ptr, flgs);
5007 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
5015 int set_elec_destroy(object_type *o_ptr)
5017 u32b flgs[TR_FLAG_SIZE];
5018 if (!hates_elec(o_ptr)) return (FALSE);
5019 object_flags(o_ptr, flgs);
5020 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
5028 int set_fire_destroy(object_type *o_ptr)
5030 u32b flgs[TR_FLAG_SIZE];
5031 if (!hates_fire(o_ptr)) return (FALSE);
5032 object_flags(o_ptr, flgs);
5033 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
5041 int set_cold_destroy(object_type *o_ptr)
5043 u32b flgs[TR_FLAG_SIZE];
5044 if (!hates_cold(o_ptr)) return (FALSE);
5045 object_flags(o_ptr, flgs);
5046 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
5052 * Destroys a type of item on a given percent chance
5053 * Note that missiles are no longer necessarily all destroyed
5054 * Destruction taken from "melee.c" code for "stealing".
5055 * New-style wands and rods handled correctly. -LM-
5056 * Returns number of items destroyed.
5058 int inven_damage(inven_func typ, int perc)
5062 char o_name[MAX_NLEN];
5064 /* Multishadow effects is determined by turn */
5065 if( p_ptr->multishadow && (turn & 1) )return 0;
5067 if (p_ptr->inside_arena) return 0;
5069 /* Count the casualties */
5072 /* Scan through the slots backwards */
5073 for (i = 0; i < INVEN_PACK; i++)
5075 o_ptr = &inventory[i];
5077 /* Skip non-objects */
5078 if (!o_ptr->k_idx) continue;
5080 /* Hack -- for now, skip artifacts */
5081 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
5083 /* Give this item slot a shot at death */
5086 /* Count the casualties */
5087 for (amt = j = 0; j < o_ptr->number; ++j)
5089 if (randint0(100) < perc) amt++;
5092 /* Some casualities */
5095 /* Get a description */
5096 object_desc(o_name, o_ptr, FALSE, 3);
5100 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
5102 msg_format("%sour %s (%c) %s destroyed!",
5106 o_name, index_to_label(i),
5107 ((o_ptr->number > 1) ?
5108 ((amt == o_ptr->number) ? "Á´Éô" :
5109 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
5111 ((o_ptr->number > 1) ?
5112 ((amt == o_ptr->number) ? "All of y" :
5113 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
5114 o_name, index_to_label(i),
5115 ((amt > 1) ? "were" : "was"));
5119 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
5120 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
5123 /* Potions smash open */
5124 if (object_is_potion(o_ptr))
5126 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
5129 /* Reduce the charges of rods/wands */
5130 reduce_charges(o_ptr, amt);
5132 /* Destroy "amt" items */
5133 inven_item_increase(i, -amt);
5134 inven_item_optimize(i);
5136 /* Count the casualties */
5142 /* Return the casualty count */
5148 * Acid has hit the player, attempt to affect some armor.
5150 * Note that the "base armor" of an object never changes.
5152 * If any armor is damaged (or resists), the player takes less damage.
5154 static int minus_ac(void)
5156 object_type *o_ptr = NULL;
5157 u32b flgs[TR_FLAG_SIZE];
5158 char o_name[MAX_NLEN];
5161 /* Pick a (possibly empty) inventory slot */
5162 switch (randint1(7))
5164 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5165 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5166 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5167 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5168 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5169 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5170 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5173 /* Nothing to damage */
5174 if (!o_ptr->k_idx) return (FALSE);
5176 if (o_ptr->tval < TV_BOOTS) return (FALSE);
5178 /* No damage left to be done */
5179 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5183 object_desc(o_name, o_ptr, FALSE, 0);
5185 /* Extract the flags */
5186 object_flags(o_ptr, flgs);
5188 /* Object resists */
5189 if (have_flag(flgs, TR_IGNORE_ACID))
5192 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5194 msg_format("Your %s is unaffected!", o_name);
5203 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5205 msg_format("Your %s is damaged!", o_name);
5209 /* Damage the item */
5212 /* Calculate bonuses */
5213 p_ptr->update |= (PU_BONUS);
5216 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5220 /* Item was damaged */
5226 * Hurt the player with Acid
5228 int acid_dam(int dam, cptr kb_str, int monspell)
5231 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5232 bool double_resist = IS_OPPOSE_ACID();
5234 /* Total Immunity */
5235 if (p_ptr->immune_acid || (dam <= 0))
5237 learn_spell(monspell);
5241 /* Vulnerability (Ouch!) */
5242 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5243 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5245 /* Resist the damage */
5246 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5247 if (double_resist) dam = (dam + 2) / 3;
5249 if ((!(double_resist || p_ptr->resist_acid)) &&
5250 one_in_(HURT_CHANCE))
5251 (void)do_dec_stat(A_CHR);
5253 /* If any armor gets hit, defend the player */
5254 if (minus_ac()) dam = (dam + 1) / 2;
5257 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5259 /* Inventory damage */
5260 if (!(double_resist && p_ptr->resist_acid))
5261 inven_damage(set_acid_destroy, inv);
5267 * Hurt the player with electricity
5269 int elec_dam(int dam, cptr kb_str, int monspell)
5272 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5273 bool double_resist = IS_OPPOSE_ELEC();
5275 /* Total immunity */
5276 if (p_ptr->immune_elec || (dam <= 0))
5278 learn_spell(monspell);
5282 /* Vulnerability (Ouch!) */
5283 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5284 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5285 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5287 /* Resist the damage */
5288 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5289 if (double_resist) dam = (dam + 2) / 3;
5291 if ((!(double_resist || p_ptr->resist_elec)) &&
5292 one_in_(HURT_CHANCE))
5293 (void)do_dec_stat(A_DEX);
5296 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5298 /* Inventory damage */
5299 if (!(double_resist && p_ptr->resist_elec))
5300 inven_damage(set_elec_destroy, inv);
5307 * Hurt the player with Fire
5309 int fire_dam(int dam, cptr kb_str, int monspell)
5312 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5313 bool double_resist = IS_OPPOSE_FIRE();
5315 /* Totally immune */
5316 if (p_ptr->immune_fire || (dam <= 0))
5318 learn_spell(monspell);
5322 /* Vulnerability (Ouch!) */
5323 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5324 if (prace_is_(RACE_ENT)) dam += dam / 3;
5325 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5327 /* Resist the damage */
5328 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5329 if (double_resist) dam = (dam + 2) / 3;
5331 if ((!(double_resist || p_ptr->resist_fire)) &&
5332 one_in_(HURT_CHANCE))
5333 (void)do_dec_stat(A_STR);
5336 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5338 /* Inventory damage */
5339 if (!(double_resist && p_ptr->resist_fire))
5340 inven_damage(set_fire_destroy, inv);
5347 * Hurt the player with Cold
5349 int cold_dam(int dam, cptr kb_str, int monspell)
5352 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5353 bool double_resist = IS_OPPOSE_COLD();
5355 /* Total immunity */
5356 if (p_ptr->immune_cold || (dam <= 0))
5358 learn_spell(monspell);
5362 /* Vulnerability (Ouch!) */
5363 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5364 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5366 /* Resist the damage */
5367 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5368 if (double_resist) dam = (dam + 2) / 3;
5370 if ((!(double_resist || p_ptr->resist_cold)) &&
5371 one_in_(HURT_CHANCE))
5372 (void)do_dec_stat(A_STR);
5375 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5377 /* Inventory damage */
5378 if (!(double_resist && p_ptr->resist_cold))
5379 inven_damage(set_cold_destroy, inv);
5385 bool rustproof(void)
5389 char o_name[MAX_NLEN];
5392 item_tester_no_ryoute = TRUE;
5393 /* Select a piece of armour */
5394 item_tester_hook = item_tester_hook_armour;
5398 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5399 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5401 q = "Rustproof which piece of armour? ";
5402 s = "You have nothing to rustproof.";
5405 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5407 /* Get the item (in the pack) */
5410 o_ptr = &inventory[item];
5413 /* Get the item (on the floor) */
5416 o_ptr = &o_list[0 - item];
5421 object_desc(o_name, o_ptr, FALSE, 0);
5423 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5425 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5428 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5430 msg_format("%s %s look%s as good as new!",
5431 ((item >= 0) ? "Your" : "The"), o_name,
5432 ((o_ptr->number > 1) ? "" : "s"));
5439 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5441 msg_format("%s %s %s now protected against corrosion.",
5442 ((item >= 0) ? "Your" : "The"), o_name,
5443 ((o_ptr->number > 1) ? "are" : "is"));
5454 * Curse the players armor
5456 bool curse_armor(void)
5461 char o_name[MAX_NLEN];
5464 /* Curse the body armor */
5465 o_ptr = &inventory[INVEN_BODY];
5467 /* Nothing to curse */
5468 if (!o_ptr->k_idx) return (FALSE);
5472 object_desc(o_name, o_ptr, FALSE, 3);
5474 /* Attempt a saving throw for artifacts */
5475 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5479 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5480 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5482 msg_format("A %s tries to %s, but your %s resists the effects!",
5483 "terrible black aura", "surround your armor", o_name);
5488 /* not artifact or failed save... */
5493 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5495 msg_format("A terrible black aura blasts your %s!", o_name);
5498 chg_virtue(V_ENCHANT, -5);
5500 /* Blast the armor */
5502 o_ptr->name2 = EGO_BLASTED;
5503 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5510 for (i = 0; i < TR_FLAG_SIZE; i++)
5511 o_ptr->art_flags[i] = 0;
5514 o_ptr->curse_flags = TRC_CURSED;
5517 o_ptr->ident |= (IDENT_BROKEN);
5519 /* Recalculate bonuses */
5520 p_ptr->update |= (PU_BONUS);
5522 /* Recalculate mana */
5523 p_ptr->update |= (PU_MANA);
5526 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5534 * Curse the players weapon
5536 bool curse_weapon(bool force, int slot)
5542 char o_name[MAX_NLEN];
5545 /* Curse the weapon */
5546 o_ptr = &inventory[slot];
5548 /* Nothing to curse */
5549 if (!o_ptr->k_idx) return (FALSE);
5553 object_desc(o_name, o_ptr, FALSE, 3);
5555 /* Attempt a saving throw */
5556 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5560 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5561 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5563 msg_format("A %s tries to %s, but your %s resists the effects!",
5564 "terrible black aura", "surround your weapon", o_name);
5569 /* not artifact or failed save... */
5574 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5576 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5579 chg_virtue(V_ENCHANT, -5);
5581 /* Shatter the weapon */
5583 o_ptr->name2 = EGO_SHATTERED;
5584 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5585 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5591 for (i = 0; i < TR_FLAG_SIZE; i++)
5592 o_ptr->art_flags[i] = 0;
5596 o_ptr->curse_flags = TRC_CURSED;
5599 o_ptr->ident |= (IDENT_BROKEN);
5601 /* Recalculate bonuses */
5602 p_ptr->update |= (PU_BONUS);
5604 /* Recalculate mana */
5605 p_ptr->update |= (PU_MANA);
5608 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5617 * Enchant some bolts
5619 bool brand_bolts(void)
5623 /* Use the first acceptable bolts */
5624 for (i = 0; i < INVEN_PACK; i++)
5626 object_type *o_ptr = &inventory[i];
5628 /* Skip non-bolts */
5629 if (o_ptr->tval != TV_BOLT) continue;
5631 /* Skip artifacts and ego-items */
5632 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5635 /* Skip cursed/broken items */
5636 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5639 if (randint0(100) < 75) continue;
5643 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5645 msg_print("Your bolts are covered in a fiery aura!");
5650 o_ptr->name2 = EGO_FLAME;
5653 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5660 if (flush_failure) flush();
5664 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5666 msg_print("The fiery enchantment failed.");
5676 * Helper function -- return a "nearby" race for polymorphing
5678 * Note that this function is one of the more "dangerous" ones...
5680 static s16b poly_r_idx(int r_idx)
5682 monster_race *r_ptr = &r_info[r_idx];
5684 int i, r, lev1, lev2;
5686 /* Hack -- Uniques/Questors never polymorph */
5687 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5688 (r_ptr->flags1 & RF1_QUESTOR))
5691 /* Allowable range of "levels" for resulting monster */
5692 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5693 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5695 /* Pick a (possibly new) non-unique race */
5696 for (i = 0; i < 1000; i++)
5698 /* Pick a new race, using a level calculation */
5699 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5701 /* Handle failure */
5707 /* Ignore unique monsters */
5708 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5710 /* Ignore monsters with incompatible levels */
5711 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5713 /* Use that index */
5725 bool polymorph_monster(int y, int x)
5727 cave_type *c_ptr = &cave[y][x];
5728 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5729 bool polymorphed = FALSE;
5731 int old_r_idx = m_ptr->r_idx;
5732 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5733 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5734 monster_type back_m;
5736 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5738 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5740 /* Memorize the monster before polymorphing */
5743 /* Pick a "new" monster race */
5744 new_r_idx = poly_r_idx(old_r_idx);
5746 /* Handle polymorph */
5747 if (new_r_idx != old_r_idx)
5751 /* Get the monsters attitude */
5752 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5753 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5754 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5756 /* "Kill" the "old" monster */
5757 delete_monster_idx(c_ptr->m_idx);
5759 /* Create a new monster (no groups) */
5760 if (place_monster_aux(0, y, x, new_r_idx, mode))
5767 /* Placing the new monster failed */
5768 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5769 m_list[hack_m_idx_ii] = back_m;
5772 if (targeted) target_who = hack_m_idx_ii;
5773 if (health_tracked) health_track(hack_m_idx_ii);
5783 bool dimension_door(void)
5785 int plev = p_ptr->lev;
5788 if (!tgt_pt(&x, &y)) return FALSE;
5790 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5792 if (!cave_empty_bold(y, x) || (cave[y][x].info & CAVE_ICKY) ||
5793 (distance(y, x, py, px) > plev / 2 + 10) ||
5794 (!randint0(plev / 10 + 10)))
5796 if( p_ptr->pclass != CLASS_MIRROR_MASTER ){
5798 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5800 msg_print("You fail to exit the astral plane correctly!");
5806 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5808 msg_print("You fail to exit the astral plane correctly!");
5811 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5812 teleport_player((plev+2)*2);
5815 teleport_player_to(y, x, TRUE);
5821 bool eat_magic(int power)
5823 object_type * o_ptr;
5826 int recharge_strength = 0;
5832 char o_name[MAX_NLEN];
5834 item_tester_hook = item_tester_hook_recharge;
5838 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5839 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5841 q = "Drain which item? ";
5842 s = "You have nothing to drain.";
5845 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5849 o_ptr = &inventory[item];
5853 o_ptr = &o_list[0 - item];
5856 k_ptr = &k_info[o_ptr->k_idx];
5857 lev = get_object_level(o_ptr);
5859 if (o_ptr->tval == TV_ROD)
5861 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5864 if (one_in_(recharge_strength))
5866 /* Activate the failure code. */
5871 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5874 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5876 msg_print("You can't absorb energy from a discharged rod.");
5883 o_ptr->timeout += k_ptr->pval;
5889 /* All staffs, wands. */
5890 recharge_strength = (100 + power - lev) / 15;
5893 if (recharge_strength < 0) recharge_strength = 0;
5896 if (one_in_(recharge_strength))
5898 /* Activate the failure code. */
5903 if (o_ptr->pval > 0)
5905 p_ptr->csp += lev / 2;
5908 /* XXX Hack -- unstack if necessary */
5909 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5914 /* Get local object */
5917 /* Obtain a local object */
5918 object_copy(q_ptr, o_ptr);
5920 /* Modify quantity */
5923 /* Restore the charges */
5926 /* Unstack the used item */
5928 p_ptr->total_weight -= q_ptr->weight;
5929 item = inven_carry(q_ptr);
5933 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5935 msg_print("You unstack your staff.");
5943 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5945 msg_print("There's no energy there to absorb!");
5949 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5953 /* Inflict the penalties for failing a recharge. */
5956 /* Artifacts are never destroyed. */
5957 if (artifact_p(o_ptr))
5959 object_desc(o_name, o_ptr, TRUE, 0);
5961 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5963 msg_format("The recharging backfires - %s is completely drained!", o_name);
5967 /* Artifact rods. */
5968 if (o_ptr->tval == TV_ROD)
5969 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5971 /* Artifact wands and staffs. */
5972 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5977 /* Get the object description */
5978 object_desc(o_name, o_ptr, FALSE, 0);
5980 /*** Determine Seriousness of Failure ***/
5982 /* Mages recharge objects more safely. */
5983 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)
5985 /* 10% chance to blow up one rod, otherwise draining. */
5986 if (o_ptr->tval == TV_ROD)
5988 if (one_in_(10)) fail_type = 2;
5991 /* 75% chance to blow up one wand, otherwise draining. */
5992 else if (o_ptr->tval == TV_WAND)
5994 if (!one_in_(3)) fail_type = 2;
5997 /* 50% chance to blow up one staff, otherwise no effect. */
5998 else if (o_ptr->tval == TV_STAFF)
6000 if (one_in_(2)) fail_type = 2;
6005 /* All other classes get no special favors. */
6008 /* 33% chance to blow up one rod, otherwise draining. */
6009 if (o_ptr->tval == TV_ROD)
6011 if (one_in_(3)) fail_type = 2;
6014 /* 20% chance of the entire stack, else destroy one wand. */
6015 else if (o_ptr->tval == TV_WAND)
6017 if (one_in_(5)) fail_type = 3;
6020 /* Blow up one staff. */
6021 else if (o_ptr->tval == TV_STAFF)
6027 /*** Apply draining and destruction. ***/
6029 /* Drain object or stack of objects. */
6032 if (o_ptr->tval == TV_ROD)
6035 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
6037 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
6040 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6042 else if (o_ptr->tval == TV_WAND)
6045 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
6047 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
6052 /* Staffs aren't drained. */
6055 /* Destroy an object or one in a stack of objects. */
6058 if (o_ptr->number > 1)
6061 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
6063 msg_format("Wild magic consumes one of your %s!", o_name);
6066 /* Reduce rod stack maximum timeout, drain wands. */
6067 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
6068 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
6073 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
6075 msg_format("Wild magic consumes your %s!", o_name);
6078 /* Reduce and describe inventory */
6081 inven_item_increase(item, -1);
6082 inven_item_describe(item);
6083 inven_item_optimize(item);
6086 /* Reduce and describe floor item */
6089 floor_item_increase(0 - item, -1);
6090 floor_item_describe(0 - item);
6091 floor_item_optimize(0 - item);
6095 /* Destroy all members of a stack of objects. */
6098 if (o_ptr->number > 1)
6100 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
6102 msg_format("Wild magic consumes all your %s!", o_name);
6107 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
6109 msg_format("Wild magic consumes your %s!", o_name);
6114 /* Reduce and describe inventory */
6117 inven_item_increase(item, -999);
6118 inven_item_describe(item);
6119 inven_item_optimize(item);
6122 /* Reduce and describe floor item */
6125 floor_item_increase(0 - item, -999);
6126 floor_item_describe(0 - item);
6127 floor_item_optimize(0 - item);
6133 if (p_ptr->csp > p_ptr->msp)
6135 p_ptr->csp = p_ptr->msp;
6138 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6139 p_ptr->window |= (PW_INVEN);
6145 bool summon_kin_player(int level, int y, int x, u32b mode)
6147 bool pet = (bool)(mode & PM_FORCE_PET);
6148 if (!pet) mode |= PM_NO_PET;
6150 switch (p_ptr->mimic_form)
6153 switch (p_ptr->prace)
6157 case RACE_BARBARIAN:
6160 summon_kin_type = 'p';
6170 case RACE_MIND_FLAYER:
6173 summon_kin_type = 'h';
6176 summon_kin_type = 'o';
6178 case RACE_HALF_TROLL:
6179 summon_kin_type = 'T';
6181 case RACE_HALF_OGRE:
6182 summon_kin_type = 'O';
6184 case RACE_HALF_GIANT:
6185 case RACE_HALF_TITAN:
6187 summon_kin_type = 'P';
6190 summon_kin_type = 'y';
6193 summon_kin_type = 'K';
6196 summon_kin_type = 'k';
6199 if (one_in_(13)) summon_kin_type = 'U';
6200 else summon_kin_type = 'u';
6202 case RACE_DRACONIAN:
6203 summon_kin_type = 'd';
6207 summon_kin_type = 'g';
6210 if (one_in_(13)) summon_kin_type = 'L';
6211 else summon_kin_type = 's';
6214 summon_kin_type = 'z';
6217 summon_kin_type = 'V';
6220 summon_kin_type = 'G';
6223 summon_kin_type = 'I';
6226 summon_kin_type = '#';
6229 summon_kin_type = 'A';
6232 summon_kin_type = 'U';
6235 summon_kin_type = 'p';
6240 if (one_in_(13)) summon_kin_type = 'U';
6241 else summon_kin_type = 'u';
6243 case MIMIC_DEMON_LORD:
6244 summon_kin_type = 'U';
6247 summon_kin_type = 'V';
6250 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);