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.
20 #include "object-boost.h"
21 #include "object-flavor.h"
22 #include "object-hook.h"
24 #include "player-move.h"
25 #include "player-status.h"
26 #include "player-class.h"
27 #include "spells-summon.h"
32 #include "spells-floor.h"
34 #include "monster-process.h"
35 #include "monster-status.h"
36 #include "monster-spell.h"
37 #include "cmd-spell.h"
39 #include "floor-save.h"
41 #include "player-effects.h"
42 #include "player-skill.h"
43 #include "view-mainwindow.h"
49 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
54 * @brief モンスターのテレポートアウェイ処理 /
55 * Teleport a monster, normally up to "dis" grids away.
56 * @param m_idx モンスターID
59 * @return テレポートが実際に行われたらtrue
61 * Attempt to move the monster at least "dis/2" grids away.
62 * But allow variation to prevent infinite loops.
64 bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
66 POSITION oy, ox, d, i, min;
68 POSITION ny = 0, nx = 0;
72 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
73 if (!monster_is_valid(m_ptr)) return (FALSE);
78 /* Minimum distance */
81 if ((mode & TELEPORT_DEC_VALOUR) &&
82 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
83 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
85 chg_virtue(V_VALOUR, -1);
93 /* Verify max distance */
94 if (dis > 200) dis = 200;
96 /* Try several locations */
97 for (i = 0; i < 500; i++)
99 /* Pick a (possibly illegal) location */
102 ny = rand_spread(oy, dis);
103 nx = rand_spread(ox, dis);
104 d = distance(oy, ox, ny, nx);
105 if ((d >= min) && (d <= dis)) break;
108 /* Ignore illegal locations */
109 if (!in_bounds(ny, nx)) continue;
111 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
113 /* No teleporting into vaults and such */
114 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
115 if (current_floor_ptr->grid_array[ny][nx].info & CAVE_ICKY) continue;
117 /* This grid looks good */
124 /* Increase the maximum distance */
127 /* Decrease the minimum distance */
130 /* Stop after MAX_TRIES tries */
131 if (tries > MAX_TRIES) return (FALSE);
134 sound(SOUND_TPOTHER);
136 /* Update the old location */
137 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
139 /* Update the new location */
140 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
142 /* Move the monster */
146 /* Forget the counter target */
149 update_monster(m_idx, TRUE);
153 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
154 p_ptr->update |= (PU_MON_LITE);
161 * @brief モンスターを指定された座標付近にテレポートする /
162 * Teleport monster next to a grid near the given location
163 * @param m_idx モンスターID
166 * @param power テレポート成功確率
170 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
172 POSITION ny, nx, oy, ox;
177 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
178 if(!m_ptr->r_idx) return;
181 if(randint1(100) > power) return;
188 /* Minimum distance */
191 /* Look until done */
192 while (look && --attempts)
194 /* Verify max distance */
195 if (dis > 200) dis = 200;
197 /* Try several locations */
198 for (i = 0; i < 500; i++)
200 /* Pick a (possibly illegal) location */
203 ny = rand_spread(ty, dis);
204 nx = rand_spread(tx, dis);
205 d = distance(ty, tx, ny, nx);
206 if ((d >= min) && (d <= dis)) break;
209 /* Ignore illegal locations */
210 if (!in_bounds(ny, nx)) continue;
212 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
214 /* No teleporting into vaults and such */
215 /* if (current_floor_ptr->grid_array[ny][nx].info & (CAVE_ICKY)) continue; */
217 /* This grid looks good */
224 /* Increase the maximum distance */
227 /* Decrease the minimum distance */
231 if (attempts < 1) return;
233 sound(SOUND_TPOTHER);
235 /* Update the old location */
236 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
238 /* Update the new location */
239 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
241 /* Move the monster */
245 update_monster(m_idx, TRUE);
249 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
250 p_ptr->update |= (PU_MON_LITE);
254 * @brief プレイヤーのテレポート先選定と移動処理 /
255 * Teleport the player to a location up to "dis" grids away.
258 * @return 実際にテレポート処理が行われたらtrue
261 * If no such spaces are readily available, the distance may increase.
262 * Try very hard to move the player at least a quarter that distance.
264 * There was a nasty tendency for a long time; which was causing the
265 * player to "bounce" between two or three different spots because
266 * these are the only spots that are "far enough" way to satisfy the
269 * But this tendency is now removed; in the new algorithm, a list of
270 * candidates is selected first, which includes at least 50% of all
271 * floor grids within the distance, and any single grid in this list
272 * of candidates has equal possibility to be choosen as a destination.
276 bool teleport_player_aux(POSITION dis, BIT_FLAGS mode)
278 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
279 int total_candidates, cur_candidates;
280 POSITION y = 0, x = 0;
283 int left = MAX(1, p_ptr->x - dis);
284 int right = MIN(current_floor_ptr->width - 2, p_ptr->x + dis);
285 int top = MAX(1, p_ptr->y - dis);
286 int bottom = MIN(current_floor_ptr->height - 2, p_ptr->y + dis);
288 if (p_ptr->wild_mode) return FALSE;
290 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
292 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
296 /* Initialize counters */
297 total_candidates = 0;
298 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
299 candidates_at[i] = 0;
301 /* Limit the distance */
302 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
304 /* Search valid locations */
305 for (y = top; y <= bottom; y++)
307 for (x = left; x <= right; x++)
311 /* Skip illegal locations */
312 if (!cave_player_teleportable_bold(y, x, mode)) continue;
314 /* Calculate distance */
315 d = distance(p_ptr->y, p_ptr->x, y, x);
317 /* Skip too far locations */
318 if (d > dis) continue;
320 /* Count the total number of candidates */
323 /* Count the number of candidates in this circumference */
328 /* No valid location! */
329 if (0 == total_candidates) return FALSE;
331 /* Fix the minimum distance */
332 for (cur_candidates = 0, min = dis; min >= 0; min--)
334 cur_candidates += candidates_at[min];
336 /* 50% of all candidates will have an equal chance to be choosen. */
337 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
340 /* Pick up a single location randomly */
341 pick = randint1(cur_candidates);
343 /* Search again the choosen location */
344 for (y = top; y <= bottom; y++)
346 for (x = left; x <= right; x++)
350 /* Skip illegal locations */
351 if (!cave_player_teleportable_bold(y, x, mode)) continue;
353 /* Calculate distance */
354 d = distance(p_ptr->y, p_ptr->x, y, x);
356 /* Skip too far locations */
357 if (d > dis) continue;
359 /* Skip too close locations */
360 if (d < min) continue;
362 /* This grid was picked up? */
371 if (player_bold(y, x)) return FALSE;
373 sound(SOUND_TELEPORT);
376 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
377 msg_format("『こっちだぁ、%s』", p_ptr->name);
380 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
385 * @brief プレイヤーのテレポート処理メインルーチン
390 void teleport_player(POSITION dis, BIT_FLAGS mode)
393 POSITION oy = p_ptr->y;
394 POSITION ox = p_ptr->x;
396 if (!teleport_player_aux(dis, mode)) return;
398 /* Monsters with teleport ability may follow the player */
399 for (xx = -1; xx < 2; xx++)
401 for (yy = -1; yy < 2; yy++)
403 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
405 /* A monster except your mount may follow */
406 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
408 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
409 monster_race *r_ptr = &r_info[m_ptr->r_idx];
412 * The latter limitation is to avoid
413 * totally unkillable suckers...
415 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
416 !(r_ptr->flagsr & RFR_RES_TELE))
418 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
427 * @brief プレイヤーのテレポートアウェイ処理 /
428 * @param m_idx アウェイを試みたプレイヤーID
432 void teleport_player_away(MONSTER_IDX m_idx, POSITION dis)
435 POSITION oy = p_ptr->y;
436 POSITION ox = p_ptr->x;
438 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
440 /* Monsters with teleport ability may follow the player */
441 for (xx = -1; xx < 2; xx++)
443 for (yy = -1; yy < 2; yy++)
445 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
447 /* A monster except your mount or caster may follow */
448 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
450 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
451 monster_race *r_ptr = &r_info[m_ptr->r_idx];
454 * The latter limitation is to avoid
455 * totally unkillable suckers...
457 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
458 !(r_ptr->flagsr & RFR_RES_TELE))
460 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
469 * @brief プレイヤーを指定位置近辺にテレポートさせる
470 * Teleport player to a grid near the given location
473 * @param mode オプションフラグ
477 * This function is slightly obsessive about correctness.
478 * This function allows teleporting into vaults (!)
481 void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
484 POSITION dis = 0, ctr = 0;
486 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
488 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
492 /* Find a usable location */
495 /* Pick a nearby legal location */
498 y = (POSITION)rand_spread(ny, dis);
499 x = (POSITION)rand_spread(nx, dis);
500 if (in_bounds(y, x)) break;
503 /* Accept any grid when wizard mode */
504 if (p_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!current_floor_ptr->grid_array[y][x].m_idx || (current_floor_ptr->grid_array[y][x].m_idx == p_ptr->riding))) break;
506 /* Accept teleportable floor grids */
507 if (cave_player_teleportable_bold(y, x, mode)) break;
509 /* Occasionally advance the distance */
510 if (++ctr > (4 * dis * dis + 4 * dis + 1))
517 sound(SOUND_TELEPORT);
518 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
522 void teleport_away_followable(MONSTER_IDX m_idx)
524 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
525 POSITION oldfy = m_ptr->fy;
526 POSITION oldfx = m_ptr->fx;
527 bool old_ml = m_ptr->ml;
528 POSITION old_cdis = m_ptr->cdis;
530 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
532 if (old_ml && (old_cdis <= MAX_SIGHT) && !current_world_ptr->timewalk_m_idx && !p_ptr->inside_battle && los(p_ptr->y, p_ptr->x, oldfy, oldfx))
536 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
539 BIT_FLAGS flgs[TR_FLAG_SIZE];
543 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
545 o_ptr = &p_ptr->inventory_list[i];
546 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
548 object_flags(o_ptr, flgs);
549 if (have_flag(flgs, TR_TELEPORT))
560 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
564 teleport_player(200, TELEPORT_PASSIVE);
565 msg_print(_("失敗!", "Failed!"));
567 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
568 p_ptr->energy_need += ENERGY_NEED();
575 bool teleport_level_other(player_type *creature_ptr)
577 MONSTER_IDX target_m_idx;
580 GAME_TEXT m_name[MAX_NLEN];
582 if (!target_set(TARGET_KILL)) return FALSE;
583 target_m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
584 if (!target_m_idx) return TRUE;
585 if (!player_has_los_bold(target_row, target_col)) return TRUE;
586 if (!projectable(creature_ptr->y, creature_ptr->x, target_row, target_col)) return TRUE;
587 m_ptr = ¤t_floor_ptr->m_list[target_m_idx];
588 r_ptr = &r_info[m_ptr->r_idx];
589 monster_desc(m_name, m_ptr, 0);
590 msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
592 if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
593 (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > creature_ptr->lev + randint1(60)))
595 msg_format(_("しかし効果がなかった!", "%^s is unaffected!"), m_name);
597 else teleport_level(target_m_idx);
602 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
603 * Teleport the player one level up or down (random when legal)
604 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
607 void teleport_level(MONSTER_IDX m_idx)
610 GAME_TEXT m_name[160];
613 if (m_idx <= 0) /* To player */
615 strcpy(m_name, _("あなた", "you"));
617 else /* To monster */
619 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
621 /* Get the monster name (or "it") */
622 monster_desc(m_name, m_ptr, 0);
624 see_m = is_seen(m_ptr);
627 /* No effect in some case */
628 if (TELE_LEVEL_IS_INEFF(m_idx))
630 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
634 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
636 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
640 /* Choose up or down */
641 if (randint0(100) < 50) go_up = TRUE;
644 if ((m_idx <= 0) && p_ptr->wizard)
646 if (get_check("Force to go up? ")) go_up = TRUE;
647 else if (get_check("Force to go down? ")) go_up = FALSE;
651 if ((ironman_downward && (m_idx <= 0)) || (current_floor_ptr->dun_level <= d_info[p_ptr->dungeon_idx].mindepth))
654 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
656 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
658 if (m_idx <= 0) /* To player */
660 if (!current_floor_ptr->dun_level)
662 p_ptr->dungeon_idx = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
663 p_ptr->oldpy = p_ptr->y;
664 p_ptr->oldpx = p_ptr->x;
667 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
669 if (autosave_l) do_cmd_save_game(TRUE);
671 if (!current_floor_ptr->dun_level)
673 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].mindepth;
674 prepare_change_floor_mode(CFM_RAND_PLACE);
678 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
680 p_ptr->leaving = TRUE;
685 else if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth))
688 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
690 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
694 if (m_idx <= 0) /* To player */
696 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
698 if (autosave_l) do_cmd_save_game(TRUE);
700 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
703 p_ptr->inside_quest = 0;
704 p_ptr->leaving = TRUE;
710 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
712 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
716 if (m_idx <= 0) /* To player */
718 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
720 if (autosave_l) do_cmd_save_game(TRUE);
722 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
723 p_ptr->leaving = TRUE;
729 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
731 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
734 if (m_idx <= 0) /* To player */
736 /* Never reach this code on the surface */
737 /* if (!current_floor_ptr->dun_level) p_ptr->dungeon_idx = p_ptr->recall_dungeon; */
738 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
739 if (autosave_l) do_cmd_save_game(TRUE);
741 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
742 p_ptr->leaving = TRUE;
746 /* Monster level teleportation is simple deleting now */
749 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
751 check_quest_completion(m_ptr);
753 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
755 char m2_name[MAX_NLEN];
757 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
758 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
761 delete_monster_idx(m_idx);
764 sound(SOUND_TPLEVEL);
769 * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
770 * @param note ダンジョンに施す処理記述
773 * @return 選択されたダンジョンID
775 DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x)
777 DUNGEON_IDX select_dungeon;
782 /* Hack -- No need to choose dungeon in some case */
783 if (lite_town || vanilla_town || ironman_downward)
785 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
788 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
794 /* Allocate the "dun" array */
795 C_MAKE(dun, max_d_idx, DUNGEON_IDX);
798 for(i = 1; i < max_d_idx; i++)
803 if (!d_info[i].maxdepth) continue;
804 if (!max_dlv[i]) continue;
805 if (d_info[i].final_guardian)
807 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
809 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
811 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
812 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
813 prt(buf, y + num, x);
819 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
822 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
826 if ((i == ESCAPE) || !num)
828 /* Free the "dun" array */
829 C_KILL(dun, max_d_idx, DUNGEON_IDX);
834 if (i >= 'a' && i <('a'+num))
836 select_dungeon = dun[i-'a'];
843 /* Free the "dun" array */
844 C_KILL(dun, max_d_idx, DUNGEON_IDX);
846 return select_dungeon;
851 * @brief プレイヤーの帰還発動及び中止処理 /
852 * Recall the player to town or dungeon
853 * @param turns 発動までのターン数
856 bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
859 * TODO: Recall the player to the last
860 * visited town when in the wilderness
864 if (creature_ptr->inside_arena || ironman_downward)
866 msg_print(_("何も起こらなかった。", "Nothing happens."));
870 if (current_floor_ptr->dun_level && (max_dlv[p_ptr->dungeon_idx] > current_floor_ptr->dun_level) && !creature_ptr->inside_quest && !creature_ptr->word_recall)
872 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
874 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
876 do_cmd_write_nikki(NIKKI_TRUMP, p_ptr->dungeon_idx, _("帰還のときに", "when recall from dungeon"));
880 if (!creature_ptr->word_recall)
882 if (!current_floor_ptr->dun_level)
884 DUNGEON_IDX select_dungeon;
885 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
886 if (!select_dungeon) return FALSE;
887 creature_ptr->recall_dungeon = select_dungeon;
889 creature_ptr->word_recall = turns;
890 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
891 creature_ptr->redraw |= (PR_STATUS);
895 creature_ptr->word_recall = 0;
896 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
897 creature_ptr->redraw |= (PR_STATUS);
902 bool free_level_recall(player_type *creature_ptr)
904 DUNGEON_IDX select_dungeon;
908 select_dungeon = choose_dungeon(_("にテレポート", "teleport"), 4, 0);
910 if (!select_dungeon) return FALSE;
912 max_depth = d_info[select_dungeon].maxdepth;
914 /* Limit depth in Angband */
915 if (select_dungeon == DUNGEON_ANGBAND)
917 if (quest[QUEST_OBERON].status != QUEST_STATUS_FINISHED) max_depth = 98;
918 else if (quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
920 amt = get_quantity(format(_("%sの何階にテレポートしますか?", "Teleport to which level of %s? "),
921 d_name + d_info[select_dungeon].name), (QUANTITY)max_depth);
925 creature_ptr->word_recall = 1;
926 creature_ptr->recall_dungeon = select_dungeon;
927 max_dlv[creature_ptr->recall_dungeon] = ((amt > d_info[select_dungeon].maxdepth) ? d_info[select_dungeon].maxdepth : ((amt < d_info[select_dungeon].mindepth) ? d_info[select_dungeon].mindepth : amt));
929 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("トランプタワーで", "at Trump Tower"));
931 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
933 creature_ptr->redraw |= (PR_STATUS);
942 * @return リセット処理が実際に行われたらTRUEを返す
944 bool reset_recall(void)
946 int select_dungeon, dummy = 0;
950 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
953 if (ironman_downward)
955 msg_print(_("何も起こらなかった。", "Nothing happens."));
959 if (!select_dungeon) return FALSE;
961 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
962 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
965 sprintf(tmp_val, "%d", (int)MAX(current_floor_ptr->dun_level, 1));
967 /* Ask for a level */
968 if (get_string(ppp, tmp_val, 10))
970 /* Extract request */
971 dummy = atoi(tmp_val);
972 if (dummy < 1) dummy = 1;
973 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
974 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
976 max_dlv[select_dungeon] = dummy;
979 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
982 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
984 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
997 * @brief プレイヤーの装備劣化処理 /
998 * Apply disenchantment to the player's stuff
999 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
1000 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
1001 * Return "TRUE" if the player notices anything
1003 bool apply_disenchant(BIT_FLAGS mode)
1007 GAME_TEXT o_name[MAX_NLEN];
1008 int to_h, to_d, to_a, pval;
1010 /* Pick a random slot */
1011 switch (randint1(8))
1013 case 1: t = INVEN_RARM; break;
1014 case 2: t = INVEN_LARM; break;
1015 case 3: t = INVEN_BOW; break;
1016 case 4: t = INVEN_BODY; break;
1017 case 5: t = INVEN_OUTER; break;
1018 case 6: t = INVEN_HEAD; break;
1019 case 7: t = INVEN_HANDS; break;
1020 case 8: t = INVEN_FEET; break;
1023 o_ptr = &p_ptr->inventory_list[t];
1025 /* No item, nothing happens */
1026 if (!o_ptr->k_idx) return (FALSE);
1028 /* Disenchant equipments only -- No disenchant on monster ball */
1029 if (!object_is_weapon_armour_ammo(o_ptr))
1032 /* Nothing to disenchant */
1033 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1035 /* Nothing to notice */
1039 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1041 /* Artifacts have 71% chance to resist */
1042 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1045 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1047 msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t),
1048 ((o_ptr->number != 1) ? "" : "s"));
1054 /* Memorize old value */
1060 /* Disenchant tohit */
1061 if (o_ptr->to_h > 0) o_ptr->to_h--;
1062 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1064 /* Disenchant todam */
1065 if (o_ptr->to_d > 0) o_ptr->to_d--;
1066 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1068 /* Disenchant toac */
1069 if (o_ptr->to_a > 0) o_ptr->to_a--;
1070 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1072 /* Disenchant pval (occasionally) */
1073 /* Unless called from wild_magic() */
1074 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1076 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1077 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1080 msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t) );
1082 msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t),
1083 ((o_ptr->number != 1) ? "were" : "was"));
1086 chg_virtue(V_HARMONY, 1);
1087 chg_virtue(V_ENCHANT, -2);
1088 p_ptr->update |= (PU_BONUS);
1089 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1099 * @brief 武器へのエゴ付加処理 /
1100 * Brand the current weapon
1101 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1104 void brand_weapon(int brand_type)
1110 /* Assume enchant weapon */
1111 item_tester_hook = object_allow_enchant_melee_weapon;
1113 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1114 s = _("強化できる武器がない。", "You have nothing to enchant.");
1116 o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
1119 /* you can never modify artifacts / ego-items */
1120 /* you can never modify cursed items */
1121 /* TY: You _can_ modify broken items (if you're silly enough) */
1122 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1123 !object_is_cursed(o_ptr) &&
1124 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1125 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1126 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1130 /* Let's get the name before it is changed... */
1131 GAME_TEXT o_name[MAX_NLEN];
1132 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1137 if (o_ptr->tval == TV_SWORD)
1139 act = _("は鋭さを増した!", "becomes very sharp!");
1141 o_ptr->name2 = EGO_SHARPNESS;
1142 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, current_floor_ptr->dun_level) + 1;
1144 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1149 act = _("は破壊力を増した!", "seems very powerful.");
1150 o_ptr->name2 = EGO_EARTHQUAKES;
1151 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, current_floor_ptr->dun_level);
1155 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1156 o_ptr->name2 = EGO_KILL_HUMAN;
1159 act = _("は電撃に覆われた!", "covered with lightning!");
1160 o_ptr->name2 = EGO_BRAND_ELEC;
1163 act = _("は酸に覆われた!", "coated with acid!");
1164 o_ptr->name2 = EGO_BRAND_ACID;
1167 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1168 o_ptr->name2 = EGO_KILL_EVIL;
1171 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1172 o_ptr->name2 = EGO_KILL_DEMON;
1175 act = _("は屍を求めている!", "seems to be looking for undead!");
1176 o_ptr->name2 = EGO_KILL_UNDEAD;
1179 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1180 o_ptr->name2 = EGO_KILL_ANIMAL;
1183 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1184 o_ptr->name2 = EGO_KILL_DRAGON;
1187 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1188 o_ptr->name2 = EGO_KILL_TROLL;
1191 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1192 o_ptr->name2 = EGO_KILL_ORC;
1195 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1196 o_ptr->name2 = EGO_KILL_GIANT;
1199 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1200 o_ptr->name2 = EGO_TRUMP;
1201 o_ptr->pval = randint1(2);
1204 act = _("は血を求めている!", "thirsts for blood!");
1205 o_ptr->name2 = EGO_VAMPIRIC;
1208 act = _("は毒に覆われた。", "is coated with poison.");
1209 o_ptr->name2 = EGO_BRAND_POIS;
1212 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1213 o_ptr->name2 = EGO_CHAOTIC;
1216 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1217 o_ptr->name2 = EGO_BRAND_FIRE;
1220 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1221 o_ptr->name2 = EGO_BRAND_COLD;
1225 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1226 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1228 o_ptr->discount = 99;
1229 chg_virtue(V_ENCHANT, 2);
1233 if (flush_failure) flush();
1235 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1236 chg_virtue(V_ENCHANT, -2);
1243 * @brief 虚無招来によるフロア中の全壁除去処理 /
1244 * Vanish all walls in this floor
1245 * @return 実際に処理が反映された場合TRUE
1247 static bool vanish_dungeon(void)
1251 feature_type *f_ptr;
1252 monster_type *m_ptr;
1253 GAME_TEXT m_name[MAX_NLEN];
1255 /* Prevent vasishing of quest levels and town */
1256 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1261 /* Scan all normal grids */
1262 for (y = 1; y < current_floor_ptr->height - 1; y++)
1264 for (x = 1; x < current_floor_ptr->width - 1; x++)
1266 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1268 /* Seeing true feature code (ignore mimic) */
1269 f_ptr = &f_info[g_ptr->feat];
1271 /* Lose room and vault */
1272 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1274 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
1277 if (g_ptr->m_idx && MON_CSLEEP(m_ptr))
1279 (void)set_monster_csleep(g_ptr->m_idx, 0);
1281 /* Notice the "waking up" */
1284 monster_desc(m_name, m_ptr, 0);
1285 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1289 /* Process all walls, doors and patterns */
1290 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1294 /* Special boundary walls -- Top and bottom */
1295 for (x = 0; x < current_floor_ptr->width; x++)
1297 g_ptr = ¤t_floor_ptr->grid_array[0][x];
1298 f_ptr = &f_info[g_ptr->mimic];
1300 /* Lose room and vault */
1301 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1303 /* Set boundary mimic if needed */
1304 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1306 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1308 /* Check for change to boring grid */
1309 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1312 g_ptr = ¤t_floor_ptr->grid_array[current_floor_ptr->height - 1][x];
1313 f_ptr = &f_info[g_ptr->mimic];
1315 /* Lose room and vault */
1316 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1318 /* Set boundary mimic if needed */
1319 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1321 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1323 /* Check for change to boring grid */
1324 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1328 /* Special boundary walls -- Left and right */
1329 for (y = 1; y < (current_floor_ptr->height - 1); y++)
1331 g_ptr = ¤t_floor_ptr->grid_array[y][0];
1332 f_ptr = &f_info[g_ptr->mimic];
1334 /* Lose room and vault */
1335 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1337 /* Set boundary mimic if needed */
1338 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1340 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1342 /* Check for change to boring grid */
1343 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1346 g_ptr = ¤t_floor_ptr->grid_array[y][current_floor_ptr->width - 1];
1347 f_ptr = &f_info[g_ptr->mimic];
1349 /* Lose room and vault */
1350 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1352 /* Set boundary mimic if needed */
1353 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1355 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1357 /* Check for change to boring grid */
1358 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1362 /* Mega-Hack -- Forget the view and lite */
1363 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1364 p_ptr->redraw |= (PR_MAP);
1365 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1374 void call_the_(void)
1378 bool do_call = TRUE;
1380 for (i = 0; i < 9; i++)
1382 g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1384 if (!cave_have_flag_grid(g_ptr, FF_PROJECT))
1386 if (!g_ptr->mimic || !have_flag(f_info[g_ptr->mimic].flags, FF_PROJECT) ||
1387 !permanent_wall(&f_info[g_ptr->feat]))
1397 for (i = 1; i < 10; i++)
1399 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1402 for (i = 1; i < 10; i++)
1404 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1407 for (i = 1; i < 10; i++)
1409 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1413 /* Prevent destruction of quest levels and town */
1414 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1416 msg_print(_("地面が揺れた。", "The ground trembles."));
1422 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1423 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1425 msg_format("You %s the %s too close to a wall!",
1426 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1427 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1429 msg_print(_("大きな爆発音があった!", "There is a loud explosion!"));
1433 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1437 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1438 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1440 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1443 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1449 * @brief アイテム引き寄せ処理 /
1450 * Fetch an item (teleport it right underneath the caster)
1451 * @param dir 魔法の発動方向
1453 * @param require_los 射線の通りを要求するならばTRUE
1456 void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
1462 GAME_TEXT o_name[MAX_NLEN];
1464 /* Check to see if an object is already there */
1465 if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx)
1467 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1472 if (dir == 5 && target_okay())
1477 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1479 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1483 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1485 /* We need an item to fetch */
1488 msg_print(_("そこには何もありません。", "There is no object at this place."));
1492 /* No fetching from vault */
1493 if (g_ptr->info & CAVE_ICKY)
1495 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1499 /* We need to see the item */
1502 if (!player_has_los_bold(ty, tx))
1504 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1507 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1509 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1522 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1524 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1525 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1527 while (!g_ptr->o_idx);
1530 o_ptr = ¤t_floor_ptr->o_list[g_ptr->o_idx];
1532 if (o_ptr->weight > wgt)
1534 /* Too heavy to 'fetch' */
1535 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1540 g_ptr->o_idx = o_ptr->next_o_idx;
1541 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1543 o_ptr->next_o_idx = 0;
1544 o_ptr->iy = p_ptr->y;
1545 o_ptr->ix = p_ptr->x;
1547 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1548 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1550 note_spot(p_ptr->y, p_ptr->x);
1551 p_ptr->redraw |= PR_MAP;
1558 void alter_reality(void)
1560 /* Ironman option */
1561 if (p_ptr->inside_arena || ironman_downward)
1563 msg_print(_("何も起こらなかった。", "Nothing happens."));
1567 if (!p_ptr->alter_reality)
1569 TIME_EFFECT turns = randint0(21) + 15;
1571 p_ptr->alter_reality = turns;
1572 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1574 p_ptr->redraw |= (PR_STATUS);
1578 p_ptr->alter_reality = 0;
1579 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1580 p_ptr->redraw |= (PR_STATUS);
1586 * @brief 全所持アイテム鑑定処理 /
1587 * Identify everything being carried.
1588 * Done by a potion of "self knowledge".
1591 void identify_pack(void)
1595 /* Simply identify and know every item */
1596 for (i = 0; i < INVEN_TOTAL; i++)
1598 object_type *o_ptr = &p_ptr->inventory_list[i];
1599 if (!o_ptr->k_idx) continue;
1601 identify_item(o_ptr);
1603 /* Auto-inscription */
1604 autopick_alter_item(i, FALSE);
1610 * @brief 装備強化処理の失敗率定数(千分率) /
1611 * Used by the "enchant" function (chance of failure)
1612 * (modified for Zangband, we need better stuff there...) -- TY
1615 static int enchant_table[16] =
1617 0, 10, 50, 100, 200,
1618 300, 400, 500, 650, 800,
1619 950, 987, 993, 995, 998,
1626 * Removes curses from items in p_ptr->inventory_list
1627 * @param all 軽い呪いまでの解除ならば0
1628 * @return 解呪されたアイテムの数
1631 * Note that Items which are "Perma-Cursed" (The One Ring,
1632 * The Crown of Morgoth) can NEVER be uncursed.
1634 * Note that if "all" is FALSE, then Items which are
1635 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1636 * will not be uncursed.
1639 static int remove_curse_aux(int all)
1643 /* Attempt to uncurse items being worn */
1644 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1646 object_type *o_ptr = &p_ptr->inventory_list[i];
1647 if (!o_ptr->k_idx) continue;
1649 /* Uncursed already */
1650 if (!object_is_cursed(o_ptr)) continue;
1652 /* Heavily Cursed Items need a special spell */
1653 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1655 /* Perma-Cursed Items can NEVER be uncursed */
1656 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1658 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1662 o_ptr->curse_flags = 0L;
1663 o_ptr->ident |= (IDENT_SENSE);
1664 o_ptr->feeling = FEEL_NONE;
1666 p_ptr->update |= (PU_BONUS);
1667 p_ptr->window |= (PW_EQUIP);
1669 /* Count the uncursings */
1675 msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
1677 /* Return "something uncursed" */
1683 * @brief 装備の軽い呪い解呪処理 /
1684 * Remove most curses
1685 * @return 解呪に成功した装備数
1687 int remove_curse(void)
1689 return (remove_curse_aux(FALSE));
1693 * @brief 装備の重い呪い解呪処理 /
1695 * @return 解呪に成功した装備数
1697 int remove_all_curse(void)
1699 return (remove_curse_aux(TRUE));
1704 * @brief アイテムの価値に応じた錬金術処理 /
1705 * Turns an object into gold, gain some of its value in a shop
1706 * @return 処理が実際に行われたらTRUEを返す
1712 ITEM_NUMBER old_number;
1716 GAME_TEXT o_name[MAX_NLEN];
1717 char out_val[MAX_NLEN+40];
1721 /* Hack -- force destruction */
1722 if (command_arg > 0) force = TRUE;
1724 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
1725 s = _("金に変えられる物がありません。", "You have nothing to current_world_ptr->game_turn to gold.");
1727 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1728 if (!o_ptr) return (FALSE);
1730 /* See how many items */
1731 if (o_ptr->number > 1)
1733 amt = get_quantity(NULL, o_ptr->number);
1735 /* Allow user abort */
1736 if (amt <= 0) return FALSE;
1739 old_number = o_ptr->number;
1740 o_ptr->number = amt;
1741 object_desc(o_name, o_ptr, 0);
1742 o_ptr->number = old_number;
1744 /* Verify unless quantity given */
1747 if (confirm_destroy || (object_value(o_ptr) > 0))
1749 /* Make a verification */
1750 sprintf(out_val, _("本当に%sを金に変えますか?", "Really current_world_ptr->game_turn %s to gold? "), o_name);
1751 if (!get_check(out_val)) return FALSE;
1755 /* Artifacts cannot be destroyed */
1756 if (!can_player_destroy_object(o_ptr))
1758 msg_format(_("%sを金に変えることに失敗した。", "You fail to current_world_ptr->game_turn %s to gold!"), o_name);
1763 price = object_value_real(o_ptr);
1767 msg_format(_("%sをニセの金に変えた。", "You current_world_ptr->game_turn %s to fool's gold."), o_name);
1773 if (amt > 1) price *= amt;
1775 if (price > 30000) price = 30000;
1776 msg_format(_("%sを$%d の金に変えた。", "You current_world_ptr->game_turn %s to %ld coins worth of gold."), o_name, price);
1779 p_ptr->redraw |= (PR_GOLD);
1780 p_ptr->window |= (PW_PLAYER);
1783 /* Eliminate the item (from the pack) */
1786 inven_item_increase(item, -amt);
1787 inven_item_describe(item);
1788 inven_item_optimize(item);
1791 /* Eliminate the item (from the floor) */
1794 floor_item_increase(0 - item, -amt);
1795 floor_item_describe(0 - item);
1796 floor_item_optimize(0 - item);
1804 * @brief 呪いの打ち破り処理 /
1805 * Break the curse of an item
1806 * @param o_ptr 呪い装備情報の参照ポインタ
1809 static void break_curse(object_type *o_ptr)
1811 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
1813 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
1815 o_ptr->curse_flags = 0L;
1816 o_ptr->ident |= (IDENT_SENSE);
1817 o_ptr->feeling = FEEL_NONE;
1824 * Enchants a plus onto an item. -RAK-
1825 * @param o_ptr 強化するアイテムの参照ポインタ
1827 * @param eflag 強化オプション(命中/ダメージ/AC)
1828 * @return 強化に成功した場合TRUEを返す
1831 * Revamped! Now takes item pointer, number of times to try enchanting,
1832 * and a flag of what to try enchanting. Artifacts resist enchantment
1833 * some of the time, and successful enchantment to at least +0 might
1834 * break a curse on the item. -CFT-
1836 * Note that an item can technically be enchanted all the way to +15 if
1837 * you wait a very, very, long time. Going from +9 to +10 only works
1838 * about 5% of the time, and from +10 to +11 only about 1% of the time.
1840 * Note that this function can now be used on "piles" of items, and
1841 * the larger the pile, the lower the chance of success.
1844 bool enchant(object_type *o_ptr, int n, int eflag)
1846 int i, chance, prob;
1848 bool a = object_is_artifact(o_ptr);
1849 bool force = (eflag & ENCH_FORCE);
1851 /* Large piles resist enchantment */
1852 prob = o_ptr->number * 100;
1854 /* Missiles are easy to enchant */
1855 if ((o_ptr->tval == TV_BOLT) ||
1856 (o_ptr->tval == TV_ARROW) ||
1857 (o_ptr->tval == TV_SHOT))
1863 for (i = 0; i < n; i++)
1865 /* Hack -- Roll for pile resistance */
1866 if (!force && randint0(prob) >= 100) continue;
1868 /* Enchant to hit */
1869 if (eflag & ENCH_TOHIT)
1871 if (o_ptr->to_h < 0) chance = 0;
1872 else if (o_ptr->to_h > 15) chance = 1000;
1873 else chance = enchant_table[o_ptr->to_h];
1875 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1880 /* only when you get it above -1 -CFT */
1881 if (o_ptr->to_h >= 0)
1886 /* Enchant to damage */
1887 if (eflag & ENCH_TODAM)
1889 if (o_ptr->to_d < 0) chance = 0;
1890 else if (o_ptr->to_d > 15) chance = 1000;
1891 else chance = enchant_table[o_ptr->to_d];
1893 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1898 /* only when you get it above -1 -CFT */
1899 if (o_ptr->to_d >= 0)
1904 /* Enchant to armor class */
1905 if (eflag & ENCH_TOAC)
1907 if (o_ptr->to_a < 0) chance = 0;
1908 else if (o_ptr->to_a > 15) chance = 1000;
1909 else chance = enchant_table[o_ptr->to_a];
1911 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1916 /* only when you get it above -1 -CFT */
1917 if (o_ptr->to_a >= 0)
1924 if (!res) return (FALSE);
1925 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
1926 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1936 * @brief 装備修正強化処理のメインルーチン /
1937 * Enchant an item (in the p_ptr->inventory_list or on the floor)
1938 * @param num_hit 命中修正量
1939 * @param num_dam ダメージ修正量
1940 * @param num_ac AC修正量
1941 * @return 強化に成功した場合TRUEを返す
1943 * Note that "num_ac" requires armour, else weapon
1944 * Returns TRUE if attempted, FALSE if cancelled
1946 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
1951 GAME_TEXT o_name[MAX_NLEN];
1954 /* Assume enchant weapon */
1955 item_tester_hook = object_allow_enchant_weapon;
1957 /* Enchant armor if requested */
1958 if (num_ac) item_tester_hook = object_is_armour;
1960 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
1961 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
1963 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1964 if (!o_ptr) return (FALSE);
1966 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1968 msg_format("%s は明るく輝いた!", o_name);
1970 msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1974 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
1975 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
1976 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
1981 if (flush_failure) flush();
1982 msg_print(_("強化に失敗した。", "The enchantment failed."));
1983 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
1986 chg_virtue(V_ENCHANT, 1);
1990 /* Something happened */
1996 * @brief アーティファクト生成の巻物処理 /
1997 * @return 生成が実際に試みられたらTRUEを返す
1999 bool artifact_scroll(void)
2004 GAME_TEXT o_name[MAX_NLEN];
2007 /* Enchant weapon/armour */
2008 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2010 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2011 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2013 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2014 if (!o_ptr) return (FALSE);
2016 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2018 msg_format("%s は眩い光を発した!",o_name);
2020 msg_format("%s %s radiate%s a blinding light!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
2023 if (object_is_artifact(o_ptr))
2026 msg_format("%sは既に伝説のアイテムです!", o_name );
2028 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2034 else if (object_is_ego(o_ptr))
2037 msg_format("%sは既に名のあるアイテムです!", o_name );
2039 msg_format("The %s %s already %s!",
2040 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2041 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2047 else if (o_ptr->xtra3)
2050 msg_format("%sは既に強化されています!", o_name );
2052 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"),
2053 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2059 if (o_ptr->number > 1)
2061 msg_print(_("複数のアイテムに魔法をかけるだけのエネルギーはありません!", "Not enough energy to enchant more than one object!"));
2063 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2065 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2070 inven_item_increase(item, 1 - (o_ptr->number));
2074 floor_item_increase(0 - item, 1 - (o_ptr->number));
2077 okay = create_artifact(o_ptr, TRUE);
2083 if (flush_failure) flush();
2084 msg_print(_("強化に失敗した。", "The enchantment failed."));
2085 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2089 if (record_rand_art)
2091 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2092 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2094 chg_virtue(V_ENCHANT, 1);
2099 /* Something happened */
2106 * Identify an object
2107 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2108 * @return 実際に鑑定できたらTRUEを返す
2110 bool identify_item(object_type *o_ptr)
2112 bool old_known = FALSE;
2113 GAME_TEXT o_name[MAX_NLEN];
2115 object_desc(o_name, o_ptr, 0);
2117 if (o_ptr->ident & IDENT_KNOWN)
2120 if (!(o_ptr->ident & (IDENT_MENTAL)))
2122 if (object_is_artifact(o_ptr) || one_in_(5))
2123 chg_virtue(V_KNOWLEDGE, 1);
2126 object_aware(o_ptr);
2127 object_known(o_ptr);
2128 o_ptr->marked |= OM_TOUCHED;
2130 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
2131 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2133 strcpy(record_o_name, o_name);
2134 record_turn = current_world_ptr->game_turn;
2136 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2138 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2139 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2140 if(record_rand_art && !old_known && o_ptr->art_name)
2141 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2147 * @brief アイテム鑑定のメインルーチン処理 /
2148 * Identify an object in the p_ptr->inventory_list (or on the floor)
2149 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2150 * @return 実際に鑑定を行ったならばTRUEを返す
2152 * This routine does *not* automatically combine objects.
2153 * Returns TRUE if something was identified, else FALSE.
2155 bool ident_spell(bool only_equip)
2159 GAME_TEXT o_name[MAX_NLEN];
2164 item_tester_hook = item_tester_hook_identify_weapon_armour;
2166 item_tester_hook = item_tester_hook_identify;
2170 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2175 item_tester_hook = object_is_weapon_armour_ammo;
2177 item_tester_hook = NULL;
2179 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2182 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2184 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2185 if (!o_ptr) return (FALSE);
2187 old_known = identify_item(o_ptr);
2189 object_desc(o_name, o_ptr, 0);
2190 if (item >= INVEN_RARM)
2192 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2196 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2200 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2203 /* Auto-inscription/destroy */
2204 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2206 /* Something happened */
2212 * @brief アイテム凡庸化のメインルーチン処理 /
2213 * Identify an object in the p_ptr->inventory_list (or on the floor)
2214 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2215 * @return 実際に凡庸化をを行ったならばTRUEを返す
2218 * Mundanify an object in the p_ptr->inventory_list (or on the floor)
2219 * This routine does *not* automatically combine objects.
2220 * Returns TRUE if something was mundanified, else FALSE.
2223 bool mundane_spell(bool only_equip)
2229 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2231 q = _("どれを使いますか?", "Use which item? ");
2232 s = _("使えるものがありません。", "You have nothing you can use.");
2234 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2235 if (!o_ptr) return (FALSE);
2237 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2239 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2240 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2241 OBJECT_IDX next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2242 byte marked = o_ptr->marked; /* Object is marked */
2243 WEIGHT weight = o_ptr->number * o_ptr->weight;
2244 u16b inscription = o_ptr->inscription;
2247 object_prep(o_ptr, o_ptr->k_idx);
2251 o_ptr->next_o_idx = next_o_idx;
2252 o_ptr->marked = marked;
2253 o_ptr->inscription = inscription;
2254 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2258 /* Something happened */
2263 * @brief アイテム*鑑定*のメインルーチン処理 /
2264 * Identify an object in the p_ptr->inventory_list (or on the floor)
2265 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2266 * @return 実際に鑑定を行ったならばTRUEを返す
2268 * Fully "identify" an object in the p_ptr->inventory_list -BEN-
2269 * This routine returns TRUE if an item was identified.
2271 bool identify_fully(bool only_equip)
2275 GAME_TEXT o_name[MAX_NLEN];
2280 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2282 item_tester_hook = item_tester_hook_identify_fully;
2286 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2291 item_tester_hook = object_is_weapon_armour_ammo;
2293 item_tester_hook = NULL;
2295 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2298 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2300 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2301 if (!o_ptr) return (FALSE);
2303 old_known = identify_item(o_ptr);
2305 /* Mark the item as fully known */
2306 o_ptr->ident |= (IDENT_MENTAL);
2309 object_desc(o_name, o_ptr, 0);
2310 if (item >= INVEN_RARM)
2312 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2316 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2320 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2323 /* Describe it fully */
2324 (void)screen_object(o_ptr, 0L);
2326 /* Auto-inscription/destroy */
2327 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2337 * Recharge a wand/staff/rod from the pack or on the floor.
2338 * This function has been rewritten in Oangband and ZAngband.
2339 * @param power 充填パワー
2340 * @return ターン消費を要する処理まで進んだらTRUEを返す
2342 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2343 * Chaos -- Arcane Binding --> recharge(90)
2345 * Scroll of recharging --> recharge(130)
2346 * Artifact activation/Thingol --> recharge(130)
2348 * It is harder to recharge high level, and highly charged wands,
2349 * staffs, and rods. The more wands in a stack, the more easily and
2350 * strongly they recharge. Staffs, however, each get fewer charges if
2353 * Beware of "sliding index errors".
2355 bool recharge(int power)
2359 int recharge_strength;
2360 TIME_EFFECT recharge_amount;
2369 GAME_TEXT o_name[MAX_NLEN];
2371 /* Only accept legal items */
2372 item_tester_hook = item_tester_hook_recharge;
2374 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2375 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2377 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2378 if (!o_ptr) return (FALSE);
2380 /* Get the object kind. */
2381 k_ptr = &k_info[o_ptr->k_idx];
2383 /* Extract the object "level" */
2384 lev = k_info[o_ptr->k_idx].level;
2387 /* Recharge a rod */
2388 if (o_ptr->tval == TV_ROD)
2390 /* Extract a recharge strength by comparing object level to power. */
2391 recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
2395 if (one_in_(recharge_strength))
2397 /* Activate the failure code. */
2404 /* Recharge amount */
2405 recharge_amount = (power * damroll(3, 2));
2407 /* Recharge by that amount */
2408 if (o_ptr->timeout > recharge_amount)
2409 o_ptr->timeout -= recharge_amount;
2416 /* Recharge wand/staff */
2419 /* Extract a recharge strength by comparing object level to power.
2420 * Divide up a stack of wands' charges to calculate charge penalty.
2422 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2423 recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15;
2425 /* All staffs, unstacked wands. */
2426 else recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15;
2427 if (recharge_strength < 0) recharge_strength = 0;
2430 if (one_in_(recharge_strength))
2432 /* Activate the failure code. */
2436 /* If the spell didn't backfire, recharge the wand or staff. */
2439 /* Recharge based on the standard number of charges. */
2440 recharge_amount = randint1(1 + k_ptr->pval / 2);
2442 /* Multiple wands in a stack increase recharging somewhat. */
2443 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2446 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2447 if (recharge_amount < 1) recharge_amount = 1;
2448 if (recharge_amount > 12) recharge_amount = 12;
2451 /* But each staff in a stack gets fewer additional charges,
2452 * although always at least one.
2454 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2456 recharge_amount /= (TIME_EFFECT)o_ptr->number;
2457 if (recharge_amount < 1) recharge_amount = 1;
2460 /* Recharge the wand or staff. */
2461 o_ptr->pval += recharge_amount;
2464 /* Hack -- we no longer "know" the item */
2465 o_ptr->ident &= ~(IDENT_KNOWN);
2467 /* Hack -- we no longer think the item is empty */
2468 o_ptr->ident &= ~(IDENT_EMPTY);
2473 /* Inflict the penalties for failing a recharge. */
2476 /* Artifacts are never destroyed. */
2477 if (object_is_fixed_artifact(o_ptr))
2479 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2480 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2482 /* Artifact rods. */
2483 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2484 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2486 /* Artifact wands and staffs. */
2487 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2492 /* Get the object description */
2493 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2495 /*** Determine Seriousness of Failure ***/
2497 /* Mages recharge objects more safely. */
2498 if (IS_WIZARD_CLASS() || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
2500 /* 10% chance to blow up one rod, otherwise draining. */
2501 if (o_ptr->tval == TV_ROD)
2503 if (one_in_(10)) fail_type = 2;
2506 /* 75% chance to blow up one wand, otherwise draining. */
2507 else if (o_ptr->tval == TV_WAND)
2509 if (!one_in_(3)) fail_type = 2;
2512 /* 50% chance to blow up one staff, otherwise no effect. */
2513 else if (o_ptr->tval == TV_STAFF)
2515 if (one_in_(2)) fail_type = 2;
2520 /* All other classes get no special favors. */
2523 /* 33% chance to blow up one rod, otherwise draining. */
2524 if (o_ptr->tval == TV_ROD)
2526 if (one_in_(3)) fail_type = 2;
2529 /* 20% chance of the entire stack, else destroy one wand. */
2530 else if (o_ptr->tval == TV_WAND)
2532 if (one_in_(5)) fail_type = 3;
2535 /* Blow up one staff. */
2536 else if (o_ptr->tval == TV_STAFF)
2542 /*** Apply draining and destruction. ***/
2544 /* Drain object or stack of objects. */
2547 if (o_ptr->tval == TV_ROD)
2549 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
2551 if (o_ptr->timeout < 10000)
2552 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2554 else if (o_ptr->tval == TV_WAND)
2556 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
2559 /* Staffs aren't drained. */
2562 /* Destroy an object or one in a stack of objects. */
2565 if (o_ptr->number > 1)
2566 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
2568 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2570 /* Reduce rod stack maximum timeout, drain wands. */
2571 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
2572 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
2574 /* Reduce and describe p_ptr->inventory_list */
2577 inven_item_increase(item, -1);
2578 inven_item_describe(item);
2579 inven_item_optimize(item);
2582 /* Reduce and describe floor item */
2585 floor_item_increase(0 - item, -1);
2586 floor_item_describe(0 - item);
2587 floor_item_optimize(0 - item);
2591 /* Destroy all members of a stack of objects. */
2594 if (o_ptr->number > 1)
2595 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
2597 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2599 /* Reduce and describe p_ptr->inventory_list */
2602 inven_item_increase(item, -999);
2603 inven_item_describe(item);
2604 inven_item_optimize(item);
2607 /* Reduce and describe floor item */
2610 floor_item_increase(0 - item, -999);
2611 floor_item_describe(0 - item);
2612 floor_item_optimize(0 - item);
2617 p_ptr->update |= (PU_COMBINE | PU_REORDER);
2618 p_ptr->window |= (PW_INVEN);
2620 /* Something was done */
2626 * @brief プレイヤーの全既知呪文を表示する /
2627 * Hack -- Display all known spells in a window
2630 * Need to analyze size of the window.
2631 * Need more color coding.
2633 void display_spell_list(void)
2638 const magic_type *s_ptr;
2639 GAME_TEXT name[MAX_NLEN];
2644 /* They have too many spells to list */
2645 if (p_ptr->pclass == CLASS_SORCERER) return;
2646 if (p_ptr->pclass == CLASS_RED_MAGE) return;
2648 if (p_ptr->pclass == CLASS_SNIPER)
2650 display_snipe_list();
2654 /* mind.c type classes */
2655 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
2656 (p_ptr->pclass == CLASS_BERSERKER) ||
2657 (p_ptr->pclass == CLASS_NINJA) ||
2658 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
2659 (p_ptr->pclass == CLASS_FORCETRAINER))
2661 PERCENTAGE minfail = 0;
2662 PLAYER_LEVEL plev = p_ptr->lev;
2663 PERCENTAGE chance = 0;
2668 bool use_hp = FALSE;
2673 /* Display a list of spells */
2675 put_str(_("名前", "Name"), y, x + 5);
2676 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
2678 switch(p_ptr->pclass)
2680 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
2681 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
2682 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
2683 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
2684 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
2685 default: use_mind = 0;break;
2688 /* Dump the spells */
2689 for (i = 0; i < MAX_MIND_POWERS; i++)
2691 byte a = TERM_WHITE;
2693 /* Access the available spell */
2694 spell = mind_powers[use_mind].info[i];
2695 if (spell.min_lev > plev) break;
2697 /* Get the failure rate */
2698 chance = spell.fail;
2700 /* Reduce failure rate by "effective" level adjustment */
2701 chance -= 3 * (p_ptr->lev - spell.min_lev);
2703 /* Reduce failure rate by INT/WIS adjustment */
2704 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2708 /* Not enough mana to cast */
2709 if (spell.mana_cost > p_ptr->csp)
2711 chance += 5 * (spell.mana_cost - p_ptr->csp);
2717 /* Not enough hp to cast */
2718 if (spell.mana_cost > p_ptr->chp)
2725 /* Extract the minimum failure rate */
2726 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2728 /* Minimum failure rate */
2729 if (chance < minfail) chance = minfail;
2731 /* Stunning makes spells harder */
2732 if (p_ptr->stun > 50) chance += 25;
2733 else if (p_ptr->stun) chance += 15;
2735 /* Always a 5 percent chance of working */
2736 if (chance > 95) chance = 95;
2739 mindcraft_info(comment, use_mind, i);
2741 /* Dump the spell */
2742 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
2744 spell.min_lev, spell.mana_cost, chance, comment);
2746 Term_putstr(x, y + i + 1, -1, a, psi_desc);
2751 /* Cannot read spellbooks */
2752 if (REALM_NONE == p_ptr->realm1) return;
2754 /* Normal spellcaster with books */
2757 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
2761 /* Reset vertical */
2764 /* Vertical location */
2765 y = (j < 3) ? 0 : (m[j - 3] + 2);
2767 /* Horizontal location */
2771 for (i = 0; i < 32; i++)
2773 byte a = TERM_WHITE;
2775 /* Access the spell */
2776 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
2778 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
2782 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
2785 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
2788 if (s_ptr->slevel >= 99)
2791 strcpy(name, _("(判読不能)", "(illegible)"));
2799 ((p_ptr->spell_forgotten1 & (1L << i))) :
2800 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
2807 else if (!((j < 1) ?
2808 (p_ptr->spell_learned1 & (1L << i)) :
2809 (p_ptr->spell_learned2 & (1L << (i % 32)))))
2816 else if (!((j < 1) ?
2817 (p_ptr->spell_worked1 & (1L << i)) :
2818 (p_ptr->spell_worked2 & (1L << (i % 32)))))
2824 /* Dump the spell --(-- */
2825 sprintf(out_val, "%c/%c) %-20.20s",
2826 I2A(n / 8), I2A(n % 8), name);
2831 /* Dump onto the window */
2832 Term_putstr(x, m[j], -1, a, out_val);
2842 * @brief 呪文の経験値を返す /
2843 * Returns experience of a spell
2845 * @param use_realm 魔法領域
2848 EXP experience_of_spell(SPELL_IDX spell, REALM_IDX use_realm)
2850 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
2851 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
2852 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
2853 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
2859 * @brief 呪文の消費MPを返す /
2860 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
2861 * @param need_mana 基本消費MP
2866 MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm)
2868 #define MANA_CONST 2400
2870 #define DEC_MANA_DIV 3
2873 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
2876 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
2877 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
2879 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
2880 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
2881 need_mana /= MANA_CONST * MANA_DIV;
2882 if (need_mana < 1) need_mana = 1;
2885 /* Non-realm magic */
2888 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
2900 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
2901 * Modify spell fail rate
2902 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2903 * @param chance 修正前失敗率
2907 PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
2909 chance += p_ptr->to_m_chance;
2911 if (p_ptr->heavy_spell) chance += 20;
2913 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
2914 else if (p_ptr->easy_spell) chance -= 3;
2915 else if (p_ptr->dec_mana) chance -= 2;
2922 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
2923 * Modify spell fail rate
2924 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2925 * @param chance 修正前失敗率
2927 * Modify spell fail rate (as "suffix" process)
2928 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2929 * Note: variable "chance" cannot be negative.
2932 PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
2934 if (p_ptr->dec_mana) chance--;
2936 if (p_ptr->heavy_spell) chance += 5;
2938 return MAX(chance, 0);
2943 * @brief 呪文の失敗率計算メインルーチン /
2944 * Returns spell chance of failure for spell -RAK-
2946 * @param use_realm 魔法領域ID
2949 PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
2951 PERCENTAGE chance, minfail;
2952 const magic_type *s_ptr;
2953 MANA_POINT need_mana;
2954 PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
2957 /* Paranoia -- must be literate */
2958 if (!mp_ptr->spell_book) return (100);
2960 if (use_realm == REALM_HISSATSU) return 0;
2962 /* Access the spell */
2963 if (!is_magic(use_realm))
2965 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
2969 s_ptr = &mp_ptr->info[use_realm - 1][spell];
2972 /* Extract the base spell failure rate */
2973 chance = s_ptr->sfail;
2975 /* Reduce failure rate by "effective" level adjustment */
2976 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
2978 /* Reduce failure rate by INT/WIS adjustment */
2979 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2982 chance += (MAX(r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
2984 /* Extract mana consumption rate */
2985 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
2987 /* Not enough mana to cast */
2988 if (need_mana > p_ptr->csp)
2990 chance += 5 * (need_mana - p_ptr->csp);
2993 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
2995 /* Extract the minimum failure rate */
2996 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2999 * Non mage/priest characters never get too good
3000 * (added high mage, mindcrafter)
3002 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
3004 if (minfail < 5) minfail = 5;
3007 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
3008 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3009 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
3011 chance = mod_spell_chance_1(chance);
3013 /* Goodness or evilness gives a penalty to failure rate */
3017 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3019 case REALM_LIFE: case REALM_CRUSADE:
3020 if (p_ptr->align < -20) chance += penalty;
3022 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3023 if (p_ptr->align > 20) chance += penalty;
3027 /* Minimum failure rate */
3028 if (chance < minfail) chance = minfail;
3030 /* Stunning makes spells harder */
3031 if (p_ptr->stun > 50) chance += 25;
3032 else if (p_ptr->stun) chance += 15;
3034 /* Always a 5 percent chance of working */
3035 if (chance > 95) chance = 95;
3037 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3038 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3040 EXP exp = experience_of_spell(spell, use_realm);
3041 if (exp >= SPELL_EXP_EXPERT) chance--;
3042 if (exp >= SPELL_EXP_MASTER) chance--;
3045 /* Return the chance */
3046 return mod_spell_chance_2(chance);
3052 * @brief 呪文情報の表示処理 /
3053 * Print a list of spells (for browsing or casting or viewing)
3054 * @param target_spell 呪文ID
3055 * @param spells 表示するスペルID配列の参照ポインタ
3056 * @param num 表示するスペルの数(spellsの要素数)
3057 * @param y 表示メッセージ左上Y座標
3058 * @param x 表示メッセージ左上X座標
3059 * @param use_realm 魔法領域ID
3062 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm)
3066 int exp_level, increment = 64;
3067 const magic_type *s_ptr;
3072 MANA_POINT need_mana;
3077 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
3078 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
3080 /* Title the list */
3082 if (use_realm == REALM_HISSATSU)
3083 strcpy(buf,_(" Lv MP", " Lv SP"));
3085 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
3087 put_str(_("名前", "Name"), y, x + 5);
3088 put_str(buf, y, x + 29);
3090 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
3091 else if (use_realm == p_ptr->realm1) increment = 0;
3092 else if (use_realm == p_ptr->realm2) increment = 32;
3094 /* Dump the spells */
3095 for (i = 0; i < num; i++)
3099 if (!is_magic(use_realm))
3101 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3105 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3108 if (use_realm == REALM_HISSATSU)
3109 need_mana = s_ptr->smana;
3112 EXP exp = experience_of_spell(spell, use_realm);
3114 /* Extract mana consumption rate */
3115 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3117 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
3118 else exp_level = spell_exp_level(exp);
3121 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
3122 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
3123 else if (s_ptr->slevel >= 99) max = TRUE;
3124 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
3126 strncpy(ryakuji, exp_level_str[exp_level], 4);
3131 if (use_menu && target_spell)
3133 if (i == (target_spell-1))
3134 strcpy(out_val, _(" 》 ", " > "));
3136 strcpy(out_val, " ");
3138 else sprintf(out_val, " %c) ", I2A(i));
3139 /* Skip illegible spells */
3140 if (s_ptr->slevel >= 99)
3142 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
3143 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
3147 /* XXX XXX Could label spells above the players level */
3149 /* Get extra info */
3150 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
3155 /* Assume spell is known and tried */
3156 line_attr = TERM_WHITE;
3158 /* Analyze the spell */
3159 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3161 if (s_ptr->slevel > p_ptr->max_plv)
3163 comment = _("未知", "unknown");
3164 line_attr = TERM_L_BLUE;
3166 else if (s_ptr->slevel > p_ptr->lev)
3168 comment = _("忘却", "forgotten");
3169 line_attr = TERM_YELLOW;
3172 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
3174 comment = _("未知", "unknown");
3175 line_attr = TERM_L_BLUE;
3177 else if ((use_realm == p_ptr->realm1) ?
3178 ((p_ptr->spell_forgotten1 & (1L << spell))) :
3179 ((p_ptr->spell_forgotten2 & (1L << spell))))
3181 comment = _("忘却", "forgotten");
3182 line_attr = TERM_YELLOW;
3184 else if (!((use_realm == p_ptr->realm1) ?
3185 (p_ptr->spell_learned1 & (1L << spell)) :
3186 (p_ptr->spell_learned2 & (1L << spell))))
3188 comment = _("未知", "unknown");
3189 line_attr = TERM_L_BLUE;
3191 else if (!((use_realm == p_ptr->realm1) ?
3192 (p_ptr->spell_worked1 & (1L << spell)) :
3193 (p_ptr->spell_worked2 & (1L << spell))))
3195 comment = _("未経験", "untried");
3196 line_attr = TERM_L_GREEN;
3199 /* Dump the spell --(-- */
3200 if (use_realm == REALM_HISSATSU)
3202 strcat(out_val, format("%-25s %2d %4d",
3203 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3204 s_ptr->slevel, need_mana));
3208 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
3209 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3210 (max ? '!' : ' '), ryakuji,
3211 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
3213 c_prt(line_attr, out_val, y + i + 1, x);
3216 /* Clear the bottom line */
3217 prt("", y + i + 1, x);
3221 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
3222 * Helper function -- return a "nearby" race for polymorphing
3223 * @param r_idx 基準となるモンスター種族ID
3224 * @return 変更先のモンスター種族ID
3226 * Note that this function is one of the more "dangerous" ones...
3228 static MONRACE_IDX poly_r_idx(MONRACE_IDX r_idx)
3230 monster_race *r_ptr = &r_info[r_idx];
3236 /* Hack -- Uniques/Questors never polymorph */
3237 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
3240 /* Allowable range of "levels" for resulting monster */
3241 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
3242 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
3244 /* Pick a (possibly new) non-unique race */
3245 for (i = 0; i < 1000; i++)
3247 /* Pick a new race, using a level calculation */
3248 r = get_mon_num((current_floor_ptr->dun_level + r_ptr->level) / 2 + 5);
3250 /* Handle failure */
3256 /* Ignore unique monsters */
3257 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3259 /* Ignore monsters with incompatible levels */
3260 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
3262 /* Use that index */
3271 * @brief 指定座標にいるモンスターを変身させる /
3272 * Helper function -- return a "nearby" race for polymorphing
3275 * @return 実際に変身したらTRUEを返す
3277 bool polymorph_monster(POSITION y, POSITION x)
3279 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
3280 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3281 bool polymorphed = FALSE;
3282 MONRACE_IDX new_r_idx;
3283 MONRACE_IDX old_r_idx = m_ptr->r_idx;
3284 bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE;
3285 bool health_tracked = (p_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
3286 monster_type back_m;
3288 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
3290 if ((p_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
3292 /* Memorize the monster before polymorphing */
3295 /* Pick a "new" monster race */
3296 new_r_idx = poly_r_idx(old_r_idx);
3298 /* Handle polymorph */
3299 if (new_r_idx != old_r_idx)
3301 BIT_FLAGS mode = 0L;
3302 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
3303 OBJECT_IDX this_o_idx, next_o_idx = 0;
3305 /* Get the monsters attitude */
3306 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
3307 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
3308 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
3310 /* Mega-hack -- ignore held objects */
3311 m_ptr->hold_o_idx = 0;
3313 /* "Kill" the "old" monster */
3314 delete_monster_idx(g_ptr->m_idx);
3316 /* Create a new monster (no groups) */
3317 if (place_monster_aux(0, y, x, new_r_idx, mode))
3319 current_floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname;
3320 current_floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
3321 current_floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
3328 /* Placing the new monster failed */
3329 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
3331 current_floor_ptr->m_list[hack_m_idx_ii] = back_m;
3333 /* Re-initialize monster process */
3336 else preserve_hold_objects = FALSE;
3339 /* Mega-hack -- preserve held objects */
3340 if (preserve_hold_objects)
3342 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3344 object_type *o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
3345 next_o_idx = o_ptr->next_o_idx;
3347 /* Held by new monster */
3348 o_ptr->held_m_idx = hack_m_idx_ii;
3351 else if (back_m.hold_o_idx) /* Failed (paranoia) */
3353 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3355 next_o_idx = current_floor_ptr->o_list[this_o_idx].next_o_idx;
3356 delete_object_idx(this_o_idx);
3360 if (targeted) target_who = hack_m_idx_ii;
3361 if (health_tracked) health_track(hack_m_idx_ii);
3370 * @param x テレポート先のX座標
3371 * @param y テレポート先のY座標
3372 * @return 目標に指定通りテレポートできたならばTRUEを返す
3374 static bool dimension_door_aux(DEPTH x, DEPTH y)
3376 PLAYER_LEVEL plev = p_ptr->lev;
3378 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3380 if (!cave_player_teleportable_bold(y, x, 0L) ||
3381 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
3382 (!randint0(plev / 10 + 10)))
3384 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3385 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
3392 teleport_player_to(y, x, 0L);
3401 * @brief 次元の扉処理のメインルーチン /
3403 * @return ターンを消費した場合TRUEを返す
3405 bool dimension_door(void)
3409 /* Rerutn FALSE if cancelled */
3410 if (!tgt_pt(&x, &y)) return FALSE;
3412 if (dimension_door_aux(x, y)) return TRUE;
3414 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
3421 * @brief 鏡抜け処理のメインルーチン /
3422 * Mirror Master's Dimension Door
3423 * @return ターンを消費した場合TRUEを返す
3425 bool mirror_tunnel(void)
3427 POSITION x = 0, y = 0;
3429 /* Rerutn FALSE if cancelled */
3430 if (!tgt_pt(&x, &y)) return FALSE;
3432 if (dimension_door_aux(x, y)) return TRUE;
3434 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
3442 * @return ターンを消費した場合TRUEを返す
3444 bool eat_magic(int power)
3450 int recharge_strength = 0;
3456 GAME_TEXT o_name[MAX_NLEN];
3458 item_tester_hook = item_tester_hook_recharge;
3460 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
3461 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
3463 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
3464 if (!o_ptr) return FALSE;
3466 k_ptr = &k_info[o_ptr->k_idx];
3467 lev = k_info[o_ptr->k_idx].level;
3469 if (o_ptr->tval == TV_ROD)
3471 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3474 if (one_in_(recharge_strength))
3476 /* Activate the failure code. */
3481 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
3483 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
3488 o_ptr->timeout += k_ptr->pval;
3494 /* All staffs, wands. */
3495 recharge_strength = (100 + power - lev) / 15;
3496 if (recharge_strength < 0) recharge_strength = 0;
3499 if (one_in_(recharge_strength))
3501 /* Activate the failure code. */
3506 if (o_ptr->pval > 0)
3508 p_ptr->csp += lev / 2;
3511 /* XXX Hack -- unstack if necessary */
3512 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
3518 /* Obtain a local object */
3519 object_copy(q_ptr, o_ptr);
3521 /* Modify quantity */
3524 /* Restore the charges */
3527 /* Unstack the used item */
3529 p_ptr->total_weight -= q_ptr->weight;
3530 item = inven_carry(q_ptr);
3532 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
3537 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
3539 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
3543 /* Inflict the penalties for failing a recharge. */
3546 /* Artifacts are never destroyed. */
3547 if (object_is_fixed_artifact(o_ptr))
3549 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3550 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3552 /* Artifact rods. */
3553 if (o_ptr->tval == TV_ROD)
3554 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3556 /* Artifact wands and staffs. */
3557 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3562 /* Get the object description */
3563 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3565 /*** Determine Seriousness of Failure ***/
3567 /* Mages recharge objects more safely. */
3568 if (IS_WIZARD_CLASS())
3570 /* 10% chance to blow up one rod, otherwise draining. */
3571 if (o_ptr->tval == TV_ROD)
3573 if (one_in_(10)) fail_type = 2;
3576 /* 75% chance to blow up one wand, otherwise draining. */
3577 else if (o_ptr->tval == TV_WAND)
3579 if (!one_in_(3)) fail_type = 2;
3582 /* 50% chance to blow up one staff, otherwise no effect. */
3583 else if (o_ptr->tval == TV_STAFF)
3585 if (one_in_(2)) fail_type = 2;
3590 /* All other classes get no special favors. */
3593 /* 33% chance to blow up one rod, otherwise draining. */
3594 if (o_ptr->tval == TV_ROD)
3596 if (one_in_(3)) fail_type = 2;
3599 /* 20% chance of the entire stack, else destroy one wand. */
3600 else if (o_ptr->tval == TV_WAND)
3602 if (one_in_(5)) fail_type = 3;
3605 /* Blow up one staff. */
3606 else if (o_ptr->tval == TV_STAFF)
3612 /*** Apply draining and destruction. ***/
3614 /* Drain object or stack of objects. */
3617 if (o_ptr->tval == TV_ROD)
3619 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
3620 "You save your rod from destruction, but all charges are lost."), o_name);
3621 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3623 else if (o_ptr->tval == TV_WAND)
3625 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3628 /* Staffs aren't drained. */
3631 /* Destroy an object or one in a stack of objects. */
3634 if (o_ptr->number > 1)
3636 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3637 /* Reduce rod stack maximum timeout, drain wands. */
3638 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
3639 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
3643 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
3646 /* Reduce and describe p_ptr->inventory_list */
3649 inven_item_increase(item, -1);
3650 inven_item_describe(item);
3651 inven_item_optimize(item);
3654 /* Reduce and describe floor item */
3657 floor_item_increase(0 - item, -1);
3658 floor_item_describe(0 - item);
3659 floor_item_optimize(0 - item);
3663 /* Destroy all members of a stack of objects. */
3666 if (o_ptr->number > 1)
3667 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3669 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3671 /* Reduce and describe p_ptr->inventory_list */
3674 inven_item_increase(item, -999);
3675 inven_item_describe(item);
3676 inven_item_optimize(item);
3679 /* Reduce and describe floor item */
3682 floor_item_increase(0 - item, -999);
3683 floor_item_describe(0 - item);
3684 floor_item_optimize(0 - item);
3690 if (p_ptr->csp > p_ptr->msp)
3692 p_ptr->csp = p_ptr->msp;
3695 p_ptr->redraw |= (PR_MANA);
3696 p_ptr->update |= (PU_COMBINE | PU_REORDER);
3697 p_ptr->window |= (PW_INVEN);
3704 * @brief 皆殺し(全方向攻撃)処理
3705 * @param py プレイヤーY座標
3706 * @param px プレイヤーX座標
3713 monster_type *m_ptr;
3716 for (dir = 0; dir < 8; dir++)
3718 y = p_ptr->y + ddy_ddd[dir];
3719 x = p_ptr->x + ddx_ddd[dir];
3720 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3721 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3723 /* Hack -- attack monsters */
3724 if (g_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
3733 feature_type *f_ptr, *mimic_f_ptr;
3736 if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
3737 y = p_ptr->y + ddy[dir];
3738 x = p_ptr->x + ddx[dir];
3739 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3740 f_ptr = &f_info[g_ptr->feat];
3741 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
3745 if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
3747 msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
3749 else if (have_flag(f_ptr->flags, FF_PERMANENT))
3751 msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch! This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
3753 else if (g_ptr->m_idx)
3755 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3756 msg_print(_("何かが邪魔しています!", "There's something in the way!"));
3758 if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(y, x, 0);
3760 else if (have_flag(f_ptr->flags, FF_TREE))
3762 msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
3764 else if (have_flag(f_ptr->flags, FF_GLASS))
3766 msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
3768 else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
3770 (void)set_food(p_ptr->food + 3000);
3772 else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
3774 (void)set_food(p_ptr->food + 5000);
3778 msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
3779 (void)set_food(p_ptr->food + 10000);
3782 /* Destroy the wall */
3783 cave_alter_feat(y, x, FF_HURT_ROCK);
3785 (void)move_player_effect(y, x, MPE_DONT_PICKUP);
3790 bool shock_power(void)
3795 PLAYER_LEVEL plev = p_ptr->lev;
3796 int boost = P_PTR_KI;
3797 if (heavy_armor()) boost /= 2;
3800 if (!get_aim_dir(&dir)) return FALSE;
3802 y = p_ptr->y + ddy[dir];
3803 x = p_ptr->x + ddx[dir];
3804 dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
3805 fire_beam(GF_MISSILE, dir, dam);
3806 if (current_floor_ptr->grid_array[y][x].m_idx)
3809 POSITION ty = y, tx = x;
3810 POSITION oy = y, ox = x;
3811 MONSTER_IDX m_idx = current_floor_ptr->grid_array[y][x].m_idx;
3812 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3813 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3814 GAME_TEXT m_name[MAX_NLEN];
3816 monster_desc(m_name, m_ptr, 0);
3818 if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2)
3820 msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
3824 for (i = 0; i < 5; i++)
3828 if (cave_empty_bold(y, x))
3835 if ((ty != oy) || (tx != ox))
3837 msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
3838 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
3839 current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
3843 update_monster(m_idx, TRUE);
3847 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
3848 p_ptr->update |= (PU_MON_LITE);
3855 bool booze(player_type *creature_ptr)
3858 if (creature_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
3859 else if (!creature_ptr->resist_conf) creature_ptr->special_attack |= ATTACK_SUIKEN;
3860 if (!creature_ptr->resist_conf)
3862 if (set_confused(randint0(20) + 15))
3868 if (!creature_ptr->resist_chaos)
3872 if (set_image(creature_ptr->image + randint0(150) + 150))
3877 if (one_in_(13) && (creature_ptr->pclass != CLASS_MONK))
3880 if (one_in_(3)) lose_all_info();
3882 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
3884 msg_print(_("知らない場所で目が醒めた。頭痛がする。", "You wake up somewhere with a sore head..."));
3885 msg_print(_("何も思い出せない。どうやってここへ来たのかも分からない!", "You can't remember a thing, or how you got here!"));
3891 bool detonation(player_type *creature_ptr)
3893 msg_print(_("体の中で激しい爆発が起きた!", "Massive explosions rupture your body!"));
3894 take_hit(DAMAGE_NOESCAPE, damroll(50, 20), _("爆発の薬", "a potion of Detonation"), -1);
3895 (void)set_stun(creature_ptr->stun + 75);
3896 (void)set_cut(creature_ptr->cut + 5000);
3900 void blood_curse_to_enemy(MONSTER_IDX m_idx)
3902 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3903 grid_type *g_ptr = ¤t_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
3904 BIT_FLAGS curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
3908 switch (randint1(28))
3913 msg_print(_("地面が揺れた...", "The ground trembles..."));
3914 earthquake(m_ptr->fy, m_ptr->fx, 4 + randint0(4));
3915 if (!one_in_(6)) break;
3917 case 3: case 4: case 5: case 6:
3920 int extra_dam = damroll(10, 10);
3921 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
3923 project(0, 8, m_ptr->fy, m_ptr->fx, extra_dam, GF_MANA, curse_flg, -1);
3924 if (!one_in_(6)) break;
3929 msg_print(_("空間が歪んだ!", "Space warps about you!"));
3931 if (m_ptr->r_idx) teleport_away(g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
3932 if (one_in_(13)) count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3933 if (!one_in_(6)) break;
3935 case 9: case 10: case 11:
3936 msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
3937 project(0, 7, m_ptr->fy, m_ptr->fx, 50, GF_DISINTEGRATE, curse_flg, -1);
3938 if (!one_in_(6)) break;
3939 case 12: case 13: case 14: case 15: case 16:
3940 aggravate_monsters(0);
3941 if (!one_in_(6)) break;
3943 count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3944 if (!one_in_(6)) break;
3945 case 19: case 20: case 21: case 22:
3947 bool pet = !one_in_(3);
3948 BIT_FLAGS mode = PM_ALLOW_GROUP;
3950 if (pet) mode |= PM_FORCE_PET;
3951 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
3953 count += summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, (pet ? p_ptr->lev * 2 / 3 + randint1(p_ptr->lev / 2) : current_floor_ptr->dun_level), 0, mode, '\0');
3954 if (!one_in_(6)) break;
3956 case 23: case 24: case 25:
3957 if (p_ptr->hold_exp && (randint0(100) < 75)) break;
3958 msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
3960 if (p_ptr->hold_exp) lose_exp(p_ptr->exp / 160);
3961 else lose_exp(p_ptr->exp / 16);
3962 if (!one_in_(6)) break;
3963 case 26: case 27: case 28:
3972 (void)do_dec_stat(i);
3973 } while (one_in_(2));
3980 (void)do_dec_stat(randint0(6));
3985 } while (one_in_(5));
3989 bool fire_crimson(void)
3993 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3997 if (!get_aim_dir(&dir)) return FALSE;
3999 /* Use the given direction */
4000 tx = p_ptr->x + 99 * ddx[dir];
4001 ty = p_ptr->y + 99 * ddy[dir];
4003 /* Hack -- Use an actual "target" */
4004 if ((dir == 5) && target_okay())
4010 if (p_ptr->pclass == CLASS_ARCHER)
4012 /* Extra shot at level 10 */
4013 if (p_ptr->lev >= 10) num++;
4015 /* Extra shot at level 30 */
4016 if (p_ptr->lev >= 30) num++;
4018 /* Extra shot at level 45 */
4019 if (p_ptr->lev >= 45) num++;
4022 for (i = 0; i < num; i++)
4023 project(0, p_ptr->lev / 20 + 1, ty, tx, p_ptr->lev*p_ptr->lev * 6 / 50, GF_ROCKET, flg, -1);
4030 * @brief 町間のテレポートを行うメインルーチン。
4031 * @return テレポート処理を決定したか否か
4033 bool tele_town(void)
4039 if (current_floor_ptr->dun_level)
4041 msg_print(_("この魔法は地上でしか使えない!", "This spell can only be used on the surface!"));
4045 if (p_ptr->inside_arena || p_ptr->inside_battle)
4047 msg_print(_("この魔法は外でしか使えない!", "This spell can only be used outside!"));
4054 for (i = 1; i < max_towns; i++)
4058 if ((i == NO_TOWN) || (i == SECRET_TOWN) || (i == p_ptr->town_num) || !(p_ptr->visit & (1L << (i - 1)))) continue;
4060 sprintf(buf, "%c) %-20s", I2A(i - 1), town_info[i].name);
4067 msg_print(_("まだ行けるところがない。", "You have not yet visited any town."));
4073 prt(_("どこに行きますか:", "Which town you go: "), 0, 0);
4083 else if ((i < 'a') || (i > ('a' + max_towns - 2))) continue;
4084 else if (((i - 'a' + 1) == p_ptr->town_num) || ((i - 'a' + 1) == NO_TOWN) || ((i - 'a' + 1) == SECRET_TOWN) || !(p_ptr->visit & (1L << (i - 'a')))) continue;
4088 for (y = 0; y < current_world_ptr->max_wild_y; y++)
4090 for (x = 0; x < current_world_ptr->max_wild_x; x++)
4092 if (wilderness[y][x].town == (i - 'a' + 1))
4094 p_ptr->wilderness_y = y;
4095 p_ptr->wilderness_x = x;
4100 p_ptr->leaving = TRUE;
4101 p_ptr->leave_bldg = TRUE;
4102 p_ptr->teleport_town = TRUE;