1 #include "blue-magic/blue-magic-caster.h"
2 #include "blue-magic/blue-magic-ball-bolt.h"
3 #include "blue-magic/blue-magic-breath.h"
4 #include "blue-magic/blue-magic-spirit-curse.h"
5 #include "blue-magic/blue-magic-status.h"
6 #include "blue-magic/blue-magic-summon.h"
7 #include "blue-magic/blue-magic-util.h"
8 #include "blue-magic/learnt-info.h"
9 #include "core/hp-mp-processor.h"
10 #include "floor/cave.h"
11 #include "grid/grid.h"
12 #include "monster-race/monster-race.h"
13 #include "monster-race/race-flags-resistance.h"
14 #include "monster-race/race-flags1.h"
15 #include "monster/monster-describer.h"
16 #include "monster/monster-info.h"
17 #include "monster/monster-status.h"
18 #include "mspell/mspell-damage-calculator.h"
19 #include "spell-kind/spells-launcher.h"
20 #include "spell-kind/spells-lite.h"
21 #include "spell-kind/spells-neighbor.h"
22 #include "spell-kind/spells-sight.h"
23 #include "spell-kind/spells-teleport.h"
24 #include "spell-kind/spells-world.h"
25 #include "spell/spell-types.h"
26 #include "spell/spells-status.h"
27 #include "status/bad-status-setter.h"
28 #include "status/body-improvement.h"
29 #include "status/buff-setter.h"
30 #include "system/floor-type-definition.h"
31 #include "target/projection-path-calculator.h"
32 #include "target/target-checker.h"
33 #include "target/target-getter.h"
34 #include "target/target-setter.h"
35 #include "target/target-types.h"
36 #include "view/display-messages.h"
38 static bool cast_blue_dispel(player_type *caster_ptr)
40 if (!target_set(caster_ptr, TARGET_KILL))
43 MONSTER_IDX m_idx = caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
44 if ((m_idx == 0) || !player_has_los_bold(caster_ptr, target_row, target_col)
45 || !projectable(caster_ptr, caster_ptr->y, caster_ptr->x, target_row, target_col))
48 dispel_monster_status(caster_ptr, m_idx);
52 static bool cast_blue_rocket(player_type *caster_ptr, bmc_type *bmc_ptr)
54 if (!get_aim_dir(caster_ptr, &bmc_ptr->dir))
57 msg_print(_("ロケットを発射した。", "You fire a rocket."));
58 bmc_ptr->damage = monspell_bluemage_damage(caster_ptr, (MS_ROCKET), bmc_ptr->plev, DAM_ROLL);
59 fire_rocket(caster_ptr, GF_ROCKET, bmc_ptr->dir, bmc_ptr->damage, 2);
63 static bool cast_blue_shoot(player_type *caster_ptr, bmc_type *bmc_ptr)
65 if (!get_aim_dir(caster_ptr, &bmc_ptr->dir))
68 msg_print(_("矢を放った。", "You fire an arrow."));
69 bmc_ptr->damage = monspell_bluemage_damage(caster_ptr, (MS_SHOOT), bmc_ptr->plev, DAM_ROLL);
70 fire_bolt(caster_ptr, GF_ARROW, bmc_ptr->dir, bmc_ptr->damage);
74 static bool cast_blue_hand_doom(player_type *caster_ptr, bmc_type *bmc_ptr)
76 if (!get_aim_dir(caster_ptr, &bmc_ptr->dir))
79 msg_print(_("<破滅の手>を放った!", "You invoke the Hand of Doom!"));
80 fire_ball_hide(caster_ptr, GF_HAND_DOOM, bmc_ptr->dir, bmc_ptr->plev * 3, 0);
84 static bool exe_blue_teleport_back(player_type *caster_ptr, GAME_TEXT *m_name)
88 floor_type *floor_ptr = caster_ptr->current_floor_ptr;
89 if ((floor_ptr->grid_array[target_row][target_col].m_idx == 0) || !player_has_los_bold(caster_ptr, target_row, target_col)
90 || !projectable(caster_ptr, caster_ptr->y, caster_ptr->x, target_row, target_col))
93 m_ptr = &floor_ptr->m_list[floor_ptr->grid_array[target_row][target_col].m_idx];
94 r_ptr = &r_info[m_ptr->r_idx];
95 monster_desc(caster_ptr, m_name, m_ptr, 0);
96 if ((r_ptr->flagsr & RFR_RES_TELE) == 0)
99 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flagsr & RFR_RES_ALL)) {
100 if (is_original_ap_and_seen(caster_ptr, m_ptr))
101 r_ptr->r_flagsr |= RFR_RES_TELE;
103 msg_format(_("%sには効果がなかった!", "%s is unaffected!"), m_name);
107 if (r_ptr->level <= randint1(100))
110 if (is_original_ap_and_seen(caster_ptr, m_ptr))
111 r_ptr->r_flagsr |= RFR_RES_TELE;
113 msg_format(_("%sには耐性がある!", "%s resists!"), m_name);
117 static bool cast_blue_teleport_back(player_type *caster_ptr)
119 if (!target_set(caster_ptr, TARGET_KILL))
122 GAME_TEXT m_name[MAX_NLEN];
123 if (exe_blue_teleport_back(caster_ptr, m_name))
126 msg_format(_("%sを引き戻した。", "You command %s to return."), m_name);
128 caster_ptr, caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx, caster_ptr->y, caster_ptr->x, 100, TELEPORT_PASSIVE);
132 static bool cast_blue_teleport_away(player_type *caster_ptr, bmc_type *bmc_ptr)
134 if (!get_aim_dir(caster_ptr, &bmc_ptr->dir))
137 (void)fire_beam(caster_ptr, GF_AWAY_ALL, bmc_ptr->dir, 100);
141 static bool cast_blue_psy_spear(player_type *caster_ptr, bmc_type *bmc_ptr)
143 if (!get_aim_dir(caster_ptr, &bmc_ptr->dir))
146 msg_print(_("光の剣を放った。", "You throw a psycho-spear."));
147 bmc_ptr->damage = monspell_bluemage_damage(caster_ptr, (MS_PSY_SPEAR), bmc_ptr->plev, DAM_ROLL);
148 (void)fire_beam(caster_ptr, GF_PSY_SPEAR, bmc_ptr->dir, bmc_ptr->damage);
152 static bool cast_blue_make_trap(player_type *caster_ptr)
154 if (!target_set(caster_ptr, TARGET_KILL))
157 msg_print(_("呪文を唱えて邪悪に微笑んだ。", "You cast a spell and cackle evilly."));
158 trap_creation(caster_ptr, target_row, target_col);
162 bool switch_cast_blue_magic(player_type *caster_ptr, bmc_type *bmc_ptr, SPELL_IDX spell)
166 msg_print(_("かん高い金切り声をあげた。", "You make a high pitched shriek."));
167 aggravate_monsters(caster_ptr, 0);
175 return cast_blue_dispel(caster_ptr);
177 return cast_blue_rocket(caster_ptr, bmc_ptr);
179 return cast_blue_shoot(caster_ptr, bmc_ptr);
181 return cast_blue_breath_acid(caster_ptr, bmc_ptr);
183 return cast_blue_breath_elec(caster_ptr, bmc_ptr);
185 return cast_blue_breath_fire(caster_ptr, bmc_ptr);
187 return cast_blue_breath_cold(caster_ptr, bmc_ptr);
189 return cast_blue_breath_pois(caster_ptr, bmc_ptr);
191 return cast_blue_breath_nether(caster_ptr, bmc_ptr);
193 return cast_blue_breath_lite(caster_ptr, bmc_ptr);
195 return cast_blue_breath_dark(caster_ptr, bmc_ptr);
197 return cast_blue_breath_conf(caster_ptr, bmc_ptr);
199 return cast_blue_breath_sound(caster_ptr, bmc_ptr);
201 return cast_blue_breath_chaos(caster_ptr, bmc_ptr);
203 return cast_blue_breath_disenchant(caster_ptr, bmc_ptr);
205 return cast_blue_breath_nexus(caster_ptr, bmc_ptr);
207 return cast_blue_breath_time(caster_ptr, bmc_ptr);
209 return cast_blue_breath_inertia(caster_ptr, bmc_ptr);
211 return cast_blue_breath_gravity(caster_ptr, bmc_ptr);
213 return cast_blue_breath_shards(caster_ptr, bmc_ptr);
215 return cast_blue_breath_plasma(caster_ptr, bmc_ptr);
217 return cast_blue_breath_force(caster_ptr, bmc_ptr);
219 return cast_blue_breath_mana(caster_ptr, bmc_ptr);
221 return cast_blue_breath_nuke(caster_ptr, bmc_ptr);
223 return cast_blue_breath_disintegration(caster_ptr, bmc_ptr);
225 return cast_blue_ball_acid(caster_ptr, bmc_ptr);
227 return cast_blue_ball_elec(caster_ptr, bmc_ptr);
229 return cast_blue_ball_fire(caster_ptr, bmc_ptr);
231 return cast_blue_ball_cold(caster_ptr, bmc_ptr);
233 return cast_blue_ball_pois(caster_ptr, bmc_ptr);
235 return cast_blue_ball_nuke(caster_ptr, bmc_ptr);
237 return cast_blue_ball_nether(caster_ptr, bmc_ptr);
239 return cast_blue_ball_chaos(caster_ptr, bmc_ptr);
241 return cast_blue_ball_water(caster_ptr, bmc_ptr);
243 return cast_blue_ball_star_burst(caster_ptr, bmc_ptr);
245 return cast_blue_ball_dark_storm(caster_ptr, bmc_ptr);
247 return cast_blue_ball_mana_storm(caster_ptr, bmc_ptr);
249 return cast_blue_drain_mana(caster_ptr, bmc_ptr);
251 return cast_blue_mind_blast(caster_ptr, bmc_ptr);
253 return cast_blue_brain_smash(caster_ptr, bmc_ptr);
255 return cast_blue_curse_1(caster_ptr, bmc_ptr);
257 return cast_blue_curse_2(caster_ptr, bmc_ptr);
259 return cast_blue_curse_3(caster_ptr, bmc_ptr);
261 return cast_blue_curse_4(caster_ptr, bmc_ptr);
263 return cast_blue_bolt_acid(caster_ptr, bmc_ptr);
265 return cast_blue_bolt_elec(caster_ptr, bmc_ptr);
267 return !cast_blue_bolt_fire(caster_ptr, bmc_ptr);
269 return cast_blue_bolt_cold(caster_ptr, bmc_ptr);
271 return cast_blue_bolt_nether(caster_ptr, bmc_ptr);
273 return cast_blue_bolt_water(caster_ptr, bmc_ptr);
275 return cast_blue_bolt_mana(caster_ptr, bmc_ptr);
277 return cast_blue_bolt_plasma(caster_ptr, bmc_ptr);
279 return cast_blue_bolt_icee(caster_ptr, bmc_ptr);
280 case MS_MAGIC_MISSILE:
281 return cast_blue_bolt_missile(caster_ptr, bmc_ptr);
283 return cast_blue_scare(caster_ptr, bmc_ptr);
285 return cast_blue_blind(caster_ptr, bmc_ptr);
287 return cast_blue_confusion(caster_ptr, bmc_ptr);
289 return cast_blue_slow(caster_ptr, bmc_ptr);
291 return cast_blue_sleep(caster_ptr, bmc_ptr);
293 (void)set_fast(caster_ptr, randint1(20 + bmc_ptr->plev) + bmc_ptr->plev, FALSE);
296 return cast_blue_hand_doom(caster_ptr, bmc_ptr);
298 msg_print(_("自分の傷に念を集中した。", "You concentrate on your wounds!"));
299 (void)hp_player(caster_ptr, bmc_ptr->plev * 4);
300 (void)set_stun(caster_ptr, 0);
301 (void)set_cut(caster_ptr, 0);
304 msg_print(_("無傷の球の呪文を唱えた。", "You cast a Globe of Invulnerability."));
305 (void)set_invuln(caster_ptr, randint1(4) + 4, FALSE);
308 teleport_player(caster_ptr, 10, TELEPORT_SPONTANEOUS);
311 teleport_player(caster_ptr, bmc_ptr->plev * 5, TELEPORT_SPONTANEOUS);
314 (void)time_walk(caster_ptr);
319 return cast_blue_teleport_back(caster_ptr);
321 return cast_blue_teleport_away(caster_ptr, bmc_ptr);
323 return teleport_level_other(caster_ptr);
325 return cast_blue_psy_spear(caster_ptr, bmc_ptr);
327 msg_print(_("暗闇の中で手を振った。", "You gesture in shadow."));
328 (void)unlite_area(caster_ptr, 10, 3);
331 return cast_blue_make_trap(caster_ptr);
333 msg_print(_("しかし何も起きなかった。", "Nothing happen."));
336 msg_print(_("死者復活の呪文を唱えた。", "You animate the dead."));
337 (void)animate_dead(caster_ptr, 0, caster_ptr->y, caster_ptr->x);
340 return cast_blue_summon_kin(caster_ptr, bmc_ptr);
342 return cast_blue_summon_cyber(caster_ptr, bmc_ptr);
344 return cast_blue_summon_monster(caster_ptr, bmc_ptr);
346 return cast_blue_summon_monsters(caster_ptr, bmc_ptr);
348 return cast_blue_summon_ant(caster_ptr, bmc_ptr);
350 return cast_blue_summon_spider(caster_ptr, bmc_ptr);
352 return cast_blue_summon_hound(caster_ptr, bmc_ptr);
354 return cast_blue_summon_hydra(caster_ptr, bmc_ptr);
356 return cast_blue_summon_angel(caster_ptr, bmc_ptr);
358 return cast_blue_summon_demon(caster_ptr, bmc_ptr);
360 return cast_blue_summon_undead(caster_ptr, bmc_ptr);
362 return cast_blue_summon_dragon(caster_ptr, bmc_ptr);
364 return cast_blue_summon_high_undead(caster_ptr, bmc_ptr);
366 return cast_blue_summon_high_dragon(caster_ptr, bmc_ptr);
368 return cast_blue_summon_amberite(caster_ptr, bmc_ptr);
370 return cast_blue_summon_unique(caster_ptr, bmc_ptr);
379 * do_cmd_cast calls this function if the player's class is 'blue-mage'.
380 * @param spell 発動するモンスター攻撃のID
381 * @param success TRUEは成功時、FALSEは失敗時の処理を行う
382 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
384 bool cast_learned_spell(player_type *caster_ptr, SPELL_IDX spell, const bool success)
387 bmc_type *bmc_ptr = initialize_blue_magic_type(caster_ptr, &tmp_bm, success, get_pseudo_monstetr_level);
388 if (!switch_cast_blue_magic(caster_ptr, bmc_ptr, spell))
391 if (bmc_ptr->no_trump)
392 msg_print(_("何も現れなかった。", "No one appeared."));