2 * @file blue-magic-caster.cpp
3 * @brief 青魔法のその他系統の呪文定義と詠唱時分岐処理
6 #include "blue-magic/blue-magic-caster.h"
7 #include "blue-magic/blue-magic-ball-bolt.h"
8 #include "blue-magic/blue-magic-breath.h"
9 #include "blue-magic/blue-magic-spirit-curse.h"
10 #include "blue-magic/blue-magic-status.h"
11 #include "blue-magic/blue-magic-summon.h"
12 #include "blue-magic/blue-magic-util.h"
13 #include "blue-magic/learnt-info.h"
14 #include "floor/cave.h"
15 #include "hpmp/hp-mp-processor.h"
16 #include "monster-race/monster-race.h"
17 #include "monster-race/race-ability-flags.h"
18 #include "monster-race/race-flags-resistance.h"
19 #include "monster-race/race-flags1.h"
20 #include "monster/monster-describer.h"
21 #include "monster/monster-info.h"
22 #include "monster/monster-status.h"
23 #include "mspell/mspell-damage-calculator.h"
24 #include "spell-kind/spells-launcher.h"
25 #include "spell-kind/spells-lite.h"
26 #include "spell-kind/spells-neighbor.h"
27 #include "spell-kind/spells-sight.h"
28 #include "spell-kind/spells-teleport.h"
29 #include "spell-kind/spells-world.h"
30 #include "spell/spell-types.h"
31 #include "spell/spells-status.h"
32 #include "status/bad-status-setter.h"
33 #include "status/body-improvement.h"
34 #include "status/buff-setter.h"
35 #include "system/floor-type-definition.h"
36 #include "system/grid-type-definition.h"
37 #include "system/monster-race-definition.h"
38 #include "system/monster-type-definition.h"
39 #include "system/player-type-definition.h"
40 #include "target/projection-path-calculator.h"
41 #include "target/target-checker.h"
42 #include "target/target-getter.h"
43 #include "target/target-setter.h"
44 #include "target/target-types.h"
45 #include "view/display-messages.h"
47 static bool cast_blue_dispel(player_type *player_ptr)
49 if (!target_set(player_ptr, TARGET_KILL))
52 MONSTER_IDX m_idx = player_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
53 if ((m_idx == 0) || !player_has_los_bold(player_ptr, target_row, target_col)
54 || !projectable(player_ptr, player_ptr->y, player_ptr->x, target_row, target_col))
57 dispel_monster_status(player_ptr, m_idx);
61 static bool cast_blue_rocket(player_type *player_ptr, bmc_type *bmc_ptr)
63 if (!get_aim_dir(player_ptr, &bmc_ptr->dir))
66 msg_print(_("ロケットを発射した。", "You fire a rocket."));
67 bmc_ptr->damage = monspell_bluemage_damage(player_ptr, RF_ABILITY::ROCKET, bmc_ptr->plev, DAM_ROLL);
68 fire_rocket(player_ptr, GF_ROCKET, bmc_ptr->dir, bmc_ptr->damage, 2);
72 static bool cast_blue_shoot(player_type *player_ptr, bmc_type *bmc_ptr)
74 if (!get_aim_dir(player_ptr, &bmc_ptr->dir))
77 msg_print(_("矢を放った。", "You fire an arrow."));
78 bmc_ptr->damage = monspell_bluemage_damage(player_ptr, RF_ABILITY::SHOOT, bmc_ptr->plev, DAM_ROLL);
79 fire_bolt(player_ptr, GF_ARROW, bmc_ptr->dir, bmc_ptr->damage);
83 static bool cast_blue_hand_doom(player_type *player_ptr, bmc_type *bmc_ptr)
85 if (!get_aim_dir(player_ptr, &bmc_ptr->dir))
88 msg_print(_("<破滅の手>を放った!", "You invoke the Hand of Doom!"));
89 fire_ball_hide(player_ptr, GF_HAND_DOOM, bmc_ptr->dir, bmc_ptr->plev * 3, 0);
93 static bool exe_blue_teleport_back(player_type *player_ptr, GAME_TEXT *m_name)
97 floor_type *floor_ptr = player_ptr->current_floor_ptr;
98 if ((floor_ptr->grid_array[target_row][target_col].m_idx == 0) || !player_has_los_bold(player_ptr, target_row, target_col)
99 || !projectable(player_ptr, player_ptr->y, player_ptr->x, target_row, target_col))
102 m_ptr = &floor_ptr->m_list[floor_ptr->grid_array[target_row][target_col].m_idx];
103 r_ptr = &r_info[m_ptr->r_idx];
104 monster_desc(player_ptr, m_name, m_ptr, 0);
105 if ((r_ptr->flagsr & RFR_RES_TELE) == 0)
108 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flagsr & RFR_RES_ALL)) {
109 if (is_original_ap_and_seen(player_ptr, m_ptr))
110 r_ptr->r_flagsr |= RFR_RES_TELE;
112 msg_format(_("%sには効果がなかった!", "%s is unaffected!"), m_name);
116 if (r_ptr->level <= randint1(100))
119 if (is_original_ap_and_seen(player_ptr, m_ptr))
120 r_ptr->r_flagsr |= RFR_RES_TELE;
122 msg_format(_("%sには耐性がある!", "%s resists!"), m_name);
126 static bool cast_blue_teleport_back(player_type *player_ptr)
128 if (!target_set(player_ptr, TARGET_KILL))
131 GAME_TEXT m_name[MAX_NLEN];
132 if (exe_blue_teleport_back(player_ptr, m_name))
135 msg_format(_("%sを引き戻した。", "You command %s to return."), m_name);
137 player_ptr, player_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx, player_ptr->y, player_ptr->x, 100, TELEPORT_PASSIVE);
141 static bool cast_blue_teleport_away(player_type *player_ptr, bmc_type *bmc_ptr)
143 if (!get_aim_dir(player_ptr, &bmc_ptr->dir))
146 (void)fire_beam(player_ptr, GF_AWAY_ALL, bmc_ptr->dir, 100);
150 static bool cast_blue_psy_spear(player_type *player_ptr, bmc_type *bmc_ptr)
152 if (!get_aim_dir(player_ptr, &bmc_ptr->dir))
155 msg_print(_("光の剣を放った。", "You throw a psycho-spear."));
156 bmc_ptr->damage = monspell_bluemage_damage(player_ptr, RF_ABILITY::PSY_SPEAR, bmc_ptr->plev, DAM_ROLL);
157 (void)fire_beam(player_ptr, GF_PSY_SPEAR, bmc_ptr->dir, bmc_ptr->damage);
161 static bool cast_blue_make_trap(player_type *player_ptr)
163 if (!target_set(player_ptr, TARGET_KILL))
166 msg_print(_("呪文を唱えて邪悪に微笑んだ。", "You cast a spell and cackle evilly."));
167 trap_creation(player_ptr, target_row, target_col);
171 static bool switch_cast_blue_magic(player_type *player_ptr, bmc_type *bmc_ptr, RF_ABILITY spell)
174 case RF_ABILITY::SHRIEK:
175 msg_print(_("かん高い金切り声をあげた。", "You make a high pitched shriek."));
176 aggravate_monsters(player_ptr, 0);
178 case RF_ABILITY::XXX1:
179 case RF_ABILITY::XXX2:
180 case RF_ABILITY::XXX3:
181 case RF_ABILITY::XXX4:
183 case RF_ABILITY::DISPEL:
184 return cast_blue_dispel(player_ptr);
185 case RF_ABILITY::ROCKET:
186 return cast_blue_rocket(player_ptr, bmc_ptr);
187 case RF_ABILITY::SHOOT:
188 return cast_blue_shoot(player_ptr, bmc_ptr);
189 case RF_ABILITY::BR_ACID:
190 return cast_blue_breath_acid(player_ptr, bmc_ptr);
191 case RF_ABILITY::BR_ELEC:
192 return cast_blue_breath_elec(player_ptr, bmc_ptr);
193 case RF_ABILITY::BR_FIRE:
194 return cast_blue_breath_fire(player_ptr, bmc_ptr);
195 case RF_ABILITY::BR_COLD:
196 return cast_blue_breath_cold(player_ptr, bmc_ptr);
197 case RF_ABILITY::BR_POIS:
198 return cast_blue_breath_pois(player_ptr, bmc_ptr);
199 case RF_ABILITY::BR_NETH:
200 return cast_blue_breath_nether(player_ptr, bmc_ptr);
201 case RF_ABILITY::BR_LITE:
202 return cast_blue_breath_lite(player_ptr, bmc_ptr);
203 case RF_ABILITY::BR_DARK:
204 return cast_blue_breath_dark(player_ptr, bmc_ptr);
205 case RF_ABILITY::BR_CONF:
206 return cast_blue_breath_conf(player_ptr, bmc_ptr);
207 case RF_ABILITY::BR_SOUN:
208 return cast_blue_breath_sound(player_ptr, bmc_ptr);
209 case RF_ABILITY::BR_CHAO:
210 return cast_blue_breath_chaos(player_ptr, bmc_ptr);
211 case RF_ABILITY::BR_DISE:
212 return cast_blue_breath_disenchant(player_ptr, bmc_ptr);
213 case RF_ABILITY::BR_NEXU:
214 return cast_blue_breath_nexus(player_ptr, bmc_ptr);
215 case RF_ABILITY::BR_TIME:
216 return cast_blue_breath_time(player_ptr, bmc_ptr);
217 case RF_ABILITY::BR_INER:
218 return cast_blue_breath_inertia(player_ptr, bmc_ptr);
219 case RF_ABILITY::BR_GRAV:
220 return cast_blue_breath_gravity(player_ptr, bmc_ptr);
221 case RF_ABILITY::BR_SHAR:
222 return cast_blue_breath_shards(player_ptr, bmc_ptr);
223 case RF_ABILITY::BR_PLAS:
224 return cast_blue_breath_plasma(player_ptr, bmc_ptr);
225 case RF_ABILITY::BR_FORC:
226 return cast_blue_breath_force(player_ptr, bmc_ptr);
227 case RF_ABILITY::BR_MANA:
228 return cast_blue_breath_mana(player_ptr, bmc_ptr);
229 case RF_ABILITY::BR_NUKE:
230 return cast_blue_breath_nuke(player_ptr, bmc_ptr);
231 case RF_ABILITY::BR_DISI:
232 return cast_blue_breath_disintegration(player_ptr, bmc_ptr);
233 case RF_ABILITY::BA_ACID:
234 return cast_blue_ball_acid(player_ptr, bmc_ptr);
235 case RF_ABILITY::BA_ELEC:
236 return cast_blue_ball_elec(player_ptr, bmc_ptr);
237 case RF_ABILITY::BA_FIRE:
238 return cast_blue_ball_fire(player_ptr, bmc_ptr);
239 case RF_ABILITY::BA_COLD:
240 return cast_blue_ball_cold(player_ptr, bmc_ptr);
241 case RF_ABILITY::BA_POIS:
242 return cast_blue_ball_pois(player_ptr, bmc_ptr);
243 case RF_ABILITY::BA_NUKE:
244 return cast_blue_ball_nuke(player_ptr, bmc_ptr);
245 case RF_ABILITY::BA_NETH:
246 return cast_blue_ball_nether(player_ptr, bmc_ptr);
247 case RF_ABILITY::BA_CHAO:
248 return cast_blue_ball_chaos(player_ptr, bmc_ptr);
249 case RF_ABILITY::BA_WATE:
250 return cast_blue_ball_water(player_ptr, bmc_ptr);
251 case RF_ABILITY::BA_LITE:
252 return cast_blue_ball_star_burst(player_ptr, bmc_ptr);
253 case RF_ABILITY::BA_DARK:
254 return cast_blue_ball_dark_storm(player_ptr, bmc_ptr);
255 case RF_ABILITY::BA_MANA:
256 return cast_blue_ball_mana_storm(player_ptr, bmc_ptr);
257 case RF_ABILITY::DRAIN_MANA:
258 return cast_blue_drain_mana(player_ptr, bmc_ptr);
259 case RF_ABILITY::MIND_BLAST:
260 return cast_blue_mind_blast(player_ptr, bmc_ptr);
261 case RF_ABILITY::BRAIN_SMASH:
262 return cast_blue_brain_smash(player_ptr, bmc_ptr);
263 case RF_ABILITY::CAUSE_1:
264 return cast_blue_curse_1(player_ptr, bmc_ptr);
265 case RF_ABILITY::CAUSE_2:
266 return cast_blue_curse_2(player_ptr, bmc_ptr);
267 case RF_ABILITY::CAUSE_3:
268 return cast_blue_curse_3(player_ptr, bmc_ptr);
269 case RF_ABILITY::CAUSE_4:
270 return cast_blue_curse_4(player_ptr, bmc_ptr);
271 case RF_ABILITY::BO_ACID:
272 return cast_blue_bolt_acid(player_ptr, bmc_ptr);
273 case RF_ABILITY::BO_ELEC:
274 return cast_blue_bolt_elec(player_ptr, bmc_ptr);
275 case RF_ABILITY::BO_FIRE:
276 return cast_blue_bolt_fire(player_ptr, bmc_ptr);
277 case RF_ABILITY::BO_COLD:
278 return cast_blue_bolt_cold(player_ptr, bmc_ptr);
279 case RF_ABILITY::BO_NETH:
280 return cast_blue_bolt_nether(player_ptr, bmc_ptr);
281 case RF_ABILITY::BO_WATE:
282 return cast_blue_bolt_water(player_ptr, bmc_ptr);
283 case RF_ABILITY::BO_MANA:
284 return cast_blue_bolt_mana(player_ptr, bmc_ptr);
285 case RF_ABILITY::BO_PLAS:
286 return cast_blue_bolt_plasma(player_ptr, bmc_ptr);
287 case RF_ABILITY::BO_ICEE:
288 return cast_blue_bolt_icee(player_ptr, bmc_ptr);
289 case RF_ABILITY::MISSILE:
290 return cast_blue_bolt_missile(player_ptr, bmc_ptr);
291 case RF_ABILITY::SCARE:
292 return cast_blue_scare(player_ptr, bmc_ptr);
293 case RF_ABILITY::BLIND:
294 return cast_blue_blind(player_ptr, bmc_ptr);
295 case RF_ABILITY::CONF:
296 return cast_blue_confusion(player_ptr, bmc_ptr);
297 case RF_ABILITY::SLOW:
298 return cast_blue_slow(player_ptr, bmc_ptr);
299 case RF_ABILITY::HOLD:
300 return cast_blue_sleep(player_ptr, bmc_ptr);
301 case RF_ABILITY::HASTE:
302 (void)set_fast(player_ptr, randint1(20 + bmc_ptr->plev) + bmc_ptr->plev, false);
304 case RF_ABILITY::HAND_DOOM:
305 return cast_blue_hand_doom(player_ptr, bmc_ptr);
306 case RF_ABILITY::HEAL: {
307 msg_print(_("自分の傷に念を集中した。", "You concentrate on your wounds!"));
308 (void)hp_player(player_ptr, bmc_ptr->plev * 4);
309 BadStatusSetter bss(player_ptr);
314 case RF_ABILITY::INVULNER:
315 msg_print(_("無傷の球の呪文を唱えた。", "You cast a Globe of Invulnerability."));
316 (void)set_invuln(player_ptr, randint1(4) + 4, false);
318 case RF_ABILITY::BLINK:
319 teleport_player(player_ptr, 10, TELEPORT_SPONTANEOUS);
321 case RF_ABILITY::TPORT:
322 teleport_player(player_ptr, bmc_ptr->plev * 5, TELEPORT_SPONTANEOUS);
324 case RF_ABILITY::WORLD:
325 (void)time_walk(player_ptr);
327 case RF_ABILITY::SPECIAL:
329 case RF_ABILITY::TELE_TO:
330 return cast_blue_teleport_back(player_ptr);
331 case RF_ABILITY::TELE_AWAY:
332 return cast_blue_teleport_away(player_ptr, bmc_ptr);
333 case RF_ABILITY::TELE_LEVEL:
334 return teleport_level_other(player_ptr);
335 case RF_ABILITY::PSY_SPEAR:
336 return cast_blue_psy_spear(player_ptr, bmc_ptr);
337 case RF_ABILITY::DARKNESS:
338 msg_print(_("暗闇の中で手を振った。", "You gesture in shadow."));
339 (void)unlite_area(player_ptr, 10, 3);
341 case RF_ABILITY::TRAPS:
342 return cast_blue_make_trap(player_ptr);
343 case RF_ABILITY::FORGET:
344 msg_print(_("しかし何も起きなかった。", "Nothing happens."));
346 case RF_ABILITY::RAISE_DEAD:
347 msg_print(_("死者復活の呪文を唱えた。", "You animate the dead."));
348 (void)animate_dead(player_ptr, 0, player_ptr->y, player_ptr->x);
350 case RF_ABILITY::S_KIN:
351 return cast_blue_summon_kin(player_ptr, bmc_ptr);
352 case RF_ABILITY::S_CYBER:
353 return cast_blue_summon_cyber(player_ptr, bmc_ptr);
354 case RF_ABILITY::S_MONSTER:
355 return cast_blue_summon_monster(player_ptr, bmc_ptr);
356 case RF_ABILITY::S_MONSTERS:
357 return cast_blue_summon_monsters(player_ptr, bmc_ptr);
358 case RF_ABILITY::S_ANT:
359 return cast_blue_summon_ant(player_ptr, bmc_ptr);
360 case RF_ABILITY::S_SPIDER:
361 return cast_blue_summon_spider(player_ptr, bmc_ptr);
362 case RF_ABILITY::S_HOUND:
363 return cast_blue_summon_hound(player_ptr, bmc_ptr);
364 case RF_ABILITY::S_HYDRA:
365 return cast_blue_summon_hydra(player_ptr, bmc_ptr);
366 case RF_ABILITY::S_ANGEL:
367 return cast_blue_summon_angel(player_ptr, bmc_ptr);
368 case RF_ABILITY::S_DEMON:
369 return cast_blue_summon_demon(player_ptr, bmc_ptr);
370 case RF_ABILITY::S_UNDEAD:
371 return cast_blue_summon_undead(player_ptr, bmc_ptr);
372 case RF_ABILITY::S_DRAGON:
373 return cast_blue_summon_dragon(player_ptr, bmc_ptr);
374 case RF_ABILITY::S_HI_UNDEAD:
375 return cast_blue_summon_high_undead(player_ptr, bmc_ptr);
376 case RF_ABILITY::S_HI_DRAGON:
377 return cast_blue_summon_high_dragon(player_ptr, bmc_ptr);
378 case RF_ABILITY::S_AMBERITES:
379 return cast_blue_summon_amberite(player_ptr, bmc_ptr);
380 case RF_ABILITY::S_UNIQUE:
381 return cast_blue_summon_unique(player_ptr, bmc_ptr);
390 * do_cmd_cast calls this function if the player's class is 'blue-mage'.
391 * @param spell 発動するモンスター攻撃のID
392 * @param success TRUEは成功時、FALSEは失敗時の処理を行う
393 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
395 bool cast_learned_spell(player_type *player_ptr, RF_ABILITY spell, const bool success)
398 bmc_type *bmc_ptr = initialize_blue_magic_type(player_ptr, &tmp_bm, success, get_pseudo_monstetr_level);
399 if (!switch_cast_blue_magic(player_ptr, bmc_ptr, spell))
402 if (bmc_ptr->no_trump)
403 msg_print(_("何も現れなかった。", "No one appeared."));