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-base/player-class.h"
23 #include "player-info/equipment-info.h"
24 #include "player-info/force-trainer-data-type.h"
25 #include "player/player-damage.h"
26 #include "spell-kind/spells-launcher.h"
27 #include "spell-kind/spells-lite.h"
28 #include "spell/spell-types.h"
29 #include "spell/summon-types.h"
30 #include "status/temporary-resistance.h"
31 #include "system/floor-type-definition.h"
32 #include "system/grid-type-definition.h"
33 #include "system/monster-race-definition.h"
34 #include "system/monster-type-definition.h"
35 #include "system/player-type-definition.h"
36 #include "target/projection-path-calculator.h"
37 #include "target/target-checker.h"
38 #include "target/target-getter.h"
39 #include "target/target-setter.h"
40 #include "target/target-types.h"
41 #include "view/display-messages.h"
44 * @brief 練気術師が「練気」で溜めた気の量を返す
45 * @param player_ptr プレイヤーの参照ポインタ
48 int32_t get_current_ki(player_type *player_ptr)
50 auto data = PlayerClass(player_ptr).get_specific_data<force_trainer_data_type>();
52 return data ? data->ki : 0;
56 * @brief 練気術師において、気を溜める
57 * @param player_ptr プレイヤーの参照ポインタ
58 * @param is_reset TRUEなら気の量をkiにセットし、FALSEなら加減算を行う
61 void set_current_ki(player_type *player_ptr, bool is_reset, int32_t ki)
63 auto data = PlayerClass(player_ptr).get_specific_data<force_trainer_data_type>();
76 bool clear_mind(player_type *player_ptr)
79 msg_print(_("今はペットを操ることに集中していないと。", "Your pets demand all of your attention."));
83 msg_print(_("少し頭がハッキリした。", "You feel your head clear a little."));
85 player_ptr->csp += (3 + player_ptr->lev / 20);
86 if (player_ptr->csp >= player_ptr->msp) {
87 player_ptr->csp = player_ptr->msp;
88 player_ptr->csp_frac = 0;
91 player_ptr->redraw |= (PR_MANA);
96 * @brief 光速移動の継続時間をセットする / Set "lightspeed", notice observable changes
98 * @param do_dec 現在の継続時間より長い値のみ上書きする
100 void set_lightspeed(player_type *player_ptr, TIME_EFFECT v, bool do_dec)
103 v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
105 if (player_ptr->is_dead)
108 if (player_ptr->wild_mode)
112 if (player_ptr->lightspeed && !do_dec) {
113 if (player_ptr->lightspeed > v)
115 } else if (!player_ptr->lightspeed) {
116 msg_print(_("非常に素早く動けるようになった!", "You feel yourself moving extremely fast!"));
118 chg_virtue(player_ptr, V_PATIENCE, -1);
119 chg_virtue(player_ptr, V_DILIGENCE, 1);
122 if (player_ptr->lightspeed) {
123 msg_print(_("動きの素早さがなくなったようだ。", "You feel yourself slow down."));
128 player_ptr->lightspeed = v;
134 disturb(player_ptr, false, false);
135 player_ptr->update |= (PU_BONUS);
136 handle_stuff(player_ptr);
140 * @brief 一時的闘気のオーラの継続時間をセットする / Set "tim_sh_touki", notice observable changes
142 * @param do_dec 現在の継続時間より長い値のみ上書きする
143 * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
145 bool set_tim_sh_force(player_type *player_ptr, TIME_EFFECT v, bool do_dec)
148 v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
150 if (player_ptr->is_dead)
154 if (player_ptr->tim_sh_touki && !do_dec) {
155 if (player_ptr->tim_sh_touki > v)
157 } else if (!player_ptr->tim_sh_touki) {
158 msg_print(_("体が闘気のオーラで覆われた。", "You are enveloped by an aura of the Force!"));
162 if (player_ptr->tim_sh_touki) {
163 msg_print(_("闘気が消えた。", "The aura of the Force disappeared."));
168 player_ptr->tim_sh_touki = v;
169 player_ptr->redraw |= (PR_STATUS);
175 disturb(player_ptr, false, false);
176 handle_stuff(player_ptr);
182 * @param player_ptr プレイヤーへの参照ポインタ
185 bool shock_power(player_type *player_ptr)
187 int boost = get_current_ki(player_ptr);
188 if (heavy_armor(player_ptr))
193 if (!get_aim_dir(player_ptr, &dir))
196 POSITION y = player_ptr->y + ddy[dir];
197 POSITION x = player_ptr->x + ddx[dir];
198 PLAYER_LEVEL plev = player_ptr->lev;
199 HIT_POINT dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
200 fire_beam(player_ptr, GF_MISSILE, dir, dam);
201 if (!player_ptr->current_floor_ptr->grid_array[y][x].m_idx)
204 POSITION ty = y, tx = x;
205 POSITION oy = y, ox = x;
206 MONSTER_IDX m_idx = player_ptr->current_floor_ptr->grid_array[y][x].m_idx;
207 monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
208 monster_race *r_ptr = &r_info[m_ptr->r_idx];
209 GAME_TEXT m_name[MAX_NLEN];
210 monster_desc(player_ptr, m_name, m_ptr, 0);
212 if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam / 2) {
213 msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
217 for (int i = 0; i < 5; i++) {
220 if (is_cave_empty_bold(player_ptr, y, x)) {
228 bool is_shock_successful = ty != oy;
229 is_shock_successful |= tx != ox;
230 if (is_shock_successful)
233 msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
234 player_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
235 player_ptr->current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
239 update_monster(player_ptr, m_idx, true);
240 lite_spot(player_ptr, oy, ox);
241 lite_spot(player_ptr, ty, tx);
243 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
244 player_ptr->update |= (PU_MON_LITE);
251 * do_cmd_cast calls this function if the player's class is 'ForceTrainer'.
252 * @param spell 発動する特殊技能のID
253 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
255 bool cast_force_spell(player_type *player_ptr, mind_force_trainer_type spell)
258 PLAYER_LEVEL plev = player_ptr->lev;
259 int boost = get_current_ki(player_ptr);
260 if (heavy_armor(player_ptr))
264 case SMALL_FORCE_BALL:
265 if (!get_aim_dir(player_ptr, &dir))
268 fire_ball(player_ptr, GF_MISSILE, dir, damroll(3 + ((plev - 1) / 5) + boost / 12, 4), 0);
271 (void)lite_area(player_ptr, damroll(2, (plev / 2)), (plev / 10) + 1);
273 case FLYING_TECHNIQUE:
274 set_tim_levitation(player_ptr, randint1(30) + 30 + boost / 5, false);
277 project_length = plev / 8 + 3;
278 if (!get_aim_dir(player_ptr, &dir))
281 fire_beam(player_ptr, GF_MISSILE, dir, damroll(5 + ((plev - 1) / 5) + boost / 10, 5));
283 case MAGIC_RESISTANCE:
284 set_resist_magic(player_ptr, randint1(20) + 20 + boost / 5, false);
287 msg_print(_("気を練った。", "You improved the Force."));
288 set_current_ki(player_ptr, false, 70 + plev);
289 player_ptr->update |= (PU_BONUS);
290 if (randint1(get_current_ki(player_ptr)) > (plev * 4 + 120)) {
291 msg_print(_("気が暴走した!", "The Force exploded!"));
292 fire_ball(player_ptr, GF_MANA, 0, get_current_ki(player_ptr) / 2, 10);
293 auto data = PlayerClass(player_ptr).get_specific_data<force_trainer_data_type>();
294 take_hit(player_ptr, DAMAGE_LOSELIFE, data->ki / 2, _("気の暴走", "Explosion of the Force"));
300 set_tim_sh_force(player_ptr, randint1(plev / 2) + 15 + boost / 7, false);
303 return shock_power(player_ptr);
305 case LARGE_FORCE_BALL:
306 if (!get_aim_dir(player_ptr, &dir))
309 fire_ball(player_ptr, GF_MISSILE, dir, damroll(10, 6) + plev * 3 / 2 + boost * 3 / 5, (plev < 30) ? 2 : 3);
312 if (!target_set(player_ptr, TARGET_KILL))
315 MONSTER_IDX m_idx = player_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
316 if ((m_idx == 0) || !player_has_los_bold(player_ptr, target_row, target_col)
317 || !projectable(player_ptr, player_ptr->y, player_ptr->x, target_row, target_col))
320 dispel_monster_status(player_ptr, m_idx);
324 bool success = false;
325 for (int i = 0; i < 1 + boost / 100; i++)
326 if (summon_specific(player_ptr, -1, player_ptr->y, player_ptr->x, plev, SUMMON_PHANTOM, PM_FORCE_PET))
330 msg_print(_("御用でございますが、御主人様?", "'Your wish, master?'"));
332 msg_print(_("何も現れなかった。", "Nothing happens."));
336 case EXPLODING_FLAME:
337 fire_ball(player_ptr, GF_FIRE, 0, 200 + (2 * plev) + boost * 2, 10);
339 case SUPER_KAMEHAMEHA:
340 if (!get_aim_dir(player_ptr, &dir))
343 fire_beam(player_ptr, GF_MANA, dir, damroll(10 + (plev / 2) + boost * 3 / 10, 15));
346 set_lightspeed(player_ptr, randint1(16) + 16 + boost / 20, false);
349 msg_print(_("なに?", "Zap?"));
352 set_current_ki(player_ptr, true, 0);
353 player_ptr->update |= PU_BONUS;