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.
15 #include "object-hook.h"
17 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
22 * @brief モンスターのテレポートアウェイ処理 /
23 * Teleport a monster, normally up to "dis" grids away.
24 * @param m_idx モンスターID
27 * @return テレポートが実際に行われたらtrue
29 * Attempt to move the monster at least "dis/2" grids away.
30 * But allow variation to prevent infinite loops.
32 bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
34 POSITION oy, ox, d, i, min;
36 POSITION ny = 0, nx = 0;
40 monster_type *m_ptr = &m_list[m_idx];
43 if (!m_ptr->r_idx) return (FALSE);
45 /* Save the old location */
49 /* Minimum distance */
52 if ((mode & TELEPORT_DEC_VALOUR) &&
53 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
54 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
56 chg_virtue(V_VALOUR, -1);
64 /* Verify max distance */
65 if (dis > 200) dis = 200;
67 /* Try several locations */
68 for (i = 0; i < 500; i++)
70 /* Pick a (possibly illegal) location */
73 ny = rand_spread(oy, dis);
74 nx = rand_spread(ox, dis);
75 d = distance(oy, ox, ny, nx);
76 if ((d >= min) && (d <= dis)) break;
79 /* Ignore illegal locations */
80 if (!in_bounds(ny, nx)) continue;
82 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
84 /* No teleporting into vaults and such */
85 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
86 if (cave[ny][nx].info & CAVE_ICKY) continue;
88 /* This grid looks good */
95 /* Increase the maximum distance */
98 /* Decrease the minimum distance */
101 /* Stop after MAX_TRIES tries */
102 if (tries > MAX_TRIES) return (FALSE);
105 sound(SOUND_TPOTHER);
107 /* Update the old location */
108 cave[oy][ox].m_idx = 0;
110 /* Update the new location */
111 cave[ny][nx].m_idx = m_idx;
113 /* Move the monster */
117 /* Forget the counter target */
120 /* Update the monster (new location) */
121 update_mon(m_idx, TRUE);
123 /* Redraw the old grid */
126 /* Redraw the new grid */
129 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
130 p_ptr->update |= (PU_MON_LITE);
137 * @brief モンスターを指定された座標付近にテレポートする /
138 * Teleport monster next to a grid near the given location
139 * @param m_idx モンスターID
142 * @param power テレポート成功確率
146 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
148 POSITION ny, nx, oy, ox;
153 monster_type *m_ptr = &m_list[m_idx];
156 if(!m_ptr->r_idx) return;
159 if(randint1(100) > power) return;
165 /* Save the old location */
169 /* Minimum distance */
172 /* Look until done */
173 while (look && --attempts)
175 /* Verify max distance */
176 if (dis > 200) dis = 200;
178 /* Try several locations */
179 for (i = 0; i < 500; i++)
181 /* Pick a (possibly illegal) location */
184 ny = rand_spread(ty, dis);
185 nx = rand_spread(tx, dis);
186 d = distance(ty, tx, ny, nx);
187 if ((d >= min) && (d <= dis)) break;
190 /* Ignore illegal locations */
191 if (!in_bounds(ny, nx)) continue;
193 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
195 /* No teleporting into vaults and such */
196 /* if (cave[ny][nx].info & (CAVE_ICKY)) continue; */
198 /* This grid looks good */
205 /* Increase the maximum distance */
208 /* Decrease the minimum distance */
212 if (attempts < 1) return;
214 sound(SOUND_TPOTHER);
216 /* Update the old location */
217 cave[oy][ox].m_idx = 0;
219 /* Update the new location */
220 cave[ny][nx].m_idx = m_idx;
222 /* Move the monster */
226 /* Update the monster (new location) */
227 update_mon(m_idx, TRUE);
229 /* Redraw the old grid */
232 /* Redraw the new grid */
235 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
236 p_ptr->update |= (PU_MON_LITE);
240 * @brief プレイヤーのテレポート先選定と移動処理 /
241 * Teleport the player to a location up to "dis" grids away.
244 * @return 実際にテレポート処理が行われたらtrue
247 * If no such spaces are readily available, the distance may increase.
248 * Try very hard to move the player at least a quarter that distance.
250 * There was a nasty tendency for a long time; which was causing the
251 * player to "bounce" between two or three different spots because
252 * these are the only spots that are "far enough" way to satisfy the
255 * But this tendency is now removed; in the new algorithm, a list of
256 * candidates is selected first, which includes at least 50% of all
257 * floor grids within the distance, and any single grid in this list
258 * of candidates has equal possibility to be choosen as a destination.
262 bool teleport_player_aux(POSITION dis, BIT_FLAGS mode)
264 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
265 int total_candidates, cur_candidates;
266 POSITION y = 0, x = 0;
269 int left = MAX(1, p_ptr->x - dis);
270 int right = MIN(cur_wid - 2, p_ptr->x + dis);
271 int top = MAX(1, p_ptr->y - dis);
272 int bottom = MIN(cur_hgt - 2, p_ptr->y + dis);
274 if (p_ptr->wild_mode) return FALSE;
276 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
278 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
282 /* Initialize counters */
283 total_candidates = 0;
284 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
285 candidates_at[i] = 0;
287 /* Limit the distance */
288 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
290 /* Search valid locations */
291 for (y = top; y <= bottom; y++)
293 for (x = left; x <= right; x++)
297 /* Skip illegal locations */
298 if (!cave_player_teleportable_bold(y, x, mode)) continue;
300 /* Calculate distance */
301 d = distance(p_ptr->y, p_ptr->x, y, x);
303 /* Skip too far locations */
304 if (d > dis) continue;
306 /* Count the total number of candidates */
309 /* Count the number of candidates in this circumference */
314 /* No valid location! */
315 if (0 == total_candidates) return FALSE;
317 /* Fix the minimum distance */
318 for (cur_candidates = 0, min = dis; min >= 0; min--)
320 cur_candidates += candidates_at[min];
322 /* 50% of all candidates will have an equal chance to be choosen. */
323 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
326 /* Pick up a single location randomly */
327 pick = randint1(cur_candidates);
329 /* Search again the choosen location */
330 for (y = top; y <= bottom; y++)
332 for (x = left; x <= right; x++)
336 /* Skip illegal locations */
337 if (!cave_player_teleportable_bold(y, x, mode)) continue;
339 /* Calculate distance */
340 d = distance(p_ptr->y, p_ptr->x, y, x);
342 /* Skip too far locations */
343 if (d > dis) continue;
345 /* Skip too close locations */
346 if (d < min) continue;
348 /* This grid was picked up? */
357 if (player_bold(y, x)) return FALSE;
359 sound(SOUND_TELEPORT);
362 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
363 msg_format("『こっちだぁ、%s』", p_ptr->name);
366 /* Move the player */
367 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
373 * @brief プレイヤーのテレポート処理メインルーチン
378 void teleport_player(POSITION dis, BIT_FLAGS mode)
382 /* Save the old location */
386 if (!teleport_player_aux(dis, mode)) return;
388 /* Monsters with teleport ability may follow the player */
389 for (xx = -1; xx < 2; xx++)
391 for (yy = -1; yy < 2; yy++)
393 MONSTER_IDX tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
395 /* A monster except your mount may follow */
396 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
398 monster_type *m_ptr = &m_list[tmp_m_idx];
399 monster_race *r_ptr = &r_info[m_ptr->r_idx];
402 * The latter limitation is to avoid
403 * totally unkillable suckers...
405 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
406 !(r_ptr->flagsr & RFR_RES_TELE))
408 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
417 * @brief プレイヤーのテレポートアウェイ処理 /
418 * @param m_idx アウェイを試みたプレイヤーID
422 void teleport_player_away(MONSTER_IDX m_idx, POSITION dis)
426 /* Save the old location */
430 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
432 /* Monsters with teleport ability may follow the player */
433 for (xx = -1; xx < 2; xx++)
435 for (yy = -1; yy < 2; yy++)
437 IDX tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
439 /* A monster except your mount or caster may follow */
440 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
442 monster_type *m_ptr = &m_list[tmp_m_idx];
443 monster_race *r_ptr = &r_info[m_ptr->r_idx];
446 * The latter limitation is to avoid
447 * totally unkillable suckers...
449 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
450 !(r_ptr->flagsr & RFR_RES_TELE))
452 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
461 * @brief プレイヤーを指定位置近辺にテレポートさせる
462 * Teleport player to a grid near the given location
465 * @param mode オプションフラグ
469 * This function is slightly obsessive about correctness.
470 * This function allows teleporting into vaults (!)
473 void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
476 POSITION dis = 0, ctr = 0;
478 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
480 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
484 /* Find a usable location */
487 /* Pick a nearby legal location */
490 y = (POSITION)rand_spread(ny, dis);
491 x = (POSITION)rand_spread(nx, dis);
492 if (in_bounds(y, x)) break;
495 /* Accept any grid when wizard mode */
496 if (p_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
498 /* Accept teleportable floor grids */
499 if (cave_player_teleportable_bold(y, x, mode)) break;
501 /* Occasionally advance the distance */
502 if (++ctr > (4 * dis * dis + 4 * dis + 1))
509 sound(SOUND_TELEPORT);
511 /* Move the player */
512 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
516 void teleport_away_followable(MONSTER_IDX m_idx)
518 monster_type *m_ptr = &m_list[m_idx];
519 int oldfy = m_ptr->fy;
520 int oldfx = m_ptr->fx;
521 bool old_ml = m_ptr->ml;
522 int old_cdis = m_ptr->cdis;
524 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
526 if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && !p_ptr->inside_battle && los(p_ptr->y, p_ptr->x, oldfy, oldfx))
530 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
533 BIT_FLAGS flgs[TR_FLAG_SIZE];
537 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
539 o_ptr = &inventory[i];
540 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
542 object_flags(o_ptr, flgs);
543 if (have_flag(flgs, TR_TELEPORT))
554 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
558 teleport_player(200, TELEPORT_PASSIVE);
559 msg_print(_("失敗!", "Failed!"));
561 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
562 p_ptr->energy_need += ENERGY_NEED();
570 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
571 * Teleport the player one level up or down (random when legal)
572 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
575 void teleport_level(MONSTER_IDX m_idx)
581 if (m_idx <= 0) /* To player */
583 strcpy(m_name, _("あなた", "you"));
585 else /* To monster */
587 monster_type *m_ptr = &m_list[m_idx];
589 /* Get the monster name (or "it") */
590 monster_desc(m_name, m_ptr, 0);
592 see_m = is_seen(m_ptr);
595 /* No effect in some case */
596 if (TELE_LEVEL_IS_INEFF(m_idx))
598 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
602 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
604 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
608 /* Choose up or down */
609 if (randint0(100) < 50) go_up = TRUE;
612 if ((m_idx <= 0) && p_ptr->wizard)
614 if (get_check("Force to go up? ")) go_up = TRUE;
615 else if (get_check("Force to go down? ")) go_up = FALSE;
619 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
622 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
624 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
626 if (m_idx <= 0) /* To player */
630 dungeon_type = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
631 p_ptr->oldpy = p_ptr->y;
632 p_ptr->oldpx = p_ptr->x;
635 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
637 if (autosave_l) do_cmd_save_game(TRUE);
641 dun_level = d_info[dungeon_type].mindepth;
642 prepare_change_floor_mode(CFM_RAND_PLACE);
646 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
650 p_ptr->leaving = TRUE;
655 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
658 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
660 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
664 if (m_idx <= 0) /* To player */
666 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
668 if (autosave_l) do_cmd_save_game(TRUE);
670 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
675 p_ptr->inside_quest = 0;
676 p_ptr->leaving = TRUE;
682 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
684 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
688 if (m_idx <= 0) /* To player */
690 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
692 if (autosave_l) do_cmd_save_game(TRUE);
694 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
697 p_ptr->leaving = TRUE;
703 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
705 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
708 if (m_idx <= 0) /* To player */
710 /* Never reach this code on the surface */
711 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
713 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
715 if (autosave_l) do_cmd_save_game(TRUE);
717 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
720 p_ptr->leaving = TRUE;
724 /* Monster level teleportation is simple deleting now */
727 monster_type *m_ptr = &m_list[m_idx];
729 /* Check for quest completion */
730 check_quest_completion(m_ptr);
732 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
736 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
737 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
740 delete_monster_idx(m_idx);
743 sound(SOUND_TPLEVEL);
748 * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
749 * @param note ダンジョンに施す処理記述
752 * @return 選択されたダンジョンID
754 DUNGEON_IDX choose_dungeon(cptr note, POSITION y, POSITION x)
756 DUNGEON_IDX select_dungeon;
761 /* Hack -- No need to choose dungeon in some case */
762 if (lite_town || vanilla_town || ironman_downward)
764 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
767 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
773 /* Allocate the "dun" array */
774 C_MAKE(dun, max_d_idx, s16b);
777 for(i = 1; i < max_d_idx; i++)
782 if (!d_info[i].maxdepth) continue;
783 if (!max_dlv[i]) continue;
784 if (d_info[i].final_guardian)
786 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
788 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
790 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
791 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
792 prt(buf, y + num, x);
798 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
801 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
805 if ((i == ESCAPE) || !num)
807 /* Free the "dun" array */
808 C_KILL(dun, max_d_idx, s16b);
813 if (i >= 'a' && i <('a'+num))
815 select_dungeon = dun[i-'a'];
822 /* Free the "dun" array */
823 C_KILL(dun, max_d_idx, s16b);
825 return select_dungeon;
830 * @brief プレイヤーの帰還発動及び中止処理 /
831 * Recall the player to town or dungeon
832 * @param turns 発動までのターン数
835 bool recall_player(TIME_EFFECT turns)
838 * TODO: Recall the player to the last
839 * visited town when in the wilderness
843 if (p_ptr->inside_arena || ironman_downward)
845 msg_print(_("何も起こらなかった。", "Nothing happens."));
849 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
851 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
853 max_dlv[dungeon_type] = dun_level;
855 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, _("帰還のときに", "when recall from dungeon"));
859 if (!p_ptr->word_recall)
863 DUNGEON_IDX select_dungeon;
864 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
865 if (!select_dungeon) return FALSE;
866 p_ptr->recall_dungeon = select_dungeon;
868 p_ptr->word_recall = turns;
869 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
870 p_ptr->redraw |= (PR_STATUS);
874 p_ptr->word_recall = 0;
875 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
876 p_ptr->redraw |= (PR_STATUS);
885 bool word_of_recall(void)
887 return(recall_player(randint0(21) + 15));
892 * @return リセット処理が実際に行われたらTRUEを返す
894 bool reset_recall(void)
896 int select_dungeon, dummy = 0;
900 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
903 if (ironman_downward)
905 msg_print(_("何も起こらなかった。", "Nothing happens."));
909 if (!select_dungeon) return FALSE;
911 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
912 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
915 sprintf(tmp_val, "%d", (int)MAX(dun_level, 1));
917 /* Ask for a level */
918 if (get_string(ppp, tmp_val, 10))
920 /* Extract request */
921 dummy = atoi(tmp_val);
924 if (dummy < 1) dummy = 1;
927 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
928 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
930 max_dlv[select_dungeon] = dummy;
933 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
936 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
938 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
951 * @brief プレイヤーの装備劣化処理 /
952 * Apply disenchantment to the player's stuff
953 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
954 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
955 * Return "TRUE" if the player notices anything
957 bool apply_disenchant(BIT_FLAGS mode)
961 char o_name[MAX_NLEN];
962 int to_h, to_d, to_a, pval;
964 /* Pick a random slot */
967 case 1: t = INVEN_RARM; break;
968 case 2: t = INVEN_LARM; break;
969 case 3: t = INVEN_BOW; break;
970 case 4: t = INVEN_BODY; break;
971 case 5: t = INVEN_OUTER; break;
972 case 6: t = INVEN_HEAD; break;
973 case 7: t = INVEN_HANDS; break;
974 case 8: t = INVEN_FEET; break;
978 o_ptr = &inventory[t];
980 /* No item, nothing happens */
981 if (!o_ptr->k_idx) return (FALSE);
983 /* Disenchant equipments only -- No disenchant on monster ball */
984 if (!object_is_weapon_armour_ammo(o_ptr))
987 /* Nothing to disenchant */
988 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
990 /* Nothing to notice */
995 /* Describe the object */
996 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
999 /* Artifacts have 71% chance to resist */
1000 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1003 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1005 msg_format("Your %s (%c) resist%s disenchantment!",
1006 o_name, index_to_label(t),
1007 ((o_ptr->number != 1) ? "" : "s"));
1016 /* Memorize old value */
1022 /* Disenchant tohit */
1023 if (o_ptr->to_h > 0) o_ptr->to_h--;
1024 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1026 /* Disenchant todam */
1027 if (o_ptr->to_d > 0) o_ptr->to_d--;
1028 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1030 /* Disenchant toac */
1031 if (o_ptr->to_a > 0) o_ptr->to_a--;
1032 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1034 /* Disenchant pval (occasionally) */
1035 /* Unless called from wild_magic() */
1036 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1038 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1039 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1042 msg_format("%s(%c)は劣化してしまった!",
1043 o_name, index_to_label(t) );
1045 msg_format("Your %s (%c) %s disenchanted!",
1046 o_name, index_to_label(t),
1047 ((o_ptr->number != 1) ? "were" : "was"));
1050 chg_virtue(V_HARMONY, 1);
1051 chg_virtue(V_ENCHANT, -2);
1053 /* Recalculate bonuses */
1054 p_ptr->update |= (PU_BONUS);
1056 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1066 * @brief プレイヤーの突然変異処理
1069 void mutate_player(void)
1071 BASE_STATUS max1, cur1, max2, cur2;
1074 /* Pick a pair of stats */
1076 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1078 max1 = p_ptr->stat_max[ii];
1079 cur1 = p_ptr->stat_cur[ii];
1080 max2 = p_ptr->stat_max[jj];
1081 cur2 = p_ptr->stat_cur[jj];
1083 p_ptr->stat_max[ii] = max2;
1084 p_ptr->stat_cur[ii] = cur2;
1085 p_ptr->stat_max[jj] = max1;
1086 p_ptr->stat_cur[jj] = cur1;
1090 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1091 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1094 p_ptr->update |= (PU_BONUS);
1099 * @brief プレイヤーの因果混乱処理 / Apply Nexus
1100 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
1103 void apply_nexus(monster_type *m_ptr)
1105 switch (randint1(7))
1107 case 1: case 2: case 3:
1109 teleport_player(200, TELEPORT_PASSIVE);
1115 teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
1121 if (randint0(100) < p_ptr->skill_sav)
1123 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1127 /* Teleport Level */
1134 if (randint0(100) < p_ptr->skill_sav)
1136 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1140 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
1149 * @brief 寿命つき光源の燃素追加処理 /
1150 * Charge a lite (torch or latern)
1153 void phlogiston(void)
1155 GAME_TURN max_flog = 0;
1156 object_type * o_ptr = &inventory[INVEN_LITE];
1159 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1161 max_flog = FUEL_LAMP;
1165 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1167 max_flog = FUEL_TORCH;
1170 /* No torch to refill */
1173 msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
1177 if (o_ptr->xtra4 >= max_flog)
1179 msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
1184 o_ptr->xtra4 += (XTRA16)(max_flog / 2);
1186 msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
1189 if (o_ptr->xtra4 >= max_flog)
1191 o_ptr->xtra4 = (XTRA16)max_flog;
1192 msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
1195 /* Recalculate torch */
1196 p_ptr->update |= (PU_TORCH);
1201 * @brief 武器へのエゴ付加処理 /
1202 * Brand the current weapon
1203 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1206 void brand_weapon(int brand_type)
1213 /* Assume enchant weapon */
1214 item_tester_hook = object_allow_enchant_melee_weapon;
1215 item_tester_no_ryoute = TRUE;
1218 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1219 s = _("強化できる武器がない。", "You have nothing to enchant.");
1221 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1223 /* Get the item (in the pack) */
1226 o_ptr = &inventory[item];
1229 /* Get the item (on the floor) */
1232 o_ptr = &o_list[0 - item];
1236 /* you can never modify artifacts / ego-items */
1237 /* you can never modify cursed items */
1238 /* TY: You _can_ modify broken items (if you're silly enough) */
1239 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1240 !object_is_cursed(o_ptr) &&
1241 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1242 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1243 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1247 /* Let's get the name before it is changed... */
1248 char o_name[MAX_NLEN];
1249 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1254 if (o_ptr->tval == TV_SWORD)
1256 act = _("は鋭さを増した!", "becomes very sharp!");
1258 o_ptr->name2 = EGO_SHARPNESS;
1259 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, dun_level) + 1;
1261 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1266 act = _("は破壊力を増した!", "seems very powerful.");
1267 o_ptr->name2 = EGO_EARTHQUAKES;
1268 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, dun_level);
1272 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1273 o_ptr->name2 = EGO_KILL_HUMAN;
1276 act = _("は電撃に覆われた!", "covered with lightning!");
1277 o_ptr->name2 = EGO_BRAND_ELEC;
1280 act = _("は酸に覆われた!", "coated with acid!");
1281 o_ptr->name2 = EGO_BRAND_ACID;
1284 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1285 o_ptr->name2 = EGO_KILL_EVIL;
1288 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1289 o_ptr->name2 = EGO_KILL_DEMON;
1292 act = _("は屍を求めている!", "seems to be looking for undead!");
1293 o_ptr->name2 = EGO_KILL_UNDEAD;
1296 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1297 o_ptr->name2 = EGO_KILL_ANIMAL;
1300 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1301 o_ptr->name2 = EGO_KILL_DRAGON;
1304 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1305 o_ptr->name2 = EGO_KILL_TROLL;
1308 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1309 o_ptr->name2 = EGO_KILL_ORC;
1312 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1313 o_ptr->name2 = EGO_KILL_GIANT;
1316 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1317 o_ptr->name2 = EGO_TRUMP;
1318 o_ptr->pval = randint1(2);
1321 act = _("は血を求めている!", "thirsts for blood!");
1322 o_ptr->name2 = EGO_VAMPIRIC;
1325 act = _("は毒に覆われた。", "is coated with poison.");
1326 o_ptr->name2 = EGO_BRAND_POIS;
1329 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1330 o_ptr->name2 = EGO_CHAOTIC;
1333 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1334 o_ptr->name2 = EGO_BRAND_FIRE;
1337 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1338 o_ptr->name2 = EGO_BRAND_COLD;
1342 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1343 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1345 o_ptr->discount = 99;
1346 chg_virtue(V_ENCHANT, 2);
1350 if (flush_failure) flush();
1352 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1353 chg_virtue(V_ENCHANT, -2);
1360 * @brief 虚無招来によるフロア中の全壁除去処理 /
1361 * Vanish all walls in this floor
1362 * @return 実際に処理が反映された場合TRUE
1364 static bool vanish_dungeon(void)
1368 feature_type *f_ptr;
1369 monster_type *m_ptr;
1372 /* Prevent vasishing of quest levels and town */
1373 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1378 /* Scan all normal grids */
1379 for (y = 1; y < cur_hgt - 1; y++)
1381 for (x = 1; x < cur_wid - 1; x++)
1383 c_ptr = &cave[y][x];
1385 /* Seeing true feature code (ignore mimic) */
1386 f_ptr = &f_info[c_ptr->feat];
1388 /* Lose room and vault */
1389 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1391 m_ptr = &m_list[c_ptr->m_idx];
1394 if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
1396 /* Reset sleep counter */
1397 (void)set_monster_csleep(c_ptr->m_idx, 0);
1399 /* Notice the "waking up" */
1402 /* Acquire the monster name */
1403 monster_desc(m_name, m_ptr, 0);
1405 /* Dump a message */
1406 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1410 /* Process all walls, doors and patterns */
1411 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1415 /* Special boundary walls -- Top and bottom */
1416 for (x = 0; x < cur_wid; x++)
1418 c_ptr = &cave[0][x];
1419 f_ptr = &f_info[c_ptr->mimic];
1421 /* Lose room and vault */
1422 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1424 /* Set boundary mimic if needed */
1425 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1427 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1429 /* Check for change to boring grid */
1430 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1433 c_ptr = &cave[cur_hgt - 1][x];
1434 f_ptr = &f_info[c_ptr->mimic];
1436 /* Lose room and vault */
1437 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1439 /* Set boundary mimic if needed */
1440 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1442 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1444 /* Check for change to boring grid */
1445 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1449 /* Special boundary walls -- Left and right */
1450 for (y = 1; y < (cur_hgt - 1); y++)
1452 c_ptr = &cave[y][0];
1453 f_ptr = &f_info[c_ptr->mimic];
1455 /* Lose room and vault */
1456 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1458 /* Set boundary mimic if needed */
1459 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1461 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1463 /* Check for change to boring grid */
1464 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1467 c_ptr = &cave[y][cur_wid - 1];
1468 f_ptr = &f_info[c_ptr->mimic];
1470 /* Lose room and vault */
1471 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1473 /* Set boundary mimic if needed */
1474 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1476 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1478 /* Check for change to boring grid */
1479 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1483 /* Mega-Hack -- Forget the view and lite */
1484 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1486 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1488 /* Update the monsters */
1489 p_ptr->update |= (PU_MONSTERS);
1492 p_ptr->redraw |= (PR_MAP);
1494 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1503 void call_the_(void)
1507 bool do_call = TRUE;
1509 for (i = 0; i < 9; i++)
1511 c_ptr = &cave[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1513 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1515 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1516 !permanent_wall(&f_info[c_ptr->feat]))
1526 for (i = 1; i < 10; i++)
1528 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1531 for (i = 1; i < 10; i++)
1533 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1536 for (i = 1; i < 10; i++)
1538 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1542 /* Prevent destruction of quest levels and town */
1543 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1545 msg_print(_("地面が揺れた。", "The ground trembles."));
1551 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1552 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1553 msg_print("大きな爆発音があった!");
1555 msg_format("You %s the %s too close to a wall!",
1556 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1557 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1558 msg_print("There is a loud explosion!");
1563 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1567 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1568 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1570 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1573 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1579 * @brief アイテム引き寄せ処理 /
1580 * Fetch an item (teleport it right underneath the caster)
1581 * @param dir 魔法の発動方向
1583 * @param require_los 射線の通りを要求するならばTRUE
1586 void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
1592 char o_name[MAX_NLEN];
1594 /* Check to see if an object is already there */
1595 if (cave[p_ptr->y][p_ptr->x].o_idx)
1597 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1602 if (dir == 5 && target_okay())
1607 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1609 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1613 c_ptr = &cave[ty][tx];
1615 /* We need an item to fetch */
1618 msg_print(_("そこには何もありません。", "There is no object at this place."));
1622 /* No fetching from vault */
1623 if (c_ptr->info & CAVE_ICKY)
1625 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1629 /* We need to see the item */
1632 if (!player_has_los_bold(ty, tx))
1634 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1637 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1639 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1646 /* Use a direction */
1647 ty = p_ptr->y; /* Where to drop the item */
1654 c_ptr = &cave[ty][tx];
1656 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1657 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1659 while (!c_ptr->o_idx);
1662 o_ptr = &o_list[c_ptr->o_idx];
1664 if (o_ptr->weight > wgt)
1666 /* Too heavy to 'fetch' */
1667 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1672 c_ptr->o_idx = o_ptr->next_o_idx;
1673 cave[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1675 o_ptr->next_o_idx = 0;
1676 o_ptr->iy = (byte)p_ptr->y;
1677 o_ptr->ix = (byte)p_ptr->x;
1679 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1680 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1682 note_spot(p_ptr->y, p_ptr->x);
1683 p_ptr->redraw |= PR_MAP;
1690 void alter_reality(void)
1692 /* Ironman option */
1693 if (p_ptr->inside_arena || ironman_downward)
1695 msg_print(_("何も起こらなかった。", "Nothing happens."));
1699 if (!p_ptr->alter_reality)
1701 TIME_EFFECT turns = randint0(21) + 15;
1703 p_ptr->alter_reality = turns;
1704 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1706 p_ptr->redraw |= (PR_STATUS);
1710 p_ptr->alter_reality = 0;
1711 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1712 p_ptr->redraw |= (PR_STATUS);
1719 * @brief 守りのルーン設置処理 /
1720 * Leave a "glyph of warding" which prevents monster movement
1721 * @return 実際に設置が行われた場合TRUEを返す
1723 bool warding_glyph(void)
1725 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1727 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1731 /* Create a glyph */
1732 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1733 cave[p_ptr->y][p_ptr->x].mimic = feat_glyph;
1736 note_spot(p_ptr->y, p_ptr->x);
1739 lite_spot(p_ptr->y, p_ptr->x);
1746 * @return 実際に設置が行われた場合TRUEを返す
1748 bool place_mirror(void)
1750 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1752 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1756 /* Create a mirror */
1757 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1758 cave[p_ptr->y][p_ptr->x].mimic = feat_mirror;
1760 /* Turn on the light */
1761 cave[p_ptr->y][p_ptr->x].info |= CAVE_GLOW;
1764 note_spot(p_ptr->y, p_ptr->x);
1767 lite_spot(p_ptr->y, p_ptr->x);
1769 update_local_illumination(p_ptr->y, p_ptr->x);
1776 * @brief 爆発のルーン設置処理 /
1777 * Leave an "explosive rune" which prevents monster movement
1778 * @return 実際に設置が行われた場合TRUEを返す
1780 bool explosive_rune(void)
1782 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1784 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1788 /* Create a glyph */
1789 cave[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1790 cave[p_ptr->y][p_ptr->x].mimic = feat_explosive_rune;
1793 note_spot(p_ptr->y, p_ptr->x);
1796 lite_spot(p_ptr->y, p_ptr->x);
1803 * @brief 全所持アイテム鑑定処理 /
1804 * Identify everything being carried.
1805 * Done by a potion of "self knowledge".
1808 void identify_pack(void)
1812 /* Simply identify and know every item */
1813 for (i = 0; i < INVEN_TOTAL; i++)
1815 object_type *o_ptr = &inventory[i];
1817 /* Skip non-objects */
1818 if (!o_ptr->k_idx) continue;
1821 identify_item(o_ptr);
1823 /* Auto-inscription */
1824 autopick_alter_item(i, FALSE);
1830 * @brief 装備強化処理の失敗率定数(千分率) /
1831 * Used by the "enchant" function (chance of failure)
1832 * (modified for Zangband, we need better stuff there...) -- TY
1835 static int enchant_table[16] =
1837 0, 10, 50, 100, 200,
1838 300, 400, 500, 650, 800,
1839 950, 987, 993, 995, 998,
1846 * Removes curses from items in inventory
1847 * @param all 軽い呪いまでの解除ならば0
1848 * @return 解呪されたアイテムの数
1851 * Note that Items which are "Perma-Cursed" (The One Ring,
1852 * The Crown of Morgoth) can NEVER be uncursed.
1854 * Note that if "all" is FALSE, then Items which are
1855 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1856 * will not be uncursed.
1859 static int remove_curse_aux(int all)
1863 /* Attempt to uncurse items being worn */
1864 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1866 object_type *o_ptr = &inventory[i];
1868 /* Skip non-objects */
1869 if (!o_ptr->k_idx) continue;
1871 /* Uncursed already */
1872 if (!object_is_cursed(o_ptr)) continue;
1874 /* Heavily Cursed Items need a special spell */
1875 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1877 /* Perma-Cursed Items can NEVER be uncursed */
1878 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1881 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1886 o_ptr->curse_flags = 0L;
1888 /* Hack -- Assume felt */
1889 o_ptr->ident |= (IDENT_SENSE);
1892 o_ptr->feeling = FEEL_NONE;
1894 /* Recalculate the bonuses */
1895 p_ptr->update |= (PU_BONUS);
1897 p_ptr->window |= (PW_EQUIP);
1899 /* Count the uncursings */
1905 msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
1907 /* Return "something uncursed" */
1913 * @brief 装備の軽い呪い解呪処理 /
1914 * Remove most curses
1915 * @return 解呪に成功した装備数
1917 int remove_curse(void)
1919 return (remove_curse_aux(FALSE));
1923 * @brief 装備の重い呪い解呪処理 /
1925 * @return 解呪に成功した装備数
1927 int remove_all_curse(void)
1929 return (remove_curse_aux(TRUE));
1934 * @brief アイテムの価値に応じた錬金術処理 /
1935 * Turns an object into gold, gain some of its value in a shop
1936 * @return 処理が実際に行われたらTRUEを返す
1942 ITEM_NUMBER old_number;
1946 char o_name[MAX_NLEN];
1947 char out_val[MAX_NLEN+40];
1951 /* Hack -- force destruction */
1952 if (command_arg > 0) force = TRUE;
1955 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
1956 s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
1958 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
1960 /* Get the item (in the pack) */
1963 o_ptr = &inventory[item];
1966 /* Get the item (on the floor) */
1969 o_ptr = &o_list[0 - item];
1973 /* See how many items */
1974 if (o_ptr->number > 1)
1976 /* Get a quantity */
1977 amt = get_quantity(NULL, o_ptr->number);
1979 /* Allow user abort */
1980 if (amt <= 0) return FALSE;
1984 /* Describe the object */
1985 old_number = o_ptr->number;
1986 o_ptr->number = amt;
1987 object_desc(o_name, o_ptr, 0);
1988 o_ptr->number = old_number;
1990 /* Verify unless quantity given */
1993 if (confirm_destroy || (object_value(o_ptr) > 0))
1995 /* Make a verification */
1996 sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
1997 if (!get_check(out_val)) return FALSE;
2001 /* Artifacts cannot be destroyed */
2002 if (!can_player_destroy_object(o_ptr))
2004 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
2009 price = object_value_real(o_ptr);
2013 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
2019 if (amt > 1) price *= amt;
2021 if (price > 30000) price = 30000;
2022 msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
2027 p_ptr->redraw |= (PR_GOLD);
2029 p_ptr->window |= (PW_PLAYER);
2033 /* Eliminate the item (from the pack) */
2036 inven_item_increase(item, -amt);
2037 inven_item_describe(item);
2038 inven_item_optimize(item);
2041 /* Eliminate the item (from the floor) */
2044 floor_item_increase(0 - item, -amt);
2045 floor_item_describe(0 - item);
2046 floor_item_optimize(0 - item);
2054 * @brief 呪いの打ち破り処理 /
2055 * Break the curse of an item
2056 * @param o_ptr 呪い装備情報の参照ポインタ
2059 static void break_curse(object_type *o_ptr)
2061 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2063 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
2065 o_ptr->curse_flags = 0L;
2066 o_ptr->ident |= (IDENT_SENSE);
2067 o_ptr->feeling = FEEL_NONE;
2074 * Enchants a plus onto an item. -RAK-
2075 * @param o_ptr 強化するアイテムの参照ポインタ
2077 * @param eflag 強化オプション(命中/ダメージ/AC)
2078 * @return 強化に成功した場合TRUEを返す
2081 * Revamped! Now takes item pointer, number of times to try enchanting,
2082 * and a flag of what to try enchanting. Artifacts resist enchantment
2083 * some of the time, and successful enchantment to at least +0 might
2084 * break a curse on the item. -CFT-
2086 * Note that an item can technically be enchanted all the way to +15 if
2087 * you wait a very, very, long time. Going from +9 to +10 only works
2088 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2090 * Note that this function can now be used on "piles" of items, and
2091 * the larger the pile, the lower the chance of success.
2094 bool enchant(object_type *o_ptr, int n, int eflag)
2096 int i, chance, prob;
2098 bool a = object_is_artifact(o_ptr);
2099 bool force = (eflag & ENCH_FORCE);
2102 /* Large piles resist enchantment */
2103 prob = o_ptr->number * 100;
2105 /* Missiles are easy to enchant */
2106 if ((o_ptr->tval == TV_BOLT) ||
2107 (o_ptr->tval == TV_ARROW) ||
2108 (o_ptr->tval == TV_SHOT))
2114 for (i = 0; i < n; i++)
2116 /* Hack -- Roll for pile resistance */
2117 if (!force && randint0(prob) >= 100) continue;
2119 /* Enchant to hit */
2120 if (eflag & ENCH_TOHIT)
2122 if (o_ptr->to_h < 0) chance = 0;
2123 else if (o_ptr->to_h > 15) chance = 1000;
2124 else chance = enchant_table[o_ptr->to_h];
2126 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2131 /* only when you get it above -1 -CFT */
2132 if (o_ptr->to_h >= 0)
2137 /* Enchant to damage */
2138 if (eflag & ENCH_TODAM)
2140 if (o_ptr->to_d < 0) chance = 0;
2141 else if (o_ptr->to_d > 15) chance = 1000;
2142 else chance = enchant_table[o_ptr->to_d];
2144 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2149 /* only when you get it above -1 -CFT */
2150 if (o_ptr->to_d >= 0)
2155 /* Enchant to armor class */
2156 if (eflag & ENCH_TOAC)
2158 if (o_ptr->to_a < 0) chance = 0;
2159 else if (o_ptr->to_a > 15) chance = 1000;
2160 else chance = enchant_table[o_ptr->to_a];
2162 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2167 /* only when you get it above -1 -CFT */
2168 if (o_ptr->to_a >= 0)
2175 if (!res) return (FALSE);
2177 /* Recalculate bonuses */
2178 p_ptr->update |= (PU_BONUS);
2180 /* Combine / Reorder the pack (later) */
2181 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2183 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2193 * @brief 装備修正強化処理のメインルーチン /
2194 * Enchant an item (in the inventory or on the floor)
2195 * @param num_hit 命中修正量
2196 * @param num_dam ダメージ修正量
2197 * @param num_ac AC修正量
2198 * @return 強化に成功した場合TRUEを返す
2200 * Note that "num_ac" requires armour, else weapon
2201 * Returns TRUE if attempted, FALSE if cancelled
2203 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
2208 char o_name[MAX_NLEN];
2212 /* Assume enchant weapon */
2213 item_tester_hook = object_allow_enchant_weapon;
2214 item_tester_no_ryoute = TRUE;
2216 /* Enchant armor if requested */
2217 if (num_ac) item_tester_hook = object_is_armour;
2220 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2221 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2223 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2225 /* Get the item (in the pack) */
2228 o_ptr = &inventory[item];
2231 /* Get the item (on the floor) */
2234 o_ptr = &o_list[0 - item];
2239 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2243 msg_format("%s は明るく輝いた!",
2246 msg_format("%s %s glow%s brightly!",
2247 ((item >= 0) ? "Your" : "The"), o_name,
2248 ((o_ptr->number > 1) ? "" : "s"));
2253 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2254 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2255 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2261 if (flush_failure) flush();
2263 msg_print(_("強化に失敗した。", "The enchantment failed."));
2265 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2268 chg_virtue(V_ENCHANT, 1);
2272 /* Something happened */
2278 * @brief アーティファクト生成の巻物処理 /
2279 * @return 生成が実際に試みられたらTRUEを返す
2281 bool artifact_scroll(void)
2286 char o_name[MAX_NLEN];
2290 item_tester_no_ryoute = TRUE;
2292 /* Enchant weapon/armour */
2293 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2296 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2297 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2299 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2301 /* Get the item (in the pack) */
2304 o_ptr = &inventory[item];
2307 /* Get the item (on the floor) */
2310 o_ptr = &o_list[0 - item];
2315 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2319 msg_format("%s は眩い光を発した!",o_name);
2321 msg_format("%s %s radiate%s a blinding light!",
2322 ((item >= 0) ? "Your" : "The"), o_name,
2323 ((o_ptr->number > 1) ? "" : "s"));
2326 if (object_is_artifact(o_ptr))
2329 msg_format("%sは既に伝説のアイテムです!", o_name );
2331 msg_format("The %s %s already %s!",
2332 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2333 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2339 else if (object_is_ego(o_ptr))
2342 msg_format("%sは既に名のあるアイテムです!", o_name );
2344 msg_format("The %s %s already %s!",
2345 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2346 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2352 else if (o_ptr->xtra3)
2355 msg_format("%sは既に強化されています!", o_name );
2357 msg_format("The %s %s already %s!",
2358 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2359 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2365 if (o_ptr->number > 1)
2368 msg_print("複数のアイテムに魔法をかけるだけのエネルギーはありません!");
2369 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2371 msg_print("Not enough enough energy to enchant more than one object!");
2372 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2377 inven_item_increase(item, 1-(o_ptr->number));
2381 floor_item_increase(0-item, 1-(o_ptr->number));
2384 okay = create_artifact(o_ptr, TRUE);
2391 if (flush_failure) flush();
2393 msg_print(_("強化に失敗した。", "The enchantment failed."));
2395 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2399 if (record_rand_art)
2402 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2403 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2405 chg_virtue(V_ENCHANT, 1);
2410 /* Something happened */
2417 * Identify an object
2418 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2419 * @return 実際に鑑定できたらTRUEを返す
2421 bool identify_item(object_type *o_ptr)
2423 bool old_known = FALSE;
2424 char o_name[MAX_NLEN];
2427 object_desc(o_name, o_ptr, 0);
2429 if (o_ptr->ident & IDENT_KNOWN)
2432 if (!(o_ptr->ident & (IDENT_MENTAL)))
2434 if (object_is_artifact(o_ptr) || one_in_(5))
2435 chg_virtue(V_KNOWLEDGE, 1);
2438 /* Identify it fully */
2439 object_aware(o_ptr);
2440 object_known(o_ptr);
2442 /* Player touches it */
2443 o_ptr->marked |= OM_TOUCHED;
2445 /* Recalculate bonuses */
2446 p_ptr->update |= (PU_BONUS);
2448 /* Combine / Reorder the pack (later) */
2449 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2451 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2453 strcpy(record_o_name, o_name);
2457 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2459 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2460 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2461 if(record_rand_art && !old_known && o_ptr->art_name)
2462 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2468 * @brief アイテム鑑定のメインルーチン処理 /
2469 * Identify an object in the inventory (or on the floor)
2470 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2471 * @return 実際に鑑定を行ったならばTRUEを返す
2473 * This routine does *not* automatically combine objects.
2474 * Returns TRUE if something was identified, else FALSE.
2476 bool ident_spell(bool only_equip)
2480 char o_name[MAX_NLEN];
2484 item_tester_no_ryoute = TRUE;
2487 item_tester_hook = item_tester_hook_identify_weapon_armour;
2489 item_tester_hook = item_tester_hook_identify;
2493 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2498 item_tester_hook = object_is_weapon_armour_ammo;
2500 item_tester_hook = NULL;
2502 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2506 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2508 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2510 /* Get the item (in the pack) */
2513 o_ptr = &inventory[item];
2516 /* Get the item (on the floor) */
2519 o_ptr = &o_list[0 - item];
2523 old_known = identify_item(o_ptr);
2526 object_desc(o_name, o_ptr, 0);
2529 if (item >= INVEN_RARM)
2531 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2535 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2539 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2542 /* Auto-inscription/destroy */
2543 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2545 /* Something happened */
2551 * @brief アイテム凡庸化のメインルーチン処理 /
2552 * Identify an object in the inventory (or on the floor)
2553 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2554 * @return 実際に凡庸化をを行ったならばTRUEを返す
2557 * Mundanify an object in the inventory (or on the floor)
2558 * This routine does *not* automatically combine objects.
2559 * Returns TRUE if something was mundanified, else FALSE.
2562 bool mundane_spell(bool only_equip)
2568 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2569 item_tester_no_ryoute = TRUE;
2572 q = _("どれを使いますか?", "Use which item? ");
2573 s = _("使えるものがありません。", "You have nothing you can use.");
2575 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2577 /* Get the item (in the pack) */
2580 o_ptr = &inventory[item];
2583 /* Get the item (on the floor) */
2586 o_ptr = &o_list[0 - item];
2590 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2592 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2593 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2594 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2595 byte marked = o_ptr->marked; /* Object is marked */
2596 s16b weight = o_ptr->number * o_ptr->weight;
2597 u16b inscription = o_ptr->inscription;
2600 object_prep(o_ptr, o_ptr->k_idx);
2604 o_ptr->next_o_idx = next_o_idx;
2605 o_ptr->marked = marked;
2606 o_ptr->inscription = inscription;
2607 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2611 /* Something happened */
2616 * @brief アイテム*鑑定*のメインルーチン処理 /
2617 * Identify an object in the inventory (or on the floor)
2618 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2619 * @return 実際に鑑定を行ったならばTRUEを返す
2621 * Fully "identify" an object in the inventory -BEN-
2622 * This routine returns TRUE if an item was identified.
2624 bool identify_fully(bool only_equip)
2628 char o_name[MAX_NLEN];
2632 item_tester_no_ryoute = TRUE;
2634 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2636 item_tester_hook = item_tester_hook_identify_fully;
2640 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2645 item_tester_hook = object_is_weapon_armour_ammo;
2647 item_tester_hook = NULL;
2649 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2653 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2655 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2657 /* Get the item (in the pack) */
2660 o_ptr = &inventory[item];
2663 /* Get the item (on the floor) */
2666 o_ptr = &o_list[0 - item];
2670 old_known = identify_item(o_ptr);
2672 /* Mark the item as fully known */
2673 o_ptr->ident |= (IDENT_MENTAL);
2679 object_desc(o_name, o_ptr, 0);
2682 if (item >= INVEN_RARM)
2684 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2688 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2692 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2695 /* Describe it fully */
2696 (void)screen_object(o_ptr, 0L);
2698 /* Auto-inscription/destroy */
2699 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2709 * Recharge a wand/staff/rod from the pack or on the floor.
2710 * This function has been rewritten in Oangband and ZAngband.
2711 * @param power 充填パワー
2712 * @return ターン消費を要する処理まで進んだらTRUEを返す
2714 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2715 * Chaos -- Arcane Binding --> recharge(90)
2717 * Scroll of recharging --> recharge(130)
2718 * Artifact activation/Thingol --> recharge(130)
2720 * It is harder to recharge high level, and highly charged wands,
2721 * staffs, and rods. The more wands in a stack, the more easily and
2722 * strongly they recharge. Staffs, however, each get fewer charges if
2725 * XXX XXX XXX Beware of "sliding index errors".
2727 bool recharge(int power)
2731 int recharge_strength;
2732 TIME_EFFECT recharge_amount;
2741 char o_name[MAX_NLEN];
2743 /* Only accept legal items */
2744 item_tester_hook = item_tester_hook_recharge;
2747 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2748 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2750 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2752 /* Get the item (in the pack) */
2755 o_ptr = &inventory[item];
2758 /* Get the item (on the floor) */
2761 o_ptr = &o_list[0 - item];
2764 /* Get the object kind. */
2765 k_ptr = &k_info[o_ptr->k_idx];
2767 /* Extract the object "level" */
2768 lev = k_info[o_ptr->k_idx].level;
2771 /* Recharge a rod */
2772 if (o_ptr->tval == TV_ROD)
2774 /* Extract a recharge strength by comparing object level to power. */
2775 recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
2779 if (one_in_(recharge_strength))
2781 /* Activate the failure code. */
2788 /* Recharge amount */
2789 recharge_amount = (power * damroll(3, 2));
2791 /* Recharge by that amount */
2792 if (o_ptr->timeout > recharge_amount)
2793 o_ptr->timeout -= recharge_amount;
2800 /* Recharge wand/staff */
2803 /* Extract a recharge strength by comparing object level to power.
2804 * Divide up a stack of wands' charges to calculate charge penalty.
2806 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2807 recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15;
2809 /* All staffs, unstacked wands. */
2810 else recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15;
2813 if (recharge_strength < 0) recharge_strength = 0;
2816 if (one_in_(recharge_strength))
2818 /* Activate the failure code. */
2822 /* If the spell didn't backfire, recharge the wand or staff. */
2825 /* Recharge based on the standard number of charges. */
2826 recharge_amount = randint1(1 + k_ptr->pval / 2);
2828 /* Multiple wands in a stack increase recharging somewhat. */
2829 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2832 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2833 if (recharge_amount < 1) recharge_amount = 1;
2834 if (recharge_amount > 12) recharge_amount = 12;
2837 /* But each staff in a stack gets fewer additional charges,
2838 * although always at least one.
2840 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2842 recharge_amount /= (TIME_EFFECT)o_ptr->number;
2843 if (recharge_amount < 1) recharge_amount = 1;
2846 /* Recharge the wand or staff. */
2847 o_ptr->pval += recharge_amount;
2850 /* Hack -- we no longer "know" the item */
2851 o_ptr->ident &= ~(IDENT_KNOWN);
2853 /* Hack -- we no longer think the item is empty */
2854 o_ptr->ident &= ~(IDENT_EMPTY);
2859 /* Inflict the penalties for failing a recharge. */
2862 /* Artifacts are never destroyed. */
2863 if (object_is_fixed_artifact(o_ptr))
2865 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2866 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2868 /* Artifact rods. */
2869 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2870 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2872 /* Artifact wands and staffs. */
2873 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2878 /* Get the object description */
2879 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2881 /*** Determine Seriousness of Failure ***/
2883 /* Mages recharge objects more safely. */
2884 if (IS_WIZARD_CLASS() || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
2886 /* 10% chance to blow up one rod, otherwise draining. */
2887 if (o_ptr->tval == TV_ROD)
2889 if (one_in_(10)) fail_type = 2;
2892 /* 75% chance to blow up one wand, otherwise draining. */
2893 else if (o_ptr->tval == TV_WAND)
2895 if (!one_in_(3)) fail_type = 2;
2898 /* 50% chance to blow up one staff, otherwise no effect. */
2899 else if (o_ptr->tval == TV_STAFF)
2901 if (one_in_(2)) fail_type = 2;
2906 /* All other classes get no special favors. */
2909 /* 33% chance to blow up one rod, otherwise draining. */
2910 if (o_ptr->tval == TV_ROD)
2912 if (one_in_(3)) fail_type = 2;
2915 /* 20% chance of the entire stack, else destroy one wand. */
2916 else if (o_ptr->tval == TV_WAND)
2918 if (one_in_(5)) fail_type = 3;
2921 /* Blow up one staff. */
2922 else if (o_ptr->tval == TV_STAFF)
2928 /*** Apply draining and destruction. ***/
2930 /* Drain object or stack of objects. */
2933 if (o_ptr->tval == TV_ROD)
2935 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
2937 if (o_ptr->timeout < 10000)
2938 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2940 else if (o_ptr->tval == TV_WAND)
2942 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
2945 /* Staffs aren't drained. */
2948 /* Destroy an object or one in a stack of objects. */
2951 if (o_ptr->number > 1)
2952 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
2954 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2956 /* Reduce rod stack maximum timeout, drain wands. */
2957 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
2958 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
2960 /* Reduce and describe inventory */
2963 inven_item_increase(item, -1);
2964 inven_item_describe(item);
2965 inven_item_optimize(item);
2968 /* Reduce and describe floor item */
2971 floor_item_increase(0 - item, -1);
2972 floor_item_describe(0 - item);
2973 floor_item_optimize(0 - item);
2977 /* Destroy all members of a stack of objects. */
2980 if (o_ptr->number > 1)
2981 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
2983 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2985 /* Reduce and describe inventory */
2988 inven_item_increase(item, -999);
2989 inven_item_describe(item);
2990 inven_item_optimize(item);
2993 /* Reduce and describe floor item */
2996 floor_item_increase(0 - item, -999);
2997 floor_item_describe(0 - item);
2998 floor_item_optimize(0 - item);
3004 /* Combine / Reorder the pack (later) */
3005 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3007 p_ptr->window |= (PW_INVEN);
3009 /* Something was done */
3017 * @return ターン消費を要する処理を行ったならばTRUEを返す
3019 bool bless_weapon(void)
3023 BIT_FLAGS flgs[TR_FLAG_SIZE];
3024 char o_name[MAX_NLEN];
3027 item_tester_no_ryoute = TRUE;
3029 /* Bless only weapons */
3030 item_tester_hook = object_is_weapon;
3033 q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
3034 s = _("祝福できる武器がありません。", "You have weapon to bless.");
3036 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3039 /* Get the item (in the pack) */
3042 o_ptr = &inventory[item];
3045 /* Get the item (on the floor) */
3048 o_ptr = &o_list[0 - item];
3053 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3055 /* Extract the flags */
3056 object_flags(o_ptr, flgs);
3058 if (object_is_cursed(o_ptr))
3060 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3061 have_flag(flgs, TR_ADD_L_CURSE) ||
3062 have_flag(flgs, TR_ADD_H_CURSE) ||
3063 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3066 msg_format("%sを覆う黒いオーラは祝福を跳ね返した!",
3069 msg_format("The black aura on %s %s disrupts the blessing!",
3070 ((item >= 0) ? "your" : "the"), o_name);
3077 msg_format("%s から邪悪なオーラが消えた。",
3080 msg_format("A malignant aura leaves %s %s.",
3081 ((item >= 0) ? "your" : "the"), o_name);
3086 o_ptr->curse_flags = 0L;
3088 /* Hack -- Assume felt */
3089 o_ptr->ident |= (IDENT_SENSE);
3092 o_ptr->feeling = FEEL_NONE;
3094 /* Recalculate the bonuses */
3095 p_ptr->update |= (PU_BONUS);
3097 p_ptr->window |= (PW_EQUIP);
3101 * Next, we try to bless it. Artifacts have a 1/3 chance of
3102 * being blessed, otherwise, the operation simply disenchants
3103 * them, godly power negating the magic. Ok, the explanation
3104 * is silly, but otherwise priests would always bless every
3105 * artifact weapon they find. Ego weapons and normal weapons
3106 * can be blessed automatically.
3108 if (have_flag(flgs, TR_BLESSED))
3111 msg_format("%s は既に祝福されている。",
3114 msg_format("%s %s %s blessed already.",
3115 ((item >= 0) ? "Your" : "The"), o_name,
3116 ((o_ptr->number > 1) ? "were" : "was"));
3122 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3126 msg_format("%sは輝いた!",
3129 msg_format("%s %s shine%s!",
3130 ((item >= 0) ? "Your" : "The"), o_name,
3131 ((o_ptr->number > 1) ? "" : "s"));
3134 add_flag(o_ptr->art_flags, TR_BLESSED);
3135 o_ptr->discount = 99;
3139 bool dis_happened = FALSE;
3140 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
3142 /* Disenchant tohit */
3143 if (o_ptr->to_h > 0)
3146 dis_happened = TRUE;
3149 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3151 /* Disenchant todam */
3152 if (o_ptr->to_d > 0)
3155 dis_happened = TRUE;
3158 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3160 /* Disenchant toac */
3161 if (o_ptr->to_a > 0)
3164 dis_happened = TRUE;
3167 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3171 msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
3174 msg_format("%s は劣化した!",
3177 msg_format("%s %s %s disenchanted!",
3178 ((item >= 0) ? "Your" : "The"), o_name,
3179 ((o_ptr->number > 1) ? "were" : "was"));
3185 /* Recalculate bonuses */
3186 p_ptr->update |= (PU_BONUS);
3188 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3199 * @return ターン消費を要する処理を行ったならばTRUEを返す
3201 bool pulish_shield(void)
3205 BIT_FLAGS flgs[TR_FLAG_SIZE];
3206 char o_name[MAX_NLEN];
3209 item_tester_no_ryoute = TRUE;
3210 /* Assume enchant weapon */
3211 item_tester_tval = TV_SHIELD;
3214 q = _("どの盾を磨きますか?", "Pulish which weapon? ");
3215 s = _("磨く盾がありません。", "You have weapon to pulish.");
3217 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3220 /* Get the item (in the pack) */
3223 o_ptr = &inventory[item];
3226 /* Get the item (on the floor) */
3229 o_ptr = &o_list[0 - item];
3234 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3236 /* Extract the flags */
3237 object_flags(o_ptr, flgs);
3239 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3240 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3243 msg_format("%sは輝いた!", o_name);
3245 msg_format("%s %s shine%s!",
3246 ((item >= 0) ? "Your" : "The"), o_name,
3247 ((o_ptr->number > 1) ? "" : "s"));
3249 o_ptr->name2 = EGO_REFLECTION;
3250 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3252 o_ptr->discount = 99;
3253 chg_virtue(V_ENCHANT, 2);
3259 if (flush_failure) flush();
3261 msg_print(_("失敗した。", "Failed."));
3262 chg_virtue(V_ENCHANT, -2);
3272 * Potions "smash open" and cause an area effect when
3273 * @param who 薬破損の主体ID(プレイヤー所持アイテムが壊れた場合0、床上のアイテムの場合モンスターID)
3276 * @param k_idx 破損した薬のアイテムID
3277 * @return 薬を浴びたモンスターが起こるならばTRUEを返す
3280 * (1) they are shattered while in the player's inventory,
3281 * due to cold (etc) attacks;
3282 * (2) they are thrown at a monster, or obstacle;
3283 * (3) they are shattered by a "cold ball" or other such spell
3284 * while lying on the floor.
3287 * who --- who caused the potion to shatter (0=player)
3288 * potions that smash on the floor are assumed to
3289 * be caused by no-one (who = 1), as are those that
3290 * shatter inside the player inventory.
3291 * (Not anymore -- I changed this; TY)
3292 * y, x --- coordinates of the potion (or player if
3293 * the potion was in her inventory);
3294 * o_ptr --- pointer to the potion object.
3297 bool potion_smash_effect(MONSTER_IDX who, POSITION y, POSITION x, KIND_OBJECT_IDX 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 * @brief プレイヤーの全既知呪文を表示する /
3440 * Hack -- Display all known spells in a window
3443 * XXX XXX XXX Need to analyze size of the window.
3444 * XXX XXX XXX Need more color coding.
3446 void display_spell_list(void)
3451 const magic_type *s_ptr;
3459 /* They have too many spells to list */
3460 if (p_ptr->pclass == CLASS_SORCERER) return;
3461 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3464 if (p_ptr->pclass == CLASS_SNIPER)
3466 display_snipe_list();
3470 /* mind.c type classes */
3471 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3472 (p_ptr->pclass == CLASS_BERSERKER) ||
3473 (p_ptr->pclass == CLASS_NINJA) ||
3474 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3475 (p_ptr->pclass == CLASS_FORCETRAINER))
3478 PLAYER_LEVEL plev = p_ptr->lev;
3484 bool use_hp = FALSE;
3489 /* Display a list of spells */
3491 put_str(_("名前", "Name"), y, x + 5);
3492 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
3494 switch(p_ptr->pclass)
3496 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3497 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3498 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3499 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3500 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3501 default: use_mind = 0;break;
3504 /* Dump the spells */
3505 for (i = 0; i < MAX_MIND_POWERS; i++)
3507 byte a = TERM_WHITE;
3509 /* Access the available spell */
3510 spell = mind_powers[use_mind].info[i];
3511 if (spell.min_lev > plev) break;
3513 /* Get the failure rate */
3514 chance = spell.fail;
3516 /* Reduce failure rate by "effective" level adjustment */
3517 chance -= 3 * (p_ptr->lev - spell.min_lev);
3519 /* Reduce failure rate by INT/WIS adjustment */
3520 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3524 /* Not enough mana to cast */
3525 if (spell.mana_cost > p_ptr->csp)
3527 chance += 5 * (spell.mana_cost - p_ptr->csp);
3533 /* Not enough hp to cast */
3534 if (spell.mana_cost > p_ptr->chp)
3541 /* Extract the minimum failure rate */
3542 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3544 /* Minimum failure rate */
3545 if (chance < minfail) chance = minfail;
3547 /* Stunning makes spells harder */
3548 if (p_ptr->stun > 50) chance += 25;
3549 else if (p_ptr->stun) chance += 15;
3551 /* Always a 5 percent chance of working */
3552 if (chance > 95) chance = 95;
3555 mindcraft_info(comment, use_mind, i);
3557 /* Dump the spell */
3558 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3560 spell.min_lev, spell.mana_cost, chance, comment);
3562 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3567 /* Cannot read spellbooks */
3568 if (REALM_NONE == p_ptr->realm1) return;
3570 /* Normal spellcaster with books */
3573 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3577 /* Reset vertical */
3580 /* Vertical location */
3581 y = (j < 3) ? 0 : (m[j - 3] + 2);
3583 /* Horizontal location */
3587 for (i = 0; i < 32; i++)
3589 byte a = TERM_WHITE;
3591 /* Access the spell */
3592 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3594 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3598 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3601 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
3604 if (s_ptr->slevel >= 99)
3607 strcpy(name, _("(判読不能)", "(illegible)"));
3615 ((p_ptr->spell_forgotten1 & (1L << i))) :
3616 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3623 else if (!((j < 1) ?
3624 (p_ptr->spell_learned1 & (1L << i)) :
3625 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3632 else if (!((j < 1) ?
3633 (p_ptr->spell_worked1 & (1L << i)) :
3634 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3640 /* Dump the spell --(-- */
3641 sprintf(out_val, "%c/%c) %-20.20s",
3642 I2A(n / 8), I2A(n % 8), name);
3647 /* Dump onto the window */
3648 Term_putstr(x, m[j], -1, a, out_val);
3658 * @brief 呪文の経験値を返す /
3659 * Returns experience of a spell
3661 * @param use_realm 魔法領域
3664 s16b experience_of_spell(int spell, int use_realm)
3666 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3667 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3668 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3669 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3675 * @brief 呪文の消費MPを返す /
3676 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3677 * @param need_mana 基本消費MP
3682 int mod_need_mana(int need_mana, int spell, int realm)
3684 #define MANA_CONST 2400
3686 #define DEC_MANA_DIV 3
3689 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
3692 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
3693 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
3695 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
3696 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
3697 need_mana /= MANA_CONST * MANA_DIV;
3698 if (need_mana < 1) need_mana = 1;
3701 /* Non-realm magic */
3704 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
3716 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
3717 * Modify spell fail rate
3718 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3719 * @param chance 修正前失敗率
3723 PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
3725 chance += p_ptr->to_m_chance;
3727 if (p_ptr->heavy_spell) chance += 20;
3729 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
3730 else if (p_ptr->easy_spell) chance -= 3;
3731 else if (p_ptr->dec_mana) chance -= 2;
3738 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
3739 * Modify spell fail rate
3740 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3741 * @param chance 修正前失敗率
3743 * Modify spell fail rate (as "suffix" process)
3744 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3745 * Note: variable "chance" cannot be negative.
3748 PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
3750 if (p_ptr->dec_mana) chance--;
3752 if (p_ptr->heavy_spell) chance += 5;
3754 return MAX(chance, 0);
3759 * @brief 呪文の失敗率計算メインルーチン /
3760 * Returns spell chance of failure for spell -RAK-
3762 * @param use_realm 魔法領域ID
3765 PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
3767 PERCENTAGE chance, minfail;
3768 const magic_type *s_ptr;
3769 MANA_POINT need_mana;
3770 PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
3773 /* Paranoia -- must be literate */
3774 if (!mp_ptr->spell_book) return (100);
3776 if (use_realm == REALM_HISSATSU) return 0;
3778 /* Access the spell */
3779 if (!is_magic(use_realm))
3781 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3785 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3788 /* Extract the base spell failure rate */
3789 chance = s_ptr->sfail;
3791 /* Reduce failure rate by "effective" level adjustment */
3792 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
3794 /* Reduce failure rate by INT/WIS adjustment */
3795 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3798 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
3800 /* Extract mana consumption rate */
3801 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3803 /* Not enough mana to cast */
3804 if (need_mana > p_ptr->csp)
3806 chance += 5 * (need_mana - p_ptr->csp);
3809 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
3811 /* Extract the minimum failure rate */
3812 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3815 * Non mage/priest characters never get too good
3816 * (added high mage, mindcrafter)
3818 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
3820 if (minfail < 5) minfail = 5;
3823 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
3824 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3825 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
3827 chance = mod_spell_chance_1(chance);
3829 /* Goodness or evilness gives a penalty to failure rate */
3833 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3835 case REALM_LIFE: case REALM_CRUSADE:
3836 if (p_ptr->align < -20) chance += penalty;
3838 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3839 if (p_ptr->align > 20) chance += penalty;
3843 /* Minimum failure rate */
3844 if (chance < minfail) chance = minfail;
3846 /* Stunning makes spells harder */
3847 if (p_ptr->stun > 50) chance += 25;
3848 else if (p_ptr->stun) chance += 15;
3850 /* Always a 5 percent chance of working */
3851 if (chance > 95) chance = 95;
3853 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3854 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3856 s16b exp = experience_of_spell(spell, use_realm);
3857 if (exp >= SPELL_EXP_EXPERT) chance--;
3858 if (exp >= SPELL_EXP_MASTER) chance--;
3861 /* Return the chance */
3862 return mod_spell_chance_2(chance);
3867 * @brief 魔法が利用可能かどうかを返す /
3868 * Determine if a spell is "okay" for the player to cast or study
3869 * The spell must be legible, not forgotten, and also, to cast,
3870 * it must be known, and to study, it must not be known.
3872 * @param learned 使用可能な判定ならばTRUE、学習可能かどうかの判定ならばFALSE
3873 * @param study_pray 祈りの学習判定目的ならばTRUE
3874 * @param use_realm 魔法領域ID
3877 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
3879 const magic_type *s_ptr;
3881 /* Access the spell */
3882 if (!is_magic(use_realm))
3884 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3888 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3891 /* Spell is illegal */
3892 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
3894 /* Spell is forgotten */
3895 if ((use_realm == p_ptr->realm2) ?
3896 (p_ptr->spell_forgotten2 & (1L << spell)) :
3897 (p_ptr->spell_forgotten1 & (1L << spell)))
3903 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
3904 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
3906 /* Spell is learned */
3907 if ((use_realm == p_ptr->realm2) ?
3908 (p_ptr->spell_learned2 & (1L << spell)) :
3909 (p_ptr->spell_learned1 & (1L << spell)))
3912 return (!study_pray);
3915 /* Okay to study, not to cast */
3922 * @brief 呪文情報の表示処理 /
3923 * Print a list of spells (for browsing or casting or viewing)
3924 * @param target_spell 呪文ID
3925 * @param spells 表示するスペルID配列の参照ポインタ
3926 * @param num 表示するスペルの数(spellsの要素数)
3927 * @param y 表示メッセージ左上Y座標
3928 * @param x 表示メッセージ左上X座標
3929 * @param use_realm 魔法領域ID
3932 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm)
3934 int i, spell, exp_level, increment = 64;
3935 const magic_type *s_ptr;
3946 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
3947 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
3949 /* Title the list */
3951 if (use_realm == REALM_HISSATSU)
3952 strcpy(buf,_(" Lv MP", " Lv SP"));
3954 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
3956 put_str(_("名前", "Name"), y, x + 5);
3957 put_str(buf, y, x + 29);
3959 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
3960 else if (use_realm == p_ptr->realm1) increment = 0;
3961 else if (use_realm == p_ptr->realm2) increment = 32;
3963 /* Dump the spells */
3964 for (i = 0; i < num; i++)
3966 /* Access the spell */
3969 /* Access the spell */
3970 if (!is_magic(use_realm))
3972 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3976 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3979 if (use_realm == REALM_HISSATSU)
3980 need_mana = s_ptr->smana;
3983 s16b exp = experience_of_spell(spell, use_realm);
3985 /* Extract mana consumption rate */
3986 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3988 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
3989 else exp_level = spell_exp_level(exp);
3992 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
3993 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
3994 else if (s_ptr->slevel >= 99) max = TRUE;
3995 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
3997 strncpy(ryakuji, exp_level_str[exp_level], 4);
4002 if (use_menu && target_spell)
4004 if (i == (target_spell-1))
4005 strcpy(out_val, _(" 》 ", " > "));
4007 strcpy(out_val, " ");
4009 else sprintf(out_val, " %c) ", I2A(i));
4010 /* Skip illegible spells */
4011 if (s_ptr->slevel >= 99)
4013 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
4014 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4018 /* XXX XXX Could label spells above the players level */
4020 /* Get extra info */
4021 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
4026 /* Assume spell is known and tried */
4027 line_attr = TERM_WHITE;
4029 /* Analyze the spell */
4030 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4032 if (s_ptr->slevel > p_ptr->max_plv)
4034 comment = _("未知", "unknown");
4035 line_attr = TERM_L_BLUE;
4037 else if (s_ptr->slevel > p_ptr->lev)
4039 comment = _("忘却", "forgotten");
4040 line_attr = TERM_YELLOW;
4043 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4045 comment = _("未知", "unknown");
4046 line_attr = TERM_L_BLUE;
4048 else if ((use_realm == p_ptr->realm1) ?
4049 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4050 ((p_ptr->spell_forgotten2 & (1L << spell))))
4052 comment = _("忘却", "forgotten");
4053 line_attr = TERM_YELLOW;
4055 else if (!((use_realm == p_ptr->realm1) ?
4056 (p_ptr->spell_learned1 & (1L << spell)) :
4057 (p_ptr->spell_learned2 & (1L << spell))))
4059 comment = _("未知", "unknown");
4060 line_attr = TERM_L_BLUE;
4062 else if (!((use_realm == p_ptr->realm1) ?
4063 (p_ptr->spell_worked1 & (1L << spell)) :
4064 (p_ptr->spell_worked2 & (1L << spell))))
4066 comment = _("未経験", "untried");
4067 line_attr = TERM_L_GREEN;
4070 /* Dump the spell --(-- */
4071 if (use_realm == REALM_HISSATSU)
4073 strcat(out_val, format("%-25s %2d %4d",
4074 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4075 s_ptr->slevel, need_mana));
4079 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4080 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4081 (max ? '!' : ' '), ryakuji,
4082 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4084 c_prt(line_attr, out_val, y + i + 1, x);
4087 /* Clear the bottom line */
4088 prt("", y + i + 1, x);
4093 * @brief アイテムが酸で破損するかどうかを判定する
4094 * @param o_ptr アイテムの情報参照ポインタ
4095 * @return 破損するならばTRUEを返す
4096 * Note that amulets, rods, and high-level spell books are immune
4097 * to "inventory damage" of any kind. Also sling ammo and shovels.
4098 * Does a given class of objects (usually) hate acid?
4099 * Note that acid can either melt or corrode something.
4101 bool hates_acid(object_type *o_ptr)
4103 /* Analyze the type */
4104 switch (o_ptr->tval)
4106 /* Wearable items */
4126 /* Staffs/Scrolls are wood/paper */
4139 /* Junk is useless */
4153 * @brief アイテムが電撃で破損するかどうかを判定する /
4154 * Does a given object (usually) hate electricity?
4155 * @param o_ptr アイテムの情報参照ポインタ
4156 * @return 破損するならばTRUEを返す
4158 bool hates_elec(object_type *o_ptr)
4160 switch (o_ptr->tval)
4174 * @brief アイテムが火炎で破損するかどうかを判定する /
4175 * Does a given object (usually) hate fire?
4176 * @param o_ptr アイテムの情報参照ポインタ
4177 * @return 破損するならばTRUEを返す
4179 * Hafted/Polearm weapons have wooden shafts.
4180 * Arrows/Bows are mostly wooden.
4182 bool hates_fire(object_type *o_ptr)
4184 /* Analyze the type */
4185 switch (o_ptr->tval)
4203 case TV_SORCERY_BOOK:
4204 case TV_NATURE_BOOK:
4208 case TV_ARCANE_BOOK:
4210 case TV_DAEMON_BOOK:
4211 case TV_CRUSADE_BOOK:
4213 case TV_HISSATSU_BOOK:
4225 /* Staffs/Scrolls burn */
4238 * @brief アイテムが冷気で破損するかどうかを判定する /
4239 * Does a given object (usually) hate cold?
4240 * @param o_ptr アイテムの情報参照ポインタ
4241 * @return 破損するならばTRUEを返す
4243 bool hates_cold(object_type *o_ptr)
4245 switch (o_ptr->tval)
4260 * @brief アイテムが酸で破損するかどうかを判定する(メインルーチン) /
4262 * @param o_ptr アイテムの情報参照ポインタ
4263 * @return 破損するならばTRUEを返す
4266 int set_acid_destroy(object_type *o_ptr)
4268 BIT_FLAGS flgs[TR_FLAG_SIZE];
4269 if (!hates_acid(o_ptr)) return (FALSE);
4270 object_flags(o_ptr, flgs);
4271 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4277 * @brief アイテムが電撃で破損するかどうかを判定する(メインルーチン) /
4279 * @param o_ptr アイテムの情報参照ポインタ
4280 * @return 破損するならばTRUEを返す
4283 int set_elec_destroy(object_type *o_ptr)
4285 BIT_FLAGS flgs[TR_FLAG_SIZE];
4286 if (!hates_elec(o_ptr)) return (FALSE);
4287 object_flags(o_ptr, flgs);
4288 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4294 * @brief アイテムが火炎で破損するかどうかを判定する(メインルーチン) /
4296 * @param o_ptr アイテムの情報参照ポインタ
4297 * @return 破損するならばTRUEを返す
4300 int set_fire_destroy(object_type *o_ptr)
4302 BIT_FLAGS flgs[TR_FLAG_SIZE];
4303 if (!hates_fire(o_ptr)) return (FALSE);
4304 object_flags(o_ptr, flgs);
4305 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4311 * @brief アイテムが冷気で破損するかどうかを判定する(メインルーチン) /
4313 * @param o_ptr アイテムの情報参照ポインタ
4314 * @return 破損するならばTRUEを返す
4317 int set_cold_destroy(object_type *o_ptr)
4319 BIT_FLAGS flgs[TR_FLAG_SIZE];
4320 if (!hates_cold(o_ptr)) return (FALSE);
4321 object_flags(o_ptr, flgs);
4322 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4328 * @brief アイテムが指定確率で破損するかどうかを判定する /
4329 * Destroys a type of item on a given percent chance
4330 * @param typ 破損判定関数ポインタ
4332 * @return 破損したアイテムの数
4334 * Note that missiles are no longer necessarily all destroyed
4335 * Destruction taken from "melee.c" code for "stealing".
4336 * New-style wands and rods handled correctly. -LM-
4337 * Returns number of items destroyed.
4339 int inven_damage(inven_func typ, int perc)
4344 char o_name[MAX_NLEN];
4346 if (CHECK_MULTISHADOW()) return 0;
4348 if (p_ptr->inside_arena) return 0;
4350 /* Count the casualties */
4353 /* Scan through the slots backwards */
4354 for (i = 0; i < INVEN_PACK; i++)
4356 o_ptr = &inventory[i];
4358 /* Skip non-objects */
4359 if (!o_ptr->k_idx) continue;
4361 /* Hack -- for now, skip artifacts */
4362 if (object_is_artifact(o_ptr)) continue;
4364 /* Give this item slot a shot at death */
4367 /* Count the casualties */
4368 for (amt = j = 0; j < o_ptr->number; ++j)
4370 if (randint0(100) < perc) amt++;
4373 /* Some casualities */
4376 /* Get a description */
4377 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4379 msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
4382 o_name, index_to_label(i),
4383 ((o_ptr->number > 1) ?
4384 ((amt == o_ptr->number) ? "全部" :
4385 (amt > 1 ? "何個か" : "一個")) : "") );
4387 ((o_ptr->number > 1) ?
4388 ((amt == o_ptr->number) ? "All of y" :
4389 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4390 o_name, index_to_label(i),
4391 ((amt > 1) ? "were" : "was"));
4395 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4396 msg_print("やりやがったな!");
4399 /* Potions smash open */
4400 if (object_is_potion(o_ptr))
4402 (void)potion_smash_effect(0, p_ptr->y, p_ptr->x, o_ptr->k_idx);
4405 /* Reduce the charges of rods/wands */
4406 reduce_charges(o_ptr, amt);
4408 /* Destroy "amt" items */
4409 inven_item_increase(i, -amt);
4410 inven_item_optimize(i);
4412 /* Count the casualties */
4418 /* Return the casualty count */
4424 * @brief 酸攻撃による装備のAC劣化処理 /
4425 * Acid has hit the player, attempt to affect some armor.
4426 * @return ACが実際に劣化したらTRUEを返す
4428 * Note that the "base armor" of an object never changes.
4429 * If any armor is damaged (or resists), the player takes less damage.
4431 static int minus_ac(void)
4433 object_type *o_ptr = NULL;
4434 BIT_FLAGS flgs[TR_FLAG_SIZE];
4435 char o_name[MAX_NLEN];
4438 /* Pick a (possibly empty) inventory slot */
4439 switch (randint1(7))
4441 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4442 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4443 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4444 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4445 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4446 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4447 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4450 /* Nothing to damage */
4451 if (!o_ptr->k_idx) return (FALSE);
4453 if (!object_is_armour(o_ptr)) return (FALSE);
4455 /* No damage left to be done */
4456 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4460 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4462 /* Extract the flags */
4463 object_flags(o_ptr, flgs);
4465 /* Object resists */
4466 if (have_flag(flgs, TR_IGNORE_ACID))
4468 msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), o_name);
4472 msg_format(_("%sがダメージを受けた!", "Your %s is damaged!"), o_name);
4474 /* Damage the item */
4477 /* Calculate bonuses */
4478 p_ptr->update |= (PU_BONUS);
4480 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4484 /* Item was damaged */
4490 * @brief 酸属性によるプレイヤー損害処理 /
4491 * Hurt the player with Acid
4492 * @param dam 基本ダメージ量
4493 * @param kb_str ダメージ原因記述
4494 * @param monspell 原因となったモンスター特殊攻撃ID
4495 * @param aura オーラよるダメージが原因ならばTRUE
4498 int acid_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4501 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4502 bool double_resist = IS_OPPOSE_ACID();
4504 /* Total Immunity */
4505 if (p_ptr->immune_acid || (dam <= 0))
4507 learn_spell(monspell);
4511 /* Vulnerability (Ouch!) */
4512 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4513 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4515 /* Resist the damage */
4516 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
4517 if (double_resist) dam = (dam + 2) / 3;
4519 if (aura || !CHECK_MULTISHADOW())
4521 if ((!(double_resist || p_ptr->resist_acid)) &&
4522 one_in_(HURT_CHANCE))
4523 (void)do_dec_stat(A_CHR);
4525 /* If any armor gets hit, defend the player */
4526 if (minus_ac()) dam = (dam + 1) / 2;
4530 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4532 /* Inventory damage */
4533 if (!aura && !(double_resist && p_ptr->resist_acid))
4534 inven_damage(set_acid_destroy, inv);
4540 * @brief 電撃属性によるプレイヤー損害処理 /
4541 * Hurt the player with electricity
4542 * @param dam 基本ダメージ量
4543 * @param kb_str ダメージ原因記述
4544 * @param monspell 原因となったモンスター特殊攻撃ID
4545 * @param aura オーラよるダメージが原因ならばTRUE
4548 int elec_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4551 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4552 bool double_resist = IS_OPPOSE_ELEC();
4554 /* Total immunity */
4555 if (p_ptr->immune_elec || (dam <= 0))
4557 learn_spell(monspell);
4561 /* Vulnerability (Ouch!) */
4562 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4563 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4564 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
4566 /* Resist the damage */
4567 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
4568 if (double_resist) dam = (dam + 2) / 3;
4570 if (aura || !CHECK_MULTISHADOW())
4572 if ((!(double_resist || p_ptr->resist_elec)) &&
4573 one_in_(HURT_CHANCE))
4574 (void)do_dec_stat(A_DEX);
4578 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4580 /* Inventory damage */
4581 if (!aura && !(double_resist && p_ptr->resist_elec))
4582 inven_damage(set_elec_destroy, inv);
4589 * @brief 火炎属性によるプレイヤー損害処理 /
4590 * Hurt the player with Fire
4591 * @param dam 基本ダメージ量
4592 * @param kb_str ダメージ原因記述
4593 * @param monspell 原因となったモンスター特殊攻撃ID
4594 * @param aura オーラよるダメージが原因ならばTRUE
4597 int fire_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4600 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4601 bool double_resist = IS_OPPOSE_FIRE();
4603 /* Totally immune */
4604 if (p_ptr->immune_fire || (dam <= 0))
4606 learn_spell(monspell);
4610 /* Vulnerability (Ouch!) */
4611 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4612 if (prace_is_(RACE_ENT)) dam += dam / 3;
4613 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4615 /* Resist the damage */
4616 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
4617 if (double_resist) dam = (dam + 2) / 3;
4619 if (aura || !CHECK_MULTISHADOW())
4621 if ((!(double_resist || p_ptr->resist_fire)) &&
4622 one_in_(HURT_CHANCE))
4623 (void)do_dec_stat(A_STR);
4627 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4629 /* Inventory damage */
4630 if (!aura && !(double_resist && p_ptr->resist_fire))
4631 inven_damage(set_fire_destroy, inv);
4638 * @brief 冷気属性によるプレイヤー損害処理 /
4639 * Hurt the player with Cold
4640 * @param dam 基本ダメージ量
4641 * @param kb_str ダメージ原因記述
4642 * @param monspell 原因となったモンスター特殊攻撃ID
4643 * @param aura オーラよるダメージが原因ならばTRUE
4646 int cold_dam(HIT_POINT dam, cptr kb_str, int monspell, bool aura)
4649 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4650 bool double_resist = IS_OPPOSE_COLD();
4652 /* Total immunity */
4653 if (p_ptr->immune_cold || (dam <= 0))
4655 learn_spell(monspell);
4659 /* Vulnerability (Ouch!) */
4660 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4661 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4663 /* Resist the damage */
4664 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
4665 if (double_resist) dam = (dam + 2) / 3;
4667 if (aura || !CHECK_MULTISHADOW())
4669 if ((!(double_resist || p_ptr->resist_cold)) &&
4670 one_in_(HURT_CHANCE))
4671 (void)do_dec_stat(A_STR);
4675 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
4677 /* Inventory damage */
4678 if (!aura && !(double_resist && p_ptr->resist_cold))
4679 inven_damage(set_cold_destroy, inv);
4686 * @return ターン消費を要する処理を行ったならばTRUEを返す
4688 bool rustproof(void)
4692 char o_name[MAX_NLEN];
4695 item_tester_no_ryoute = TRUE;
4696 /* Select a piece of armour */
4697 item_tester_hook = object_is_armour;
4700 q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
4701 s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
4703 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
4705 /* Get the item (in the pack) */
4708 o_ptr = &inventory[item];
4711 /* Get the item (on the floor) */
4714 o_ptr = &o_list[0 - item];
4719 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4721 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
4723 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
4726 msg_format("%sは新品同様になった!",o_name);
4728 msg_format("%s %s look%s as good as new!",
4729 ((item >= 0) ? "Your" : "The"), o_name,
4730 ((o_ptr->number > 1) ? "" : "s"));
4737 msg_format("%sは腐食しなくなった。", o_name);
4739 msg_format("%s %s %s now protected against corrosion.",
4740 ((item >= 0) ? "Your" : "The"), o_name,
4741 ((o_ptr->number > 1) ? "are" : "is"));
4753 * Curse the players armor
4754 * @return 実際に呪縛されたらTRUEを返す
4756 bool curse_armor(void)
4761 char o_name[MAX_NLEN];
4764 /* Curse the body armor */
4765 o_ptr = &inventory[INVEN_BODY];
4767 /* Nothing to curse */
4768 if (!o_ptr->k_idx) return (FALSE);
4772 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4774 /* Attempt a saving throw for artifacts */
4775 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
4779 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
4780 "恐怖の暗黒オーラ", "防具", o_name);
4782 msg_format("A %s tries to %s, but your %s resists the effects!",
4783 "terrible black aura", "surround your armor", o_name);
4788 /* not artifact or failed save... */
4792 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4793 chg_virtue(V_ENCHANT, -5);
4795 /* Blast the armor */
4797 o_ptr->name2 = EGO_BLASTED;
4798 o_ptr->to_a = 0 - randint1(5) - randint1(5);
4805 for (i = 0; i < TR_FLAG_SIZE; i++)
4806 o_ptr->art_flags[i] = 0;
4809 o_ptr->curse_flags = TRC_CURSED;
4812 o_ptr->ident |= (IDENT_BROKEN);
4814 /* Recalculate bonuses */
4815 p_ptr->update |= (PU_BONUS);
4817 /* Recalculate mana */
4818 p_ptr->update |= (PU_MANA);
4820 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
4828 * Curse the players weapon
4829 * @param force 無条件に呪縛を行うならばTRUE
4830 * @param o_ptr 呪縛する武器のアイテム情報参照ポインタ
4831 * @return 実際に呪縛されたらTRUEを返す
4833 bool curse_weapon_object(bool force, object_type *o_ptr)
4836 char o_name[MAX_NLEN];
4838 /* Nothing to curse */
4839 if (!o_ptr->k_idx) return (FALSE);
4842 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4844 /* Attempt a saving throw */
4845 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
4849 msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
4850 "恐怖の暗黒オーラ", "武器", o_name);
4852 msg_format("A %s tries to %s, but your %s resists the effects!",
4853 "terrible black aura", "surround your weapon", o_name);
4857 /* not artifact or failed save... */
4861 if (!force) msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
4862 chg_virtue(V_ENCHANT, -5);
4864 /* Shatter the weapon */
4866 o_ptr->name2 = EGO_SHATTERED;
4867 o_ptr->to_h = 0 - randint1(5) - randint1(5);
4868 o_ptr->to_d = 0 - randint1(5) - randint1(5);
4874 for (i = 0; i < TR_FLAG_SIZE; i++)
4875 o_ptr->art_flags[i] = 0;
4878 o_ptr->curse_flags = TRC_CURSED;
4881 o_ptr->ident |= (IDENT_BROKEN);
4883 /* Recalculate bonuses */
4884 p_ptr->update |= (PU_BONUS);
4886 /* Recalculate mana */
4887 p_ptr->update |= (PU_MANA);
4889 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
4897 * @brief 武器呪縛処理のメインルーチン /
4898 * Curse the players weapon
4899 * @param force 無条件に呪縛を行うならばTRUE
4900 * @param slot 呪縛する武器の装備スロット
4901 * @return 実際に呪縛されたらTRUEを返す
4903 bool curse_weapon(bool force, int slot)
4905 /* Curse the weapon */
4906 return curse_weapon_object(force, &inventory[slot]);
4911 * @brief ボルトのエゴ化処理(火炎エゴのみ) /
4912 * Enchant some bolts
4915 bool brand_bolts(void)
4919 /* Use the first acceptable bolts */
4920 for (i = 0; i < INVEN_PACK; i++)
4922 object_type *o_ptr = &inventory[i];
4924 /* Skip non-bolts */
4925 if (o_ptr->tval != TV_BOLT) continue;
4927 /* Skip artifacts and ego-items */
4928 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
4931 /* Skip cursed/broken items */
4932 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
4935 if (randint0(100) < 75) continue;
4937 msg_print(_("クロスボウの矢が炎のオーラに包まれた!", "Your bolts are covered in a fiery aura!"));
4940 o_ptr->name2 = EGO_FLAME;
4943 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
4950 if (flush_failure) flush();
4953 msg_print(_("炎で強化するのに失敗した。", "The fiery enchantment failed."));
4961 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
4962 * Helper function -- return a "nearby" race for polymorphing
4963 * @param r_idx 基準となるモンスター種族ID
4964 * @return 変更先のモンスター種族ID
4966 * Note that this function is one of the more "dangerous" ones...
4968 static IDX poly_r_idx(MONRACE_IDX r_idx)
4970 monster_race *r_ptr = &r_info[r_idx];
4976 /* Hack -- Uniques/Questors never polymorph */
4977 if ((r_ptr->flags1 & RF1_UNIQUE) ||
4978 (r_ptr->flags1 & RF1_QUESTOR))
4981 /* Allowable range of "levels" for resulting monster */
4982 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
4983 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
4985 /* Pick a (possibly new) non-unique race */
4986 for (i = 0; i < 1000; i++)
4988 /* Pick a new race, using a level calculation */
4989 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
4991 /* Handle failure */
4997 /* Ignore unique monsters */
4998 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5000 /* Ignore monsters with incompatible levels */
5001 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5003 /* Use that index */
5014 * @brief 指定座標にいるモンスターを変身させる /
5015 * Helper function -- return a "nearby" race for polymorphing
5018 * @return 実際に変身したらTRUEを返す
5020 bool polymorph_monster(POSITION y, POSITION x)
5022 cave_type *c_ptr = &cave[y][x];
5023 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5024 bool polymorphed = FALSE;
5025 MONRACE_IDX new_r_idx;
5026 MONRACE_IDX old_r_idx = m_ptr->r_idx;
5027 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5028 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5029 monster_type back_m;
5031 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5033 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5035 /* Memorize the monster before polymorphing */
5038 /* Pick a "new" monster race */
5039 new_r_idx = poly_r_idx(old_r_idx);
5041 /* Handle polymorph */
5042 if (new_r_idx != old_r_idx)
5044 BIT_FLAGS mode = 0L;
5045 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
5046 OBJECT_IDX this_o_idx, next_o_idx = 0;
5048 /* Get the monsters attitude */
5049 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5050 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5051 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5053 /* Mega-hack -- ignore held objects */
5054 m_ptr->hold_o_idx = 0;
5056 /* "Kill" the "old" monster */
5057 delete_monster_idx(c_ptr->m_idx);
5059 /* Create a new monster (no groups) */
5060 if (place_monster_aux(0, y, x, new_r_idx, mode))
5062 m_list[hack_m_idx_ii].nickname = back_m.nickname;
5063 m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
5064 m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
5071 /* Placing the new monster failed */
5072 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5074 m_list[hack_m_idx_ii] = back_m;
5076 /* Re-initialize monster process */
5079 else preserve_hold_objects = FALSE;
5082 /* Mega-hack -- preserve held objects */
5083 if (preserve_hold_objects)
5085 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5087 /* Acquire object */
5088 object_type *o_ptr = &o_list[this_o_idx];
5090 /* Acquire next object */
5091 next_o_idx = o_ptr->next_o_idx;
5093 /* Held by new monster */
5094 o_ptr->held_m_idx = hack_m_idx_ii;
5097 else if (back_m.hold_o_idx) /* Failed (paranoia) */
5099 /* Delete objects */
5100 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5102 /* Acquire next object */
5103 next_o_idx = o_list[this_o_idx].next_o_idx;
5105 /* Delete the object */
5106 delete_object_idx(this_o_idx);
5110 if (targeted) target_who = hack_m_idx_ii;
5111 if (health_tracked) health_track(hack_m_idx_ii);
5120 * @param x テレポート先のX座標
5121 * @param y テレポート先のY座標
5122 * @return 目標に指定通りテレポートできたならばTRUEを返す
5124 static bool dimension_door_aux(DEPTH x, DEPTH y)
5126 PLAYER_LEVEL plev = p_ptr->lev;
5128 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5130 if (!cave_player_teleportable_bold(y, x, 0L) ||
5131 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
5132 (!randint0(plev / 10 + 10)))
5134 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5135 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
5142 teleport_player_to(y, x, 0L);
5151 * @brief 次元の扉処理のメインルーチン /
5153 * @return ターンを消費した場合TRUEを返す
5155 bool dimension_door(void)
5159 /* Rerutn FALSE if cancelled */
5160 if (!tgt_pt(&x, &y)) return FALSE;
5162 if (dimension_door_aux(x, y)) return TRUE;
5164 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
5171 * @brief 鏡抜け処理のメインルーチン /
5172 * Mirror Master's Dimension Door
5173 * @return ターンを消費した場合TRUEを返す
5175 bool mirror_tunnel(void)
5177 POSITION x = 0, y = 0;
5179 /* Rerutn FALSE if cancelled */
5180 if (!tgt_pt(&x, &y)) return FALSE;
5182 if (dimension_door_aux(x, y)) return TRUE;
5184 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
5192 * @return ターンを消費した場合TRUEを返す
5194 bool eat_magic(int power)
5200 int recharge_strength = 0;
5206 char o_name[MAX_NLEN];
5208 item_tester_hook = item_tester_hook_recharge;
5211 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
5212 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
5214 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5218 o_ptr = &inventory[item];
5222 o_ptr = &o_list[0 - item];
5225 k_ptr = &k_info[o_ptr->k_idx];
5226 lev = k_info[o_ptr->k_idx].level;
5228 if (o_ptr->tval == TV_ROD)
5230 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5233 if (one_in_(recharge_strength))
5235 /* Activate the failure code. */
5240 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5242 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
5247 o_ptr->timeout += k_ptr->pval;
5253 /* All staffs, wands. */
5254 recharge_strength = (100 + power - lev) / 15;
5257 if (recharge_strength < 0) recharge_strength = 0;
5260 if (one_in_(recharge_strength))
5262 /* Activate the failure code. */
5267 if (o_ptr->pval > 0)
5269 p_ptr->csp += lev / 2;
5272 /* XXX Hack -- unstack if necessary */
5273 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5278 /* Get local object */
5281 /* Obtain a local object */
5282 object_copy(q_ptr, o_ptr);
5284 /* Modify quantity */
5287 /* Restore the charges */
5290 /* Unstack the used item */
5292 p_ptr->total_weight -= q_ptr->weight;
5293 item = inven_carry(q_ptr);
5295 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
5300 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
5302 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5306 /* Inflict the penalties for failing a recharge. */
5309 /* Artifacts are never destroyed. */
5310 if (object_is_fixed_artifact(o_ptr))
5312 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5313 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
5315 /* Artifact rods. */
5316 if (o_ptr->tval == TV_ROD)
5317 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5319 /* Artifact wands and staffs. */
5320 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5325 /* Get the object description */
5326 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5328 /*** Determine Seriousness of Failure ***/
5330 /* Mages recharge objects more safely. */
5331 if (IS_WIZARD_CLASS())
5333 /* 10% chance to blow up one rod, otherwise draining. */
5334 if (o_ptr->tval == TV_ROD)
5336 if (one_in_(10)) fail_type = 2;
5339 /* 75% chance to blow up one wand, otherwise draining. */
5340 else if (o_ptr->tval == TV_WAND)
5342 if (!one_in_(3)) fail_type = 2;
5345 /* 50% chance to blow up one staff, otherwise no effect. */
5346 else if (o_ptr->tval == TV_STAFF)
5348 if (one_in_(2)) fail_type = 2;
5353 /* All other classes get no special favors. */
5356 /* 33% chance to blow up one rod, otherwise draining. */
5357 if (o_ptr->tval == TV_ROD)
5359 if (one_in_(3)) fail_type = 2;
5362 /* 20% chance of the entire stack, else destroy one wand. */
5363 else if (o_ptr->tval == TV_WAND)
5365 if (one_in_(5)) fail_type = 3;
5368 /* Blow up one staff. */
5369 else if (o_ptr->tval == TV_STAFF)
5375 /*** Apply draining and destruction. ***/
5377 /* Drain object or stack of objects. */
5380 if (o_ptr->tval == TV_ROD)
5382 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
5383 "You save your rod from destruction, but all charges are lost."), o_name);
5384 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5386 else if (o_ptr->tval == TV_WAND)
5388 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
5391 /* Staffs aren't drained. */
5394 /* Destroy an object or one in a stack of objects. */
5397 if (o_ptr->number > 1)
5399 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
5400 /* Reduce rod stack maximum timeout, drain wands. */
5401 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5402 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5406 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
5409 /* Reduce and describe inventory */
5412 inven_item_increase(item, -1);
5413 inven_item_describe(item);
5414 inven_item_optimize(item);
5417 /* Reduce and describe floor item */
5420 floor_item_increase(0 - item, -1);
5421 floor_item_describe(0 - item);
5422 floor_item_optimize(0 - item);
5426 /* Destroy all members of a stack of objects. */
5429 if (o_ptr->number > 1)
5430 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
5432 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
5434 /* Reduce and describe inventory */
5437 inven_item_increase(item, -999);
5438 inven_item_describe(item);
5439 inven_item_optimize(item);
5442 /* Reduce and describe floor item */
5445 floor_item_increase(0 - item, -999);
5446 floor_item_describe(0 - item);
5447 floor_item_optimize(0 - item);
5453 if (p_ptr->csp > p_ptr->msp)
5455 p_ptr->csp = p_ptr->msp;
5458 /* Redraw mana and hp */
5459 p_ptr->redraw |= (PR_MANA);
5461 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5462 p_ptr->window |= (PW_INVEN);
5469 * @param level 召喚基準レベル
5472 * @param mode 召喚オプション
5473 * @return ターンを消費した場合TRUEを返す
5475 bool summon_kin_player(DEPTH level, POSITION y, POSITION x, BIT_FLAGS mode)
5477 bool pet = (bool)(mode & PM_FORCE_PET);
5478 if (!pet) mode |= PM_NO_PET;
5480 switch (p_ptr->mimic_form)
5483 switch (p_ptr->prace)
5487 case RACE_BARBARIAN:
5490 summon_kin_type = 'p';
5500 case RACE_MIND_FLAYER:
5503 summon_kin_type = 'h';
5506 summon_kin_type = 'o';
5508 case RACE_HALF_TROLL:
5509 summon_kin_type = 'T';
5511 case RACE_HALF_OGRE:
5512 summon_kin_type = 'O';
5514 case RACE_HALF_GIANT:
5515 case RACE_HALF_TITAN:
5517 summon_kin_type = 'P';
5520 summon_kin_type = 'y';
5523 summon_kin_type = 'K';
5526 summon_kin_type = 'k';
5529 if (one_in_(13)) summon_kin_type = 'U';
5530 else summon_kin_type = 'u';
5532 case RACE_DRACONIAN:
5533 summon_kin_type = 'd';
5537 summon_kin_type = 'g';
5540 if (one_in_(13)) summon_kin_type = 'L';
5541 else summon_kin_type = 's';
5544 summon_kin_type = 'z';
5547 summon_kin_type = 'V';
5550 summon_kin_type = 'G';
5553 summon_kin_type = 'I';
5556 summon_kin_type = '#';
5559 summon_kin_type = 'A';
5562 summon_kin_type = 'U';
5565 summon_kin_type = 'p';
5570 if (one_in_(13)) summon_kin_type = 'U';
5571 else summon_kin_type = 'u';
5573 case MIMIC_DEMON_LORD:
5574 summon_kin_type = 'U';
5577 summon_kin_type = 'V';
5580 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);
5584 * @brief 皆殺し(全方向攻撃)処理
5585 * @param py プレイヤーY座標
5586 * @param px プレイヤーX座標
5593 monster_type *m_ptr;
5596 for (dir = 0; dir < 8; dir++)
5598 y = p_ptr->y + ddy_ddd[dir];
5599 x = p_ptr->x + ddx_ddd[dir];
5600 c_ptr = &cave[y][x];
5602 /* Get the monster */
5603 m_ptr = &m_list[c_ptr->m_idx];
5605 /* Hack -- attack monsters */
5606 if (c_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
5615 feature_type *f_ptr, *mimic_f_ptr;
5618 if (!get_rep_dir2(&dir)) return FALSE;
5619 y = p_ptr->y + ddy[dir];
5620 x = p_ptr->x + ddx[dir];
5621 c_ptr = &cave[y][x];
5622 f_ptr = &f_info[c_ptr->feat];
5623 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
5627 if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
5629 msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
5631 else if (have_flag(f_ptr->flags, FF_PERMANENT))
5633 msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch! This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
5635 else if (c_ptr->m_idx)
5637 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5638 msg_print(_("何かが邪魔しています!", "There's something in the way!"));
5640 if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(y, x, 0);
5642 else if (have_flag(f_ptr->flags, FF_TREE))
5644 msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
5646 else if (have_flag(f_ptr->flags, FF_GLASS))
5648 msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
5650 else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
5652 (void)set_food(p_ptr->food + 3000);
5654 else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
5656 (void)set_food(p_ptr->food + 5000);
5660 msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
5661 (void)set_food(p_ptr->food + 10000);
5664 /* Destroy the wall */
5665 cave_alter_feat(y, x, FF_HURT_ROCK);
5667 /* Move the player */
5668 (void)move_player_effect(y, x, MPE_DONT_PICKUP);
5673 bool shock_power(void)
5678 PLAYER_LEVEL plev = p_ptr->lev;
5679 int boost = P_PTR_KI;
5680 if (heavy_armor()) boost /= 2;
5683 if (!get_aim_dir(&dir)) return FALSE;
5685 y = p_ptr->y + ddy[dir];
5686 x = p_ptr->x + ddx[dir];
5687 dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
5688 fire_beam(GF_MISSILE, dir, dam);
5689 if (cave[y][x].m_idx)
5694 MONSTER_IDX m_idx = cave[y][x].m_idx;
5695 monster_type *m_ptr = &m_list[m_idx];
5696 monster_race *r_ptr = &r_info[m_ptr->r_idx];
5699 monster_desc(m_name, m_ptr, 0);
5701 if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2)
5703 msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
5707 for (i = 0; i < 5; i++)
5711 if (cave_empty_bold(y, x))
5718 if ((ty != oy) || (tx != ox))
5720 msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
5721 cave[oy][ox].m_idx = 0;
5722 cave[ty][tx].m_idx = (s16b)m_idx;
5723 m_ptr->fy = (byte_hack)ty;
5724 m_ptr->fx = (byte_hack)tx;
5726 update_mon(m_idx, TRUE);
5730 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
5731 p_ptr->update |= (PU_MON_LITE);