3 * @brief 魔法効果の実装/ Spell code (part 3)
7 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
16 #include "object-boost.h"
17 #include "object-flavor.h"
18 #include "object-hook.h"
20 #include "player-move.h"
21 #include "player-status.h"
22 #include "spells-summon.h"
27 #include "spells-floor.h"
29 #include "monster-process.h"
30 #include "monster-status.h"
31 #include "monster-spell.h"
32 #include "cmd-spell.h"
34 #include "floor-save.h"
36 #include "player-effects.h"
39 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
44 * @brief モンスターのテレポートアウェイ処理 /
45 * Teleport a monster, normally up to "dis" grids away.
46 * @param m_idx モンスターID
49 * @return テレポートが実際に行われたらtrue
51 * Attempt to move the monster at least "dis/2" grids away.
52 * But allow variation to prevent infinite loops.
54 bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
56 POSITION oy, ox, d, i, min;
58 POSITION ny = 0, nx = 0;
62 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
63 if (!monster_is_valid(m_ptr)) return (FALSE);
68 /* Minimum distance */
71 if ((mode & TELEPORT_DEC_VALOUR) &&
72 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
73 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
75 chg_virtue(V_VALOUR, -1);
83 /* Verify max distance */
84 if (dis > 200) dis = 200;
86 /* Try several locations */
87 for (i = 0; i < 500; i++)
89 /* Pick a (possibly illegal) location */
92 ny = rand_spread(oy, dis);
93 nx = rand_spread(ox, dis);
94 d = distance(oy, ox, ny, nx);
95 if ((d >= min) && (d <= dis)) break;
98 /* Ignore illegal locations */
99 if (!in_bounds(ny, nx)) continue;
101 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
103 /* No teleporting into vaults and such */
104 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
105 if (current_floor_ptr->grid_array[ny][nx].info & CAVE_ICKY) continue;
107 /* This grid looks good */
114 /* Increase the maximum distance */
117 /* Decrease the minimum distance */
120 /* Stop after MAX_TRIES tries */
121 if (tries > MAX_TRIES) return (FALSE);
124 sound(SOUND_TPOTHER);
126 /* Update the old location */
127 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
129 /* Update the new location */
130 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
132 /* Move the monster */
136 /* Forget the counter target */
139 update_monster(m_idx, TRUE);
143 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
144 p_ptr->update |= (PU_MON_LITE);
151 * @brief モンスターを指定された座標付近にテレポートする /
152 * Teleport monster next to a grid near the given location
153 * @param m_idx モンスターID
156 * @param power テレポート成功確率
160 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
162 POSITION ny, nx, oy, ox;
167 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
168 if(!m_ptr->r_idx) return;
171 if(randint1(100) > power) return;
178 /* Minimum distance */
181 /* Look until done */
182 while (look && --attempts)
184 /* Verify max distance */
185 if (dis > 200) dis = 200;
187 /* Try several locations */
188 for (i = 0; i < 500; i++)
190 /* Pick a (possibly illegal) location */
193 ny = rand_spread(ty, dis);
194 nx = rand_spread(tx, dis);
195 d = distance(ty, tx, ny, nx);
196 if ((d >= min) && (d <= dis)) break;
199 /* Ignore illegal locations */
200 if (!in_bounds(ny, nx)) continue;
202 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
204 /* No teleporting into vaults and such */
205 /* if (current_floor_ptr->grid_array[ny][nx].info & (CAVE_ICKY)) continue; */
207 /* This grid looks good */
214 /* Increase the maximum distance */
217 /* Decrease the minimum distance */
221 if (attempts < 1) return;
223 sound(SOUND_TPOTHER);
225 /* Update the old location */
226 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
228 /* Update the new location */
229 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
231 /* Move the monster */
235 update_monster(m_idx, TRUE);
239 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
240 p_ptr->update |= (PU_MON_LITE);
244 * @brief プレイヤーのテレポート先選定と移動処理 /
245 * Teleport the player to a location up to "dis" grids away.
248 * @return 実際にテレポート処理が行われたらtrue
251 * If no such spaces are readily available, the distance may increase.
252 * Try very hard to move the player at least a quarter that distance.
254 * There was a nasty tendency for a long time; which was causing the
255 * player to "bounce" between two or three different spots because
256 * these are the only spots that are "far enough" way to satisfy the
259 * But this tendency is now removed; in the new algorithm, a list of
260 * candidates is selected first, which includes at least 50% of all
261 * floor grids within the distance, and any single grid in this list
262 * of candidates has equal possibility to be choosen as a destination.
266 bool teleport_player_aux(POSITION dis, BIT_FLAGS mode)
268 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
269 int total_candidates, cur_candidates;
270 POSITION y = 0, x = 0;
273 int left = MAX(1, p_ptr->x - dis);
274 int right = MIN(current_floor_ptr->width - 2, p_ptr->x + dis);
275 int top = MAX(1, p_ptr->y - dis);
276 int bottom = MIN(current_floor_ptr->height - 2, p_ptr->y + dis);
278 if (p_ptr->wild_mode) return FALSE;
280 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
282 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
286 /* Initialize counters */
287 total_candidates = 0;
288 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
289 candidates_at[i] = 0;
291 /* Limit the distance */
292 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
294 /* Search valid locations */
295 for (y = top; y <= bottom; y++)
297 for (x = left; x <= right; x++)
301 /* Skip illegal locations */
302 if (!cave_player_teleportable_bold(y, x, mode)) continue;
304 /* Calculate distance */
305 d = distance(p_ptr->y, p_ptr->x, y, x);
307 /* Skip too far locations */
308 if (d > dis) continue;
310 /* Count the total number of candidates */
313 /* Count the number of candidates in this circumference */
318 /* No valid location! */
319 if (0 == total_candidates) return FALSE;
321 /* Fix the minimum distance */
322 for (cur_candidates = 0, min = dis; min >= 0; min--)
324 cur_candidates += candidates_at[min];
326 /* 50% of all candidates will have an equal chance to be choosen. */
327 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
330 /* Pick up a single location randomly */
331 pick = randint1(cur_candidates);
333 /* Search again the choosen location */
334 for (y = top; y <= bottom; y++)
336 for (x = left; x <= right; x++)
340 /* Skip illegal locations */
341 if (!cave_player_teleportable_bold(y, x, mode)) continue;
343 /* Calculate distance */
344 d = distance(p_ptr->y, p_ptr->x, y, x);
346 /* Skip too far locations */
347 if (d > dis) continue;
349 /* Skip too close locations */
350 if (d < min) continue;
352 /* This grid was picked up? */
361 if (player_bold(y, x)) return FALSE;
363 sound(SOUND_TELEPORT);
366 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
367 msg_format("『こっちだぁ、%s』", p_ptr->name);
370 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
375 * @brief プレイヤーのテレポート処理メインルーチン
380 void teleport_player(POSITION dis, BIT_FLAGS mode)
383 POSITION oy = p_ptr->y;
384 POSITION ox = p_ptr->x;
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 = current_floor_ptr->grid_array[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 = ¤t_floor_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)
425 POSITION oy = p_ptr->y;
426 POSITION ox = p_ptr->x;
428 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
430 /* Monsters with teleport ability may follow the player */
431 for (xx = -1; xx < 2; xx++)
433 for (yy = -1; yy < 2; yy++)
435 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
437 /* A monster except your mount or caster may follow */
438 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
440 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
441 monster_race *r_ptr = &r_info[m_ptr->r_idx];
444 * The latter limitation is to avoid
445 * totally unkillable suckers...
447 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
448 !(r_ptr->flagsr & RFR_RES_TELE))
450 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
459 * @brief プレイヤーを指定位置近辺にテレポートさせる
460 * Teleport player to a grid near the given location
463 * @param mode オプションフラグ
467 * This function is slightly obsessive about correctness.
468 * This function allows teleporting into vaults (!)
471 void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
474 POSITION dis = 0, ctr = 0;
476 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
478 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
482 /* Find a usable location */
485 /* Pick a nearby legal location */
488 y = (POSITION)rand_spread(ny, dis);
489 x = (POSITION)rand_spread(nx, dis);
490 if (in_bounds(y, x)) break;
493 /* Accept any grid when wizard mode */
494 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;
496 /* Accept teleportable floor grids */
497 if (cave_player_teleportable_bold(y, x, mode)) break;
499 /* Occasionally advance the distance */
500 if (++ctr > (4 * dis * dis + 4 * dis + 1))
507 sound(SOUND_TELEPORT);
508 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
512 void teleport_away_followable(MONSTER_IDX m_idx)
514 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
515 POSITION oldfy = m_ptr->fy;
516 POSITION oldfx = m_ptr->fx;
517 bool old_ml = m_ptr->ml;
518 POSITION old_cdis = m_ptr->cdis;
520 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
522 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))
526 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
529 BIT_FLAGS flgs[TR_FLAG_SIZE];
533 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
535 o_ptr = &inventory[i];
536 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
538 object_flags(o_ptr, flgs);
539 if (have_flag(flgs, TR_TELEPORT))
550 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
554 teleport_player(200, TELEPORT_PASSIVE);
555 msg_print(_("失敗!", "Failed!"));
557 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
558 p_ptr->energy_need += ENERGY_NEED();
565 bool teleport_level_other(player_type *creature_ptr)
567 MONSTER_IDX target_m_idx;
570 GAME_TEXT m_name[MAX_NLEN];
572 if (!target_set(TARGET_KILL)) return FALSE;
573 target_m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
574 if (!target_m_idx) return TRUE;
575 if (!player_has_los_bold(target_row, target_col)) return TRUE;
576 if (!projectable(creature_ptr->y, creature_ptr->x, target_row, target_col)) return TRUE;
577 m_ptr = ¤t_floor_ptr->m_list[target_m_idx];
578 r_ptr = &r_info[m_ptr->r_idx];
579 monster_desc(m_name, m_ptr, 0);
580 msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
582 if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
583 (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > creature_ptr->lev + randint1(60)))
585 msg_format(_("しかし効果がなかった!", "%^s is unaffected!"), m_name);
587 else teleport_level(target_m_idx);
592 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
593 * Teleport the player one level up or down (random when legal)
594 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
597 void teleport_level(MONSTER_IDX m_idx)
600 GAME_TEXT m_name[160];
603 if (m_idx <= 0) /* To player */
605 strcpy(m_name, _("あなた", "you"));
607 else /* To monster */
609 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
611 /* Get the monster name (or "it") */
612 monster_desc(m_name, m_ptr, 0);
614 see_m = is_seen(m_ptr);
617 /* No effect in some case */
618 if (TELE_LEVEL_IS_INEFF(m_idx))
620 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
624 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
626 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
630 /* Choose up or down */
631 if (randint0(100) < 50) go_up = TRUE;
634 if ((m_idx <= 0) && p_ptr->wizard)
636 if (get_check("Force to go up? ")) go_up = TRUE;
637 else if (get_check("Force to go down? ")) go_up = FALSE;
641 if ((ironman_downward && (m_idx <= 0)) || (current_floor_ptr->dun_level <= d_info[p_ptr->dungeon_idx].mindepth))
644 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
646 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
648 if (m_idx <= 0) /* To player */
650 if (!current_floor_ptr->dun_level)
652 p_ptr->dungeon_idx = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
653 p_ptr->oldpy = p_ptr->y;
654 p_ptr->oldpx = p_ptr->x;
657 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
659 if (autosave_l) do_cmd_save_game(TRUE);
661 if (!current_floor_ptr->dun_level)
663 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].mindepth;
664 prepare_change_floor_mode(CFM_RAND_PLACE);
668 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
670 p_ptr->leaving = TRUE;
675 else if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth))
678 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
680 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
684 if (m_idx <= 0) /* To player */
686 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
688 if (autosave_l) do_cmd_save_game(TRUE);
690 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
693 p_ptr->inside_quest = 0;
694 p_ptr->leaving = TRUE;
700 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
702 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
706 if (m_idx <= 0) /* To player */
708 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
710 if (autosave_l) do_cmd_save_game(TRUE);
712 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
713 p_ptr->leaving = TRUE;
719 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
721 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
724 if (m_idx <= 0) /* To player */
726 /* Never reach this code on the surface */
727 /* if (!current_floor_ptr->dun_level) p_ptr->dungeon_idx = p_ptr->recall_dungeon; */
728 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
729 if (autosave_l) do_cmd_save_game(TRUE);
731 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
732 p_ptr->leaving = TRUE;
736 /* Monster level teleportation is simple deleting now */
739 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
741 check_quest_completion(m_ptr);
743 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
745 char m2_name[MAX_NLEN];
747 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
748 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
751 delete_monster_idx(m_idx);
754 sound(SOUND_TPLEVEL);
759 * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
760 * @param note ダンジョンに施す処理記述
763 * @return 選択されたダンジョンID
765 DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x)
767 DUNGEON_IDX select_dungeon;
772 /* Hack -- No need to choose dungeon in some case */
773 if (lite_town || vanilla_town || ironman_downward)
775 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
778 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
784 /* Allocate the "dun" array */
785 C_MAKE(dun, max_d_idx, DUNGEON_IDX);
788 for(i = 1; i < max_d_idx; i++)
793 if (!d_info[i].maxdepth) continue;
794 if (!max_dlv[i]) continue;
795 if (d_info[i].final_guardian)
797 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
799 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
801 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
802 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
803 prt(buf, y + num, x);
809 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
812 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
816 if ((i == ESCAPE) || !num)
818 /* Free the "dun" array */
819 C_KILL(dun, max_d_idx, DUNGEON_IDX);
824 if (i >= 'a' && i <('a'+num))
826 select_dungeon = dun[i-'a'];
833 /* Free the "dun" array */
834 C_KILL(dun, max_d_idx, DUNGEON_IDX);
836 return select_dungeon;
841 * @brief プレイヤーの帰還発動及び中止処理 /
842 * Recall the player to town or dungeon
843 * @param turns 発動までのターン数
846 bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
849 * TODO: Recall the player to the last
850 * visited town when in the wilderness
854 if (creature_ptr->inside_arena || ironman_downward)
856 msg_print(_("何も起こらなかった。", "Nothing happens."));
860 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)
862 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
864 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
866 do_cmd_write_nikki(NIKKI_TRUMP, p_ptr->dungeon_idx, _("帰還のときに", "when recall from dungeon"));
870 if (!creature_ptr->word_recall)
872 if (!current_floor_ptr->dun_level)
874 DUNGEON_IDX select_dungeon;
875 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
876 if (!select_dungeon) return FALSE;
877 creature_ptr->recall_dungeon = select_dungeon;
879 creature_ptr->word_recall = turns;
880 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
881 creature_ptr->redraw |= (PR_STATUS);
885 creature_ptr->word_recall = 0;
886 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
887 creature_ptr->redraw |= (PR_STATUS);
892 bool free_level_recall(player_type *creature_ptr)
894 DUNGEON_IDX select_dungeon;
898 select_dungeon = choose_dungeon(_("にテレポート", "teleport"), 4, 0);
900 if (!select_dungeon) return FALSE;
902 max_depth = d_info[select_dungeon].maxdepth;
904 /* Limit depth in Angband */
905 if (select_dungeon == DUNGEON_ANGBAND)
907 if (quest[QUEST_OBERON].status != QUEST_STATUS_FINISHED) max_depth = 98;
908 else if (quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
910 amt = get_quantity(format(_("%sの何階にテレポートしますか?", "Teleport to which level of %s? "),
911 d_name + d_info[select_dungeon].name), (QUANTITY)max_depth);
915 creature_ptr->word_recall = 1;
916 creature_ptr->recall_dungeon = select_dungeon;
917 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));
919 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("トランプタワーで", "at Trump Tower"));
921 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
923 creature_ptr->redraw |= (PR_STATUS);
932 * @return リセット処理が実際に行われたらTRUEを返す
934 bool reset_recall(void)
936 int select_dungeon, dummy = 0;
940 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
943 if (ironman_downward)
945 msg_print(_("何も起こらなかった。", "Nothing happens."));
949 if (!select_dungeon) return FALSE;
951 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
952 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
955 sprintf(tmp_val, "%d", (int)MAX(current_floor_ptr->dun_level, 1));
957 /* Ask for a level */
958 if (get_string(ppp, tmp_val, 10))
960 /* Extract request */
961 dummy = atoi(tmp_val);
962 if (dummy < 1) dummy = 1;
963 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
964 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
966 max_dlv[select_dungeon] = dummy;
969 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
972 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
974 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
987 * @brief プレイヤーの装備劣化処理 /
988 * Apply disenchantment to the player's stuff
989 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
990 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
991 * Return "TRUE" if the player notices anything
993 bool apply_disenchant(BIT_FLAGS mode)
997 GAME_TEXT o_name[MAX_NLEN];
998 int to_h, to_d, to_a, pval;
1000 /* Pick a random slot */
1001 switch (randint1(8))
1003 case 1: t = INVEN_RARM; break;
1004 case 2: t = INVEN_LARM; break;
1005 case 3: t = INVEN_BOW; break;
1006 case 4: t = INVEN_BODY; break;
1007 case 5: t = INVEN_OUTER; break;
1008 case 6: t = INVEN_HEAD; break;
1009 case 7: t = INVEN_HANDS; break;
1010 case 8: t = INVEN_FEET; break;
1013 o_ptr = &inventory[t];
1015 /* No item, nothing happens */
1016 if (!o_ptr->k_idx) return (FALSE);
1018 /* Disenchant equipments only -- No disenchant on monster ball */
1019 if (!object_is_weapon_armour_ammo(o_ptr))
1022 /* Nothing to disenchant */
1023 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1025 /* Nothing to notice */
1029 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1031 /* Artifacts have 71% chance to resist */
1032 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1035 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1037 msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t),
1038 ((o_ptr->number != 1) ? "" : "s"));
1044 /* Memorize old value */
1050 /* Disenchant tohit */
1051 if (o_ptr->to_h > 0) o_ptr->to_h--;
1052 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1054 /* Disenchant todam */
1055 if (o_ptr->to_d > 0) o_ptr->to_d--;
1056 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1058 /* Disenchant toac */
1059 if (o_ptr->to_a > 0) o_ptr->to_a--;
1060 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1062 /* Disenchant pval (occasionally) */
1063 /* Unless called from wild_magic() */
1064 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1066 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1067 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1070 msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t) );
1072 msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t),
1073 ((o_ptr->number != 1) ? "were" : "was"));
1076 chg_virtue(V_HARMONY, 1);
1077 chg_virtue(V_ENCHANT, -2);
1078 p_ptr->update |= (PU_BONUS);
1079 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1089 * @brief 武器へのエゴ付加処理 /
1090 * Brand the current weapon
1091 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1094 void brand_weapon(int brand_type)
1100 /* Assume enchant weapon */
1101 item_tester_hook = object_allow_enchant_melee_weapon;
1103 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1104 s = _("強化できる武器がない。", "You have nothing to enchant.");
1106 o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
1109 /* you can never modify artifacts / ego-items */
1110 /* you can never modify cursed items */
1111 /* TY: You _can_ modify broken items (if you're silly enough) */
1112 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1113 !object_is_cursed(o_ptr) &&
1114 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1115 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1116 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1120 /* Let's get the name before it is changed... */
1121 GAME_TEXT o_name[MAX_NLEN];
1122 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1127 if (o_ptr->tval == TV_SWORD)
1129 act = _("は鋭さを増した!", "becomes very sharp!");
1131 o_ptr->name2 = EGO_SHARPNESS;
1132 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, current_floor_ptr->dun_level) + 1;
1134 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1139 act = _("は破壊力を増した!", "seems very powerful.");
1140 o_ptr->name2 = EGO_EARTHQUAKES;
1141 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, current_floor_ptr->dun_level);
1145 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1146 o_ptr->name2 = EGO_KILL_HUMAN;
1149 act = _("は電撃に覆われた!", "covered with lightning!");
1150 o_ptr->name2 = EGO_BRAND_ELEC;
1153 act = _("は酸に覆われた!", "coated with acid!");
1154 o_ptr->name2 = EGO_BRAND_ACID;
1157 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1158 o_ptr->name2 = EGO_KILL_EVIL;
1161 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1162 o_ptr->name2 = EGO_KILL_DEMON;
1165 act = _("は屍を求めている!", "seems to be looking for undead!");
1166 o_ptr->name2 = EGO_KILL_UNDEAD;
1169 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1170 o_ptr->name2 = EGO_KILL_ANIMAL;
1173 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1174 o_ptr->name2 = EGO_KILL_DRAGON;
1177 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1178 o_ptr->name2 = EGO_KILL_TROLL;
1181 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1182 o_ptr->name2 = EGO_KILL_ORC;
1185 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1186 o_ptr->name2 = EGO_KILL_GIANT;
1189 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1190 o_ptr->name2 = EGO_TRUMP;
1191 o_ptr->pval = randint1(2);
1194 act = _("は血を求めている!", "thirsts for blood!");
1195 o_ptr->name2 = EGO_VAMPIRIC;
1198 act = _("は毒に覆われた。", "is coated with poison.");
1199 o_ptr->name2 = EGO_BRAND_POIS;
1202 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1203 o_ptr->name2 = EGO_CHAOTIC;
1206 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1207 o_ptr->name2 = EGO_BRAND_FIRE;
1210 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1211 o_ptr->name2 = EGO_BRAND_COLD;
1215 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1216 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1218 o_ptr->discount = 99;
1219 chg_virtue(V_ENCHANT, 2);
1223 if (flush_failure) flush();
1225 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1226 chg_virtue(V_ENCHANT, -2);
1233 * @brief 虚無招来によるフロア中の全壁除去処理 /
1234 * Vanish all walls in this floor
1235 * @return 実際に処理が反映された場合TRUE
1237 static bool vanish_dungeon(void)
1241 feature_type *f_ptr;
1242 monster_type *m_ptr;
1243 GAME_TEXT m_name[MAX_NLEN];
1245 /* Prevent vasishing of quest levels and town */
1246 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1251 /* Scan all normal grids */
1252 for (y = 1; y < current_floor_ptr->height - 1; y++)
1254 for (x = 1; x < current_floor_ptr->width - 1; x++)
1256 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1258 /* Seeing true feature code (ignore mimic) */
1259 f_ptr = &f_info[g_ptr->feat];
1261 /* Lose room and vault */
1262 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1264 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
1267 if (g_ptr->m_idx && MON_CSLEEP(m_ptr))
1269 (void)set_monster_csleep(g_ptr->m_idx, 0);
1271 /* Notice the "waking up" */
1274 monster_desc(m_name, m_ptr, 0);
1275 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1279 /* Process all walls, doors and patterns */
1280 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1284 /* Special boundary walls -- Top and bottom */
1285 for (x = 0; x < current_floor_ptr->width; x++)
1287 g_ptr = ¤t_floor_ptr->grid_array[0][x];
1288 f_ptr = &f_info[g_ptr->mimic];
1290 /* Lose room and vault */
1291 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1293 /* Set boundary mimic if needed */
1294 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1296 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1298 /* Check for change to boring grid */
1299 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1302 g_ptr = ¤t_floor_ptr->grid_array[current_floor_ptr->height - 1][x];
1303 f_ptr = &f_info[g_ptr->mimic];
1305 /* Lose room and vault */
1306 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1308 /* Set boundary mimic if needed */
1309 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1311 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1313 /* Check for change to boring grid */
1314 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1318 /* Special boundary walls -- Left and right */
1319 for (y = 1; y < (current_floor_ptr->height - 1); y++)
1321 g_ptr = ¤t_floor_ptr->grid_array[y][0];
1322 f_ptr = &f_info[g_ptr->mimic];
1324 /* Lose room and vault */
1325 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1327 /* Set boundary mimic if needed */
1328 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1330 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1332 /* Check for change to boring grid */
1333 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1336 g_ptr = ¤t_floor_ptr->grid_array[y][current_floor_ptr->width - 1];
1337 f_ptr = &f_info[g_ptr->mimic];
1339 /* Lose room and vault */
1340 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1342 /* Set boundary mimic if needed */
1343 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1345 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1347 /* Check for change to boring grid */
1348 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1352 /* Mega-Hack -- Forget the view and lite */
1353 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1354 p_ptr->redraw |= (PR_MAP);
1355 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1364 void call_the_(void)
1368 bool do_call = TRUE;
1370 for (i = 0; i < 9; i++)
1372 g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1374 if (!cave_have_flag_grid(g_ptr, FF_PROJECT))
1376 if (!g_ptr->mimic || !have_flag(f_info[g_ptr->mimic].flags, FF_PROJECT) ||
1377 !permanent_wall(&f_info[g_ptr->feat]))
1387 for (i = 1; i < 10; i++)
1389 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1392 for (i = 1; i < 10; i++)
1394 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1397 for (i = 1; i < 10; i++)
1399 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1403 /* Prevent destruction of quest levels and town */
1404 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1406 msg_print(_("地面が揺れた。", "The ground trembles."));
1412 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1413 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1415 msg_format("You %s the %s too close to a wall!",
1416 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1417 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1419 msg_print(_("大きな爆発音があった!", "There is a loud explosion!"));
1423 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1427 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1428 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1430 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1433 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1439 * @brief アイテム引き寄せ処理 /
1440 * Fetch an item (teleport it right underneath the caster)
1441 * @param dir 魔法の発動方向
1443 * @param require_los 射線の通りを要求するならばTRUE
1446 void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
1452 GAME_TEXT o_name[MAX_NLEN];
1454 /* Check to see if an object is already there */
1455 if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx)
1457 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1462 if (dir == 5 && target_okay())
1467 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1469 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1473 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1475 /* We need an item to fetch */
1478 msg_print(_("そこには何もありません。", "There is no object at this place."));
1482 /* No fetching from vault */
1483 if (g_ptr->info & CAVE_ICKY)
1485 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1489 /* We need to see the item */
1492 if (!player_has_los_bold(ty, tx))
1494 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1497 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1499 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1512 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1514 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1515 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1517 while (!g_ptr->o_idx);
1520 o_ptr = ¤t_floor_ptr->o_list[g_ptr->o_idx];
1522 if (o_ptr->weight > wgt)
1524 /* Too heavy to 'fetch' */
1525 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1530 g_ptr->o_idx = o_ptr->next_o_idx;
1531 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1533 o_ptr->next_o_idx = 0;
1534 o_ptr->iy = p_ptr->y;
1535 o_ptr->ix = p_ptr->x;
1537 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1538 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1540 note_spot(p_ptr->y, p_ptr->x);
1541 p_ptr->redraw |= PR_MAP;
1548 void alter_reality(void)
1550 /* Ironman option */
1551 if (p_ptr->inside_arena || ironman_downward)
1553 msg_print(_("何も起こらなかった。", "Nothing happens."));
1557 if (!p_ptr->alter_reality)
1559 TIME_EFFECT turns = randint0(21) + 15;
1561 p_ptr->alter_reality = turns;
1562 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1564 p_ptr->redraw |= (PR_STATUS);
1568 p_ptr->alter_reality = 0;
1569 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1570 p_ptr->redraw |= (PR_STATUS);
1576 * @brief 全所持アイテム鑑定処理 /
1577 * Identify everything being carried.
1578 * Done by a potion of "self knowledge".
1581 void identify_pack(void)
1585 /* Simply identify and know every item */
1586 for (i = 0; i < INVEN_TOTAL; i++)
1588 object_type *o_ptr = &inventory[i];
1590 /* Skip non-objects */
1591 if (!o_ptr->k_idx) continue;
1593 identify_item(o_ptr);
1595 /* Auto-inscription */
1596 autopick_alter_item(i, FALSE);
1602 * @brief 装備強化処理の失敗率定数(千分率) /
1603 * Used by the "enchant" function (chance of failure)
1604 * (modified for Zangband, we need better stuff there...) -- TY
1607 static int enchant_table[16] =
1609 0, 10, 50, 100, 200,
1610 300, 400, 500, 650, 800,
1611 950, 987, 993, 995, 998,
1618 * Removes curses from items in inventory
1619 * @param all 軽い呪いまでの解除ならば0
1620 * @return 解呪されたアイテムの数
1623 * Note that Items which are "Perma-Cursed" (The One Ring,
1624 * The Crown of Morgoth) can NEVER be uncursed.
1626 * Note that if "all" is FALSE, then Items which are
1627 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1628 * will not be uncursed.
1631 static int remove_curse_aux(int all)
1635 /* Attempt to uncurse items being worn */
1636 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1638 object_type *o_ptr = &inventory[i];
1640 /* Skip non-objects */
1641 if (!o_ptr->k_idx) continue;
1643 /* Uncursed already */
1644 if (!object_is_cursed(o_ptr)) continue;
1646 /* Heavily Cursed Items need a special spell */
1647 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1649 /* Perma-Cursed Items can NEVER be uncursed */
1650 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1652 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1656 o_ptr->curse_flags = 0L;
1657 o_ptr->ident |= (IDENT_SENSE);
1658 o_ptr->feeling = FEEL_NONE;
1660 p_ptr->update |= (PU_BONUS);
1661 p_ptr->window |= (PW_EQUIP);
1663 /* Count the uncursings */
1669 msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
1671 /* Return "something uncursed" */
1677 * @brief 装備の軽い呪い解呪処理 /
1678 * Remove most curses
1679 * @return 解呪に成功した装備数
1681 int remove_curse(void)
1683 return (remove_curse_aux(FALSE));
1687 * @brief 装備の重い呪い解呪処理 /
1689 * @return 解呪に成功した装備数
1691 int remove_all_curse(void)
1693 return (remove_curse_aux(TRUE));
1698 * @brief アイテムの価値に応じた錬金術処理 /
1699 * Turns an object into gold, gain some of its value in a shop
1700 * @return 処理が実際に行われたらTRUEを返す
1706 ITEM_NUMBER old_number;
1710 GAME_TEXT o_name[MAX_NLEN];
1711 char out_val[MAX_NLEN+40];
1715 /* Hack -- force destruction */
1716 if (command_arg > 0) force = TRUE;
1718 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
1719 s = _("金に変えられる物がありません。", "You have nothing to current_world_ptr->game_turn to gold.");
1721 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1722 if (!o_ptr) return (FALSE);
1724 /* See how many items */
1725 if (o_ptr->number > 1)
1727 amt = get_quantity(NULL, o_ptr->number);
1729 /* Allow user abort */
1730 if (amt <= 0) return FALSE;
1733 old_number = o_ptr->number;
1734 o_ptr->number = amt;
1735 object_desc(o_name, o_ptr, 0);
1736 o_ptr->number = old_number;
1738 /* Verify unless quantity given */
1741 if (confirm_destroy || (object_value(o_ptr) > 0))
1743 /* Make a verification */
1744 sprintf(out_val, _("本当に%sを金に変えますか?", "Really current_world_ptr->game_turn %s to gold? "), o_name);
1745 if (!get_check(out_val)) return FALSE;
1749 /* Artifacts cannot be destroyed */
1750 if (!can_player_destroy_object(o_ptr))
1752 msg_format(_("%sを金に変えることに失敗した。", "You fail to current_world_ptr->game_turn %s to gold!"), o_name);
1757 price = object_value_real(o_ptr);
1761 msg_format(_("%sをニセの金に変えた。", "You current_world_ptr->game_turn %s to fool's gold."), o_name);
1767 if (amt > 1) price *= amt;
1769 if (price > 30000) price = 30000;
1770 msg_format(_("%sを$%d の金に変えた。", "You current_world_ptr->game_turn %s to %ld coins worth of gold."), o_name, price);
1773 p_ptr->redraw |= (PR_GOLD);
1774 p_ptr->window |= (PW_PLAYER);
1777 /* Eliminate the item (from the pack) */
1780 inven_item_increase(item, -amt);
1781 inven_item_describe(item);
1782 inven_item_optimize(item);
1785 /* Eliminate the item (from the floor) */
1788 floor_item_increase(0 - item, -amt);
1789 floor_item_describe(0 - item);
1790 floor_item_optimize(0 - item);
1798 * @brief 呪いの打ち破り処理 /
1799 * Break the curse of an item
1800 * @param o_ptr 呪い装備情報の参照ポインタ
1803 static void break_curse(object_type *o_ptr)
1805 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
1807 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
1809 o_ptr->curse_flags = 0L;
1810 o_ptr->ident |= (IDENT_SENSE);
1811 o_ptr->feeling = FEEL_NONE;
1818 * Enchants a plus onto an item. -RAK-
1819 * @param o_ptr 強化するアイテムの参照ポインタ
1821 * @param eflag 強化オプション(命中/ダメージ/AC)
1822 * @return 強化に成功した場合TRUEを返す
1825 * Revamped! Now takes item pointer, number of times to try enchanting,
1826 * and a flag of what to try enchanting. Artifacts resist enchantment
1827 * some of the time, and successful enchantment to at least +0 might
1828 * break a curse on the item. -CFT-
1830 * Note that an item can technically be enchanted all the way to +15 if
1831 * you wait a very, very, long time. Going from +9 to +10 only works
1832 * about 5% of the time, and from +10 to +11 only about 1% of the time.
1834 * Note that this function can now be used on "piles" of items, and
1835 * the larger the pile, the lower the chance of success.
1838 bool enchant(object_type *o_ptr, int n, int eflag)
1840 int i, chance, prob;
1842 bool a = object_is_artifact(o_ptr);
1843 bool force = (eflag & ENCH_FORCE);
1845 /* Large piles resist enchantment */
1846 prob = o_ptr->number * 100;
1848 /* Missiles are easy to enchant */
1849 if ((o_ptr->tval == TV_BOLT) ||
1850 (o_ptr->tval == TV_ARROW) ||
1851 (o_ptr->tval == TV_SHOT))
1857 for (i = 0; i < n; i++)
1859 /* Hack -- Roll for pile resistance */
1860 if (!force && randint0(prob) >= 100) continue;
1862 /* Enchant to hit */
1863 if (eflag & ENCH_TOHIT)
1865 if (o_ptr->to_h < 0) chance = 0;
1866 else if (o_ptr->to_h > 15) chance = 1000;
1867 else chance = enchant_table[o_ptr->to_h];
1869 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1874 /* only when you get it above -1 -CFT */
1875 if (o_ptr->to_h >= 0)
1880 /* Enchant to damage */
1881 if (eflag & ENCH_TODAM)
1883 if (o_ptr->to_d < 0) chance = 0;
1884 else if (o_ptr->to_d > 15) chance = 1000;
1885 else chance = enchant_table[o_ptr->to_d];
1887 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1892 /* only when you get it above -1 -CFT */
1893 if (o_ptr->to_d >= 0)
1898 /* Enchant to armor class */
1899 if (eflag & ENCH_TOAC)
1901 if (o_ptr->to_a < 0) chance = 0;
1902 else if (o_ptr->to_a > 15) chance = 1000;
1903 else chance = enchant_table[o_ptr->to_a];
1905 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1910 /* only when you get it above -1 -CFT */
1911 if (o_ptr->to_a >= 0)
1918 if (!res) return (FALSE);
1919 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
1920 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1930 * @brief 装備修正強化処理のメインルーチン /
1931 * Enchant an item (in the inventory or on the floor)
1932 * @param num_hit 命中修正量
1933 * @param num_dam ダメージ修正量
1934 * @param num_ac AC修正量
1935 * @return 強化に成功した場合TRUEを返す
1937 * Note that "num_ac" requires armour, else weapon
1938 * Returns TRUE if attempted, FALSE if cancelled
1940 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
1945 GAME_TEXT o_name[MAX_NLEN];
1948 /* Assume enchant weapon */
1949 item_tester_hook = object_allow_enchant_weapon;
1951 /* Enchant armor if requested */
1952 if (num_ac) item_tester_hook = object_is_armour;
1954 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
1955 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
1957 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1958 if (!o_ptr) return (FALSE);
1960 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1962 msg_format("%s は明るく輝いた!", o_name);
1964 msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1968 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
1969 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
1970 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
1975 if (flush_failure) flush();
1976 msg_print(_("強化に失敗した。", "The enchantment failed."));
1977 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
1980 chg_virtue(V_ENCHANT, 1);
1984 /* Something happened */
1990 * @brief アーティファクト生成の巻物処理 /
1991 * @return 生成が実際に試みられたらTRUEを返す
1993 bool artifact_scroll(void)
1998 GAME_TEXT o_name[MAX_NLEN];
2001 /* Enchant weapon/armour */
2002 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2004 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2005 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2007 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2008 if (!o_ptr) return (FALSE);
2010 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2012 msg_format("%s は眩い光を発した!",o_name);
2014 msg_format("%s %s radiate%s a blinding light!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
2017 if (object_is_artifact(o_ptr))
2020 msg_format("%sは既に伝説のアイテムです!", o_name );
2022 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2028 else if (object_is_ego(o_ptr))
2031 msg_format("%sは既に名のあるアイテムです!", o_name );
2033 msg_format("The %s %s already %s!",
2034 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2035 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2041 else if (o_ptr->xtra3)
2044 msg_format("%sは既に強化されています!", o_name );
2046 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"),
2047 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2053 if (o_ptr->number > 1)
2055 msg_print(_("複数のアイテムに魔法をかけるだけのエネルギーはありません!", "Not enough energy to enchant more than one object!"));
2057 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2059 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2064 inven_item_increase(item, 1 - (o_ptr->number));
2068 floor_item_increase(0 - item, 1 - (o_ptr->number));
2071 okay = create_artifact(o_ptr, TRUE);
2077 if (flush_failure) flush();
2078 msg_print(_("強化に失敗した。", "The enchantment failed."));
2079 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2083 if (record_rand_art)
2085 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2086 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2088 chg_virtue(V_ENCHANT, 1);
2093 /* Something happened */
2100 * Identify an object
2101 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2102 * @return 実際に鑑定できたらTRUEを返す
2104 bool identify_item(object_type *o_ptr)
2106 bool old_known = FALSE;
2107 GAME_TEXT o_name[MAX_NLEN];
2109 object_desc(o_name, o_ptr, 0);
2111 if (o_ptr->ident & IDENT_KNOWN)
2114 if (!(o_ptr->ident & (IDENT_MENTAL)))
2116 if (object_is_artifact(o_ptr) || one_in_(5))
2117 chg_virtue(V_KNOWLEDGE, 1);
2120 object_aware(o_ptr);
2121 object_known(o_ptr);
2122 o_ptr->marked |= OM_TOUCHED;
2124 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
2125 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2127 strcpy(record_o_name, o_name);
2128 record_turn = current_world_ptr->game_turn;
2130 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2132 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2133 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2134 if(record_rand_art && !old_known && o_ptr->art_name)
2135 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2141 * @brief アイテム鑑定のメインルーチン処理 /
2142 * Identify an object in the inventory (or on the floor)
2143 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2144 * @return 実際に鑑定を行ったならばTRUEを返す
2146 * This routine does *not* automatically combine objects.
2147 * Returns TRUE if something was identified, else FALSE.
2149 bool ident_spell(bool only_equip)
2153 GAME_TEXT o_name[MAX_NLEN];
2158 item_tester_hook = item_tester_hook_identify_weapon_armour;
2160 item_tester_hook = item_tester_hook_identify;
2164 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2169 item_tester_hook = object_is_weapon_armour_ammo;
2171 item_tester_hook = NULL;
2173 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2176 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2178 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2179 if (!o_ptr) return (FALSE);
2181 old_known = identify_item(o_ptr);
2183 object_desc(o_name, o_ptr, 0);
2184 if (item >= INVEN_RARM)
2186 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2190 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2194 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2197 /* Auto-inscription/destroy */
2198 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2200 /* Something happened */
2206 * @brief アイテム凡庸化のメインルーチン処理 /
2207 * Identify an object in the inventory (or on the floor)
2208 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2209 * @return 実際に凡庸化をを行ったならばTRUEを返す
2212 * Mundanify an object in the inventory (or on the floor)
2213 * This routine does *not* automatically combine objects.
2214 * Returns TRUE if something was mundanified, else FALSE.
2217 bool mundane_spell(bool only_equip)
2223 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2225 q = _("どれを使いますか?", "Use which item? ");
2226 s = _("使えるものがありません。", "You have nothing you can use.");
2228 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2229 if (!o_ptr) return (FALSE);
2231 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2233 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2234 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2235 OBJECT_IDX next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2236 byte marked = o_ptr->marked; /* Object is marked */
2237 WEIGHT weight = o_ptr->number * o_ptr->weight;
2238 u16b inscription = o_ptr->inscription;
2241 object_prep(o_ptr, o_ptr->k_idx);
2245 o_ptr->next_o_idx = next_o_idx;
2246 o_ptr->marked = marked;
2247 o_ptr->inscription = inscription;
2248 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2252 /* Something happened */
2257 * @brief アイテム*鑑定*のメインルーチン処理 /
2258 * Identify an object in the inventory (or on the floor)
2259 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2260 * @return 実際に鑑定を行ったならばTRUEを返す
2262 * Fully "identify" an object in the inventory -BEN-
2263 * This routine returns TRUE if an item was identified.
2265 bool identify_fully(bool only_equip)
2269 GAME_TEXT o_name[MAX_NLEN];
2274 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2276 item_tester_hook = item_tester_hook_identify_fully;
2280 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2285 item_tester_hook = object_is_weapon_armour_ammo;
2287 item_tester_hook = NULL;
2289 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2292 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2294 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2295 if (!o_ptr) return (FALSE);
2297 old_known = identify_item(o_ptr);
2299 /* Mark the item as fully known */
2300 o_ptr->ident |= (IDENT_MENTAL);
2303 object_desc(o_name, o_ptr, 0);
2304 if (item >= INVEN_RARM)
2306 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2310 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2314 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2317 /* Describe it fully */
2318 (void)screen_object(o_ptr, 0L);
2320 /* Auto-inscription/destroy */
2321 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2331 * Recharge a wand/staff/rod from the pack or on the floor.
2332 * This function has been rewritten in Oangband and ZAngband.
2333 * @param power 充填パワー
2334 * @return ターン消費を要する処理まで進んだらTRUEを返す
2336 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2337 * Chaos -- Arcane Binding --> recharge(90)
2339 * Scroll of recharging --> recharge(130)
2340 * Artifact activation/Thingol --> recharge(130)
2342 * It is harder to recharge high level, and highly charged wands,
2343 * staffs, and rods. The more wands in a stack, the more easily and
2344 * strongly they recharge. Staffs, however, each get fewer charges if
2347 * Beware of "sliding index errors".
2349 bool recharge(int power)
2353 int recharge_strength;
2354 TIME_EFFECT recharge_amount;
2363 GAME_TEXT o_name[MAX_NLEN];
2365 /* Only accept legal items */
2366 item_tester_hook = item_tester_hook_recharge;
2368 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2369 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2371 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2372 if (!o_ptr) return (FALSE);
2374 /* Get the object kind. */
2375 k_ptr = &k_info[o_ptr->k_idx];
2377 /* Extract the object "level" */
2378 lev = k_info[o_ptr->k_idx].level;
2381 /* Recharge a rod */
2382 if (o_ptr->tval == TV_ROD)
2384 /* Extract a recharge strength by comparing object level to power. */
2385 recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
2389 if (one_in_(recharge_strength))
2391 /* Activate the failure code. */
2398 /* Recharge amount */
2399 recharge_amount = (power * damroll(3, 2));
2401 /* Recharge by that amount */
2402 if (o_ptr->timeout > recharge_amount)
2403 o_ptr->timeout -= recharge_amount;
2410 /* Recharge wand/staff */
2413 /* Extract a recharge strength by comparing object level to power.
2414 * Divide up a stack of wands' charges to calculate charge penalty.
2416 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2417 recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15;
2419 /* All staffs, unstacked wands. */
2420 else recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15;
2421 if (recharge_strength < 0) recharge_strength = 0;
2424 if (one_in_(recharge_strength))
2426 /* Activate the failure code. */
2430 /* If the spell didn't backfire, recharge the wand or staff. */
2433 /* Recharge based on the standard number of charges. */
2434 recharge_amount = randint1(1 + k_ptr->pval / 2);
2436 /* Multiple wands in a stack increase recharging somewhat. */
2437 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2440 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2441 if (recharge_amount < 1) recharge_amount = 1;
2442 if (recharge_amount > 12) recharge_amount = 12;
2445 /* But each staff in a stack gets fewer additional charges,
2446 * although always at least one.
2448 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2450 recharge_amount /= (TIME_EFFECT)o_ptr->number;
2451 if (recharge_amount < 1) recharge_amount = 1;
2454 /* Recharge the wand or staff. */
2455 o_ptr->pval += recharge_amount;
2458 /* Hack -- we no longer "know" the item */
2459 o_ptr->ident &= ~(IDENT_KNOWN);
2461 /* Hack -- we no longer think the item is empty */
2462 o_ptr->ident &= ~(IDENT_EMPTY);
2467 /* Inflict the penalties for failing a recharge. */
2470 /* Artifacts are never destroyed. */
2471 if (object_is_fixed_artifact(o_ptr))
2473 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2474 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2476 /* Artifact rods. */
2477 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2478 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2480 /* Artifact wands and staffs. */
2481 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2486 /* Get the object description */
2487 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2489 /*** Determine Seriousness of Failure ***/
2491 /* Mages recharge objects more safely. */
2492 if (IS_WIZARD_CLASS() || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
2494 /* 10% chance to blow up one rod, otherwise draining. */
2495 if (o_ptr->tval == TV_ROD)
2497 if (one_in_(10)) fail_type = 2;
2500 /* 75% chance to blow up one wand, otherwise draining. */
2501 else if (o_ptr->tval == TV_WAND)
2503 if (!one_in_(3)) fail_type = 2;
2506 /* 50% chance to blow up one staff, otherwise no effect. */
2507 else if (o_ptr->tval == TV_STAFF)
2509 if (one_in_(2)) fail_type = 2;
2514 /* All other classes get no special favors. */
2517 /* 33% chance to blow up one rod, otherwise draining. */
2518 if (o_ptr->tval == TV_ROD)
2520 if (one_in_(3)) fail_type = 2;
2523 /* 20% chance of the entire stack, else destroy one wand. */
2524 else if (o_ptr->tval == TV_WAND)
2526 if (one_in_(5)) fail_type = 3;
2529 /* Blow up one staff. */
2530 else if (o_ptr->tval == TV_STAFF)
2536 /*** Apply draining and destruction. ***/
2538 /* Drain object or stack of objects. */
2541 if (o_ptr->tval == TV_ROD)
2543 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
2545 if (o_ptr->timeout < 10000)
2546 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2548 else if (o_ptr->tval == TV_WAND)
2550 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
2553 /* Staffs aren't drained. */
2556 /* Destroy an object or one in a stack of objects. */
2559 if (o_ptr->number > 1)
2560 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
2562 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2564 /* Reduce rod stack maximum timeout, drain wands. */
2565 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
2566 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
2568 /* Reduce and describe inventory */
2571 inven_item_increase(item, -1);
2572 inven_item_describe(item);
2573 inven_item_optimize(item);
2576 /* Reduce and describe floor item */
2579 floor_item_increase(0 - item, -1);
2580 floor_item_describe(0 - item);
2581 floor_item_optimize(0 - item);
2585 /* Destroy all members of a stack of objects. */
2588 if (o_ptr->number > 1)
2589 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
2591 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2593 /* Reduce and describe inventory */
2596 inven_item_increase(item, -999);
2597 inven_item_describe(item);
2598 inven_item_optimize(item);
2601 /* Reduce and describe floor item */
2604 floor_item_increase(0 - item, -999);
2605 floor_item_describe(0 - item);
2606 floor_item_optimize(0 - item);
2611 p_ptr->update |= (PU_COMBINE | PU_REORDER);
2612 p_ptr->window |= (PW_INVEN);
2614 /* Something was done */
2620 * @brief プレイヤーの全既知呪文を表示する /
2621 * Hack -- Display all known spells in a window
2624 * Need to analyze size of the window.
2625 * Need more color coding.
2627 void display_spell_list(void)
2632 const magic_type *s_ptr;
2633 GAME_TEXT name[MAX_NLEN];
2638 /* They have too many spells to list */
2639 if (p_ptr->pclass == CLASS_SORCERER) return;
2640 if (p_ptr->pclass == CLASS_RED_MAGE) return;
2642 if (p_ptr->pclass == CLASS_SNIPER)
2644 display_snipe_list();
2648 /* mind.c type classes */
2649 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
2650 (p_ptr->pclass == CLASS_BERSERKER) ||
2651 (p_ptr->pclass == CLASS_NINJA) ||
2652 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
2653 (p_ptr->pclass == CLASS_FORCETRAINER))
2655 PERCENTAGE minfail = 0;
2656 PLAYER_LEVEL plev = p_ptr->lev;
2657 PERCENTAGE chance = 0;
2662 bool use_hp = FALSE;
2667 /* Display a list of spells */
2669 put_str(_("名前", "Name"), y, x + 5);
2670 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
2672 switch(p_ptr->pclass)
2674 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
2675 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
2676 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
2677 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
2678 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
2679 default: use_mind = 0;break;
2682 /* Dump the spells */
2683 for (i = 0; i < MAX_MIND_POWERS; i++)
2685 byte a = TERM_WHITE;
2687 /* Access the available spell */
2688 spell = mind_powers[use_mind].info[i];
2689 if (spell.min_lev > plev) break;
2691 /* Get the failure rate */
2692 chance = spell.fail;
2694 /* Reduce failure rate by "effective" level adjustment */
2695 chance -= 3 * (p_ptr->lev - spell.min_lev);
2697 /* Reduce failure rate by INT/WIS adjustment */
2698 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2702 /* Not enough mana to cast */
2703 if (spell.mana_cost > p_ptr->csp)
2705 chance += 5 * (spell.mana_cost - p_ptr->csp);
2711 /* Not enough hp to cast */
2712 if (spell.mana_cost > p_ptr->chp)
2719 /* Extract the minimum failure rate */
2720 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2722 /* Minimum failure rate */
2723 if (chance < minfail) chance = minfail;
2725 /* Stunning makes spells harder */
2726 if (p_ptr->stun > 50) chance += 25;
2727 else if (p_ptr->stun) chance += 15;
2729 /* Always a 5 percent chance of working */
2730 if (chance > 95) chance = 95;
2733 mindcraft_info(comment, use_mind, i);
2735 /* Dump the spell */
2736 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
2738 spell.min_lev, spell.mana_cost, chance, comment);
2740 Term_putstr(x, y + i + 1, -1, a, psi_desc);
2745 /* Cannot read spellbooks */
2746 if (REALM_NONE == p_ptr->realm1) return;
2748 /* Normal spellcaster with books */
2751 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
2755 /* Reset vertical */
2758 /* Vertical location */
2759 y = (j < 3) ? 0 : (m[j - 3] + 2);
2761 /* Horizontal location */
2765 for (i = 0; i < 32; i++)
2767 byte a = TERM_WHITE;
2769 /* Access the spell */
2770 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
2772 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
2776 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
2779 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
2782 if (s_ptr->slevel >= 99)
2785 strcpy(name, _("(判読不能)", "(illegible)"));
2793 ((p_ptr->spell_forgotten1 & (1L << i))) :
2794 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
2801 else if (!((j < 1) ?
2802 (p_ptr->spell_learned1 & (1L << i)) :
2803 (p_ptr->spell_learned2 & (1L << (i % 32)))))
2810 else if (!((j < 1) ?
2811 (p_ptr->spell_worked1 & (1L << i)) :
2812 (p_ptr->spell_worked2 & (1L << (i % 32)))))
2818 /* Dump the spell --(-- */
2819 sprintf(out_val, "%c/%c) %-20.20s",
2820 I2A(n / 8), I2A(n % 8), name);
2825 /* Dump onto the window */
2826 Term_putstr(x, m[j], -1, a, out_val);
2836 * @brief 呪文の経験値を返す /
2837 * Returns experience of a spell
2839 * @param use_realm 魔法領域
2842 EXP experience_of_spell(SPELL_IDX spell, REALM_IDX use_realm)
2844 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
2845 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
2846 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
2847 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
2853 * @brief 呪文の消費MPを返す /
2854 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
2855 * @param need_mana 基本消費MP
2860 MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm)
2862 #define MANA_CONST 2400
2864 #define DEC_MANA_DIV 3
2867 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
2870 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
2871 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
2873 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
2874 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
2875 need_mana /= MANA_CONST * MANA_DIV;
2876 if (need_mana < 1) need_mana = 1;
2879 /* Non-realm magic */
2882 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
2894 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
2895 * Modify spell fail rate
2896 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2897 * @param chance 修正前失敗率
2901 PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
2903 chance += p_ptr->to_m_chance;
2905 if (p_ptr->heavy_spell) chance += 20;
2907 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
2908 else if (p_ptr->easy_spell) chance -= 3;
2909 else if (p_ptr->dec_mana) chance -= 2;
2916 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
2917 * Modify spell fail rate
2918 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2919 * @param chance 修正前失敗率
2921 * Modify spell fail rate (as "suffix" process)
2922 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2923 * Note: variable "chance" cannot be negative.
2926 PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
2928 if (p_ptr->dec_mana) chance--;
2930 if (p_ptr->heavy_spell) chance += 5;
2932 return MAX(chance, 0);
2937 * @brief 呪文の失敗率計算メインルーチン /
2938 * Returns spell chance of failure for spell -RAK-
2940 * @param use_realm 魔法領域ID
2943 PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
2945 PERCENTAGE chance, minfail;
2946 const magic_type *s_ptr;
2947 MANA_POINT need_mana;
2948 PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
2951 /* Paranoia -- must be literate */
2952 if (!mp_ptr->spell_book) return (100);
2954 if (use_realm == REALM_HISSATSU) return 0;
2956 /* Access the spell */
2957 if (!is_magic(use_realm))
2959 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
2963 s_ptr = &mp_ptr->info[use_realm - 1][spell];
2966 /* Extract the base spell failure rate */
2967 chance = s_ptr->sfail;
2969 /* Reduce failure rate by "effective" level adjustment */
2970 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
2972 /* Reduce failure rate by INT/WIS adjustment */
2973 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2976 chance += (MAX(r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
2978 /* Extract mana consumption rate */
2979 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
2981 /* Not enough mana to cast */
2982 if (need_mana > p_ptr->csp)
2984 chance += 5 * (need_mana - p_ptr->csp);
2987 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
2989 /* Extract the minimum failure rate */
2990 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2993 * Non mage/priest characters never get too good
2994 * (added high mage, mindcrafter)
2996 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
2998 if (minfail < 5) minfail = 5;
3001 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
3002 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3003 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
3005 chance = mod_spell_chance_1(chance);
3007 /* Goodness or evilness gives a penalty to failure rate */
3011 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3013 case REALM_LIFE: case REALM_CRUSADE:
3014 if (p_ptr->align < -20) chance += penalty;
3016 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3017 if (p_ptr->align > 20) chance += penalty;
3021 /* Minimum failure rate */
3022 if (chance < minfail) chance = minfail;
3024 /* Stunning makes spells harder */
3025 if (p_ptr->stun > 50) chance += 25;
3026 else if (p_ptr->stun) chance += 15;
3028 /* Always a 5 percent chance of working */
3029 if (chance > 95) chance = 95;
3031 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3032 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3034 EXP exp = experience_of_spell(spell, use_realm);
3035 if (exp >= SPELL_EXP_EXPERT) chance--;
3036 if (exp >= SPELL_EXP_MASTER) chance--;
3039 /* Return the chance */
3040 return mod_spell_chance_2(chance);
3046 * @brief 呪文情報の表示処理 /
3047 * Print a list of spells (for browsing or casting or viewing)
3048 * @param target_spell 呪文ID
3049 * @param spells 表示するスペルID配列の参照ポインタ
3050 * @param num 表示するスペルの数(spellsの要素数)
3051 * @param y 表示メッセージ左上Y座標
3052 * @param x 表示メッセージ左上X座標
3053 * @param use_realm 魔法領域ID
3056 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm)
3060 int exp_level, increment = 64;
3061 const magic_type *s_ptr;
3066 MANA_POINT need_mana;
3071 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
3072 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
3074 /* Title the list */
3076 if (use_realm == REALM_HISSATSU)
3077 strcpy(buf,_(" Lv MP", " Lv SP"));
3079 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
3081 put_str(_("名前", "Name"), y, x + 5);
3082 put_str(buf, y, x + 29);
3084 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
3085 else if (use_realm == p_ptr->realm1) increment = 0;
3086 else if (use_realm == p_ptr->realm2) increment = 32;
3088 /* Dump the spells */
3089 for (i = 0; i < num; i++)
3093 if (!is_magic(use_realm))
3095 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3099 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3102 if (use_realm == REALM_HISSATSU)
3103 need_mana = s_ptr->smana;
3106 EXP exp = experience_of_spell(spell, use_realm);
3108 /* Extract mana consumption rate */
3109 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3111 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
3112 else exp_level = spell_exp_level(exp);
3115 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
3116 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
3117 else if (s_ptr->slevel >= 99) max = TRUE;
3118 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
3120 strncpy(ryakuji, exp_level_str[exp_level], 4);
3125 if (use_menu && target_spell)
3127 if (i == (target_spell-1))
3128 strcpy(out_val, _(" 》 ", " > "));
3130 strcpy(out_val, " ");
3132 else sprintf(out_val, " %c) ", I2A(i));
3133 /* Skip illegible spells */
3134 if (s_ptr->slevel >= 99)
3136 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
3137 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
3141 /* XXX XXX Could label spells above the players level */
3143 /* Get extra info */
3144 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
3149 /* Assume spell is known and tried */
3150 line_attr = TERM_WHITE;
3152 /* Analyze the spell */
3153 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3155 if (s_ptr->slevel > p_ptr->max_plv)
3157 comment = _("未知", "unknown");
3158 line_attr = TERM_L_BLUE;
3160 else if (s_ptr->slevel > p_ptr->lev)
3162 comment = _("忘却", "forgotten");
3163 line_attr = TERM_YELLOW;
3166 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
3168 comment = _("未知", "unknown");
3169 line_attr = TERM_L_BLUE;
3171 else if ((use_realm == p_ptr->realm1) ?
3172 ((p_ptr->spell_forgotten1 & (1L << spell))) :
3173 ((p_ptr->spell_forgotten2 & (1L << spell))))
3175 comment = _("忘却", "forgotten");
3176 line_attr = TERM_YELLOW;
3178 else if (!((use_realm == p_ptr->realm1) ?
3179 (p_ptr->spell_learned1 & (1L << spell)) :
3180 (p_ptr->spell_learned2 & (1L << spell))))
3182 comment = _("未知", "unknown");
3183 line_attr = TERM_L_BLUE;
3185 else if (!((use_realm == p_ptr->realm1) ?
3186 (p_ptr->spell_worked1 & (1L << spell)) :
3187 (p_ptr->spell_worked2 & (1L << spell))))
3189 comment = _("未経験", "untried");
3190 line_attr = TERM_L_GREEN;
3193 /* Dump the spell --(-- */
3194 if (use_realm == REALM_HISSATSU)
3196 strcat(out_val, format("%-25s %2d %4d",
3197 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3198 s_ptr->slevel, need_mana));
3202 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
3203 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3204 (max ? '!' : ' '), ryakuji,
3205 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
3207 c_prt(line_attr, out_val, y + i + 1, x);
3210 /* Clear the bottom line */
3211 prt("", y + i + 1, x);
3215 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
3216 * Helper function -- return a "nearby" race for polymorphing
3217 * @param r_idx 基準となるモンスター種族ID
3218 * @return 変更先のモンスター種族ID
3220 * Note that this function is one of the more "dangerous" ones...
3222 static MONRACE_IDX poly_r_idx(MONRACE_IDX r_idx)
3224 monster_race *r_ptr = &r_info[r_idx];
3230 /* Hack -- Uniques/Questors never polymorph */
3231 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
3234 /* Allowable range of "levels" for resulting monster */
3235 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
3236 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
3238 /* Pick a (possibly new) non-unique race */
3239 for (i = 0; i < 1000; i++)
3241 /* Pick a new race, using a level calculation */
3242 r = get_mon_num((current_floor_ptr->dun_level + r_ptr->level) / 2 + 5);
3244 /* Handle failure */
3250 /* Ignore unique monsters */
3251 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3253 /* Ignore monsters with incompatible levels */
3254 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
3256 /* Use that index */
3265 * @brief 指定座標にいるモンスターを変身させる /
3266 * Helper function -- return a "nearby" race for polymorphing
3269 * @return 実際に変身したらTRUEを返す
3271 bool polymorph_monster(POSITION y, POSITION x)
3273 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
3274 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3275 bool polymorphed = FALSE;
3276 MONRACE_IDX new_r_idx;
3277 MONRACE_IDX old_r_idx = m_ptr->r_idx;
3278 bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE;
3279 bool health_tracked = (p_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
3280 monster_type back_m;
3282 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
3284 if ((p_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
3286 /* Memorize the monster before polymorphing */
3289 /* Pick a "new" monster race */
3290 new_r_idx = poly_r_idx(old_r_idx);
3292 /* Handle polymorph */
3293 if (new_r_idx != old_r_idx)
3295 BIT_FLAGS mode = 0L;
3296 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
3297 OBJECT_IDX this_o_idx, next_o_idx = 0;
3299 /* Get the monsters attitude */
3300 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
3301 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
3302 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
3304 /* Mega-hack -- ignore held objects */
3305 m_ptr->hold_o_idx = 0;
3307 /* "Kill" the "old" monster */
3308 delete_monster_idx(g_ptr->m_idx);
3310 /* Create a new monster (no groups) */
3311 if (place_monster_aux(0, y, x, new_r_idx, mode))
3313 current_floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname;
3314 current_floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
3315 current_floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
3322 /* Placing the new monster failed */
3323 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
3325 current_floor_ptr->m_list[hack_m_idx_ii] = back_m;
3327 /* Re-initialize monster process */
3330 else preserve_hold_objects = FALSE;
3333 /* Mega-hack -- preserve held objects */
3334 if (preserve_hold_objects)
3336 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3338 object_type *o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
3339 next_o_idx = o_ptr->next_o_idx;
3341 /* Held by new monster */
3342 o_ptr->held_m_idx = hack_m_idx_ii;
3345 else if (back_m.hold_o_idx) /* Failed (paranoia) */
3347 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3349 next_o_idx = current_floor_ptr->o_list[this_o_idx].next_o_idx;
3350 delete_object_idx(this_o_idx);
3354 if (targeted) target_who = hack_m_idx_ii;
3355 if (health_tracked) health_track(hack_m_idx_ii);
3364 * @param x テレポート先のX座標
3365 * @param y テレポート先のY座標
3366 * @return 目標に指定通りテレポートできたならばTRUEを返す
3368 static bool dimension_door_aux(DEPTH x, DEPTH y)
3370 PLAYER_LEVEL plev = p_ptr->lev;
3372 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3374 if (!cave_player_teleportable_bold(y, x, 0L) ||
3375 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
3376 (!randint0(plev / 10 + 10)))
3378 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3379 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
3386 teleport_player_to(y, x, 0L);
3395 * @brief 次元の扉処理のメインルーチン /
3397 * @return ターンを消費した場合TRUEを返す
3399 bool dimension_door(void)
3403 /* Rerutn FALSE if cancelled */
3404 if (!tgt_pt(&x, &y)) return FALSE;
3406 if (dimension_door_aux(x, y)) return TRUE;
3408 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
3415 * @brief 鏡抜け処理のメインルーチン /
3416 * Mirror Master's Dimension Door
3417 * @return ターンを消費した場合TRUEを返す
3419 bool mirror_tunnel(void)
3421 POSITION x = 0, y = 0;
3423 /* Rerutn FALSE if cancelled */
3424 if (!tgt_pt(&x, &y)) return FALSE;
3426 if (dimension_door_aux(x, y)) return TRUE;
3428 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
3436 * @return ターンを消費した場合TRUEを返す
3438 bool eat_magic(int power)
3444 int recharge_strength = 0;
3450 GAME_TEXT o_name[MAX_NLEN];
3452 item_tester_hook = item_tester_hook_recharge;
3454 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
3455 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
3457 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
3458 if (!o_ptr) return FALSE;
3460 k_ptr = &k_info[o_ptr->k_idx];
3461 lev = k_info[o_ptr->k_idx].level;
3463 if (o_ptr->tval == TV_ROD)
3465 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3468 if (one_in_(recharge_strength))
3470 /* Activate the failure code. */
3475 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
3477 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
3482 o_ptr->timeout += k_ptr->pval;
3488 /* All staffs, wands. */
3489 recharge_strength = (100 + power - lev) / 15;
3490 if (recharge_strength < 0) recharge_strength = 0;
3493 if (one_in_(recharge_strength))
3495 /* Activate the failure code. */
3500 if (o_ptr->pval > 0)
3502 p_ptr->csp += lev / 2;
3505 /* XXX Hack -- unstack if necessary */
3506 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
3512 /* Obtain a local object */
3513 object_copy(q_ptr, o_ptr);
3515 /* Modify quantity */
3518 /* Restore the charges */
3521 /* Unstack the used item */
3523 p_ptr->total_weight -= q_ptr->weight;
3524 item = inven_carry(q_ptr);
3526 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
3531 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
3533 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
3537 /* Inflict the penalties for failing a recharge. */
3540 /* Artifacts are never destroyed. */
3541 if (object_is_fixed_artifact(o_ptr))
3543 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3544 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3546 /* Artifact rods. */
3547 if (o_ptr->tval == TV_ROD)
3548 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3550 /* Artifact wands and staffs. */
3551 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3556 /* Get the object description */
3557 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3559 /*** Determine Seriousness of Failure ***/
3561 /* Mages recharge objects more safely. */
3562 if (IS_WIZARD_CLASS())
3564 /* 10% chance to blow up one rod, otherwise draining. */
3565 if (o_ptr->tval == TV_ROD)
3567 if (one_in_(10)) fail_type = 2;
3570 /* 75% chance to blow up one wand, otherwise draining. */
3571 else if (o_ptr->tval == TV_WAND)
3573 if (!one_in_(3)) fail_type = 2;
3576 /* 50% chance to blow up one staff, otherwise no effect. */
3577 else if (o_ptr->tval == TV_STAFF)
3579 if (one_in_(2)) fail_type = 2;
3584 /* All other classes get no special favors. */
3587 /* 33% chance to blow up one rod, otherwise draining. */
3588 if (o_ptr->tval == TV_ROD)
3590 if (one_in_(3)) fail_type = 2;
3593 /* 20% chance of the entire stack, else destroy one wand. */
3594 else if (o_ptr->tval == TV_WAND)
3596 if (one_in_(5)) fail_type = 3;
3599 /* Blow up one staff. */
3600 else if (o_ptr->tval == TV_STAFF)
3606 /*** Apply draining and destruction. ***/
3608 /* Drain object or stack of objects. */
3611 if (o_ptr->tval == TV_ROD)
3613 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
3614 "You save your rod from destruction, but all charges are lost."), o_name);
3615 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3617 else if (o_ptr->tval == TV_WAND)
3619 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3622 /* Staffs aren't drained. */
3625 /* Destroy an object or one in a stack of objects. */
3628 if (o_ptr->number > 1)
3630 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3631 /* Reduce rod stack maximum timeout, drain wands. */
3632 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
3633 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
3637 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
3640 /* Reduce and describe inventory */
3643 inven_item_increase(item, -1);
3644 inven_item_describe(item);
3645 inven_item_optimize(item);
3648 /* Reduce and describe floor item */
3651 floor_item_increase(0 - item, -1);
3652 floor_item_describe(0 - item);
3653 floor_item_optimize(0 - item);
3657 /* Destroy all members of a stack of objects. */
3660 if (o_ptr->number > 1)
3661 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3663 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3665 /* Reduce and describe inventory */
3668 inven_item_increase(item, -999);
3669 inven_item_describe(item);
3670 inven_item_optimize(item);
3673 /* Reduce and describe floor item */
3676 floor_item_increase(0 - item, -999);
3677 floor_item_describe(0 - item);
3678 floor_item_optimize(0 - item);
3684 if (p_ptr->csp > p_ptr->msp)
3686 p_ptr->csp = p_ptr->msp;
3689 p_ptr->redraw |= (PR_MANA);
3690 p_ptr->update |= (PU_COMBINE | PU_REORDER);
3691 p_ptr->window |= (PW_INVEN);
3698 * @brief 皆殺し(全方向攻撃)処理
3699 * @param py プレイヤーY座標
3700 * @param px プレイヤーX座標
3707 monster_type *m_ptr;
3710 for (dir = 0; dir < 8; dir++)
3712 y = p_ptr->y + ddy_ddd[dir];
3713 x = p_ptr->x + ddx_ddd[dir];
3714 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3715 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3717 /* Hack -- attack monsters */
3718 if (g_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
3727 feature_type *f_ptr, *mimic_f_ptr;
3730 if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
3731 y = p_ptr->y + ddy[dir];
3732 x = p_ptr->x + ddx[dir];
3733 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3734 f_ptr = &f_info[g_ptr->feat];
3735 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
3739 if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
3741 msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
3743 else if (have_flag(f_ptr->flags, FF_PERMANENT))
3745 msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch! This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
3747 else if (g_ptr->m_idx)
3749 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3750 msg_print(_("何かが邪魔しています!", "There's something in the way!"));
3752 if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(y, x, 0);
3754 else if (have_flag(f_ptr->flags, FF_TREE))
3756 msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
3758 else if (have_flag(f_ptr->flags, FF_GLASS))
3760 msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
3762 else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
3764 (void)set_food(p_ptr->food + 3000);
3766 else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
3768 (void)set_food(p_ptr->food + 5000);
3772 msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
3773 (void)set_food(p_ptr->food + 10000);
3776 /* Destroy the wall */
3777 cave_alter_feat(y, x, FF_HURT_ROCK);
3779 (void)move_player_effect(y, x, MPE_DONT_PICKUP);
3784 bool shock_power(void)
3789 PLAYER_LEVEL plev = p_ptr->lev;
3790 int boost = P_PTR_KI;
3791 if (heavy_armor()) boost /= 2;
3794 if (!get_aim_dir(&dir)) return FALSE;
3796 y = p_ptr->y + ddy[dir];
3797 x = p_ptr->x + ddx[dir];
3798 dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
3799 fire_beam(GF_MISSILE, dir, dam);
3800 if (current_floor_ptr->grid_array[y][x].m_idx)
3803 POSITION ty = y, tx = x;
3804 POSITION oy = y, ox = x;
3805 MONSTER_IDX m_idx = current_floor_ptr->grid_array[y][x].m_idx;
3806 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3807 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3808 GAME_TEXT m_name[MAX_NLEN];
3810 monster_desc(m_name, m_ptr, 0);
3812 if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2)
3814 msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
3818 for (i = 0; i < 5; i++)
3822 if (cave_empty_bold(y, x))
3829 if ((ty != oy) || (tx != ox))
3831 msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
3832 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
3833 current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
3837 update_monster(m_idx, TRUE);
3841 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
3842 p_ptr->update |= (PU_MON_LITE);
3849 bool booze(player_type *creature_ptr)
3852 if (creature_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
3853 else if (!creature_ptr->resist_conf) creature_ptr->special_attack |= ATTACK_SUIKEN;
3854 if (!creature_ptr->resist_conf)
3856 if (set_confused(randint0(20) + 15))
3862 if (!creature_ptr->resist_chaos)
3866 if (set_image(creature_ptr->image + randint0(150) + 150))
3871 if (one_in_(13) && (creature_ptr->pclass != CLASS_MONK))
3874 if (one_in_(3)) lose_all_info();
3876 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
3878 msg_print(_("知らない場所で目が醒めた。頭痛がする。", "You wake up somewhere with a sore head..."));
3879 msg_print(_("何も思い出せない。どうやってここへ来たのかも分からない!", "You can't remember a thing, or how you got here!"));
3885 bool detonation(player_type *creature_ptr)
3887 msg_print(_("体の中で激しい爆発が起きた!", "Massive explosions rupture your body!"));
3888 take_hit(DAMAGE_NOESCAPE, damroll(50, 20), _("爆発の薬", "a potion of Detonation"), -1);
3889 (void)set_stun(creature_ptr->stun + 75);
3890 (void)set_cut(creature_ptr->cut + 5000);
3894 void blood_curse_to_enemy(MONSTER_IDX m_idx)
3896 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3897 grid_type *g_ptr = ¤t_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
3898 BIT_FLAGS curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
3902 switch (randint1(28))
3907 msg_print(_("地面が揺れた...", "The ground trembles..."));
3908 earthquake(m_ptr->fy, m_ptr->fx, 4 + randint0(4));
3909 if (!one_in_(6)) break;
3911 case 3: case 4: case 5: case 6:
3914 int extra_dam = damroll(10, 10);
3915 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
3917 project(0, 8, m_ptr->fy, m_ptr->fx, extra_dam, GF_MANA, curse_flg, -1);
3918 if (!one_in_(6)) break;
3923 msg_print(_("空間が歪んだ!", "Space warps about you!"));
3925 if (m_ptr->r_idx) teleport_away(g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
3926 if (one_in_(13)) count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3927 if (!one_in_(6)) break;
3929 case 9: case 10: case 11:
3930 msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
3931 project(0, 7, m_ptr->fy, m_ptr->fx, 50, GF_DISINTEGRATE, curse_flg, -1);
3932 if (!one_in_(6)) break;
3933 case 12: case 13: case 14: case 15: case 16:
3934 aggravate_monsters(0);
3935 if (!one_in_(6)) break;
3937 count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3938 if (!one_in_(6)) break;
3939 case 19: case 20: case 21: case 22:
3941 bool pet = !one_in_(3);
3942 BIT_FLAGS mode = PM_ALLOW_GROUP;
3944 if (pet) mode |= PM_FORCE_PET;
3945 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
3947 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');
3948 if (!one_in_(6)) break;
3950 case 23: case 24: case 25:
3951 if (p_ptr->hold_exp && (randint0(100) < 75)) break;
3952 msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
3954 if (p_ptr->hold_exp) lose_exp(p_ptr->exp / 160);
3955 else lose_exp(p_ptr->exp / 16);
3956 if (!one_in_(6)) break;
3957 case 26: case 27: case 28:
3966 (void)do_dec_stat(i);
3967 } while (one_in_(2));
3974 (void)do_dec_stat(randint0(6));
3979 } while (one_in_(5));
3983 bool fire_crimson(void)
3987 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3991 if (!get_aim_dir(&dir)) return FALSE;
3993 /* Use the given direction */
3994 tx = p_ptr->x + 99 * ddx[dir];
3995 ty = p_ptr->y + 99 * ddy[dir];
3997 /* Hack -- Use an actual "target" */
3998 if ((dir == 5) && target_okay())
4004 if (p_ptr->pclass == CLASS_ARCHER)
4006 /* Extra shot at level 10 */
4007 if (p_ptr->lev >= 10) num++;
4009 /* Extra shot at level 30 */
4010 if (p_ptr->lev >= 30) num++;
4012 /* Extra shot at level 45 */
4013 if (p_ptr->lev >= 45) num++;
4016 for (i = 0; i < num; i++)
4017 project(0, p_ptr->lev / 20 + 1, ty, tx, p_ptr->lev*p_ptr->lev * 6 / 50, GF_ROCKET, flg, -1);