3 * @brief 魔法効果の実装/ Spell code (part 3)
7 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
16 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
19 /*! 能力値現象の基本確率(1 / HURT_CHANCE) / 1/x chance of reducing stats (for elemental attacks) */
20 #define HURT_CHANCE 16
23 * @brief 指定されたマスがモンスターのテレポート可能先かどうかを判定する。
24 * @param m_idx モンスターID
29 static bool cave_monster_teleportable_bold(int m_idx, int y, int x, u32b mode)
31 monster_type *m_ptr = &m_list[m_idx];
32 cave_type *c_ptr = &cave[y][x];
33 feature_type *f_ptr = &f_info[c_ptr->feat];
35 /* Require "teleportable" space */
36 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
38 if (c_ptr->m_idx && (c_ptr->m_idx != m_idx)) return FALSE;
39 if (player_bold(y, x)) return FALSE;
41 /* Hack -- no teleport onto glyph of warding */
42 if (is_glyph_grid(c_ptr)) return FALSE;
43 if (is_explosive_rune_grid(c_ptr)) return FALSE;
45 if (!(mode & TELEPORT_PASSIVE))
47 if (!monster_can_cross_terrain(c_ptr->feat, &r_info[m_ptr->r_idx], 0)) return FALSE;
55 * @brief モンスターのテレポートアウェイ処理 /
56 * Teleport a monster, normally up to "dis" grids away.
57 * @param m_idx モンスターID
61 * Attempt to move the monster at least "dis/2" grids away.
62 * But allow variation to prevent infinite loops.
64 bool teleport_away(int m_idx, int dis, u32b mode)
66 int oy, ox, d, i, min;
72 monster_type *m_ptr = &m_list[m_idx];
75 if (!m_ptr->r_idx) return (FALSE);
77 /* Save the old location */
81 /* Minimum distance */
84 if ((mode & TELEPORT_DEC_VALOUR) &&
85 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
86 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
88 chg_virtue(V_VALOUR, -1);
96 /* Verify max distance */
97 if (dis > 200) dis = 200;
99 /* Try several locations */
100 for (i = 0; i < 500; i++)
102 /* Pick a (possibly illegal) location */
105 ny = rand_spread(oy, dis);
106 nx = rand_spread(ox, dis);
107 d = distance(oy, ox, ny, nx);
108 if ((d >= min) && (d <= dis)) break;
111 /* Ignore illegal locations */
112 if (!in_bounds(ny, nx)) continue;
114 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
116 /* No teleporting into vaults and such */
117 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
118 if (cave[ny][nx].info & CAVE_ICKY) continue;
120 /* This grid looks good */
127 /* Increase the maximum distance */
130 /* Decrease the minimum distance */
133 /* Stop after MAX_TRIES tries */
134 if (tries > MAX_TRIES) return (FALSE);
138 sound(SOUND_TPOTHER);
140 /* Update the old location */
141 cave[oy][ox].m_idx = 0;
143 /* Update the new location */
144 cave[ny][nx].m_idx = m_idx;
146 /* Move the monster */
150 /* Forget the counter target */
153 /* Update the monster (new location) */
154 update_mon(m_idx, TRUE);
156 /* Redraw the old grid */
159 /* Redraw the new grid */
162 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
163 p_ptr->update |= (PU_MON_LITE);
170 * @brief モンスターを指定された座標付近にテレポートする /
171 * Teleport monster next to a grid near the given location
172 * @param m_idx モンスターID
175 * @param power テレポート成功確率
178 void teleport_monster_to(int m_idx, int ty, int tx, int power, u32b mode)
180 int ny, nx, oy, ox, d, i, min;
184 monster_type *m_ptr = &m_list[m_idx];
187 if (!m_ptr->r_idx) return;
190 if (randint1(100) > power) return;
196 /* Save the old location */
200 /* Minimum distance */
203 /* Look until done */
204 while (look && --attempts)
206 /* Verify max distance */
207 if (dis > 200) dis = 200;
209 /* Try several locations */
210 for (i = 0; i < 500; i++)
212 /* Pick a (possibly illegal) location */
215 ny = rand_spread(ty, dis);
216 nx = rand_spread(tx, dis);
217 d = distance(ty, tx, ny, nx);
218 if ((d >= min) && (d <= dis)) break;
221 /* Ignore illegal locations */
222 if (!in_bounds(ny, nx)) continue;
224 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
226 /* No teleporting into vaults and such */
227 /* if (cave[ny][nx].info & (CAVE_ICKY)) continue; */
229 /* This grid looks good */
236 /* Increase the maximum distance */
239 /* Decrease the minimum distance */
243 if (attempts < 1) return;
246 sound(SOUND_TPOTHER);
248 /* Update the old location */
249 cave[oy][ox].m_idx = 0;
251 /* Update the new location */
252 cave[ny][nx].m_idx = m_idx;
254 /* Move the monster */
258 /* Update the monster (new location) */
259 update_mon(m_idx, TRUE);
261 /* Redraw the old grid */
264 /* Redraw the new grid */
267 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
268 p_ptr->update |= (PU_MON_LITE);
272 bool cave_player_teleportable_bold(int y, int x, u32b mode)
274 cave_type *c_ptr = &cave[y][x];
275 feature_type *f_ptr = &f_info[c_ptr->feat];
277 /* Require "teleportable" space */
278 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
280 /* No magical teleporting into vaults and such */
281 if (!(mode & TELEPORT_NONMAGICAL) && (c_ptr->info & CAVE_ICKY)) return FALSE;
283 if (c_ptr->m_idx && (c_ptr->m_idx != p_ptr->riding)) return FALSE;
285 /* don't teleport on a trap. */
286 if (have_flag(f_ptr->flags, FF_HIT_TRAP)) return FALSE;
288 if (!(mode & TELEPORT_PASSIVE))
290 if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
292 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
294 if (!p_ptr->levitation && !p_ptr->can_swim) return FALSE;
297 if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
299 /* Always forbid deep lava */
300 if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
302 /* Forbid shallow lava when the player don't have levitation */
303 if (!p_ptr->levitation) return FALSE;
313 * Teleport the player to a location up to "dis" grids away.
315 * If no such spaces are readily available, the distance may increase.
316 * Try very hard to move the player at least a quarter that distance.
318 * There was a nasty tendency for a long time; which was causing the
319 * player to "bounce" between two or three different spots because
320 * these are the only spots that are "far enough" way to satisfy the
323 * But this tendency is now removed; in the new algorithm, a list of
324 * candidates is selected first, which includes at least 50% of all
325 * floor grids within the distance, and any single grid in this list
326 * of candidates has equal possibility to be choosen as a destination.
329 #define MAX_TELEPORT_DISTANCE 200
331 bool teleport_player_aux(int dis, u32b mode)
333 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
334 int total_candidates, cur_candidates;
335 int y = 0, x = 0, min, pick, i;
337 int left = MAX(1, px - dis);
338 int right = MIN(cur_wid - 2, px + dis);
339 int top = MAX(1, py - dis);
340 int bottom = MIN(cur_hgt - 2, py + dis);
342 if (p_ptr->wild_mode) return FALSE;
344 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
346 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
350 /* Initialize counters */
351 total_candidates = 0;
352 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
353 candidates_at[i] = 0;
355 /* Limit the distance */
356 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
358 /* Search valid locations */
359 for (y = top; y <= bottom; y++)
361 for (x = left; x <= right; x++)
365 /* Skip illegal locations */
366 if (!cave_player_teleportable_bold(y, x, mode)) continue;
368 /* Calculate distance */
369 d = distance(py, px, y, x);
371 /* Skip too far locations */
372 if (d > dis) continue;
374 /* Count the total number of candidates */
377 /* Count the number of candidates in this circumference */
382 /* No valid location! */
383 if (0 == total_candidates) return FALSE;
385 /* Fix the minimum distance */
386 for (cur_candidates = 0, min = dis; min >= 0; min--)
388 cur_candidates += candidates_at[min];
390 /* 50% of all candidates will have an equal chance to be choosen. */
391 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
394 /* Pick up a single location randomly */
395 pick = randint1(cur_candidates);
397 /* Search again the choosen location */
398 for (y = top; y <= bottom; y++)
400 for (x = left; x <= right; x++)
404 /* Skip illegal locations */
405 if (!cave_player_teleportable_bold(y, x, mode)) continue;
407 /* Calculate distance */
408 d = distance(py, px, y, x);
410 /* Skip too far locations */
411 if (d > dis) continue;
413 /* Skip too close locations */
414 if (d < min) continue;
416 /* This grid was picked up? */
425 if (player_bold(y, x)) return FALSE;
428 sound(SOUND_TELEPORT);
431 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
432 msg_format("『こっちだぁ、%s』", player_name);
435 /* Move the player */
436 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
441 void teleport_player(int dis, u32b mode)
445 /* Save the old location */
449 if (!teleport_player_aux(dis, mode)) return;
451 /* Monsters with teleport ability may follow the player */
452 for (xx = -1; xx < 2; xx++)
454 for (yy = -1; yy < 2; yy++)
456 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
458 /* A monster except your mount may follow */
459 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
461 monster_type *m_ptr = &m_list[tmp_m_idx];
462 monster_race *r_ptr = &r_info[m_ptr->r_idx];
465 * The latter limitation is to avoid
466 * totally unkillable suckers...
468 if ((r_ptr->flags6 & RF6_TPORT) &&
469 !(r_ptr->flagsr & RFR_RES_TELE))
471 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level, 0L);
479 void teleport_player_away(int m_idx, int dis)
483 /* Save the old location */
487 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
489 /* Monsters with teleport ability may follow the player */
490 for (xx = -1; xx < 2; xx++)
492 for (yy = -1; yy < 2; yy++)
494 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
496 /* A monster except your mount or caster may follow */
497 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
499 monster_type *m_ptr = &m_list[tmp_m_idx];
500 monster_race *r_ptr = &r_info[m_ptr->r_idx];
503 * The latter limitation is to avoid
504 * totally unkillable suckers...
506 if ((r_ptr->flags6 & RF6_TPORT) &&
507 !(r_ptr->flagsr & RFR_RES_TELE))
509 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level, 0L);
518 * Teleport player to a grid near the given location
520 * This function is slightly obsessive about correctness.
521 * This function allows teleporting into vaults (!)
523 void teleport_player_to(int ny, int nx, u32b mode)
525 int y, x, dis = 0, ctr = 0;
527 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
529 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
533 /* Find a usable location */
536 /* Pick a nearby legal location */
539 y = rand_spread(ny, dis);
540 x = rand_spread(nx, dis);
541 if (in_bounds(y, x)) break;
544 /* Accept any grid when wizard mode */
545 if (p_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
547 /* Accept teleportable floor grids */
548 if (cave_player_teleportable_bold(y, x, mode)) break;
550 /* Occasionally advance the distance */
551 if (++ctr > (4 * dis * dis + 4 * dis + 1))
559 sound(SOUND_TELEPORT);
561 /* Move the player */
562 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
566 void teleport_away_followable(int m_idx)
568 monster_type *m_ptr = &m_list[m_idx];
569 int oldfy = m_ptr->fy;
570 int oldfx = m_ptr->fx;
571 bool old_ml = m_ptr->ml;
572 int old_cdis = m_ptr->cdis;
574 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
576 if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && !p_ptr->inside_battle && los(py, px, oldfy, oldfx))
580 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
583 u32b flgs[TR_FLAG_SIZE];
587 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
589 o_ptr = &inventory[i];
590 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
592 object_flags(o_ptr, flgs);
593 if (have_flag(flgs, TR_TELEPORT))
604 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
608 teleport_player(200, TELEPORT_PASSIVE);
609 msg_print(_("失敗!", "Failed!"));
611 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
612 p_ptr->energy_need += ENERGY_NEED();
620 * Teleport the player one level up or down (random when legal)
621 * Note: If m_idx <= 0, target is player.
623 void teleport_level(int m_idx)
629 if (m_idx <= 0) /* To player */
631 strcpy(m_name, _("あなた", "you"));
633 else /* To monster */
635 monster_type *m_ptr = &m_list[m_idx];
637 /* Get the monster name (or "it") */
638 monster_desc(m_name, m_ptr, 0);
640 see_m = is_seen(m_ptr);
643 /* No effect in some case */
644 if (TELE_LEVEL_IS_INEFF(m_idx))
646 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
650 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
652 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
656 /* Choose up or down */
657 if (randint0(100) < 50) go_up = TRUE;
660 if ((m_idx <= 0) && p_ptr->wizard)
662 if (get_check("Force to go up? ")) go_up = TRUE;
663 else if (get_check("Force to go down? ")) go_up = FALSE;
667 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
670 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
672 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
674 if (m_idx <= 0) /* To player */
678 dungeon_type = p_ptr->recall_dungeon;
683 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
685 if (autosave_l) do_cmd_save_game(TRUE);
689 dun_level = d_info[dungeon_type].mindepth;
690 prepare_change_floor_mode(CFM_RAND_PLACE);
694 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
698 p_ptr->leaving = TRUE;
703 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
706 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
708 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
712 if (m_idx <= 0) /* To player */
714 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
716 if (autosave_l) do_cmd_save_game(TRUE);
718 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
723 p_ptr->inside_quest = 0;
724 p_ptr->leaving = TRUE;
730 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
732 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
736 if (m_idx <= 0) /* To player */
738 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
740 if (autosave_l) do_cmd_save_game(TRUE);
742 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
745 p_ptr->leaving = TRUE;
751 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
753 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
756 if (m_idx <= 0) /* To player */
758 /* Never reach this code on the surface */
759 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
761 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
763 if (autosave_l) do_cmd_save_game(TRUE);
765 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
768 p_ptr->leaving = TRUE;
772 /* Monster level teleportation is simple deleting now */
775 monster_type *m_ptr = &m_list[m_idx];
777 /* Check for quest completion */
778 check_quest_completion(m_ptr);
780 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
784 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
785 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
788 delete_monster_idx(m_idx);
792 sound(SOUND_TPLEVEL);
797 int choose_dungeon(cptr note, int y, int x)
803 /* Hack -- No need to choose dungeon in some case */
804 if (lite_town || vanilla_town || ironman_downward)
806 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
809 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
815 /* Allocate the "dun" array */
816 C_MAKE(dun, max_d_idx, s16b);
819 for(i = 1; i < max_d_idx; i++)
824 if (!d_info[i].maxdepth) continue;
825 if (!max_dlv[i]) continue;
826 if (d_info[i].final_guardian)
828 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
830 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
832 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
833 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
834 prt(buf, y + num, x);
840 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
843 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
847 if ((i == ESCAPE) || !num)
849 /* Free the "dun" array */
850 C_KILL(dun, max_d_idx, s16b);
855 if (i >= 'a' && i <('a'+num))
857 select_dungeon = dun[i-'a'];
864 /* Free the "dun" array */
865 C_KILL(dun, max_d_idx, s16b);
867 return select_dungeon;
872 * Recall the player to town or dungeon
874 bool recall_player(int turns)
877 * TODO: Recall the player to the last
878 * visited town when in the wilderness
882 if (p_ptr->inside_arena || ironman_downward)
884 msg_print(_("何も起こらなかった。", "Nothing happens."));
888 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
890 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
892 max_dlv[dungeon_type] = dun_level;
894 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, _("帰還のときに", "when recall from dungeon"));
898 if (!p_ptr->word_recall)
903 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
904 if (!select_dungeon) return FALSE;
905 p_ptr->recall_dungeon = select_dungeon;
907 p_ptr->word_recall = turns;
908 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
909 p_ptr->redraw |= (PR_STATUS);
913 p_ptr->word_recall = 0;
914 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
915 p_ptr->redraw |= (PR_STATUS);
921 bool word_of_recall(void)
923 return(recall_player(randint0(21) + 15));
927 bool reset_recall(void)
929 int select_dungeon, dummy = 0;
933 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
936 if (ironman_downward)
938 msg_print(_("何も起こらなかった。", "Nothing happens."));
942 if (!select_dungeon) return FALSE;
944 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "), d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
947 sprintf(tmp_val, "%d", MAX(dun_level, 1));
949 /* Ask for a level */
950 if (get_string(ppp, tmp_val, 10))
952 /* Extract request */
953 dummy = atoi(tmp_val);
956 if (dummy < 1) dummy = 1;
959 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
960 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
962 max_dlv[select_dungeon] = dummy;
965 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
968 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
970 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
983 * Apply disenchantment to the player's stuff
985 * XXX XXX XXX This function is also called from the "melee" code
987 * Return "TRUE" if the player notices anything
989 bool apply_disenchant(int mode)
993 char o_name[MAX_NLEN];
994 int to_h, to_d, to_a, pval;
996 /* Pick a random slot */
999 case 1: t = INVEN_RARM; break;
1000 case 2: t = INVEN_LARM; break;
1001 case 3: t = INVEN_BOW; break;
1002 case 4: t = INVEN_BODY; break;
1003 case 5: t = INVEN_OUTER; break;
1004 case 6: t = INVEN_HEAD; break;
1005 case 7: t = INVEN_HANDS; break;
1006 case 8: t = INVEN_FEET; break;
1010 o_ptr = &inventory[t];
1012 /* No item, nothing happens */
1013 if (!o_ptr->k_idx) return (FALSE);
1015 /* Disenchant equipments only -- No disenchant on monster ball */
1016 if (!object_is_weapon_armour_ammo(o_ptr))
1019 /* Nothing to disenchant */
1020 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1022 /* Nothing to notice */
1027 /* Describe the object */
1028 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1031 /* Artifacts have 71% chance to resist */
1032 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1036 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1038 msg_format("Your %s (%c) resist%s disenchantment!",
1039 o_name, index_to_label(t),
1040 ((o_ptr->number != 1) ? "" : "s"));
1049 /* Memorize old value */
1055 /* Disenchant tohit */
1056 if (o_ptr->to_h > 0) o_ptr->to_h--;
1057 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1059 /* Disenchant todam */
1060 if (o_ptr->to_d > 0) o_ptr->to_d--;
1061 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1063 /* Disenchant toac */
1064 if (o_ptr->to_a > 0) o_ptr->to_a--;
1065 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1067 /* Disenchant pval (occasionally) */
1068 /* Unless called from wild_magic() */
1069 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1071 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1072 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1076 msg_format("%s(%c)は劣化してしまった!",
1077 o_name, index_to_label(t) );
1079 msg_format("Your %s (%c) %s disenchanted!",
1080 o_name, index_to_label(t),
1081 ((o_ptr->number != 1) ? "were" : "was"));
1084 chg_virtue(V_HARMONY, 1);
1085 chg_virtue(V_ENCHANT, -2);
1087 /* Recalculate bonuses */
1088 p_ptr->update |= (PU_BONUS);
1091 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1101 void mutate_player(void)
1103 int max1, cur1, max2, cur2, ii, jj, i;
1105 /* Pick a pair of stats */
1107 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1109 max1 = p_ptr->stat_max[ii];
1110 cur1 = p_ptr->stat_cur[ii];
1111 max2 = p_ptr->stat_max[jj];
1112 cur2 = p_ptr->stat_cur[jj];
1114 p_ptr->stat_max[ii] = max2;
1115 p_ptr->stat_cur[ii] = cur2;
1116 p_ptr->stat_max[jj] = max1;
1117 p_ptr->stat_cur[jj] = cur1;
1121 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1122 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1125 p_ptr->update |= (PU_BONUS);
1132 void apply_nexus(monster_type *m_ptr)
1134 switch (randint1(7))
1136 case 1: case 2: case 3:
1138 teleport_player(200, TELEPORT_PASSIVE);
1144 teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
1150 if (randint0(100) < p_ptr->skill_sav)
1152 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1156 /* Teleport Level */
1163 if (randint0(100) < p_ptr->skill_sav)
1165 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1169 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
1178 * Charge a lite (torch or latern)
1180 void phlogiston(void)
1183 object_type * o_ptr = &inventory[INVEN_LITE];
1186 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1188 max_flog = FUEL_LAMP;
1192 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1194 max_flog = FUEL_TORCH;
1197 /* No torch to refill */
1200 msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
1204 if (o_ptr->xtra4 >= max_flog)
1206 msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
1211 o_ptr->xtra4 += (max_flog / 2);
1214 msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
1217 if (o_ptr->xtra4 >= max_flog)
1219 o_ptr->xtra4 = max_flog;
1220 msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
1223 /* Recalculate torch */
1224 p_ptr->update |= (PU_TORCH);
1229 * Brand the current weapon
1231 void brand_weapon(int brand_type)
1238 /* Assume enchant weapon */
1239 item_tester_hook = object_allow_enchant_melee_weapon;
1240 item_tester_no_ryoute = TRUE;
1243 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1244 s = _("強化できる武器がない。", "You have nothing to enchant.");
1246 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1248 /* Get the item (in the pack) */
1251 o_ptr = &inventory[item];
1254 /* Get the item (on the floor) */
1257 o_ptr = &o_list[0 - item];
1261 /* you can never modify artifacts / ego-items */
1262 /* you can never modify cursed items */
1263 /* TY: You _can_ modify broken items (if you're silly enough) */
1264 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1265 !object_is_cursed(o_ptr) &&
1266 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1267 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1268 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1272 /* Let's get the name before it is changed... */
1273 char o_name[MAX_NLEN];
1274 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1279 if (o_ptr->tval == TV_SWORD)
1281 act = _("は鋭さを増した!", "becomes very sharp!");
1283 o_ptr->name2 = EGO_SHARPNESS;
1284 o_ptr->pval = m_bonus(5, dun_level) + 1;
1286 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1291 act = _("は破壊力を増した!", "seems very powerful.");
1292 o_ptr->name2 = EGO_EARTHQUAKES;
1293 o_ptr->pval = m_bonus(3, dun_level);
1297 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1298 o_ptr->name2 = EGO_KILL_HUMAN;
1301 act = _("は電撃に覆われた!", "covered with lightning!");
1302 o_ptr->name2 = EGO_BRAND_ELEC;
1305 act = _("は酸に覆われた!", "coated with acid!");
1306 o_ptr->name2 = EGO_BRAND_ACID;
1309 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1310 o_ptr->name2 = EGO_KILL_EVIL;
1313 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1314 o_ptr->name2 = EGO_KILL_DEMON;
1317 act = _("は屍を求めている!", "seems to be looking for undead!");
1318 o_ptr->name2 = EGO_KILL_UNDEAD;
1321 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1322 o_ptr->name2 = EGO_KILL_ANIMAL;
1325 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1326 o_ptr->name2 = EGO_KILL_DRAGON;
1329 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1330 o_ptr->name2 = EGO_KILL_TROLL;
1333 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1334 o_ptr->name2 = EGO_KILL_ORC;
1337 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1338 o_ptr->name2 = EGO_KILL_GIANT;
1341 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1342 o_ptr->name2 = EGO_TRUMP;
1343 o_ptr->pval = randint1(2);
1346 act = _("は血を求めている!", "thirsts for blood!");
1347 o_ptr->name2 = EGO_VAMPIRIC;
1350 act = _("は毒に覆われた。", "is coated with poison.");
1351 o_ptr->name2 = EGO_BRAND_POIS;
1354 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1355 o_ptr->name2 = EGO_CHAOTIC;
1358 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1359 o_ptr->name2 = EGO_BRAND_FIRE;
1362 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1363 o_ptr->name2 = EGO_BRAND_COLD;
1367 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1368 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1370 o_ptr->discount = 99;
1371 chg_virtue(V_ENCHANT, 2);
1375 if (flush_failure) flush();
1377 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1378 chg_virtue(V_ENCHANT, -2);
1385 * Vanish all walls in this floor
1387 static bool vanish_dungeon(void)
1391 feature_type *f_ptr;
1392 monster_type *m_ptr;
1395 /* Prevent vasishing of quest levels and town */
1396 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1401 /* Scan all normal grids */
1402 for (y = 1; y < cur_hgt - 1; y++)
1404 for (x = 1; x < cur_wid - 1; x++)
1406 c_ptr = &cave[y][x];
1408 /* Seeing true feature code (ignore mimic) */
1409 f_ptr = &f_info[c_ptr->feat];
1411 /* Lose room and vault */
1412 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1414 m_ptr = &m_list[c_ptr->m_idx];
1417 if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
1419 /* Reset sleep counter */
1420 (void)set_monster_csleep(c_ptr->m_idx, 0);
1422 /* Notice the "waking up" */
1425 /* Acquire the monster name */
1426 monster_desc(m_name, m_ptr, 0);
1428 /* Dump a message */
1429 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1433 /* Process all walls, doors and patterns */
1434 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1438 /* Special boundary walls -- Top and bottom */
1439 for (x = 0; x < cur_wid; x++)
1441 c_ptr = &cave[0][x];
1442 f_ptr = &f_info[c_ptr->mimic];
1444 /* Lose room and vault */
1445 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1447 /* Set boundary mimic if needed */
1448 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1450 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1452 /* Check for change to boring grid */
1453 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1456 c_ptr = &cave[cur_hgt - 1][x];
1457 f_ptr = &f_info[c_ptr->mimic];
1459 /* Lose room and vault */
1460 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1462 /* Set boundary mimic if needed */
1463 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1465 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1467 /* Check for change to boring grid */
1468 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1472 /* Special boundary walls -- Left and right */
1473 for (y = 1; y < (cur_hgt - 1); y++)
1475 c_ptr = &cave[y][0];
1476 f_ptr = &f_info[c_ptr->mimic];
1478 /* Lose room and vault */
1479 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1481 /* Set boundary mimic if needed */
1482 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1484 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1486 /* Check for change to boring grid */
1487 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1490 c_ptr = &cave[y][cur_wid - 1];
1491 f_ptr = &f_info[c_ptr->mimic];
1493 /* Lose room and vault */
1494 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1496 /* Set boundary mimic if needed */
1497 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1499 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1501 /* Check for change to boring grid */
1502 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1506 /* Mega-Hack -- Forget the view and lite */
1507 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1510 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1512 /* Update the monsters */
1513 p_ptr->update |= (PU_MONSTERS);
1516 p_ptr->redraw |= (PR_MAP);
1519 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1525 void call_the_(void)
1529 bool do_call = TRUE;
1531 for (i = 0; i < 9; i++)
1533 c_ptr = &cave[py + ddy_ddd[i]][px + ddx_ddd[i]];
1535 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1537 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1538 !permanent_wall(&f_info[c_ptr->feat]))
1548 for (i = 1; i < 10; i++)
1550 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1553 for (i = 1; i < 10; i++)
1555 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1558 for (i = 1; i < 10; i++)
1560 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1564 /* Prevent destruction of quest levels and town */
1565 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1567 msg_print(_("地面が揺れた。", "The ground trembles."));
1573 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1574 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1575 msg_print("大きな爆発音があった!");
1577 msg_format("You %s the %s too close to a wall!",
1578 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1579 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1580 msg_print("There is a loud explosion!");
1585 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1589 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1590 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1592 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1595 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1601 * Fetch an item (teleport it right underneath the caster)
1603 void fetch(int dir, int wgt, bool require_los)
1608 char o_name[MAX_NLEN];
1610 /* Check to see if an object is already there */
1611 if (cave[py][px].o_idx)
1613 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1618 if (dir == 5 && target_okay())
1623 if (distance(py, px, ty, tx) > MAX_RANGE)
1625 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1629 c_ptr = &cave[ty][tx];
1631 /* We need an item to fetch */
1634 msg_print(_("そこには何もありません。", "There is no object at this place."));
1638 /* No fetching from vault */
1639 if (c_ptr->info & CAVE_ICKY)
1641 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1645 /* We need to see the item */
1648 if (!player_has_los_bold(ty, tx))
1650 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1653 else if (!projectable(py, px, ty, tx))
1655 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1662 /* Use a direction */
1663 ty = py; /* Where to drop the item */
1670 c_ptr = &cave[ty][tx];
1672 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1673 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1675 while (!c_ptr->o_idx);
1678 o_ptr = &o_list[c_ptr->o_idx];
1680 if (o_ptr->weight > wgt)
1682 /* Too heavy to 'fetch' */
1683 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1688 c_ptr->o_idx = o_ptr->next_o_idx;
1689 cave[py][px].o_idx = i; /* 'move' it */
1690 o_ptr->next_o_idx = 0;
1691 o_ptr->iy = (byte)py;
1692 o_ptr->ix = (byte)px;
1694 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1695 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1698 p_ptr->redraw |= PR_MAP;
1702 void alter_reality(void)
1704 /* Ironman option */
1705 if (p_ptr->inside_arena || ironman_downward)
1707 msg_print(_("何も起こらなかった。", "Nothing happens."));
1711 if (!p_ptr->alter_reality)
1713 int turns = randint0(21) + 15;
1715 p_ptr->alter_reality = turns;
1716 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1718 p_ptr->redraw |= (PR_STATUS);
1722 p_ptr->alter_reality = 0;
1723 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1724 p_ptr->redraw |= (PR_STATUS);
1731 * Leave a "glyph of warding" which prevents monster movement
1733 bool warding_glyph(void)
1736 if (!cave_clean_bold(py, px))
1738 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1742 /* Create a glyph */
1743 cave[py][px].info |= CAVE_OBJECT;
1744 cave[py][px].mimic = feat_glyph;
1755 bool place_mirror(void)
1758 if (!cave_clean_bold(py, px))
1760 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1764 /* Create a mirror */
1765 cave[py][px].info |= CAVE_OBJECT;
1766 cave[py][px].mimic = feat_mirror;
1768 /* Turn on the light */
1769 cave[py][px].info |= CAVE_GLOW;
1777 update_local_illumination(py, px);
1784 * Leave an "explosive rune" which prevents monster movement
1786 bool explosive_rune(void)
1789 if (!cave_clean_bold(py, px))
1791 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1795 /* Create a glyph */
1796 cave[py][px].info |= CAVE_OBJECT;
1797 cave[py][px].mimic = feat_explosive_rune;
1810 * Identify everything being carried.
1811 * Done by a potion of "self knowledge".
1813 void identify_pack(void)
1817 /* Simply identify and know every item */
1818 for (i = 0; i < INVEN_TOTAL; i++)
1820 object_type *o_ptr = &inventory[i];
1822 /* Skip non-objects */
1823 if (!o_ptr->k_idx) continue;
1826 identify_item(o_ptr);
1828 /* Auto-inscription */
1829 autopick_alter_item(i, FALSE);
1835 * Used by the "enchant" function (chance of failure)
1836 * (modified for Zangband, we need better stuff there...) -- TY
1838 static int enchant_table[16] =
1840 0, 10, 50, 100, 200,
1841 300, 400, 500, 650, 800,
1842 950, 987, 993, 995, 998,
1848 * Removes curses from items in inventory
1850 * Note that Items which are "Perma-Cursed" (The One Ring,
1851 * The Crown of Morgoth) can NEVER be uncursed.
1853 * Note that if "all" is FALSE, then Items which are
1854 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1855 * will not be uncursed.
1857 static int remove_curse_aux(int all)
1861 /* Attempt to uncurse items being worn */
1862 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1864 object_type *o_ptr = &inventory[i];
1866 /* Skip non-objects */
1867 if (!o_ptr->k_idx) continue;
1869 /* Uncursed already */
1870 if (!object_is_cursed(o_ptr)) continue;
1872 /* Heavily Cursed Items need a special spell */
1873 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1875 /* Perma-Cursed Items can NEVER be uncursed */
1876 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1879 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1884 o_ptr->curse_flags = 0L;
1886 /* Hack -- Assume felt */
1887 o_ptr->ident |= (IDENT_SENSE);
1890 o_ptr->feeling = FEEL_NONE;
1892 /* Recalculate the bonuses */
1893 p_ptr->update |= (PU_BONUS);
1896 p_ptr->window |= (PW_EQUIP);
1898 /* Count the uncursings */
1902 /* Return "something uncursed" */
1908 * Remove most curses
1910 bool remove_curse(void)
1912 return (remove_curse_aux(FALSE));
1918 bool remove_all_curse(void)
1920 return (remove_curse_aux(TRUE));
1925 * Turns an object into gold, gain some of its value in a shop
1934 char o_name[MAX_NLEN];
1935 char out_val[MAX_NLEN+40];
1939 /* Hack -- force destruction */
1940 if (command_arg > 0) force = TRUE;
1943 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
1944 s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
1946 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
1948 /* Get the item (in the pack) */
1951 o_ptr = &inventory[item];
1954 /* Get the item (on the floor) */
1957 o_ptr = &o_list[0 - item];
1961 /* See how many items */
1962 if (o_ptr->number > 1)
1964 /* Get a quantity */
1965 amt = get_quantity(NULL, o_ptr->number);
1967 /* Allow user abort */
1968 if (amt <= 0) return FALSE;
1972 /* Describe the object */
1973 old_number = o_ptr->number;
1974 o_ptr->number = amt;
1975 object_desc(o_name, o_ptr, 0);
1976 o_ptr->number = old_number;
1978 /* Verify unless quantity given */
1981 if (confirm_destroy || (object_value(o_ptr) > 0))
1983 /* Make a verification */
1984 sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
1985 if (!get_check(out_val)) return FALSE;
1989 /* Artifacts cannot be destroyed */
1990 if (!can_player_destroy_object(o_ptr))
1993 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
1999 price = object_value_real(o_ptr);
2004 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
2010 if (amt > 1) price *= amt;
2012 if (price > 30000) price = 30000;
2013 msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
2018 p_ptr->redraw |= (PR_GOLD);
2021 p_ptr->window |= (PW_PLAYER);
2025 /* Eliminate the item (from the pack) */
2028 inven_item_increase(item, -amt);
2029 inven_item_describe(item);
2030 inven_item_optimize(item);
2033 /* Eliminate the item (from the floor) */
2036 floor_item_increase(0 - item, -amt);
2037 floor_item_describe(0 - item);
2038 floor_item_optimize(0 - item);
2046 * Break the curse of an item
2048 static void break_curse(object_type *o_ptr)
2050 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2052 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
2054 o_ptr->curse_flags = 0L;
2055 o_ptr->ident |= (IDENT_SENSE);
2056 o_ptr->feeling = FEEL_NONE;
2062 * Enchants a plus onto an item. -RAK-
2064 * Revamped! Now takes item pointer, number of times to try enchanting,
2065 * and a flag of what to try enchanting. Artifacts resist enchantment
2066 * some of the time, and successful enchantment to at least +0 might
2067 * break a curse on the item. -CFT-
2069 * Note that an item can technically be enchanted all the way to +15 if
2070 * you wait a very, very, long time. Going from +9 to +10 only works
2071 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2073 * Note that this function can now be used on "piles" of items, and
2074 * the larger the pile, the lower the chance of success.
2076 bool enchant(object_type *o_ptr, int n, int eflag)
2078 int i, chance, prob;
2080 bool a = object_is_artifact(o_ptr);
2081 bool force = (eflag & ENCH_FORCE);
2084 /* Large piles resist enchantment */
2085 prob = o_ptr->number * 100;
2087 /* Missiles are easy to enchant */
2088 if ((o_ptr->tval == TV_BOLT) ||
2089 (o_ptr->tval == TV_ARROW) ||
2090 (o_ptr->tval == TV_SHOT))
2096 for (i = 0; i < n; i++)
2098 /* Hack -- Roll for pile resistance */
2099 if (!force && randint0(prob) >= 100) continue;
2101 /* Enchant to hit */
2102 if (eflag & ENCH_TOHIT)
2104 if (o_ptr->to_h < 0) chance = 0;
2105 else if (o_ptr->to_h > 15) chance = 1000;
2106 else chance = enchant_table[o_ptr->to_h];
2108 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2113 /* only when you get it above -1 -CFT */
2114 if (o_ptr->to_h >= 0)
2119 /* Enchant to damage */
2120 if (eflag & ENCH_TODAM)
2122 if (o_ptr->to_d < 0) chance = 0;
2123 else if (o_ptr->to_d > 15) chance = 1000;
2124 else chance = enchant_table[o_ptr->to_d];
2126 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2131 /* only when you get it above -1 -CFT */
2132 if (o_ptr->to_d >= 0)
2137 /* Enchant to armor class */
2138 if (eflag & ENCH_TOAC)
2140 if (o_ptr->to_a < 0) chance = 0;
2141 else if (o_ptr->to_a > 15) chance = 1000;
2142 else chance = enchant_table[o_ptr->to_a];
2144 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2149 /* only when you get it above -1 -CFT */
2150 if (o_ptr->to_a >= 0)
2157 if (!res) return (FALSE);
2159 /* Recalculate bonuses */
2160 p_ptr->update |= (PU_BONUS);
2162 /* Combine / Reorder the pack (later) */
2163 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2166 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2177 * Enchant an item (in the inventory or on the floor)
2178 * Note that "num_ac" requires armour, else weapon
2179 * Returns TRUE if attempted, FALSE if cancelled
2181 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2186 char o_name[MAX_NLEN];
2190 /* Assume enchant weapon */
2191 item_tester_hook = object_allow_enchant_weapon;
2192 item_tester_no_ryoute = TRUE;
2194 /* Enchant armor if requested */
2195 if (num_ac) item_tester_hook = object_is_armour;
2198 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2199 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2201 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2203 /* Get the item (in the pack) */
2206 o_ptr = &inventory[item];
2209 /* Get the item (on the floor) */
2212 o_ptr = &o_list[0 - item];
2217 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2221 msg_format("%s は明るく輝いた!",
2224 msg_format("%s %s glow%s brightly!",
2225 ((item >= 0) ? "Your" : "The"), o_name,
2226 ((o_ptr->number > 1) ? "" : "s"));
2231 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2232 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2233 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2239 if (flush_failure) flush();
2242 msg_print(_("強化に失敗した。", "The enchantment failed."));
2244 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2247 chg_virtue(V_ENCHANT, 1);
2251 /* Something happened */
2257 * Check if an object is nameless weapon or armour
2259 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2261 /* Require weapon or armour */
2262 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2264 /* Require nameless object if the object is well known */
2265 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2272 bool artifact_scroll(void)
2277 char o_name[MAX_NLEN];
2281 item_tester_no_ryoute = TRUE;
2283 /* Enchant weapon/armour */
2284 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2287 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2288 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2290 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2292 /* Get the item (in the pack) */
2295 o_ptr = &inventory[item];
2298 /* Get the item (on the floor) */
2301 o_ptr = &o_list[0 - item];
2306 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2310 msg_format("%s は眩い光を発した!",o_name);
2312 msg_format("%s %s radiate%s a blinding light!",
2313 ((item >= 0) ? "Your" : "The"), o_name,
2314 ((o_ptr->number > 1) ? "" : "s"));
2317 if (object_is_artifact(o_ptr))
2320 msg_format("%sは既に伝説のアイテムです!", o_name );
2322 msg_format("The %s %s already %s!",
2323 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2324 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2330 else if (object_is_ego(o_ptr))
2333 msg_format("%sは既に名のあるアイテムです!", o_name );
2335 msg_format("The %s %s already %s!",
2336 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2337 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2343 else if (o_ptr->xtra3)
2346 msg_format("%sは既に強化されています!", o_name );
2348 msg_format("The %s %s already %s!",
2349 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2350 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2356 if (o_ptr->number > 1)
2359 msg_print("複数のアイテムに魔法をかけるだけのエネルギーはありません!");
2360 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2362 msg_print("Not enough enough energy to enchant more than one object!");
2363 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2368 inven_item_increase(item, 1-(o_ptr->number));
2372 floor_item_increase(0-item, 1-(o_ptr->number));
2375 okay = create_artifact(o_ptr, TRUE);
2382 if (flush_failure) flush();
2385 msg_print(_("強化に失敗した。", "The enchantment failed."));
2387 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2390 chg_virtue(V_ENCHANT, 1);
2394 /* Something happened */
2400 * Identify an object
2402 bool identify_item(object_type *o_ptr)
2404 bool old_known = FALSE;
2405 char o_name[MAX_NLEN];
2408 object_desc(o_name, o_ptr, 0);
2410 if (o_ptr->ident & IDENT_KNOWN)
2413 if (!(o_ptr->ident & (IDENT_MENTAL)))
2415 if (object_is_artifact(o_ptr) || one_in_(5))
2416 chg_virtue(V_KNOWLEDGE, 1);
2419 /* Identify it fully */
2420 object_aware(o_ptr);
2421 object_known(o_ptr);
2423 /* Player touches it */
2424 o_ptr->marked |= OM_TOUCHED;
2426 /* Recalculate bonuses */
2427 p_ptr->update |= (PU_BONUS);
2429 /* Combine / Reorder the pack (later) */
2430 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2433 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2435 strcpy(record_o_name, o_name);
2439 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2441 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2442 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2443 if(record_rand_art && !old_known && o_ptr->art_name)
2444 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2450 static bool item_tester_hook_identify(object_type *o_ptr)
2452 return (bool)!object_is_known(o_ptr);
2455 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2457 if (object_is_known(o_ptr))
2459 return object_is_weapon_armour_ammo(o_ptr);
2463 * Identify an object in the inventory (or on the floor)
2464 * This routine does *not* automatically combine objects.
2465 * Returns TRUE if something was identified, else FALSE.
2467 bool ident_spell(bool only_equip)
2471 char o_name[MAX_NLEN];
2475 item_tester_no_ryoute = TRUE;
2478 item_tester_hook = item_tester_hook_identify_weapon_armour;
2480 item_tester_hook = item_tester_hook_identify;
2484 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2489 item_tester_hook = object_is_weapon_armour_ammo;
2491 item_tester_hook = NULL;
2493 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2497 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2499 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2501 /* Get the item (in the pack) */
2504 o_ptr = &inventory[item];
2507 /* Get the item (on the floor) */
2510 o_ptr = &o_list[0 - item];
2514 old_known = identify_item(o_ptr);
2517 object_desc(o_name, o_ptr, 0);
2520 if (item >= INVEN_RARM)
2522 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2526 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2530 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2533 /* Auto-inscription/destroy */
2534 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2536 /* Something happened */
2542 * Mundanify an object in the inventory (or on the floor)
2543 * This routine does *not* automatically combine objects.
2544 * Returns TRUE if something was mundanified, else FALSE.
2546 bool mundane_spell(bool only_equip)
2552 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2553 item_tester_no_ryoute = TRUE;
2556 q = _("どれを使いますか?", "Use which item? ");
2557 s = _("使えるものがありません。", "You have nothing you can use.");
2559 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2561 /* Get the item (in the pack) */
2564 o_ptr = &inventory[item];
2567 /* Get the item (on the floor) */
2570 o_ptr = &o_list[0 - item];
2574 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2576 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2577 byte ix = o_ptr->ix; /* X-position on map, or zero */
2578 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2579 byte marked = o_ptr->marked; /* Object is marked */
2580 s16b weight = o_ptr->number * o_ptr->weight;
2581 u16b inscription = o_ptr->inscription;
2584 object_prep(o_ptr, o_ptr->k_idx);
2588 o_ptr->next_o_idx = next_o_idx;
2589 o_ptr->marked = marked;
2590 o_ptr->inscription = inscription;
2591 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2595 /* Something happened */
2601 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2603 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2606 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2608 if (!item_tester_hook_identify_fully(o_ptr))
2610 return object_is_weapon_armour_ammo(o_ptr);
2614 * Fully "identify" an object in the inventory -BEN-
2615 * This routine returns TRUE if an item was identified.
2617 bool identify_fully(bool only_equip)
2621 char o_name[MAX_NLEN];
2625 item_tester_no_ryoute = TRUE;
2627 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2629 item_tester_hook = item_tester_hook_identify_fully;
2633 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2638 item_tester_hook = object_is_weapon_armour_ammo;
2640 item_tester_hook = NULL;
2642 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2646 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2648 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2650 /* Get the item (in the pack) */
2653 o_ptr = &inventory[item];
2656 /* Get the item (on the floor) */
2659 o_ptr = &o_list[0 - item];
2663 old_known = identify_item(o_ptr);
2665 /* Mark the item as fully known */
2666 o_ptr->ident |= (IDENT_MENTAL);
2672 object_desc(o_name, o_ptr, 0);
2675 if (item >= INVEN_RARM)
2677 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2681 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2685 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2688 /* Describe it fully */
2689 (void)screen_object(o_ptr, 0L);
2691 /* Auto-inscription/destroy */
2692 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2702 * Hook for "get_item()". Determine if something is rechargable.
2704 bool item_tester_hook_recharge(object_type *o_ptr)
2706 /* Recharge staffs */
2707 if (o_ptr->tval == TV_STAFF) return (TRUE);
2709 /* Recharge wands */
2710 if (o_ptr->tval == TV_WAND) return (TRUE);
2712 /* Hack -- Recharge rods */
2713 if (o_ptr->tval == TV_ROD) return (TRUE);
2721 * Recharge a wand/staff/rod from the pack or on the floor.
2722 * This function has been rewritten in Oangband and ZAngband.
2724 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2725 * Chaos -- Arcane Binding --> recharge(90)
2727 * Scroll of recharging --> recharge(130)
2728 * Artifact activation/Thingol --> recharge(130)
2730 * It is harder to recharge high level, and highly charged wands,
2731 * staffs, and rods. The more wands in a stack, the more easily and
2732 * strongly they recharge. Staffs, however, each get fewer charges if
2735 * XXX XXX XXX Beware of "sliding index errors".
2737 bool recharge(int power)
2740 int recharge_strength, recharge_amount;
2749 char o_name[MAX_NLEN];
2751 /* Only accept legal items */
2752 item_tester_hook = item_tester_hook_recharge;
2755 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2756 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2758 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2760 /* Get the item (in the pack) */
2763 o_ptr = &inventory[item];
2766 /* Get the item (on the floor) */
2769 o_ptr = &o_list[0 - item];
2772 /* Get the object kind. */
2773 k_ptr = &k_info[o_ptr->k_idx];
2775 /* Extract the object "level" */
2776 lev = k_info[o_ptr->k_idx].level;
2779 /* Recharge a rod */
2780 if (o_ptr->tval == TV_ROD)
2782 /* Extract a recharge strength by comparing object level to power. */
2783 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
2787 if (one_in_(recharge_strength))
2789 /* Activate the failure code. */
2796 /* Recharge amount */
2797 recharge_amount = (power * damroll(3, 2));
2799 /* Recharge by that amount */
2800 if (o_ptr->timeout > recharge_amount)
2801 o_ptr->timeout -= recharge_amount;
2808 /* Recharge wand/staff */
2811 /* Extract a recharge strength by comparing object level to power.
2812 * Divide up a stack of wands' charges to calculate charge penalty.
2814 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2815 recharge_strength = (100 + power - lev -
2816 (8 * o_ptr->pval / o_ptr->number)) / 15;
2818 /* All staffs, unstacked wands. */
2819 else recharge_strength = (100 + power - lev -
2820 (8 * o_ptr->pval)) / 15;
2823 if (recharge_strength < 0) recharge_strength = 0;
2826 if (one_in_(recharge_strength))
2828 /* Activate the failure code. */
2832 /* If the spell didn't backfire, recharge the wand or staff. */
2835 /* Recharge based on the standard number of charges. */
2836 recharge_amount = randint1(1 + k_ptr->pval / 2);
2838 /* Multiple wands in a stack increase recharging somewhat. */
2839 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2842 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2843 if (recharge_amount < 1) recharge_amount = 1;
2844 if (recharge_amount > 12) recharge_amount = 12;
2847 /* But each staff in a stack gets fewer additional charges,
2848 * although always at least one.
2850 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2852 recharge_amount /= o_ptr->number;
2853 if (recharge_amount < 1) recharge_amount = 1;
2856 /* Recharge the wand or staff. */
2857 o_ptr->pval += recharge_amount;
2860 /* Hack -- we no longer "know" the item */
2861 o_ptr->ident &= ~(IDENT_KNOWN);
2863 /* Hack -- we no longer think the item is empty */
2864 o_ptr->ident &= ~(IDENT_EMPTY);
2869 /* Inflict the penalties for failing a recharge. */
2872 /* Artifacts are never destroyed. */
2873 if (object_is_fixed_artifact(o_ptr))
2875 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2876 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2878 /* Artifact rods. */
2879 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2880 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2882 /* Artifact wands and staffs. */
2883 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2888 /* Get the object description */
2889 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2891 /*** Determine Seriousness of Failure ***/
2893 /* Mages recharge objects more safely. */
2894 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)
2896 /* 10% chance to blow up one rod, otherwise draining. */
2897 if (o_ptr->tval == TV_ROD)
2899 if (one_in_(10)) fail_type = 2;
2902 /* 75% chance to blow up one wand, otherwise draining. */
2903 else if (o_ptr->tval == TV_WAND)
2905 if (!one_in_(3)) fail_type = 2;
2908 /* 50% chance to blow up one staff, otherwise no effect. */
2909 else if (o_ptr->tval == TV_STAFF)
2911 if (one_in_(2)) fail_type = 2;
2916 /* All other classes get no special favors. */
2919 /* 33% chance to blow up one rod, otherwise draining. */
2920 if (o_ptr->tval == TV_ROD)
2922 if (one_in_(3)) fail_type = 2;
2925 /* 20% chance of the entire stack, else destroy one wand. */
2926 else if (o_ptr->tval == TV_WAND)
2928 if (one_in_(5)) fail_type = 3;
2931 /* Blow up one staff. */
2932 else if (o_ptr->tval == TV_STAFF)
2938 /*** Apply draining and destruction. ***/
2940 /* Drain object or stack of objects. */
2943 if (o_ptr->tval == TV_ROD)
2945 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
2947 if (o_ptr->timeout < 10000)
2948 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2950 else if (o_ptr->tval == TV_WAND)
2952 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
2955 /* Staffs aren't drained. */
2958 /* Destroy an object or one in a stack of objects. */
2961 if (o_ptr->number > 1)
2962 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
2964 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2966 /* Reduce rod stack maximum timeout, drain wands. */
2967 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
2968 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
2970 /* Reduce and describe inventory */
2973 inven_item_increase(item, -1);
2974 inven_item_describe(item);
2975 inven_item_optimize(item);
2978 /* Reduce and describe floor item */
2981 floor_item_increase(0 - item, -1);
2982 floor_item_describe(0 - item);
2983 floor_item_optimize(0 - item);
2987 /* Destroy all members of a stack of objects. */
2990 if (o_ptr->number > 1)
2991 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
2993 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2995 /* Reduce and describe inventory */
2998 inven_item_increase(item, -999);
2999 inven_item_describe(item);
3000 inven_item_optimize(item);
3003 /* Reduce and describe floor item */
3006 floor_item_increase(0 - item, -999);
3007 floor_item_describe(0 - item);
3008 floor_item_optimize(0 - item);
3014 /* Combine / Reorder the pack (later) */
3015 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3018 p_ptr->window |= (PW_INVEN);
3020 /* Something was done */
3028 bool bless_weapon(void)
3032 u32b flgs[TR_FLAG_SIZE];
3033 char o_name[MAX_NLEN];
3036 item_tester_no_ryoute = TRUE;
3038 /* Bless only weapons */
3039 item_tester_hook = object_is_weapon;
3042 q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
3043 s = _("祝福できる武器がありません。", "You have weapon to bless.");
3045 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3048 /* Get the item (in the pack) */
3051 o_ptr = &inventory[item];
3054 /* Get the item (on the floor) */
3057 o_ptr = &o_list[0 - item];
3062 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3064 /* Extract the flags */
3065 object_flags(o_ptr, flgs);
3067 if (object_is_cursed(o_ptr))
3069 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3070 have_flag(flgs, TR_ADD_L_CURSE) ||
3071 have_flag(flgs, TR_ADD_H_CURSE) ||
3072 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3075 msg_format("%sを覆う黒いオーラは祝福を跳ね返した!",
3078 msg_format("The black aura on %s %s disrupts the blessing!",
3079 ((item >= 0) ? "your" : "the"), o_name);
3086 msg_format("%s から邪悪なオーラが消えた。",
3089 msg_format("A malignant aura leaves %s %s.",
3090 ((item >= 0) ? "your" : "the"), o_name);
3095 o_ptr->curse_flags = 0L;
3097 /* Hack -- Assume felt */
3098 o_ptr->ident |= (IDENT_SENSE);
3101 o_ptr->feeling = FEEL_NONE;
3103 /* Recalculate the bonuses */
3104 p_ptr->update |= (PU_BONUS);
3107 p_ptr->window |= (PW_EQUIP);
3111 * Next, we try to bless it. Artifacts have a 1/3 chance of
3112 * being blessed, otherwise, the operation simply disenchants
3113 * them, godly power negating the magic. Ok, the explanation
3114 * is silly, but otherwise priests would always bless every
3115 * artifact weapon they find. Ego weapons and normal weapons
3116 * can be blessed automatically.
3118 if (have_flag(flgs, TR_BLESSED))
3121 msg_format("%s は既に祝福されている。",
3124 msg_format("%s %s %s blessed already.",
3125 ((item >= 0) ? "Your" : "The"), o_name,
3126 ((o_ptr->number > 1) ? "were" : "was"));
3132 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3136 msg_format("%sは輝いた!",
3139 msg_format("%s %s shine%s!",
3140 ((item >= 0) ? "Your" : "The"), o_name,
3141 ((o_ptr->number > 1) ? "" : "s"));
3144 add_flag(o_ptr->art_flags, TR_BLESSED);
3145 o_ptr->discount = 99;
3149 bool dis_happened = FALSE;
3150 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
3152 /* Disenchant tohit */
3153 if (o_ptr->to_h > 0)
3156 dis_happened = TRUE;
3159 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3161 /* Disenchant todam */
3162 if (o_ptr->to_d > 0)
3165 dis_happened = TRUE;
3168 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3170 /* Disenchant toac */
3171 if (o_ptr->to_a > 0)
3174 dis_happened = TRUE;
3177 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3181 msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
3184 msg_format("%s は劣化した!",
3187 msg_format("%s %s %s disenchanted!",
3188 ((item >= 0) ? "Your" : "The"), o_name,
3189 ((o_ptr->number > 1) ? "were" : "was"));
3195 /* Recalculate bonuses */
3196 p_ptr->update |= (PU_BONUS);
3199 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3210 bool pulish_shield(void)
3214 u32b flgs[TR_FLAG_SIZE];
3215 char o_name[MAX_NLEN];
3218 item_tester_no_ryoute = TRUE;
3219 /* Assume enchant weapon */
3220 item_tester_tval = TV_SHIELD;
3223 q = _("どの盾を磨きますか?", "Pulish which weapon? ");
3224 s = _("磨く盾がありません。", "You have weapon to pulish.");
3226 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3229 /* Get the item (in the pack) */
3232 o_ptr = &inventory[item];
3235 /* Get the item (on the floor) */
3238 o_ptr = &o_list[0 - item];
3243 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3245 /* Extract the flags */
3246 object_flags(o_ptr, flgs);
3248 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3249 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3252 msg_format("%sは輝いた!", o_name);
3254 msg_format("%s %s shine%s!",
3255 ((item >= 0) ? "Your" : "The"), o_name,
3256 ((o_ptr->number > 1) ? "" : "s"));
3258 o_ptr->name2 = EGO_REFLECTION;
3259 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3261 o_ptr->discount = 99;
3262 chg_virtue(V_ENCHANT, 2);
3268 if (flush_failure) flush();
3270 msg_print(_("失敗した。", "Failed."));
3271 chg_virtue(V_ENCHANT, -2);
3280 * Potions "smash open" and cause an area effect when
3281 * (1) they are shattered while in the player's inventory,
3282 * due to cold (etc) attacks;
3283 * (2) they are thrown at a monster, or obstacle;
3284 * (3) they are shattered by a "cold ball" or other such spell
3285 * while lying on the floor.
3288 * who --- who caused the potion to shatter (0=player)
3289 * potions that smash on the floor are assumed to
3290 * be caused by no-one (who = 1), as are those that
3291 * shatter inside the player inventory.
3292 * (Not anymore -- I changed this; TY)
3293 * y, x --- coordinates of the potion (or player if
3294 * the potion was in her inventory);
3295 * o_ptr --- pointer to the potion object.
3297 bool potion_smash_effect(int who, int y, int x, int k_idx)
3304 object_kind *k_ptr = &k_info[k_idx];
3306 switch (k_ptr->sval)
3308 case SV_POTION_SALT_WATER:
3309 case SV_POTION_SLIME_MOLD:
3310 case SV_POTION_LOSE_MEMORIES:
3311 case SV_POTION_DEC_STR:
3312 case SV_POTION_DEC_INT:
3313 case SV_POTION_DEC_WIS:
3314 case SV_POTION_DEC_DEX:
3315 case SV_POTION_DEC_CON:
3316 case SV_POTION_DEC_CHR:
3317 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3318 case SV_POTION_APPLE_JUICE:
3321 case SV_POTION_INFRAVISION:
3322 case SV_POTION_DETECT_INVIS:
3323 case SV_POTION_SLOW_POISON:
3324 case SV_POTION_CURE_POISON:
3325 case SV_POTION_BOLDNESS:
3326 case SV_POTION_RESIST_HEAT:
3327 case SV_POTION_RESIST_COLD:
3328 case SV_POTION_HEROISM:
3329 case SV_POTION_BESERK_STRENGTH:
3330 case SV_POTION_RES_STR:
3331 case SV_POTION_RES_INT:
3332 case SV_POTION_RES_WIS:
3333 case SV_POTION_RES_DEX:
3334 case SV_POTION_RES_CON:
3335 case SV_POTION_RES_CHR:
3336 case SV_POTION_INC_STR:
3337 case SV_POTION_INC_INT:
3338 case SV_POTION_INC_WIS:
3339 case SV_POTION_INC_DEX:
3340 case SV_POTION_INC_CON:
3341 case SV_POTION_INC_CHR:
3342 case SV_POTION_AUGMENTATION:
3343 case SV_POTION_ENLIGHTENMENT:
3344 case SV_POTION_STAR_ENLIGHTENMENT:
3345 case SV_POTION_SELF_KNOWLEDGE:
3346 case SV_POTION_EXPERIENCE:
3347 case SV_POTION_RESISTANCE:
3348 case SV_POTION_INVULNERABILITY:
3349 case SV_POTION_NEW_LIFE:
3350 /* All of the above potions have no effect when shattered */
3352 case SV_POTION_SLOWNESS:
3357 case SV_POTION_POISON:
3362 case SV_POTION_BLINDNESS:
3366 case SV_POTION_CONFUSION: /* Booze */
3370 case SV_POTION_SLEEP:
3374 case SV_POTION_RUINATION:
3375 case SV_POTION_DETONATIONS:
3377 dam = damroll(25, 25);
3380 case SV_POTION_DEATH:
3381 dt = GF_DEATH_RAY; /* !! */
3382 dam = k_ptr->level * 10;
3386 case SV_POTION_SPEED:
3389 case SV_POTION_CURE_LIGHT:
3391 dam = damroll(2, 3);
3393 case SV_POTION_CURE_SERIOUS:
3395 dam = damroll(4, 3);
3397 case SV_POTION_CURE_CRITICAL:
3398 case SV_POTION_CURING:
3400 dam = damroll(6, 3);
3402 case SV_POTION_HEALING:
3404 dam = damroll(10, 10);
3406 case SV_POTION_RESTORE_EXP:
3411 case SV_POTION_LIFE:
3413 dam = damroll(50, 50);
3416 case SV_POTION_STAR_HEALING:
3418 dam = damroll(50, 50);
3421 case SV_POTION_RESTORE_MANA: /* MANA */
3423 dam = damroll(10, 10);
3430 (void)project(who, radius, y, x, dam, dt,
3431 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3433 /* XXX those potions that explode need to become "known" */
3439 * Hack -- Display all known spells in a window
3441 * XXX XXX XXX Need to analyze size of the window.
3443 * XXX XXX XXX Need more color coding.
3445 void display_spell_list(void)
3450 const magic_type *s_ptr;
3458 /* They have too many spells to list */
3459 if (p_ptr->pclass == CLASS_SORCERER) return;
3460 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3463 if (p_ptr->pclass == CLASS_SNIPER)
3465 display_snipe_list();
3469 /* mind.c type classes */
3470 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3471 (p_ptr->pclass == CLASS_BERSERKER) ||
3472 (p_ptr->pclass == CLASS_NINJA) ||
3473 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3474 (p_ptr->pclass == CLASS_FORCETRAINER))
3480 int plev = p_ptr->lev;
3486 bool use_hp = FALSE;
3488 /* Display a list of spells */
3490 put_str(_("名前", "Name"), y, x + 5);
3491 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
3493 switch(p_ptr->pclass)
3495 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3496 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3497 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3498 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3499 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3500 default: use_mind = 0;break;
3503 /* Dump the spells */
3504 for (i = 0; i < MAX_MIND_POWERS; i++)
3506 byte a = TERM_WHITE;
3508 /* Access the available spell */
3509 spell = mind_powers[use_mind].info[i];
3510 if (spell.min_lev > plev) break;
3512 /* Get the failure rate */
3513 chance = spell.fail;
3515 /* Reduce failure rate by "effective" level adjustment */
3516 chance -= 3 * (p_ptr->lev - spell.min_lev);
3518 /* Reduce failure rate by INT/WIS adjustment */
3519 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3523 /* Not enough mana to cast */
3524 if (spell.mana_cost > p_ptr->csp)
3526 chance += 5 * (spell.mana_cost - p_ptr->csp);
3532 /* Not enough hp to cast */
3533 if (spell.mana_cost > p_ptr->chp)
3540 /* Extract the minimum failure rate */
3541 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3543 /* Minimum failure rate */
3544 if (chance < minfail) chance = minfail;
3546 /* Stunning makes spells harder */
3547 if (p_ptr->stun > 50) chance += 25;
3548 else if (p_ptr->stun) chance += 15;
3550 /* Always a 5 percent chance of working */
3551 if (chance > 95) chance = 95;
3554 mindcraft_info(comment, use_mind, i);
3556 /* Dump the spell */
3557 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3559 spell.min_lev, spell.mana_cost, chance, comment);
3561 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3566 /* Cannot read spellbooks */
3567 if (REALM_NONE == p_ptr->realm1) return;
3569 /* Normal spellcaster with books */
3572 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3576 /* Reset vertical */
3579 /* Vertical location */
3580 y = (j < 3) ? 0 : (m[j - 3] + 2);
3582 /* Horizontal location */
3586 for (i = 0; i < 32; i++)
3588 byte a = TERM_WHITE;
3590 /* Access the spell */
3591 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3593 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3597 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3600 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
3603 if (s_ptr->slevel >= 99)
3606 strcpy(name, _("(判読不能)", "(illegible)"));
3614 ((p_ptr->spell_forgotten1 & (1L << i))) :
3615 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3622 else if (!((j < 1) ?
3623 (p_ptr->spell_learned1 & (1L << i)) :
3624 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3631 else if (!((j < 1) ?
3632 (p_ptr->spell_worked1 & (1L << i)) :
3633 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3639 /* Dump the spell --(-- */
3640 sprintf(out_val, "%c/%c) %-20.20s",
3641 I2A(n / 8), I2A(n % 8), name);
3646 /* Dump onto the window */
3647 Term_putstr(x, m[j], -1, a, out_val);
3657 * Returns experience of a spell
3659 s16b experience_of_spell(int spell, int use_realm)
3661 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3662 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3663 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3664 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3670 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3672 int mod_need_mana(int need_mana, int spell, int realm)
3674 #define MANA_CONST 2400
3676 #define DEC_MANA_DIV 3
3679 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
3682 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
3683 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
3685 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
3686 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
3687 need_mana /= MANA_CONST * MANA_DIV;
3688 if (need_mana < 1) need_mana = 1;
3691 /* Non-realm magic */
3694 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
3706 * Modify spell fail rate
3707 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3709 int mod_spell_chance_1(int chance)
3711 chance += p_ptr->to_m_chance;
3713 if (p_ptr->heavy_spell) chance += 20;
3715 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
3716 else if (p_ptr->easy_spell) chance -= 3;
3717 else if (p_ptr->dec_mana) chance -= 2;
3724 * Modify spell fail rate (as "suffix" process)
3725 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3726 * Note: variable "chance" cannot be negative.
3728 int mod_spell_chance_2(int chance)
3730 if (p_ptr->dec_mana) chance--;
3732 if (p_ptr->heavy_spell) chance += 5;
3734 return MAX(chance, 0);
3739 * Returns spell chance of failure for spell -RAK-
3741 s16b spell_chance(int spell, int use_realm)
3743 int chance, minfail;
3744 const magic_type *s_ptr;
3746 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
3749 /* Paranoia -- must be literate */
3750 if (!mp_ptr->spell_book) return (100);
3752 if (use_realm == REALM_HISSATSU) return 0;
3754 /* Access the spell */
3755 if (!is_magic(use_realm))
3757 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3761 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3764 /* Extract the base spell failure rate */
3765 chance = s_ptr->sfail;
3767 /* Reduce failure rate by "effective" level adjustment */
3768 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
3770 /* Reduce failure rate by INT/WIS adjustment */
3771 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3774 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
3776 /* Extract mana consumption rate */
3777 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3779 /* Not enough mana to cast */
3780 if (need_mana > p_ptr->csp)
3782 chance += 5 * (need_mana - p_ptr->csp);
3785 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
3787 /* Extract the minimum failure rate */
3788 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3791 * Non mage/priest characters never get too good
3792 * (added high mage, mindcrafter)
3794 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
3796 if (minfail < 5) minfail = 5;
3799 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
3800 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3801 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
3803 chance = mod_spell_chance_1(chance);
3805 /* Goodness or evilness gives a penalty to failure rate */
3809 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3811 case REALM_LIFE: case REALM_CRUSADE:
3812 if (p_ptr->align < -20) chance += penalty;
3814 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3815 if (p_ptr->align > 20) chance += penalty;
3819 /* Minimum failure rate */
3820 if (chance < minfail) chance = minfail;
3822 /* Stunning makes spells harder */
3823 if (p_ptr->stun > 50) chance += 25;
3824 else if (p_ptr->stun) chance += 15;
3826 /* Always a 5 percent chance of working */
3827 if (chance > 95) chance = 95;
3829 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3830 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3832 s16b exp = experience_of_spell(spell, use_realm);
3833 if (exp >= SPELL_EXP_EXPERT) chance--;
3834 if (exp >= SPELL_EXP_MASTER) chance--;
3837 /* Return the chance */
3838 return mod_spell_chance_2(chance);
3844 * Determine if a spell is "okay" for the player to cast or study
3845 * The spell must be legible, not forgotten, and also, to cast,
3846 * it must be known, and to study, it must not be known.
3848 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
3850 const magic_type *s_ptr;
3852 /* Access the spell */
3853 if (!is_magic(use_realm))
3855 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3859 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3862 /* Spell is illegal */
3863 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
3865 /* Spell is forgotten */
3866 if ((use_realm == p_ptr->realm2) ?
3867 (p_ptr->spell_forgotten2 & (1L << spell)) :
3868 (p_ptr->spell_forgotten1 & (1L << spell)))
3874 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
3875 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
3877 /* Spell is learned */
3878 if ((use_realm == p_ptr->realm2) ?
3879 (p_ptr->spell_learned2 & (1L << spell)) :
3880 (p_ptr->spell_learned1 & (1L << spell)))
3883 return (!study_pray);
3886 /* Okay to study, not to cast */
3892 * Print a list of spells (for browsing or casting or viewing)
3894 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
3896 int i, spell, exp_level, increment = 64;
3897 const magic_type *s_ptr;
3908 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
3909 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
3911 /* Title the list */
3913 if (use_realm == REALM_HISSATSU)
3914 strcpy(buf,_(" Lv MP", " Lv SP"));
3916 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
3918 put_str(_("名前", "Name"), y, x + 5);
3919 put_str(buf, y, x + 29);
3921 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
3922 else if (use_realm == p_ptr->realm1) increment = 0;
3923 else if (use_realm == p_ptr->realm2) increment = 32;
3925 /* Dump the spells */
3926 for (i = 0; i < num; i++)
3928 /* Access the spell */
3931 /* Access the spell */
3932 if (!is_magic(use_realm))
3934 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3938 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3941 if (use_realm == REALM_HISSATSU)
3942 need_mana = s_ptr->smana;
3945 s16b exp = experience_of_spell(spell, use_realm);
3947 /* Extract mana consumption rate */
3948 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3950 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
3951 else exp_level = spell_exp_level(exp);
3954 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
3955 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
3956 else if (s_ptr->slevel >= 99) max = TRUE;
3957 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
3959 strncpy(ryakuji, exp_level_str[exp_level], 4);
3964 if (use_menu && target_spell)
3966 if (i == (target_spell-1))
3967 strcpy(out_val, _(" 》 ", " > "));
3969 strcpy(out_val, " ");
3971 else sprintf(out_val, " %c) ", I2A(i));
3972 /* Skip illegible spells */
3973 if (s_ptr->slevel >= 99)
3975 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
3976 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
3980 /* XXX XXX Could label spells above the players level */
3982 /* Get extra info */
3983 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
3988 /* Assume spell is known and tried */
3989 line_attr = TERM_WHITE;
3991 /* Analyze the spell */
3992 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3994 if (s_ptr->slevel > p_ptr->max_plv)
3996 comment = _("未知", "unknown");
3997 line_attr = TERM_L_BLUE;
3999 else if (s_ptr->slevel > p_ptr->lev)
4001 comment = _("忘却", "forgotten");
4002 line_attr = TERM_YELLOW;
4005 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4007 comment = _("未知", "unknown");
4008 line_attr = TERM_L_BLUE;
4010 else if ((use_realm == p_ptr->realm1) ?
4011 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4012 ((p_ptr->spell_forgotten2 & (1L << spell))))
4014 comment = _("忘却", "forgotten");
4015 line_attr = TERM_YELLOW;
4017 else if (!((use_realm == p_ptr->realm1) ?
4018 (p_ptr->spell_learned1 & (1L << spell)) :
4019 (p_ptr->spell_learned2 & (1L << spell))))
4021 comment = _("未知", "unknown");
4022 line_attr = TERM_L_BLUE;
4024 else if (!((use_realm == p_ptr->realm1) ?
4025 (p_ptr->spell_worked1 & (1L << spell)) :
4026 (p_ptr->spell_worked2 & (1L << spell))))
4028 comment = _("未経験", "untried");
4029 line_attr = TERM_L_GREEN;
4032 /* Dump the spell --(-- */
4033 if (use_realm == REALM_HISSATSU)
4035 strcat(out_val, format("%-25s %2d %4d",
4036 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4037 s_ptr->slevel, need_mana));
4041 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4042 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4043 (max ? '!' : ' '), ryakuji,
4044 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4046 c_prt(line_attr, out_val, y + i + 1, x);
4049 /* Clear the bottom line */
4050 prt("", y + i + 1, x);
4055 * Note that amulets, rods, and high-level spell books are immune
4056 * to "inventory damage" of any kind. Also sling ammo and shovels.
4061 * Does a given class of objects (usually) hate acid?
4062 * Note that acid can either melt or corrode something.
4064 bool hates_acid(object_type *o_ptr)
4066 /* Analyze the type */
4067 switch (o_ptr->tval)
4069 /* Wearable items */
4089 /* Staffs/Scrolls are wood/paper */
4102 /* Junk is useless */
4116 * Does a given object (usually) hate electricity?
4118 bool hates_elec(object_type *o_ptr)
4120 switch (o_ptr->tval)
4134 * Does a given object (usually) hate fire?
4135 * Hafted/Polearm weapons have wooden shafts.
4136 * Arrows/Bows are mostly wooden.
4138 bool hates_fire(object_type *o_ptr)
4140 /* Analyze the type */
4141 switch (o_ptr->tval)
4159 case TV_SORCERY_BOOK:
4160 case TV_NATURE_BOOK:
4164 case TV_ARCANE_BOOK:
4166 case TV_DAEMON_BOOK:
4167 case TV_CRUSADE_BOOK:
4169 case TV_HISSATSU_BOOK:
4181 /* Staffs/Scrolls burn */
4194 * Does a given object (usually) hate cold?
4196 bool hates_cold(object_type *o_ptr)
4198 switch (o_ptr->tval)
4215 int set_acid_destroy(object_type *o_ptr)
4217 u32b flgs[TR_FLAG_SIZE];
4218 if (!hates_acid(o_ptr)) return (FALSE);
4219 object_flags(o_ptr, flgs);
4220 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4228 int set_elec_destroy(object_type *o_ptr)
4230 u32b flgs[TR_FLAG_SIZE];
4231 if (!hates_elec(o_ptr)) return (FALSE);
4232 object_flags(o_ptr, flgs);
4233 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4241 int set_fire_destroy(object_type *o_ptr)
4243 u32b flgs[TR_FLAG_SIZE];
4244 if (!hates_fire(o_ptr)) return (FALSE);
4245 object_flags(o_ptr, flgs);
4246 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4254 int set_cold_destroy(object_type *o_ptr)
4256 u32b flgs[TR_FLAG_SIZE];
4257 if (!hates_cold(o_ptr)) return (FALSE);
4258 object_flags(o_ptr, flgs);
4259 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4265 * Destroys a type of item on a given percent chance
4266 * Note that missiles are no longer necessarily all destroyed
4267 * Destruction taken from "melee.c" code for "stealing".
4268 * New-style wands and rods handled correctly. -LM-
4269 * Returns number of items destroyed.
4271 int inven_damage(inven_func typ, int perc)
4275 char o_name[MAX_NLEN];
4277 if (CHECK_MULTISHADOW()) return 0;
4279 if (p_ptr->inside_arena) return 0;
4281 /* Count the casualties */
4284 /* Scan through the slots backwards */
4285 for (i = 0; i < INVEN_PACK; i++)
4287 o_ptr = &inventory[i];
4289 /* Skip non-objects */
4290 if (!o_ptr->k_idx) continue;
4292 /* Hack -- for now, skip artifacts */
4293 if (object_is_artifact(o_ptr)) continue;
4295 /* Give this item slot a shot at death */
4298 /* Count the casualties */
4299 for (amt = j = 0; j < o_ptr->number; ++j)
4301 if (randint0(100) < perc) amt++;
4304 /* Some casualities */
4307 /* Get a description */
4308 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4311 msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
4314 o_name, index_to_label(i),
4315 ((o_ptr->number > 1) ?
4316 ((amt == o_ptr->number) ? "全部" :
4317 (amt > 1 ? "何個か" : "一個")) : "") );
4319 ((o_ptr->number > 1) ?
4320 ((amt == o_ptr->number) ? "All of y" :
4321 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4322 o_name, index_to_label(i),
4323 ((amt > 1) ? "were" : "was"));
4327 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4328 msg_print("やりやがったな!");
4331 /* Potions smash open */
4332 if (object_is_potion(o_ptr))
4334 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
4337 /* Reduce the charges of rods/wands */
4338 reduce_charges(o_ptr, amt);
4340 /* Destroy "amt" items */
4341 inven_item_increase(i, -amt);
4342 inven_item_optimize(i);
4344 /* Count the casualties */
4350 /* Return the casualty count */
4356 * Acid has hit the player, attempt to affect some armor.
4358 * Note that the "base armor" of an object never changes.
4360 * If any armor is damaged (or resists), the player takes less damage.
4362 static int minus_ac(void)
4364 object_type *o_ptr = NULL;
4365 u32b flgs[TR_FLAG_SIZE];
4366 char o_name[MAX_NLEN];
4369 /* Pick a (possibly empty) inventory slot */
4370 switch (randint1(7))
4372 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4373 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4374 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4375 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4376 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4377 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4378 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4381 /* Nothing to damage */
4382 if (!o_ptr->k_idx) return (FALSE);
4384 if (!object_is_armour(o_ptr)) return (FALSE);
4386 /* No damage left to be done */
4387 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4391 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4393 /* Extract the flags */
4394 object_flags(o_ptr, flgs);
4396 /* Object resists */
4397 if (have_flag(flgs, TR_IGNORE_ACID))
4399 msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), o_name);
4404 msg_format(_("%sがダメージを受けた!", "Your %s is damaged!"), o_name);
4406 /* Damage the item */
4409 /* Calculate bonuses */
4410 p_ptr->update |= (PU_BONUS);
4413 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4417 /* Item was damaged */
4423 * Hurt the player with Acid
4425 int acid_dam(int dam, cptr kb_str, int monspell, bool aura)
4428 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4429 bool double_resist = IS_OPPOSE_ACID();
4431 /* Total Immunity */
4432 if (p_ptr->immune_acid || (dam <= 0))
4434 learn_spell(monspell);
4438 /* Vulnerability (Ouch!) */
4439 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4440 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4442 /* Resist the damage */
4443 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
4444 if (double_resist) dam = (dam + 2) / 3;
4446 if (aura || !CHECK_MULTISHADOW())
4448 if ((!(double_resist || p_ptr->resist_acid)) &&
4449 one_in_(HURT_CHANCE))
4450 (void)do_dec_stat(A_CHR);
4452 /* If any armor gets hit, defend the player */
4453 if (minus_ac()) dam = (dam + 1) / 2;
4457 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4459 /* Inventory damage */
4460 if (!aura && !(double_resist && p_ptr->resist_acid))
4461 inven_damage(set_acid_destroy, inv);
4467 * Hurt the player with electricity
4469 int elec_dam(int dam, cptr kb_str, int monspell, bool aura)
4472 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4473 bool double_resist = IS_OPPOSE_ELEC();
4475 /* Total immunity */
4476 if (p_ptr->immune_elec || (dam <= 0))
4478 learn_spell(monspell);
4482 /* Vulnerability (Ouch!) */
4483 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4484 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4485 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
4487 /* Resist the damage */
4488 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
4489 if (double_resist) dam = (dam + 2) / 3;
4491 if (aura || !CHECK_MULTISHADOW())
4493 if ((!(double_resist || p_ptr->resist_elec)) &&
4494 one_in_(HURT_CHANCE))
4495 (void)do_dec_stat(A_DEX);
4499 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4501 /* Inventory damage */
4502 if (!aura && !(double_resist && p_ptr->resist_elec))
4503 inven_damage(set_elec_destroy, inv);
4510 * Hurt the player with Fire
4512 int fire_dam(int dam, cptr kb_str, int monspell, bool aura)
4515 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4516 bool double_resist = IS_OPPOSE_FIRE();
4518 /* Totally immune */
4519 if (p_ptr->immune_fire || (dam <= 0))
4521 learn_spell(monspell);
4525 /* Vulnerability (Ouch!) */
4526 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4527 if (prace_is_(RACE_ENT)) dam += dam / 3;
4528 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4530 /* Resist the damage */
4531 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
4532 if (double_resist) dam = (dam + 2) / 3;
4534 if (aura || !CHECK_MULTISHADOW())
4536 if ((!(double_resist || p_ptr->resist_fire)) &&
4537 one_in_(HURT_CHANCE))
4538 (void)do_dec_stat(A_STR);
4542 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4544 /* Inventory damage */
4545 if (!aura && !(double_resist && p_ptr->resist_fire))
4546 inven_damage(set_fire_destroy, inv);
4553 * Hurt the player with Cold
4555 int cold_dam(int dam, cptr kb_str, int monspell, bool aura)
4558 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4559 bool double_resist = IS_OPPOSE_COLD();
4561 /* Total immunity */
4562 if (p_ptr->immune_cold || (dam <= 0))
4564 learn_spell(monspell);
4568 /* Vulnerability (Ouch!) */
4569 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4570 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4572 /* Resist the damage */
4573 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
4574 if (double_resist) dam = (dam + 2) / 3;
4576 if (aura || !CHECK_MULTISHADOW())
4578 if ((!(double_resist || p_ptr->resist_cold)) &&
4579 one_in_(HURT_CHANCE))
4580 (void)do_dec_stat(A_STR);
4584 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4586 /* Inventory damage */
4587 if (!aura && !(double_resist && p_ptr->resist_cold))
4588 inven_damage(set_cold_destroy, inv);
4594 bool rustproof(void)
4598 char o_name[MAX_NLEN];
4601 item_tester_no_ryoute = TRUE;
4602 /* Select a piece of armour */
4603 item_tester_hook = object_is_armour;
4606 q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
4607 s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
4609 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
4611 /* Get the item (in the pack) */
4614 o_ptr = &inventory[item];
4617 /* Get the item (on the floor) */
4620 o_ptr = &o_list[0 - item];
4625 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4627 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
4629 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
4632 msg_format("%sは新品同様になった!",o_name);
4634 msg_format("%s %s look%s as good as new!",
4635 ((item >= 0) ? "Your" : "The"), o_name,
4636 ((o_ptr->number > 1) ? "" : "s"));
4643 msg_format("%sは腐食しなくなった。", o_name);
4645 msg_format("%s %s %s now protected against corrosion.",
4646 ((item >= 0) ? "Your" : "The"), o_name,
4647 ((o_ptr->number > 1) ? "are" : "is"));
4658 * Curse the players armor
4660 bool curse_armor(void)
4665 char o_name[MAX_NLEN];
4668 /* Curse the body armor */
4669 o_ptr = &inventory[INVEN_BODY];
4671 /* Nothing to curse */
4672 if (!o_ptr->k_idx) return (FALSE);
4676 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4678 /* Attempt a saving throw for artifacts */
4679 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
4683 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
4684 "恐怖の暗黒オーラ", "防具", o_name);
4686 msg_format("A %s tries to %s, but your %s resists the effects!",
4687 "terrible black aura", "surround your armor", o_name);
4692 /* not artifact or failed save... */
4696 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4697 chg_virtue(V_ENCHANT, -5);
4699 /* Blast the armor */
4701 o_ptr->name2 = EGO_BLASTED;
4702 o_ptr->to_a = 0 - randint1(5) - randint1(5);
4709 for (i = 0; i < TR_FLAG_SIZE; i++)
4710 o_ptr->art_flags[i] = 0;
4713 o_ptr->curse_flags = TRC_CURSED;
4716 o_ptr->ident |= (IDENT_BROKEN);
4718 /* Recalculate bonuses */
4719 p_ptr->update |= (PU_BONUS);
4721 /* Recalculate mana */
4722 p_ptr->update |= (PU_MANA);
4725 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
4733 * Curse the players weapon
4735 bool curse_weapon_object(bool force, object_type *o_ptr)
4738 char o_name[MAX_NLEN];
4740 /* Nothing to curse */
4741 if (!o_ptr->k_idx) return (FALSE);
4744 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4746 /* Attempt a saving throw */
4747 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
4751 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
4752 "恐怖の暗黒オーラ", "武器", o_name);
4754 msg_format("A %s tries to %s, but your %s resists the effects!",
4755 "terrible black aura", "surround your weapon", o_name);
4759 /* not artifact or failed save... */
4763 if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4764 chg_virtue(V_ENCHANT, -5);
4766 /* Shatter the weapon */
4768 o_ptr->name2 = EGO_SHATTERED;
4769 o_ptr->to_h = 0 - randint1(5) - randint1(5);
4770 o_ptr->to_d = 0 - randint1(5) - randint1(5);
4776 for (i = 0; i < TR_FLAG_SIZE; i++)
4777 o_ptr->art_flags[i] = 0;
4780 o_ptr->curse_flags = TRC_CURSED;
4783 o_ptr->ident |= (IDENT_BROKEN);
4785 /* Recalculate bonuses */
4786 p_ptr->update |= (PU_BONUS);
4788 /* Recalculate mana */
4789 p_ptr->update |= (PU_MANA);
4792 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
4799 bool curse_weapon(bool force, int slot)
4801 /* Curse the weapon */
4802 return curse_weapon_object(force, &inventory[slot]);
4807 * Enchant some bolts
4809 bool brand_bolts(void)
4813 /* Use the first acceptable bolts */
4814 for (i = 0; i < INVEN_PACK; i++)
4816 object_type *o_ptr = &inventory[i];
4818 /* Skip non-bolts */
4819 if (o_ptr->tval != TV_BOLT) continue;
4821 /* Skip artifacts and ego-items */
4822 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
4825 /* Skip cursed/broken items */
4826 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
4829 if (randint0(100) < 75) continue;
4832 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
4835 o_ptr->name2 = EGO_FLAME;
4838 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
4845 if (flush_failure) flush();
4848 msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
4856 * Helper function -- return a "nearby" race for polymorphing
4858 * Note that this function is one of the more "dangerous" ones...
4860 static s16b poly_r_idx(int r_idx)
4862 monster_race *r_ptr = &r_info[r_idx];
4864 int i, r, lev1, lev2;
4866 /* Hack -- Uniques/Questors never polymorph */
4867 if ((r_ptr->flags1 & RF1_UNIQUE) ||
4868 (r_ptr->flags1 & RF1_QUESTOR))
4871 /* Allowable range of "levels" for resulting monster */
4872 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
4873 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
4875 /* Pick a (possibly new) non-unique race */
4876 for (i = 0; i < 1000; i++)
4878 /* Pick a new race, using a level calculation */
4879 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
4881 /* Handle failure */
4887 /* Ignore unique monsters */
4888 if (r_ptr->flags1 & RF1_UNIQUE) continue;
4890 /* Ignore monsters with incompatible levels */
4891 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
4893 /* Use that index */
4905 bool polymorph_monster(int y, int x)
4907 cave_type *c_ptr = &cave[y][x];
4908 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4909 bool polymorphed = FALSE;
4911 int old_r_idx = m_ptr->r_idx;
4912 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
4913 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
4914 monster_type back_m;
4916 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
4918 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
4920 /* Memorize the monster before polymorphing */
4923 /* Pick a "new" monster race */
4924 new_r_idx = poly_r_idx(old_r_idx);
4926 /* Handle polymorph */
4927 if (new_r_idx != old_r_idx)
4930 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
4931 s16b this_o_idx, next_o_idx = 0;
4933 /* Get the monsters attitude */
4934 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
4935 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
4936 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
4938 /* Mega-hack -- ignore held objects */
4939 m_ptr->hold_o_idx = 0;
4941 /* "Kill" the "old" monster */
4942 delete_monster_idx(c_ptr->m_idx);
4944 /* Create a new monster (no groups) */
4945 if (place_monster_aux(0, y, x, new_r_idx, mode))
4947 m_list[hack_m_idx_ii].nickname = back_m.nickname;
4948 m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
4949 m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
4956 /* Placing the new monster failed */
4957 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
4959 m_list[hack_m_idx_ii] = back_m;
4961 /* Re-initialize monster process */
4964 else preserve_hold_objects = FALSE;
4967 /* Mega-hack -- preserve held objects */
4968 if (preserve_hold_objects)
4970 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4972 /* Acquire object */
4973 object_type *o_ptr = &o_list[this_o_idx];
4975 /* Acquire next object */
4976 next_o_idx = o_ptr->next_o_idx;
4978 /* Held by new monster */
4979 o_ptr->held_m_idx = hack_m_idx_ii;
4982 else if (back_m.hold_o_idx) /* Failed (paranoia) */
4984 /* Delete objects */
4985 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4987 /* Acquire next object */
4988 next_o_idx = o_list[this_o_idx].next_o_idx;
4990 /* Delete the object */
4991 delete_object_idx(this_o_idx);
4995 if (targeted) target_who = hack_m_idx_ii;
4996 if (health_tracked) health_track(hack_m_idx_ii);
5006 static bool dimension_door_aux(int x, int y)
5008 int plev = p_ptr->lev;
5010 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5012 if (!cave_player_teleportable_bold(y, x, 0L) ||
5013 (distance(y, x, py, px) > plev / 2 + 10) ||
5014 (!randint0(plev / 10 + 10)))
5016 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5017 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
5024 teleport_player_to(y, x, 0L);
5035 bool dimension_door(void)
5039 /* Rerutn FALSE if cancelled */
5040 if (!tgt_pt(&x, &y)) return FALSE;
5042 if (dimension_door_aux(x, y)) return TRUE;
5044 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
5051 * Mirror Master's Dimension Door
5053 bool mirror_tunnel(void)
5057 /* Rerutn FALSE if cancelled */
5058 if (!tgt_pt(&x, &y)) return FALSE;
5060 if (dimension_door_aux(x, y)) return TRUE;
5062 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
5068 bool eat_magic(int power)
5070 object_type * o_ptr;
5073 int recharge_strength = 0;
5079 char o_name[MAX_NLEN];
5081 item_tester_hook = item_tester_hook_recharge;
5084 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
5085 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
5087 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5091 o_ptr = &inventory[item];
5095 o_ptr = &o_list[0 - item];
5098 k_ptr = &k_info[o_ptr->k_idx];
5099 lev = k_info[o_ptr->k_idx].level;
5101 if (o_ptr->tval == TV_ROD)
5103 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5106 if (one_in_(recharge_strength))
5108 /* Activate the failure code. */
5113 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5115 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
5120 o_ptr->timeout += k_ptr->pval;
5126 /* All staffs, wands. */
5127 recharge_strength = (100 + power - lev) / 15;
5130 if (recharge_strength < 0) recharge_strength = 0;
5133 if (one_in_(recharge_strength))
5135 /* Activate the failure code. */
5140 if (o_ptr->pval > 0)
5142 p_ptr->csp += lev / 2;
5145 /* XXX Hack -- unstack if necessary */
5146 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5151 /* Get local object */
5154 /* Obtain a local object */
5155 object_copy(q_ptr, o_ptr);
5157 /* Modify quantity */
5160 /* Restore the charges */
5163 /* Unstack the used item */
5165 p_ptr->total_weight -= q_ptr->weight;
5166 item = inven_carry(q_ptr);
5169 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
5174 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
5176 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5180 /* Inflict the penalties for failing a recharge. */
5183 /* Artifacts are never destroyed. */
5184 if (object_is_fixed_artifact(o_ptr))
5186 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5187 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
5189 /* Artifact rods. */
5190 if (o_ptr->tval == TV_ROD)
5191 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5193 /* Artifact wands and staffs. */
5194 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5199 /* Get the object description */
5200 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5202 /*** Determine Seriousness of Failure ***/
5204 /* Mages recharge objects more safely. */
5205 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)
5207 /* 10% chance to blow up one rod, otherwise draining. */
5208 if (o_ptr->tval == TV_ROD)
5210 if (one_in_(10)) fail_type = 2;
5213 /* 75% chance to blow up one wand, otherwise draining. */
5214 else if (o_ptr->tval == TV_WAND)
5216 if (!one_in_(3)) fail_type = 2;
5219 /* 50% chance to blow up one staff, otherwise no effect. */
5220 else if (o_ptr->tval == TV_STAFF)
5222 if (one_in_(2)) fail_type = 2;
5227 /* All other classes get no special favors. */
5230 /* 33% chance to blow up one rod, otherwise draining. */
5231 if (o_ptr->tval == TV_ROD)
5233 if (one_in_(3)) fail_type = 2;
5236 /* 20% chance of the entire stack, else destroy one wand. */
5237 else if (o_ptr->tval == TV_WAND)
5239 if (one_in_(5)) fail_type = 3;
5242 /* Blow up one staff. */
5243 else if (o_ptr->tval == TV_STAFF)
5249 /*** Apply draining and destruction. ***/
5251 /* Drain object or stack of objects. */
5254 if (o_ptr->tval == TV_ROD)
5256 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
5257 "You save your rod from destruction, but all charges are lost."), o_name);
5258 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5260 else if (o_ptr->tval == TV_WAND)
5262 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
5265 /* Staffs aren't drained. */
5268 /* Destroy an object or one in a stack of objects. */
5271 if (o_ptr->number > 1)
5273 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
5274 /* Reduce rod stack maximum timeout, drain wands. */
5275 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5276 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5280 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
5283 /* Reduce and describe inventory */
5286 inven_item_increase(item, -1);
5287 inven_item_describe(item);
5288 inven_item_optimize(item);
5291 /* Reduce and describe floor item */
5294 floor_item_increase(0 - item, -1);
5295 floor_item_describe(0 - item);
5296 floor_item_optimize(0 - item);
5300 /* Destroy all members of a stack of objects. */
5303 if (o_ptr->number > 1)
5304 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
5306 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
5308 /* Reduce and describe inventory */
5311 inven_item_increase(item, -999);
5312 inven_item_describe(item);
5313 inven_item_optimize(item);
5316 /* Reduce and describe floor item */
5319 floor_item_increase(0 - item, -999);
5320 floor_item_describe(0 - item);
5321 floor_item_optimize(0 - item);
5327 if (p_ptr->csp > p_ptr->msp)
5329 p_ptr->csp = p_ptr->msp;
5332 /* Redraw mana and hp */
5333 p_ptr->redraw |= (PR_MANA);
5335 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5336 p_ptr->window |= (PW_INVEN);
5342 bool summon_kin_player(int level, int y, int x, u32b mode)
5344 bool pet = (bool)(mode & PM_FORCE_PET);
5345 if (!pet) mode |= PM_NO_PET;
5347 switch (p_ptr->mimic_form)
5350 switch (p_ptr->prace)
5354 case RACE_BARBARIAN:
5357 summon_kin_type = 'p';
5367 case RACE_MIND_FLAYER:
5370 summon_kin_type = 'h';
5373 summon_kin_type = 'o';
5375 case RACE_HALF_TROLL:
5376 summon_kin_type = 'T';
5378 case RACE_HALF_OGRE:
5379 summon_kin_type = 'O';
5381 case RACE_HALF_GIANT:
5382 case RACE_HALF_TITAN:
5384 summon_kin_type = 'P';
5387 summon_kin_type = 'y';
5390 summon_kin_type = 'K';
5393 summon_kin_type = 'k';
5396 if (one_in_(13)) summon_kin_type = 'U';
5397 else summon_kin_type = 'u';
5399 case RACE_DRACONIAN:
5400 summon_kin_type = 'd';
5404 summon_kin_type = 'g';
5407 if (one_in_(13)) summon_kin_type = 'L';
5408 else summon_kin_type = 's';
5411 summon_kin_type = 'z';
5414 summon_kin_type = 'V';
5417 summon_kin_type = 'G';
5420 summon_kin_type = 'I';
5423 summon_kin_type = '#';
5426 summon_kin_type = 'A';
5429 summon_kin_type = 'U';
5432 summon_kin_type = 'p';
5437 if (one_in_(13)) summon_kin_type = 'U';
5438 else summon_kin_type = 'u';
5440 case MIMIC_DEMON_LORD:
5441 summon_kin_type = 'U';
5444 summon_kin_type = 'V';
5447 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);
5450 void massacre(int py, int px)
5454 monster_type *m_ptr;
5457 for (dir = 0; dir < 8; dir++)
5459 y = py + ddy_ddd[dir];
5460 x = px + ddx_ddd[dir];
5461 c_ptr = &cave[y][x];
5463 /* Get the monster */
5464 m_ptr = &m_list[c_ptr->m_idx];
5466 /* Hack -- attack monsters */
5467 if (c_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))