OSDN Git Service

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