OSDN Git Service

[Refactor] #40569 Separated floor-type-definition.h from floor.h
[hengband/hengband.git] / src / wizard / wizard-spells.c
1 /*!
2  * @brief ウィザードモード専用のスペル処理
3  * @date 2020/06/27
4  * @author Hourier
5  */
6
7 #include "wizard/wizard-spells.h"
8 #include "core/asking-player.h"
9 #include "floor/floor.h"
10 #include "io/targeting.h"
11 #include "monster-floor/monster-generator.h"
12 #include "monster-floor/monster-summon.h"
13 #include "monster-floor/place-monster-types.h"
14 #include "mutation/mutation-processor.h"
15 #include "mspell/mspells3.h"
16 #include "spell-kind/spells-teleport.h"
17 #include "spell-realm/spells-chaos.h"
18 #include "spell/spells-status.h"
19 #include "system/floor-type-definition.h"
20 #include "view/display-messages.h"
21
22 debug_spell_command debug_spell_commands_list[SPELL_MAX] = {
23     { 2, "vanish dungeon", { .spell2 = { vanish_dungeon } } },
24     { 3, "true healing", { .spell3 = { true_healing } } },
25     { 2, "drop weapons", { .spell2 = { drop_weapons } } },
26 };
27
28 /*!
29  * @brief コマンド入力により任意にスペル効果を起こす / Wizard spells
30  * @return 実際にテレポートを行ったらTRUEを返す
31  */
32 bool do_cmd_debug_spell(player_type *creature_ptr)
33 {
34     char tmp_val[50] = "\0";
35     int tmp_int;
36
37     if (!get_string("SPELL: ", tmp_val, 32))
38         return FALSE;
39
40     for (int i = 0; i < SPELL_MAX; i++) {
41         if (strcmp(tmp_val, debug_spell_commands_list[i].command_name) != 0)
42             continue;
43
44         switch (debug_spell_commands_list[i].type) {
45         case 2:
46             (*(debug_spell_commands_list[i].command_function.spell2.spell_function))(creature_ptr);
47             return TRUE;
48             break;
49         case 3:
50             tmp_val[0] = '\0';
51             if (!get_string("POWER:", tmp_val, 32))
52                 return FALSE;
53             tmp_int = atoi(tmp_val);
54             (*(debug_spell_commands_list[i].command_function.spell3.spell_function))(creature_ptr, tmp_int);
55             return TRUE;
56             break;
57         default:
58             break;
59         }
60     }
61
62     msg_format("Command not found.");
63     return FALSE;
64 }
65
66 /*!
67  * @brief 必ず成功するウィザードモード用次元の扉処理 / Wizard Dimension Door
68  * @param caster_ptr プレーヤーへの参照ポインタ
69  * @return なし
70  */
71 void wiz_dimension_door(player_type *caster_ptr)
72 {
73     POSITION x = 0, y = 0;
74     if (!tgt_pt(caster_ptr, &x, &y))
75         return;
76
77     teleport_player_to(caster_ptr, y, x, TELEPORT_NONMAGICAL);
78 }
79
80 /*!
81  * @brief ウィザードモード用モンスターの群れ生成 / Summon a horde of monsters
82  * @param caster_ptr プレーヤーへの参照ポインタ
83  * @return なし
84  */
85 void do_cmd_summon_horde(player_type *caster_ptr)
86 {
87     POSITION wy = caster_ptr->y, wx = caster_ptr->x;
88     int attempts = 1000;
89
90     while (--attempts) {
91         scatter(caster_ptr, &wy, &wx, caster_ptr->y, caster_ptr->x, 3, 0);
92         if (is_cave_empty_bold(caster_ptr, wy, wx))
93             break;
94     }
95
96     (void)alloc_horde(caster_ptr, wy, wx, summon_specific);
97 }
98
99 /*!
100  * @brief ウィザードモード用処理としてターゲット中の相手をテレポートバックする / Hack -- Teleport to the target
101  * @return なし
102  */
103 void do_cmd_wiz_bamf(player_type *caster_ptr)
104 {
105     if (!target_who)
106         return;
107
108     teleport_player_to(caster_ptr, target_row, target_col, TELEPORT_NONMAGICAL);
109 }
110
111 /*!
112  * @brief 青魔導師の魔法を全て習得済みにする /
113  * debug command for blue mage
114  * @return なし
115  */
116 void do_cmd_wiz_blue_mage(player_type *caster_ptr)
117 {
118     BIT_FLAGS f4 = 0L, f5 = 0L, f6 = 0L;
119     for (int j = 1; j < A_MAX; j++) {
120         set_rf_masks(&f4, &f5, &f6, j);
121
122         int i;
123         for (i = 0; i < 32; i++) {
124             if ((0x00000001 << i) & f4)
125                 caster_ptr->magic_num2[i] = 1;
126         }
127
128         for (; i < 64; i++) {
129             if ((0x00000001 << (i - 32)) & f5)
130                 caster_ptr->magic_num2[i] = 1;
131         }
132
133         for (; i < 96; i++) {
134             if ((0x00000001 << (i - 64)) & f6)
135                 caster_ptr->magic_num2[i] = 1;
136         }
137     }
138 }
139
140 /*!
141  * @brief 現在のフロアに合ったモンスターをランダムに召喚する /
142  * Summon some creatures
143  * @param caster_ptr プレーヤーへの参照ポインタ
144  * @param num 生成処理回数
145  * @return なし
146  */
147 void do_cmd_wiz_summon(player_type *caster_ptr, int num)
148 {
149     for (int i = 0; i < num; i++) {
150         (void)summon_specific(caster_ptr, 0, caster_ptr->y, caster_ptr->x, caster_ptr->current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
151     }
152 }
153
154 /*!
155  * @brief モンスターを種族IDを指定して敵対的に召喚する /
156  * Summon a creature of the specified type
157  * @param r_idx モンスター種族ID
158  * @return なし
159  * @details
160  * This function is rather dangerous
161  */
162 void do_cmd_wiz_named(player_type *summoner_ptr, MONRACE_IDX r_idx)
163 {
164     (void)summon_named_creature(summoner_ptr, 0, summoner_ptr->y, summoner_ptr->x, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
165 }
166
167 /*!
168  * @brief モンスターを種族IDを指定してペット召喚する /
169  * Summon a creature of the specified type
170  * @param r_idx モンスター種族ID
171  * @return なし
172  * @details
173  * This function is rather dangerous
174  */
175 void do_cmd_wiz_named_friendly(player_type *summoner_ptr, MONRACE_IDX r_idx)
176 {
177     (void)summon_named_creature(summoner_ptr, 0, summoner_ptr->y, summoner_ptr->x, r_idx, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP | PM_FORCE_PET));
178 }