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-hook.h"
18 #include "player-status.h"
19 #include "projection.h"
20 #include "spells-summon.h"
24 #include "spells-floor.h"
27 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
32 * @brief モンスターのテレポートアウェイ処理 /
33 * Teleport a monster, normally up to "dis" grids away.
34 * @param m_idx モンスターID
37 * @return テレポートが実際に行われたらtrue
39 * Attempt to move the monster at least "dis/2" grids away.
40 * But allow variation to prevent infinite loops.
42 bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
44 POSITION oy, ox, d, i, min;
46 POSITION ny = 0, nx = 0;
50 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
53 if (!m_ptr->r_idx) return (FALSE);
58 /* Minimum distance */
61 if ((mode & TELEPORT_DEC_VALOUR) &&
62 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
63 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
65 chg_virtue(V_VALOUR, -1);
73 /* Verify max distance */
74 if (dis > 200) dis = 200;
76 /* Try several locations */
77 for (i = 0; i < 500; i++)
79 /* Pick a (possibly illegal) location */
82 ny = rand_spread(oy, dis);
83 nx = rand_spread(ox, dis);
84 d = distance(oy, ox, ny, nx);
85 if ((d >= min) && (d <= dis)) break;
88 /* Ignore illegal locations */
89 if (!in_bounds(ny, nx)) continue;
91 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
93 /* No teleporting into vaults and such */
94 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
95 if (current_floor_ptr->grid_array[ny][nx].info & CAVE_ICKY) continue;
97 /* This grid looks good */
104 /* Increase the maximum distance */
107 /* Decrease the minimum distance */
110 /* Stop after MAX_TRIES tries */
111 if (tries > MAX_TRIES) return (FALSE);
114 sound(SOUND_TPOTHER);
116 /* Update the old location */
117 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
119 /* Update the new location */
120 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
122 /* Move the monster */
126 /* Forget the counter target */
129 update_monster(m_idx, TRUE);
133 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
134 p_ptr->update |= (PU_MON_LITE);
141 * @brief モンスターを指定された座標付近にテレポートする /
142 * Teleport monster next to a grid near the given location
143 * @param m_idx モンスターID
146 * @param power テレポート成功確率
150 void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, BIT_FLAGS mode)
152 POSITION ny, nx, oy, ox;
157 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
160 if(!m_ptr->r_idx) return;
163 if(randint1(100) > power) return;
170 /* Minimum distance */
173 /* Look until done */
174 while (look && --attempts)
176 /* Verify max distance */
177 if (dis > 200) dis = 200;
179 /* Try several locations */
180 for (i = 0; i < 500; i++)
182 /* Pick a (possibly illegal) location */
185 ny = rand_spread(ty, dis);
186 nx = rand_spread(tx, dis);
187 d = distance(ty, tx, ny, nx);
188 if ((d >= min) && (d <= dis)) break;
191 /* Ignore illegal locations */
192 if (!in_bounds(ny, nx)) continue;
194 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
196 /* No teleporting into vaults and such */
197 /* if (current_floor_ptr->grid_array[ny][nx].info & (CAVE_ICKY)) continue; */
199 /* This grid looks good */
206 /* Increase the maximum distance */
209 /* Decrease the minimum distance */
213 if (attempts < 1) return;
215 sound(SOUND_TPOTHER);
217 /* Update the old location */
218 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
220 /* Update the new location */
221 current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
223 /* Move the monster */
227 update_monster(m_idx, TRUE);
231 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
232 p_ptr->update |= (PU_MON_LITE);
236 * @brief プレイヤーのテレポート先選定と移動処理 /
237 * Teleport the player to a location up to "dis" grids away.
240 * @return 実際にテレポート処理が行われたらtrue
243 * If no such spaces are readily available, the distance may increase.
244 * Try very hard to move the player at least a quarter that distance.
246 * There was a nasty tendency for a long time; which was causing the
247 * player to "bounce" between two or three different spots because
248 * these are the only spots that are "far enough" way to satisfy the
251 * But this tendency is now removed; in the new algorithm, a list of
252 * candidates is selected first, which includes at least 50% of all
253 * floor grids within the distance, and any single grid in this list
254 * of candidates has equal possibility to be choosen as a destination.
258 bool teleport_player_aux(POSITION dis, BIT_FLAGS mode)
260 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
261 int total_candidates, cur_candidates;
262 POSITION y = 0, x = 0;
265 int left = MAX(1, p_ptr->x - dis);
266 int right = MIN(current_floor_ptr->width - 2, p_ptr->x + dis);
267 int top = MAX(1, p_ptr->y - dis);
268 int bottom = MIN(current_floor_ptr->height - 2, p_ptr->y + dis);
270 if (p_ptr->wild_mode) return FALSE;
272 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
274 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
278 /* Initialize counters */
279 total_candidates = 0;
280 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
281 candidates_at[i] = 0;
283 /* Limit the distance */
284 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
286 /* Search valid locations */
287 for (y = top; y <= bottom; y++)
289 for (x = left; x <= right; x++)
293 /* Skip illegal locations */
294 if (!cave_player_teleportable_bold(y, x, mode)) continue;
296 /* Calculate distance */
297 d = distance(p_ptr->y, p_ptr->x, y, x);
299 /* Skip too far locations */
300 if (d > dis) continue;
302 /* Count the total number of candidates */
305 /* Count the number of candidates in this circumference */
310 /* No valid location! */
311 if (0 == total_candidates) return FALSE;
313 /* Fix the minimum distance */
314 for (cur_candidates = 0, min = dis; min >= 0; min--)
316 cur_candidates += candidates_at[min];
318 /* 50% of all candidates will have an equal chance to be choosen. */
319 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
322 /* Pick up a single location randomly */
323 pick = randint1(cur_candidates);
325 /* Search again the choosen location */
326 for (y = top; y <= bottom; y++)
328 for (x = left; x <= right; x++)
332 /* Skip illegal locations */
333 if (!cave_player_teleportable_bold(y, x, mode)) continue;
335 /* Calculate distance */
336 d = distance(p_ptr->y, p_ptr->x, y, x);
338 /* Skip too far locations */
339 if (d > dis) continue;
341 /* Skip too close locations */
342 if (d < min) continue;
344 /* This grid was picked up? */
353 if (player_bold(y, x)) return FALSE;
355 sound(SOUND_TELEPORT);
358 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
359 msg_format("『こっちだぁ、%s』", p_ptr->name);
362 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
367 * @brief プレイヤーのテレポート処理メインルーチン
372 void teleport_player(POSITION dis, BIT_FLAGS mode)
375 POSITION oy = p_ptr->y;
376 POSITION ox = p_ptr->x;
378 if (!teleport_player_aux(dis, mode)) return;
380 /* Monsters with teleport ability may follow the player */
381 for (xx = -1; xx < 2; xx++)
383 for (yy = -1; yy < 2; yy++)
385 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
387 /* A monster except your mount may follow */
388 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
390 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
391 monster_race *r_ptr = &r_info[m_ptr->r_idx];
394 * The latter limitation is to avoid
395 * totally unkillable suckers...
397 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
398 !(r_ptr->flagsr & RFR_RES_TELE))
400 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
409 * @brief プレイヤーのテレポートアウェイ処理 /
410 * @param m_idx アウェイを試みたプレイヤーID
414 void teleport_player_away(MONSTER_IDX m_idx, POSITION dis)
417 POSITION oy = p_ptr->y;
418 POSITION ox = p_ptr->x;
420 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
422 /* Monsters with teleport ability may follow the player */
423 for (xx = -1; xx < 2; xx++)
425 for (yy = -1; yy < 2; yy++)
427 MONSTER_IDX tmp_m_idx = current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
429 /* A monster except your mount or caster may follow */
430 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
432 monster_type *m_ptr = ¤t_floor_ptr->m_list[tmp_m_idx];
433 monster_race *r_ptr = &r_info[m_ptr->r_idx];
436 * The latter limitation is to avoid
437 * totally unkillable suckers...
439 if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
440 !(r_ptr->flagsr & RFR_RES_TELE))
442 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
451 * @brief プレイヤーを指定位置近辺にテレポートさせる
452 * Teleport player to a grid near the given location
455 * @param mode オプションフラグ
459 * This function is slightly obsessive about correctness.
460 * This function allows teleporting into vaults (!)
463 void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
466 POSITION dis = 0, ctr = 0;
468 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
470 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
474 /* Find a usable location */
477 /* Pick a nearby legal location */
480 y = (POSITION)rand_spread(ny, dis);
481 x = (POSITION)rand_spread(nx, dis);
482 if (in_bounds(y, x)) break;
485 /* Accept any grid when wizard mode */
486 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;
488 /* Accept teleportable floor grids */
489 if (cave_player_teleportable_bold(y, x, mode)) break;
491 /* Occasionally advance the distance */
492 if (++ctr > (4 * dis * dis + 4 * dis + 1))
499 sound(SOUND_TELEPORT);
500 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
504 void teleport_away_followable(MONSTER_IDX m_idx)
506 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
507 POSITION oldfy = m_ptr->fy;
508 POSITION oldfx = m_ptr->fx;
509 bool old_ml = m_ptr->ml;
510 POSITION old_cdis = m_ptr->cdis;
512 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
514 if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && !p_ptr->inside_battle && los(p_ptr->y, p_ptr->x, oldfy, oldfx))
518 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
521 BIT_FLAGS flgs[TR_FLAG_SIZE];
525 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
527 o_ptr = &inventory[i];
528 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
530 object_flags(o_ptr, flgs);
531 if (have_flag(flgs, TR_TELEPORT))
542 if (get_check_strict(_("ついていきますか?", "Do you follow it? "), CHECK_OKAY_CANCEL))
546 teleport_player(200, TELEPORT_PASSIVE);
547 msg_print(_("失敗!", "Failed!"));
549 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
550 p_ptr->energy_need += ENERGY_NEED();
557 bool teleport_level_other(player_type *creature_ptr)
559 MONSTER_IDX target_m_idx;
562 GAME_TEXT m_name[MAX_NLEN];
564 if (!target_set(TARGET_KILL)) return FALSE;
565 target_m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
566 if (!target_m_idx) return TRUE;
567 if (!player_has_los_bold(target_row, target_col)) return TRUE;
568 if (!projectable(creature_ptr->y, creature_ptr->x, target_row, target_col)) return TRUE;
569 m_ptr = ¤t_floor_ptr->m_list[target_m_idx];
570 r_ptr = &r_info[m_ptr->r_idx];
571 monster_desc(m_name, m_ptr, 0);
572 msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
574 if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
575 (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > creature_ptr->lev + randint1(60)))
577 msg_format(_("しかし効果がなかった!", "%^s is unaffected!"), m_name);
579 else teleport_level(target_m_idx);
584 * @brief プレイヤー及びモンスターをレベルテレポートさせる /
585 * Teleport the player one level up or down (random when legal)
586 * @param m_idx テレポートの対象となるモンスターID(0ならばプレイヤー) / If m_idx <= 0, target is player.
589 void teleport_level(MONSTER_IDX m_idx)
592 GAME_TEXT m_name[160];
595 if (m_idx <= 0) /* To player */
597 strcpy(m_name, _("あなた", "you"));
599 else /* To monster */
601 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
603 /* Get the monster name (or "it") */
604 monster_desc(m_name, m_ptr, 0);
606 see_m = is_seen(m_ptr);
609 /* No effect in some case */
610 if (TELE_LEVEL_IS_INEFF(m_idx))
612 if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
616 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
618 msg_print(_("不思議な力がテレポートを防いだ!", "A mysterious force prevents you from teleporting!"));
622 /* Choose up or down */
623 if (randint0(100) < 50) go_up = TRUE;
626 if ((m_idx <= 0) && p_ptr->wizard)
628 if (get_check("Force to go up? ")) go_up = TRUE;
629 else if (get_check("Force to go down? ")) go_up = FALSE;
633 if ((ironman_downward && (m_idx <= 0)) || (current_floor_ptr->dun_level <= d_info[p_ptr->dungeon_idx].mindepth))
636 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
638 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
640 if (m_idx <= 0) /* To player */
642 if (!current_floor_ptr->dun_level)
644 p_ptr->dungeon_idx = ironman_downward ? DUNGEON_ANGBAND : p_ptr->recall_dungeon;
645 p_ptr->oldpy = p_ptr->y;
646 p_ptr->oldpx = p_ptr->x;
649 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
651 if (autosave_l) do_cmd_save_game(TRUE);
653 if (!current_floor_ptr->dun_level)
655 current_floor_ptr->dun_level = d_info[p_ptr->dungeon_idx].mindepth;
656 prepare_change_floor_mode(CFM_RAND_PLACE);
660 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);
689 p_ptr->inside_quest = 0;
690 p_ptr->leaving = TRUE;
696 if (see_m) msg_format("%^sは天井を突き破って宙へ浮いていく。", m_name);
698 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
702 if (m_idx <= 0) /* To player */
704 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
706 if (autosave_l) do_cmd_save_game(TRUE);
708 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
711 p_ptr->leaving = TRUE;
717 if (see_m) msg_format("%^sは床を突き破って沈んでいく。", m_name);
719 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
722 if (m_idx <= 0) /* To player */
724 /* Never reach this code on the surface */
725 /* if (!current_floor_ptr->dun_level) p_ptr->dungeon_idx = p_ptr->recall_dungeon; */
727 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
729 if (autosave_l) do_cmd_save_game(TRUE);
731 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
734 p_ptr->leaving = TRUE;
738 /* Monster level teleportation is simple deleting now */
741 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
743 /* Check for quest completion */
744 check_quest_completion(m_ptr);
746 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
748 char m2_name[MAX_NLEN];
750 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
751 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
754 delete_monster_idx(m_idx);
757 sound(SOUND_TPLEVEL);
762 * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
763 * @param note ダンジョンに施す処理記述
766 * @return 選択されたダンジョンID
768 DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x)
770 DUNGEON_IDX select_dungeon;
775 /* Hack -- No need to choose dungeon in some case */
776 if (lite_town || vanilla_town || ironman_downward)
778 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
781 msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
787 /* Allocate the "dun" array */
788 C_MAKE(dun, max_d_idx, DUNGEON_IDX);
791 for(i = 1; i < max_d_idx; i++)
796 if (!d_info[i].maxdepth) continue;
797 if (!max_dlv[i]) continue;
798 if (d_info[i].final_guardian)
800 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
802 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
804 sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
805 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
806 prt(buf, y + num, x);
812 prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
815 prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
819 if ((i == ESCAPE) || !num)
821 /* Free the "dun" array */
822 C_KILL(dun, max_d_idx, DUNGEON_IDX);
827 if (i >= 'a' && i <('a'+num))
829 select_dungeon = dun[i-'a'];
836 /* Free the "dun" array */
837 C_KILL(dun, max_d_idx, DUNGEON_IDX);
839 return select_dungeon;
844 * @brief プレイヤーの帰還発動及び中止処理 /
845 * Recall the player to town or dungeon
846 * @param turns 発動までのターン数
849 bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
852 * TODO: Recall the player to the last
853 * visited town when in the wilderness
857 if (creature_ptr->inside_arena || ironman_downward)
859 msg_print(_("何も起こらなかった。", "Nothing happens."));
863 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)
865 if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
867 max_dlv[p_ptr->dungeon_idx] = current_floor_ptr->dun_level;
869 do_cmd_write_nikki(NIKKI_TRUMP, p_ptr->dungeon_idx, _("帰還のときに", "when recall from dungeon"));
873 if (!creature_ptr->word_recall)
875 if (!current_floor_ptr->dun_level)
877 DUNGEON_IDX select_dungeon;
878 select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
879 if (!select_dungeon) return FALSE;
880 creature_ptr->recall_dungeon = select_dungeon;
882 creature_ptr->word_recall = turns;
883 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
884 creature_ptr->redraw |= (PR_STATUS);
888 creature_ptr->word_recall = 0;
889 msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
890 creature_ptr->redraw |= (PR_STATUS);
895 bool free_level_recall(player_type *creature_ptr)
897 DUNGEON_IDX select_dungeon;
901 select_dungeon = choose_dungeon(_("にテレポート", "teleport"), 4, 0);
903 if (!select_dungeon) return FALSE;
905 max_depth = d_info[select_dungeon].maxdepth;
907 /* Limit depth in Angband */
908 if (select_dungeon == DUNGEON_ANGBAND)
910 if (quest[QUEST_OBERON].status != QUEST_STATUS_FINISHED) max_depth = 98;
911 else if (quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
913 amt = get_quantity(format(_("%sの何階にテレポートしますか?", "Teleport to which level of %s? "),
914 d_name + d_info[select_dungeon].name), (QUANTITY)max_depth);
918 creature_ptr->word_recall = 1;
919 creature_ptr->recall_dungeon = select_dungeon;
920 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));
922 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("トランプタワーで", "at Trump Tower"));
924 msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
926 creature_ptr->redraw |= (PR_STATUS);
935 * @return リセット処理が実際に行われたらTRUEを返す
937 bool reset_recall(void)
939 int select_dungeon, dummy = 0;
943 select_dungeon = choose_dungeon(_("をセット", "reset"), 2, 14);
946 if (ironman_downward)
948 msg_print(_("何も起こらなかった。", "Nothing happens."));
952 if (!select_dungeon) return FALSE;
954 sprintf(ppp, _("何階にセットしますか (%d-%d):", "Reset to which level (%d-%d): "),
955 (int)d_info[select_dungeon].mindepth, (int)max_dlv[select_dungeon]);
958 sprintf(tmp_val, "%d", (int)MAX(current_floor_ptr->dun_level, 1));
960 /* Ask for a level */
961 if (get_string(ppp, tmp_val, 10))
963 /* Extract request */
964 dummy = atoi(tmp_val);
967 if (dummy < 1) dummy = 1;
970 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
971 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
973 max_dlv[select_dungeon] = dummy;
976 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
979 msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
981 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
994 * @brief プレイヤーの装備劣化処理 /
995 * Apply disenchantment to the player's stuff
996 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
997 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
998 * Return "TRUE" if the player notices anything
1000 bool apply_disenchant(BIT_FLAGS mode)
1004 GAME_TEXT o_name[MAX_NLEN];
1005 int to_h, to_d, to_a, pval;
1007 /* Pick a random slot */
1008 switch (randint1(8))
1010 case 1: t = INVEN_RARM; break;
1011 case 2: t = INVEN_LARM; break;
1012 case 3: t = INVEN_BOW; break;
1013 case 4: t = INVEN_BODY; break;
1014 case 5: t = INVEN_OUTER; break;
1015 case 6: t = INVEN_HEAD; break;
1016 case 7: t = INVEN_HANDS; break;
1017 case 8: t = INVEN_FEET; break;
1020 o_ptr = &inventory[t];
1022 /* No item, nothing happens */
1023 if (!o_ptr->k_idx) return (FALSE);
1025 /* Disenchant equipments only -- No disenchant on monster ball */
1026 if (!object_is_weapon_armour_ammo(o_ptr))
1029 /* Nothing to disenchant */
1030 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1032 /* Nothing to notice */
1036 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1038 /* Artifacts have 71% chance to resist */
1039 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1042 msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
1044 msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t),
1045 ((o_ptr->number != 1) ? "" : "s"));
1051 /* Memorize old value */
1057 /* Disenchant tohit */
1058 if (o_ptr->to_h > 0) o_ptr->to_h--;
1059 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1061 /* Disenchant todam */
1062 if (o_ptr->to_d > 0) o_ptr->to_d--;
1063 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1065 /* Disenchant toac */
1066 if (o_ptr->to_a > 0) o_ptr->to_a--;
1067 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1069 /* Disenchant pval (occasionally) */
1070 /* Unless called from wild_magic() */
1071 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1073 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1074 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1077 msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t) );
1079 msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t),
1080 ((o_ptr->number != 1) ? "were" : "was"));
1083 chg_virtue(V_HARMONY, 1);
1084 chg_virtue(V_ENCHANT, -2);
1085 p_ptr->update |= (PU_BONUS);
1086 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1095 * @brief プレイヤーの突然変異処理
1098 void mutate_player(void)
1100 BASE_STATUS max1, cur1, max2, cur2;
1103 /* Pick a pair of stats */
1104 ii = randint0(A_MAX);
1105 for (jj = ii; jj == ii; jj = randint0(A_MAX)) /* loop */;
1107 max1 = p_ptr->stat_max[ii];
1108 cur1 = p_ptr->stat_cur[ii];
1109 max2 = p_ptr->stat_max[jj];
1110 cur2 = p_ptr->stat_cur[jj];
1112 p_ptr->stat_max[ii] = max2;
1113 p_ptr->stat_cur[ii] = cur2;
1114 p_ptr->stat_max[jj] = max1;
1115 p_ptr->stat_cur[jj] = cur1;
1117 for (i = 0; i < A_MAX; i++)
1119 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1120 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1123 p_ptr->update |= (PU_BONUS);
1128 * @brief プレイヤーの因果混乱処理 / Apply Nexus
1129 * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
1132 void apply_nexus(monster_type *m_ptr)
1134 switch (randint1(7))
1136 case 1: case 2: case 3:
1138 teleport_player(200, TELEPORT_PASSIVE);
1144 teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
1150 if (randint0(100) < p_ptr->skill_sav)
1152 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1156 /* Teleport Level */
1163 if (randint0(100) < p_ptr->skill_sav)
1165 msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
1169 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
1178 * @brief 寿命つき光源の燃素追加処理 /
1179 * Charge a lite (torch or latern)
1182 void phlogiston(void)
1184 GAME_TURN max_flog = 0;
1185 object_type * o_ptr = &inventory[INVEN_LITE];
1188 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1190 max_flog = FUEL_LAMP;
1194 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1196 max_flog = FUEL_TORCH;
1199 /* No torch to refill */
1202 msg_print(_("燃素を消費するアイテムを装備していません。", "You are not wielding anything which uses phlogiston."));
1206 if (o_ptr->xtra4 >= max_flog)
1208 msg_print(_("このアイテムにはこれ以上燃素を補充できません。", "No more phlogiston can be put in this item."));
1213 o_ptr->xtra4 += (XTRA16)(max_flog / 2);
1215 msg_print(_("照明用アイテムに燃素を補充した。", "You add phlogiston to your light item."));
1217 if (o_ptr->xtra4 >= max_flog)
1219 o_ptr->xtra4 = (XTRA16)max_flog;
1220 msg_print(_("照明用アイテムは満タンになった。", "Your light item is full."));
1223 /* Recalculate torch */
1224 p_ptr->update |= (PU_TORCH);
1229 * @brief 武器へのエゴ付加処理 /
1230 * Brand the current weapon
1231 * @param brand_type エゴ化ID(e_info.txtとは連動していない)
1234 void brand_weapon(int brand_type)
1241 /* Assume enchant weapon */
1242 item_tester_hook = object_allow_enchant_melee_weapon;
1244 q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
1245 s = _("強化できる武器がない。", "You have nothing to enchant.");
1247 o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
1250 /* you can never modify artifacts / ego-items */
1251 /* you can never modify cursed items */
1252 /* TY: You _can_ modify broken items (if you're silly enough) */
1253 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1254 !object_is_cursed(o_ptr) &&
1255 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1256 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1257 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1261 /* Let's get the name before it is changed... */
1262 GAME_TEXT o_name[MAX_NLEN];
1263 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1268 if (o_ptr->tval == TV_SWORD)
1270 act = _("は鋭さを増した!", "becomes very sharp!");
1272 o_ptr->name2 = EGO_SHARPNESS;
1273 o_ptr->pval = (PARAMETER_VALUE)m_bonus(5, current_floor_ptr->dun_level) + 1;
1275 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1280 act = _("は破壊力を増した!", "seems very powerful.");
1281 o_ptr->name2 = EGO_EARTHQUAKES;
1282 o_ptr->pval = (PARAMETER_VALUE)m_bonus(3, current_floor_ptr->dun_level);
1286 act = _("は人間の血を求めている!", "seems to be looking for humans!");
1287 o_ptr->name2 = EGO_KILL_HUMAN;
1290 act = _("は電撃に覆われた!", "covered with lightning!");
1291 o_ptr->name2 = EGO_BRAND_ELEC;
1294 act = _("は酸に覆われた!", "coated with acid!");
1295 o_ptr->name2 = EGO_BRAND_ACID;
1298 act = _("は邪悪なる怪物を求めている!", "seems to be looking for evil monsters!");
1299 o_ptr->name2 = EGO_KILL_EVIL;
1302 act = _("は異世界の住人の肉体を求めている!", "seems to be looking for demons!");
1303 o_ptr->name2 = EGO_KILL_DEMON;
1306 act = _("は屍を求めている!", "seems to be looking for undead!");
1307 o_ptr->name2 = EGO_KILL_UNDEAD;
1310 act = _("は動物の血を求めている!", "seems to be looking for animals!");
1311 o_ptr->name2 = EGO_KILL_ANIMAL;
1314 act = _("はドラゴンの血を求めている!", "seems to be looking for dragons!");
1315 o_ptr->name2 = EGO_KILL_DRAGON;
1318 act = _("はトロルの血を求めている!", "seems to be looking for troll!s");
1319 o_ptr->name2 = EGO_KILL_TROLL;
1322 act = _("はオークの血を求めている!", "seems to be looking for orcs!");
1323 o_ptr->name2 = EGO_KILL_ORC;
1326 act = _("は巨人の血を求めている!", "seems to be looking for giants!");
1327 o_ptr->name2 = EGO_KILL_GIANT;
1330 act = _("は非常に不安定になったようだ。", "seems very unstable now.");
1331 o_ptr->name2 = EGO_TRUMP;
1332 o_ptr->pval = randint1(2);
1335 act = _("は血を求めている!", "thirsts for blood!");
1336 o_ptr->name2 = EGO_VAMPIRIC;
1339 act = _("は毒に覆われた。", "is coated with poison.");
1340 o_ptr->name2 = EGO_BRAND_POIS;
1343 act = _("は純ログルスに飲み込まれた。", "is engulfed in raw Logrus!");
1344 o_ptr->name2 = EGO_CHAOTIC;
1347 act = _("は炎のシールドに覆われた!", "is covered in a fiery shield!");
1348 o_ptr->name2 = EGO_BRAND_FIRE;
1351 act = _("は深く冷たいブルーに輝いた!", "glows deep, icy blue!");
1352 o_ptr->name2 = EGO_BRAND_COLD;
1356 msg_format(_("あなたの%s%s", "Your %s %s"), o_name, act);
1357 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1359 o_ptr->discount = 99;
1360 chg_virtue(V_ENCHANT, 2);
1364 if (flush_failure) flush();
1366 msg_print(_("属性付加に失敗した。", "The Branding failed."));
1367 chg_virtue(V_ENCHANT, -2);
1374 * @brief 虚無招来によるフロア中の全壁除去処理 /
1375 * Vanish all walls in this floor
1376 * @return 実際に処理が反映された場合TRUE
1378 static bool vanish_dungeon(void)
1382 feature_type *f_ptr;
1383 monster_type *m_ptr;
1384 GAME_TEXT m_name[MAX_NLEN];
1386 /* Prevent vasishing of quest levels and town */
1387 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1392 /* Scan all normal grids */
1393 for (y = 1; y < current_floor_ptr->height - 1; y++)
1395 for (x = 1; x < current_floor_ptr->width - 1; x++)
1397 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1399 /* Seeing true feature code (ignore mimic) */
1400 f_ptr = &f_info[g_ptr->feat];
1402 /* Lose room and vault */
1403 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1405 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
1408 if (g_ptr->m_idx && MON_CSLEEP(m_ptr))
1410 /* Reset sleep counter */
1411 (void)set_monster_csleep(g_ptr->m_idx, 0);
1413 /* Notice the "waking up" */
1416 monster_desc(m_name, m_ptr, 0);
1417 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
1421 /* Process all walls, doors and patterns */
1422 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1426 /* Special boundary walls -- Top and bottom */
1427 for (x = 0; x < current_floor_ptr->width; x++)
1429 g_ptr = ¤t_floor_ptr->grid_array[0][x];
1430 f_ptr = &f_info[g_ptr->mimic];
1432 /* Lose room and vault */
1433 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1435 /* Set boundary mimic if needed */
1436 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1438 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1440 /* Check for change to boring grid */
1441 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1444 g_ptr = ¤t_floor_ptr->grid_array[current_floor_ptr->height - 1][x];
1445 f_ptr = &f_info[g_ptr->mimic];
1447 /* Lose room and vault */
1448 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1450 /* Set boundary mimic if needed */
1451 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1453 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1455 /* Check for change to boring grid */
1456 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1460 /* Special boundary walls -- Left and right */
1461 for (y = 1; y < (current_floor_ptr->height - 1); y++)
1463 g_ptr = ¤t_floor_ptr->grid_array[y][0];
1464 f_ptr = &f_info[g_ptr->mimic];
1466 /* Lose room and vault */
1467 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1469 /* Set boundary mimic if needed */
1470 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1472 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1474 /* Check for change to boring grid */
1475 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1478 g_ptr = ¤t_floor_ptr->grid_array[y][current_floor_ptr->width - 1];
1479 f_ptr = &f_info[g_ptr->mimic];
1481 /* Lose room and vault */
1482 g_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1484 /* Set boundary mimic if needed */
1485 if (g_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1487 g_ptr->mimic = feat_state(g_ptr->mimic, FF_HURT_DISI);
1489 /* Check for change to boring grid */
1490 if (!have_flag(f_info[g_ptr->mimic].flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
1494 /* Mega-Hack -- Forget the view and lite */
1495 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
1496 p_ptr->redraw |= (PR_MAP);
1497 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1506 void call_the_(void)
1510 bool do_call = TRUE;
1512 for (i = 0; i < 9; i++)
1514 g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
1516 if (!cave_have_flag_grid(g_ptr, FF_PROJECT))
1518 if (!g_ptr->mimic || !have_flag(f_info[g_ptr->mimic].flags, FF_PROJECT) ||
1519 !permanent_wall(&f_info[g_ptr->feat]))
1529 for (i = 1; i < 10; i++)
1531 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1534 for (i = 1; i < 10; i++)
1536 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1539 for (i = 1; i < 10; i++)
1541 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1545 /* Prevent destruction of quest levels and town */
1546 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !current_floor_ptr->dun_level)
1548 msg_print(_("地面が揺れた。", "The ground trembles."));
1554 msg_format("あなたは%sを壁に近すぎる場所で唱えてしまった!",
1555 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "祈り" : "呪文"));
1557 msg_format("You %s the %s too close to a wall!",
1558 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1559 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1561 msg_print(_("大きな爆発音があった!", "There is a loud explosion!"));
1565 if (!vanish_dungeon()) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
1569 if (destroy_area(p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
1570 msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
1572 msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
1575 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
1581 * @brief アイテム引き寄せ処理 /
1582 * Fetch an item (teleport it right underneath the caster)
1583 * @param dir 魔法の発動方向
1585 * @param require_los 射線の通りを要求するならばTRUE
1588 void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
1594 GAME_TEXT o_name[MAX_NLEN];
1596 /* Check to see if an object is already there */
1597 if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx)
1599 msg_print(_("自分の足の下にある物は取れません。", "You can't fetch when you're already standing on something."));
1604 if (dir == 5 && target_okay())
1609 if (distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE)
1611 msg_print(_("そんなに遠くにある物は取れません!", "You can't fetch something that far away!"));
1615 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1617 /* We need an item to fetch */
1620 msg_print(_("そこには何もありません。", "There is no object at this place."));
1624 /* No fetching from vault */
1625 if (g_ptr->info & CAVE_ICKY)
1627 msg_print(_("アイテムがコントロールを外れて落ちた。", "The item slips from your control."));
1631 /* We need to see the item */
1634 if (!player_has_los_bold(ty, tx))
1636 msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
1639 else if (!projectable(p_ptr->y, p_ptr->x, ty, tx))
1641 msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
1654 g_ptr = ¤t_floor_ptr->grid_array[ty][tx];
1656 if ((distance(p_ptr->y, p_ptr->x, ty, tx) > MAX_RANGE) ||
1657 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1659 while (!g_ptr->o_idx);
1662 o_ptr = ¤t_floor_ptr->o_list[g_ptr->o_idx];
1664 if (o_ptr->weight > wgt)
1666 /* Too heavy to 'fetch' */
1667 msg_print(_("そのアイテムは重過ぎます。", "The object is too heavy."));
1672 g_ptr->o_idx = o_ptr->next_o_idx;
1673 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
1675 o_ptr->next_o_idx = 0;
1676 o_ptr->iy = p_ptr->y;
1677 o_ptr->ix = p_ptr->x;
1679 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1680 msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
1682 note_spot(p_ptr->y, p_ptr->x);
1683 p_ptr->redraw |= PR_MAP;
1690 void alter_reality(void)
1692 /* Ironman option */
1693 if (p_ptr->inside_arena || ironman_downward)
1695 msg_print(_("何も起こらなかった。", "Nothing happens."));
1699 if (!p_ptr->alter_reality)
1701 TIME_EFFECT turns = randint0(21) + 15;
1703 p_ptr->alter_reality = turns;
1704 msg_print(_("回りの景色が変わり始めた...", "The view around you begins to change..."));
1706 p_ptr->redraw |= (PR_STATUS);
1710 p_ptr->alter_reality = 0;
1711 msg_print(_("景色が元に戻った...", "The view around you got back..."));
1712 p_ptr->redraw |= (PR_STATUS);
1719 * @brief 守りのルーン設置処理 /
1720 * Leave a "glyph of warding" which prevents monster movement
1721 * @return 実際に設置が行われた場合TRUEを返す
1723 bool warding_glyph(void)
1725 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1727 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1731 /* Create a glyph */
1732 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1733 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].mimic = feat_glyph;
1735 note_spot(p_ptr->y, p_ptr->x);
1736 lite_spot(p_ptr->y, p_ptr->x);
1743 * @return 実際に設置が行われた場合TRUEを返す
1745 bool place_mirror(void)
1747 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1749 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1753 /* Create a mirror */
1754 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1755 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].mimic = feat_mirror;
1757 /* Turn on the light */
1758 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info |= CAVE_GLOW;
1760 note_spot(p_ptr->y, p_ptr->x);
1761 lite_spot(p_ptr->y, p_ptr->x);
1762 update_local_illumination(p_ptr->y, p_ptr->x);
1769 * @brief 爆発のルーン設置処理 /
1770 * Leave an "explosive rune" which prevents monster movement
1771 * @return 実際に設置が行われた場合TRUEを返す
1773 bool explosive_rune(void)
1775 if (!cave_clean_bold(p_ptr->y, p_ptr->x))
1777 msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
1781 /* Create a glyph */
1782 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info |= CAVE_OBJECT;
1783 current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].mimic = feat_explosive_rune;
1785 note_spot(p_ptr->y, p_ptr->x);
1786 lite_spot(p_ptr->y, p_ptr->x);
1793 * @brief 全所持アイテム鑑定処理 /
1794 * Identify everything being carried.
1795 * Done by a potion of "self knowledge".
1798 void identify_pack(void)
1802 /* Simply identify and know every item */
1803 for (i = 0; i < INVEN_TOTAL; i++)
1805 object_type *o_ptr = &inventory[i];
1807 /* Skip non-objects */
1808 if (!o_ptr->k_idx) continue;
1810 identify_item(o_ptr);
1812 /* Auto-inscription */
1813 autopick_alter_item(i, FALSE);
1819 * @brief 装備強化処理の失敗率定数(千分率) /
1820 * Used by the "enchant" function (chance of failure)
1821 * (modified for Zangband, we need better stuff there...) -- TY
1824 static int enchant_table[16] =
1826 0, 10, 50, 100, 200,
1827 300, 400, 500, 650, 800,
1828 950, 987, 993, 995, 998,
1835 * Removes curses from items in inventory
1836 * @param all 軽い呪いまでの解除ならば0
1837 * @return 解呪されたアイテムの数
1840 * Note that Items which are "Perma-Cursed" (The One Ring,
1841 * The Crown of Morgoth) can NEVER be uncursed.
1843 * Note that if "all" is FALSE, then Items which are
1844 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1845 * will not be uncursed.
1848 static int remove_curse_aux(int all)
1852 /* Attempt to uncurse items being worn */
1853 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1855 object_type *o_ptr = &inventory[i];
1857 /* Skip non-objects */
1858 if (!o_ptr->k_idx) continue;
1860 /* Uncursed already */
1861 if (!object_is_cursed(o_ptr)) continue;
1863 /* Heavily Cursed Items need a special spell */
1864 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1866 /* Perma-Cursed Items can NEVER be uncursed */
1867 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1869 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1873 o_ptr->curse_flags = 0L;
1874 o_ptr->ident |= (IDENT_SENSE);
1875 o_ptr->feeling = FEEL_NONE;
1877 p_ptr->update |= (PU_BONUS);
1878 p_ptr->window |= (PW_EQUIP);
1880 /* Count the uncursings */
1886 msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
1888 /* Return "something uncursed" */
1894 * @brief 装備の軽い呪い解呪処理 /
1895 * Remove most curses
1896 * @return 解呪に成功した装備数
1898 int remove_curse(void)
1900 return (remove_curse_aux(FALSE));
1904 * @brief 装備の重い呪い解呪処理 /
1906 * @return 解呪に成功した装備数
1908 int remove_all_curse(void)
1910 return (remove_curse_aux(TRUE));
1915 * @brief アイテムの価値に応じた錬金術処理 /
1916 * Turns an object into gold, gain some of its value in a shop
1917 * @return 処理が実際に行われたらTRUEを返す
1923 ITEM_NUMBER old_number;
1927 GAME_TEXT o_name[MAX_NLEN];
1928 char out_val[MAX_NLEN+40];
1932 /* Hack -- force destruction */
1933 if (command_arg > 0) force = TRUE;
1935 q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
1936 s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
1938 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1939 if (!o_ptr) return (FALSE);
1941 /* See how many items */
1942 if (o_ptr->number > 1)
1944 /* Get a quantity */
1945 amt = get_quantity(NULL, o_ptr->number);
1947 /* Allow user abort */
1948 if (amt <= 0) return FALSE;
1951 old_number = o_ptr->number;
1952 o_ptr->number = amt;
1953 object_desc(o_name, o_ptr, 0);
1954 o_ptr->number = old_number;
1956 /* Verify unless quantity given */
1959 if (confirm_destroy || (object_value(o_ptr) > 0))
1961 /* Make a verification */
1962 sprintf(out_val, _("本当に%sを金に変えますか?", "Really turn %s to gold? "), o_name);
1963 if (!get_check(out_val)) return FALSE;
1967 /* Artifacts cannot be destroyed */
1968 if (!can_player_destroy_object(o_ptr))
1970 msg_format(_("%sを金に変えることに失敗した。", "You fail to turn %s to gold!"), o_name);
1975 price = object_value_real(o_ptr);
1979 msg_format(_("%sをニセの金に変えた。", "You turn %s to fool's gold."), o_name);
1985 if (amt > 1) price *= amt;
1987 if (price > 30000) price = 30000;
1988 msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
1991 p_ptr->redraw |= (PR_GOLD);
1992 p_ptr->window |= (PW_PLAYER);
1995 /* Eliminate the item (from the pack) */
1998 inven_item_increase(item, -amt);
1999 inven_item_describe(item);
2000 inven_item_optimize(item);
2003 /* Eliminate the item (from the floor) */
2006 floor_item_increase(0 - item, -amt);
2007 floor_item_describe(0 - item);
2008 floor_item_optimize(0 - item);
2016 * @brief 呪いの打ち破り処理 /
2017 * Break the curse of an item
2018 * @param o_ptr 呪い装備情報の参照ポインタ
2021 static void break_curse(object_type *o_ptr)
2023 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2025 msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
2027 o_ptr->curse_flags = 0L;
2028 o_ptr->ident |= (IDENT_SENSE);
2029 o_ptr->feeling = FEEL_NONE;
2036 * Enchants a plus onto an item. -RAK-
2037 * @param o_ptr 強化するアイテムの参照ポインタ
2039 * @param eflag 強化オプション(命中/ダメージ/AC)
2040 * @return 強化に成功した場合TRUEを返す
2043 * Revamped! Now takes item pointer, number of times to try enchanting,
2044 * and a flag of what to try enchanting. Artifacts resist enchantment
2045 * some of the time, and successful enchantment to at least +0 might
2046 * break a curse on the item. -CFT-
2048 * Note that an item can technically be enchanted all the way to +15 if
2049 * you wait a very, very, long time. Going from +9 to +10 only works
2050 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2052 * Note that this function can now be used on "piles" of items, and
2053 * the larger the pile, the lower the chance of success.
2056 bool enchant(object_type *o_ptr, int n, int eflag)
2058 int i, chance, prob;
2060 bool a = object_is_artifact(o_ptr);
2061 bool force = (eflag & ENCH_FORCE);
2063 /* Large piles resist enchantment */
2064 prob = o_ptr->number * 100;
2066 /* Missiles are easy to enchant */
2067 if ((o_ptr->tval == TV_BOLT) ||
2068 (o_ptr->tval == TV_ARROW) ||
2069 (o_ptr->tval == TV_SHOT))
2075 for (i = 0; i < n; i++)
2077 /* Hack -- Roll for pile resistance */
2078 if (!force && randint0(prob) >= 100) continue;
2080 /* Enchant to hit */
2081 if (eflag & ENCH_TOHIT)
2083 if (o_ptr->to_h < 0) chance = 0;
2084 else if (o_ptr->to_h > 15) chance = 1000;
2085 else chance = enchant_table[o_ptr->to_h];
2087 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2092 /* only when you get it above -1 -CFT */
2093 if (o_ptr->to_h >= 0)
2098 /* Enchant to damage */
2099 if (eflag & ENCH_TODAM)
2101 if (o_ptr->to_d < 0) chance = 0;
2102 else if (o_ptr->to_d > 15) chance = 1000;
2103 else chance = enchant_table[o_ptr->to_d];
2105 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2110 /* only when you get it above -1 -CFT */
2111 if (o_ptr->to_d >= 0)
2116 /* Enchant to armor class */
2117 if (eflag & ENCH_TOAC)
2119 if (o_ptr->to_a < 0) chance = 0;
2120 else if (o_ptr->to_a > 15) chance = 1000;
2121 else chance = enchant_table[o_ptr->to_a];
2123 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2128 /* only when you get it above -1 -CFT */
2129 if (o_ptr->to_a >= 0)
2136 if (!res) return (FALSE);
2137 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
2138 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2148 * @brief 装備修正強化処理のメインルーチン /
2149 * Enchant an item (in the inventory or on the floor)
2150 * @param num_hit 命中修正量
2151 * @param num_dam ダメージ修正量
2152 * @param num_ac AC修正量
2153 * @return 強化に成功した場合TRUEを返す
2155 * Note that "num_ac" requires armour, else weapon
2156 * Returns TRUE if attempted, FALSE if cancelled
2158 bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
2163 GAME_TEXT o_name[MAX_NLEN];
2166 /* Assume enchant weapon */
2167 item_tester_hook = object_allow_enchant_weapon;
2169 /* Enchant armor if requested */
2170 if (num_ac) item_tester_hook = object_is_armour;
2172 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2173 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2175 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2176 if (!o_ptr) return (FALSE);
2178 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2180 msg_format("%s は明るく輝いた!", o_name);
2182 msg_format("%s %s glow%s brightly!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
2186 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2187 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2188 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2193 if (flush_failure) flush();
2194 msg_print(_("強化に失敗した。", "The enchantment failed."));
2195 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2198 chg_virtue(V_ENCHANT, 1);
2202 /* Something happened */
2208 * @brief アーティファクト生成の巻物処理 /
2209 * @return 生成が実際に試みられたらTRUEを返す
2211 bool artifact_scroll(void)
2216 GAME_TEXT o_name[MAX_NLEN];
2219 /* Enchant weapon/armour */
2220 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2222 q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
2223 s = _("強化できるアイテムがない。", "You have nothing to enchant.");
2225 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2226 if (!o_ptr) return (FALSE);
2228 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2230 msg_format("%s は眩い光を発した!",o_name);
2232 msg_format("%s %s radiate%s a blinding light!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
2235 if (object_is_artifact(o_ptr))
2238 msg_format("%sは既に伝説のアイテムです!", o_name );
2240 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"), ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2246 else if (object_is_ego(o_ptr))
2249 msg_format("%sは既に名のあるアイテムです!", o_name );
2251 msg_format("The %s %s already %s!",
2252 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2253 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2259 else if (o_ptr->xtra3)
2262 msg_format("%sは既に強化されています!", o_name );
2264 msg_format("The %s %s already %s!", o_name, ((o_ptr->number > 1) ? "are" : "is"),
2265 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2271 if (o_ptr->number > 1)
2273 msg_print(_("複数のアイテムに魔法をかけるだけのエネルギーはありません!", "Not enough energy to enchant more than one object!"));
2275 msg_format("%d 個の%sが壊れた!",(o_ptr->number)-1, o_name);
2277 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2282 inven_item_increase(item, 1 - (o_ptr->number));
2286 floor_item_increase(0 - item, 1 - (o_ptr->number));
2289 okay = create_artifact(o_ptr, TRUE);
2295 if (flush_failure) flush();
2296 msg_print(_("強化に失敗した。", "The enchantment failed."));
2297 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2301 if (record_rand_art)
2303 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2304 do_cmd_write_nikki(NIKKI_ART_SCROLL, 0, o_name);
2306 chg_virtue(V_ENCHANT, 1);
2311 /* Something happened */
2318 * Identify an object
2319 * @param o_ptr 鑑定されるアイテムの情報参照ポインタ
2320 * @return 実際に鑑定できたらTRUEを返す
2322 bool identify_item(object_type *o_ptr)
2324 bool old_known = FALSE;
2325 GAME_TEXT o_name[MAX_NLEN];
2327 object_desc(o_name, o_ptr, 0);
2329 if (o_ptr->ident & IDENT_KNOWN)
2332 if (!(o_ptr->ident & (IDENT_MENTAL)))
2334 if (object_is_artifact(o_ptr) || one_in_(5))
2335 chg_virtue(V_KNOWLEDGE, 1);
2338 object_aware(o_ptr);
2339 object_known(o_ptr);
2340 o_ptr->marked |= OM_TOUCHED;
2342 p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
2343 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2345 strcpy(record_o_name, o_name);
2348 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2350 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2351 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2352 if(record_rand_art && !old_known && o_ptr->art_name)
2353 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2359 * @brief アイテム鑑定のメインルーチン処理 /
2360 * Identify an object in the inventory (or on the floor)
2361 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2362 * @return 実際に鑑定を行ったならばTRUEを返す
2364 * This routine does *not* automatically combine objects.
2365 * Returns TRUE if something was identified, else FALSE.
2367 bool ident_spell(bool only_equip)
2371 GAME_TEXT o_name[MAX_NLEN];
2376 item_tester_hook = item_tester_hook_identify_weapon_armour;
2378 item_tester_hook = item_tester_hook_identify;
2382 q = _("どのアイテムを鑑定しますか? ", "Identify which item? ");
2387 item_tester_hook = object_is_weapon_armour_ammo;
2389 item_tester_hook = NULL;
2391 q = _("すべて鑑定済みです。 ", "All items are identified. ");
2394 s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
2396 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2397 if (!o_ptr) return (FALSE);
2399 old_known = identify_item(o_ptr);
2401 object_desc(o_name, o_ptr, 0);
2402 if (item >= INVEN_RARM)
2404 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2408 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2412 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2415 /* Auto-inscription/destroy */
2416 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2418 /* Something happened */
2424 * @brief アイテム凡庸化のメインルーチン処理 /
2425 * Identify an object in the inventory (or on the floor)
2426 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2427 * @return 実際に凡庸化をを行ったならばTRUEを返す
2430 * Mundanify an object in the inventory (or on the floor)
2431 * This routine does *not* automatically combine objects.
2432 * Returns TRUE if something was mundanified, else FALSE.
2435 bool mundane_spell(bool only_equip)
2441 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2443 q = _("どれを使いますか?", "Use which item? ");
2444 s = _("使えるものがありません。", "You have nothing you can use.");
2446 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2447 if (!o_ptr) return (FALSE);
2449 msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
2451 POSITION iy = o_ptr->iy; /* Y-position on map, or zero */
2452 POSITION ix = o_ptr->ix; /* X-position on map, or zero */
2453 OBJECT_IDX next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2454 byte marked = o_ptr->marked; /* Object is marked */
2455 WEIGHT weight = o_ptr->number * o_ptr->weight;
2456 u16b inscription = o_ptr->inscription;
2459 object_prep(o_ptr, o_ptr->k_idx);
2463 o_ptr->next_o_idx = next_o_idx;
2464 o_ptr->marked = marked;
2465 o_ptr->inscription = inscription;
2466 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2470 /* Something happened */
2475 * @brief アイテム*鑑定*のメインルーチン処理 /
2476 * Identify an object in the inventory (or on the floor)
2477 * @param only_equip 装備品のみを対象とするならばTRUEを返す
2478 * @return 実際に鑑定を行ったならばTRUEを返す
2480 * Fully "identify" an object in the inventory -BEN-
2481 * This routine returns TRUE if an item was identified.
2483 bool identify_fully(bool only_equip)
2487 GAME_TEXT o_name[MAX_NLEN];
2492 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2494 item_tester_hook = item_tester_hook_identify_fully;
2498 q = _("どのアイテムを*鑑定*しますか? ", "*Identify* which item? ");
2503 item_tester_hook = object_is_weapon_armour_ammo;
2505 item_tester_hook = NULL;
2507 q = _("すべて*鑑定*済みです。 ", "All items are *identified*. ");
2510 s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
2512 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2513 if (!o_ptr) return (FALSE);
2515 old_known = identify_item(o_ptr);
2517 /* Mark the item as fully known */
2518 o_ptr->ident |= (IDENT_MENTAL);
2521 object_desc(o_name, o_ptr, 0);
2522 if (item >= INVEN_RARM)
2524 msg_format(_("%^s: %s(%c)。", "%^s: %s (%c)."), describe_use(item), o_name, index_to_label(item));
2528 msg_format(_("ザック中: %s(%c)。", "In your pack: %s (%c)."), o_name, index_to_label(item));
2532 msg_format(_("床上: %s。", "On the ground: %s."), o_name);
2535 /* Describe it fully */
2536 (void)screen_object(o_ptr, 0L);
2538 /* Auto-inscription/destroy */
2539 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2549 * Recharge a wand/staff/rod from the pack or on the floor.
2550 * This function has been rewritten in Oangband and ZAngband.
2551 * @param power 充填パワー
2552 * @return ターン消費を要する処理まで進んだらTRUEを返す
2554 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2555 * Chaos -- Arcane Binding --> recharge(90)
2557 * Scroll of recharging --> recharge(130)
2558 * Artifact activation/Thingol --> recharge(130)
2560 * It is harder to recharge high level, and highly charged wands,
2561 * staffs, and rods. The more wands in a stack, the more easily and
2562 * strongly they recharge. Staffs, however, each get fewer charges if
2565 * Beware of "sliding index errors".
2567 bool recharge(int power)
2571 int recharge_strength;
2572 TIME_EFFECT recharge_amount;
2581 GAME_TEXT o_name[MAX_NLEN];
2583 /* Only accept legal items */
2584 item_tester_hook = item_tester_hook_recharge;
2586 q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
2587 s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
2589 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2590 if (!o_ptr) return (FALSE);
2592 /* Get the object kind. */
2593 k_ptr = &k_info[o_ptr->k_idx];
2595 /* Extract the object "level" */
2596 lev = k_info[o_ptr->k_idx].level;
2599 /* Recharge a rod */
2600 if (o_ptr->tval == TV_ROD)
2602 /* Extract a recharge strength by comparing object level to power. */
2603 recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
2607 if (one_in_(recharge_strength))
2609 /* Activate the failure code. */
2616 /* Recharge amount */
2617 recharge_amount = (power * damroll(3, 2));
2619 /* Recharge by that amount */
2620 if (o_ptr->timeout > recharge_amount)
2621 o_ptr->timeout -= recharge_amount;
2628 /* Recharge wand/staff */
2631 /* Extract a recharge strength by comparing object level to power.
2632 * Divide up a stack of wands' charges to calculate charge penalty.
2634 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2635 recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15;
2637 /* All staffs, unstacked wands. */
2638 else recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15;
2641 if (recharge_strength < 0) recharge_strength = 0;
2644 if (one_in_(recharge_strength))
2646 /* Activate the failure code. */
2650 /* If the spell didn't backfire, recharge the wand or staff. */
2653 /* Recharge based on the standard number of charges. */
2654 recharge_amount = randint1(1 + k_ptr->pval / 2);
2656 /* Multiple wands in a stack increase recharging somewhat. */
2657 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
2660 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
2661 if (recharge_amount < 1) recharge_amount = 1;
2662 if (recharge_amount > 12) recharge_amount = 12;
2665 /* But each staff in a stack gets fewer additional charges,
2666 * although always at least one.
2668 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
2670 recharge_amount /= (TIME_EFFECT)o_ptr->number;
2671 if (recharge_amount < 1) recharge_amount = 1;
2674 /* Recharge the wand or staff. */
2675 o_ptr->pval += recharge_amount;
2678 /* Hack -- we no longer "know" the item */
2679 o_ptr->ident &= ~(IDENT_KNOWN);
2681 /* Hack -- we no longer think the item is empty */
2682 o_ptr->ident &= ~(IDENT_EMPTY);
2687 /* Inflict the penalties for failing a recharge. */
2690 /* Artifacts are never destroyed. */
2691 if (object_is_fixed_artifact(o_ptr))
2693 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2694 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
2696 /* Artifact rods. */
2697 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
2698 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2700 /* Artifact wands and staffs. */
2701 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
2706 /* Get the object description */
2707 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2709 /*** Determine Seriousness of Failure ***/
2711 /* Mages recharge objects more safely. */
2712 if (IS_WIZARD_CLASS() || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
2714 /* 10% chance to blow up one rod, otherwise draining. */
2715 if (o_ptr->tval == TV_ROD)
2717 if (one_in_(10)) fail_type = 2;
2720 /* 75% chance to blow up one wand, otherwise draining. */
2721 else if (o_ptr->tval == TV_WAND)
2723 if (!one_in_(3)) fail_type = 2;
2726 /* 50% chance to blow up one staff, otherwise no effect. */
2727 else if (o_ptr->tval == TV_STAFF)
2729 if (one_in_(2)) fail_type = 2;
2734 /* All other classes get no special favors. */
2737 /* 33% chance to blow up one rod, otherwise draining. */
2738 if (o_ptr->tval == TV_ROD)
2740 if (one_in_(3)) fail_type = 2;
2743 /* 20% chance of the entire stack, else destroy one wand. */
2744 else if (o_ptr->tval == TV_WAND)
2746 if (one_in_(5)) fail_type = 3;
2749 /* Blow up one staff. */
2750 else if (o_ptr->tval == TV_STAFF)
2756 /*** Apply draining and destruction. ***/
2758 /* Drain object or stack of objects. */
2761 if (o_ptr->tval == TV_ROD)
2763 msg_print(_("魔力が逆噴射して、ロッドからさらに魔力を吸い取ってしまった!", "The recharge backfires, draining the rod further!"));
2765 if (o_ptr->timeout < 10000)
2766 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
2768 else if (o_ptr->tval == TV_WAND)
2770 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
2773 /* Staffs aren't drained. */
2776 /* Destroy an object or one in a stack of objects. */
2779 if (o_ptr->number > 1)
2780 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
2782 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2784 /* Reduce rod stack maximum timeout, drain wands. */
2785 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
2786 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
2788 /* Reduce and describe inventory */
2791 inven_item_increase(item, -1);
2792 inven_item_describe(item);
2793 inven_item_optimize(item);
2796 /* Reduce and describe floor item */
2799 floor_item_increase(0 - item, -1);
2800 floor_item_describe(0 - item);
2801 floor_item_optimize(0 - item);
2805 /* Destroy all members of a stack of objects. */
2808 if (o_ptr->number > 1)
2809 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
2811 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
2813 /* Reduce and describe inventory */
2816 inven_item_increase(item, -999);
2817 inven_item_describe(item);
2818 inven_item_optimize(item);
2821 /* Reduce and describe floor item */
2824 floor_item_increase(0 - item, -999);
2825 floor_item_describe(0 - item);
2826 floor_item_optimize(0 - item);
2831 p_ptr->update |= (PU_COMBINE | PU_REORDER);
2832 p_ptr->window |= (PW_INVEN);
2834 /* Something was done */
2842 * @return ターン消費を要する処理を行ったならばTRUEを返す
2844 bool bless_weapon(void)
2848 BIT_FLAGS flgs[TR_FLAG_SIZE];
2849 GAME_TEXT o_name[MAX_NLEN];
2852 /* Bless only weapons */
2853 item_tester_hook = object_is_weapon;
2855 q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
2856 s = _("祝福できる武器がありません。", "You have weapon to bless.");
2858 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
2859 if (!o_ptr) return FALSE;
2861 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2862 object_flags(o_ptr, flgs);
2864 if (object_is_cursed(o_ptr))
2866 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
2867 have_flag(flgs, TR_ADD_L_CURSE) ||
2868 have_flag(flgs, TR_ADD_H_CURSE) ||
2869 (o_ptr->curse_flags & TRC_PERMA_CURSE))
2872 msg_format("%sを覆う黒いオーラは祝福を跳ね返した!", o_name);
2874 msg_format("The black aura on %s %s disrupts the blessing!", ((item >= 0) ? "your" : "the"), o_name);
2881 msg_format("%s から邪悪なオーラが消えた。", o_name);
2883 msg_format("A malignant aura leaves %s %s.", ((item >= 0) ? "your" : "the"), o_name);
2887 o_ptr->curse_flags = 0L;
2889 o_ptr->ident |= (IDENT_SENSE);
2890 o_ptr->feeling = FEEL_NONE;
2892 /* Recalculate the bonuses */
2893 p_ptr->update |= (PU_BONUS);
2894 p_ptr->window |= (PW_EQUIP);
2898 * Next, we try to bless it. Artifacts have a 1/3 chance of
2899 * being blessed, otherwise, the operation simply disenchants
2900 * them, godly power negating the magic. Ok, the explanation
2901 * is silly, but otherwise priests would always bless every
2902 * artifact weapon they find. Ego weapons and normal weapons
2903 * can be blessed automatically.
2905 if (have_flag(flgs, TR_BLESSED))
2908 msg_format("%s は既に祝福されている。", o_name);
2910 msg_format("%s %s %s blessed already.",
2911 ((item >= 0) ? "Your" : "The"), o_name,
2912 ((o_ptr->number > 1) ? "were" : "was"));
2918 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
2921 msg_format("%sは輝いた!", o_name);
2923 msg_format("%s %s shine%s!",
2924 ((item >= 0) ? "Your" : "The"), o_name,
2925 ((o_ptr->number > 1) ? "" : "s"));
2928 add_flag(o_ptr->art_flags, TR_BLESSED);
2929 o_ptr->discount = 99;
2933 bool dis_happened = FALSE;
2934 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
2936 /* Disenchant tohit */
2937 if (o_ptr->to_h > 0)
2940 dis_happened = TRUE;
2943 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
2945 /* Disenchant todam */
2946 if (o_ptr->to_d > 0)
2949 dis_happened = TRUE;
2952 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
2954 /* Disenchant toac */
2955 if (o_ptr->to_a > 0)
2958 dis_happened = TRUE;
2961 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
2965 msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
2968 msg_format("%s は劣化した!", o_name);
2970 msg_format("%s %s %s disenchanted!", ((item >= 0) ? "Your" : "The"), o_name,
2971 ((o_ptr->number > 1) ? "were" : "was"));
2977 p_ptr->update |= (PU_BONUS);
2978 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
2988 * @return ターン消費を要する処理を行ったならばTRUEを返す
2990 bool pulish_shield(void)
2994 BIT_FLAGS flgs[TR_FLAG_SIZE];
2995 GAME_TEXT o_name[MAX_NLEN];
2998 /* Assume enchant weapon */
2999 item_tester_tval = TV_SHIELD;
3001 q = _("どの盾を磨きますか?", "Pulish which weapon? ");
3002 s = _("磨く盾がありません。", "You have weapon to pulish.");
3004 o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
3005 if (!o_ptr) return FALSE;
3007 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3008 object_flags(o_ptr, flgs);
3010 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3011 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3014 msg_format("%sは輝いた!", o_name);
3016 msg_format("%s %s shine%s!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
3018 o_ptr->name2 = EGO_REFLECTION;
3019 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3021 o_ptr->discount = 99;
3022 chg_virtue(V_ENCHANT, 2);
3028 if (flush_failure) flush();
3030 msg_print(_("失敗した。", "Failed."));
3031 chg_virtue(V_ENCHANT, -2);
3041 * Potions "smash open" and cause an area effect when
3042 * @param who 薬破損の主体ID(プレイヤー所持アイテムが壊れた場合0、床上のアイテムの場合モンスターID)
3045 * @param k_idx 破損した薬のアイテムID
3046 * @return 薬を浴びたモンスターが起こるならばTRUEを返す
3049 * (1) they are shattered while in the player's inventory,
3050 * due to cold (etc) attacks;
3051 * (2) they are thrown at a monster, or obstacle;
3052 * (3) they are shattered by a "cold ball" or other such spell
3053 * while lying on the floor.
3056 * who --- who caused the potion to shatter (0=player)
3057 * potions that smash on the floor are assumed to
3058 * be caused by no-one (who = 1), as are those that
3059 * shatter inside the player inventory.
3060 * (Not anymore -- I changed this; TY)
3061 * y, x --- coordinates of the potion (or player if
3062 * the potion was in her inventory);
3063 * o_ptr --- pointer to the potion object.
3066 bool potion_smash_effect(MONSTER_IDX who, POSITION y, POSITION x, KIND_OBJECT_IDX k_idx)
3073 object_kind *k_ptr = &k_info[k_idx];
3075 switch (k_ptr->sval)
3077 case SV_POTION_SALT_WATER:
3078 case SV_POTION_SLIME_MOLD:
3079 case SV_POTION_LOSE_MEMORIES:
3080 case SV_POTION_DEC_STR:
3081 case SV_POTION_DEC_INT:
3082 case SV_POTION_DEC_WIS:
3083 case SV_POTION_DEC_DEX:
3084 case SV_POTION_DEC_CON:
3085 case SV_POTION_DEC_CHR:
3086 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3087 case SV_POTION_APPLE_JUICE:
3090 case SV_POTION_INFRAVISION:
3091 case SV_POTION_DETECT_INVIS:
3092 case SV_POTION_SLOW_POISON:
3093 case SV_POTION_CURE_POISON:
3094 case SV_POTION_BOLDNESS:
3095 case SV_POTION_RESIST_HEAT:
3096 case SV_POTION_RESIST_COLD:
3097 case SV_POTION_HEROISM:
3098 case SV_POTION_BESERK_STRENGTH:
3099 case SV_POTION_RES_STR:
3100 case SV_POTION_RES_INT:
3101 case SV_POTION_RES_WIS:
3102 case SV_POTION_RES_DEX:
3103 case SV_POTION_RES_CON:
3104 case SV_POTION_RES_CHR:
3105 case SV_POTION_INC_STR:
3106 case SV_POTION_INC_INT:
3107 case SV_POTION_INC_WIS:
3108 case SV_POTION_INC_DEX:
3109 case SV_POTION_INC_CON:
3110 case SV_POTION_INC_CHR:
3111 case SV_POTION_AUGMENTATION:
3112 case SV_POTION_ENLIGHTENMENT:
3113 case SV_POTION_STAR_ENLIGHTENMENT:
3114 case SV_POTION_SELF_KNOWLEDGE:
3115 case SV_POTION_EXPERIENCE:
3116 case SV_POTION_RESISTANCE:
3117 case SV_POTION_INVULNERABILITY:
3118 case SV_POTION_NEW_LIFE:
3119 /* All of the above potions have no effect when shattered */
3121 case SV_POTION_SLOWNESS:
3126 case SV_POTION_POISON:
3131 case SV_POTION_BLINDNESS:
3135 case SV_POTION_BOOZE: /* Booze */
3139 case SV_POTION_SLEEP:
3143 case SV_POTION_RUINATION:
3144 case SV_POTION_DETONATIONS:
3146 dam = damroll(25, 25);
3149 case SV_POTION_DEATH:
3150 dt = GF_DEATH_RAY; /* !! */
3151 dam = k_ptr->level * 10;
3155 case SV_POTION_SPEED:
3158 case SV_POTION_CURE_LIGHT:
3160 dam = damroll(2, 3);
3162 case SV_POTION_CURE_SERIOUS:
3164 dam = damroll(4, 3);
3166 case SV_POTION_CURE_CRITICAL:
3167 case SV_POTION_CURING:
3169 dam = damroll(6, 3);
3171 case SV_POTION_HEALING:
3173 dam = damroll(10, 10);
3175 case SV_POTION_RESTORE_EXP:
3180 case SV_POTION_LIFE:
3182 dam = damroll(50, 50);
3185 case SV_POTION_STAR_HEALING:
3187 dam = damroll(50, 50);
3190 case SV_POTION_RESTORE_MANA: /* MANA */
3192 dam = damroll(10, 10);
3199 (void)project(who, radius, y, x, dam, dt, (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3201 /* XXX those potions that explode need to become "known" */
3207 * @brief プレイヤーの全既知呪文を表示する /
3208 * Hack -- Display all known spells in a window
3211 * Need to analyze size of the window.
3212 * Need more color coding.
3214 void display_spell_list(void)
3219 const magic_type *s_ptr;
3220 GAME_TEXT name[MAX_NLEN];
3225 /* They have too many spells to list */
3226 if (p_ptr->pclass == CLASS_SORCERER) return;
3227 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3229 if (p_ptr->pclass == CLASS_SNIPER)
3231 display_snipe_list();
3235 /* mind.c type classes */
3236 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3237 (p_ptr->pclass == CLASS_BERSERKER) ||
3238 (p_ptr->pclass == CLASS_NINJA) ||
3239 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3240 (p_ptr->pclass == CLASS_FORCETRAINER))
3243 PLAYER_LEVEL plev = p_ptr->lev;
3249 bool use_hp = FALSE;
3254 /* Display a list of spells */
3256 put_str(_("名前", "Name"), y, x + 5);
3257 put_str(_("Lv MP 失率 効果", "Lv Mana Fail Info"), y, x + 35);
3259 switch(p_ptr->pclass)
3261 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3262 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3263 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3264 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3265 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3266 default: use_mind = 0;break;
3269 /* Dump the spells */
3270 for (i = 0; i < MAX_MIND_POWERS; i++)
3272 byte a = TERM_WHITE;
3274 /* Access the available spell */
3275 spell = mind_powers[use_mind].info[i];
3276 if (spell.min_lev > plev) break;
3278 /* Get the failure rate */
3279 chance = spell.fail;
3281 /* Reduce failure rate by "effective" level adjustment */
3282 chance -= 3 * (p_ptr->lev - spell.min_lev);
3284 /* Reduce failure rate by INT/WIS adjustment */
3285 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3289 /* Not enough mana to cast */
3290 if (spell.mana_cost > p_ptr->csp)
3292 chance += 5 * (spell.mana_cost - p_ptr->csp);
3298 /* Not enough hp to cast */
3299 if (spell.mana_cost > p_ptr->chp)
3306 /* Extract the minimum failure rate */
3307 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3309 /* Minimum failure rate */
3310 if (chance < minfail) chance = minfail;
3312 /* Stunning makes spells harder */
3313 if (p_ptr->stun > 50) chance += 25;
3314 else if (p_ptr->stun) chance += 15;
3316 /* Always a 5 percent chance of working */
3317 if (chance > 95) chance = 95;
3320 mindcraft_info(comment, use_mind, i);
3322 /* Dump the spell */
3323 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3325 spell.min_lev, spell.mana_cost, chance, comment);
3327 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3332 /* Cannot read spellbooks */
3333 if (REALM_NONE == p_ptr->realm1) return;
3335 /* Normal spellcaster with books */
3338 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3342 /* Reset vertical */
3345 /* Vertical location */
3346 y = (j < 3) ? 0 : (m[j - 3] + 2);
3348 /* Horizontal location */
3352 for (i = 0; i < 32; i++)
3354 byte a = TERM_WHITE;
3356 /* Access the spell */
3357 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3359 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3363 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3366 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
3369 if (s_ptr->slevel >= 99)
3372 strcpy(name, _("(判読不能)", "(illegible)"));
3380 ((p_ptr->spell_forgotten1 & (1L << i))) :
3381 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3388 else if (!((j < 1) ?
3389 (p_ptr->spell_learned1 & (1L << i)) :
3390 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3397 else if (!((j < 1) ?
3398 (p_ptr->spell_worked1 & (1L << i)) :
3399 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3405 /* Dump the spell --(-- */
3406 sprintf(out_val, "%c/%c) %-20.20s",
3407 I2A(n / 8), I2A(n % 8), name);
3412 /* Dump onto the window */
3413 Term_putstr(x, m[j], -1, a, out_val);
3423 * @brief 呪文の経験値を返す /
3424 * Returns experience of a spell
3426 * @param use_realm 魔法領域
3429 EXP experience_of_spell(SPELL_IDX spell, REALM_IDX use_realm)
3431 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
3432 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
3433 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3434 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3440 * @brief 呪文の消費MPを返す /
3441 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
3442 * @param need_mana 基本消費MP
3447 MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm)
3449 #define MANA_CONST 2400
3451 #define DEC_MANA_DIV 3
3454 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
3457 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
3458 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
3460 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
3461 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
3462 need_mana /= MANA_CONST * MANA_DIV;
3463 if (need_mana < 1) need_mana = 1;
3466 /* Non-realm magic */
3469 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
3481 * @brief 呪文の失敗率修正処理1(呪い、消費魔力減少、呪文簡易化) /
3482 * Modify spell fail rate
3483 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3484 * @param chance 修正前失敗率
3488 PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
3490 chance += p_ptr->to_m_chance;
3492 if (p_ptr->heavy_spell) chance += 20;
3494 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
3495 else if (p_ptr->easy_spell) chance -= 3;
3496 else if (p_ptr->dec_mana) chance -= 2;
3503 * @brief 呪文の失敗率修正処理2(消費魔力減少、呪い、負値修正) /
3504 * Modify spell fail rate
3505 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3506 * @param chance 修正前失敗率
3508 * Modify spell fail rate (as "suffix" process)
3509 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
3510 * Note: variable "chance" cannot be negative.
3513 PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
3515 if (p_ptr->dec_mana) chance--;
3517 if (p_ptr->heavy_spell) chance += 5;
3519 return MAX(chance, 0);
3524 * @brief 呪文の失敗率計算メインルーチン /
3525 * Returns spell chance of failure for spell -RAK-
3527 * @param use_realm 魔法領域ID
3530 PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
3532 PERCENTAGE chance, minfail;
3533 const magic_type *s_ptr;
3534 MANA_POINT need_mana;
3535 PERCENTAGE penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
3538 /* Paranoia -- must be literate */
3539 if (!mp_ptr->spell_book) return (100);
3541 if (use_realm == REALM_HISSATSU) return 0;
3543 /* Access the spell */
3544 if (!is_magic(use_realm))
3546 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3550 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3553 /* Extract the base spell failure rate */
3554 chance = s_ptr->sfail;
3556 /* Reduce failure rate by "effective" level adjustment */
3557 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
3559 /* Reduce failure rate by INT/WIS adjustment */
3560 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3563 chance += (MAX(r_info[current_floor_ptr->m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
3565 /* Extract mana consumption rate */
3566 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3568 /* Not enough mana to cast */
3569 if (need_mana > p_ptr->csp)
3571 chance += 5 * (need_mana - p_ptr->csp);
3574 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
3576 /* Extract the minimum failure rate */
3577 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3580 * Non mage/priest characters never get too good
3581 * (added high mage, mindcrafter)
3583 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
3585 if (minfail < 5) minfail = 5;
3588 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
3589 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
3590 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
3592 chance = mod_spell_chance_1(chance);
3594 /* Goodness or evilness gives a penalty to failure rate */
3598 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
3600 case REALM_LIFE: case REALM_CRUSADE:
3601 if (p_ptr->align < -20) chance += penalty;
3603 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
3604 if (p_ptr->align > 20) chance += penalty;
3608 /* Minimum failure rate */
3609 if (chance < minfail) chance = minfail;
3611 /* Stunning makes spells harder */
3612 if (p_ptr->stun > 50) chance += 25;
3613 else if (p_ptr->stun) chance += 15;
3615 /* Always a 5 percent chance of working */
3616 if (chance > 95) chance = 95;
3618 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
3619 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3621 EXP exp = experience_of_spell(spell, use_realm);
3622 if (exp >= SPELL_EXP_EXPERT) chance--;
3623 if (exp >= SPELL_EXP_MASTER) chance--;
3626 /* Return the chance */
3627 return mod_spell_chance_2(chance);
3632 * @brief 魔法が利用可能かどうかを返す /
3633 * Determine if a spell is "okay" for the player to cast or study
3634 * The spell must be legible, not forgotten, and also, to cast,
3635 * it must be known, and to study, it must not be known.
3637 * @param learned 使用可能な判定ならばTRUE、学習可能かどうかの判定ならばFALSE
3638 * @param study_pray 祈りの学習判定目的ならばTRUE
3639 * @param use_realm 魔法領域ID
3642 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
3644 const magic_type *s_ptr;
3646 /* Access the spell */
3647 if (!is_magic(use_realm))
3649 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3653 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3656 /* Spell is illegal */
3657 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
3659 /* Spell is forgotten */
3660 if ((use_realm == p_ptr->realm2) ?
3661 (p_ptr->spell_forgotten2 & (1L << spell)) :
3662 (p_ptr->spell_forgotten1 & (1L << spell)))
3668 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
3669 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
3671 /* Spell is learned */
3672 if ((use_realm == p_ptr->realm2) ?
3673 (p_ptr->spell_learned2 & (1L << spell)) :
3674 (p_ptr->spell_learned1 & (1L << spell)))
3677 return (!study_pray);
3680 /* Okay to study, not to cast */
3687 * @brief 呪文情報の表示処理 /
3688 * Print a list of spells (for browsing or casting or viewing)
3689 * @param target_spell 呪文ID
3690 * @param spells 表示するスペルID配列の参照ポインタ
3691 * @param num 表示するスペルの数(spellsの要素数)
3692 * @param y 表示メッセージ左上Y座標
3693 * @param x 表示メッセージ左上X座標
3694 * @param use_realm 魔法領域ID
3697 void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm)
3701 int exp_level, increment = 64;
3702 const magic_type *s_ptr;
3707 MANA_POINT need_mana;
3712 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
3713 msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm"));
3715 /* Title the list */
3717 if (use_realm == REALM_HISSATSU)
3718 strcpy(buf,_(" Lv MP", " Lv SP"));
3720 strcpy(buf,_("熟練度 Lv MP 失率 効果", "Profic Lv SP Fail Effect"));
3722 put_str(_("名前", "Name"), y, x + 5);
3723 put_str(buf, y, x + 29);
3725 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
3726 else if (use_realm == p_ptr->realm1) increment = 0;
3727 else if (use_realm == p_ptr->realm2) increment = 32;
3729 /* Dump the spells */
3730 for (i = 0; i < num; i++)
3734 if (!is_magic(use_realm))
3736 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3740 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3743 if (use_realm == REALM_HISSATSU)
3744 need_mana = s_ptr->smana;
3747 EXP exp = experience_of_spell(spell, use_realm);
3749 /* Extract mana consumption rate */
3750 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
3752 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
3753 else exp_level = spell_exp_level(exp);
3756 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
3757 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
3758 else if (s_ptr->slevel >= 99) max = TRUE;
3759 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
3761 strncpy(ryakuji, exp_level_str[exp_level], 4);
3766 if (use_menu && target_spell)
3768 if (i == (target_spell-1))
3769 strcpy(out_val, _(" 》 ", " > "));
3771 strcpy(out_val, " ");
3773 else sprintf(out_val, " %c) ", I2A(i));
3774 /* Skip illegible spells */
3775 if (s_ptr->slevel >= 99)
3777 strcat(out_val, format("%-30s", _("(判読不能)", "(illegible)")));
3778 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
3782 /* XXX XXX Could label spells above the players level */
3784 /* Get extra info */
3785 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
3790 /* Assume spell is known and tried */
3791 line_attr = TERM_WHITE;
3793 /* Analyze the spell */
3794 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
3796 if (s_ptr->slevel > p_ptr->max_plv)
3798 comment = _("未知", "unknown");
3799 line_attr = TERM_L_BLUE;
3801 else if (s_ptr->slevel > p_ptr->lev)
3803 comment = _("忘却", "forgotten");
3804 line_attr = TERM_YELLOW;
3807 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
3809 comment = _("未知", "unknown");
3810 line_attr = TERM_L_BLUE;
3812 else if ((use_realm == p_ptr->realm1) ?
3813 ((p_ptr->spell_forgotten1 & (1L << spell))) :
3814 ((p_ptr->spell_forgotten2 & (1L << spell))))
3816 comment = _("忘却", "forgotten");
3817 line_attr = TERM_YELLOW;
3819 else if (!((use_realm == p_ptr->realm1) ?
3820 (p_ptr->spell_learned1 & (1L << spell)) :
3821 (p_ptr->spell_learned2 & (1L << spell))))
3823 comment = _("未知", "unknown");
3824 line_attr = TERM_L_BLUE;
3826 else if (!((use_realm == p_ptr->realm1) ?
3827 (p_ptr->spell_worked1 & (1L << spell)) :
3828 (p_ptr->spell_worked2 & (1L << spell))))
3830 comment = _("未経験", "untried");
3831 line_attr = TERM_L_GREEN;
3834 /* Dump the spell --(-- */
3835 if (use_realm == REALM_HISSATSU)
3837 strcat(out_val, format("%-25s %2d %4d",
3838 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3839 s_ptr->slevel, need_mana));
3843 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
3844 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
3845 (max ? '!' : ' '), ryakuji,
3846 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
3848 c_prt(line_attr, out_val, y + i + 1, x);
3851 /* Clear the bottom line */
3852 prt("", y + i + 1, x);
3856 * @brief 変身処理向けにモンスターの近隣レベル帯モンスターを返す /
3857 * Helper function -- return a "nearby" race for polymorphing
3858 * @param r_idx 基準となるモンスター種族ID
3859 * @return 変更先のモンスター種族ID
3861 * Note that this function is one of the more "dangerous" ones...
3863 static MONRACE_IDX poly_r_idx(MONRACE_IDX r_idx)
3865 monster_race *r_ptr = &r_info[r_idx];
3871 /* Hack -- Uniques/Questors never polymorph */
3872 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
3875 /* Allowable range of "levels" for resulting monster */
3876 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
3877 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
3879 /* Pick a (possibly new) non-unique race */
3880 for (i = 0; i < 1000; i++)
3882 /* Pick a new race, using a level calculation */
3883 r = get_mon_num((current_floor_ptr->dun_level + r_ptr->level) / 2 + 5);
3885 /* Handle failure */
3891 /* Ignore unique monsters */
3892 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3894 /* Ignore monsters with incompatible levels */
3895 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
3897 /* Use that index */
3906 * @brief 指定座標にいるモンスターを変身させる /
3907 * Helper function -- return a "nearby" race for polymorphing
3910 * @return 実際に変身したらTRUEを返す
3912 bool polymorph_monster(POSITION y, POSITION x)
3914 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
3915 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3916 bool polymorphed = FALSE;
3917 MONRACE_IDX new_r_idx;
3918 MONRACE_IDX old_r_idx = m_ptr->r_idx;
3919 bool targeted = (target_who == g_ptr->m_idx) ? TRUE : FALSE;
3920 bool health_tracked = (p_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
3921 monster_type back_m;
3923 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
3925 if ((p_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
3927 /* Memorize the monster before polymorphing */
3930 /* Pick a "new" monster race */
3931 new_r_idx = poly_r_idx(old_r_idx);
3933 /* Handle polymorph */
3934 if (new_r_idx != old_r_idx)
3936 BIT_FLAGS mode = 0L;
3937 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
3938 OBJECT_IDX this_o_idx, next_o_idx = 0;
3940 /* Get the monsters attitude */
3941 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
3942 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
3943 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
3945 /* Mega-hack -- ignore held objects */
3946 m_ptr->hold_o_idx = 0;
3948 /* "Kill" the "old" monster */
3949 delete_monster_idx(g_ptr->m_idx);
3951 /* Create a new monster (no groups) */
3952 if (place_monster_aux(0, y, x, new_r_idx, mode))
3954 current_floor_ptr->m_list[hack_m_idx_ii].nickname = back_m.nickname;
3955 current_floor_ptr->m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
3956 current_floor_ptr->m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
3963 /* Placing the new monster failed */
3964 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
3966 current_floor_ptr->m_list[hack_m_idx_ii] = back_m;
3968 /* Re-initialize monster process */
3971 else preserve_hold_objects = FALSE;
3974 /* Mega-hack -- preserve held objects */
3975 if (preserve_hold_objects)
3977 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3979 object_type *o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
3981 /* Acquire next object */
3982 next_o_idx = o_ptr->next_o_idx;
3984 /* Held by new monster */
3985 o_ptr->held_m_idx = hack_m_idx_ii;
3988 else if (back_m.hold_o_idx) /* Failed (paranoia) */
3990 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3992 /* Acquire next object */
3993 next_o_idx = current_floor_ptr->o_list[this_o_idx].next_o_idx;
3994 delete_object_idx(this_o_idx);
3998 if (targeted) target_who = hack_m_idx_ii;
3999 if (health_tracked) health_track(hack_m_idx_ii);
4008 * @param x テレポート先のX座標
4009 * @param y テレポート先のY座標
4010 * @return 目標に指定通りテレポートできたならばTRUEを返す
4012 static bool dimension_door_aux(DEPTH x, DEPTH y)
4014 PLAYER_LEVEL plev = p_ptr->lev;
4016 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
4018 if (!cave_player_teleportable_bold(y, x, 0L) ||
4019 (distance(y, x, p_ptr->y, p_ptr->x) > plev / 2 + 10) ||
4020 (!randint0(plev / 10 + 10)))
4022 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
4023 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
4030 teleport_player_to(y, x, 0L);
4039 * @brief 次元の扉処理のメインルーチン /
4041 * @return ターンを消費した場合TRUEを返す
4043 bool dimension_door(void)
4047 /* Rerutn FALSE if cancelled */
4048 if (!tgt_pt(&x, &y)) return FALSE;
4050 if (dimension_door_aux(x, y)) return TRUE;
4052 msg_print(_("精霊界から物質界に戻る時うまくいかなかった!", "You fail to exit the astral plane correctly!"));
4059 * @brief 鏡抜け処理のメインルーチン /
4060 * Mirror Master's Dimension Door
4061 * @return ターンを消費した場合TRUEを返す
4063 bool mirror_tunnel(void)
4065 POSITION x = 0, y = 0;
4067 /* Rerutn FALSE if cancelled */
4068 if (!tgt_pt(&x, &y)) return FALSE;
4070 if (dimension_door_aux(x, y)) return TRUE;
4072 msg_print(_("鏡の世界をうまく通れなかった!", "You fail to pass the mirror plane correctly!"));
4080 * @return ターンを消費した場合TRUEを返す
4082 bool eat_magic(int power)
4088 int recharge_strength = 0;
4094 GAME_TEXT o_name[MAX_NLEN];
4096 item_tester_hook = item_tester_hook_recharge;
4098 q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
4099 s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
4101 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
4102 if (!o_ptr) return FALSE;
4104 k_ptr = &k_info[o_ptr->k_idx];
4105 lev = k_info[o_ptr->k_idx].level;
4107 if (o_ptr->tval == TV_ROD)
4109 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
4112 if (one_in_(recharge_strength))
4114 /* Activate the failure code. */
4119 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
4121 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
4126 o_ptr->timeout += k_ptr->pval;
4132 /* All staffs, wands. */
4133 recharge_strength = (100 + power - lev) / 15;
4136 if (recharge_strength < 0) recharge_strength = 0;
4139 if (one_in_(recharge_strength))
4141 /* Activate the failure code. */
4146 if (o_ptr->pval > 0)
4148 p_ptr->csp += lev / 2;
4151 /* XXX Hack -- unstack if necessary */
4152 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
4158 /* Obtain a local object */
4159 object_copy(q_ptr, o_ptr);
4161 /* Modify quantity */
4164 /* Restore the charges */
4167 /* Unstack the used item */
4169 p_ptr->total_weight -= q_ptr->weight;
4170 item = inven_carry(q_ptr);
4172 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
4177 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
4179 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
4183 /* Inflict the penalties for failing a recharge. */
4186 /* Artifacts are never destroyed. */
4187 if (object_is_fixed_artifact(o_ptr))
4189 object_desc(o_name, o_ptr, OD_NAME_ONLY);
4190 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
4192 /* Artifact rods. */
4193 if (o_ptr->tval == TV_ROD)
4194 o_ptr->timeout = k_ptr->pval * o_ptr->number;
4196 /* Artifact wands and staffs. */
4197 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
4202 /* Get the object description */
4203 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4205 /*** Determine Seriousness of Failure ***/
4207 /* Mages recharge objects more safely. */
4208 if (IS_WIZARD_CLASS())
4210 /* 10% chance to blow up one rod, otherwise draining. */
4211 if (o_ptr->tval == TV_ROD)
4213 if (one_in_(10)) fail_type = 2;
4216 /* 75% chance to blow up one wand, otherwise draining. */
4217 else if (o_ptr->tval == TV_WAND)
4219 if (!one_in_(3)) fail_type = 2;
4222 /* 50% chance to blow up one staff, otherwise no effect. */
4223 else if (o_ptr->tval == TV_STAFF)
4225 if (one_in_(2)) fail_type = 2;
4230 /* All other classes get no special favors. */
4233 /* 33% chance to blow up one rod, otherwise draining. */
4234 if (o_ptr->tval == TV_ROD)
4236 if (one_in_(3)) fail_type = 2;
4239 /* 20% chance of the entire stack, else destroy one wand. */
4240 else if (o_ptr->tval == TV_WAND)
4242 if (one_in_(5)) fail_type = 3;
4245 /* Blow up one staff. */
4246 else if (o_ptr->tval == TV_STAFF)
4252 /*** Apply draining and destruction. ***/
4254 /* Drain object or stack of objects. */
4257 if (o_ptr->tval == TV_ROD)
4259 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。",
4260 "You save your rod from destruction, but all charges are lost."), o_name);
4261 o_ptr->timeout = k_ptr->pval * o_ptr->number;
4263 else if (o_ptr->tval == TV_WAND)
4265 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
4268 /* Staffs aren't drained. */
4271 /* Destroy an object or one in a stack of objects. */
4274 if (o_ptr->number > 1)
4276 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
4277 /* Reduce rod stack maximum timeout, drain wands. */
4278 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
4279 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
4283 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
4286 /* Reduce and describe inventory */
4289 inven_item_increase(item, -1);
4290 inven_item_describe(item);
4291 inven_item_optimize(item);
4294 /* Reduce and describe floor item */
4297 floor_item_increase(0 - item, -1);
4298 floor_item_describe(0 - item);
4299 floor_item_optimize(0 - item);
4303 /* Destroy all members of a stack of objects. */
4306 if (o_ptr->number > 1)
4307 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
4309 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
4311 /* Reduce and describe inventory */
4314 inven_item_increase(item, -999);
4315 inven_item_describe(item);
4316 inven_item_optimize(item);
4319 /* Reduce and describe floor item */
4322 floor_item_increase(0 - item, -999);
4323 floor_item_describe(0 - item);
4324 floor_item_optimize(0 - item);
4330 if (p_ptr->csp > p_ptr->msp)
4332 p_ptr->csp = p_ptr->msp;
4335 p_ptr->redraw |= (PR_MANA);
4336 p_ptr->update |= (PU_COMBINE | PU_REORDER);
4337 p_ptr->window |= (PW_INVEN);
4344 * @brief 皆殺し(全方向攻撃)処理
4345 * @param py プレイヤーY座標
4346 * @param px プレイヤーX座標
4353 monster_type *m_ptr;
4356 for (dir = 0; dir < 8; dir++)
4358 y = p_ptr->y + ddy_ddd[dir];
4359 x = p_ptr->x + ddx_ddd[dir];
4360 g_ptr = ¤t_floor_ptr->grid_array[y][x];
4361 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
4363 /* Hack -- attack monsters */
4364 if (g_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
4373 feature_type *f_ptr, *mimic_f_ptr;
4376 if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
4377 y = p_ptr->y + ddy[dir];
4378 x = p_ptr->x + ddx[dir];
4379 g_ptr = ¤t_floor_ptr->grid_array[y][x];
4380 f_ptr = &f_info[g_ptr->feat];
4381 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
4385 if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
4387 msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
4389 else if (have_flag(f_ptr->flags, FF_PERMANENT))
4391 msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch! This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
4393 else if (g_ptr->m_idx)
4395 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
4396 msg_print(_("何かが邪魔しています!", "There's something in the way!"));
4398 if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(y, x, 0);
4400 else if (have_flag(f_ptr->flags, FF_TREE))
4402 msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
4404 else if (have_flag(f_ptr->flags, FF_GLASS))
4406 msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
4408 else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
4410 (void)set_food(p_ptr->food + 3000);
4412 else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
4414 (void)set_food(p_ptr->food + 5000);
4418 msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
4419 (void)set_food(p_ptr->food + 10000);
4422 /* Destroy the wall */
4423 cave_alter_feat(y, x, FF_HURT_ROCK);
4425 (void)move_player_effect(y, x, MPE_DONT_PICKUP);
4430 bool shock_power(void)
4435 PLAYER_LEVEL plev = p_ptr->lev;
4436 int boost = P_PTR_KI;
4437 if (heavy_armor()) boost /= 2;
4440 if (!get_aim_dir(&dir)) return FALSE;
4442 y = p_ptr->y + ddy[dir];
4443 x = p_ptr->x + ddx[dir];
4444 dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
4445 fire_beam(GF_MISSILE, dir, dam);
4446 if (current_floor_ptr->grid_array[y][x].m_idx)
4449 POSITION ty = y, tx = x;
4450 POSITION oy = y, ox = x;
4451 MONSTER_IDX m_idx = current_floor_ptr->grid_array[y][x].m_idx;
4452 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
4453 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4454 GAME_TEXT m_name[MAX_NLEN];
4456 monster_desc(m_name, m_ptr, 0);
4458 if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2)
4460 msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
4464 for (i = 0; i < 5; i++)
4468 if (cave_empty_bold(y, x))
4475 if ((ty != oy) || (tx != ox))
4477 msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
4478 current_floor_ptr->grid_array[oy][ox].m_idx = 0;
4479 current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
4483 update_monster(m_idx, TRUE);
4487 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
4488 p_ptr->update |= (PU_MON_LITE);
4495 bool booze(player_type *creature_ptr)
4498 if (creature_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
4499 else if (!creature_ptr->resist_conf) creature_ptr->special_attack |= ATTACK_SUIKEN;
4500 if (!creature_ptr->resist_conf)
4502 if (set_confused(randint0(20) + 15))
4508 if (!creature_ptr->resist_chaos)
4512 if (set_image(creature_ptr->image + randint0(150) + 150))
4517 if (one_in_(13) && (creature_ptr->pclass != CLASS_MONK))
4520 if (one_in_(3)) lose_all_info();
4522 (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
4524 msg_print(_("知らない場所で目が醒めた。頭痛がする。", "You wake up somewhere with a sore head..."));
4525 msg_print(_("何も思い出せない。どうやってここへ来たのかも分からない!", "You can't remember a thing, or how you got here!"));
4531 bool detonation(player_type *creature_ptr)
4533 msg_print(_("体の中で激しい爆発が起きた!", "Massive explosions rupture your body!"));
4534 take_hit(DAMAGE_NOESCAPE, damroll(50, 20), _("爆発の薬", "a potion of Detonation"), -1);
4535 (void)set_stun(creature_ptr->stun + 75);
4536 (void)set_cut(creature_ptr->cut + 5000);
4540 void blood_curse_to_enemy(MONSTER_IDX m_idx)
4542 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
4543 grid_type *g_ptr = ¤t_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
4544 BIT_FLAGS curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
4548 switch (randint1(28))
4553 msg_print(_("地面が揺れた...", "The ground trembles..."));
4554 earthquake(m_ptr->fy, m_ptr->fx, 4 + randint0(4));
4555 if (!one_in_(6)) break;
4557 case 3: case 4: case 5: case 6:
4560 int extra_dam = damroll(10, 10);
4561 msg_print(_("純粋な魔力の次元への扉が開いた!", "A portal opens to a plane of raw mana!"));
4563 project(0, 8, m_ptr->fy, m_ptr->fx, extra_dam, GF_MANA, curse_flg, -1);
4564 if (!one_in_(6)) break;
4569 msg_print(_("空間が歪んだ!", "Space warps about you!"));
4571 if (m_ptr->r_idx) teleport_away(g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
4572 if (one_in_(13)) count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
4573 if (!one_in_(6)) break;
4575 case 9: case 10: case 11:
4576 msg_print(_("エネルギーのうねりを感じた!", "You feel a surge of energy!"));
4577 project(0, 7, m_ptr->fy, m_ptr->fx, 50, GF_DISINTEGRATE, curse_flg, -1);
4578 if (!one_in_(6)) break;
4579 case 12: case 13: case 14: case 15: case 16:
4580 aggravate_monsters(0);
4581 if (!one_in_(6)) break;
4583 count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
4584 if (!one_in_(6)) break;
4585 case 19: case 20: case 21: case 22:
4587 bool pet = !one_in_(3);
4588 BIT_FLAGS mode = PM_ALLOW_GROUP;
4590 if (pet) mode |= PM_FORCE_PET;
4591 else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
4593 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');
4594 if (!one_in_(6)) break;
4596 case 23: case 24: case 25:
4597 if (p_ptr->hold_exp && (randint0(100) < 75)) break;
4598 msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
4600 if (p_ptr->hold_exp) lose_exp(p_ptr->exp / 160);
4601 else lose_exp(p_ptr->exp / 16);
4602 if (!one_in_(6)) break;
4603 case 26: case 27: case 28:
4612 (void)do_dec_stat(i);
4613 } while (one_in_(2));
4620 (void)do_dec_stat(randint0(6));
4625 } while (one_in_(5));
4629 bool fire_crimson(void)
4633 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
4637 if (!get_aim_dir(&dir)) return FALSE;
4639 /* Use the given direction */
4640 tx = p_ptr->x + 99 * ddx[dir];
4641 ty = p_ptr->y + 99 * ddy[dir];
4643 /* Hack -- Use an actual "target" */
4644 if ((dir == 5) && target_okay())
4650 if (p_ptr->pclass == CLASS_ARCHER)
4652 /* Extra shot at level 10 */
4653 if (p_ptr->lev >= 10) num++;
4655 /* Extra shot at level 30 */
4656 if (p_ptr->lev >= 30) num++;
4658 /* Extra shot at level 45 */
4659 if (p_ptr->lev >= 45) num++;
4662 for (i = 0; i < num; i++)
4663 project(0, p_ptr->lev / 20 + 1, ty, tx, p_ptr->lev*p_ptr->lev * 6 / 50, GF_ROCKET, flg, -1);