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.
19 #include "object-ego.h"
25 #include "floor-town.h"
26 #include "object-boost.h"
27 #include "object-flavor.h"
28 #include "object-hook.h"
30 #include "player-move.h"
31 #include "player-status.h"
32 #include "player-class.h"
33 #include "player-damage.h"
34 #include "player-inventory.h"
35 #include "spells-summon.h"
40 #include "spells-floor.h"
42 #include "monster-process.h"
43 #include "monster-status.h"
44 #include "monster-spell.h"
45 #include "cmd-spell.h"
48 #include "floor-save.h"
50 #include "player-effects.h"
51 #include "player-skill.h"
52 #include "player-personality.h"
53 #include "view-mainwindow.h"
57 #include "objectkind.h"
59 #include "targeting.h"
62 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
67 * @brief モンスターのテレポートアウェイ処理 /
68 * Teleport a monster, normally up to "dis" grids away.
69 * @param m_idx モンスターID
72 * @return テレポートが実際に行われたらtrue
74 * Attempt to move the monster at least "dis/2" grids away.
75 * But allow variation to prevent infinite loops.
77 bool teleport_away(player_type *caster_ptr, MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
79 POSITION oy, ox, d, i, min;
81 POSITION ny = 0, nx = 0;
85 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
86 if (!monster_is_valid(m_ptr)) return (FALSE);
91 /* Minimum distance */
94 if ((mode & TELEPORT_DEC_VALOUR) &&
95 (((caster_ptr->chp * 10) / caster_ptr->mhp) > 5) &&
96 (4+randint1(5) < ((caster_ptr->chp * 10) / caster_ptr->mhp)))
98 chg_virtue(caster_ptr, V_VALOUR, -1);
101 /* Look until done */
106 /* Verify max distance */
107 if (dis > 200) dis = 200;
109 /* Try several locations */
110 for (i = 0; i < 500; i++)
112 /* Pick a (possibly illegal) location */
115 ny = rand_spread(oy, dis);
116 nx = rand_spread(ox, dis);
117 d = distance(oy, ox, ny, nx);
118 if ((d >= min) && (d <= dis)) break;
121 /* Ignore illegal locations */
122 if (!in_bounds(caster_ptr->current_floor_ptr, ny, nx)) continue;
124 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
126 /* No teleporting into vaults and such */
127 if (!(caster_ptr->current_floor_ptr->inside_quest || caster_ptr->current_floor_ptr->inside_arena))
128 if (caster_ptr->current_floor_ptr->grid_array[ny][nx].info & CAVE_ICKY) continue;
130 /* This grid looks good */
137 /* Increase the maximum distance */
140 /* Decrease the minimum distance */
143 /* Stop after MAX_TRIES tries */
144 if (tries > MAX_TRIES) return (FALSE);
147 sound(SOUND_TPOTHER);
149 /* Update the old location */
150 caster_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
152 /* Update the new location */
153 caster_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
155 /* Move the monster */
159 /* Forget the counter target */
162 update_monster(caster_ptr, m_idx, TRUE);
166 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
167 caster_ptr->update |= (PU_MON_LITE);
174 * @brief モンスターを指定された座標付近にテレポートする /
175 * Teleport monster next to a grid near the given location
176 * @param m_idx モンスターID
179 * @param power テレポート成功確率
183 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
185 POSITION ny, nx, oy, ox;
190 monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
191 if(!m_ptr->r_idx) return;
194 if(randint1(100) > power) return;
201 /* Minimum distance */
204 /* Look until done */
205 while (look && --attempts)
207 /* Verify max distance */
208 if (dis > 200) dis = 200;
210 /* Try several locations */
211 for (i = 0; i < 500; i++)
213 /* Pick a (possibly illegal) location */
216 ny = rand_spread(ty, dis);
217 nx = rand_spread(tx, dis);
218 d = distance(ty, tx, ny, nx);
219 if ((d >= min) && (d <= dis)) break;
222 /* Ignore illegal locations */
223 if (!in_bounds(p_ptr->current_floor_ptr, ny, nx)) continue;
225 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
227 /* No teleporting into vaults and such */
228 /* if (p_ptr->current_floor_ptr->grid_array[ny][nx].info & (CAVE_ICKY)) continue; */
230 /* This grid looks good */
237 /* Increase the maximum distance */
240 /* Decrease the minimum distance */
244 if (attempts < 1) return;
246 sound(SOUND_TPOTHER);
248 /* Update the old location */
249 p_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
251 /* Update the new location */
252 p_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
254 /* Move the monster */
258 update_monster(p_ptr, m_idx, TRUE);
262 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
263 p_ptr->update |= (PU_MON_LITE);
267 * @brief プレイヤーのテレポート先選定と移動処理 /
268 * Teleport the player to a location up to "dis" grids away.
271 * @return 実際にテレポート処理が行われたらtrue
274 * If no such spaces are readily available, the distance may increase.
275 * Try very hard to move the player at least a quarter that distance.
277 * There was a nasty tendency for a long time; which was causing the
278 * player to "bounce" between two or three different spots because
279 * these are the only spots that are "far enough" way to satisfy the
282 * But this tendency is now removed; in the new algorithm, a list of
283 * candidates is selected first, which includes at least 50% of all
284 * floor grids within the distance, and any single grid in this list
285 * of candidates has equal possibility to be choosen as a destination.
289 bool teleport_player_aux(player_type *creature_ptr, POSITION dis, BIT_FLAGS mode)
291 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
292 int total_candidates, cur_candidates;
293 POSITION y = 0, x = 0;
296 int left = MAX(1, creature_ptr->x - dis);
297 int right = MIN(creature_ptr->current_floor_ptr->width - 2, creature_ptr->x + dis);
298 int top = MAX(1, creature_ptr->y - dis);
299 int bottom = MIN(creature_ptr->current_floor_ptr->height - 2, creature_ptr->y + dis);
301 if (creature_ptr->wild_mode) return FALSE;
303 if (creature_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
305 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
309 /* Initialize counters */
310 total_candidates = 0;
311 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
312 candidates_at[i] = 0;
314 /* Limit the distance */
315 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
317 /* Search valid locations */
318 for (y = top; y <= bottom; y++)
320 for (x = left; x <= right; x++)
324 /* Skip illegal locations */
325 if (!cave_player_teleportable_bold(y, x, mode)) continue;
327 /* Calculate distance */
328 d = distance(creature_ptr->y, creature_ptr->x, y, x);
330 /* Skip too far locations */
331 if (d > dis) continue;
333 /* Count the total number of candidates */
336 /* Count the number of candidates in this circumference */
341 /* No valid location! */
342 if (0 == total_candidates) return FALSE;
344 /* Fix the minimum distance */
345 for (cur_candidates = 0, min = dis; min >= 0; min--)
347 cur_candidates += candidates_at[min];
349 /* 50% of all candidates will have an equal chance to be choosen. */
350 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
353 /* Pick up a single location randomly */
354 pick = randint1(cur_candidates);
356 /* Search again the choosen location */
357 for (y = top; y <= bottom; y++)
359 for (x = left; x <= right; x++)
363 /* Skip illegal locations */
364 if (!cave_player_teleportable_bold(y, x, mode)) continue;
366 /* Calculate distance */
367 d = distance(creature_ptr->y, creature_ptr->x, y, x);
369 /* Skip too far locations */
370 if (d > dis) continue;
372 /* Skip too close locations */
373 if (d < min) continue;
375 /* This grid was picked up? */
384 if (player_bold(creature_ptr, y, x)) return FALSE;
386 sound(SOUND_TELEPORT);
389 if ((creature_ptr->pseikaku == SEIKAKU_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
390 msg_format("『こっちだぁ、%s』", creature_ptr->name);
393 (void)move_player_effect(creature_ptr, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
398 * @brief プレイヤーのテレポート処理メインルーチン
403 void teleport_player(player_type *creature_ptr, POSITION dis, BIT_FLAGS mode)
406 POSITION oy = creature_ptr->y;
407 POSITION ox = creature_ptr->x;
409 if (!teleport_player_aux(creature_ptr, dis, mode)) return;
411 /* Monsters with teleport ability may follow the player */
412 for (xx = -1; xx < 2; xx++)
414 for (yy = -1; yy < 2; yy++)
416 MONSTER_IDX tmp_m_idx = creature_ptr->current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
418 /* A monster except your mount may follow */
419 if (tmp_m_idx && (creature_ptr->riding != tmp_m_idx))
421 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[tmp_m_idx];
422 monster_race *r_ptr = &r_info[m_ptr->r_idx];
425 * The latter limitation is to avoid
426 * totally unkillable suckers...
428 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
429 !(r_ptr->flagsr & RFR_RES_TELE))
431 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, creature_ptr->y, creature_ptr->x, r_ptr->level, 0L);
440 * @brief プレイヤーのテレポートアウェイ処理 /
441 * @param m_idx アウェイを試みたプレイヤーID
445 void teleport_player_away(MONSTER_IDX m_idx, POSITION dis)
448 POSITION oy = p_ptr->y;
449 POSITION ox = p_ptr->x;
451 if (!teleport_player_aux(p_ptr, dis, TELEPORT_PASSIVE)) return;
453 /* Monsters with teleport ability may follow the player */
454 for (xx = -1; xx < 2; xx++)
456 for (yy = -1; yy < 2; yy++)
458 MONSTER_IDX tmp_m_idx = p_ptr->current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
460 /* A monster except your mount or caster may follow */
461 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
463 monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[tmp_m_idx];
464 monster_race *r_ptr = &r_info[m_ptr->r_idx];
467 * The latter limitation is to avoid
468 * totally unkillable suckers...
470 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
471 !(r_ptr->flagsr & RFR_RES_TELE))
473 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
482 * @brief プレイヤーを指定位置近辺にテレポートさせる
483 * Teleport player to a grid near the given location
486 * @param mode オプションフラグ
490 * This function is slightly obsessive about correctness.
491 * This function allows teleporting into vaults (!)
494 void teleport_player_to(player_type *creature_ptr, POSITION ny, POSITION nx, BIT_FLAGS mode)
497 POSITION dis = 0, ctr = 0;
499 if (creature_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
501 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
505 /* Find a usable location */
508 /* Pick a nearby legal location */
511 y = (POSITION)rand_spread(ny, dis);
512 x = (POSITION)rand_spread(nx, dis);
513 if (in_bounds(creature_ptr->current_floor_ptr, y, x)) break;
516 /* Accept any grid when wizard mode */
517 if (current_world_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!creature_ptr->current_floor_ptr->grid_array[y][x].m_idx || (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx == creature_ptr->riding))) break;
519 /* Accept teleportable floor grids */
520 if (cave_player_teleportable_bold(y, x, mode)) break;
522 /* Occasionally advance the distance */
523 if (++ctr > (4 * dis * dis + 4 * dis + 1))
530 sound(SOUND_TELEPORT);
531 (void)move_player_effect(creature_ptr, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
535 void teleport_away_followable(MONSTER_IDX m_idx)
537 monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
538 POSITION oldfy = m_ptr->fy;
539 POSITION oldfx = m_ptr->fx;
540 bool old_ml = m_ptr->ml;
541 POSITION old_cdis = m_ptr->cdis;
543 teleport_away(p_ptr, m_idx, MAX_SIGHT * 2 + 5, 0L);
545 if (old_ml && (old_cdis <= MAX_SIGHT) && !current_world_ptr->timewalk_m_idx && !p_ptr->phase_out && los(p_ptr->current_floor_ptr, p_ptr->y, p_ptr->x, oldfy, oldfx))
549 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
552 BIT_FLAGS flgs[TR_FLAG_SIZE];
556 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
558 o_ptr = &p_ptr->inventory_list[i];
559 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
561 object_flags(o_ptr, flgs);
562 if (have_flag(flgs, TR_TELEPORT))
573 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
577 teleport_player(p_ptr, 200, TELEPORT_PASSIVE);
578 msg_print(_("失敗!", "Failed!"));
580 else teleport_player_to(p_ptr, m_ptr->fy, m_ptr->fx, 0L);
581 p_ptr->energy_need += ENERGY_NEED();
588 bool teleport_level_other(player_type *creature_ptr)
590 MONSTER_IDX target_m_idx;
593 GAME_TEXT m_name[MAX_NLEN];
595 if (!target_set(TARGET_KILL)) return FALSE;
596 target_m_idx = p_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
597 if (!target_m_idx) return TRUE;
598 if (!player_has_los_bold(p_ptr, target_row, target_col)) return TRUE;
599 if (!projectable(creature_ptr->current_floor_ptr, creature_ptr->y, creature_ptr->x, target_row, target_col)) return TRUE;
600 m_ptr = &p_ptr->current_floor_ptr->m_list[target_m_idx];
601 r_ptr = &r_info[m_ptr->r_idx];
602 monster_desc(m_name, m_ptr, 0);
603 msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
605 if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
606 (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > creature_ptr->lev + randint1(60)))
608 msg_format(_("しかし効果がなかった!", "%^s is unaffected!"), m_name);
610 else teleport_level(creature_ptr, target_m_idx);
615 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
616 * Teleport the player one level up or down (random when legal)
617 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
620 void teleport_level(player_type *creature_ptr, MONSTER_IDX m_idx)
623 GAME_TEXT m_name[160];
626 if (m_idx <= 0) /* To player */
628 strcpy(m_name, _("あなた", "you"));
630 else /* To monster */
632 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
634 /* Get the monster name (or "it") */
635 monster_desc(m_name, m_ptr, 0);
637 see_m = is_seen(m_ptr);
640 /* No effect in some case */
641 if (TELE_LEVEL_IS_INEFF(m_idx))
643 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
647 if ((m_idx <= 0) && creature_ptr->anti_tele) /* To player */
649 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
653 /* Choose up or down */
654 if (randint0(100) < 50) go_up = TRUE;
657 if ((m_idx <= 0) && current_world_ptr->wizard)
659 if (get_check("Force to go up? ")) go_up = TRUE;
660 else if (get_check("Force to go down? ")) go_up = FALSE;
664 if ((ironman_downward && (m_idx <= 0)) || (creature_ptr->current_floor_ptr->dun_level <= d_info[creature_ptr->dungeon_idx].mindepth))
667 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
669 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
671 if (m_idx <= 0) /* To player */
673 if (!creature_ptr->current_floor_ptr->dun_level)
675 creature_ptr->dungeon_idx = ironman_downward ? DUNGEON_ANGBAND : creature_ptr->recall_dungeon;
676 creature_ptr->oldpy = creature_ptr->y;
677 creature_ptr->oldpx = creature_ptr->x;
680 if (record_stair) exe_write_diary(creature_ptr, NIKKI_TELE_LEV, 1, NULL);
682 if (autosave_l) do_cmd_save_game(TRUE);
684 if (!creature_ptr->current_floor_ptr->dun_level)
686 creature_ptr->current_floor_ptr->dun_level = d_info[creature_ptr->dungeon_idx].mindepth;
687 prepare_change_floor_mode(CFM_RAND_PLACE);
691 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
693 creature_ptr->leaving = TRUE;
698 else if (quest_number(creature_ptr->current_floor_ptr->dun_level) || (creature_ptr->current_floor_ptr->dun_level >= d_info[creature_ptr->dungeon_idx].maxdepth))
701 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
703 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
707 if (m_idx <= 0) /* To player */
709 if (record_stair) exe_write_diary(creature_ptr, NIKKI_TELE_LEV, -1, NULL);
711 if (autosave_l) do_cmd_save_game(TRUE);
713 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
716 creature_ptr->current_floor_ptr->inside_quest = 0;
717 creature_ptr->leaving = TRUE;
723 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
725 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
729 if (m_idx <= 0) /* To player */
731 if (record_stair) exe_write_diary(creature_ptr, NIKKI_TELE_LEV, -1, NULL);
733 if (autosave_l) do_cmd_save_game(TRUE);
735 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
736 creature_ptr->leaving = TRUE;
742 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
744 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
747 if (m_idx <= 0) /* To player */
749 /* Never reach this code on the surface */
750 /* if (!creature_ptr->current_floor_ptr->dun_level) creature_ptr->dungeon_idx = creature_ptr->recall_dungeon; */
751 if (record_stair) exe_write_diary(creature_ptr, NIKKI_TELE_LEV, 1, NULL);
752 if (autosave_l) do_cmd_save_game(TRUE);
754 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
755 creature_ptr->leaving = TRUE;
759 /* Monster level teleportation is simple deleting now */
762 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[m_idx];
764 check_quest_completion(m_ptr);
766 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
768 char m2_name[MAX_NLEN];
770 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
771 exe_write_diary(creature_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
774 delete_monster_idx(m_idx);
777 sound(SOUND_TPLEVEL);
781 * @brief プレイヤーの帰還発動及び中止処理 /
782 * Recall the player to town or dungeon
783 * @param turns 発動までのターン数
786 bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
789 * TODO: Recall the player to the last
790 * visited town when in the wilderness
794 if (creature_ptr->current_floor_ptr->inside_arena || ironman_downward)
796 msg_print(_("何も起こらなかった。", "Nothing happens."));
800 if (p_ptr->current_floor_ptr->dun_level && (max_dlv[p_ptr->dungeon_idx] > p_ptr->current_floor_ptr->dun_level) && !creature_ptr->current_floor_ptr->inside_quest && !creature_ptr->word_recall)
802 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
804 max_dlv[p_ptr->dungeon_idx] = p_ptr->current_floor_ptr->dun_level;
806 exe_write_diary(p_ptr, NIKKI_TRUMP, p_ptr->dungeon_idx, _("帰還のときに", "when recall from dungeon"));
810 if (!creature_ptr->word_recall)
812 if (!p_ptr->current_floor_ptr->dun_level)
814 DUNGEON_IDX select_dungeon;
815 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
816 if (!select_dungeon) return FALSE;
817 creature_ptr->recall_dungeon = select_dungeon;
819 creature_ptr->word_recall = turns;
820 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
821 creature_ptr->redraw |= (PR_STATUS);
825 creature_ptr->word_recall = 0;
826 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
827 creature_ptr->redraw |= (PR_STATUS);
832 bool free_level_recall(player_type *creature_ptr)
834 DUNGEON_IDX select_dungeon;
838 select_dungeon = choose_dungeon(_("にテレポート", "teleport"), 4, 0);
840 if (!select_dungeon) return FALSE;
842 max_depth = d_info[select_dungeon].maxdepth;
844 /* Limit depth in Angband */
845 if (select_dungeon == DUNGEON_ANGBAND)
847 if (quest[QUEST_OBERON].status != QUEST_STATUS_FINISHED) max_depth = 98;
848 else if (quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
850 amt = get_quantity(format(_("%sの何階にテレポートしますか?", "Teleport to which level of %s? "),
851 d_name + d_info[select_dungeon].name), (QUANTITY)max_depth);
855 creature_ptr->word_recall = 1;
856 creature_ptr->recall_dungeon = select_dungeon;
857 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));
859 exe_write_diary(p_ptr, NIKKI_TRUMP, select_dungeon, _("トランプタワーで", "at Trump Tower"));
861 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
863 creature_ptr->redraw |= (PR_STATUS);
872 * @return リセット処理が実際に行われたらTRUEを返す
874 bool reset_recall(void)
876 int select_dungeon, dummy = 0;
880 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
883 if (ironman_downward)
885 msg_print(_("何も起こらなかった。", "Nothing happens."));
889 if (!select_dungeon) return FALSE;
891 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
892 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
895 sprintf(tmp_val, "%d", (int)MAX(p_ptr->current_floor_ptr->dun_level, 1));
897 /* Ask for a level */
898 if (get_string(ppp, tmp_val, 10))
900 /* Extract request */
901 dummy = atoi(tmp_val);
902 if (dummy < 1) dummy = 1;
903 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
904 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
906 max_dlv[select_dungeon] = dummy;
909 exe_write_diary(p_ptr, NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
912 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
914 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
927 * @brief プレイヤーの装備劣化処理 /
928 * Apply disenchantment to the player's stuff
929 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
930 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
931 * Return "TRUE" if the player notices anything
933 bool apply_disenchant(player_type *target_ptr, BIT_FLAGS mode)
937 GAME_TEXT o_name[MAX_NLEN];
938 int to_h, to_d, to_a, pval;
940 /* Pick a random slot */
943 case 1: t = INVEN_RARM; break;
944 case 2: t = INVEN_LARM; break;
945 case 3: t = INVEN_BOW; break;
946 case 4: t = INVEN_BODY; break;
947 case 5: t = INVEN_OUTER; break;
948 case 6: t = INVEN_HEAD; break;
949 case 7: t = INVEN_HANDS; break;
950 case 8: t = INVEN_FEET; break;
953 o_ptr = &target_ptr->inventory_list[t];
955 /* No item, nothing happens */
956 if (!o_ptr->k_idx) return (FALSE);
958 /* Disenchant equipments only -- No disenchant on monster ball */
959 if (!object_is_weapon_armour_ammo(o_ptr))
962 /* Nothing to disenchant */
963 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
965 /* Nothing to notice */
969 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
971 /* Artifacts have 71% chance to resist */
972 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
975 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
977 msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t),
978 ((o_ptr->number != 1) ? "" : "s"));
984 /* Memorize old value */
990 /* Disenchant tohit */
991 if (o_ptr->to_h > 0) o_ptr->to_h--;
992 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
994 /* Disenchant todam */
995 if (o_ptr->to_d > 0) o_ptr->to_d--;
996 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
998 /* Disenchant toac */
999 if (o_ptr->to_a > 0) o_ptr->to_a--;
1000 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1002 /* Disenchant pval (occasionally) */
1003 /* Unless called from wild_magic() */
1004 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1006 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1007 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1010 msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t) );
1012 msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t),
1013 ((o_ptr->number != 1) ? "were" : "was"));
1016 chg_virtue(target_ptr, V_HARMONY, 1);
1017 chg_virtue(target_ptr, V_ENCHANT, -2);
1018 target_ptr->update |= (PU_BONUS);
1019 target_ptr->window |= (PW_EQUIP | PW_PLAYER);
1021 calc_android_exp(target_ptr);
1029 * @brief 虚無招来によるフロア中の全壁除去処理 /
1030 * Vanish all walls in this floor
1031 * @params floor_ptr 対象となるフロアの対象ポインタ
1032 * @params subject_ptr 現象を主観するクリーチャーの参照ポインタ
1033 * @return 実際に処理が反映された場合TRUE
1035 static bool vanish_dungeon(floor_type *floor_ptr, player_type *subject_ptr)
1039 feature_type *f_ptr;
1040 monster_type *m_ptr;
1041 GAME_TEXT m_name[MAX_NLEN];
1043 /* Prevent vasishing of quest levels and town */
1044 if ((subject_ptr->current_floor_ptr->inside_quest && is_fixed_quest_idx(subject_ptr->current_floor_ptr->inside_quest)) || !floor_ptr->dun_level)
1049 /* Scan all normal grids */
1050 for (y = 1; y < floor_ptr->height - 1; y++)
1052 for (x = 1; x < floor_ptr->width - 1; x++)
1054 g_ptr = &floor_ptr->grid_array[y][x];
1056 /* Seeing true feature code (ignore mimic) */
1057 f_ptr = &f_info[g_ptr->feat];
1059 /* Lose room and vault */
1060 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1062 m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
1065 if (g_ptr->m_idx && MON_CSLEEP(m_ptr))
1067 (void)set_monster_csleep(g_ptr->m_idx, 0);
1069 /* Notice the "waking up" */
1072 monster_desc(m_name, m_ptr, 0);
1073 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1077 /* Process all walls, doors and patterns */
1078 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1082 /* Special boundary walls -- Top and bottom */
1083 for (x = 0; x < floor_ptr->width; x++)
1085 g_ptr = &floor_ptr->grid_array[0][x];
1086 f_ptr = &f_info[g_ptr->mimic];
1088 /* Lose room and vault */
1089 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1091 /* Set boundary mimic if needed */
1092 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1094 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1096 /* Check for change to boring grid */
1097 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1100 g_ptr = &floor_ptr->grid_array[floor_ptr->height - 1][x];
1101 f_ptr = &f_info[g_ptr->mimic];
1103 /* Lose room and vault */
1104 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1106 /* Set boundary mimic if needed */
1107 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1109 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1111 /* Check for change to boring grid */
1112 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1116 /* Special boundary walls -- Left and right */
1117 for (y = 1; y < (floor_ptr->height - 1); y++)
1119 g_ptr = &floor_ptr->grid_array[y][0];
1120 f_ptr = &f_info[g_ptr->mimic];
1122 /* Lose room and vault */
1123 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1125 /* Set boundary mimic if needed */
1126 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1128 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1130 /* Check for change to boring grid */
1131 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1134 g_ptr = &floor_ptr->grid_array[y][floor_ptr->width - 1];
1135 f_ptr = &f_info[g_ptr->mimic];
1137 /* Lose room and vault */
1138 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1140 /* Set boundary mimic if needed */
1141 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1143 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1145 /* Check for change to boring grid */
1146 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1150 /* Mega-Hack -- Forget the view and lite */
1151 subject_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1152 subject_ptr->redraw |= (PR_MAP);
1153 subject_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1162 * Sorry, it becomes not (void)...
1164 void call_the_void(player_type *caster_ptr)
1168 bool do_call = TRUE;
1170 for (i = 0; i < 9; i++)
1172 g_ptr = &caster_ptr->current_floor_ptr->grid_array[caster_ptr->y + ddy_ddd[i]][caster_ptr->x + ddx_ddd[i]];
1174 if (!cave_have_flag_grid(g_ptr, FF_PROJECT))
1176 if (!g_ptr->mimic || !have_flag(f_info[g_ptr->mimic].flags, FF_PROJECT) ||
1177 !permanent_wall(&f_info[g_ptr->feat]))
1187 for (i = 1; i < 10; i++)
1189 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1192 for (i = 1; i < 10; i++)
1194 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1197 for (i = 1; i < 10; i++)
1199 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1203 /* Prevent destruction of quest levels and town */
1204 else if ((caster_ptr->current_floor_ptr->inside_quest && is_fixed_quest_idx(caster_ptr->current_floor_ptr->inside_quest)) || !caster_ptr->current_floor_ptr->dun_level)
1206 msg_print(_("地面が揺れた。", "The ground trembles."));
1212 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1213 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1215 msg_format("You %s the %s too close to a wall!",
1216 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1217 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1219 msg_print(_("大きな爆発音があった!", "There is a loud explosion!"));
1223 if (!vanish_dungeon(caster_ptr->current_floor_ptr, caster_ptr)) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1227 if (destroy_area(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x, 15 + caster_ptr->lev + randint0(11), FALSE))
1228 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1230 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1233 take_hit(caster_ptr, DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1239 * @brief アイテム引き寄せ処理 /
1240 * Fetch an item (teleport it right underneath the caster)
1241 * @param dir 魔法の発動方向
1243 * @param require_los 射線の通りを要求するならばTRUE
1246 void fetch(player_type *caster_ptr, DIRECTION dir, WEIGHT wgt, bool require_los)
1252 GAME_TEXT o_name[MAX_NLEN];
1254 /* Check to see if an object is already there */
1255 if (caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].o_idx)
1257 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1262 if (dir == 5 && target_okay())
1267 if (distance(caster_ptr->y, caster_ptr->x, ty, tx) > MAX_RANGE)
1269 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1273 g_ptr = &caster_ptr->current_floor_ptr->grid_array[ty][tx];
1275 /* We need an item to fetch */
1278 msg_print(_("そこには何もありません。", "There is no object at this place."));
1282 /* No fetching from vault */
1283 if (g_ptr->info & CAVE_ICKY)
1285 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1289 /* We need to see the item */
1292 if (!player_has_los_bold(p_ptr, ty, tx))
1294 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1297 else if (!projectable(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x, ty, tx))
1299 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1312 g_ptr = &caster_ptr->current_floor_ptr->grid_array[ty][tx];
1314 if ((distance(caster_ptr->y, caster_ptr->x, ty, tx) > MAX_RANGE) ||
1315 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1317 while (!g_ptr->o_idx);
1320 o_ptr = &caster_ptr->current_floor_ptr->o_list[g_ptr->o_idx];
1322 if (o_ptr->weight > wgt)
1324 /* Too heavy to 'fetch' */
1325 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1330 g_ptr->o_idx = o_ptr->next_o_idx;
1331 caster_ptr->current_floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].o_idx = i; /* 'move' it */
1333 o_ptr->next_o_idx = 0;
1334 o_ptr->iy = caster_ptr->y;
1335 o_ptr->ix = caster_ptr->x;
1337 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1338 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1340 note_spot(caster_ptr->y, caster_ptr->x);
1341 caster_ptr->redraw |= PR_MAP;
1348 void alter_reality(void)
1350 /* Ironman option */
1351 if (p_ptr->current_floor_ptr->inside_arena || ironman_downward)
1353 msg_print(_("何も起こらなかった。", "Nothing happens."));
1357 if (!p_ptr->alter_reality)
1359 TIME_EFFECT turns = randint0(21) + 15;
1361 p_ptr->alter_reality = turns;
1362 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1364 p_ptr->redraw |= (PR_STATUS);
1368 p_ptr->alter_reality = 0;
1369 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1370 p_ptr->redraw |= (PR_STATUS);
1376 * @brief 全所持アイテム鑑定処理 /
1377 * Identify everything being carried.
1378 * Done by a potion of "self knowledge".
1381 void identify_pack(void)
1385 /* Simply identify and know every item */
1386 for (i = 0; i < INVEN_TOTAL; i++)
1388 object_type *o_ptr = &p_ptr->inventory_list[i];
1389 if (!o_ptr->k_idx) continue;
1391 identify_item(o_ptr);
1393 /* Auto-inscription */
1394 autopick_alter_item(i, FALSE);
1400 * Removes curses from items in p_ptr->inventory_list
1401 * @param all 軽い呪いまでの解除ならば0
1402 * @return 解呪されたアイテムの数
1405 * Note that Items which are "Perma-Cursed" (The One Ring,
1406 * The Crown of Morgoth) can NEVER be uncursed.
1408 * Note that if "all" is FALSE, then Items which are
1409 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1410 * will not be uncursed.
1413 static int remove_curse_aux(player_type *creature_ptr, int all)
1417 /* Attempt to uncurse items being worn */
1418 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1420 object_type *o_ptr = &creature_ptr->inventory_list[i];
1421 if (!o_ptr->k_idx) continue;
1423 /* Uncursed already */
1424 if (!object_is_cursed(o_ptr)) continue;
1426 /* Heavily Cursed Items need a special spell */
1427 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1429 /* Perma-Cursed Items can NEVER be uncursed */
1430 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1432 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1436 o_ptr->curse_flags = 0L;
1437 o_ptr->ident |= (IDENT_SENSE);
1438 o_ptr->feeling = FEEL_NONE;
1440 creature_ptr->update |= (PU_BONUS);
1441 creature_ptr->window |= (PW_EQUIP);
1443 /* Count the uncursings */
1449 msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
1451 /* Return "something uncursed" */
1457 * @brief 装備の軽い呪い解呪処理 /
1458 * Remove most curses
1459 * @return 解呪に成功した装備数
1461 int remove_curse(player_type *caster_ptr)
1463 return (remove_curse_aux(caster_ptr, FALSE));
1467 * @brief 装備の重い呪い解呪処理 /
1469 * @return 解呪に成功した装備数
1471 int remove_all_curse(player_type *caster_ptr)
1473 return (remove_curse_aux(caster_ptr, TRUE));
1478 * @brief アイテムの価値に応じた錬金術処理 /
1479 * Turns an object into gold, gain some of its value in a shop
1480 * @return 処理が実際に行われたらTRUEを返す
1486 ITEM_NUMBER old_number;
1490 GAME_TEXT o_name[MAX_NLEN];
1491 char out_val[MAX_NLEN+40];
1495 /* Hack -- force destruction */
1496 if (command_arg > 0) force = TRUE;
1498 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
1499 s = _("金に変えられる物がありません。", "You have nothing to current_world_ptr->game_turn to gold.");
1501 o_ptr = choose_object(p_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
1502 if (!o_ptr) return (FALSE);
1504 /* See how many items */
1505 if (o_ptr->number > 1)
1507 amt = get_quantity(NULL, o_ptr->number);
1509 /* Allow user abort */
1510 if (amt <= 0) return FALSE;
1513 old_number = o_ptr->number;
1514 o_ptr->number = amt;
1515 object_desc(o_name, o_ptr, 0);
1516 o_ptr->number = old_number;
1518 /* Verify unless quantity given */
1521 if (confirm_destroy || (object_value(o_ptr) > 0))
1523 /* Make a verification */
1524 sprintf(out_val, _("本当に%sを金に変えますか?", "Really current_world_ptr->game_turn %s to gold? "), o_name);
1525 if (!get_check(out_val)) return FALSE;
1529 /* Artifacts cannot be destroyed */
1530 if (!can_player_destroy_object(o_ptr))
1532 msg_format(_("%sを金に変えることに失敗した。", "You fail to current_world_ptr->game_turn %s to gold!"), o_name);
1537 price = object_value_real(o_ptr);
1541 msg_format(_("%sをニセの金に変えた。", "You current_world_ptr->game_turn %s to fool's gold."), o_name);
1547 if (amt > 1) price *= amt;
1549 if (price > 30000) price = 30000;
1550 msg_format(_("%sを$%d の金に変えた。", "You current_world_ptr->game_turn %s to %ld coins worth of gold."), o_name, price);
1553 p_ptr->redraw |= (PR_GOLD);
1554 p_ptr->window |= (PW_PLAYER);
1557 /* Eliminate the item (from the pack) */
1560 inven_item_increase(item, -amt);
1561 inven_item_describe(item);
1562 inven_item_optimize(item);
1565 /* Eliminate the item (from the floor) */
1568 floor_item_increase(0 - item, -amt);
1569 floor_item_describe(0 - item);
1570 floor_item_optimize(0 - item);
1578 * @brief アーティファクト生成の巻物処理 /
1579 * @return 生成が実際に試みられたらTRUEを返す
1581 bool artifact_scroll(void)
1586 GAME_TEXT o_name[MAX_NLEN];
1589 /* Enchant weapon/armour */
1590 item_tester_hook = item_tester_hook_nameless_weapon_armour;
1592 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
1593 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
1595 o_ptr = choose_object(p_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1596 if (!o_ptr) return (FALSE);
1598 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1600 msg_format("%s は眩い光を発した!",o_name);
1602 msg_format("%s %s radiate%s a blinding light!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
1605 if (object_is_artifact(o_ptr))
1608 msg_format("%sは既に伝説のアイテムです!", o_name );
1610 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
1616 else if (object_is_ego(o_ptr))
1619 msg_format("%sは既に名のあるアイテムです!", o_name );
1621 msg_format("The %s %s already %s!",
1622 o_name, ((o_ptr->number > 1) ? "are" : "is"),
1623 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
1629 else if (o_ptr->xtra3)
1632 msg_format("%sは既に強化されています!", o_name );
1634 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"),
1635 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
1641 if (o_ptr->number > 1)
1643 msg_print(_("複数のアイテムに魔法をかけるだけのエネルギーはありません!", "Not enough energy to enchant more than one object!"));
1645 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
1647 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
1652 inven_item_increase(item, 1 - (o_ptr->number));
1656 floor_item_increase(0 - item, 1 - (o_ptr->number));
1659 okay = become_random_artifact(o_ptr, TRUE);
1665 if (flush_failure) flush();
1666 msg_print(_("強化に失敗した。", "The enchantment failed."));
1667 if (one_in_(3)) chg_virtue(p_ptr, V_ENCHANT, -1);
1671 if (record_rand_art)
1673 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1674 exe_write_diary(p_ptr, NIKKI_ART_SCROLL, 0, o_name);
1676 chg_virtue(p_ptr, V_ENCHANT, 1);
1679 calc_android_exp(p_ptr);
1681 /* Something happened */
1688 * Identify an object
1689 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
1690 * @return 実際に鑑定できたらTRUEを返す
1692 bool identify_item(object_type *o_ptr)
1694 bool old_known = FALSE;
1695 GAME_TEXT o_name[MAX_NLEN];
1697 object_desc(o_name, o_ptr, 0);
1699 if (o_ptr->ident & IDENT_KNOWN)
1702 if (!(o_ptr->ident & (IDENT_MENTAL)))
1704 if (object_is_artifact(o_ptr) || one_in_(5))
1705 chg_virtue(p_ptr, V_KNOWLEDGE, 1);
1708 object_aware(o_ptr);
1709 object_known(o_ptr);
1710 o_ptr->marked |= OM_TOUCHED;
1712 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
1713 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1715 strcpy(record_o_name, o_name);
1716 record_turn = current_world_ptr->game_turn;
1718 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1720 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
1721 exe_write_diary(p_ptr, NIKKI_ART, 0, o_name);
1722 if(record_rand_art && !old_known && o_ptr->art_name)
1723 exe_write_diary(p_ptr, NIKKI_ART, 0, o_name);
1729 * @brief アイテム鑑定のメインルーチン処理 /
1730 * Identify an object in the p_ptr->inventory_list (or on the floor)
1731 * @param only_equip 装備品のみを対象とするならばTRUEを返す
1732 * @return 実際に鑑定を行ったならばTRUEを返す
1734 * This routine does *not* automatically combine objects.
1735 * Returns TRUE if something was identified, else FALSE.
1737 bool ident_spell(bool only_equip)
1741 GAME_TEXT o_name[MAX_NLEN];
1746 item_tester_hook = item_tester_hook_identify_weapon_armour;
1748 item_tester_hook = item_tester_hook_identify;
1750 if (can_get_item(item_tester_tval))
1752 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
1757 item_tester_hook = object_is_weapon_armour_ammo;
1759 item_tester_hook = NULL;
1761 q = _("すべて鑑定済みです。 ", "All items are identified. ");
1764 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
1766 o_ptr = choose_object(p_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1767 if (!o_ptr) return (FALSE);
1769 old_known = identify_item(o_ptr);
1771 object_desc(o_name, o_ptr, 0);
1772 if (item >= INVEN_RARM)
1774 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
1778 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
1782 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
1785 /* Auto-inscription/destroy */
1786 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
1788 /* Something happened */
1794 * @brief アイテム凡庸化のメインルーチン処理 /
1795 * Identify an object in the p_ptr->inventory_list (or on the floor)
1796 * @param only_equip 装備品のみを対象とするならばTRUEを返す
1797 * @return 実際に凡庸化をを行ったならばTRUEを返す
1800 * Mundanify an object in the p_ptr->inventory_list (or on the floor)
1801 * This routine does *not* automatically combine objects.
1802 * Returns TRUE if something was mundanified, else FALSE.
1805 bool mundane_spell(bool only_equip)
1811 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
1813 q = _("どれを使いますか?", "Use which item? ");
1814 s = _("使えるものがありません。", "You have nothing you can use.");
1816 o_ptr = choose_object(p_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1817 if (!o_ptr) return (FALSE);
1819 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
1821 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
1822 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
1823 OBJECT_IDX next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
1824 byte marked = o_ptr->marked; /* Object is marked */
1825 WEIGHT weight = o_ptr->number * o_ptr->weight;
1826 u16b inscription = o_ptr->inscription;
1829 object_prep(o_ptr, o_ptr->k_idx);
1833 o_ptr->next_o_idx = next_o_idx;
1834 o_ptr->marked = marked;
1835 o_ptr->inscription = inscription;
1836 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
1838 calc_android_exp(p_ptr);
1840 /* Something happened */
1845 * @brief アイテム*鑑定*のメインルーチン処理 /
1846 * Identify an object in the p_ptr->inventory_list (or on the floor)
1847 * @param only_equip 装備品のみを対象とするならばTRUEを返す
1848 * @return 実際に鑑定を行ったならばTRUEを返す
1850 * Fully "identify" an object in the p_ptr->inventory_list -BEN-
1851 * This routine returns TRUE if an item was identified.
1853 bool identify_fully(bool only_equip)
1857 GAME_TEXT o_name[MAX_NLEN];
1862 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
1864 item_tester_hook = item_tester_hook_identify_fully;
1866 if (can_get_item(item_tester_tval))
1868 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
1873 item_tester_hook = object_is_weapon_armour_ammo;
1875 item_tester_hook = NULL;
1877 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
1880 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
1882 o_ptr = choose_object(p_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
1883 if (!o_ptr) return (FALSE);
1885 old_known = identify_item(o_ptr);
1887 /* Mark the item as fully known */
1888 o_ptr->ident |= (IDENT_MENTAL);
1891 object_desc(o_name, o_ptr, 0);
1892 if (item >= INVEN_RARM)
1894 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
1898 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
1902 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
1905 /* Describe it fully */
1906 (void)screen_object(o_ptr, 0L);
1908 /* Auto-inscription/destroy */
1909 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
1919 * Recharge a wand/staff/rod from the pack or on the floor.
1920 * This function has been rewritten in Oangband and ZAngband.
1921 * @param power 充填パワー
1922 * @return ターン消費を要する処理まで進んだらTRUEを返す
1924 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
1925 * Chaos -- Arcane Binding --> recharge(90)
1927 * Scroll of recharging --> recharge(130)
1928 * Artifact activation/Thingol --> recharge(130)
1930 * It is harder to recharge high level, and highly charged wands,
1931 * staffs, and rods. The more wands in a stack, the more easily and
1932 * strongly they recharge. Staffs, however, each get fewer charges if
1935 * Beware of "sliding index errors".
1937 bool recharge(int power)
1941 int recharge_strength;
1942 TIME_EFFECT recharge_amount;
1951 GAME_TEXT o_name[MAX_NLEN];
1953 /* Only accept legal items */
1954 item_tester_hook = item_tester_hook_recharge;
1956 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
1957 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
1959 o_ptr = choose_object(p_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
1960 if (!o_ptr) return (FALSE);
1962 /* Get the object kind. */
1963 k_ptr = &k_info[o_ptr->k_idx];
1965 /* Extract the object "level" */
1966 lev = k_info[o_ptr->k_idx].level;
1969 /* Recharge a rod */
1970 if (o_ptr->tval == TV_ROD)
1972 /* Extract a recharge strength by comparing object level to power. */
1973 recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
1977 if (one_in_(recharge_strength))
1979 /* Activate the failure code. */
1986 /* Recharge amount */
1987 recharge_amount = (power * damroll(3, 2));
1989 /* Recharge by that amount */
1990 if (o_ptr->timeout > recharge_amount)
1991 o_ptr->timeout -= recharge_amount;
1998 /* Recharge wand/staff */
2001 /* Extract a recharge strength by comparing object level to power.
2002 * Divide up a stack of wands' charges to calculate charge penalty.
2004 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2005 recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15;
2007 /* All staffs, unstacked wands. */
2008 else recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15;
2009 if (recharge_strength < 0) recharge_strength = 0;
2012 if (one_in_(recharge_strength))
2014 /* Activate the failure code. */
2018 /* If the spell didn't backfire, recharge the wand or staff. */
2021 /* Recharge based on the standard number of charges. */
2022 recharge_amount = randint1(1 + k_ptr->pval / 2);
2024 /* Multiple wands in a stack increase recharging somewhat. */
2025 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2028 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2029 if (recharge_amount < 1) recharge_amount = 1;
2030 if (recharge_amount > 12) recharge_amount = 12;
2033 /* But each staff in a stack gets fewer additional charges,
2034 * although always at least one.
2036 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2038 recharge_amount /= (TIME_EFFECT)o_ptr->number;
2039 if (recharge_amount < 1) recharge_amount = 1;
2042 /* Recharge the wand or staff. */
2043 o_ptr->pval += recharge_amount;
2046 /* Hack -- we no longer "know" the item */
2047 o_ptr->ident &= ~(IDENT_KNOWN);
2049 /* Hack -- we no longer think the item is empty */
2050 o_ptr->ident &= ~(IDENT_EMPTY);
2055 /* Inflict the penalties for failing a recharge. */
2058 /* Artifacts are never destroyed. */
2059 if (object_is_fixed_artifact(o_ptr))
2061 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2062 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2064 /* Artifact rods. */
2065 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2066 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2068 /* Artifact wands and staffs. */
2069 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2074 /* Get the object description */
2075 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2077 /*** Determine Seriousness of Failure ***/
2079 /* Mages recharge objects more safely. */
2080 if (IS_WIZARD_CLASS(p_ptr) || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
2082 /* 10% chance to blow up one rod, otherwise draining. */
2083 if (o_ptr->tval == TV_ROD)
2085 if (one_in_(10)) fail_type = 2;
2088 /* 75% chance to blow up one wand, otherwise draining. */
2089 else if (o_ptr->tval == TV_WAND)
2091 if (!one_in_(3)) fail_type = 2;
2094 /* 50% chance to blow up one staff, otherwise no effect. */
2095 else if (o_ptr->tval == TV_STAFF)
2097 if (one_in_(2)) fail_type = 2;
2102 /* All other classes get no special favors. */
2105 /* 33% chance to blow up one rod, otherwise draining. */
2106 if (o_ptr->tval == TV_ROD)
2108 if (one_in_(3)) fail_type = 2;
2111 /* 20% chance of the entire stack, else destroy one wand. */
2112 else if (o_ptr->tval == TV_WAND)
2114 if (one_in_(5)) fail_type = 3;
2117 /* Blow up one staff. */
2118 else if (o_ptr->tval == TV_STAFF)
2124 /*** Apply draining and destruction. ***/
2126 /* Drain object or stack of objects. */
2129 if (o_ptr->tval == TV_ROD)
2131 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
2133 if (o_ptr->timeout < 10000)
2134 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2136 else if (o_ptr->tval == TV_WAND)
2138 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
2141 /* Staffs aren't drained. */
2144 /* Destroy an object or one in a stack of objects. */
2147 if (o_ptr->number > 1)
2148 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
2150 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2152 /* Reduce rod stack maximum timeout, drain wands. */
2153 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
2154 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
2156 /* Reduce and describe p_ptr->inventory_list */
2159 inven_item_increase(item, -1);
2160 inven_item_describe(item);
2161 inven_item_optimize(item);
2164 /* Reduce and describe floor item */
2167 floor_item_increase(0 - item, -1);
2168 floor_item_describe(0 - item);
2169 floor_item_optimize(0 - item);
2173 /* Destroy all members of a stack of objects. */
2176 if (o_ptr->number > 1)
2177 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
2179 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2181 /* Reduce and describe p_ptr->inventory_list */
2184 inven_item_increase(item, -999);
2185 inven_item_describe(item);
2186 inven_item_optimize(item);
2189 /* Reduce and describe floor item */
2192 floor_item_increase(0 - item, -999);
2193 floor_item_describe(0 - item);
2194 floor_item_optimize(0 - item);
2199 p_ptr->update |= (PU_COMBINE | PU_REORDER);
2200 p_ptr->window |= (PW_INVEN);
2202 /* Something was done */
2208 * @brief クリーチャー全既知呪文を表示する /
2209 * Hack -- Display all known spells in a window
2210 * @param caster_ptr 術者の参照ポインタ
2213 * Need to analyze size of the window.
2214 * Need more color coding.
2216 void display_spell_list(player_type *caster_ptr)
2221 const magic_type *s_ptr;
2222 GAME_TEXT name[MAX_NLEN];
2227 /* They have too many spells to list */
2228 if (caster_ptr->pclass == CLASS_SORCERER) return;
2229 if (caster_ptr->pclass == CLASS_RED_MAGE) return;
2231 if (caster_ptr->pclass == CLASS_SNIPER)
2233 display_snipe_list(caster_ptr);
2237 /* mind.c type classes */
2238 if ((caster_ptr->pclass == CLASS_MINDCRAFTER) ||
2239 (caster_ptr->pclass == CLASS_BERSERKER) ||
2240 (caster_ptr->pclass == CLASS_NINJA) ||
2241 (caster_ptr->pclass == CLASS_MIRROR_MASTER) ||
2242 (caster_ptr->pclass == CLASS_FORCETRAINER))
2244 PERCENTAGE minfail = 0;
2245 PLAYER_LEVEL plev = caster_ptr->lev;
2246 PERCENTAGE chance = 0;
2251 bool use_hp = FALSE;
2256 /* Display a list of spells */
2258 put_str(_("名前", "Name"), y, x + 5);
2259 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
2261 switch(caster_ptr->pclass)
2263 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
2264 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
2265 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
2266 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
2267 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
2268 default: use_mind = 0;break;
2271 /* Dump the spells */
2272 for (i = 0; i < MAX_MIND_POWERS; i++)
2274 byte a = TERM_WHITE;
2276 /* Access the available spell */
2277 spell = mind_powers[use_mind].info[i];
2278 if (spell.min_lev > plev) break;
2280 /* Get the failure rate */
2281 chance = spell.fail;
2283 /* Reduce failure rate by "effective" level adjustment */
2284 chance -= 3 * (caster_ptr->lev - spell.min_lev);
2286 /* Reduce failure rate by INT/WIS adjustment */
2287 chance -= 3 * (adj_mag_stat[caster_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2291 /* Not enough mana to cast */
2292 if (spell.mana_cost > caster_ptr->csp)
2294 chance += 5 * (spell.mana_cost - caster_ptr->csp);
2300 /* Not enough hp to cast */
2301 if (spell.mana_cost > caster_ptr->chp)
2308 /* Extract the minimum failure rate */
2309 minfail = adj_mag_fail[caster_ptr->stat_ind[mp_ptr->spell_stat]];
2311 /* Minimum failure rate */
2312 if (chance < minfail) chance = minfail;
2314 /* Stunning makes spells harder */
2315 if (caster_ptr->stun > 50) chance += 25;
2316 else if (caster_ptr->stun) chance += 15;
2318 /* Always a 5 percent chance of working */
2319 if (chance > 95) chance = 95;
2322 mindcraft_info(comment, use_mind, i);
2324 /* Dump the spell */
2325 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
2327 spell.min_lev, spell.mana_cost, chance, comment);
2329 Term_putstr(x, y + i + 1, -1, a, psi_desc);
2334 /* Cannot read spellbooks */
2335 if (REALM_NONE == caster_ptr->realm1) return;
2337 /* Normal spellcaster with books */
2340 for (j = 0; j < ((caster_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
2344 /* Reset vertical */
2347 /* Vertical location */
2348 y = (j < 3) ? 0 : (m[j - 3] + 2);
2350 /* Horizontal location */
2354 for (i = 0; i < 32; i++)
2356 byte a = TERM_WHITE;
2358 /* Access the spell */
2359 if (!is_magic((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2))
2361 s_ptr = &technic_info[((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2) - MIN_TECHNIC][i % 32];
2365 s_ptr = &mp_ptr->info[((j < 1) ? caster_ptr->realm1 : caster_ptr->realm2) - 1][i % 32];
2368 strcpy(name, exe_spell(caster_ptr, (j < 1) ? caster_ptr->realm1 : caster_ptr->realm2, i % 32, SPELL_NAME));
2371 if (s_ptr->slevel >= 99)
2374 strcpy(name, _("(判読不能)", "(illegible)"));
2382 ((caster_ptr->spell_forgotten1 & (1L << i))) :
2383 ((caster_ptr->spell_forgotten2 & (1L << (i % 32)))))
2390 else if (!((j < 1) ?
2391 (caster_ptr->spell_learned1 & (1L << i)) :
2392 (caster_ptr->spell_learned2 & (1L << (i % 32)))))
2399 else if (!((j < 1) ?
2400 (caster_ptr->spell_worked1 & (1L << i)) :
2401 (caster_ptr->spell_worked2 & (1L << (i % 32)))))
2407 /* Dump the spell --(-- */
2408 sprintf(out_val, "%c/%c) %-20.20s",
2409 I2A(n / 8), I2A(n % 8), name);
2414 /* Dump onto the window */
2415 Term_putstr(x, m[j], -1, a, out_val);
2425 * @brief 呪文の経験値を返す /
2426 * Returns experience of a spell
2428 * @param use_realm 魔法領域
2431 EXP experience_of_spell(player_type *caster_ptr, SPELL_IDX spell, REALM_IDX use_realm)
2433 if (caster_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
2434 else if (caster_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
2435 else if (use_realm == caster_ptr->realm1) return caster_ptr->spell_exp[spell];
2436 else if (use_realm == caster_ptr->realm2) return caster_ptr->spell_exp[spell + 32];
2442 * @brief 呪文の消費MPを返す /
2443 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
2444 * @param need_mana 基本消費MP
2449 MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm)
2451 #define MANA_CONST 2400
2453 #define DEC_MANA_DIV 3
2456 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
2459 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
2460 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
2462 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(p_ptr, spell, realm)) + (MANA_CONST - 1);
2463 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
2464 need_mana /= MANA_CONST * MANA_DIV;
2465 if (need_mana < 1) need_mana = 1;
2468 /* Non-realm magic */
2471 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
2483 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
2484 * Modify spell fail rate
2485 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2486 * @param chance 修正前失敗率
2490 PERCENTAGE mod_spell_chance_1(player_type *caster_ptr, PERCENTAGE chance)
2492 chance += caster_ptr->to_m_chance;
2494 if (caster_ptr->heavy_spell) chance += 20;
2496 if (caster_ptr->dec_mana && caster_ptr->easy_spell) chance -= 4;
2497 else if (caster_ptr->easy_spell) chance -= 3;
2498 else if (caster_ptr->dec_mana) chance -= 2;
2505 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
2506 * Modify spell fail rate
2507 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2508 * @param chance 修正前失敗率
2510 * Modify spell fail rate (as "suffix" process)
2511 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
2512 * Note: variable "chance" cannot be negative.
2515 PERCENTAGE mod_spell_chance_2(player_type *caster_ptr, PERCENTAGE chance)
2517 if (caster_ptr->dec_mana) chance--;
2518 if (caster_ptr->heavy_spell) chance += 5;
2519 return MAX(chance, 0);
2524 * @brief 呪文の失敗率計算メインルーチン /
2525 * Returns spell chance of failure for spell -RAK-
2527 * @param use_realm 魔法領域ID
2530 PERCENTAGE spell_chance(player_type *caster_ptr, SPELL_IDX spell, REALM_IDX use_realm)
2532 PERCENTAGE chance, minfail;
2533 const magic_type *s_ptr;
2534 MANA_POINT need_mana;
2535 PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
2538 /* Paranoia -- must be literate */
2539 if (!mp_ptr->spell_book) return (100);
2541 if (use_realm == REALM_HISSATSU) return 0;
2543 /* Access the spell */
2544 if (!is_magic(use_realm))
2546 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
2550 s_ptr = &mp_ptr->info[use_realm - 1][spell];
2553 /* Extract the base spell failure rate */
2554 chance = s_ptr->sfail;
2556 /* Reduce failure rate by "effective" level adjustment */
2557 chance -= 3 * (caster_ptr->lev - s_ptr->slevel);
2559 /* Reduce failure rate by INT/WIS adjustment */
2560 chance -= 3 * (adj_mag_stat[caster_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
2562 if (caster_ptr->riding)
2563 chance += (MAX(r_info[caster_ptr->current_floor_ptr->m_list[caster_ptr->riding].r_idx].level - caster_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
2565 /* Extract mana consumption rate */
2566 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
2568 /* Not enough mana to cast */
2569 if (need_mana > caster_ptr->csp)
2571 chance += 5 * (need_mana - caster_ptr->csp);
2574 if ((use_realm != caster_ptr->realm1) && ((caster_ptr->pclass == CLASS_MAGE) || (caster_ptr->pclass == CLASS_PRIEST))) chance += 5;
2576 /* Extract the minimum failure rate */
2577 minfail = adj_mag_fail[caster_ptr->stat_ind[mp_ptr->spell_stat]];
2580 * Non mage/priest characters never get too good
2581 * (added high mage, mindcrafter)
2583 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
2585 if (minfail < 5) minfail = 5;
2588 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
2589 if (((caster_ptr->pclass == CLASS_PRIEST) || (caster_ptr->pclass == CLASS_SORCERER)) && caster_ptr->icky_wield[0]) chance += 25;
2590 if (((caster_ptr->pclass == CLASS_PRIEST) || (caster_ptr->pclass == CLASS_SORCERER)) && caster_ptr->icky_wield[1]) chance += 25;
2592 chance = mod_spell_chance_1(caster_ptr, chance);
2594 /* Goodness or evilness gives a penalty to failure rate */
2598 if ((caster_ptr->align > 50) || (caster_ptr->align < -50)) chance += penalty;
2600 case REALM_LIFE: case REALM_CRUSADE:
2601 if (caster_ptr->align < -20) chance += penalty;
2603 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
2604 if (caster_ptr->align > 20) chance += penalty;
2608 /* Minimum failure rate */
2609 if (chance < minfail) chance = minfail;
2611 /* Stunning makes spells harder */
2612 if (caster_ptr->stun > 50) chance += 25;
2613 else if (caster_ptr->stun) chance += 15;
2615 /* Always a 5 percent chance of working */
2616 if (chance > 95) chance = 95;
2618 if ((use_realm == caster_ptr->realm1) || (use_realm == caster_ptr->realm2)
2619 || (caster_ptr->pclass == CLASS_SORCERER) || (caster_ptr->pclass == CLASS_RED_MAGE))
2621 EXP exp = experience_of_spell(caster_ptr, spell, use_realm);
2622 if (exp >= SPELL_EXP_EXPERT) chance--;
2623 if (exp >= SPELL_EXP_MASTER) chance--;
2626 /* Return the chance */
2627 return mod_spell_chance_2(caster_ptr, chance);
2633 * @brief 呪文情報の表示処理 /
2634 * Print a list of spells (for browsing or casting or viewing)
2635 * @param target_spell 呪文ID
2636 * @param caster_ptr 術者の参照ポインタ
2637 * @param spells 表示するスペルID配列の参照ポインタ
2638 * @param num 表示するスペルの数(spellsの要素数)
2639 * @param y 表示メッセージ左上Y座標
2640 * @param x 表示メッセージ左上X座標
2641 * @param use_realm 魔法領域ID
2644 void print_spells(player_type* caster_ptr, SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm)
2648 int exp_level, increment = 64;
2649 const magic_type *s_ptr;
2654 MANA_POINT need_mana;
2659 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && current_world_ptr->wizard)
2660 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
2662 /* Title the list */
2664 if (use_realm == REALM_HISSATSU)
2665 strcpy(buf,_(" Lv MP", " Lv SP"));
2667 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
2669 put_str(_("名前", "Name"), y, x + 5);
2670 put_str(buf, y, x + 29);
2672 if ((caster_ptr->pclass == CLASS_SORCERER) || (caster_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
2673 else if (use_realm == caster_ptr->realm1) increment = 0;
2674 else if (use_realm == caster_ptr->realm2) increment = 32;
2676 /* Dump the spells */
2677 for (i = 0; i < num; i++)
2681 if (!is_magic(use_realm))
2683 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
2687 s_ptr = &mp_ptr->info[use_realm - 1][spell];
2690 if (use_realm == REALM_HISSATSU)
2691 need_mana = s_ptr->smana;
2694 EXP exp = experience_of_spell(caster_ptr, spell, use_realm);
2696 /* Extract mana consumption rate */
2697 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
2699 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
2700 else exp_level = spell_exp_level(exp);
2703 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
2704 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
2705 else if (s_ptr->slevel >= 99) max = TRUE;
2706 else if ((caster_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
2708 strncpy(ryakuji, exp_level_str[exp_level], 4);
2713 if (use_menu && target_spell)
2715 if (i == (target_spell-1))
2716 strcpy(out_val, _(" 》 ", " > "));
2718 strcpy(out_val, " ");
2720 else sprintf(out_val, " %c) ", I2A(i));
2721 /* Skip illegible spells */
2722 if (s_ptr->slevel >= 99)
2724 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
2725 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
2729 /* XXX XXX Could label spells above the players level */
2731 /* Get extra info */
2732 strcpy(info, exe_spell(caster_ptr, use_realm, spell, SPELL_INFO));
2737 /* Assume spell is known and tried */
2738 line_attr = TERM_WHITE;
2740 /* Analyze the spell */
2741 if ((caster_ptr->pclass == CLASS_SORCERER) || (caster_ptr->pclass == CLASS_RED_MAGE))
2743 if (s_ptr->slevel > caster_ptr->max_plv)
2745 comment = _("未知", "unknown");
2746 line_attr = TERM_L_BLUE;
2748 else if (s_ptr->slevel > caster_ptr->lev)
2750 comment = _("忘却", "forgotten");
2751 line_attr = TERM_YELLOW;
2754 else if ((use_realm != caster_ptr->realm1) && (use_realm != caster_ptr->realm2))
2756 comment = _("未知", "unknown");
2757 line_attr = TERM_L_BLUE;
2759 else if ((use_realm == caster_ptr->realm1) ?
2760 ((caster_ptr->spell_forgotten1 & (1L << spell))) :
2761 ((caster_ptr->spell_forgotten2 & (1L << spell))))
2763 comment = _("忘却", "forgotten");
2764 line_attr = TERM_YELLOW;
2766 else if (!((use_realm == caster_ptr->realm1) ?
2767 (caster_ptr->spell_learned1 & (1L << spell)) :
2768 (caster_ptr->spell_learned2 & (1L << spell))))
2770 comment = _("未知", "unknown");
2771 line_attr = TERM_L_BLUE;
2773 else if (!((use_realm == caster_ptr->realm1) ?
2774 (caster_ptr->spell_worked1 & (1L << spell)) :
2775 (caster_ptr->spell_worked2 & (1L << spell))))
2777 comment = _("未経験", "untried");
2778 line_attr = TERM_L_GREEN;
2781 /* Dump the spell --(-- */
2782 if (use_realm == REALM_HISSATSU)
2784 strcat(out_val, format("%-25s %2d %4d",
2785 exe_spell(caster_ptr, use_realm, spell, SPELL_NAME), /* realm, spell */
2786 s_ptr->slevel, need_mana));
2790 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
2791 exe_spell(caster_ptr, use_realm, spell, SPELL_NAME), /* realm, spell */
2792 (max ? '!' : ' '), ryakuji,
2793 s_ptr->slevel, need_mana, spell_chance(caster_ptr, spell, use_realm), comment));
2795 c_prt(line_attr, out_val, y + i + 1, x);
2798 /* Clear the bottom line */
2799 prt("", y + i + 1, x);
2803 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
2804 * Helper function -- return a "nearby" race for polymorphing
2805 * @param r_idx 基準となるモンスター種族ID
2806 * @return 変更先のモンスター種族ID
2808 * Note that this function is one of the more "dangerous" ones...
2810 static MONRACE_IDX poly_r_idx(MONRACE_IDX r_idx)
2812 monster_race *r_ptr = &r_info[r_idx];
2818 /* Hack -- Uniques/Questors never polymorph */
2819 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
2822 /* Allowable range of "levels" for resulting monster */
2823 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
2824 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
2826 /* Pick a (possibly new) non-unique race */
2827 for (i = 0; i < 1000; i++)
2829 /* Pick a new race, using a level calculation */
2830 r = get_mon_num((p_ptr->current_floor_ptr->dun_level + r_ptr->level) / 2 + 5);
2832 /* Handle failure */
2837 /* Ignore unique monsters */
2838 if (r_ptr->flags1 & RF1_UNIQUE) continue;
2840 /* Ignore monsters with incompatible levels */
2841 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
2843 /* Use that index */
2852 * @brief 指定座標にいるモンスターを変身させる /
2853 * Helper function -- return a "nearby" race for polymorphing
2856 * @return 実際に変身したらTRUEを返す
2858 bool polymorph_monster(player_type *caster_ptr, POSITION y, POSITION x)
2860 grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
2861 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
2862 bool polymorphed = FALSE;
2863 MONRACE_IDX new_r_idx;
2864 MONRACE_IDX old_r_idx = m_ptr->r_idx;
2865 bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE;
2866 bool health_tracked = (caster_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
2867 monster_type back_m;
2869 if (caster_ptr->current_floor_ptr->inside_arena || caster_ptr->phase_out) return (FALSE);
2871 if ((caster_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
2873 /* Memorize the monster before polymorphing */
2876 /* Pick a "new" monster race */
2877 new_r_idx = poly_r_idx(old_r_idx);
2879 /* Handle polymorph */
2880 if (new_r_idx != old_r_idx)
2882 BIT_FLAGS mode = 0L;
2883 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
2884 OBJECT_IDX this_o_idx, next_o_idx = 0;
2886 /* Get the monsters attitude */
2887 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
2888 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
2889 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
2891 /* Mega-hack -- ignore held objects */
2892 m_ptr->hold_o_idx = 0;
2894 /* "Kill" the "old" monster */
2895 delete_monster_idx(g_ptr->m_idx);
2897 /* Create a new monster (no groups) */
2898 if (place_monster_aux(0, y, x, new_r_idx, mode))
2900 caster_ptr->current_floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname;
2901 caster_ptr->current_floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
2902 caster_ptr->current_floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
2909 /* Placing the new monster failed */
2910 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
2912 caster_ptr->current_floor_ptr->m_list[hack_m_idx_ii] = back_m;
2914 /* Re-initialize monster process */
2917 else preserve_hold_objects = FALSE;
2920 /* Mega-hack -- preserve held objects */
2921 if (preserve_hold_objects)
2923 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
2925 object_type *o_ptr = &caster_ptr->current_floor_ptr->o_list[this_o_idx];
2926 next_o_idx = o_ptr->next_o_idx;
2928 /* Held by new monster */
2929 o_ptr->held_m_idx = hack_m_idx_ii;
2932 else if (back_m.hold_o_idx) /* Failed (paranoia) */
2934 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
2936 next_o_idx = caster_ptr->current_floor_ptr->o_list[this_o_idx].next_o_idx;
2937 delete_object_idx(this_o_idx);
2941 if (targeted) target_who = hack_m_idx_ii;
2942 if (health_tracked) health_track(hack_m_idx_ii);
2951 * @param x テレポート先のX座標
2952 * @param y テレポート先のY座標
2953 * @return 目標に指定通りテレポートできたならばTRUEを返す
2955 static bool dimension_door_aux(DEPTH x, DEPTH y)
2957 PLAYER_LEVEL plev = p_ptr->lev;
2959 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
2961 if (!cave_player_teleportable_bold(y, x, 0L) ||
2962 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
2963 (!randint0(plev / 10 + 10)))
2965 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
2966 teleport_player(p_ptr, (plev + 2) * 2, TELEPORT_PASSIVE);
2973 teleport_player_to(p_ptr, y, x, 0L);
2982 * @brief 次元の扉処理のメインルーチン /
2984 * @return ターンを消費した場合TRUEを返す
2986 bool dimension_door(void)
2990 /* Rerutn FALSE if cancelled */
2991 if (!tgt_pt(&x, &y)) return FALSE;
2993 if (dimension_door_aux(x, y)) return TRUE;
2995 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
3002 * @brief 鏡抜け処理のメインルーチン /
3003 * Mirror Master's Dimension Door
3004 * @return ターンを消費した場合TRUEを返す
3006 bool mirror_tunnel(void)
3008 POSITION x = 0, y = 0;
3010 /* Rerutn FALSE if cancelled */
3011 if (!tgt_pt(&x, &y)) return FALSE;
3013 if (dimension_door_aux(x, y)) return TRUE;
3015 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
3023 * @return ターンを消費した場合TRUEを返す
3025 bool eat_magic(player_type *caster_ptr, int power)
3031 int recharge_strength = 0;
3037 GAME_TEXT o_name[MAX_NLEN];
3039 item_tester_hook = item_tester_hook_recharge;
3041 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
3042 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
3044 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
3045 if (!o_ptr) return FALSE;
3047 k_ptr = &k_info[o_ptr->k_idx];
3048 lev = k_info[o_ptr->k_idx].level;
3050 if (o_ptr->tval == TV_ROD)
3052 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3055 if (one_in_(recharge_strength))
3057 /* Activate the failure code. */
3062 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
3064 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
3068 caster_ptr->csp += lev;
3069 o_ptr->timeout += k_ptr->pval;
3075 /* All staffs, wands. */
3076 recharge_strength = (100 + power - lev) / 15;
3077 if (recharge_strength < 0) recharge_strength = 0;
3080 if (one_in_(recharge_strength))
3082 /* Activate the failure code. */
3087 if (o_ptr->pval > 0)
3089 caster_ptr->csp += lev / 2;
3092 /* XXX Hack -- unstack if necessary */
3093 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
3098 object_copy(q_ptr, o_ptr);
3100 /* Modify quantity */
3103 /* Restore the charges */
3106 /* Unstack the used item */
3108 caster_ptr->total_weight -= q_ptr->weight;
3109 item = inven_carry(q_ptr);
3111 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
3116 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
3118 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
3122 /* Inflict the penalties for failing a recharge. */
3125 /* Artifacts are never destroyed. */
3126 if (object_is_fixed_artifact(o_ptr))
3128 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3129 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
3131 /* Artifact rods. */
3132 if (o_ptr->tval == TV_ROD)
3133 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3135 /* Artifact wands and staffs. */
3136 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3141 /* Get the object description */
3142 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3144 /*** Determine Seriousness of Failure ***/
3146 /* Mages recharge objects more safely. */
3147 if (IS_WIZARD_CLASS(caster_ptr))
3149 /* 10% chance to blow up one rod, otherwise draining. */
3150 if (o_ptr->tval == TV_ROD)
3152 if (one_in_(10)) fail_type = 2;
3155 /* 75% chance to blow up one wand, otherwise draining. */
3156 else if (o_ptr->tval == TV_WAND)
3158 if (!one_in_(3)) fail_type = 2;
3161 /* 50% chance to blow up one staff, otherwise no effect. */
3162 else if (o_ptr->tval == TV_STAFF)
3164 if (one_in_(2)) fail_type = 2;
3169 /* All other classes get no special favors. */
3172 /* 33% chance to blow up one rod, otherwise draining. */
3173 if (o_ptr->tval == TV_ROD)
3175 if (one_in_(3)) fail_type = 2;
3178 /* 20% chance of the entire stack, else destroy one wand. */
3179 else if (o_ptr->tval == TV_WAND)
3181 if (one_in_(5)) fail_type = 3;
3184 /* Blow up one staff. */
3185 else if (o_ptr->tval == TV_STAFF)
3191 /*** Apply draining and destruction. ***/
3193 /* Drain object or stack of objects. */
3196 if (o_ptr->tval == TV_ROD)
3198 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
3199 "You save your rod from destruction, but all charges are lost."), o_name);
3200 o_ptr->timeout = k_ptr->pval * o_ptr->number;
3202 else if (o_ptr->tval == TV_WAND)
3204 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
3207 /* Staffs aren't drained. */
3210 /* Destroy an object or one in a stack of objects. */
3213 if (o_ptr->number > 1)
3215 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
3216 /* Reduce rod stack maximum timeout, drain wands. */
3217 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
3218 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
3222 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
3225 /* Reduce and describe caster_ptr->inventory_list */
3228 inven_item_increase(item, -1);
3229 inven_item_describe(item);
3230 inven_item_optimize(item);
3233 /* Reduce and describe floor item */
3236 floor_item_increase(0 - item, -1);
3237 floor_item_describe(0 - item);
3238 floor_item_optimize(0 - item);
3242 /* Destroy all members of a stack of objects. */
3245 if (o_ptr->number > 1)
3246 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
3248 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
3250 /* Reduce and describe caster_ptr->inventory_list */
3253 inven_item_increase(item, -999);
3254 inven_item_describe(item);
3255 inven_item_optimize(item);
3258 /* Reduce and describe floor item */
3261 floor_item_increase(0 - item, -999);
3262 floor_item_describe(0 - item);
3263 floor_item_optimize(0 - item);
3269 if (caster_ptr->csp > caster_ptr->msp)
3271 caster_ptr->csp = caster_ptr->msp;
3274 caster_ptr->redraw |= (PR_MANA);
3275 caster_ptr->update |= (PU_COMBINE | PU_REORDER);
3276 caster_ptr->window |= (PW_INVEN);
3283 * @brief 皆殺し(全方向攻撃)処理
3284 * @param py プレイヤーY座標
3285 * @param px プレイヤーX座標
3288 void massacre(player_type *caster_ptr)
3292 monster_type *m_ptr;
3295 for (dir = 0; dir < 8; dir++)
3297 y = caster_ptr->y + ddy_ddd[dir];
3298 x = caster_ptr->x + ddx_ddd[dir];
3299 g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
3300 m_ptr = &caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
3302 /* Hack -- attack monsters */
3303 if (g_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
3304 py_attack(caster_ptr, y, x, 0);
3308 bool eat_lock(player_type *caster_ptr)
3312 feature_type *f_ptr, *mimic_f_ptr;
3315 if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
3316 y = caster_ptr->y + ddy[dir];
3317 x = caster_ptr->x + ddx[dir];
3318 g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
3319 f_ptr = &f_info[g_ptr->feat];
3320 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
3324 if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
3326 msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
3328 else if (have_flag(f_ptr->flags, FF_PERMANENT))
3330 msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch! This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
3332 else if (g_ptr->m_idx)
3334 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
3335 msg_print(_("何かが邪魔しています!", "There's something in the way!"));
3337 if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(caster_ptr, y, x, 0);
3339 else if (have_flag(f_ptr->flags, FF_TREE))
3341 msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
3343 else if (have_flag(f_ptr->flags, FF_GLASS))
3345 msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
3347 else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
3349 (void)set_food(caster_ptr, caster_ptr->food + 3000);
3351 else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
3353 (void)set_food(caster_ptr, caster_ptr->food + 5000);
3357 msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
3358 (void)set_food(caster_ptr, caster_ptr->food + 10000);
3361 /* Destroy the wall */
3362 cave_alter_feat(y, x, FF_HURT_ROCK);
3364 (void)move_player_effect(caster_ptr, y, x, MPE_DONT_PICKUP);
3369 bool shock_power(player_type *caster_ptr)
3374 PLAYER_LEVEL plev = caster_ptr->lev;
3375 int boost = P_PTR_KI;
3376 if (heavy_armor(caster_ptr)) boost /= 2;
3379 if (!get_aim_dir(&dir)) return FALSE;
3381 y = caster_ptr->y + ddy[dir];
3382 x = caster_ptr->x + ddx[dir];
3383 dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
3384 fire_beam(GF_MISSILE, dir, dam);
3385 if (caster_ptr->current_floor_ptr->grid_array[y][x].m_idx)
3388 POSITION ty = y, tx = x;
3389 POSITION oy = y, ox = x;
3390 MONSTER_IDX m_idx = caster_ptr->current_floor_ptr->grid_array[y][x].m_idx;
3391 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
3392 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3393 GAME_TEXT m_name[MAX_NLEN];
3395 monster_desc(m_name, m_ptr, 0);
3397 if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2)
3399 msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
3403 for (i = 0; i < 5; i++)
3407 if (cave_empty_bold(caster_ptr->current_floor_ptr, y, x))
3414 if ((ty != oy) || (tx != ox))
3416 msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
3417 caster_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
3418 caster_ptr->current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
3422 update_monster(caster_ptr, m_idx, TRUE);
3426 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
3427 caster_ptr->update |= (PU_MON_LITE);
3434 bool booze(player_type *creature_ptr)
3437 if (creature_ptr->pclass != CLASS_MONK) chg_virtue(p_ptr, V_HARMONY, -1);
3438 else if (!creature_ptr->resist_conf) creature_ptr->special_attack |= ATTACK_SUIKEN;
3439 if (!creature_ptr->resist_conf)
3441 if (set_confused(p_ptr, randint0(20) + 15))
3447 if (!creature_ptr->resist_chaos)
3451 if (set_image(p_ptr, creature_ptr->image + randint0(150) + 150))
3456 if (one_in_(13) && (creature_ptr->pclass != CLASS_MONK))
3459 if (one_in_(3)) lose_all_info(p_ptr);
3460 else wiz_dark(creature_ptr);
3461 (void)teleport_player_aux(creature_ptr, 100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
3462 wiz_dark(creature_ptr);
3463 msg_print(_("知らない場所で目が醒めた。頭痛がする。", "You wake up somewhere with a sore head..."));
3464 msg_print(_("何も思い出せない。どうやってここへ来たのかも分からない!", "You can't remember a thing, or how you got here!"));
3470 bool detonation(player_type *creature_ptr)
3472 msg_print(_("体の中で激しい爆発が起きた!", "Massive explosions rupture your body!"));
3473 take_hit(p_ptr, DAMAGE_NOESCAPE, damroll(50, 20), _("爆発の薬", "a potion of Detonation"), -1);
3474 (void)set_stun(p_ptr, creature_ptr->stun + 75);
3475 (void)set_cut(p_ptr,creature_ptr->cut + 5000);
3479 void blood_curse_to_enemy(player_type *caster_ptr, MONSTER_IDX m_idx)
3481 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
3482 grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
3483 BIT_FLAGS curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
3487 switch (randint1(28))
3492 msg_print(_("地面が揺れた...", "The ground trembles..."));
3493 earthquake(caster_ptr, m_ptr->fy, m_ptr->fx, 4 + randint0(4), 0);
3494 if (!one_in_(6)) break;
3496 case 3: case 4: case 5: case 6:
3499 int extra_dam = damroll(10, 10);
3500 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
3502 project(0, 8, m_ptr->fy, m_ptr->fx, extra_dam, GF_MANA, curse_flg, -1);
3503 if (!one_in_(6)) break;
3508 msg_print(_("空間が歪んだ!", "Space warps about you!"));
3510 if (m_ptr->r_idx) teleport_away(caster_ptr, g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
3511 if (one_in_(13)) count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3512 if (!one_in_(6)) break;
3514 case 9: case 10: case 11:
3515 msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
3516 project(0, 7, m_ptr->fy, m_ptr->fx, 50, GF_DISINTEGRATE, curse_flg, -1);
3517 if (!one_in_(6)) break;
3518 case 12: case 13: case 14: case 15: case 16:
3519 aggravate_monsters(0);
3520 if (!one_in_(6)) break;
3522 count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
3523 if (!one_in_(6)) break;
3524 case 19: case 20: case 21: case 22:
3526 bool pet = !one_in_(3);
3527 BIT_FLAGS mode = PM_ALLOW_GROUP;
3529 if (pet) mode |= PM_FORCE_PET;
3530 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
3532 count += summon_specific((pet ? -1 : 0), caster_ptr->y, caster_ptr->x, (pet ? caster_ptr->lev * 2 / 3 + randint1(caster_ptr->lev / 2) : caster_ptr->current_floor_ptr->dun_level), 0, mode);
3533 if (!one_in_(6)) break;
3535 case 23: case 24: case 25:
3536 if (caster_ptr->hold_exp && (randint0(100) < 75)) break;
3537 msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
3539 if (caster_ptr->hold_exp) lose_exp(caster_ptr, caster_ptr->exp / 160);
3540 else lose_exp(caster_ptr, caster_ptr->exp / 16);
3541 if (!one_in_(6)) break;
3542 case 26: case 27: case 28:
3551 (void)do_dec_stat(caster_ptr, i);
3552 } while (one_in_(2));
3559 (void)do_dec_stat(caster_ptr, randint0(6));
3564 } while (one_in_(5));
3568 * @brief クリムゾンを発射する / Fire Crimson, evoluting gun.
3569 @ @param shooter_ptr 射撃を行うクリーチャー参照
3570 * @return キャンセルした場合 false.
3572 * Need to analyze size of the window.
3573 * Need more color coding.
3575 bool fire_crimson(player_type *shooter_ptr)
3579 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
3583 if (!get_aim_dir(&dir)) return FALSE;
3585 /* Use the given direction */
3586 tx = shooter_ptr->x + 99 * ddx[dir];
3587 ty = shooter_ptr->y + 99 * ddy[dir];
3589 /* Hack -- Use an actual "target" */
3590 if ((dir == 5) && target_okay())
3596 if (shooter_ptr->pclass == CLASS_ARCHER)
3598 /* Extra shot at level 10 */
3599 if (shooter_ptr->lev >= 10) num++;
3601 /* Extra shot at level 30 */
3602 if (shooter_ptr->lev >= 30) num++;
3604 /* Extra shot at level 45 */
3605 if (shooter_ptr->lev >= 45) num++;
3608 for (i = 0; i < num; i++)
3609 project(0, shooter_ptr->lev / 20 + 1, ty, tx, shooter_ptr->lev*shooter_ptr->lev * 6 / 50, GF_ROCKET, flg, -1);
3616 * @brief 町間のテレポートを行うメインルーチン。
3617 * @return テレポート処理を決定したか否か
3619 bool tele_town(player_type *caster_ptr)
3625 if (caster_ptr->current_floor_ptr->dun_level)
3627 msg_print(_("この魔法は地上でしか使えない!", "This spell can only be used on the surface!"));
3631 if (caster_ptr->current_floor_ptr->inside_arena || caster_ptr->phase_out)
3633 msg_print(_("この魔法は外でしか使えない!", "This spell can only be used outside!"));
3640 for (i = 1; i < max_towns; i++)
3644 if ((i == NO_TOWN) || (i == SECRET_TOWN) || (i == caster_ptr->town_num) || !(caster_ptr->visit & (1L << (i - 1)))) continue;
3646 sprintf(buf, "%c) %-20s", I2A(i - 1), town_info[i].name);
3653 msg_print(_("まだ行けるところがない。", "You have not yet visited any town."));
3659 prt(_("どこに行きますか:", "Which town you go: "), 0, 0);
3669 else if ((i < 'a') || (i > ('a' + max_towns - 2))) continue;
3670 else if (((i - 'a' + 1) == caster_ptr->town_num) || ((i - 'a' + 1) == NO_TOWN) || ((i - 'a' + 1) == SECRET_TOWN) || !(caster_ptr->visit & (1L << (i - 'a')))) continue;
3674 for (y = 0; y < current_world_ptr->max_wild_y; y++)
3676 for (x = 0; x < current_world_ptr->max_wild_x; x++)
3678 if (wilderness[y][x].town == (i - 'a' + 1))
3680 caster_ptr->wilderness_y = y;
3681 caster_ptr->wilderness_x = x;
3686 caster_ptr->leaving = TRUE;
3687 caster_ptr->leave_bldg = TRUE;
3688 caster_ptr->teleport_town = TRUE;