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-status.h"
30 #include "monster-spell.h"
33 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
38 * @brief モンスターのテレポートアウェイ処理 /
39 * Teleport a monster, normally up to "dis" grids away.
40 * @param m_idx モンスターID
43 * @return テレポートが実際に行われたらtrue
45 * Attempt to move the monster at least "dis/2" grids away.
46 * But allow variation to prevent infinite loops.
48 bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
50 POSITION oy, ox, d, i, min;
52 POSITION ny = 0, nx = 0;
56 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
57 if (!monster_is_valid(m_ptr)) return (FALSE);
62 /* Minimum distance */
65 if ((mode & TELEPORT_DEC_VALOUR) &&
66 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
67 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
69 chg_virtue(V_VALOUR, -1);
77 /* Verify max distance */
78 if (dis > 200) dis = 200;
80 /* Try several locations */
81 for (i = 0; i < 500; i++)
83 /* Pick a (possibly illegal) location */
86 ny = rand_spread(oy, dis);
87 nx = rand_spread(ox, dis);
88 d = distance(oy, ox, ny, nx);
89 if ((d >= min) && (d <= dis)) break;
92 /* Ignore illegal locations */
93 if (!in_bounds(ny, nx)) continue;
95 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
97 /* No teleporting into vaults and such */
98 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
99 if (current_floor_ptr->grid_array[ny][nx].info & CAVE_ICKY) continue;
101 /* This grid looks good */
108 /* Increase the maximum distance */
111 /* Decrease the minimum distance */
114 /* Stop after MAX_TRIES tries */
115 if (tries > MAX_TRIES) return (FALSE);
118 sound(SOUND_TPOTHER);
120 /* Update the old location */
121 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
123 /* Update the new location */
124 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
126 /* Move the monster */
130 /* Forget the counter target */
133 update_monster(m_idx, TRUE);
137 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
138 p_ptr->update |= (PU_MON_LITE);
145 * @brief モンスターを指定された座標付近にテレポートする /
146 * Teleport monster next to a grid near the given location
147 * @param m_idx モンスターID
150 * @param power テレポート成功確率
154 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
156 POSITION ny, nx, oy, ox;
161 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
162 if(!m_ptr->r_idx) return;
165 if(randint1(100) > power) return;
172 /* Minimum distance */
175 /* Look until done */
176 while (look && --attempts)
178 /* Verify max distance */
179 if (dis > 200) dis = 200;
181 /* Try several locations */
182 for (i = 0; i < 500; i++)
184 /* Pick a (possibly illegal) location */
187 ny = rand_spread(ty, dis);
188 nx = rand_spread(tx, dis);
189 d = distance(ty, tx, ny, nx);
190 if ((d >= min) && (d <= dis)) break;
193 /* Ignore illegal locations */
194 if (!in_bounds(ny, nx)) continue;
196 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
198 /* No teleporting into vaults and such */
199 /* if (current_floor_ptr->grid_array[ny][nx].info & (CAVE_ICKY)) continue; */
201 /* This grid looks good */
208 /* Increase the maximum distance */
211 /* Decrease the minimum distance */
215 if (attempts < 1) return;
217 sound(SOUND_TPOTHER);
219 /* Update the old location */
220 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
222 /* Update the new location */
223 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
225 /* Move the monster */
229 update_monster(m_idx, TRUE);
233 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
234 p_ptr->update |= (PU_MON_LITE);
238 * @brief プレイヤーのテレポート先選定と移動処理 /
239 * Teleport the player to a location up to "dis" grids away.
242 * @return 実際にテレポート処理が行われたらtrue
245 * If no such spaces are readily available, the distance may increase.
246 * Try very hard to move the player at least a quarter that distance.
248 * There was a nasty tendency for a long time; which was causing the
249 * player to "bounce" between two or three different spots because
250 * these are the only spots that are "far enough" way to satisfy the
253 * But this tendency is now removed; in the new algorithm, a list of
254 * candidates is selected first, which includes at least 50% of all
255 * floor grids within the distance, and any single grid in this list
256 * of candidates has equal possibility to be choosen as a destination.
260 bool teleport_player_aux(POSITION dis, BIT_FLAGS mode)
262 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
263 int total_candidates, cur_candidates;
264 POSITION y = 0, x = 0;
267 int left = MAX(1, p_ptr->x - dis);
268 int right = MIN(current_floor_ptr->width - 2, p_ptr->x + dis);
269 int top = MAX(1, p_ptr->y - dis);
270 int bottom = MIN(current_floor_ptr->height - 2, p_ptr->y + dis);
272 if (p_ptr->wild_mode) return FALSE;
274 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
276 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
280 /* Initialize counters */
281 total_candidates = 0;
282 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
283 candidates_at[i] = 0;
285 /* Limit the distance */
286 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
288 /* Search valid locations */
289 for (y = top; y <= bottom; y++)
291 for (x = left; x <= right; x++)
295 /* Skip illegal locations */
296 if (!cave_player_teleportable_bold(y, x, mode)) continue;
298 /* Calculate distance */
299 d = distance(p_ptr->y, p_ptr->x, y, x);
301 /* Skip too far locations */
302 if (d > dis) continue;
304 /* Count the total number of candidates */
307 /* Count the number of candidates in this circumference */
312 /* No valid location! */
313 if (0 == total_candidates) return FALSE;
315 /* Fix the minimum distance */
316 for (cur_candidates = 0, min = dis; min >= 0; min--)
318 cur_candidates += candidates_at[min];
320 /* 50% of all candidates will have an equal chance to be choosen. */
321 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
324 /* Pick up a single location randomly */
325 pick = randint1(cur_candidates);
327 /* Search again the choosen location */
328 for (y = top; y <= bottom; y++)
330 for (x = left; x <= right; x++)
334 /* Skip illegal locations */
335 if (!cave_player_teleportable_bold(y, x, mode)) continue;
337 /* Calculate distance */
338 d = distance(p_ptr->y, p_ptr->x, y, x);
340 /* Skip too far locations */
341 if (d > dis) continue;
343 /* Skip too close locations */
344 if (d < min) continue;
346 /* This grid was picked up? */
355 if (player_bold(y, x)) return FALSE;
357 sound(SOUND_TELEPORT);
360 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
361 msg_format("『こっちだぁ、%s』", p_ptr->name);
364 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
369 * @brief プレイヤーのテレポート処理メインルーチン
374 void teleport_player(POSITION dis, BIT_FLAGS mode)
377 POSITION oy = p_ptr->y;
378 POSITION ox = p_ptr->x;
380 if (!teleport_player_aux(dis, mode)) return;
382 /* Monsters with teleport ability may follow the player */
383 for (xx = -1; xx < 2; xx++)
385 for (yy = -1; yy < 2; yy++)
387 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
389 /* A monster except your mount may follow */
390 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
392 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
393 monster_race *r_ptr = &r_info[m_ptr->r_idx];
396 * The latter limitation is to avoid
397 * totally unkillable suckers...
399 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
400 !(r_ptr->flagsr & RFR_RES_TELE))
402 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
411 * @brief プレイヤーのテレポートアウェイ処理 /
412 * @param m_idx アウェイを試みたプレイヤーID
416 void teleport_player_away(MONSTER_IDX m_idx, POSITION dis)
419 POSITION oy = p_ptr->y;
420 POSITION ox = p_ptr->x;
422 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
424 /* Monsters with teleport ability may follow the player */
425 for (xx = -1; xx < 2; xx++)
427 for (yy = -1; yy < 2; yy++)
429 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
431 /* A monster except your mount or caster may follow */
432 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
434 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
435 monster_race *r_ptr = &r_info[m_ptr->r_idx];
438 * The latter limitation is to avoid
439 * totally unkillable suckers...
441 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
442 !(r_ptr->flagsr & RFR_RES_TELE))
444 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
453 * @brief プレイヤーを指定位置近辺にテレポートさせる
454 * Teleport player to a grid near the given location
457 * @param mode オプションフラグ
461 * This function is slightly obsessive about correctness.
462 * This function allows teleporting into vaults (!)
465 void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
468 POSITION dis = 0, ctr = 0;
470 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
472 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
476 /* Find a usable location */
479 /* Pick a nearby legal location */
482 y = (POSITION)rand_spread(ny, dis);
483 x = (POSITION)rand_spread(nx, dis);
484 if (in_bounds(y, x)) break;
487 /* Accept any grid when wizard mode */
488 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;
490 /* Accept teleportable floor grids */
491 if (cave_player_teleportable_bold(y, x, mode)) break;
493 /* Occasionally advance the distance */
494 if (++ctr > (4 * dis * dis + 4 * dis + 1))
501 sound(SOUND_TELEPORT);
502 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
506 void teleport_away_followable(MONSTER_IDX m_idx)
508 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
509 POSITION oldfy = m_ptr->fy;
510 POSITION oldfx = m_ptr->fx;
511 bool old_ml = m_ptr->ml;
512 POSITION old_cdis = m_ptr->cdis;
514 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
516 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))
520 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
523 BIT_FLAGS flgs[TR_FLAG_SIZE];
527 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
529 o_ptr = &inventory[i];
530 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
532 object_flags(o_ptr, flgs);
533 if (have_flag(flgs, TR_TELEPORT))
544 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
548 teleport_player(200, TELEPORT_PASSIVE);
549 msg_print(_("失敗!", "Failed!"));
551 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
552 p_ptr->energy_need += ENERGY_NEED();
559 bool teleport_level_other(player_type *creature_ptr)
561 MONSTER_IDX target_m_idx;
564 GAME_TEXT m_name[MAX_NLEN];
566 if (!target_set(TARGET_KILL)) return FALSE;
567 target_m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
568 if (!target_m_idx) return TRUE;
569 if (!player_has_los_bold(target_row, target_col)) return TRUE;
570 if (!projectable(creature_ptr->y, creature_ptr->x, target_row, target_col)) return TRUE;
571 m_ptr = ¤t_floor_ptr->m_list[target_m_idx];
572 r_ptr = &r_info[m_ptr->r_idx];
573 monster_desc(m_name, m_ptr, 0);
574 msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
576 if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
577 (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > creature_ptr->lev + randint1(60)))
579 msg_format(_("しかし効果がなかった!", "%^s is unaffected!"), m_name);
581 else teleport_level(target_m_idx);
586 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
587 * Teleport the player one level up or down (random when legal)
588 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
591 void teleport_level(MONSTER_IDX m_idx)
594 GAME_TEXT m_name[160];
597 if (m_idx <= 0) /* To player */
599 strcpy(m_name, _("あなた", "you"));
601 else /* To monster */
603 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
605 /* Get the monster name (or "it") */
606 monster_desc(m_name, m_ptr, 0);
608 see_m = is_seen(m_ptr);
611 /* No effect in some case */
612 if (TELE_LEVEL_IS_INEFF(m_idx))
614 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
618 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
620 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
624 /* Choose up or down */
625 if (randint0(100) < 50) go_up = TRUE;
628 if ((m_idx <= 0) && p_ptr->wizard)
630 if (get_check("Force to go up? ")) go_up = TRUE;
631 else if (get_check("Force to go down? ")) go_up = FALSE;
635 if ((ironman_downward && (m_idx <= 0)) || (current_floor_ptr->dun_level <= d_info[p_ptr->dungeon_idx].mindepth))
638 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
640 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
642 if (m_idx <= 0) /* To player */
644 if (!current_floor_ptr->dun_level)
646 p_ptr->dungeon_idx = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
647 p_ptr->oldpy = p_ptr->y;
648 p_ptr->oldpx = p_ptr->x;
651 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
653 if (autosave_l) do_cmd_save_game(TRUE);
655 if (!current_floor_ptr->dun_level)
657 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].mindepth;
658 prepare_change_floor_mode(CFM_RAND_PLACE);
662 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
664 p_ptr->leaving = TRUE;
669 else if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth))
672 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
674 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
678 if (m_idx <= 0) /* To player */
680 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
682 if (autosave_l) do_cmd_save_game(TRUE);
684 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
687 p_ptr->inside_quest = 0;
688 p_ptr->leaving = TRUE;
694 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
696 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
700 if (m_idx <= 0) /* To player */
702 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
704 if (autosave_l) do_cmd_save_game(TRUE);
706 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
707 p_ptr->leaving = TRUE;
713 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
715 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
718 if (m_idx <= 0) /* To player */
720 /* Never reach this code on the surface */
721 /* if (!current_floor_ptr->dun_level) p_ptr->dungeon_idx = p_ptr->recall_dungeon; */
722 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
723 if (autosave_l) do_cmd_save_game(TRUE);
725 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
726 p_ptr->leaving = TRUE;
730 /* Monster level teleportation is simple deleting now */
733 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
735 check_quest_completion(m_ptr);
737 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
739 char m2_name[MAX_NLEN];
741 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
742 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
745 delete_monster_idx(m_idx);
748 sound(SOUND_TPLEVEL);
753 * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
754 * @param note ダンジョンに施す処理記述
757 * @return 選択されたダンジョンID
759 DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x)
761 DUNGEON_IDX select_dungeon;
766 /* Hack -- No need to choose dungeon in some case */
767 if (lite_town || vanilla_town || ironman_downward)
769 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
772 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
778 /* Allocate the "dun" array */
779 C_MAKE(dun, max_d_idx, DUNGEON_IDX);
782 for(i = 1; i < max_d_idx; i++)
787 if (!d_info[i].maxdepth) continue;
788 if (!max_dlv[i]) continue;
789 if (d_info[i].final_guardian)
791 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
793 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
795 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
796 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
797 prt(buf, y + num, x);
803 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
806 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
810 if ((i == ESCAPE) || !num)
812 /* Free the "dun" array */
813 C_KILL(dun, max_d_idx, DUNGEON_IDX);
818 if (i >= 'a' && i <('a'+num))
820 select_dungeon = dun[i-'a'];
827 /* Free the "dun" array */
828 C_KILL(dun, max_d_idx, DUNGEON_IDX);
830 return select_dungeon;
835 * @brief プレイヤーの帰還発動及び中止処理 /
836 * Recall the player to town or dungeon
837 * @param turns 発動までのターン数
840 bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
843 * TODO: Recall the player to the last
844 * visited town when in the wilderness
848 if (creature_ptr->inside_arena || ironman_downward)
850 msg_print(_("何も起こらなかった。", "Nothing happens."));
854 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)
856 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
858 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
860 do_cmd_write_nikki(NIKKI_TRUMP, p_ptr->dungeon_idx, _("帰還のときに", "when recall from dungeon"));
864 if (!creature_ptr->word_recall)
866 if (!current_floor_ptr->dun_level)
868 DUNGEON_IDX select_dungeon;
869 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
870 if (!select_dungeon) return FALSE;
871 creature_ptr->recall_dungeon = select_dungeon;
873 creature_ptr->word_recall = turns;
874 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
875 creature_ptr->redraw |= (PR_STATUS);
879 creature_ptr->word_recall = 0;
880 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
881 creature_ptr->redraw |= (PR_STATUS);
886 bool free_level_recall(player_type *creature_ptr)
888 DUNGEON_IDX select_dungeon;
892 select_dungeon = choose_dungeon(_("にテレポート", "teleport"), 4, 0);
894 if (!select_dungeon) return FALSE;
896 max_depth = d_info[select_dungeon].maxdepth;
898 /* Limit depth in Angband */
899 if (select_dungeon == DUNGEON_ANGBAND)
901 if (quest[QUEST_OBERON].status != QUEST_STATUS_FINISHED) max_depth = 98;
902 else if (quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
904 amt = get_quantity(format(_("%sの何階にテレポートしますか?", "Teleport to which level of %s? "),
905 d_name + d_info[select_dungeon].name), (QUANTITY)max_depth);
909 creature_ptr->word_recall = 1;
910 creature_ptr->recall_dungeon = select_dungeon;
911 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));
913 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("トランプタワーで", "at Trump Tower"));
915 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
917 creature_ptr->redraw |= (PR_STATUS);
926 * @return リセット処理が実際に行われたらTRUEを返す
928 bool reset_recall(void)
930 int select_dungeon, dummy = 0;
934 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
937 if (ironman_downward)
939 msg_print(_("何も起こらなかった。", "Nothing happens."));
943 if (!select_dungeon) return FALSE;
945 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
946 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
949 sprintf(tmp_val, "%d", (int)MAX(current_floor_ptr->dun_level, 1));
951 /* Ask for a level */
952 if (get_string(ppp, tmp_val, 10))
954 /* Extract request */
955 dummy = atoi(tmp_val);
956 if (dummy < 1) dummy = 1;
957 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
958 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
960 max_dlv[select_dungeon] = dummy;
963 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
966 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
968 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
981 * @brief プレイヤーの装備劣化処理 /
982 * Apply disenchantment to the player's stuff
983 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
984 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
985 * Return "TRUE" if the player notices anything
987 bool apply_disenchant(BIT_FLAGS mode)
991 GAME_TEXT o_name[MAX_NLEN];
992 int to_h, to_d, to_a, pval;
994 /* Pick a random slot */
997 case 1: t = INVEN_RARM; break;
998 case 2: t = INVEN_LARM; break;
999 case 3: t = INVEN_BOW; break;
1000 case 4: t = INVEN_BODY; break;
1001 case 5: t = INVEN_OUTER; break;
1002 case 6: t = INVEN_HEAD; break;
1003 case 7: t = INVEN_HANDS; break;
1004 case 8: t = INVEN_FEET; break;
1007 o_ptr = &inventory[t];
1009 /* No item, nothing happens */
1010 if (!o_ptr->k_idx) return (FALSE);
1012 /* Disenchant equipments only -- No disenchant on monster ball */
1013 if (!object_is_weapon_armour_ammo(o_ptr))
1016 /* Nothing to disenchant */
1017 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1019 /* Nothing to notice */
1023 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1025 /* Artifacts have 71% chance to resist */
1026 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1029 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1031 msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t),
1032 ((o_ptr->number != 1) ? "" : "s"));
1038 /* Memorize old value */
1044 /* Disenchant tohit */
1045 if (o_ptr->to_h > 0) o_ptr->to_h--;
1046 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1048 /* Disenchant todam */
1049 if (o_ptr->to_d > 0) o_ptr->to_d--;
1050 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1052 /* Disenchant toac */
1053 if (o_ptr->to_a > 0) o_ptr->to_a--;
1054 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1056 /* Disenchant pval (occasionally) */
1057 /* Unless called from wild_magic() */
1058 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1060 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1061 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1064 msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t) );
1066 msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t),
1067 ((o_ptr->number != 1) ? "were" : "was"));
1070 chg_virtue(V_HARMONY, 1);
1071 chg_virtue(V_ENCHANT, -2);
1072 p_ptr->update |= (PU_BONUS);
1073 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1083 * @brief 武器へのエゴ付加処理 /
1084 * Brand the current weapon
1085 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1088 void brand_weapon(int brand_type)
1094 /* Assume enchant weapon */
1095 item_tester_hook = object_allow_enchant_melee_weapon;
1097 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1098 s = _("強化できる武器がない。", "You have nothing to enchant.");
1100 o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
1103 /* you can never modify artifacts / ego-items */
1104 /* you can never modify cursed items */
1105 /* TY: You _can_ modify broken items (if you're silly enough) */
1106 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1107 !object_is_cursed(o_ptr) &&
1108 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1109 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1110 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1114 /* Let's get the name before it is changed... */
1115 GAME_TEXT o_name[MAX_NLEN];
1116 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1121 if (o_ptr->tval == TV_SWORD)
1123 act = _("は鋭さを増した!", "becomes very sharp!");
1125 o_ptr->name2 = EGO_SHARPNESS;
1126 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, current_floor_ptr->dun_level) + 1;
1128 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1133 act = _("は破壊力を増した!", "seems very powerful.");
1134 o_ptr->name2 = EGO_EARTHQUAKES;
1135 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, current_floor_ptr->dun_level);
1139 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1140 o_ptr->name2 = EGO_KILL_HUMAN;
1143 act = _("は電撃に覆われた!", "covered with lightning!");
1144 o_ptr->name2 = EGO_BRAND_ELEC;
1147 act = _("は酸に覆われた!", "coated with acid!");
1148 o_ptr->name2 = EGO_BRAND_ACID;
1151 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1152 o_ptr->name2 = EGO_KILL_EVIL;
1155 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1156 o_ptr->name2 = EGO_KILL_DEMON;
1159 act = _("は屍を求めている!", "seems to be looking for undead!");
1160 o_ptr->name2 = EGO_KILL_UNDEAD;
1163 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1164 o_ptr->name2 = EGO_KILL_ANIMAL;
1167 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1168 o_ptr->name2 = EGO_KILL_DRAGON;
1171 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1172 o_ptr->name2 = EGO_KILL_TROLL;
1175 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1176 o_ptr->name2 = EGO_KILL_ORC;
1179 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1180 o_ptr->name2 = EGO_KILL_GIANT;
1183 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1184 o_ptr->name2 = EGO_TRUMP;
1185 o_ptr->pval = randint1(2);
1188 act = _("は血を求めている!", "thirsts for blood!");
1189 o_ptr->name2 = EGO_VAMPIRIC;
1192 act = _("は毒に覆われた。", "is coated with poison.");
1193 o_ptr->name2 = EGO_BRAND_POIS;
1196 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1197 o_ptr->name2 = EGO_CHAOTIC;
1200 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1201 o_ptr->name2 = EGO_BRAND_FIRE;
1204 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1205 o_ptr->name2 = EGO_BRAND_COLD;
1209 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1210 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1212 o_ptr->discount = 99;
1213 chg_virtue(V_ENCHANT, 2);
1217 if (flush_failure) flush();
1219 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1220 chg_virtue(V_ENCHANT, -2);
1227 * @brief 虚無招来によるフロア中の全壁除去処理 /
1228 * Vanish all walls in this floor
1229 * @return 実際に処理が反映された場合TRUE
1231 static bool vanish_dungeon(void)
1235 feature_type *f_ptr;
1236 monster_type *m_ptr;
1237 GAME_TEXT m_name[MAX_NLEN];
1239 /* Prevent vasishing of quest levels and town */
1240 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1245 /* Scan all normal grids */
1246 for (y = 1; y < current_floor_ptr->height - 1; y++)
1248 for (x = 1; x < current_floor_ptr->width - 1; x++)
1250 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1252 /* Seeing true feature code (ignore mimic) */
1253 f_ptr = &f_info[g_ptr->feat];
1255 /* Lose room and vault */
1256 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1258 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
1261 if (g_ptr->m_idx && MON_CSLEEP(m_ptr))
1263 (void)set_monster_csleep(g_ptr->m_idx, 0);
1265 /* Notice the "waking up" */
1268 monster_desc(m_name, m_ptr, 0);
1269 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1273 /* Process all walls, doors and patterns */
1274 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1278 /* Special boundary walls -- Top and bottom */
1279 for (x = 0; x < current_floor_ptr->width; x++)
1281 g_ptr = ¤t_floor_ptr->grid_array[0][x];
1282 f_ptr = &f_info[g_ptr->mimic];
1284 /* Lose room and vault */
1285 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1287 /* Set boundary mimic if needed */
1288 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1290 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1292 /* Check for change to boring grid */
1293 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1296 g_ptr = ¤t_floor_ptr->grid_array[current_floor_ptr->height - 1][x];
1297 f_ptr = &f_info[g_ptr->mimic];
1299 /* Lose room and vault */
1300 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1302 /* Set boundary mimic if needed */
1303 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1305 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1307 /* Check for change to boring grid */
1308 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1312 /* Special boundary walls -- Left and right */
1313 for (y = 1; y < (current_floor_ptr->height - 1); y++)
1315 g_ptr = ¤t_floor_ptr->grid_array[y][0];
1316 f_ptr = &f_info[g_ptr->mimic];
1318 /* Lose room and vault */
1319 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1321 /* Set boundary mimic if needed */
1322 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1324 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1326 /* Check for change to boring grid */
1327 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1330 g_ptr = ¤t_floor_ptr->grid_array[y][current_floor_ptr->width - 1];
1331 f_ptr = &f_info[g_ptr->mimic];
1333 /* Lose room and vault */
1334 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1336 /* Set boundary mimic if needed */
1337 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1339 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1341 /* Check for change to boring grid */
1342 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1346 /* Mega-Hack -- Forget the view and lite */
1347 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1348 p_ptr->redraw |= (PR_MAP);
1349 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1358 void call_the_(void)
1362 bool do_call = TRUE;
1364 for (i = 0; i < 9; i++)
1366 g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1368 if (!cave_have_flag_grid(g_ptr, FF_PROJECT))
1370 if (!g_ptr->mimic || !have_flag(f_info[g_ptr->mimic].flags, FF_PROJECT) ||
1371 !permanent_wall(&f_info[g_ptr->feat]))
1381 for (i = 1; i < 10; i++)
1383 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1386 for (i = 1; i < 10; i++)
1388 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1391 for (i = 1; i < 10; i++)
1393 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1397 /* Prevent destruction of quest levels and town */
1398 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1400 msg_print(_("地面が揺れた。", "The ground trembles."));
1406 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1407 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1409 msg_format("You %s the %s too close to a wall!",
1410 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1411 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1413 msg_print(_("大きな爆発音があった!", "There is a loud explosion!"));
1417 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1421 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1422 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1424 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1427 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1433 * @brief アイテム引き寄せ処理 /
1434 * Fetch an item (teleport it right underneath the caster)
1435 * @param dir 魔法の発動方向
1437 * @param require_los 射線の通りを要求するならばTRUE
1440 void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
1446 GAME_TEXT o_name[MAX_NLEN];
1448 /* Check to see if an object is already there */
1449 if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx)
1451 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1456 if (dir == 5 && target_okay())
1461 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1463 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1467 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1469 /* We need an item to fetch */
1472 msg_print(_("そこには何もありません。", "There is no object at this place."));
1476 /* No fetching from vault */
1477 if (g_ptr->info & CAVE_ICKY)
1479 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1483 /* We need to see the item */
1486 if (!player_has_los_bold(ty, tx))
1488 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1491 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1493 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1506 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1508 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1509 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1511 while (!g_ptr->o_idx);
1514 o_ptr = ¤t_floor_ptr->o_list[g_ptr->o_idx];
1516 if (o_ptr->weight > wgt)
1518 /* Too heavy to 'fetch' */
1519 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1524 g_ptr->o_idx = o_ptr->next_o_idx;
1525 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1527 o_ptr->next_o_idx = 0;
1528 o_ptr->iy = p_ptr->y;
1529 o_ptr->ix = p_ptr->x;
1531 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1532 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1534 note_spot(p_ptr->y, p_ptr->x);
1535 p_ptr->redraw |= PR_MAP;
1542 void alter_reality(void)
1544 /* Ironman option */
1545 if (p_ptr->inside_arena || ironman_downward)
1547 msg_print(_("何も起こらなかった。", "Nothing happens."));
1551 if (!p_ptr->alter_reality)
1553 TIME_EFFECT turns = randint0(21) + 15;
1555 p_ptr->alter_reality = turns;
1556 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1558 p_ptr->redraw |= (PR_STATUS);
1562 p_ptr->alter_reality = 0;
1563 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1564 p_ptr->redraw |= (PR_STATUS);
1570 * @brief 全所持アイテム鑑定処理 /
1571 * Identify everything being carried.
1572 * Done by a potion of "self knowledge".
1575 void identify_pack(void)
1579 /* Simply identify and know every item */
1580 for (i = 0; i < INVEN_TOTAL; i++)
1582 object_type *o_ptr = &inventory[i];
1584 /* Skip non-objects */
1585 if (!o_ptr->k_idx) continue;
1587 identify_item(o_ptr);
1589 /* Auto-inscription */
1590 autopick_alter_item(i, FALSE);
1596 * @brief 装備強化処理の失敗率定数(千分率) /
1597 * Used by the "enchant" function (chance of failure)
1598 * (modified for Zangband, we need better stuff there...) -- TY
1601 static int enchant_table[16] =
1603 0, 10, 50, 100, 200,
1604 300, 400, 500, 650, 800,
1605 950, 987, 993, 995, 998,
1612 * Removes curses from items in inventory
1613 * @param all 軽い呪いまでの解除ならば0
1614 * @return 解呪されたアイテムの数
1617 * Note that Items which are "Perma-Cursed" (The One Ring,
1618 * The Crown of Morgoth) can NEVER be uncursed.
1620 * Note that if "all" is FALSE, then Items which are
1621 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1622 * will not be uncursed.
1625 static int remove_curse_aux(int all)
1629 /* Attempt to uncurse items being worn */
1630 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1632 object_type *o_ptr = &inventory[i];
1634 /* Skip non-objects */
1635 if (!o_ptr->k_idx) continue;
1637 /* Uncursed already */
1638 if (!object_is_cursed(o_ptr)) continue;
1640 /* Heavily Cursed Items need a special spell */
1641 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1643 /* Perma-Cursed Items can NEVER be uncursed */
1644 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1646 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1650 o_ptr->curse_flags = 0L;
1651 o_ptr->ident |= (IDENT_SENSE);
1652 o_ptr->feeling = FEEL_NONE;
1654 p_ptr->update |= (PU_BONUS);
1655 p_ptr->window |= (PW_EQUIP);
1657 /* Count the uncursings */
1663 msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
1665 /* Return "something uncursed" */
1671 * @brief 装備の軽い呪い解呪処理 /
1672 * Remove most curses
1673 * @return 解呪に成功した装備数
1675 int remove_curse(void)
1677 return (remove_curse_aux(FALSE));
1681 * @brief 装備の重い呪い解呪処理 /
1683 * @return 解呪に成功した装備数
1685 int remove_all_curse(void)
1687 return (remove_curse_aux(TRUE));
1692 * @brief アイテムの価値に応じた錬金術処理 /
1693 * Turns an object into gold, gain some of its value in a shop
1694 * @return 処理が実際に行われたらTRUEを返す
1700 ITEM_NUMBER old_number;
1704 GAME_TEXT o_name[MAX_NLEN];
1705 char out_val[MAX_NLEN+40];
1709 /* Hack -- force destruction */
1710 if (command_arg > 0) force = TRUE;
1712 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
1713 s = _("金に変えられる物がありません。", "You have nothing to current_world_ptr->game_turn to gold.");
1715 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1716 if (!o_ptr) return (FALSE);
1718 /* See how many items */
1719 if (o_ptr->number > 1)
1721 amt = get_quantity(NULL, o_ptr->number);
1723 /* Allow user abort */
1724 if (amt <= 0) return FALSE;
1727 old_number = o_ptr->number;
1728 o_ptr->number = amt;
1729 object_desc(o_name, o_ptr, 0);
1730 o_ptr->number = old_number;
1732 /* Verify unless quantity given */
1735 if (confirm_destroy || (object_value(o_ptr) > 0))
1737 /* Make a verification */
1738 sprintf(out_val, _("本当に%sを金に変えますか?", "Really current_world_ptr->game_turn %s to gold? "), o_name);
1739 if (!get_check(out_val)) return FALSE;
1743 /* Artifacts cannot be destroyed */
1744 if (!can_player_destroy_object(o_ptr))
1746 msg_format(_("%sを金に変えることに失敗した。", "You fail to current_world_ptr->game_turn %s to gold!"), o_name);
1751 price = object_value_real(o_ptr);
1755 msg_format(_("%sをニセの金に変えた。", "You current_world_ptr->game_turn %s to fool's gold."), o_name);
1761 if (amt > 1) price *= amt;
1763 if (price > 30000) price = 30000;
1764 msg_format(_("%sを$%d の金に変えた。", "You current_world_ptr->game_turn %s to %ld coins worth of gold."), o_name, price);
1767 p_ptr->redraw |= (PR_GOLD);
1768 p_ptr->window |= (PW_PLAYER);
1771 /* Eliminate the item (from the pack) */
1774 inven_item_increase(item, -amt);
1775 inven_item_describe(item);
1776 inven_item_optimize(item);
1779 /* Eliminate the item (from the floor) */
1782 floor_item_increase(0 - item, -amt);
1783 floor_item_describe(0 - item);
1784 floor_item_optimize(0 - item);
1792 * @brief 呪いの打ち破り処理 /
1793 * Break the curse of an item
1794 * @param o_ptr 呪い装備情報の参照ポインタ
1797 static void break_curse(object_type *o_ptr)
1799 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
1801 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
1803 o_ptr->curse_flags = 0L;
1804 o_ptr->ident |= (IDENT_SENSE);
1805 o_ptr->feeling = FEEL_NONE;
1812 * Enchants a plus onto an item. -RAK-
1813 * @param o_ptr 強化するアイテムの参照ポインタ
1815 * @param eflag 強化オプション(命中/ダメージ/AC)
1816 * @return 強化に成功した場合TRUEを返す
1819 * Revamped! Now takes item pointer, number of times to try enchanting,
1820 * and a flag of what to try enchanting. Artifacts resist enchantment
1821 * some of the time, and successful enchantment to at least +0 might
1822 * break a curse on the item. -CFT-
1824 * Note that an item can technically be enchanted all the way to +15 if
1825 * you wait a very, very, long time. Going from +9 to +10 only works
1826 * about 5% of the time, and from +10 to +11 only about 1% of the time.
1828 * Note that this function can now be used on "piles" of items, and
1829 * the larger the pile, the lower the chance of success.
1832 bool enchant(object_type *o_ptr, int n, int eflag)
1834 int i, chance, prob;
1836 bool a = object_is_artifact(o_ptr);
1837 bool force = (eflag & ENCH_FORCE);
1839 /* Large piles resist enchantment */
1840 prob = o_ptr->number * 100;
1842 /* Missiles are easy to enchant */
1843 if ((o_ptr->tval == TV_BOLT) ||
1844 (o_ptr->tval == TV_ARROW) ||
1845 (o_ptr->tval == TV_SHOT))
1851 for (i = 0; i < n; i++)
1853 /* Hack -- Roll for pile resistance */
1854 if (!force && randint0(prob) >= 100) continue;
1856 /* Enchant to hit */
1857 if (eflag & ENCH_TOHIT)
1859 if (o_ptr->to_h < 0) chance = 0;
1860 else if (o_ptr->to_h > 15) chance = 1000;
1861 else chance = enchant_table[o_ptr->to_h];
1863 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1868 /* only when you get it above -1 -CFT */
1869 if (o_ptr->to_h >= 0)
1874 /* Enchant to damage */
1875 if (eflag & ENCH_TODAM)
1877 if (o_ptr->to_d < 0) chance = 0;
1878 else if (o_ptr->to_d > 15) chance = 1000;
1879 else chance = enchant_table[o_ptr->to_d];
1881 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1886 /* only when you get it above -1 -CFT */
1887 if (o_ptr->to_d >= 0)
1892 /* Enchant to armor class */
1893 if (eflag & ENCH_TOAC)
1895 if (o_ptr->to_a < 0) chance = 0;
1896 else if (o_ptr->to_a > 15) chance = 1000;
1897 else chance = enchant_table[o_ptr->to_a];
1899 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
1904 /* only when you get it above -1 -CFT */
1905 if (o_ptr->to_a >= 0)
1912 if (!res) return (FALSE);
1913 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
1914 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1924 * @brief 装備修正強化処理のメインルーチン /
1925 * Enchant an item (in the inventory or on the floor)
1926 * @param num_hit 命中修正量
1927 * @param num_dam ダメージ修正量
1928 * @param num_ac AC修正量
1929 * @return 強化に成功した場合TRUEを返す
1931 * Note that "num_ac" requires armour, else weapon
1932 * Returns TRUE if attempted, FALSE if cancelled
1934 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
1939 GAME_TEXT o_name[MAX_NLEN];
1942 /* Assume enchant weapon */
1943 item_tester_hook = object_allow_enchant_weapon;
1945 /* Enchant armor if requested */
1946 if (num_ac) item_tester_hook = object_is_armour;
1948 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
1949 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
1951 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1952 if (!o_ptr) return (FALSE);
1954 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1956 msg_format("%s は明るく輝いた!", o_name);
1958 msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1962 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
1963 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
1964 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
1969 if (flush_failure) flush();
1970 msg_print(_("強化に失敗した。", "The enchantment failed."));
1971 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
1974 chg_virtue(V_ENCHANT, 1);
1978 /* Something happened */
1984 * @brief アーティファクト生成の巻物処理 /
1985 * @return 生成が実際に試みられたらTRUEを返す
1987 bool artifact_scroll(void)
1992 GAME_TEXT o_name[MAX_NLEN];
1995 /* Enchant weapon/armour */
1996 item_tester_hook = item_tester_hook_nameless_weapon_armour;
1998 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
1999 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2001 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2002 if (!o_ptr) return (FALSE);
2004 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2006 msg_format("%s は眩い光を発した!",o_name);
2008 msg_format("%s %s radiate%s a blinding light!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
2011 if (object_is_artifact(o_ptr))
2014 msg_format("%sは既に伝説のアイテムです!", o_name );
2016 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2022 else if (object_is_ego(o_ptr))
2025 msg_format("%sは既に名のあるアイテムです!", o_name );
2027 msg_format("The %s %s already %s!",
2028 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2029 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2035 else if (o_ptr->xtra3)
2038 msg_format("%sは既に強化されています!", o_name );
2040 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"),
2041 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2047 if (o_ptr->number > 1)
2049 msg_print(_("複数のアイテムに魔法をかけるだけのエネルギーはありません!", "Not enough energy to enchant more than one object!"));
2051 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2053 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2058 inven_item_increase(item, 1 - (o_ptr->number));
2062 floor_item_increase(0 - item, 1 - (o_ptr->number));
2065 okay = create_artifact(o_ptr, TRUE);
2071 if (flush_failure) flush();
2072 msg_print(_("強化に失敗した。", "The enchantment failed."));
2073 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2077 if (record_rand_art)
2079 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2080 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2082 chg_virtue(V_ENCHANT, 1);
2087 /* Something happened */
2094 * Identify an object
2095 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2096 * @return 実際に鑑定できたらTRUEを返す
2098 bool identify_item(object_type *o_ptr)
2100 bool old_known = FALSE;
2101 GAME_TEXT o_name[MAX_NLEN];
2103 object_desc(o_name, o_ptr, 0);
2105 if (o_ptr->ident & IDENT_KNOWN)
2108 if (!(o_ptr->ident & (IDENT_MENTAL)))
2110 if (object_is_artifact(o_ptr) || one_in_(5))
2111 chg_virtue(V_KNOWLEDGE, 1);
2114 object_aware(o_ptr);
2115 object_known(o_ptr);
2116 o_ptr->marked |= OM_TOUCHED;
2118 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
2119 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2121 strcpy(record_o_name, o_name);
2122 record_turn = current_world_ptr->game_turn;
2124 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2126 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2127 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2128 if(record_rand_art && !old_known && o_ptr->art_name)
2129 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2135 * @brief アイテム鑑定のメインルーチン処理 /
2136 * Identify an object in the inventory (or on the floor)
2137 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2138 * @return 実際に鑑定を行ったならばTRUEを返す
2140 * This routine does *not* automatically combine objects.
2141 * Returns TRUE if something was identified, else FALSE.
2143 bool ident_spell(bool only_equip)
2147 GAME_TEXT o_name[MAX_NLEN];
2152 item_tester_hook = item_tester_hook_identify_weapon_armour;
2154 item_tester_hook = item_tester_hook_identify;
2158 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2163 item_tester_hook = object_is_weapon_armour_ammo;
2165 item_tester_hook = NULL;
2167 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2170 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2172 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2173 if (!o_ptr) return (FALSE);
2175 old_known = identify_item(o_ptr);
2177 object_desc(o_name, o_ptr, 0);
2178 if (item >= INVEN_RARM)
2180 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2184 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2188 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2191 /* Auto-inscription/destroy */
2192 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2194 /* Something happened */
2200 * @brief アイテム凡庸化のメインルーチン処理 /
2201 * Identify an object in the inventory (or on the floor)
2202 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2203 * @return 実際に凡庸化をを行ったならばTRUEを返す
2206 * Mundanify an object in the inventory (or on the floor)
2207 * This routine does *not* automatically combine objects.
2208 * Returns TRUE if something was mundanified, else FALSE.
2211 bool mundane_spell(bool only_equip)
2217 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2219 q = _("どれを使いますか?", "Use which item? ");
2220 s = _("使えるものがありません。", "You have nothing you can use.");
2222 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2223 if (!o_ptr) return (FALSE);
2225 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2227 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2228 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2229 OBJECT_IDX next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2230 byte marked = o_ptr->marked; /* Object is marked */
2231 WEIGHT weight = o_ptr->number * o_ptr->weight;
2232 u16b inscription = o_ptr->inscription;
2235 object_prep(o_ptr, o_ptr->k_idx);
2239 o_ptr->next_o_idx = next_o_idx;
2240 o_ptr->marked = marked;
2241 o_ptr->inscription = inscription;
2242 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2246 /* Something happened */
2251 * @brief アイテム*鑑定*のメインルーチン処理 /
2252 * Identify an object in the inventory (or on the floor)
2253 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2254 * @return 実際に鑑定を行ったならばTRUEを返す
2256 * Fully "identify" an object in the inventory -BEN-
2257 * This routine returns TRUE if an item was identified.
2259 bool identify_fully(bool only_equip)
2263 GAME_TEXT o_name[MAX_NLEN];
2268 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2270 item_tester_hook = item_tester_hook_identify_fully;
2274 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2279 item_tester_hook = object_is_weapon_armour_ammo;
2281 item_tester_hook = NULL;
2283 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2286 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2288 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2289 if (!o_ptr) return (FALSE);
2291 old_known = identify_item(o_ptr);
2293 /* Mark the item as fully known */
2294 o_ptr->ident |= (IDENT_MENTAL);
2297 object_desc(o_name, o_ptr, 0);
2298 if (item >= INVEN_RARM)
2300 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2304 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2308 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2311 /* Describe it fully */
2312 (void)screen_object(o_ptr, 0L);
2314 /* Auto-inscription/destroy */
2315 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2325 * Recharge a wand/staff/rod from the pack or on the floor.
2326 * This function has been rewritten in Oangband and ZAngband.
2327 * @param power 充填パワー
2328 * @return ターン消費を要する処理まで進んだらTRUEを返す
2330 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2331 * Chaos -- Arcane Binding --> recharge(90)
2333 * Scroll of recharging --> recharge(130)
2334 * Artifact activation/Thingol --> recharge(130)
2336 * It is harder to recharge high level, and highly charged wands,
2337 * staffs, and rods. The more wands in a stack, the more easily and
2338 * strongly they recharge. Staffs, however, each get fewer charges if
2341 * Beware of "sliding index errors".
2343 bool recharge(int power)
2347 int recharge_strength;
2348 TIME_EFFECT recharge_amount;
2357 GAME_TEXT o_name[MAX_NLEN];
2359 /* Only accept legal items */
2360 item_tester_hook = item_tester_hook_recharge;
2362 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2363 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2365 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2366 if (!o_ptr) return (FALSE);
2368 /* Get the object kind. */
2369 k_ptr = &k_info[o_ptr->k_idx];
2371 /* Extract the object "level" */
2372 lev = k_info[o_ptr->k_idx].level;
2375 /* Recharge a rod */
2376 if (o_ptr->tval == TV_ROD)
2378 /* Extract a recharge strength by comparing object level to power. */
2379 recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
2383 if (one_in_(recharge_strength))
2385 /* Activate the failure code. */
2392 /* Recharge amount */
2393 recharge_amount = (power * damroll(3, 2));
2395 /* Recharge by that amount */
2396 if (o_ptr->timeout > recharge_amount)
2397 o_ptr->timeout -= recharge_amount;
2404 /* Recharge wand/staff */
2407 /* Extract a recharge strength by comparing object level to power.
2408 * Divide up a stack of wands' charges to calculate charge penalty.
2410 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2411 recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15;
2413 /* All staffs, unstacked wands. */
2414 else recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15;
2415 if (recharge_strength < 0) recharge_strength = 0;
2418 if (one_in_(recharge_strength))
2420 /* Activate the failure code. */
2424 /* If the spell didn't backfire, recharge the wand or staff. */
2427 /* Recharge based on the standard number of charges. */
2428 recharge_amount = randint1(1 + k_ptr->pval / 2);
2430 /* Multiple wands in a stack increase recharging somewhat. */
2431 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2434 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2435 if (recharge_amount < 1) recharge_amount = 1;
2436 if (recharge_amount > 12) recharge_amount = 12;
2439 /* But each staff in a stack gets fewer additional charges,
2440 * although always at least one.
2442 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2444 recharge_amount /= (TIME_EFFECT)o_ptr->number;
2445 if (recharge_amount < 1) recharge_amount = 1;
2448 /* Recharge the wand or staff. */
2449 o_ptr->pval += recharge_amount;
2452 /* Hack -- we no longer "know" the item */
2453 o_ptr->ident &= ~(IDENT_KNOWN);
2455 /* Hack -- we no longer think the item is empty */
2456 o_ptr->ident &= ~(IDENT_EMPTY);
2461 /* Inflict the penalties for failing a recharge. */
2464 /* Artifacts are never destroyed. */
2465 if (object_is_fixed_artifact(o_ptr))
2467 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2468 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2470 /* Artifact rods. */
2471 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2472 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2474 /* Artifact wands and staffs. */
2475 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2480 /* Get the object description */
2481 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2483 /*** Determine Seriousness of Failure ***/
2485 /* Mages recharge objects more safely. */
2486 if (IS_WIZARD_CLASS() || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
2488 /* 10% chance to blow up one rod, otherwise draining. */
2489 if (o_ptr->tval == TV_ROD)
2491 if (one_in_(10)) fail_type = 2;
2494 /* 75% chance to blow up one wand, otherwise draining. */
2495 else if (o_ptr->tval == TV_WAND)
2497 if (!one_in_(3)) fail_type = 2;
2500 /* 50% chance to blow up one staff, otherwise no effect. */
2501 else if (o_ptr->tval == TV_STAFF)
2503 if (one_in_(2)) fail_type = 2;
2508 /* All other classes get no special favors. */
2511 /* 33% chance to blow up one rod, otherwise draining. */
2512 if (o_ptr->tval == TV_ROD)
2514 if (one_in_(3)) fail_type = 2;
2517 /* 20% chance of the entire stack, else destroy one wand. */
2518 else if (o_ptr->tval == TV_WAND)
2520 if (one_in_(5)) fail_type = 3;
2523 /* Blow up one staff. */
2524 else if (o_ptr->tval == TV_STAFF)
2530 /*** Apply draining and destruction. ***/
2532 /* Drain object or stack of objects. */
2535 if (o_ptr->tval == TV_ROD)
2537 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
2539 if (o_ptr->timeout < 10000)
2540 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2542 else if (o_ptr->tval == TV_WAND)
2544 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
2547 /* Staffs aren't drained. */
2550 /* Destroy an object or one in a stack of objects. */
2553 if (o_ptr->number > 1)
2554 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
2556 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2558 /* Reduce rod stack maximum timeout, drain wands. */
2559 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
2560 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
2562 /* Reduce and describe inventory */
2565 inven_item_increase(item, -1);
2566 inven_item_describe(item);
2567 inven_item_optimize(item);
2570 /* Reduce and describe floor item */
2573 floor_item_increase(0 - item, -1);
2574 floor_item_describe(0 - item);
2575 floor_item_optimize(0 - item);
2579 /* Destroy all members of a stack of objects. */
2582 if (o_ptr->number > 1)
2583 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
2585 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2587 /* Reduce and describe inventory */
2590 inven_item_increase(item, -999);
2591 inven_item_describe(item);
2592 inven_item_optimize(item);
2595 /* Reduce and describe floor item */
2598 floor_item_increase(0 - item, -999);
2599 floor_item_describe(0 - item);
2600 floor_item_optimize(0 - item);
2605 p_ptr->update |= (PU_COMBINE | PU_REORDER);
2606 p_ptr->window |= (PW_INVEN);
2608 /* Something was done */
2614 * @brief プレイヤーの全既知呪文を表示する /
2615 * Hack -- Display all known spells in a window
2618 * Need to analyze size of the window.
2619 * Need more color coding.
2621 void display_spell_list(void)
2626 const magic_type *s_ptr;
2627 GAME_TEXT name[MAX_NLEN];
2632 /* They have too many spells to list */
2633 if (p_ptr->pclass == CLASS_SORCERER) return;
2634 if (p_ptr->pclass == CLASS_RED_MAGE) return;
2636 if (p_ptr->pclass == CLASS_SNIPER)
2638 display_snipe_list();
2642 /* mind.c type classes */
2643 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
2644 (p_ptr->pclass == CLASS_BERSERKER) ||
2645 (p_ptr->pclass == CLASS_NINJA) ||
2646 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
2647 (p_ptr->pclass == CLASS_FORCETRAINER))
2649 PERCENTAGE minfail = 0;
2650 PLAYER_LEVEL plev = p_ptr->lev;
2651 PERCENTAGE chance = 0;
2656 bool use_hp = FALSE;
2661 /* Display a list of spells */
2663 put_str(_("名前", "Name"), y, x + 5);
2664 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
2666 switch(p_ptr->pclass)
2668 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
2669 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
2670 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
2671 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
2672 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
2673 default: use_mind = 0;break;
2676 /* Dump the spells */
2677 for (i = 0; i < MAX_MIND_POWERS; i++)
2679 byte a = TERM_WHITE;
2681 /* Access the available spell */
2682 spell = mind_powers[use_mind].info[i];
2683 if (spell.min_lev > plev) break;
2685 /* Get the failure rate */
2686 chance = spell.fail;
2688 /* Reduce failure rate by "effective" level adjustment */
2689 chance -= 3 * (p_ptr->lev - spell.min_lev);
2691 /* Reduce failure rate by INT/WIS adjustment */
2692 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2696 /* Not enough mana to cast */
2697 if (spell.mana_cost > p_ptr->csp)
2699 chance += 5 * (spell.mana_cost - p_ptr->csp);
2705 /* Not enough hp to cast */
2706 if (spell.mana_cost > p_ptr->chp)
2713 /* Extract the minimum failure rate */
2714 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2716 /* Minimum failure rate */
2717 if (chance < minfail) chance = minfail;
2719 /* Stunning makes spells harder */
2720 if (p_ptr->stun > 50) chance += 25;
2721 else if (p_ptr->stun) chance += 15;
2723 /* Always a 5 percent chance of working */
2724 if (chance > 95) chance = 95;
2727 mindcraft_info(comment, use_mind, i);
2729 /* Dump the spell */
2730 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
2732 spell.min_lev, spell.mana_cost, chance, comment);
2734 Term_putstr(x, y + i + 1, -1, a, psi_desc);
2739 /* Cannot read spellbooks */
2740 if (REALM_NONE == p_ptr->realm1) return;
2742 /* Normal spellcaster with books */
2745 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
2749 /* Reset vertical */
2752 /* Vertical location */
2753 y = (j < 3) ? 0 : (m[j - 3] + 2);
2755 /* Horizontal location */
2759 for (i = 0; i < 32; i++)
2761 byte a = TERM_WHITE;
2763 /* Access the spell */
2764 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
2766 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
2770 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
2773 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
2776 if (s_ptr->slevel >= 99)
2779 strcpy(name, _("(判読不能)", "(illegible)"));
2787 ((p_ptr->spell_forgotten1 & (1L << i))) :
2788 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
2795 else if (!((j < 1) ?
2796 (p_ptr->spell_learned1 & (1L << i)) :
2797 (p_ptr->spell_learned2 & (1L << (i % 32)))))
2804 else if (!((j < 1) ?
2805 (p_ptr->spell_worked1 & (1L << i)) :
2806 (p_ptr->spell_worked2 & (1L << (i % 32)))))
2812 /* Dump the spell --(-- */
2813 sprintf(out_val, "%c/%c) %-20.20s",
2814 I2A(n / 8), I2A(n % 8), name);
2819 /* Dump onto the window */
2820 Term_putstr(x, m[j], -1, a, out_val);
2830 * @brief 呪文の経験値を返す /
2831 * Returns experience of a spell
2833 * @param use_realm 魔法領域
2836 EXP experience_of_spell(SPELL_IDX spell, REALM_IDX use_realm)
2838 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
2839 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
2840 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
2841 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
2847 * @brief 呪文の消費MPを返す /
2848 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
2849 * @param need_mana 基本消費MP
2854 MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm)
2856 #define MANA_CONST 2400
2858 #define DEC_MANA_DIV 3
2861 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
2864 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
2865 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
2867 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
2868 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
2869 need_mana /= MANA_CONST * MANA_DIV;
2870 if (need_mana < 1) need_mana = 1;
2873 /* Non-realm magic */
2876 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
2888 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
2889 * Modify spell fail rate
2890 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2891 * @param chance 修正前失敗率
2895 PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
2897 chance += p_ptr->to_m_chance;
2899 if (p_ptr->heavy_spell) chance += 20;
2901 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
2902 else if (p_ptr->easy_spell) chance -= 3;
2903 else if (p_ptr->dec_mana) chance -= 2;
2910 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
2911 * Modify spell fail rate
2912 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2913 * @param chance 修正前失敗率
2915 * Modify spell fail rate (as "suffix" process)
2916 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2917 * Note: variable "chance" cannot be negative.
2920 PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
2922 if (p_ptr->dec_mana) chance--;
2924 if (p_ptr->heavy_spell) chance += 5;
2926 return MAX(chance, 0);
2931 * @brief 呪文の失敗率計算メインルーチン /
2932 * Returns spell chance of failure for spell -RAK-
2934 * @param use_realm 魔法領域ID
2937 PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
2939 PERCENTAGE chance, minfail;
2940 const magic_type *s_ptr;
2941 MANA_POINT need_mana;
2942 PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
2945 /* Paranoia -- must be literate */
2946 if (!mp_ptr->spell_book) return (100);
2948 if (use_realm == REALM_HISSATSU) return 0;
2950 /* Access the spell */
2951 if (!is_magic(use_realm))
2953 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
2957 s_ptr = &mp_ptr->info[use_realm - 1][spell];
2960 /* Extract the base spell failure rate */
2961 chance = s_ptr->sfail;
2963 /* Reduce failure rate by "effective" level adjustment */
2964 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
2966 /* Reduce failure rate by INT/WIS adjustment */
2967 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2970 chance += (MAX(r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
2972 /* Extract mana consumption rate */
2973 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
2975 /* Not enough mana to cast */
2976 if (need_mana > p_ptr->csp)
2978 chance += 5 * (need_mana - p_ptr->csp);
2981 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
2983 /* Extract the minimum failure rate */
2984 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
2987 * Non mage/priest characters never get too good
2988 * (added high mage, mindcrafter)
2990 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
2992 if (minfail < 5) minfail = 5;
2995 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
2996 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
2997 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
2999 chance = mod_spell_chance_1(chance);
3001 /* Goodness or evilness gives a penalty to failure rate */
3005 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3007 case REALM_LIFE: case REALM_CRUSADE:
3008 if (p_ptr->align < -20) chance += penalty;
3010 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3011 if (p_ptr->align > 20) chance += penalty;
3015 /* Minimum failure rate */
3016 if (chance < minfail) chance = minfail;
3018 /* Stunning makes spells harder */
3019 if (p_ptr->stun > 50) chance += 25;
3020 else if (p_ptr->stun) chance += 15;
3022 /* Always a 5 percent chance of working */
3023 if (chance > 95) chance = 95;
3025 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3026 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3028 EXP exp = experience_of_spell(spell, use_realm);
3029 if (exp >= SPELL_EXP_EXPERT) chance--;
3030 if (exp >= SPELL_EXP_MASTER) chance--;
3033 /* Return the chance */
3034 return mod_spell_chance_2(chance);
3040 * @brief 呪文情報の表示処理 /
3041 * Print a list of spells (for browsing or casting or viewing)
3042 * @param target_spell 呪文ID
3043 * @param spells 表示するスペルID配列の参照ポインタ
3044 * @param num 表示するスペルの数(spellsの要素数)
3045 * @param y 表示メッセージ左上Y座標
3046 * @param x 表示メッセージ左上X座標
3047 * @param use_realm 魔法領域ID
3050 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm)
3054 int exp_level, increment = 64;
3055 const magic_type *s_ptr;
3060 MANA_POINT need_mana;
3065 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
3066 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
3068 /* Title the list */
3070 if (use_realm == REALM_HISSATSU)
3071 strcpy(buf,_(" Lv MP", " Lv SP"));
3073 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
3075 put_str(_("名前", "Name"), y, x + 5);
3076 put_str(buf, y, x + 29);
3078 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
3079 else if (use_realm == p_ptr->realm1) increment = 0;
3080 else if (use_realm == p_ptr->realm2) increment = 32;
3082 /* Dump the spells */
3083 for (i = 0; i < num; i++)
3087 if (!is_magic(use_realm))
3089 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3093 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3096 if (use_realm == REALM_HISSATSU)
3097 need_mana = s_ptr->smana;
3100 EXP exp = experience_of_spell(spell, use_realm);
3102 /* Extract mana consumption rate */
3103 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3105 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
3106 else exp_level = spell_exp_level(exp);
3109 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
3110 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
3111 else if (s_ptr->slevel >= 99) max = TRUE;
3112 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
3114 strncpy(ryakuji, exp_level_str[exp_level], 4);
3119 if (use_menu && target_spell)
3121 if (i == (target_spell-1))
3122 strcpy(out_val, _(" 》 ", " > "));
3124 strcpy(out_val, " ");
3126 else sprintf(out_val, " %c) ", I2A(i));
3127 /* Skip illegible spells */
3128 if (s_ptr->slevel >= 99)
3130 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
3131 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
3135 /* XXX XXX Could label spells above the players level */
3137 /* Get extra info */
3138 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
3143 /* Assume spell is known and tried */
3144 line_attr = TERM_WHITE;
3146 /* Analyze the spell */
3147 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3149 if (s_ptr->slevel > p_ptr->max_plv)
3151 comment = _("未知", "unknown");
3152 line_attr = TERM_L_BLUE;
3154 else if (s_ptr->slevel > p_ptr->lev)
3156 comment = _("忘却", "forgotten");
3157 line_attr = TERM_YELLOW;
3160 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
3162 comment = _("未知", "unknown");
3163 line_attr = TERM_L_BLUE;
3165 else if ((use_realm == p_ptr->realm1) ?
3166 ((p_ptr->spell_forgotten1 & (1L << spell))) :
3167 ((p_ptr->spell_forgotten2 & (1L << spell))))
3169 comment = _("忘却", "forgotten");
3170 line_attr = TERM_YELLOW;
3172 else if (!((use_realm == p_ptr->realm1) ?
3173 (p_ptr->spell_learned1 & (1L << spell)) :
3174 (p_ptr->spell_learned2 & (1L << spell))))
3176 comment = _("未知", "unknown");
3177 line_attr = TERM_L_BLUE;
3179 else if (!((use_realm == p_ptr->realm1) ?
3180 (p_ptr->spell_worked1 & (1L << spell)) :
3181 (p_ptr->spell_worked2 & (1L << spell))))
3183 comment = _("未経験", "untried");
3184 line_attr = TERM_L_GREEN;
3187 /* Dump the spell --(-- */
3188 if (use_realm == REALM_HISSATSU)
3190 strcat(out_val, format("%-25s %2d %4d",
3191 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3192 s_ptr->slevel, need_mana));
3196 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
3197 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3198 (max ? '!' : ' '), ryakuji,
3199 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
3201 c_prt(line_attr, out_val, y + i + 1, x);
3204 /* Clear the bottom line */
3205 prt("", y + i + 1, x);
3209 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
3210 * Helper function -- return a "nearby" race for polymorphing
3211 * @param r_idx 基準となるモンスター種族ID
3212 * @return 変更先のモンスター種族ID
3214 * Note that this function is one of the more "dangerous" ones...
3216 static MONRACE_IDX poly_r_idx(MONRACE_IDX r_idx)
3218 monster_race *r_ptr = &r_info[r_idx];
3224 /* Hack -- Uniques/Questors never polymorph */
3225 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
3228 /* Allowable range of "levels" for resulting monster */
3229 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
3230 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
3232 /* Pick a (possibly new) non-unique race */
3233 for (i = 0; i < 1000; i++)
3235 /* Pick a new race, using a level calculation */
3236 r = get_mon_num((current_floor_ptr->dun_level + r_ptr->level) / 2 + 5);
3238 /* Handle failure */
3244 /* Ignore unique monsters */
3245 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3247 /* Ignore monsters with incompatible levels */
3248 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
3250 /* Use that index */
3259 * @brief 指定座標にいるモンスターを変身させる /
3260 * Helper function -- return a "nearby" race for polymorphing
3263 * @return 実際に変身したらTRUEを返す
3265 bool polymorph_monster(POSITION y, POSITION x)
3267 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
3268 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3269 bool polymorphed = FALSE;
3270 MONRACE_IDX new_r_idx;
3271 MONRACE_IDX old_r_idx = m_ptr->r_idx;
3272 bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE;
3273 bool health_tracked = (p_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
3274 monster_type back_m;
3276 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
3278 if ((p_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
3280 /* Memorize the monster before polymorphing */
3283 /* Pick a "new" monster race */
3284 new_r_idx = poly_r_idx(old_r_idx);
3286 /* Handle polymorph */
3287 if (new_r_idx != old_r_idx)
3289 BIT_FLAGS mode = 0L;
3290 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
3291 OBJECT_IDX this_o_idx, next_o_idx = 0;
3293 /* Get the monsters attitude */
3294 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
3295 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
3296 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
3298 /* Mega-hack -- ignore held objects */
3299 m_ptr->hold_o_idx = 0;
3301 /* "Kill" the "old" monster */
3302 delete_monster_idx(g_ptr->m_idx);
3304 /* Create a new monster (no groups) */
3305 if (place_monster_aux(0, y, x, new_r_idx, mode))
3307 current_floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname;
3308 current_floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
3309 current_floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
3316 /* Placing the new monster failed */
3317 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
3319 current_floor_ptr->m_list[hack_m_idx_ii] = back_m;
3321 /* Re-initialize monster process */
3324 else preserve_hold_objects = FALSE;
3327 /* Mega-hack -- preserve held objects */
3328 if (preserve_hold_objects)
3330 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3332 object_type *o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
3333 next_o_idx = o_ptr->next_o_idx;
3335 /* Held by new monster */
3336 o_ptr->held_m_idx = hack_m_idx_ii;
3339 else if (back_m.hold_o_idx) /* Failed (paranoia) */
3341 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3343 next_o_idx = current_floor_ptr->o_list[this_o_idx].next_o_idx;
3344 delete_object_idx(this_o_idx);
3348 if (targeted) target_who = hack_m_idx_ii;
3349 if (health_tracked) health_track(hack_m_idx_ii);
3358 * @param x テレポート先のX座標
3359 * @param y テレポート先のY座標
3360 * @return 目標に指定通りテレポートできたならばTRUEを返す
3362 static bool dimension_door_aux(DEPTH x, DEPTH y)
3364 PLAYER_LEVEL plev = p_ptr->lev;
3366 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3368 if (!cave_player_teleportable_bold(y, x, 0L) ||
3369 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
3370 (!randint0(plev / 10 + 10)))
3372 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
3373 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
3380 teleport_player_to(y, x, 0L);
3389 * @brief 次元の扉処理のメインルーチン /
3391 * @return ターンを消費した場合TRUEを返す
3393 bool dimension_door(void)
3397 /* Rerutn FALSE if cancelled */
3398 if (!tgt_pt(&x, &y)) return FALSE;
3400 if (dimension_door_aux(x, y)) return TRUE;
3402 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
3409 * @brief 鏡抜け処理のメインルーチン /
3410 * Mirror Master's Dimension Door
3411 * @return ターンを消費した場合TRUEを返す
3413 bool mirror_tunnel(void)
3415 POSITION x = 0, y = 0;
3417 /* Rerutn FALSE if cancelled */
3418 if (!tgt_pt(&x, &y)) return FALSE;
3420 if (dimension_door_aux(x, y)) return TRUE;
3422 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
3430 * @return ターンを消費した場合TRUEを返す
3432 bool eat_magic(int power)
3438 int recharge_strength = 0;
3444 GAME_TEXT o_name[MAX_NLEN];
3446 item_tester_hook = item_tester_hook_recharge;
3448 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
3449 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
3451 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
3452 if (!o_ptr) return FALSE;
3454 k_ptr = &k_info[o_ptr->k_idx];
3455 lev = k_info[o_ptr->k_idx].level;
3457 if (o_ptr->tval == TV_ROD)
3459 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3462 if (one_in_(recharge_strength))
3464 /* Activate the failure code. */
3469 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
3471 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
3476 o_ptr->timeout += k_ptr->pval;
3482 /* All staffs, wands. */
3483 recharge_strength = (100 + power - lev) / 15;
3484 if (recharge_strength < 0) recharge_strength = 0;
3487 if (one_in_(recharge_strength))
3489 /* Activate the failure code. */
3494 if (o_ptr->pval > 0)
3496 p_ptr->csp += lev / 2;
3499 /* XXX Hack -- unstack if necessary */
3500 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
3506 /* Obtain a local object */
3507 object_copy(q_ptr, o_ptr);
3509 /* Modify quantity */
3512 /* Restore the charges */
3515 /* Unstack the used item */
3517 p_ptr->total_weight -= q_ptr->weight;
3518 item = inven_carry(q_ptr);
3520 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
3525 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
3527 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
3531 /* Inflict the penalties for failing a recharge. */
3534 /* Artifacts are never destroyed. */
3535 if (object_is_fixed_artifact(o_ptr))
3537 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3538 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3540 /* Artifact rods. */
3541 if (o_ptr->tval == TV_ROD)
3542 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3544 /* Artifact wands and staffs. */
3545 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3550 /* Get the object description */
3551 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3553 /*** Determine Seriousness of Failure ***/
3555 /* Mages recharge objects more safely. */
3556 if (IS_WIZARD_CLASS())
3558 /* 10% chance to blow up one rod, otherwise draining. */
3559 if (o_ptr->tval == TV_ROD)
3561 if (one_in_(10)) fail_type = 2;
3564 /* 75% chance to blow up one wand, otherwise draining. */
3565 else if (o_ptr->tval == TV_WAND)
3567 if (!one_in_(3)) fail_type = 2;
3570 /* 50% chance to blow up one staff, otherwise no effect. */
3571 else if (o_ptr->tval == TV_STAFF)
3573 if (one_in_(2)) fail_type = 2;
3578 /* All other classes get no special favors. */
3581 /* 33% chance to blow up one rod, otherwise draining. */
3582 if (o_ptr->tval == TV_ROD)
3584 if (one_in_(3)) fail_type = 2;
3587 /* 20% chance of the entire stack, else destroy one wand. */
3588 else if (o_ptr->tval == TV_WAND)
3590 if (one_in_(5)) fail_type = 3;
3593 /* Blow up one staff. */
3594 else if (o_ptr->tval == TV_STAFF)
3600 /*** Apply draining and destruction. ***/
3602 /* Drain object or stack of objects. */
3605 if (o_ptr->tval == TV_ROD)
3607 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
3608 "You save your rod from destruction, but all charges are lost."), o_name);
3609 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3611 else if (o_ptr->tval == TV_WAND)
3613 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3616 /* Staffs aren't drained. */
3619 /* Destroy an object or one in a stack of objects. */
3622 if (o_ptr->number > 1)
3624 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3625 /* Reduce rod stack maximum timeout, drain wands. */
3626 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
3627 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
3631 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
3634 /* Reduce and describe inventory */
3637 inven_item_increase(item, -1);
3638 inven_item_describe(item);
3639 inven_item_optimize(item);
3642 /* Reduce and describe floor item */
3645 floor_item_increase(0 - item, -1);
3646 floor_item_describe(0 - item);
3647 floor_item_optimize(0 - item);
3651 /* Destroy all members of a stack of objects. */
3654 if (o_ptr->number > 1)
3655 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3657 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3659 /* Reduce and describe inventory */
3662 inven_item_increase(item, -999);
3663 inven_item_describe(item);
3664 inven_item_optimize(item);
3667 /* Reduce and describe floor item */
3670 floor_item_increase(0 - item, -999);
3671 floor_item_describe(0 - item);
3672 floor_item_optimize(0 - item);
3678 if (p_ptr->csp > p_ptr->msp)
3680 p_ptr->csp = p_ptr->msp;
3683 p_ptr->redraw |= (PR_MANA);
3684 p_ptr->update |= (PU_COMBINE | PU_REORDER);
3685 p_ptr->window |= (PW_INVEN);
3692 * @brief 皆殺し(全方向攻撃)処理
3693 * @param py プレイヤーY座標
3694 * @param px プレイヤーX座標
3701 monster_type *m_ptr;
3704 for (dir = 0; dir < 8; dir++)
3706 y = p_ptr->y + ddy_ddd[dir];
3707 x = p_ptr->x + ddx_ddd[dir];
3708 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3709 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3711 /* Hack -- attack monsters */
3712 if (g_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
3721 feature_type *f_ptr, *mimic_f_ptr;
3724 if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
3725 y = p_ptr->y + ddy[dir];
3726 x = p_ptr->x + ddx[dir];
3727 g_ptr = ¤t_floor_ptr->grid_array[y][x];
3728 f_ptr = &f_info[g_ptr->feat];
3729 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
3733 if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
3735 msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
3737 else if (have_flag(f_ptr->flags, FF_PERMANENT))
3739 msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch! This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
3741 else if (g_ptr->m_idx)
3743 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3744 msg_print(_("何かが邪魔しています!", "There's something in the way!"));
3746 if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(y, x, 0);
3748 else if (have_flag(f_ptr->flags, FF_TREE))
3750 msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
3752 else if (have_flag(f_ptr->flags, FF_GLASS))
3754 msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
3756 else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
3758 (void)set_food(p_ptr->food + 3000);
3760 else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
3762 (void)set_food(p_ptr->food + 5000);
3766 msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
3767 (void)set_food(p_ptr->food + 10000);
3770 /* Destroy the wall */
3771 cave_alter_feat(y, x, FF_HURT_ROCK);
3773 (void)move_player_effect(y, x, MPE_DONT_PICKUP);
3778 bool shock_power(void)
3783 PLAYER_LEVEL plev = p_ptr->lev;
3784 int boost = P_PTR_KI;
3785 if (heavy_armor()) boost /= 2;
3788 if (!get_aim_dir(&dir)) return FALSE;
3790 y = p_ptr->y + ddy[dir];
3791 x = p_ptr->x + ddx[dir];
3792 dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
3793 fire_beam(GF_MISSILE, dir, dam);
3794 if (current_floor_ptr->grid_array[y][x].m_idx)
3797 POSITION ty = y, tx = x;
3798 POSITION oy = y, ox = x;
3799 MONSTER_IDX m_idx = current_floor_ptr->grid_array[y][x].m_idx;
3800 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3801 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3802 GAME_TEXT m_name[MAX_NLEN];
3804 monster_desc(m_name, m_ptr, 0);
3806 if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2)
3808 msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
3812 for (i = 0; i < 5; i++)
3816 if (cave_empty_bold(y, x))
3823 if ((ty != oy) || (tx != ox))
3825 msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
3826 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
3827 current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
3831 update_monster(m_idx, TRUE);
3835 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
3836 p_ptr->update |= (PU_MON_LITE);
3843 bool booze(player_type *creature_ptr)
3846 if (creature_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
3847 else if (!creature_ptr->resist_conf) creature_ptr->special_attack |= ATTACK_SUIKEN;
3848 if (!creature_ptr->resist_conf)
3850 if (set_confused(randint0(20) + 15))
3856 if (!creature_ptr->resist_chaos)
3860 if (set_image(creature_ptr->image + randint0(150) + 150))
3865 if (one_in_(13) && (creature_ptr->pclass != CLASS_MONK))
3868 if (one_in_(3)) lose_all_info();
3870 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
3872 msg_print(_("知らない場所で目が醒めた。頭痛がする。", "You wake up somewhere with a sore head..."));
3873 msg_print(_("何も思い出せない。どうやってここへ来たのかも分からない!", "You can't remember a thing, or how you got here!"));
3879 bool detonation(player_type *creature_ptr)
3881 msg_print(_("体の中で激しい爆発が起きた!", "Massive explosions rupture your body!"));
3882 take_hit(DAMAGE_NOESCAPE, damroll(50, 20), _("爆発の薬", "a potion of Detonation"), -1);
3883 (void)set_stun(creature_ptr->stun + 75);
3884 (void)set_cut(creature_ptr->cut + 5000);
3888 void blood_curse_to_enemy(MONSTER_IDX m_idx)
3890 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3891 grid_type *g_ptr = ¤t_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
3892 BIT_FLAGS curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
3896 switch (randint1(28))
3901 msg_print(_("地面が揺れた...", "The ground trembles..."));
3902 earthquake(m_ptr->fy, m_ptr->fx, 4 + randint0(4));
3903 if (!one_in_(6)) break;
3905 case 3: case 4: case 5: case 6:
3908 int extra_dam = damroll(10, 10);
3909 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
3911 project(0, 8, m_ptr->fy, m_ptr->fx, extra_dam, GF_MANA, curse_flg, -1);
3912 if (!one_in_(6)) break;
3917 msg_print(_("空間が歪んだ!", "Space warps about you!"));
3919 if (m_ptr->r_idx) teleport_away(g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
3920 if (one_in_(13)) count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3921 if (!one_in_(6)) break;
3923 case 9: case 10: case 11:
3924 msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
3925 project(0, 7, m_ptr->fy, m_ptr->fx, 50, GF_DISINTEGRATE, curse_flg, -1);
3926 if (!one_in_(6)) break;
3927 case 12: case 13: case 14: case 15: case 16:
3928 aggravate_monsters(0);
3929 if (!one_in_(6)) break;
3931 count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3932 if (!one_in_(6)) break;
3933 case 19: case 20: case 21: case 22:
3935 bool pet = !one_in_(3);
3936 BIT_FLAGS mode = PM_ALLOW_GROUP;
3938 if (pet) mode |= PM_FORCE_PET;
3939 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
3941 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');
3942 if (!one_in_(6)) break;
3944 case 23: case 24: case 25:
3945 if (p_ptr->hold_exp && (randint0(100) < 75)) break;
3946 msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
3948 if (p_ptr->hold_exp) lose_exp(p_ptr->exp / 160);
3949 else lose_exp(p_ptr->exp / 16);
3950 if (!one_in_(6)) break;
3951 case 26: case 27: case 28:
3960 (void)do_dec_stat(i);
3961 } while (one_in_(2));
3968 (void)do_dec_stat(randint0(6));
3973 } while (one_in_(5));
3977 bool fire_crimson(void)
3981 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3985 if (!get_aim_dir(&dir)) return FALSE;
3987 /* Use the given direction */
3988 tx = p_ptr->x + 99 * ddx[dir];
3989 ty = p_ptr->y + 99 * ddy[dir];
3991 /* Hack -- Use an actual "target" */
3992 if ((dir == 5) && target_okay())
3998 if (p_ptr->pclass == CLASS_ARCHER)
4000 /* Extra shot at level 10 */
4001 if (p_ptr->lev >= 10) num++;
4003 /* Extra shot at level 30 */
4004 if (p_ptr->lev >= 30) num++;
4006 /* Extra shot at level 45 */
4007 if (p_ptr->lev >= 45) num++;
4010 for (i = 0; i < num; i++)
4011 project(0, p_ptr->lev / 20 + 1, ty, tx, p_ptr->lev*p_ptr->lev * 6 / 50, GF_ROCKET, flg, -1);