2 * @brief ウィザードモード専用のスペル処理
7 #include "wizard/wizard-spells.h"
8 #include "blue-magic/blue-magic-checker.h"
9 #include "core/asking-player.h"
10 #include "effect/effect-characteristics.h"
11 #include "effect/effect-processor.h"
12 #include "floor/cave.h"
13 #include "floor/floor-util.h"
14 #include "floor/pattern-walk.h"
15 #include "io/gf-descriptions.h"
16 #include "mind/mind-blue-mage.h"
17 #include "monster-floor/monster-generator.h"
18 #include "monster-floor/monster-summon.h"
19 #include "monster-floor/place-monster-types.h"
20 #include "monster-race/monster-race.h"
21 #include "monster-race/race-ability-flags.h"
22 #include "monster-race/race-indice-types.h"
23 #include "mutation/mutation-processor.h"
24 #include "object-activation/activation-others.h"
25 #include "player-base/player-class.h"
26 #include "player-info/bluemage-data-type.h"
27 #include "player-info/smith-data-type.h"
28 #include "smith/object-smith.h"
29 #include "spell-kind/spells-launcher.h"
30 #include "spell-kind/spells-random.h"
31 #include "spell-kind/spells-teleport.h"
32 #include "spell-realm/spells-chaos.h"
33 #include "spell/spells-status.h"
34 #include "spell/summon-types.h"
35 #include "system/floor-type-definition.h"
36 #include "system/monster-race-info.h"
37 #include "system/player-type-definition.h"
38 #include "target/grid-selector.h"
39 #include "target/target-checker.h"
40 #include "target/target-getter.h"
41 #include "term/screen-processor.h"
42 #include "util/enum-converter.h"
43 #include "util/flag-group.h"
44 #include "view/display-messages.h"
45 #include "wizard/wizard-messages.h"
46 #include <string_view>
49 static const std::vector<debug_spell_command> debug_spell_commands_list = {
50 { 2, "vanish dungeon", { .spell2 = { vanish_dungeon } } },
51 { 2, "unique detection", { .spell2 = { activate_unique_detection } } },
52 { 3, "true healing", { .spell3 = { true_healing } } },
53 { 2, "drop weapons", { .spell2 = { drop_weapons } } },
54 { 4, "ty curse", { .spell4 = { activate_ty_curse } } },
55 { 5, "pattern teleport", { .spell5 = { pattern_teleport } } },
59 * @brief コマンド入力により任意にスペル効果を起こす / Wizard spells
60 * @param player_ptr プレイヤーへの参照ポインタ
62 void wiz_debug_spell(PlayerType *player_ptr)
64 const auto spell = input_string("SPELL: ", 50);
69 for (const auto &d : debug_spell_commands_list) {
70 if (*spell != d.command_name) {
76 (d.command_function.spell2.spell_function)(player_ptr);
79 const auto power = input_integer("POWER", -MAX_INT, MAX_INT);
84 (d.command_function.spell3.spell_function)(player_ptr, *power);
89 (d.command_function.spell4.spell_function)(player_ptr, true, &count);
93 (d.command_function.spell5.spell_function)(player_ptr);
96 msg_format("Command not found.");
103 * @brief 必ず成功するウィザードモード用次元の扉処理 / Wizard Dimension Door
104 * @param player_ptr プレイヤーへの参照ポインタ
106 void wiz_dimension_door(PlayerType *player_ptr)
108 POSITION x = 0, y = 0;
109 if (!tgt_pt(player_ptr, &x, &y)) {
113 teleport_player_to(player_ptr, y, x, TELEPORT_NONMAGICAL);
117 * @brief ウィザードモード用モンスターの群れ生成 / Summon a horde of monsters
118 * @param player_ptr プレイヤーへの参照ポインタ
120 void wiz_summon_horde(PlayerType *player_ptr)
122 POSITION wy = player_ptr->y, wx = player_ptr->x;
126 scatter(player_ptr, &wy, &wx, player_ptr->y, player_ptr->x, 3, PROJECT_NONE);
127 if (is_cave_empty_bold(player_ptr, wy, wx)) {
132 (void)alloc_horde(player_ptr, wy, wx, summon_specific);
136 * @brief ウィザードモード用処理としてターゲット中の相手をテレポートバックする / Hack -- Teleport to the target
138 void wiz_teleport_back(PlayerType *player_ptr)
144 teleport_player_to(player_ptr, target_row, target_col, TELEPORT_NONMAGICAL);
148 * @brief 青魔導師の魔法を全て習得済みにする /
149 * debug command for blue mage
151 void wiz_learn_blue_magic_all(PlayerType *player_ptr)
153 auto bluemage_data = PlayerClass(player_ptr).get_specific_data<bluemage_data_type>();
154 if (!bluemage_data) {
158 for (auto type : BLUE_MAGIC_TYPE_LIST) {
159 EnumClassFlagGroup<MonsterAbilityType> ability_flags;
160 set_rf_masks(ability_flags, type);
161 bluemage_data->learnt_blue_magics.set(ability_flags);
166 * @brief 鍛冶師の全てのエッセンスを最大所持量にする
168 void wiz_fillup_all_smith_essences(PlayerType *player_ptr)
170 auto smith_data = PlayerClass(player_ptr).get_specific_data<smith_data_type>();
175 for (auto essence : Smith::get_essence_list()) {
176 smith_data->essences[essence] = Smith::ESSENCE_AMOUNT_MAX;
181 * @brief 現在のフロアに合ったモンスターをランダムに生成する
182 * @param player_ptr プレイヤーへの参照ポインタ
184 * @details 半径5マス以内に生成する。生成場所がなかったらキャンセル。
186 void wiz_generate_random_monster(PlayerType *player_ptr, int num)
188 constexpr auto flags = PM_ALLOW_SLEEP | PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_QUEST;
189 for (auto i = 0; i < num; i++) {
190 if (!alloc_monster(player_ptr, 0, flags, summon_specific, 5)) {
191 msg_print_wizard(player_ptr, 1, "Monster isn't generated correctly...");
198 * @brief 現在のフロアに合ったモンスターをランダムに召喚する
199 * @param player_ptr プレイヤーへの参照ポインタ
201 * @details 現在のレベル+5F からランダムに選定する。生成場所がなかったらキャンセル。
203 void wiz_summon_random_monster(PlayerType *player_ptr, int num)
205 const auto level = player_ptr->current_floor_ptr->dun_level;
206 constexpr auto flags = PM_ALLOW_GROUP | PM_ALLOW_UNIQUE;
207 const auto y = player_ptr->y;
208 const auto x = player_ptr->x;
209 for (auto i = 0; i < num; i++) {
210 if (!summon_specific(player_ptr, 0, y, x, level, SUMMON_NONE, flags)) {
211 msg_print_wizard(player_ptr, 1, "Monster isn't summoned correctly...");
218 * @brief モンスターを種族IDを指定して自然生成と同じように召喚する /
219 * Summon a creature of the specified type
220 * @param r_idx モンスター種族ID(回数指定コマンド'0'で指定した回数がIDになる)
222 * This function is rather dangerous
224 void wiz_summon_specific_monster(PlayerType *player_ptr, MonsterRaceId r_idx)
226 if (!MonsterRace(r_idx).is_valid()) {
227 const auto new_monrace_id = input_numerics("MonsterID", 1, monraces_info.size() - 1, MonsterRaceId::FILTHY_URCHIN);
228 if (!new_monrace_id) {
232 r_idx = *new_monrace_id;
235 (void)summon_named_creature(player_ptr, 0, player_ptr->y, player_ptr->x, r_idx, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
239 * @brief モンスターを種族IDを指定してペット召喚する /
240 * Summon a creature of the specified type
241 * @param r_idx モンスター種族ID(回数指定コマンド'0'で指定した回数がIDになる)
243 * This function is rather dangerous
245 void wiz_summon_pet(PlayerType *player_ptr, MonsterRaceId r_idx)
247 if (!MonsterRace(r_idx).is_valid()) {
248 const auto new_monrace_id = input_numerics("MonsterID", 1, monraces_info.size() - 1, MonsterRaceId::FILTHY_URCHIN);
249 if (!new_monrace_id) {
253 r_idx = *new_monrace_id;
256 (void)summon_named_creature(player_ptr, 0, player_ptr->y, player_ptr->x, r_idx, PM_ALLOW_SLEEP | PM_ALLOW_GROUP | PM_FORCE_PET);
260 * @brief ターゲットを指定して指定ダメージ・指定属性・半径0のボールを放つ
262 * @param effect_idx 属性ID
263 * @param self 自分に与えるか否か
264 * @details デフォルトは100万・GF_ARROW(射撃)。RES_ALL持ちも一撃で殺せる。
266 void wiz_kill_target(PlayerType *player_ptr, int initial_dam, AttributeType effect_idx, const bool self)
268 auto dam = initial_dam;
270 const auto input_dam = input_integer("Damage", 1, 1000000, 1000000);
278 constexpr auto max = enum2i(AttributeType::MAX);
279 auto idx = effect_idx;
280 if (effect_idx == AttributeType::NONE) {
282 for (auto i = 1; i <= 23; i++) {
286 for (auto i = 0U; i < std::size(gf_descriptions); ++i) {
287 const auto &gf_description = gf_descriptions[i];
288 auto name = std::string_view(gf_description.name).substr(3); // 先頭の"GF_"を取り除く
289 auto num = enum2i(gf_description.num);
290 put_str(format("%03d:%-.10s^", num, name.data()), 1 + i / 5, 1 + (i % 5) * 16);
293 const auto input_effect_id = input_numerics("EffectID", 1, max - 1, idx);
294 if (!input_effect_id) {
299 idx = *input_effect_id;
304 project(player_ptr, -1, 0, player_ptr->y, player_ptr->x, dam, idx, PROJECT_KILL | PROJECT_PLAYER);
309 if (!get_aim_dir(player_ptr, &dir)) {
312 fire_ball(player_ptr, idx, dir, dam, 0);