OSDN Git Service

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