1 #include "spell/spells-launcher.h"
2 #include "effect/effect-characteristics.h"
3 #include "io/targeting.h"
4 #include "spell/process-effect.h"
5 #include "spell/spells-type.h"
8 * @brief ボール系スペルの発動 / Cast a ball spell
9 * @param caster_ptr プレーヤーへの参照ポインタ
11 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
14 * @return 作用が実際にあった場合TRUEを返す
17 * Stop if we hit a monster, act as a "ball"
18 * Allow "target" mode to pass over monsters
19 * Affect grids, objects, and monsters
22 bool fire_ball(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
24 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
25 if (typ == GF_CHARM_LIVING)
28 POSITION tx = caster_ptr->x + 99 * ddx[dir];
29 POSITION ty = caster_ptr->y + 99 * ddy[dir];
31 if ((dir == 5) && target_okay(caster_ptr)) {
32 flg &= ~(PROJECT_STOP);
37 return project(caster_ptr, 0, rad, ty, tx, dam, typ, flg, -1);
41 * @brief ブレス系スペルの発動 / Cast a breath spell
42 * @param caster_ptr プレーヤーへの参照ポインタ
44 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
47 * @return 作用が実際にあった場合TRUEを返す
50 * Stop if we hit a monster, act as a "ball"
51 * Allow "target" mode to pass over monsters
52 * Affect grids, objects, and monsters
55 bool fire_breath(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad) { return fire_ball(caster_ptr, typ, dir, dam, -rad); }
58 * @brief ロケット系スペルの発動(詳細な差は確認中) / Cast a ball spell
59 * @param caster_ptr プレーヤーへの参照ポインタ
61 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
64 * @return 作用が実際にあった場合TRUEを返す
67 * Stop if we hit a monster, act as a "ball"
68 * Allow "target" mode to pass over monsters
69 * Affect grids, objects, and monsters
72 bool fire_rocket(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
74 POSITION tx = caster_ptr->x + 99 * ddx[dir];
75 POSITION ty = caster_ptr->y + 99 * ddy[dir];
76 if ((dir == 5) && target_okay(caster_ptr)) {
81 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
82 return (project(caster_ptr, 0, rad, ty, tx, dam, typ, flg, -1));
86 * @brief ボール(ハイド)系スペルの発動 / Cast a ball spell
87 * @param caster_ptr プレーヤーへの参照ポインタ
89 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
92 * @return 作用が実際にあった場合TRUEを返す
95 * Stop if we hit a monster, act as a "ball"
96 * Allow "target" mode to pass over monsters
97 * Affect grids, objects, and monsters
100 bool fire_ball_hide(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, POSITION rad)
102 POSITION tx = caster_ptr->x + 99 * ddx[dir];
103 POSITION ty = caster_ptr->y + 99 * ddy[dir];
104 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_HIDE;
105 if ((dir == 5) && target_okay(caster_ptr)) {
106 flg &= ~(PROJECT_STOP);
111 return (project(caster_ptr, 0, rad, ty, tx, dam, typ, flg, -1));
115 * @brief メテオ系スペルの発動 / Cast a meteor spell
116 * @param caster_ptr プレーヤーへの参照ポインタ
117 * @param who スぺル詠唱者のモンスターID(0=プレイヤー)
123 * @return 作用が実際にあった場合TRUEを返す
126 * Cast a meteor spell, defined as a ball spell cast by an arbitary monster,
127 * player, or outside source, that starts out at an arbitrary location, and
128 * leaving no trail from the "caster" to the target. This function is
129 * especially useful for bombardments and similar. -LM-
130 * Option to hurt the player.
133 bool fire_meteor(player_type *caster_ptr, MONSTER_IDX who, EFFECT_ID typ, POSITION y, POSITION x, HIT_POINT dam, POSITION rad)
135 BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
136 return (project(caster_ptr, who, rad, y, x, dam, typ, flg, -1));
140 * @brief ブラスト系スペルの発動 / Cast a blast spell
141 * @param caster_ptr プレーヤーへの参照ポインタ
143 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
148 * @return 作用が実際にあった場合TRUEを返す
150 bool fire_blast(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, DICE_NUMBER dd, DICE_SID ds, int num, int dev)
152 POSITION ty, tx, y, x;
158 lx = 20 * (tx - caster_ptr->x) + caster_ptr->x;
159 ly = 20 * (ty - caster_ptr->y) + caster_ptr->y;
161 ly = ty = caster_ptr->y + 20 * ddy[dir];
162 lx = tx = caster_ptr->x + 20 * ddx[dir];
165 int ld = distance(caster_ptr->y, caster_ptr->x, ly, lx);
166 BIT_FLAGS flg = PROJECT_FAST | PROJECT_THRU | PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE | PROJECT_GRID;
168 for (int i = 0; i < num; i++) {
170 /* Get targets for some bolts */
171 y = rand_spread(ly, ld * dev / 20);
172 x = rand_spread(lx, ld * dev / 20);
174 if (distance(ly, lx, y, x) <= ld * dev / 20)
178 /* Analyze the "dir" and the "target". */
179 if (!project(caster_ptr, 0, 0, y, x, damroll(dd, ds), typ, flg, -1)) {
188 * @brief ボルト系スペルの発動 / Cast a bolt spell.
189 * @param caster_ptr プレーヤーへの参照ポインタ
191 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
193 * @return 作用が実際にあった場合TRUEを返す
196 * Stop if we hit a monster, as a "bolt".
197 * Affect monsters and grids (not objects).
200 bool fire_bolt(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
202 BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_GRID;
204 flg |= PROJECT_REFLECTABLE;
205 return (project_hook(caster_ptr, typ, dir, dam, flg));
209 * @brief ビーム系スペルの発動 / Cast a beam spell.
210 * @param caster_ptr プレーヤーへの参照ポインタ
212 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
214 * @return 作用が実際にあった場合TRUEを返す
217 * Pass through monsters, as a "beam".
218 * Affect monsters, grids and objects.
221 bool fire_beam(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
223 BIT_FLAGS flg = PROJECT_BEAM | PROJECT_KILL | PROJECT_GRID | PROJECT_ITEM;
224 return (project_hook(caster_ptr, typ, dir, dam, flg));
228 * @brief 確率に応じたボルト系/ビーム系スペルの発動 / Cast a bolt spell, or rarely, a beam spell.
229 * @param caster_ptr プレーヤーへの参照ポインタ
230 * @param prob ビーム化する確率(%)
232 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
234 * @return 作用が実際にあった場合TRUEを返す
237 * Pass through monsters, as a "beam".
238 * Affect monsters, grids and objects.
241 bool fire_bolt_or_beam(player_type *caster_ptr, PERCENTAGE prob, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam)
243 if (randint0(100) < prob) {
244 return (fire_beam(caster_ptr, typ, dir, dam));
247 return (fire_bolt(caster_ptr, typ, dir, dam));
251 * @brief 指定方向に飛び道具を飛ばす (フラグ任意指定) / Apply a "project()" in a direction (or at the target)
252 * @param caster_ptr プレーヤーへの参照ポインタ
254 * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
257 * @return 作用が実際にあった場合TRUEを返す
259 bool project_hook(player_type *caster_ptr, EFFECT_ID typ, DIRECTION dir, HIT_POINT dam, BIT_FLAGS flg)
261 flg |= (PROJECT_THRU);
262 POSITION tx = caster_ptr->x + ddx[dir];
263 POSITION ty = caster_ptr->y + ddy[dir];
264 if ((dir == 5) && target_okay(caster_ptr)) {
269 return (project(caster_ptr, 0, 0, ty, tx, dam, typ, flg, -1));