1 #include "mind/mind-force-trainer.h"
2 #include "avatar/avatar.h"
3 #include "core/disturbance.h"
4 #include "core/player-redraw-types.h"
5 #include "core/player-update-types.h"
6 #include "core/stuff-handler.h"
7 #include "effect/spells-effect-util.h"
8 #include "floor/cave.h"
9 #include "floor/geometry.h"
10 #include "game-option/disturbance-options.h"
11 #include "grid/grid.h"
12 #include "mind/mind-magic-resistance.h"
13 #include "mind/mind-numbers.h"
14 #include "monster-floor/monster-summon.h"
15 #include "monster-floor/place-monster-types.h"
16 #include "monster-race/monster-race.h"
17 #include "monster-race/race-flags7.h"
18 #include "monster/monster-describer.h"
19 #include "monster/monster-status.h"
20 #include "monster/monster-update.h"
21 #include "pet/pet-util.h"
22 #include "player-info/equipment-info.h"
23 #include "player/player-damage.h"
24 #include "spell-kind/spells-launcher.h"
25 #include "spell-kind/spells-lite.h"
26 #include "spell/spell-types.h"
27 #include "spell/summon-types.h"
28 #include "status/temporary-resistance.h"
29 #include "system/floor-type-definition.h"
30 #include "system/grid-type-definition.h"
31 #include "system/monster-race-definition.h"
32 #include "system/monster-type-definition.h"
33 #include "system/player-type-definition.h"
34 #include "target/projection-path-calculator.h"
35 #include "target/target-checker.h"
36 #include "target/target-getter.h"
37 #include "target/target-setter.h"
38 #include "target/target-types.h"
39 #include "view/display-messages.h"
42 * @brief 練気術師が「練気」で溜めた気の量を返す
43 * @param caster_ptr プレーヤーの参照ポインタ
46 s32b get_current_ki(player_type *caster_ptr)
48 return caster_ptr->magic_num1[0];
52 * @brief 練気術師において、気を溜める
53 * @param caster_ptr プレーヤーの参照ポインタ
54 * @param is_reset TRUEなら気の量をkiにセットし、FALSEなら加減算を行う
57 void set_current_ki(player_type *caster_ptr, bool is_reset, s32b ki)
60 caster_ptr->magic_num1[0] = ki;
64 caster_ptr->magic_num1[0] += ki;
67 bool clear_mind(player_type *creature_ptr)
70 msg_print(_("今はペットを操ることに集中していないと。", "Your pets demand all of your attention."));
74 msg_print(_("少し頭がハッキリした。", "You feel your head clear a little."));
76 creature_ptr->csp += (3 + creature_ptr->lev / 20);
77 if (creature_ptr->csp >= creature_ptr->msp) {
78 creature_ptr->csp = creature_ptr->msp;
79 creature_ptr->csp_frac = 0;
82 creature_ptr->redraw |= (PR_MANA);
87 * @brief 光速移動の継続時間をセットする / Set "lightspeed", notice observable changes
89 * @param do_dec 現在の継続時間より長い値のみ上書きする
91 void set_lightspeed(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
94 v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
96 if (creature_ptr->is_dead)
99 if (creature_ptr->wild_mode)
103 if (creature_ptr->lightspeed && !do_dec) {
104 if (creature_ptr->lightspeed > v)
106 } else if (!creature_ptr->lightspeed) {
107 msg_print(_("非常に素早く動けるようになった!", "You feel yourself moving extremely fast!"));
109 chg_virtue(creature_ptr, V_PATIENCE, -1);
110 chg_virtue(creature_ptr, V_DILIGENCE, 1);
113 if (creature_ptr->lightspeed) {
114 msg_print(_("動きの素早さがなくなったようだ。", "You feel yourself slow down."));
119 creature_ptr->lightspeed = v;
125 disturb(creature_ptr, false, false);
126 creature_ptr->update |= (PU_BONUS);
127 handle_stuff(creature_ptr);
131 * @brief 一時的闘気のオーラの継続時間をセットする / Set "tim_sh_touki", notice observable changes
133 * @param do_dec 現在の継続時間より長い値のみ上書きする
134 * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
136 bool set_tim_sh_force(player_type *creature_ptr, TIME_EFFECT v, bool do_dec)
139 v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
141 if (creature_ptr->is_dead)
145 if (creature_ptr->tim_sh_touki && !do_dec) {
146 if (creature_ptr->tim_sh_touki > v)
148 } else if (!creature_ptr->tim_sh_touki) {
149 msg_print(_("体が闘気のオーラで覆われた。", "You are enveloped by an aura of the Force!"));
153 if (creature_ptr->tim_sh_touki) {
154 msg_print(_("闘気が消えた。", "The aura of the Force disappeared."));
159 creature_ptr->tim_sh_touki = v;
160 creature_ptr->redraw |= (PR_STATUS);
166 disturb(creature_ptr, false, false);
167 handle_stuff(creature_ptr);
173 * @param caster_ptr プレーヤーへの参照ポインタ
176 bool shock_power(player_type *caster_ptr)
178 int boost = get_current_ki(caster_ptr);
179 if (heavy_armor(caster_ptr))
184 if (!get_aim_dir(caster_ptr, &dir))
187 POSITION y = caster_ptr->y + ddy[dir];
188 POSITION x = caster_ptr->x + ddx[dir];
189 PLAYER_LEVEL plev = caster_ptr->lev;
190 HIT_POINT dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
191 fire_beam(caster_ptr, GF_MISSILE, dir, dam);
192 if (!caster_ptr->current_floor_ptr->grid_array[y][x].m_idx)
195 POSITION ty = y, tx = x;
196 POSITION oy = y, ox = x;
197 MONSTER_IDX m_idx = caster_ptr->current_floor_ptr->grid_array[y][x].m_idx;
198 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
199 monster_race *r_ptr = &r_info[m_ptr->r_idx];
200 GAME_TEXT m_name[MAX_NLEN];
201 monster_desc(caster_ptr, m_name, m_ptr, 0);
203 if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2) {
204 msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
208 for (int i = 0; i < 5; i++) {
211 if (is_cave_empty_bold(caster_ptr, y, x)) {
219 bool is_shock_successful = ty != oy;
220 is_shock_successful |= tx != ox;
221 if (is_shock_successful)
224 msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
225 caster_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
226 caster_ptr->current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
230 update_monster(caster_ptr, m_idx, true);
231 lite_spot(caster_ptr, oy, ox);
232 lite_spot(caster_ptr, ty, tx);
234 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
235 caster_ptr->update |= (PU_MON_LITE);
242 * do_cmd_cast calls this function if the player's class is 'ForceTrainer'.
243 * @param spell 発動する特殊技能のID
244 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
246 bool cast_force_spell(player_type *caster_ptr, mind_force_trainer_type spell)
249 PLAYER_LEVEL plev = caster_ptr->lev;
250 int boost = get_current_ki(caster_ptr);
251 if (heavy_armor(caster_ptr))
255 case SMALL_FORCE_BALL:
256 if (!get_aim_dir(caster_ptr, &dir))
259 fire_ball(caster_ptr, GF_MISSILE, dir, damroll(3 + ((plev - 1) / 5) + boost / 12, 4), 0);
262 (void)lite_area(caster_ptr, damroll(2, (plev / 2)), (plev / 10) + 1);
264 case FLYING_TECHNIQUE:
265 set_tim_levitation(caster_ptr, randint1(30) + 30 + boost / 5, false);
268 project_length = plev / 8 + 3;
269 if (!get_aim_dir(caster_ptr, &dir))
272 fire_beam(caster_ptr, GF_MISSILE, dir, damroll(5 + ((plev - 1) / 5) + boost / 10, 5));
274 case MAGIC_RESISTANCE:
275 set_resist_magic(caster_ptr, randint1(20) + 20 + boost / 5, false);
278 msg_print(_("気を練った。", "You improved the Force."));
279 set_current_ki(caster_ptr, false, 70 + plev);
280 caster_ptr->update |= (PU_BONUS);
281 if (randint1(get_current_ki(caster_ptr)) > (plev * 4 + 120)) {
282 msg_print(_("気が暴走した!", "The Force exploded!"));
283 fire_ball(caster_ptr, GF_MANA, 0, get_current_ki(caster_ptr) / 2, 10);
284 take_hit(caster_ptr, DAMAGE_LOSELIFE, caster_ptr->magic_num1[0] / 2, _("気の暴走", "Explosion of the Force"));
290 set_tim_sh_force(caster_ptr, randint1(plev / 2) + 15 + boost / 7, false);
293 return shock_power(caster_ptr);
295 case LARGE_FORCE_BALL:
296 if (!get_aim_dir(caster_ptr, &dir))
299 fire_ball(caster_ptr, GF_MISSILE, dir, damroll(10, 6) + plev * 3 / 2 + boost * 3 / 5, (plev < 30) ? 2 : 3);
302 if (!target_set(caster_ptr, TARGET_KILL))
305 MONSTER_IDX m_idx = caster_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
306 if ((m_idx == 0) || !player_has_los_bold(caster_ptr, target_row, target_col)
307 || !projectable(caster_ptr, caster_ptr->y, caster_ptr->x, target_row, target_col))
310 dispel_monster_status(caster_ptr, m_idx);
314 bool success = false;
315 for (int i = 0; i < 1 + boost / 100; i++)
316 if (summon_specific(caster_ptr, -1, caster_ptr->y, caster_ptr->x, plev, SUMMON_PHANTOM, PM_FORCE_PET))
320 msg_print(_("御用でございますが、御主人様?", "'Your wish, master?'"));
322 msg_print(_("何も現れなかった。", "Nothing happens."));
326 case EXPLODING_FLAME:
327 fire_ball(caster_ptr, GF_FIRE, 0, 200 + (2 * plev) + boost * 2, 10);
329 case SUPER_KAMEHAMEHA:
330 if (!get_aim_dir(caster_ptr, &dir))
333 fire_beam(caster_ptr, GF_MANA, dir, damroll(10 + (plev / 2) + boost * 3 / 10, 15));
336 set_lightspeed(caster_ptr, randint1(16) + 16 + boost / 20, false);
339 msg_print(_("なに?", "Zap?"));
342 set_current_ki(caster_ptr, true, 0);
343 caster_ptr->update |= PU_BONUS;