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 some case */
546 if (TELE_LEVEL_IS_INEFF(m_idx))
549 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
551 if (see_m) msg_print("There is no effect.");
557 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
560 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
562 msg_print("A mysterious force prevents you from teleporting!");
567 /* Choose up or down */
568 if (randint0(100) < 50) go_up = TRUE;
571 if ((m_idx <= 0) && p_ptr->wizard)
573 if (get_check("Force to go up? ")) go_up = TRUE;
574 else if (get_check("Force to go down? ")) go_up = FALSE;
578 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
581 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
583 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
585 if (m_idx <= 0) /* To player */
589 dungeon_type = p_ptr->recall_dungeon;
594 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
596 if (autosave_l) do_cmd_save_game(TRUE);
600 dun_level = d_info[dungeon_type].mindepth;
601 prepare_change_floor_mode(CFM_RAND_PLACE | CFM_CLEAR_ALL);
605 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
609 p_ptr->leaving = TRUE;
614 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
617 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
619 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
623 if (m_idx <= 0) /* To player */
625 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
627 if (autosave_l) do_cmd_save_game(TRUE);
629 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
634 p_ptr->inside_quest = 0;
635 p_ptr->leaving = TRUE;
641 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
643 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
647 if (m_idx <= 0) /* To player */
649 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
651 if (autosave_l) do_cmd_save_game(TRUE);
653 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
656 p_ptr->leaving = TRUE;
662 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
664 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
667 if (m_idx <= 0) /* To player */
669 /* Never reach this code on the surface */
670 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
672 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
674 if (autosave_l) do_cmd_save_game(TRUE);
676 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
679 p_ptr->leaving = TRUE;
683 /* Monster level teleportation is simple deleting now */
686 /* Check for quest completion */
687 check_quest_completion(m_ptr);
689 delete_monster_idx(m_idx);
693 sound(SOUND_TPLEVEL);
698 static int choose_dungeon(cptr note)
704 /* Allocate the "dun" array */
705 C_MAKE(dun, max_d_idx, s16b);
708 for(i = 1; i < max_d_idx; i++)
713 if (!d_info[i].maxdepth) continue;
714 if (!max_dlv[i]) continue;
715 if (d_info[i].final_guardian)
717 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
719 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
722 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
724 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
730 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
732 prt(format("Which dungeon do you %s?: ", note), 0, 0);
739 /* Free the "dun" array */
740 C_KILL(dun, max_d_idx, s16b);
745 if (i >= 'a' && i <('a'+num))
747 select_dungeon = dun[i-'a'];
754 /* Free the "dun" array */
755 C_KILL(dun, max_d_idx, s16b);
757 return select_dungeon;
762 * Recall the player to town or dungeon
764 bool recall_player(int turns)
767 * TODO: Recall the player to the last
768 * visited town when in the wilderness
772 if (p_ptr->inside_arena || ironman_downward)
775 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
777 msg_print("Nothing happens.");
783 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
786 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
788 if (get_check("Reset recall depth? "))
791 max_dlv[dungeon_type] = dun_level;
792 if (record_maxdeapth)
794 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
796 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
801 if (!p_ptr->word_recall)
807 select_dungeon = choose_dungeon("¤Ëµ¢´Ô");
809 select_dungeon = choose_dungeon("recall");
811 if (!select_dungeon) return FALSE;
812 p_ptr->recall_dungeon = select_dungeon;
814 p_ptr->word_recall = turns;
816 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
818 msg_print("The air about you becomes charged...");
821 p_ptr->redraw |= (PR_STATUS);
825 p_ptr->word_recall = 0;
827 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
829 msg_print("A tension leaves the air around you...");
832 p_ptr->redraw |= (PR_STATUS);
838 bool word_of_recall(void)
840 return(recall_player(randint0(21) + 15));
844 bool reset_recall(void)
846 int select_dungeon, dummy = 0;
851 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È");
853 select_dungeon = choose_dungeon("reset");
857 if (ironman_downward)
860 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
862 msg_print("Nothing happens.");
868 if (!select_dungeon) return FALSE;
871 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
873 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
878 sprintf(tmp_val, "%d", MAX(dun_level, 1));
880 /* Ask for a level */
881 if (get_string(ppp, tmp_val, 10))
883 /* Extract request */
884 dummy = atoi(tmp_val);
887 if (dummy < 1) dummy = 1;
890 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
891 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
893 max_dlv[select_dungeon] = dummy;
895 if (record_maxdeapth)
897 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
899 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
903 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
905 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
918 * Apply disenchantment to the player's stuff
920 * XXX XXX XXX This function is also called from the "melee" code
922 * Return "TRUE" if the player notices anything
924 bool apply_disenchant(int mode)
928 char o_name[MAX_NLEN];
929 int to_h, to_d, to_a, pval;
931 /* Pick a random slot */
934 case 1: t = INVEN_RARM; break;
935 case 2: t = INVEN_LARM; break;
936 case 3: t = INVEN_BOW; break;
937 case 4: t = INVEN_BODY; break;
938 case 5: t = INVEN_OUTER; break;
939 case 6: t = INVEN_HEAD; break;
940 case 7: t = INVEN_HANDS; break;
941 case 8: t = INVEN_FEET; break;
945 o_ptr = &inventory[t];
947 /* No item, nothing happens */
948 if (!o_ptr->k_idx) return (FALSE);
951 /* Nothing to disenchant */
952 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
954 /* Nothing to notice */
959 /* Describe the object */
960 object_desc(o_name, o_ptr, FALSE, 0);
963 /* Artifacts have 71% chance to resist */
964 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 71))
968 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
970 msg_format("Your %s (%c) resist%s disenchantment!",
971 o_name, index_to_label(t),
972 ((o_ptr->number != 1) ? "" : "s"));
981 /* Memorize old value */
987 /* Disenchant tohit */
988 if (o_ptr->to_h > 0) o_ptr->to_h--;
989 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
991 /* Disenchant todam */
992 if (o_ptr->to_d > 0) o_ptr->to_d--;
993 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
995 /* Disenchant toac */
996 if (o_ptr->to_a > 0) o_ptr->to_a--;
997 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
999 /* Disenchant pval (occasionally) */
1000 /* Unless called from wild_magic() */
1001 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1003 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1004 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1008 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
1009 o_name, index_to_label(t) );
1011 msg_format("Your %s (%c) %s disenchanted!",
1012 o_name, index_to_label(t),
1013 ((o_ptr->number != 1) ? "were" : "was"));
1016 chg_virtue(V_HARMONY, 1);
1017 chg_virtue(V_ENCHANT, -2);
1019 /* Recalculate bonuses */
1020 p_ptr->update |= (PU_BONUS);
1023 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1033 void mutate_player(void)
1035 int max1, cur1, max2, cur2, ii, jj, i;
1037 /* Pick a pair of stats */
1039 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1041 max1 = p_ptr->stat_max[ii];
1042 cur1 = p_ptr->stat_cur[ii];
1043 max2 = p_ptr->stat_max[jj];
1044 cur2 = p_ptr->stat_cur[jj];
1046 p_ptr->stat_max[ii] = max2;
1047 p_ptr->stat_cur[ii] = cur2;
1048 p_ptr->stat_max[jj] = max1;
1049 p_ptr->stat_cur[jj] = cur1;
1053 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1054 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1057 p_ptr->update |= (PU_BONUS);
1064 void apply_nexus(monster_type *m_ptr)
1066 switch (randint1(7))
1068 case 1: case 2: case 3:
1070 teleport_player(200);
1076 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE);
1082 if (randint0(100) < p_ptr->skill_sav)
1085 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1087 msg_print("You resist the effects!");
1093 /* Teleport Level */
1100 if (randint0(100) < p_ptr->skill_sav)
1103 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1105 msg_print("You resist the effects!");
1112 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1114 msg_print("Your body starts to scramble...");
1125 * Charge a lite (torch or latern)
1127 void phlogiston(void)
1130 object_type * o_ptr = &inventory[INVEN_LITE];
1133 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1135 max_flog = FUEL_LAMP;
1139 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1141 max_flog = FUEL_TORCH;
1144 /* No torch to refill */
1148 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1150 msg_print("You are not wielding anything which uses phlogiston.");
1156 if (o_ptr->xtra4 >= max_flog)
1159 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1161 msg_print("No more phlogiston can be put in this item.");
1168 o_ptr->xtra4 += (max_flog / 2);
1172 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1174 msg_print("You add phlogiston to your light item.");
1179 if (o_ptr->xtra4 >= max_flog)
1181 o_ptr->xtra4 = max_flog;
1183 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1185 msg_print("Your light item is full.");
1190 /* Recalculate torch */
1191 p_ptr->update |= (PU_TORCH);
1195 static bool item_tester_hook_weapon_nobow(object_type *o_ptr)
1197 switch (o_ptr->tval)
1207 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
1215 * Brand the current weapon
1217 void brand_weapon(int brand_type)
1224 /* Assume enchant weapon */
1225 item_tester_hook = item_tester_hook_weapon_nobow;
1226 item_tester_no_ryoute = TRUE;
1230 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1231 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1233 q = "Enchant which weapon? ";
1234 s = "You have nothing to enchant.";
1237 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1239 /* Get the item (in the pack) */
1242 o_ptr = &inventory[item];
1245 /* Get the item (on the floor) */
1248 o_ptr = &o_list[0 - item];
1252 /* you can never modify artifacts / ego-items */
1253 /* you can never modify cursed items */
1254 /* TY: You _can_ modify broken items (if you're silly enough) */
1255 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
1256 !o_ptr->art_name && !cursed_p(o_ptr) &&
1257 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1258 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1259 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1263 /* Let's get the name before it is changed... */
1264 char o_name[MAX_NLEN];
1265 object_desc(o_name, o_ptr, FALSE, 0);
1270 if (o_ptr->tval == TV_SWORD)
1273 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1275 act = "becomes very sharp!";
1278 o_ptr->name2 = EGO_SHARPNESS;
1279 o_ptr->pval = m_bonus(5, dun_level) + 1;
1284 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1286 act = "seems very powerful.";
1289 o_ptr->name2 = EGO_EARTHQUAKES;
1290 o_ptr->pval = m_bonus(3, dun_level);
1295 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1297 act = "seems to be looking for humans!";
1300 o_ptr->name2 = EGO_SLAY_HUMAN;
1304 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1306 act = "covered with lightning!";
1309 o_ptr->name2 = EGO_BRAND_ELEC;
1313 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1315 act = "coated with acid!";
1318 o_ptr->name2 = EGO_BRAND_ACID;
1322 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1324 act = "seems to be looking for evil monsters!";
1327 o_ptr->name2 = EGO_SLAY_EVIL;
1331 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1333 act = "seems to be looking for demons!";
1336 o_ptr->name2 = EGO_SLAY_DEMON;
1340 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1342 act = "seems to be looking for undead!";
1345 o_ptr->name2 = EGO_SLAY_UNDEAD;
1349 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1351 act = "seems to be looking for animals!";
1354 o_ptr->name2 = EGO_SLAY_ANIMAL;
1358 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1360 act = "seems to be looking for dragons!";
1363 o_ptr->name2 = EGO_SLAY_DRAGON;
1367 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1369 act = "seems to be looking for troll!s";
1372 o_ptr->name2 = EGO_SLAY_TROLL;
1376 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1378 act = "seems to be looking for orcs!";
1381 o_ptr->name2 = EGO_SLAY_ORC;
1385 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1387 act = "seems to be looking for giants!";
1390 o_ptr->name2 = EGO_SLAY_GIANT;
1394 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1396 act = "seems very unstable now.";
1399 o_ptr->name2 = EGO_TRUMP;
1400 o_ptr->pval = randint1(2);
1404 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1406 act = "thirsts for blood!";
1409 o_ptr->name2 = EGO_VAMPIRIC;
1413 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1415 act = "is coated with poison.";
1418 o_ptr->name2 = EGO_BRAND_POIS;
1422 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1424 act = "is engulfed in raw Logrus!";
1427 o_ptr->name2 = EGO_CHAOTIC;
1431 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1433 act = "is covered in a fiery shield!";
1436 o_ptr->name2 = EGO_BRAND_FIRE;
1440 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1442 act = "glows deep, icy blue!";
1445 o_ptr->name2 = EGO_BRAND_COLD;
1450 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1452 msg_format("Your %s %s", o_name, act);
1456 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1458 o_ptr->discount = 99;
1459 chg_virtue(V_ENCHANT, 2);
1463 if (flush_failure) flush();
1466 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1468 msg_print("The Branding failed.");
1471 chg_virtue(V_ENCHANT, -2);
1478 * Determine if a "feature" is a "vanishable"
1479 * Non-permanent walls, trees, mountains, or doors
1481 #define vanishable_feat(F) \
1482 ((!feat_floor(F) && (((F) < FEAT_PERM_EXTRA) || ((F) > FEAT_PERM_SOLID))) || \
1483 ((F) == FEAT_OPEN) || ((F) == FEAT_BROKEN))
1486 * Vanish all walls in this floor
1488 static bool vanish_dungeon(void)
1492 monster_type *m_ptr;
1496 /* Prevent vasishing of quest levels and town */
1497 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1502 /* Scan all normal grids */
1503 for (y = 1; y < cur_hgt - 1; y++)
1505 for (x = 1; x < cur_wid - 1; x++)
1507 c_ptr = &cave[y][x];
1509 /* Seeing true feature code (ignore mimic) */
1512 /* Lose room and vault */
1513 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1518 m_ptr = &m_list[c_ptr->m_idx];
1520 /* Reset sleep counter */
1523 /* Notice the "waking up" */
1526 /* Acquire the monster name */
1527 monster_desc(m_name, m_ptr, 0);
1529 /* Dump a message */
1531 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1533 msg_format("%^s wakes up.", m_name);
1536 /* Redraw the health bar */
1537 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
1538 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
1542 /* Process all walls, doors and patterns */
1543 if (vanishable_feat(feat) || pattern_tile(y, x))
1546 cave_set_feat(y, x, floor_type[randint0(100)]);
1551 /* Special boundary walls -- Top and bottom */
1552 for (x = 0; x < cur_wid; x++)
1554 c_ptr = &cave[0][x];
1556 /* Lose room and vault */
1557 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1559 /* Set boundary mimic if needed */
1560 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1562 c_ptr = &cave[cur_hgt - 1][x];
1564 /* Lose room and vault */
1565 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1567 /* Set boundary mimic if needed */
1568 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1571 /* Special boundary walls -- Left and right */
1572 for (y = 1; y < (cur_hgt - 1); y++)
1574 c_ptr = &cave[y][0];
1576 /* Lose room and vault */
1577 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1579 /* Set boundary mimic if needed */
1580 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1582 c_ptr = &cave[y][cur_wid - 1];
1584 /* Lose room and vault */
1585 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1587 /* Set boundary mimic if needed */
1588 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1591 /* Mega-Hack -- Forget the view and lite */
1592 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1595 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1597 /* Update the monsters */
1598 p_ptr->update |= (PU_MONSTERS);
1601 p_ptr->redraw |= (PR_MAP);
1604 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1610 void call_the_(void)
1614 bool do_call = TRUE;
1616 for (i = 0; i < 9; i++)
1618 y = py + ddy_ddd[i];
1619 x = px + ddx_ddd[i];
1621 if (!cave_floor_bold(y, x) && !boundary_floor_bold(y, x))
1630 for (i = 1; i < 10; i++)
1632 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1635 for (i = 1; i < 10; i++)
1637 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1640 for (i = 1; i < 10; i++)
1642 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1646 /* Prevent destruction of quest levels and town */
1647 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1650 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1652 msg_print("The ground trembles.");
1659 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1660 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1661 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1663 msg_format("You %s the %s too close to a wall!",
1664 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1665 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1666 msg_print("There is a loud explosion!");
1672 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1674 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1679 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1681 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1683 msg_print("The dungeon collapses...");
1688 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1690 msg_print("The dungeon trembles.");
1695 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1697 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1704 * Fetch an item (teleport it right underneath the caster)
1706 void fetch(int dir, int wgt, bool require_los)
1711 char o_name[MAX_NLEN];
1713 /* Check to see if an object is already there */
1714 if (cave[py][px].o_idx)
1717 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1719 msg_print("You can't fetch when you're already standing on something.");
1726 if (dir == 5 && target_okay())
1731 if (distance(py, px, ty, tx) > MAX_RANGE)
1734 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1736 msg_print("You can't fetch something that far away!");
1742 c_ptr = &cave[ty][tx];
1744 /* We need an item to fetch */
1748 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1750 msg_print("There is no object at this place.");
1756 /* No fetching from vault */
1757 if (c_ptr->info & CAVE_ICKY)
1760 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1762 msg_print("The item slips from your control.");
1768 /* We need to see the item */
1769 if (require_los && !player_has_los_bold(ty, tx))
1772 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1774 msg_print("You have no direct line of sight to that location.");
1782 /* Use a direction */
1783 ty = py; /* Where to drop the item */
1790 c_ptr = &cave[ty][tx];
1792 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1793 !cave_floor_bold(ty, tx)) return;
1795 while (!c_ptr->o_idx);
1798 o_ptr = &o_list[c_ptr->o_idx];
1800 if (o_ptr->weight > wgt)
1802 /* Too heavy to 'fetch' */
1804 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1806 msg_print("The object is too heavy.");
1813 c_ptr->o_idx = o_ptr->next_o_idx;
1814 cave[py][px].o_idx = i; /* 'move' it */
1815 o_ptr->next_o_idx = 0;
1816 o_ptr->iy = (byte)py;
1817 o_ptr->ix = (byte)px;
1819 object_desc(o_name, o_ptr, TRUE, 0);
1821 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1823 msg_format("%^s flies through the air to your feet.", o_name);
1828 p_ptr->redraw |= PR_MAP;
1832 void alter_reality(void)
1834 /* Ironman option */
1835 if (p_ptr->inside_arena || ironman_downward)
1838 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1840 msg_print("Nothing happens.");
1845 if (!p_ptr->alter_reality)
1847 int turns = randint0(21) + 15;
1849 p_ptr->alter_reality = turns;
1851 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1853 msg_print("The view around you begins to change...");
1856 p_ptr->redraw |= (PR_STATUS);
1860 p_ptr->alter_reality = 0;
1862 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1864 msg_print("The view around you got back...");
1867 p_ptr->redraw |= (PR_STATUS);
1874 * Leave a "glyph of warding" which prevents monster movement
1876 bool warding_glyph(void)
1879 if (!cave_clean_bold(py, px))
1882 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1884 msg_print("The object resists the spell.");
1890 /* Create a glyph */
1891 cave[py][px].info |= CAVE_OBJECT;
1892 cave[py][px].mimic = FEAT_GLYPH;
1903 bool warding_mirror(void)
1906 if (!cave_clean_bold(py, px))
1909 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1911 msg_print("The object resists the spell.");
1917 /* Create a mirror */
1918 cave[py][px].info |= CAVE_OBJECT;
1919 cave[py][px].mimic = FEAT_MIRROR;
1921 /* Turn on the light */
1922 cave[py][px].info |= CAVE_GLOW;
1935 * Leave an "explosive rune" which prevents monster movement
1937 bool explosive_rune(void)
1940 if (!cave_clean_bold(py, px))
1943 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1945 msg_print("The object resists the spell.");
1951 /* Create a glyph */
1952 cave[py][px].info |= CAVE_OBJECT;
1953 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1966 * Identify everything being carried.
1967 * Done by a potion of "self knowledge".
1969 void identify_pack(void)
1973 /* Simply identify and know every item */
1974 for (i = 0; i < INVEN_TOTAL; i++)
1976 object_type *o_ptr = &inventory[i];
1978 /* Skip non-objects */
1979 if (!o_ptr->k_idx) continue;
1982 identify_item(o_ptr);
1988 * Used by the "enchant" function (chance of failure)
1989 * (modified for Zangband, we need better stuff there...) -- TY
1991 static int enchant_table[16] =
1993 0, 10, 50, 100, 200,
1994 300, 400, 500, 650, 800,
1995 950, 987, 993, 995, 998,
2001 * Removes curses from items in inventory
2003 * Note that Items which are "Perma-Cursed" (The One Ring,
2004 * The Crown of Morgoth) can NEVER be uncursed.
2006 * Note that if "all" is FALSE, then Items which are
2007 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2008 * will not be uncursed.
2010 static int remove_curse_aux(int all)
2014 /* Attempt to uncurse items being worn */
2015 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2017 object_type *o_ptr = &inventory[i];
2019 /* Skip non-objects */
2020 if (!o_ptr->k_idx) continue;
2022 /* Uncursed already */
2023 if (!cursed_p(o_ptr)) continue;
2025 /* Heavily Cursed Items need a special spell */
2026 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2028 /* Perma-Cursed Items can NEVER be uncursed */
2029 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2032 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2037 o_ptr->curse_flags = 0L;
2039 /* Hack -- Assume felt */
2040 o_ptr->ident |= (IDENT_SENSE);
2043 o_ptr->feeling = FEEL_NONE;
2045 /* Recalculate the bonuses */
2046 p_ptr->update |= (PU_BONUS);
2049 p_ptr->window |= (PW_EQUIP);
2051 /* Count the uncursings */
2055 /* Return "something uncursed" */
2061 * Remove most curses
2063 bool remove_curse(void)
2065 return (remove_curse_aux(FALSE));
2071 bool remove_all_curse(void)
2073 return (remove_curse_aux(TRUE));
2078 * Turns an object into gold, gain some of its value in a shop
2087 char o_name[MAX_NLEN];
2088 char out_val[MAX_NLEN+40];
2092 /* Hack -- force destruction */
2093 if (command_arg > 0) force = TRUE;
2097 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2098 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2100 q = "Turn which item to gold? ";
2101 s = "You have nothing to turn to gold.";
2104 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2106 /* Get the item (in the pack) */
2109 o_ptr = &inventory[item];
2112 /* Get the item (on the floor) */
2115 o_ptr = &o_list[0 - item];
2119 /* See how many items */
2120 if (o_ptr->number > 1)
2122 /* Get a quantity */
2123 amt = get_quantity(NULL, o_ptr->number);
2125 /* Allow user abort */
2126 if (amt <= 0) return FALSE;
2130 /* Describe the object */
2131 old_number = o_ptr->number;
2132 o_ptr->number = amt;
2133 object_desc(o_name, o_ptr, TRUE, 3);
2134 o_ptr->number = old_number;
2136 /* Verify unless quantity given */
2139 if (confirm_destroy || (object_value(o_ptr) > 0))
2141 /* Make a verification */
2143 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2145 sprintf(out_val, "Really turn %s to gold? ", o_name);
2148 if (!get_check(out_val)) return FALSE;
2152 /* Artifacts cannot be destroyed */
2153 if (!can_player_destroy_object(o_ptr))
2157 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2159 msg_format("You fail to turn %s to gold!", o_name);
2166 price = object_value_real(o_ptr);
2172 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2174 msg_format("You turn %s to fool's gold.", o_name);
2182 if (amt > 1) price *= amt;
2184 if (price > 30000) price = 30000;
2186 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2188 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2194 p_ptr->redraw |= (PR_GOLD);
2197 p_ptr->window |= (PW_PLAYER);
2201 /* Eliminate the item (from the pack) */
2204 inven_item_increase(item, -amt);
2205 inven_item_describe(item);
2206 inven_item_optimize(item);
2209 /* Eliminate the item (from the floor) */
2212 floor_item_increase(0 - item, -amt);
2213 floor_item_describe(0 - item);
2214 floor_item_optimize(0 - item);
2223 * Hook to specify "weapon"
2225 bool item_tester_hook_weapon(object_type *o_ptr)
2227 switch (o_ptr->tval)
2241 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2248 static bool item_tester_hook_weapon2(object_type *o_ptr)
2250 switch (o_ptr->tval)
2270 * Hook to specify "armour"
2272 bool item_tester_hook_armour(object_type *o_ptr)
2274 switch (o_ptr->tval)
2295 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2297 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2299 switch (o_ptr->tval)
2328 * Check if an object is nameless weapon or armour
2330 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2332 switch (o_ptr->tval)
2351 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2353 if (object_known_p(o_ptr)) return FALSE;
2363 * Break the curse of an item
2365 static void break_curse(object_type *o_ptr)
2367 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2370 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2372 msg_print("The curse is broken!");
2375 o_ptr->curse_flags = 0L;
2377 o_ptr->ident |= (IDENT_SENSE);
2379 o_ptr->feeling = FEEL_NONE;
2385 * Enchants a plus onto an item. -RAK-
2387 * Revamped! Now takes item pointer, number of times to try enchanting,
2388 * and a flag of what to try enchanting. Artifacts resist enchantment
2389 * some of the time, and successful enchantment to at least +0 might
2390 * break a curse on the item. -CFT-
2392 * Note that an item can technically be enchanted all the way to +15 if
2393 * you wait a very, very, long time. Going from +9 to +10 only works
2394 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2396 * Note that this function can now be used on "piles" of items, and
2397 * the larger the pile, the lower the chance of success.
2399 bool enchant(object_type *o_ptr, int n, int eflag)
2401 int i, chance, prob;
2403 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2404 bool force = (eflag & ENCH_FORCE);
2407 /* Large piles resist enchantment */
2408 prob = o_ptr->number * 100;
2410 /* Missiles are easy to enchant */
2411 if ((o_ptr->tval == TV_BOLT) ||
2412 (o_ptr->tval == TV_ARROW) ||
2413 (o_ptr->tval == TV_SHOT))
2419 for (i = 0; i < n; i++)
2421 /* Hack -- Roll for pile resistance */
2422 if (!force && randint0(prob) >= 100) continue;
2424 /* Enchant to hit */
2425 if (eflag & ENCH_TOHIT)
2427 if (o_ptr->to_h < 0) chance = 0;
2428 else if (o_ptr->to_h > 15) chance = 1000;
2429 else chance = enchant_table[o_ptr->to_h];
2431 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2436 /* only when you get it above -1 -CFT */
2437 if (o_ptr->to_h >= 0)
2442 /* Enchant to damage */
2443 if (eflag & ENCH_TODAM)
2445 if (o_ptr->to_d < 0) chance = 0;
2446 else if (o_ptr->to_d > 15) chance = 1000;
2447 else chance = enchant_table[o_ptr->to_d];
2449 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2454 /* only when you get it above -1 -CFT */
2455 if (o_ptr->to_d >= 0)
2460 /* Enchant to armor class */
2461 if (eflag & ENCH_TOAC)
2463 if (o_ptr->to_a < 0) chance = 0;
2464 else if (o_ptr->to_a > 15) chance = 1000;
2465 else chance = enchant_table[o_ptr->to_a];
2467 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2472 /* only when you get it above -1 -CFT */
2473 if (o_ptr->to_a >= 0)
2480 if (!res) return (FALSE);
2482 /* Recalculate bonuses */
2483 p_ptr->update |= (PU_BONUS);
2485 /* Combine / Reorder the pack (later) */
2486 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2489 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2500 * Enchant an item (in the inventory or on the floor)
2501 * Note that "num_ac" requires armour, else weapon
2502 * Returns TRUE if attempted, FALSE if cancelled
2504 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2509 char o_name[MAX_NLEN];
2513 /* Assume enchant weapon */
2514 item_tester_hook = item_tester_hook_weapon;
2515 item_tester_no_ryoute = TRUE;
2517 /* Enchant armor if requested */
2518 if (num_ac) item_tester_hook = item_tester_hook_armour;
2522 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2523 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2525 q = "Enchant which item? ";
2526 s = "You have nothing to enchant.";
2529 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2531 /* Get the item (in the pack) */
2534 o_ptr = &inventory[item];
2537 /* Get the item (on the floor) */
2540 o_ptr = &o_list[0 - item];
2545 object_desc(o_name, o_ptr, FALSE, 0);
2549 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2552 msg_format("%s %s glow%s brightly!",
2553 ((item >= 0) ? "Your" : "The"), o_name,
2554 ((o_ptr->number > 1) ? "" : "s"));
2559 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2560 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2561 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2567 if (flush_failure) flush();
2571 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2573 msg_print("The enchantment failed.");
2576 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2579 chg_virtue(V_ENCHANT, 1);
2583 /* Something happened */
2588 bool artifact_scroll(void)
2593 char o_name[MAX_NLEN];
2597 item_tester_no_ryoute = TRUE;
2598 /* Enchant weapon/armour */
2599 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2603 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2604 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2606 q = "Enchant which item? ";
2607 s = "You have nothing to enchant.";
2610 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2612 /* Get the item (in the pack) */
2615 o_ptr = &inventory[item];
2618 /* Get the item (on the floor) */
2621 o_ptr = &o_list[0 - item];
2626 object_desc(o_name, o_ptr, FALSE, 0);
2630 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2632 msg_format("%s %s radiate%s a blinding light!",
2633 ((item >= 0) ? "Your" : "The"), o_name,
2634 ((o_ptr->number > 1) ? "" : "s"));
2637 if (o_ptr->name1 || o_ptr->art_name)
2640 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2642 msg_format("The %s %s already %s!",
2643 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2644 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2650 else if (o_ptr->name2)
2653 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2655 msg_format("The %s %s already %s!",
2656 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2657 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2663 else if (o_ptr->xtra3)
2666 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2668 msg_format("The %s %s already %s!",
2669 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2670 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2676 if (o_ptr->number > 1)
2679 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2680 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2682 msg_print("Not enough enough energy to enchant more than one object!");
2683 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2688 inven_item_increase(item, 1-(o_ptr->number));
2692 floor_item_increase(0-item, 1-(o_ptr->number));
2695 okay = create_artifact(o_ptr, TRUE);
2702 if (flush_failure) flush();
2706 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2708 msg_print("The enchantment failed.");
2711 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2714 chg_virtue(V_ENCHANT, 1);
2718 /* Something happened */
2724 * Identify an object
2726 bool identify_item(object_type *o_ptr)
2728 bool old_known = FALSE;
2729 char o_name[MAX_NLEN];
2732 object_desc(o_name, o_ptr, TRUE, 3);
2734 if (o_ptr->ident & IDENT_KNOWN)
2737 if (!(o_ptr->ident & (IDENT_MENTAL)))
2739 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2740 chg_virtue(V_KNOWLEDGE, 1);
2743 /* Identify it fully */
2744 object_aware(o_ptr);
2745 object_known(o_ptr);
2747 /* Recalculate bonuses */
2748 p_ptr->update |= (PU_BONUS);
2750 /* Combine / Reorder the pack (later) */
2751 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2754 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2756 strcpy(record_o_name, o_name);
2760 object_desc(o_name, o_ptr, TRUE, 0);
2762 if(record_fix_art && !old_known && artifact_p(o_ptr))
2763 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2764 if(record_rand_art && !old_known && o_ptr->art_name)
2765 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2771 static bool item_tester_hook_identify(object_type *o_ptr)
2773 return (bool)!object_known_p(o_ptr);
2776 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2778 if (object_known_p(o_ptr))
2780 return item_tester_hook_weapon_armour(o_ptr);
2784 * Identify an object in the inventory (or on the floor)
2785 * This routine does *not* automatically combine objects.
2786 * Returns TRUE if something was identified, else FALSE.
2788 bool ident_spell(bool only_equip)
2792 char o_name[MAX_NLEN];
2797 item_tester_no_ryoute = TRUE;
2800 item_tester_hook = item_tester_hook_identify_weapon_armour;
2802 item_tester_hook = item_tester_hook_identify;
2804 if (!can_get_item())
2808 item_tester_hook = item_tester_hook_weapon_armour;
2812 item_tester_hook = NULL;
2818 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2819 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2821 q = "Identify which item? ";
2822 s = "You have nothing to identify.";
2825 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2827 /* Get the item (in the pack) */
2830 o_ptr = &inventory[item];
2833 /* Get the item (on the floor) */
2836 o_ptr = &o_list[0 - item];
2840 old_known = identify_item(o_ptr);
2843 object_desc(o_name, o_ptr, TRUE, 3);
2846 if (item >= INVEN_RARM)
2849 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2851 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2857 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2859 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2865 msg_format("¾²¾å: %s¡£", o_name);
2867 msg_format("On the ground: %s.", o_name);
2871 /* Auto-inscription/destroy */
2872 idx = is_autopick(o_ptr);
2873 auto_inscribe_item(item, idx);
2874 if (destroy_identify && !old_known)
2875 auto_destroy_item(item, idx);
2877 /* Something happened */
2883 * Mundanify an object in the inventory (or on the floor)
2884 * This routine does *not* automatically combine objects.
2885 * Returns TRUE if something was mundanified, else FALSE.
2887 bool mundane_spell(bool only_equip)
2893 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
2894 item_tester_no_ryoute = TRUE;
2898 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2899 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2901 q = "Use which item? ";
2902 s = "You have nothing you can use.";
2905 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2907 /* Get the item (in the pack) */
2910 o_ptr = &inventory[item];
2913 /* Get the item (on the floor) */
2916 o_ptr = &o_list[0 - item];
2921 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2923 msg_print("There is a bright flash of light!");
2926 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2927 byte ix = o_ptr->ix; /* X-position on map, or zero */
2928 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2929 byte marked = o_ptr->marked; /* Object is marked */
2930 s16b weight = o_ptr->number * o_ptr->weight;
2931 u16b inscription = o_ptr->inscription;
2934 object_prep(o_ptr, o_ptr->k_idx);
2938 o_ptr->next_o_idx = next_o_idx;
2939 o_ptr->marked = marked;
2940 o_ptr->inscription = inscription;
2941 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2945 /* Something happened */
2951 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2953 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2956 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2958 if (!item_tester_hook_identify_fully(o_ptr))
2960 return item_tester_hook_weapon_armour(o_ptr);
2964 * Fully "identify" an object in the inventory -BEN-
2965 * This routine returns TRUE if an item was identified.
2967 bool identify_fully(bool only_equip)
2971 char o_name[MAX_NLEN];
2976 item_tester_no_ryoute = TRUE;
2978 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2980 item_tester_hook = item_tester_hook_identify_fully;
2982 if (!can_get_item())
2985 item_tester_hook = item_tester_hook_weapon_armour;
2987 item_tester_hook = NULL;
2992 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2993 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2995 q = "Identify which item? ";
2996 s = "You have nothing to identify.";
2999 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
3001 /* Get the item (in the pack) */
3004 o_ptr = &inventory[item];
3007 /* Get the item (on the floor) */
3010 o_ptr = &o_list[0 - item];
3014 old_known = identify_item(o_ptr);
3016 /* Mark the item as fully known */
3017 o_ptr->ident |= (IDENT_MENTAL);
3023 object_desc(o_name, o_ptr, TRUE, 3);
3026 if (item >= INVEN_RARM)
3029 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
3031 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
3039 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
3041 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3047 msg_format("¾²¾å: %s¡£", o_name);
3049 msg_format("On the ground: %s.", o_name);
3053 /* Describe it fully */
3054 (void)screen_object(o_ptr, TRUE);
3056 /* Auto-inscription/destroy */
3057 idx = is_autopick(o_ptr);
3058 auto_inscribe_item(item, idx);
3059 if (destroy_identify && !old_known)
3060 auto_destroy_item(item, idx);
3070 * Hook for "get_item()". Determine if something is rechargable.
3072 bool item_tester_hook_recharge(object_type *o_ptr)
3074 /* Recharge staffs */
3075 if (o_ptr->tval == TV_STAFF) return (TRUE);
3077 /* Recharge wands */
3078 if (o_ptr->tval == TV_WAND) return (TRUE);
3080 /* Hack -- Recharge rods */
3081 if (o_ptr->tval == TV_ROD) return (TRUE);
3089 * Recharge a wand/staff/rod from the pack or on the floor.
3090 * This function has been rewritten in Oangband and ZAngband.
3092 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3093 * Chaos -- Arcane Binding --> recharge(90)
3095 * Scroll of recharging --> recharge(130)
3096 * Artifact activation/Thingol --> recharge(130)
3098 * It is harder to recharge high level, and highly charged wands,
3099 * staffs, and rods. The more wands in a stack, the more easily and
3100 * strongly they recharge. Staffs, however, each get fewer charges if
3103 * XXX XXX XXX Beware of "sliding index errors".
3105 bool recharge(int power)
3108 int recharge_strength, recharge_amount;
3117 char o_name[MAX_NLEN];
3119 /* Only accept legal items */
3120 item_tester_hook = item_tester_hook_recharge;
3124 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3125 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3127 q = "Recharge which item? ";
3128 s = "You have nothing to recharge.";
3131 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3133 /* Get the item (in the pack) */
3136 o_ptr = &inventory[item];
3139 /* Get the item (on the floor) */
3142 o_ptr = &o_list[0 - item];
3145 /* Get the object kind. */
3146 k_ptr = &k_info[o_ptr->k_idx];
3148 /* Extract the object "level" */
3149 lev = get_object_level(o_ptr);
3152 /* Recharge a rod */
3153 if (o_ptr->tval == TV_ROD)
3155 /* Extract a recharge strength by comparing object level to power. */
3156 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3160 if (one_in_(recharge_strength))
3162 /* Activate the failure code. */
3169 /* Recharge amount */
3170 recharge_amount = (power * damroll(3, 2));
3172 /* Recharge by that amount */
3173 if (o_ptr->timeout > recharge_amount)
3174 o_ptr->timeout -= recharge_amount;
3181 /* Recharge wand/staff */
3184 /* Extract a recharge strength by comparing object level to power.
3185 * Divide up a stack of wands' charges to calculate charge penalty.
3187 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3188 recharge_strength = (100 + power - lev -
3189 (8 * o_ptr->pval / o_ptr->number)) / 15;
3191 /* All staffs, unstacked wands. */
3192 else recharge_strength = (100 + power - lev -
3193 (8 * o_ptr->pval)) / 15;
3196 if (recharge_strength < 0) recharge_strength = 0;
3199 if (one_in_(recharge_strength))
3201 /* Activate the failure code. */
3205 /* If the spell didn't backfire, recharge the wand or staff. */
3208 /* Recharge based on the standard number of charges. */
3209 recharge_amount = randint1(1 + k_ptr->pval / 2);
3211 /* Multiple wands in a stack increase recharging somewhat. */
3212 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3215 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3216 if (recharge_amount < 1) recharge_amount = 1;
3217 if (recharge_amount > 12) recharge_amount = 12;
3220 /* But each staff in a stack gets fewer additional charges,
3221 * although always at least one.
3223 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3225 recharge_amount /= o_ptr->number;
3226 if (recharge_amount < 1) recharge_amount = 1;
3229 /* Recharge the wand or staff. */
3230 o_ptr->pval += recharge_amount;
3233 /* Hack -- we no longer "know" the item */
3234 o_ptr->ident &= ~(IDENT_KNOWN);
3236 /* Hack -- we no longer think the item is empty */
3237 o_ptr->ident &= ~(IDENT_EMPTY);
3242 /* Inflict the penalties for failing a recharge. */
3245 /* Artifacts are never destroyed. */
3246 if (artifact_p(o_ptr))
3248 object_desc(o_name, o_ptr, TRUE, 0);
3250 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3252 msg_format("The recharging backfires - %s is completely drained!", o_name);
3256 /* Artifact rods. */
3257 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3258 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3260 /* Artifact wands and staffs. */
3261 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3266 /* Get the object description */
3267 object_desc(o_name, o_ptr, FALSE, 0);
3269 /*** Determine Seriousness of Failure ***/
3271 /* Mages recharge objects more safely. */
3272 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)
3274 /* 10% chance to blow up one rod, otherwise draining. */
3275 if (o_ptr->tval == TV_ROD)
3277 if (one_in_(10)) fail_type = 2;
3280 /* 75% chance to blow up one wand, otherwise draining. */
3281 else if (o_ptr->tval == TV_WAND)
3283 if (!one_in_(3)) fail_type = 2;
3286 /* 50% chance to blow up one staff, otherwise no effect. */
3287 else if (o_ptr->tval == TV_STAFF)
3289 if (one_in_(2)) fail_type = 2;
3294 /* All other classes get no special favors. */
3297 /* 33% chance to blow up one rod, otherwise draining. */
3298 if (o_ptr->tval == TV_ROD)
3300 if (one_in_(3)) fail_type = 2;
3303 /* 20% chance of the entire stack, else destroy one wand. */
3304 else if (o_ptr->tval == TV_WAND)
3306 if (one_in_(5)) fail_type = 3;
3309 /* Blow up one staff. */
3310 else if (o_ptr->tval == TV_STAFF)
3316 /*** Apply draining and destruction. ***/
3318 /* Drain object or stack of objects. */
3321 if (o_ptr->tval == TV_ROD)
3324 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3326 msg_print("The recharge backfires, draining the rod further!");
3329 if (o_ptr->timeout < 10000)
3330 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3332 else if (o_ptr->tval == TV_WAND)
3335 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3337 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3342 /* Staffs aren't drained. */
3345 /* Destroy an object or one in a stack of objects. */
3348 if (o_ptr->number > 1)
3350 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3352 msg_format("Wild magic consumes one of your %s!", o_name);
3357 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3359 msg_format("Wild magic consumes your %s!", o_name);
3363 /* Reduce rod stack maximum timeout, drain wands. */
3364 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3365 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3367 /* Reduce and describe inventory */
3370 inven_item_increase(item, -1);
3371 inven_item_describe(item);
3372 inven_item_optimize(item);
3375 /* Reduce and describe floor item */
3378 floor_item_increase(0 - item, -1);
3379 floor_item_describe(0 - item);
3380 floor_item_optimize(0 - item);
3384 /* Destroy all members of a stack of objects. */
3387 if (o_ptr->number > 1)
3389 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3391 msg_format("Wild magic consumes all your %s!", o_name);
3396 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3398 msg_format("Wild magic consumes your %s!", o_name);
3403 /* Reduce and describe inventory */
3406 inven_item_increase(item, -999);
3407 inven_item_describe(item);
3408 inven_item_optimize(item);
3411 /* Reduce and describe floor item */
3414 floor_item_increase(0 - item, -999);
3415 floor_item_describe(0 - item);
3416 floor_item_optimize(0 - item);
3422 /* Combine / Reorder the pack (later) */
3423 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3426 p_ptr->window |= (PW_INVEN);
3428 /* Something was done */
3436 bool bless_weapon(void)
3440 u32b flgs[TR_FLAG_SIZE];
3441 char o_name[MAX_NLEN];
3444 item_tester_no_ryoute = TRUE;
3445 /* Assume enchant weapon */
3446 item_tester_hook = item_tester_hook_weapon2;
3450 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3451 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3453 q = "Bless which weapon? ";
3454 s = "You have weapon to bless.";
3457 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3460 /* Get the item (in the pack) */
3463 o_ptr = &inventory[item];
3466 /* Get the item (on the floor) */
3469 o_ptr = &o_list[0 - item];
3474 object_desc(o_name, o_ptr, FALSE, 0);
3476 /* Extract the flags */
3477 object_flags(o_ptr, flgs);
3479 if (cursed_p(o_ptr))
3481 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3482 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3485 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3488 msg_format("The black aura on %s %s disrupts the blessing!",
3489 ((item >= 0) ? "your" : "the"), o_name);
3496 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3499 msg_format("A malignant aura leaves %s %s.",
3500 ((item >= 0) ? "your" : "the"), o_name);
3505 o_ptr->curse_flags = 0L;
3507 /* Hack -- Assume felt */
3508 o_ptr->ident |= (IDENT_SENSE);
3511 o_ptr->feeling = FEEL_NONE;
3513 /* Recalculate the bonuses */
3514 p_ptr->update |= (PU_BONUS);
3517 p_ptr->window |= (PW_EQUIP);
3521 * Next, we try to bless it. Artifacts have a 1/3 chance of
3522 * being blessed, otherwise, the operation simply disenchants
3523 * them, godly power negating the magic. Ok, the explanation
3524 * is silly, but otherwise priests would always bless every
3525 * artifact weapon they find. Ego weapons and normal weapons
3526 * can be blessed automatically.
3528 if (have_flag(flgs, TR_BLESSED))
3531 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3534 msg_format("%s %s %s blessed already.",
3535 ((item >= 0) ? "Your" : "The"), o_name,
3536 ((o_ptr->number > 1) ? "were" : "was"));
3542 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3546 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3549 msg_format("%s %s shine%s!",
3550 ((item >= 0) ? "Your" : "The"), o_name,
3551 ((o_ptr->number > 1) ? "" : "s"));
3554 add_flag(o_ptr->art_flags, TR_BLESSED);
3555 o_ptr->discount = 99;
3559 bool dis_happened = FALSE;
3562 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3564 msg_print("The weapon resists your blessing!");
3568 /* Disenchant tohit */
3569 if (o_ptr->to_h > 0)
3572 dis_happened = TRUE;
3575 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3577 /* Disenchant todam */
3578 if (o_ptr->to_d > 0)
3581 dis_happened = TRUE;
3584 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3586 /* Disenchant toac */
3587 if (o_ptr->to_a > 0)
3590 dis_happened = TRUE;
3593 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3598 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3600 msg_print("There is a static feeling in the air...");
3604 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3607 msg_format("%s %s %s disenchanted!",
3608 ((item >= 0) ? "Your" : "The"), o_name,
3609 ((o_ptr->number > 1) ? "were" : "was"));
3615 /* Recalculate bonuses */
3616 p_ptr->update |= (PU_BONUS);
3619 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3630 bool pulish_shield(void)
3634 u32b flgs[TR_FLAG_SIZE];
3635 char o_name[MAX_NLEN];
3638 item_tester_no_ryoute = TRUE;
3639 /* Assume enchant weapon */
3640 item_tester_tval = TV_SHIELD;
3644 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3645 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3647 q = "Pulish which weapon? ";
3648 s = "You have weapon to pulish.";
3651 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3654 /* Get the item (in the pack) */
3657 o_ptr = &inventory[item];
3660 /* Get the item (on the floor) */
3663 o_ptr = &o_list[0 - item];
3668 object_desc(o_name, o_ptr, FALSE, 0);
3670 /* Extract the flags */
3671 object_flags(o_ptr, flgs);
3673 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3674 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3677 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3679 msg_format("%s %s shine%s!",
3680 ((item >= 0) ? "Your" : "The"), o_name,
3681 ((o_ptr->number > 1) ? "" : "s"));
3683 o_ptr->name2 = EGO_REFLECTION;
3684 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3686 o_ptr->discount = 99;
3687 chg_virtue(V_ENCHANT, 2);
3693 if (flush_failure) flush();
3696 msg_print("¼ºÇÔ¤·¤¿¡£");
3698 msg_print("Failed.");
3701 chg_virtue(V_ENCHANT, -2);
3710 * Potions "smash open" and cause an area effect when
3711 * (1) they are shattered while in the player's inventory,
3712 * due to cold (etc) attacks;
3713 * (2) they are thrown at a monster, or obstacle;
3714 * (3) they are shattered by a "cold ball" or other such spell
3715 * while lying on the floor.
3718 * who --- who caused the potion to shatter (0=player)
3719 * potions that smash on the floor are assumed to
3720 * be caused by no-one (who = 1), as are those that
3721 * shatter inside the player inventory.
3722 * (Not anymore -- I changed this; TY)
3723 * y, x --- coordinates of the potion (or player if
3724 * the potion was in her inventory);
3725 * o_ptr --- pointer to the potion object.
3727 bool potion_smash_effect(int who, int y, int x, int k_idx)
3734 object_kind *k_ptr = &k_info[k_idx];
3736 switch (k_ptr->sval)
3738 case SV_POTION_SALT_WATER:
3739 case SV_POTION_SLIME_MOLD:
3740 case SV_POTION_LOSE_MEMORIES:
3741 case SV_POTION_DEC_STR:
3742 case SV_POTION_DEC_INT:
3743 case SV_POTION_DEC_WIS:
3744 case SV_POTION_DEC_DEX:
3745 case SV_POTION_DEC_CON:
3746 case SV_POTION_DEC_CHR:
3747 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3748 case SV_POTION_APPLE_JUICE:
3751 case SV_POTION_INFRAVISION:
3752 case SV_POTION_DETECT_INVIS:
3753 case SV_POTION_SLOW_POISON:
3754 case SV_POTION_CURE_POISON:
3755 case SV_POTION_BOLDNESS:
3756 case SV_POTION_RESIST_HEAT:
3757 case SV_POTION_RESIST_COLD:
3758 case SV_POTION_HEROISM:
3759 case SV_POTION_BESERK_STRENGTH:
3760 case SV_POTION_RES_STR:
3761 case SV_POTION_RES_INT:
3762 case SV_POTION_RES_WIS:
3763 case SV_POTION_RES_DEX:
3764 case SV_POTION_RES_CON:
3765 case SV_POTION_RES_CHR:
3766 case SV_POTION_INC_STR:
3767 case SV_POTION_INC_INT:
3768 case SV_POTION_INC_WIS:
3769 case SV_POTION_INC_DEX:
3770 case SV_POTION_INC_CON:
3771 case SV_POTION_INC_CHR:
3772 case SV_POTION_AUGMENTATION:
3773 case SV_POTION_ENLIGHTENMENT:
3774 case SV_POTION_STAR_ENLIGHTENMENT:
3775 case SV_POTION_SELF_KNOWLEDGE:
3776 case SV_POTION_EXPERIENCE:
3777 case SV_POTION_RESISTANCE:
3778 case SV_POTION_INVULNERABILITY:
3779 case SV_POTION_NEW_LIFE:
3780 /* All of the above potions have no effect when shattered */
3782 case SV_POTION_SLOWNESS:
3787 case SV_POTION_POISON:
3792 case SV_POTION_BLINDNESS:
3796 case SV_POTION_CONFUSION: /* Booze */
3800 case SV_POTION_SLEEP:
3804 case SV_POTION_RUINATION:
3805 case SV_POTION_DETONATIONS:
3807 dam = damroll(25, 25);
3810 case SV_POTION_DEATH:
3811 dt = GF_DEATH_RAY; /* !! */
3812 dam = k_ptr->level * 10;
3816 case SV_POTION_SPEED:
3819 case SV_POTION_CURE_LIGHT:
3821 dam = damroll(2, 3);
3823 case SV_POTION_CURE_SERIOUS:
3825 dam = damroll(4, 3);
3827 case SV_POTION_CURE_CRITICAL:
3828 case SV_POTION_CURING:
3830 dam = damroll(6, 3);
3832 case SV_POTION_HEALING:
3834 dam = damroll(10, 10);
3836 case SV_POTION_RESTORE_EXP:
3841 case SV_POTION_LIFE:
3843 dam = damroll(50, 50);
3846 case SV_POTION_STAR_HEALING:
3848 dam = damroll(50, 50);
3851 case SV_POTION_RESTORE_MANA: /* MANA */
3853 dam = damroll(10, 10);
3860 (void)project(who, radius, y, x, dam, dt,
3861 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3863 /* XXX those potions that explode need to become "known" */
3869 * Hack -- Display all known spells in a window
3871 * XXX XXX XXX Need to analyze size of the window.
3873 * XXX XXX XXX Need more color coding.
3875 void display_spell_list(void)
3888 /* They have too many spells to list */
3889 if (p_ptr->pclass == CLASS_SORCERER) return;
3890 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3892 /* mind.c type classes */
3893 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3894 (p_ptr->pclass == CLASS_BERSERKER) ||
3895 (p_ptr->pclass == CLASS_NINJA) ||
3896 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3897 (p_ptr->pclass == CLASS_FORCETRAINER))
3903 int plev = p_ptr->lev;
3909 bool use_hp = FALSE;
3911 /* Display a list of spells */
3914 put_str("̾Á°", y, x + 5);
3915 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3917 put_str("Name", y, x + 5);
3918 put_str("Lv Mana Fail Info", y, x + 35);
3921 switch(p_ptr->pclass)
3923 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3924 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3925 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3926 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3927 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3928 default: use_mind = 0;break;
3931 /* Dump the spells */
3932 for (i = 0; i < MAX_MIND_POWERS; i++)
3934 byte a = TERM_WHITE;
3936 /* Access the available spell */
3937 spell = mind_powers[use_mind].info[i];
3938 if (spell.min_lev > plev) break;
3940 /* Get the failure rate */
3941 chance = spell.fail;
3943 /* Reduce failure rate by "effective" level adjustment */
3944 chance -= 3 * (p_ptr->lev - spell.min_lev);
3946 /* Reduce failure rate by INT/WIS adjustment */
3947 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3951 /* Not enough mana to cast */
3952 if (spell.mana_cost > p_ptr->csp)
3954 chance += 5 * (spell.mana_cost - p_ptr->csp);
3960 /* Not enough hp to cast */
3961 if (spell.mana_cost > p_ptr->chp)
3968 /* Extract the minimum failure rate */
3969 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3971 /* Minimum failure rate */
3972 if (chance < minfail) chance = minfail;
3974 /* Stunning makes spells harder */
3975 if (p_ptr->stun > 50) chance += 25;
3976 else if (p_ptr->stun) chance += 15;
3978 /* Always a 5 percent chance of working */
3979 if (chance > 95) chance = 95;
3982 mindcraft_info(comment, use_mind, i);
3984 /* Dump the spell */
3985 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3987 spell.min_lev, spell.mana_cost, chance, comment);
3989 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3994 /* Cannot read spellbooks */
3995 if (REALM_NONE == p_ptr->realm1) return;
3997 /* Normal spellcaster with books */
4000 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
4004 /* Reset vertical */
4007 /* Vertical location */
4008 y = (j < 3) ? 0 : (m[j - 3] + 2);
4010 /* Horizontal location */
4014 for (i = 0; i < 32; i++)
4016 byte a = TERM_WHITE;
4018 /* Access the spell */
4019 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
4021 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
4025 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
4028 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
4031 if (s_ptr->slevel >= 99)
4035 strcpy(name, "(ȽÆÉÉÔǽ)");
4037 strcpy(name, "(illegible)");
4047 ((p_ptr->spell_forgotten1 & (1L << i))) :
4048 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4055 else if (!((j < 1) ?
4056 (p_ptr->spell_learned1 & (1L << i)) :
4057 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4064 else if (!((j < 1) ?
4065 (p_ptr->spell_worked1 & (1L << i)) :
4066 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4072 /* Dump the spell --(-- */
4073 sprintf(out_val, "%c/%c) %-20.20s",
4074 I2A(n / 8), I2A(n % 8), name);
4079 /* Dump onto the window */
4080 Term_putstr(x, m[j], -1, a, out_val);
4090 * Returns experience of a spell
4092 s16b experience_of_spell(int spell, int use_realm)
4094 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4095 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4096 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4097 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4103 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4105 int mod_need_mana(int need_mana, int spell, int realm)
4107 #define MANA_CONST 2400
4109 #define DEC_MANA_DIV 3
4112 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4115 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4116 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4118 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4119 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4120 need_mana /= MANA_CONST * MANA_DIV;
4121 if (need_mana < 1) need_mana = 1;
4124 /* Non-realm magic */
4127 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4139 * Returns spell chance of failure for spell -RAK-
4141 s16b spell_chance(int spell, int use_realm)
4143 int chance, minfail;
4146 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4149 /* Paranoia -- must be literate */
4150 if (!mp_ptr->spell_book) return (100);
4152 if (use_realm == REALM_HISSATSU) return 0;
4154 /* Access the spell */
4155 if (!is_magic(use_realm))
4157 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4161 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4164 /* Extract the base spell failure rate */
4165 chance = s_ptr->sfail;
4167 /* Reduce failure rate by "effective" level adjustment */
4168 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4170 /* Reduce failure rate by INT/WIS adjustment */
4171 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4174 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4176 /* Extract mana consumption rate */
4177 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4179 /* Not enough mana to cast */
4180 if (need_mana > p_ptr->csp)
4182 chance += 5 * (need_mana - p_ptr->csp);
4185 chance += p_ptr->to_m_chance;
4186 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4188 /* Extract the minimum failure rate */
4189 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4192 * Non mage/priest characters never get too good
4193 * (added high mage, mindcrafter)
4195 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4197 if (minfail < 5) minfail = 5;
4200 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4201 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4202 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4204 if (p_ptr->heavy_spell) chance += 20;
4205 if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
4206 else if (p_ptr->easy_spell) chance-=3;
4207 else if (p_ptr->dec_mana) chance-=2;
4209 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4210 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4211 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4213 /* Minimum failure rate */
4214 if (chance < minfail) chance = minfail;
4216 /* Stunning makes spells harder */
4217 if (p_ptr->stun > 50) chance += 25;
4218 else if (p_ptr->stun) chance += 15;
4220 /* Always a 5 percent chance of working */
4221 if (chance > 95) chance = 95;
4223 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4224 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4226 s16b exp = experience_of_spell(spell, use_realm);
4227 if (exp >= SPELL_EXP_EXPERT) chance--;
4228 if (exp >= SPELL_EXP_MASTER) chance--;
4230 if(p_ptr->dec_mana) chance--;
4231 if (p_ptr->heavy_spell) chance += 5;
4233 chance = MAX(chance,0);
4235 /* Return the chance */
4242 * Determine if a spell is "okay" for the player to cast or study
4243 * The spell must be legible, not forgotten, and also, to cast,
4244 * it must be known, and to study, it must not be known.
4246 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4250 /* Access the spell */
4251 if (!is_magic(use_realm))
4253 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4257 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4260 /* Spell is illegal */
4261 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4263 /* Spell is forgotten */
4264 if ((use_realm == p_ptr->realm2) ?
4265 (p_ptr->spell_forgotten2 & (1L << spell)) :
4266 (p_ptr->spell_forgotten1 & (1L << spell)))
4272 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4273 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4275 /* Spell is learned */
4276 if ((use_realm == p_ptr->realm2) ?
4277 (p_ptr->spell_learned2 & (1L << spell)) :
4278 (p_ptr->spell_learned1 & (1L << spell)))
4281 return (!study_pray);
4284 /* Okay to study, not to cast */
4291 * Extra information on a spell -DRS-
4293 * We can use up to 14 characters of the buffer 'p'
4295 * The strings in this function were extracted from the code in the
4296 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4298 static void spell_info(char *p, int spell, int use_realm)
4300 int plev = p_ptr->lev;
4303 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4304 p_ptr->pclass == CLASS_HIGH_MAGE ||
4305 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4307 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4308 p_ptr->pclass == CLASS_HIGH_MAGE ||
4309 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4311 cptr s_dam = "»½ý:";
4312 cptr s_dur = "´ü´Ö:";
4313 cptr s_range = "ÈÏ°Ï:";
4314 cptr s_heal = "²óÉü:";
4315 cptr s_random = "¥é¥ó¥À¥à";
4316 cptr s_delay = "ÃÙ±ä:";
4318 cptr s_dam = "dam ";
4319 cptr s_dur = "dur ";
4320 cptr s_range = "range ";
4321 cptr s_heal = "heal ";
4322 cptr s_random = "random";
4323 cptr s_delay = "delay ";
4328 /* Analyze the spell */
4331 case REALM_LIFE: /* Life */
4334 case 0: sprintf(p, " %s2d10", s_heal); break;
4335 case 1: sprintf(p, " %s12+d12", s_dur); break;
4336 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4337 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4338 case 5: sprintf(p, " %s4d10", s_heal); break;
4339 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4340 case 10: sprintf(p, " %s8d10", s_heal); break;
4341 case 11: sprintf(p, " %s20+d20", s_dur); break;
4342 case 14: sprintf(p, " %s300", s_heal); break;
4343 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4344 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4345 case 21: sprintf(p, " %s15+d21", s_delay); break;
4346 case 29: sprintf(p, " %s2000", s_heal); break;
4347 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4351 case REALM_SORCERY: /* Sorcery */
4354 case 1: sprintf(p, " %s10", s_range); break;
4355 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4356 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4357 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4358 case 18: sprintf(p, " %s25+d30", s_dur); break;
4359 case 22: sprintf(p, " %s15+d21", s_delay); break;
4360 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4361 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4363 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4365 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4367 case 27: sprintf(p, " %s25+d30", s_dur); break;
4368 case 31: sprintf(p, " %s4+d4", s_dur); break;
4372 case REALM_NATURE: /* Nature */
4376 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4378 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4380 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4381 case 6: sprintf(p, " %s20+d20", s_dur); break;
4382 case 7: sprintf(p, " %s2d8", s_heal); break;
4383 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4384 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4385 case 12: sprintf(p, " %s6d8", s_dam); break;
4386 case 15: sprintf(p, " %s500", s_heal); break;
4387 case 17: sprintf(p, " %s20+d30", s_dur); break;
4388 case 18: sprintf(p, " %s20+d20", s_dur); break;
4390 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4392 case 24: sprintf(p, " rad 10"); break;
4394 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4395 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4396 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4397 case 29: sprintf(p, " %s75", s_dam); break;
4398 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4402 case REALM_CHAOS: /* Chaos */
4405 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4406 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4407 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4408 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4409 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4410 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4411 case 8: sprintf(p, " %s", s_random); break;
4412 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4413 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4414 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4415 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4416 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4417 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4418 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4419 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4420 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4422 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4424 case 25: sprintf(p, " dam %d each", plev * 2); break;
4426 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4427 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4428 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4429 case 30: sprintf(p, " %s%d", s_dam, p_ptr->chp); break;
4430 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4434 case REALM_DEATH: /* Death */
4437 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4438 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4439 case 5: sprintf(p, " %s20+d20", s_dur); break;
4440 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4441 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4442 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4444 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4446 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4448 case 16: sprintf(p, " %s25+d25", s_dur); break;
4449 case 17: sprintf(p, " %s", s_random); break;
4450 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4451 case 19: sprintf(p, " %s25+d25", s_dur); break;
4452 case 21: sprintf(p, " %s3*100", s_dam); break;
4453 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4454 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4455 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4456 case 30: sprintf(p, " %s666", s_dam); break;
4457 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4461 case REALM_TRUMP: /* Trump */
4464 case 0: sprintf(p, " %s10", s_range); break;
4465 case 2: sprintf(p, " %s", s_random); break;
4466 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4467 case 5: sprintf(p, " %s25+d30", s_dur); break;
4469 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4471 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4473 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4474 case 14: sprintf(p, " %s15+d21", s_delay); break;
4475 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4477 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4479 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4484 case REALM_ARCANE: /* Arcane */
4487 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4488 case 4: sprintf(p, " %s10", s_range); break;
4489 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4490 case 7: sprintf(p, " %s2d8", s_heal); break;
4494 case 17: sprintf(p, " %s20+d20", s_dur); break;
4495 case 18: sprintf(p, " %s4d8", s_heal); break;
4496 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4497 case 21: sprintf(p, " %s6d8", s_dam); break;
4498 case 24: sprintf(p, " %s24+d24", s_dur); break;
4499 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4500 case 30: sprintf(p, " %s15+d21", s_delay); break;
4501 case 31: sprintf(p, " %s25+d30", s_dur); break;
4505 case REALM_ENCHANT: /* Craft */
4508 case 0: sprintf(p, " %s100+d100", s_dur); break;
4509 case 1: sprintf(p, " %s80+d80", s_dur); break;
4515 case 18: sprintf(p, " %s20+d20", s_dur); break;
4516 case 5: sprintf(p, " %s25+d25", s_dur); break;
4517 case 8: sprintf(p, " %s24+d24", s_dur); break;
4518 case 11: sprintf(p, " %s25+d25", s_dur); break;
4519 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4520 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4521 case 16: sprintf(p, " %s25+d30", s_dur); break;
4522 case 17: sprintf(p, " %s30+d20", s_dur); break;
4523 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4524 case 20: sprintf(p, " %s50+d50", s_dur); break;
4525 case 23: sprintf(p, " %s20+d20", s_dur); break;
4526 case 31: sprintf(p, " %s13+d13", s_dur); break;
4530 case REALM_DAEMON: /* Daemon */
4533 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4534 case 2: sprintf(p, " %s12+d12", s_dur); break;
4535 case 3: sprintf(p, " %s20+d20", s_dur); break;
4536 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4537 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4538 case 10: sprintf(p, " %s20+d20", s_dur); break;
4539 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4540 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4541 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4542 case 16: sprintf(p, " %s30+d25", s_dur); break;
4543 case 17: sprintf(p, " %s20+d20", s_dur); break;
4544 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4545 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4546 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4547 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4548 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4549 case 24: sprintf(p, " %s25+d25", s_dur); break;
4550 case 25: sprintf(p, " %s20+d20", s_dur); break;
4551 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4552 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4553 case 30: sprintf(p, " %s600", s_dam); break;
4554 case 31: sprintf(p, " %s15+d15", s_dur); break;
4558 case REALM_CRUSADE: /* Crusade */
4561 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4562 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4564 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4566 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4568 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4569 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4570 case 12: sprintf(p, " %s24+d24", s_dur); break;
4571 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4572 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4574 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4576 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4578 case 18: sprintf(p, " %s18+d18", s_dur); break;
4579 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4580 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4581 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4582 case 24: sprintf(p, " %s25+d25", s_dur); break;
4583 case 28: sprintf(p, " %s10+d10", s_dur); break;
4585 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4587 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4590 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4592 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4597 case REALM_MUSIC: /* Music */
4600 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4601 case 4 : sprintf(p, " %s2d6", s_heal); break;
4602 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4603 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4604 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4605 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4606 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4607 case 28: sprintf(p, " %s15d10", s_heal); break;
4608 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4613 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4615 sprintf(p, "Unknown type: %d.", use_realm);
4622 * Print a list of spells (for browsing or casting or viewing)
4624 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4626 int i, spell, exp_level, increment = 64;
4638 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4640 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4642 msg_print("Warning! print_spells called with null realm");
4646 /* Title the list */
4648 if (use_realm == REALM_HISSATSU)
4650 strcpy(buf," Lv MP");
4652 strcpy(buf," Lv SP");
4656 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4658 strcpy(buf,"Profic Lv SP Fail Effect");
4662 put_str("̾Á°", y, x + 5);
4663 put_str(buf, y, x + 29);
4665 put_str("Name", y, x + 5);
4666 put_str(buf, y, x + 29);
4669 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4670 else if (use_realm == p_ptr->realm1) increment = 0;
4671 else if (use_realm == p_ptr->realm2) increment = 32;
4673 /* Dump the spells */
4674 for (i = 0; i < num; i++)
4676 /* Access the spell */
4679 /* Access the spell */
4680 if (!is_magic(use_realm))
4682 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4686 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4689 if (use_realm == REALM_HISSATSU)
4690 need_mana = s_ptr->smana;
4693 s16b exp = experience_of_spell(spell, use_realm);
4695 /* Extract mana consumption rate */
4696 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4698 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4699 else exp_level = spell_exp_level(exp);
4702 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4703 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4704 else if (s_ptr->slevel >= 99) max = TRUE;
4705 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4707 strncpy(ryakuji, exp_level_str[exp_level], 4);
4712 if (use_menu && target_spell)
4714 if (i == (target_spell-1))
4716 strcpy(out_val, " ¡Õ ");
4718 strcpy(out_val, " > ");
4721 strcpy(out_val, " ");
4723 else sprintf(out_val, " %c) ", I2A(i));
4724 /* Skip illegible spells */
4725 if (s_ptr->slevel >= 99)
4728 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4730 strcat(out_val, format("%-30s", "(illegible)"));
4733 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4737 /* XXX XXX Could label spells above the players level */
4739 /* Get extra info */
4740 spell_info(info, spell, use_realm);
4745 /* Assume spell is known and tried */
4746 line_attr = TERM_WHITE;
4748 /* Analyze the spell */
4749 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4751 if (s_ptr->slevel > p_ptr->max_plv)
4756 comment = " unknown";
4759 line_attr = TERM_L_BLUE;
4761 else if (s_ptr->slevel > p_ptr->lev)
4766 comment = " forgotten";
4769 line_attr = TERM_YELLOW;
4772 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4777 comment = " unknown";
4780 line_attr = TERM_L_BLUE;
4782 else if ((use_realm == p_ptr->realm1) ?
4783 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4784 ((p_ptr->spell_forgotten2 & (1L << spell))))
4789 comment = " forgotten";
4792 line_attr = TERM_YELLOW;
4794 else if (!((use_realm == p_ptr->realm1) ?
4795 (p_ptr->spell_learned1 & (1L << spell)) :
4796 (p_ptr->spell_learned2 & (1L << spell))))
4801 comment = " unknown";
4804 line_attr = TERM_L_BLUE;
4806 else if (!((use_realm == p_ptr->realm1) ?
4807 (p_ptr->spell_worked1 & (1L << spell)) :
4808 (p_ptr->spell_worked2 & (1L << spell))))
4811 comment = " ̤·Ð¸³";
4813 comment = " untried";
4816 line_attr = TERM_L_GREEN;
4819 /* Dump the spell --(-- */
4820 if (use_realm == REALM_HISSATSU)
4822 strcat(out_val, format("%-25s %2d %4d",
4823 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4824 s_ptr->slevel, need_mana));
4828 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4829 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4830 (max ? '!' : ' '), ryakuji,
4831 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4833 c_prt(line_attr, out_val, y + i + 1, x);
4836 /* Clear the bottom line */
4837 prt("", y + i + 1, x);
4842 * Note that amulets, rods, and high-level spell books are immune
4843 * to "inventory damage" of any kind. Also sling ammo and shovels.
4848 * Does a given class of objects (usually) hate acid?
4849 * Note that acid can either melt or corrode something.
4851 bool hates_acid(object_type *o_ptr)
4853 /* Analyze the type */
4854 switch (o_ptr->tval)
4856 /* Wearable items */
4876 /* Staffs/Scrolls are wood/paper */
4889 /* Junk is useless */
4903 * Does a given object (usually) hate electricity?
4905 bool hates_elec(object_type *o_ptr)
4907 switch (o_ptr->tval)
4921 * Does a given object (usually) hate fire?
4922 * Hafted/Polearm weapons have wooden shafts.
4923 * Arrows/Bows are mostly wooden.
4925 bool hates_fire(object_type *o_ptr)
4927 /* Analyze the type */
4928 switch (o_ptr->tval)
4946 case TV_SORCERY_BOOK:
4947 case TV_NATURE_BOOK:
4951 case TV_ARCANE_BOOK:
4952 case TV_ENCHANT_BOOK:
4953 case TV_DAEMON_BOOK:
4954 case TV_CRUSADE_BOOK:
4956 case TV_HISSATSU_BOOK:
4967 /* Staffs/Scrolls burn */
4980 * Does a given object (usually) hate cold?
4982 bool hates_cold(object_type *o_ptr)
4984 switch (o_ptr->tval)
5001 int set_acid_destroy(object_type *o_ptr)
5003 u32b flgs[TR_FLAG_SIZE];
5004 if (!hates_acid(o_ptr)) return (FALSE);
5005 object_flags(o_ptr, flgs);
5006 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
5014 int set_elec_destroy(object_type *o_ptr)
5016 u32b flgs[TR_FLAG_SIZE];
5017 if (!hates_elec(o_ptr)) return (FALSE);
5018 object_flags(o_ptr, flgs);
5019 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
5027 int set_fire_destroy(object_type *o_ptr)
5029 u32b flgs[TR_FLAG_SIZE];
5030 if (!hates_fire(o_ptr)) return (FALSE);
5031 object_flags(o_ptr, flgs);
5032 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
5040 int set_cold_destroy(object_type *o_ptr)
5042 u32b flgs[TR_FLAG_SIZE];
5043 if (!hates_cold(o_ptr)) return (FALSE);
5044 object_flags(o_ptr, flgs);
5045 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
5051 * Destroys a type of item on a given percent chance
5052 * Note that missiles are no longer necessarily all destroyed
5053 * Destruction taken from "melee.c" code for "stealing".
5054 * New-style wands and rods handled correctly. -LM-
5055 * Returns number of items destroyed.
5057 int inven_damage(inven_func typ, int perc)
5061 char o_name[MAX_NLEN];
5063 /* Multishadow effects is determined by turn */
5064 if( p_ptr->multishadow && (turn & 1) )return 0;
5066 if (p_ptr->inside_arena) return 0;
5068 /* Count the casualties */
5071 /* Scan through the slots backwards */
5072 for (i = 0; i < INVEN_PACK; i++)
5074 o_ptr = &inventory[i];
5076 /* Skip non-objects */
5077 if (!o_ptr->k_idx) continue;
5079 /* Hack -- for now, skip artifacts */
5080 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
5082 /* Give this item slot a shot at death */
5085 /* Count the casualties */
5086 for (amt = j = 0; j < o_ptr->number; ++j)
5088 if (randint0(100) < perc) amt++;
5091 /* Some casualities */
5094 /* Get a description */
5095 object_desc(o_name, o_ptr, FALSE, 3);
5099 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
5101 msg_format("%sour %s (%c) %s destroyed!",
5105 o_name, index_to_label(i),
5106 ((o_ptr->number > 1) ?
5107 ((amt == o_ptr->number) ? "Á´Éô" :
5108 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
5110 ((o_ptr->number > 1) ?
5111 ((amt == o_ptr->number) ? "All of y" :
5112 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
5113 o_name, index_to_label(i),
5114 ((amt > 1) ? "were" : "was"));
5118 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
5119 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
5122 /* Potions smash open */
5123 if (object_is_potion(o_ptr))
5125 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
5128 /* Reduce the charges of rods/wands */
5129 reduce_charges(o_ptr, amt);
5131 /* Destroy "amt" items */
5132 inven_item_increase(i, -amt);
5133 inven_item_optimize(i);
5135 /* Count the casualties */
5141 /* Return the casualty count */
5147 * Acid has hit the player, attempt to affect some armor.
5149 * Note that the "base armor" of an object never changes.
5151 * If any armor is damaged (or resists), the player takes less damage.
5153 static int minus_ac(void)
5155 object_type *o_ptr = NULL;
5156 u32b flgs[TR_FLAG_SIZE];
5157 char o_name[MAX_NLEN];
5160 /* Pick a (possibly empty) inventory slot */
5161 switch (randint1(7))
5163 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5164 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5165 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5166 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5167 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5168 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5169 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5172 /* Nothing to damage */
5173 if (!o_ptr->k_idx) return (FALSE);
5175 if (o_ptr->tval < TV_BOOTS) return (FALSE);
5177 /* No damage left to be done */
5178 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5182 object_desc(o_name, o_ptr, FALSE, 0);
5184 /* Extract the flags */
5185 object_flags(o_ptr, flgs);
5187 /* Object resists */
5188 if (have_flag(flgs, TR_IGNORE_ACID))
5191 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5193 msg_format("Your %s is unaffected!", o_name);
5202 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5204 msg_format("Your %s is damaged!", o_name);
5208 /* Damage the item */
5211 /* Calculate bonuses */
5212 p_ptr->update |= (PU_BONUS);
5215 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5219 /* Item was damaged */
5225 * Hurt the player with Acid
5227 int acid_dam(int dam, cptr kb_str, int monspell)
5230 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5231 bool double_resist = IS_OPPOSE_ACID();
5233 /* Total Immunity */
5234 if (p_ptr->immune_acid || (dam <= 0))
5236 learn_spell(monspell);
5240 /* Vulnerability (Ouch!) */
5241 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5242 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5244 /* Resist the damage */
5245 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5246 if (double_resist) dam = (dam + 2) / 3;
5248 if ((!(double_resist || p_ptr->resist_acid)) &&
5249 one_in_(HURT_CHANCE))
5250 (void)do_dec_stat(A_CHR);
5252 /* If any armor gets hit, defend the player */
5253 if (minus_ac()) dam = (dam + 1) / 2;
5256 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5258 /* Inventory damage */
5259 if (!(double_resist && p_ptr->resist_acid))
5260 inven_damage(set_acid_destroy, inv);
5266 * Hurt the player with electricity
5268 int elec_dam(int dam, cptr kb_str, int monspell)
5271 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5272 bool double_resist = IS_OPPOSE_ELEC();
5274 /* Total immunity */
5275 if (p_ptr->immune_elec || (dam <= 0))
5277 learn_spell(monspell);
5281 /* Vulnerability (Ouch!) */
5282 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5283 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5284 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5286 /* Resist the damage */
5287 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5288 if (double_resist) dam = (dam + 2) / 3;
5290 if ((!(double_resist || p_ptr->resist_elec)) &&
5291 one_in_(HURT_CHANCE))
5292 (void)do_dec_stat(A_DEX);
5295 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5297 /* Inventory damage */
5298 if (!(double_resist && p_ptr->resist_elec))
5299 inven_damage(set_elec_destroy, inv);
5306 * Hurt the player with Fire
5308 int fire_dam(int dam, cptr kb_str, int monspell)
5311 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5312 bool double_resist = IS_OPPOSE_FIRE();
5314 /* Totally immune */
5315 if (p_ptr->immune_fire || (dam <= 0))
5317 learn_spell(monspell);
5321 /* Vulnerability (Ouch!) */
5322 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5323 if (prace_is_(RACE_ENT)) dam += dam / 3;
5324 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5326 /* Resist the damage */
5327 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5328 if (double_resist) dam = (dam + 2) / 3;
5330 if ((!(double_resist || p_ptr->resist_fire)) &&
5331 one_in_(HURT_CHANCE))
5332 (void)do_dec_stat(A_STR);
5335 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5337 /* Inventory damage */
5338 if (!(double_resist && p_ptr->resist_fire))
5339 inven_damage(set_fire_destroy, inv);
5346 * Hurt the player with Cold
5348 int cold_dam(int dam, cptr kb_str, int monspell)
5351 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5352 bool double_resist = IS_OPPOSE_COLD();
5354 /* Total immunity */
5355 if (p_ptr->immune_cold || (dam <= 0))
5357 learn_spell(monspell);
5361 /* Vulnerability (Ouch!) */
5362 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5363 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5365 /* Resist the damage */
5366 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5367 if (double_resist) dam = (dam + 2) / 3;
5369 if ((!(double_resist || p_ptr->resist_cold)) &&
5370 one_in_(HURT_CHANCE))
5371 (void)do_dec_stat(A_STR);
5374 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5376 /* Inventory damage */
5377 if (!(double_resist && p_ptr->resist_cold))
5378 inven_damage(set_cold_destroy, inv);
5384 bool rustproof(void)
5388 char o_name[MAX_NLEN];
5391 item_tester_no_ryoute = TRUE;
5392 /* Select a piece of armour */
5393 item_tester_hook = item_tester_hook_armour;
5397 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5398 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5400 q = "Rustproof which piece of armour? ";
5401 s = "You have nothing to rustproof.";
5404 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5406 /* Get the item (in the pack) */
5409 o_ptr = &inventory[item];
5412 /* Get the item (on the floor) */
5415 o_ptr = &o_list[0 - item];
5420 object_desc(o_name, o_ptr, FALSE, 0);
5422 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5424 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5427 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5429 msg_format("%s %s look%s as good as new!",
5430 ((item >= 0) ? "Your" : "The"), o_name,
5431 ((o_ptr->number > 1) ? "" : "s"));
5438 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5440 msg_format("%s %s %s now protected against corrosion.",
5441 ((item >= 0) ? "Your" : "The"), o_name,
5442 ((o_ptr->number > 1) ? "are" : "is"));
5453 * Curse the players armor
5455 bool curse_armor(void)
5460 char o_name[MAX_NLEN];
5463 /* Curse the body armor */
5464 o_ptr = &inventory[INVEN_BODY];
5466 /* Nothing to curse */
5467 if (!o_ptr->k_idx) return (FALSE);
5471 object_desc(o_name, o_ptr, FALSE, 3);
5473 /* Attempt a saving throw for artifacts */
5474 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5478 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5479 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5481 msg_format("A %s tries to %s, but your %s resists the effects!",
5482 "terrible black aura", "surround your armor", o_name);
5487 /* not artifact or failed save... */
5492 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5494 msg_format("A terrible black aura blasts your %s!", o_name);
5497 chg_virtue(V_ENCHANT, -5);
5499 /* Blast the armor */
5501 o_ptr->name2 = EGO_BLASTED;
5502 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5509 for (i = 0; i < TR_FLAG_SIZE; i++)
5510 o_ptr->art_flags[i] = 0;
5513 o_ptr->curse_flags = TRC_CURSED;
5516 o_ptr->ident |= (IDENT_BROKEN);
5518 /* Recalculate bonuses */
5519 p_ptr->update |= (PU_BONUS);
5521 /* Recalculate mana */
5522 p_ptr->update |= (PU_MANA);
5525 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5533 * Curse the players weapon
5535 bool curse_weapon(bool force, int slot)
5541 char o_name[MAX_NLEN];
5544 /* Curse the weapon */
5545 o_ptr = &inventory[slot];
5547 /* Nothing to curse */
5548 if (!o_ptr->k_idx) return (FALSE);
5552 object_desc(o_name, o_ptr, FALSE, 3);
5554 /* Attempt a saving throw */
5555 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5559 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5560 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5562 msg_format("A %s tries to %s, but your %s resists the effects!",
5563 "terrible black aura", "surround your weapon", o_name);
5568 /* not artifact or failed save... */
5573 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5575 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5578 chg_virtue(V_ENCHANT, -5);
5580 /* Shatter the weapon */
5582 o_ptr->name2 = EGO_SHATTERED;
5583 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5584 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5590 for (i = 0; i < TR_FLAG_SIZE; i++)
5591 o_ptr->art_flags[i] = 0;
5595 o_ptr->curse_flags = TRC_CURSED;
5598 o_ptr->ident |= (IDENT_BROKEN);
5600 /* Recalculate bonuses */
5601 p_ptr->update |= (PU_BONUS);
5603 /* Recalculate mana */
5604 p_ptr->update |= (PU_MANA);
5607 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5616 * Enchant some bolts
5618 bool brand_bolts(void)
5622 /* Use the first acceptable bolts */
5623 for (i = 0; i < INVEN_PACK; i++)
5625 object_type *o_ptr = &inventory[i];
5627 /* Skip non-bolts */
5628 if (o_ptr->tval != TV_BOLT) continue;
5630 /* Skip artifacts and ego-items */
5631 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5634 /* Skip cursed/broken items */
5635 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5638 if (randint0(100) < 75) continue;
5642 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5644 msg_print("Your bolts are covered in a fiery aura!");
5649 o_ptr->name2 = EGO_FLAME;
5652 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5659 if (flush_failure) flush();
5663 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5665 msg_print("The fiery enchantment failed.");
5675 * Helper function -- return a "nearby" race for polymorphing
5677 * Note that this function is one of the more "dangerous" ones...
5679 static s16b poly_r_idx(int r_idx)
5681 monster_race *r_ptr = &r_info[r_idx];
5683 int i, r, lev1, lev2;
5685 /* Hack -- Uniques/Questors never polymorph */
5686 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5687 (r_ptr->flags1 & RF1_QUESTOR))
5690 /* Allowable range of "levels" for resulting monster */
5691 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5692 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5694 /* Pick a (possibly new) non-unique race */
5695 for (i = 0; i < 1000; i++)
5697 /* Pick a new race, using a level calculation */
5698 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5700 /* Handle failure */
5706 /* Ignore unique monsters */
5707 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5709 /* Ignore monsters with incompatible levels */
5710 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5712 /* Use that index */
5724 bool polymorph_monster(int y, int x)
5726 cave_type *c_ptr = &cave[y][x];
5727 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5728 bool polymorphed = FALSE;
5730 int old_r_idx = m_ptr->r_idx;
5731 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5732 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5733 monster_type back_m;
5735 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5737 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5739 /* Memorize the monster before polymorphing */
5742 /* Pick a "new" monster race */
5743 new_r_idx = poly_r_idx(old_r_idx);
5745 /* Handle polymorph */
5746 if (new_r_idx != old_r_idx)
5750 /* Get the monsters attitude */
5751 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5752 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5753 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5755 /* "Kill" the "old" monster */
5756 delete_monster_idx(c_ptr->m_idx);
5758 /* Create a new monster (no groups) */
5759 if (place_monster_aux(0, y, x, new_r_idx, mode))
5766 /* Placing the new monster failed */
5767 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5768 m_list[hack_m_idx_ii] = back_m;
5771 if (targeted) target_who = hack_m_idx_ii;
5772 if (health_tracked) health_track(hack_m_idx_ii);
5782 bool dimension_door(void)
5784 int plev = p_ptr->lev;
5787 if (!tgt_pt(&x, &y)) return FALSE;
5789 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5791 if (!cave_empty_bold(y, x) || (cave[y][x].info & CAVE_ICKY) ||
5792 (distance(y, x, py, px) > plev / 2 + 10) ||
5793 (!randint0(plev / 10 + 10)))
5795 if( p_ptr->pclass != CLASS_MIRROR_MASTER ){
5797 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5799 msg_print("You fail to exit the astral plane correctly!");
5805 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5807 msg_print("You fail to exit the astral plane correctly!");
5810 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5811 teleport_player((plev+2)*2);
5814 teleport_player_to(y, x, TRUE);
5820 bool eat_magic(int power)
5822 object_type * o_ptr;
5825 int recharge_strength = 0;
5831 char o_name[MAX_NLEN];
5833 item_tester_hook = item_tester_hook_recharge;
5837 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5838 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5840 q = "Drain which item? ";
5841 s = "You have nothing to drain.";
5844 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5848 o_ptr = &inventory[item];
5852 o_ptr = &o_list[0 - item];
5855 k_ptr = &k_info[o_ptr->k_idx];
5856 lev = get_object_level(o_ptr);
5858 if (o_ptr->tval == TV_ROD)
5860 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5863 if (one_in_(recharge_strength))
5865 /* Activate the failure code. */
5870 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5873 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5875 msg_print("You can't absorb energy from a discharged rod.");
5882 o_ptr->timeout += k_ptr->pval;
5888 /* All staffs, wands. */
5889 recharge_strength = (100 + power - lev) / 15;
5892 if (recharge_strength < 0) recharge_strength = 0;
5895 if (one_in_(recharge_strength))
5897 /* Activate the failure code. */
5902 if (o_ptr->pval > 0)
5904 p_ptr->csp += lev / 2;
5907 /* XXX Hack -- unstack if necessary */
5908 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5913 /* Get local object */
5916 /* Obtain a local object */
5917 object_copy(q_ptr, o_ptr);
5919 /* Modify quantity */
5922 /* Restore the charges */
5925 /* Unstack the used item */
5927 p_ptr->total_weight -= q_ptr->weight;
5928 item = inven_carry(q_ptr);
5932 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5934 msg_print("You unstack your staff.");
5942 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5944 msg_print("There's no energy there to absorb!");
5948 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5952 /* Inflict the penalties for failing a recharge. */
5955 /* Artifacts are never destroyed. */
5956 if (artifact_p(o_ptr))
5958 object_desc(o_name, o_ptr, TRUE, 0);
5960 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5962 msg_format("The recharging backfires - %s is completely drained!", o_name);
5966 /* Artifact rods. */
5967 if (o_ptr->tval == TV_ROD)
5968 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5970 /* Artifact wands and staffs. */
5971 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5976 /* Get the object description */
5977 object_desc(o_name, o_ptr, FALSE, 0);
5979 /*** Determine Seriousness of Failure ***/
5981 /* Mages recharge objects more safely. */
5982 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)
5984 /* 10% chance to blow up one rod, otherwise draining. */
5985 if (o_ptr->tval == TV_ROD)
5987 if (one_in_(10)) fail_type = 2;
5990 /* 75% chance to blow up one wand, otherwise draining. */
5991 else if (o_ptr->tval == TV_WAND)
5993 if (!one_in_(3)) fail_type = 2;
5996 /* 50% chance to blow up one staff, otherwise no effect. */
5997 else if (o_ptr->tval == TV_STAFF)
5999 if (one_in_(2)) fail_type = 2;
6004 /* All other classes get no special favors. */
6007 /* 33% chance to blow up one rod, otherwise draining. */
6008 if (o_ptr->tval == TV_ROD)
6010 if (one_in_(3)) fail_type = 2;
6013 /* 20% chance of the entire stack, else destroy one wand. */
6014 else if (o_ptr->tval == TV_WAND)
6016 if (one_in_(5)) fail_type = 3;
6019 /* Blow up one staff. */
6020 else if (o_ptr->tval == TV_STAFF)
6026 /*** Apply draining and destruction. ***/
6028 /* Drain object or stack of objects. */
6031 if (o_ptr->tval == TV_ROD)
6034 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
6036 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
6039 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6041 else if (o_ptr->tval == TV_WAND)
6044 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
6046 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
6051 /* Staffs aren't drained. */
6054 /* Destroy an object or one in a stack of objects. */
6057 if (o_ptr->number > 1)
6060 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
6062 msg_format("Wild magic consumes one of your %s!", o_name);
6065 /* Reduce rod stack maximum timeout, drain wands. */
6066 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
6067 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
6072 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
6074 msg_format("Wild magic consumes your %s!", o_name);
6077 /* Reduce and describe inventory */
6080 inven_item_increase(item, -1);
6081 inven_item_describe(item);
6082 inven_item_optimize(item);
6085 /* Reduce and describe floor item */
6088 floor_item_increase(0 - item, -1);
6089 floor_item_describe(0 - item);
6090 floor_item_optimize(0 - item);
6094 /* Destroy all members of a stack of objects. */
6097 if (o_ptr->number > 1)
6099 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
6101 msg_format("Wild magic consumes all your %s!", o_name);
6106 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
6108 msg_format("Wild magic consumes your %s!", o_name);
6113 /* Reduce and describe inventory */
6116 inven_item_increase(item, -999);
6117 inven_item_describe(item);
6118 inven_item_optimize(item);
6121 /* Reduce and describe floor item */
6124 floor_item_increase(0 - item, -999);
6125 floor_item_describe(0 - item);
6126 floor_item_optimize(0 - item);
6132 if (p_ptr->csp > p_ptr->msp)
6134 p_ptr->csp = p_ptr->msp;
6137 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6138 p_ptr->window |= (PW_INVEN);
6144 bool summon_kin_player(int level, int y, int x, u32b mode)
6146 bool pet = (bool)(mode & PM_FORCE_PET);
6147 if (!pet) mode |= PM_NO_PET;
6149 switch (p_ptr->mimic_form)
6152 switch (p_ptr->prace)
6156 case RACE_BARBARIAN:
6159 summon_kin_type = 'p';
6169 case RACE_MIND_FLAYER:
6172 summon_kin_type = 'h';
6175 summon_kin_type = 'o';
6177 case RACE_HALF_TROLL:
6178 summon_kin_type = 'T';
6180 case RACE_HALF_OGRE:
6181 summon_kin_type = 'O';
6183 case RACE_HALF_GIANT:
6184 case RACE_HALF_TITAN:
6186 summon_kin_type = 'P';
6189 summon_kin_type = 'y';
6192 summon_kin_type = 'K';
6195 summon_kin_type = 'k';
6198 if (one_in_(13)) summon_kin_type = 'U';
6199 else summon_kin_type = 'u';
6201 case RACE_DRACONIAN:
6202 summon_kin_type = 'd';
6206 summon_kin_type = 'g';
6209 if (one_in_(13)) summon_kin_type = 'L';
6210 else summon_kin_type = 's';
6213 summon_kin_type = 'z';
6216 summon_kin_type = 'V';
6219 summon_kin_type = 'G';
6222 summon_kin_type = 'I';
6225 summon_kin_type = '#';
6228 summon_kin_type = 'A';
6231 summon_kin_type = 'U';
6234 summon_kin_type = 'p';
6239 if (one_in_(13)) summon_kin_type = 'U';
6240 else summon_kin_type = 'u';
6242 case MIMIC_DEMON_LORD:
6243 summon_kin_type = 'U';
6246 summon_kin_type = 'V';
6249 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);