1 #include "mind/mind-ninja.h"
2 #include "cmd-action/cmd-attack.h"
3 #include "cmd-item/cmd-throw.h"
4 #include "combat/combat-options-type.h"
5 #include "core/disturbance.h"
6 #include "core/player-redraw-types.h"
7 #include "effect/effect-characteristics.h"
8 #include "effect/effect-processor.h"
9 #include "effect/spells-effect-util.h"
10 #include "floor/cave.h"
11 #include "floor/floor-object.h"
12 #include "floor/floor.h"
13 #include "game-option/disturbance-options.h"
14 #include "grid/feature.h"
15 #include "inventory/inventory-slot-types.h"
16 #include "mind/mind-mirror-master.h"
17 #include "mind/mind-numbers.h"
18 #include "mind/mind-warrior.h"
19 #include "monster-race/monster-race.h"
20 #include "monster-race/race-flags-resistance.h"
21 #include "monster-race/race-indice-types.h"
22 #include "monster/monster-describer.h"
23 #include "monster/monster-status.h"
24 #include "monster/monster-update.h"
25 #include "object-enchant/trc-types.h"
26 #include "object/object-generator.h"
27 #include "object/object-kind-hook.h"
28 #include "player/attack-defense-types.h"
29 #include "player/special-defense-types.h"
30 #include "spell-kind/spells-detection.h"
31 #include "spell-kind/spells-fetcher.h"
32 #include "spell-kind/spells-floor.h"
33 #include "spell-kind/spells-grid.h"
34 #include "spell-kind/spells-launcher.h"
35 #include "spell-kind/spells-lite.h"
36 #include "spell-kind/spells-perception.h"
37 #include "spell-kind/spells-teleport.h"
38 #include "spell/spell-types.h"
39 #include "spell/spells-status.h"
40 #include "status/action-setter.h"
41 #include "status/body-improvement.h"
42 #include "status/element-resistance.h"
43 #include "status/temporary-resistance.h"
44 #include "system/floor-type-definition.h"
45 #include "target/target-checker.h"
46 #include "target/target-getter.h"
47 #include "util/bit-flags-calculator.h"
48 #include "view/display-messages.h"
52 * @param caster_ptr プレーヤーへの参照ポインタ
53 * @param success 判定成功上の処理ならばTRUE
54 * @return 作用が実際にあった場合TRUEを返す
56 bool kawarimi(player_type *caster_ptr, bool success)
59 object_type *q_ptr = &forge;
61 if (caster_ptr->is_dead)
63 if (caster_ptr->confused || caster_ptr->blind || caster_ptr->paralyzed || caster_ptr->image)
65 if (randint0(200) < caster_ptr->stun)
68 if (!success && one_in_(3)) {
69 msg_print(_("失敗!逃げられなかった。", "Failed! You couldn't run away."));
70 caster_ptr->special_defense &= ~(NINJA_KAWARIMI);
71 caster_ptr->redraw |= (PR_STATUS);
75 POSITION y = caster_ptr->y;
76 POSITION x = caster_ptr->x;
78 teleport_player(caster_ptr, 10 + randint1(90), TELEPORT_SPONTANEOUS);
80 const int SV_WOODEN_STATUE = 0;
81 object_prep(caster_ptr, q_ptr, lookup_kind(TV_STATUE, SV_WOODEN_STATUE));
83 q_ptr->pval = MON_NINJA;
84 (void)drop_near(caster_ptr, q_ptr, -1, y, x);
87 msg_print(_("攻撃を受ける前に素早く身をひるがえした。", "You have turned around just before the attack hit you."));
89 msg_print(_("失敗!攻撃を受けてしまった。", "Failed! You are hit by the attack."));
91 caster_ptr->special_defense &= ~(NINJA_KAWARIMI);
92 caster_ptr->redraw |= (PR_STATUS);
97 * @brief 入身処理 / "Rush Attack" routine for Samurai or Ninja
98 * @param caster_ptr プレーヤーへの参照ポインタ
99 * @param mdeath 目標モンスターが死亡したかを返す
100 * @return 作用が実際にあった場合TRUEを返す / Return value is for checking "done"
102 bool rush_attack(player_type *attacker_ptr, bool *mdeath)
109 if (!get_aim_dir(attacker_ptr, &dir))
112 int tx = attacker_ptr->x + project_length * ddx[dir];
113 int ty = attacker_ptr->y + project_length * ddy[dir];
115 if ((dir == 5) && target_okay(attacker_ptr)) {
121 floor_type *floor_ptr = attacker_ptr->current_floor_ptr;
122 if (in_bounds(floor_ptr, ty, tx))
123 tm_idx = floor_ptr->grid_array[ty][tx].m_idx;
126 int path_n = projection_path(attacker_ptr, path_g, project_length, attacker_ptr->y, attacker_ptr->x, ty, tx, PROJECT_STOP | PROJECT_KILL);
131 ty = attacker_ptr->y;
132 tx = attacker_ptr->x;
133 bool tmp_mdeath = FALSE;
135 for (int i = 0; i < path_n; i++) {
138 int ny = GRID_Y(path_g[i]);
139 int nx = GRID_X(path_g[i]);
141 if (is_cave_empty_bold(attacker_ptr, ny, nx) && player_can_enter(attacker_ptr, floor_ptr->grid_array[ny][nx].feat, 0)) {
147 if (!floor_ptr->grid_array[ny][nx].m_idx) {
149 msg_print(_("失敗!", "Failed!"));
151 msg_print(_("ここには入身では入れない。", "You can't move to that place."));
157 if (!player_bold(attacker_ptr, ty, tx))
158 teleport_player_to(attacker_ptr, ty, tx, TELEPORT_NONMAGICAL);
159 update_monster(attacker_ptr, floor_ptr->grid_array[ny][nx].m_idx, TRUE);
161 m_ptr = &floor_ptr->m_list[floor_ptr->grid_array[ny][nx].m_idx];
162 if (tm_idx != floor_ptr->grid_array[ny][nx].m_idx) {
164 msg_format("%s%sが立ちふさがっている!", tm_idx ? "別の" : "", m_ptr->ml ? "モンスター" : "何か");
166 msg_format("There is %s in the way!", m_ptr->ml ? (tm_idx ? "another monster" : "a monster") : "someone");
168 } else if (!player_bold(attacker_ptr, ty, tx)) {
169 GAME_TEXT m_name[MAX_NLEN];
170 monster_desc(attacker_ptr, m_name, m_ptr, 0);
171 msg_format(_("素早く%sの懐に入り込んだ!", "You quickly jump in and attack %s!"), m_name);
174 if (!player_bold(attacker_ptr, ty, tx))
175 teleport_player_to(attacker_ptr, ty, tx, TELEPORT_NONMAGICAL);
177 tmp_mdeath = do_cmd_attack(attacker_ptr, ny, nx, HISSATSU_NYUSIN);
182 if (!moved && !player_bold(attacker_ptr, ty, tx))
183 teleport_player_to(attacker_ptr, ty, tx, TELEPORT_NONMAGICAL);
186 *mdeath = tmp_mdeath;
191 * @brief 盗賊と忍者における不意打ち
192 * @param attacker_ptr プレーヤーへの参照ポインタ
193 * @param pa_ptr 直接攻撃構造体への参照ポインタ
196 void process_surprise_attack(player_type *attacker_ptr, player_attack_type *pa_ptr)
198 monster_race *r_ptr = &r_info[pa_ptr->m_ptr->r_idx];
199 if (!has_melee_weapon(attacker_ptr, INVEN_RARM + pa_ptr->hand) || attacker_ptr->icky_wield[pa_ptr->hand])
202 int tmp = attacker_ptr->lev * 6 + (attacker_ptr->skill_stl + 10) * 4;
203 if (attacker_ptr->monlite && (pa_ptr->mode != HISSATSU_NYUSIN))
205 if (attacker_ptr->cursed & TRC_AGGRAVATE)
207 if (r_ptr->level > (attacker_ptr->lev * attacker_ptr->lev / 20 + 10))
209 if (monster_csleep_remaining(pa_ptr->m_ptr) && pa_ptr->m_ptr->ml) {
210 /* Can't backstab creatures that we can't see, right? */
211 pa_ptr->backstab = TRUE;
212 } else if ((attacker_ptr->special_defense & NINJA_S_STEALTH) && (randint0(tmp) > (r_ptr->level + 20)) && pa_ptr->m_ptr->ml
213 && !(r_ptr->flagsr & RFR_RES_ALL)) {
214 pa_ptr->surprise_attack = TRUE;
215 } else if (monster_fear_remaining(pa_ptr->m_ptr) && pa_ptr->m_ptr->ml) {
216 pa_ptr->stab_fleeing = TRUE;
220 void print_surprise_attack(player_attack_type *pa_ptr)
222 if (pa_ptr->backstab)
223 msg_format(_("あなたは冷酷にも眠っている無力な%sを突き刺した!", "You cruelly stab the helpless, sleeping %s!"), pa_ptr->m_name);
224 else if (pa_ptr->surprise_attack)
225 msg_format(_("不意を突いて%sに強烈な一撃を喰らわせた!", "You make surprise attack, and hit %s with a powerful blow!"), pa_ptr->m_name);
226 else if (pa_ptr->stab_fleeing)
227 msg_format(_("逃げる%sを背中から突き刺した!", "You backstab the fleeing %s!"), pa_ptr->m_name);
228 else if (!pa_ptr->monk_attack)
229 msg_format(_("%sを攻撃した。", "You hit %s."), pa_ptr->m_name);
233 * @brief 盗賊と忍者における不意打ちのダメージ計算
234 * @param attacker_ptr プレーヤーへの参照ポインタ
235 * @param pa_ptr 直接攻撃構造体への参照ポインタ
238 void calc_surprise_attack_damage(player_type *attacker_ptr, player_attack_type *pa_ptr)
240 if (pa_ptr->backstab) {
241 pa_ptr->attack_damage *= (3 + (attacker_ptr->lev / 20));
245 if (pa_ptr->surprise_attack) {
246 pa_ptr->attack_damage = pa_ptr->attack_damage * (5 + (attacker_ptr->lev * 2 / 25)) / 2;
250 if (pa_ptr->stab_fleeing)
251 pa_ptr->attack_damage = (3 * pa_ptr->attack_damage) / 2;
256 * @param creature_ptr プレーヤーへの参照ポインタ
259 bool hayagake(player_type *creature_ptr)
261 if (creature_ptr->action == ACTION_HAYAGAKE) {
262 set_action(creature_ptr, ACTION_NONE);
263 creature_ptr->energy_use = 0;
267 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
268 feature_type *f_ptr = &f_info[g_ptr->feat];
270 if (!have_flag(f_ptr->flags, FF_PROJECT) || (!creature_ptr->levitation && have_flag(f_ptr->flags, FF_DEEP))) {
271 msg_print(_("ここでは素早く動けない。", "You cannot run in here."));
273 set_action(creature_ptr, ACTION_HAYAGAKE);
276 creature_ptr->energy_use = 0;
282 * @param set TRUEならば超隠密状態になる。
283 * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。
285 bool set_superstealth(player_type *creature_ptr, bool set)
289 if (creature_ptr->is_dead)
293 if (!(creature_ptr->special_defense & NINJA_S_STEALTH)) {
294 if (creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].info & CAVE_MNLT) {
295 msg_print(_("敵の目から薄い影の中に覆い隠された。", "You are mantled in weak shadow from ordinary eyes."));
296 creature_ptr->monlite = creature_ptr->old_monlite = TRUE;
298 msg_print(_("敵の目から影の中に覆い隠された!", "You are mantled in shadow from ordinary eyes!"));
299 creature_ptr->monlite = creature_ptr->old_monlite = FALSE;
303 creature_ptr->special_defense |= NINJA_S_STEALTH;
306 if (creature_ptr->special_defense & NINJA_S_STEALTH) {
307 msg_print(_("再び敵の目にさらされるようになった。", "You are exposed to common sight once more."));
309 creature_ptr->special_defense &= ~(NINJA_S_STEALTH);
315 creature_ptr->redraw |= (PR_STATUS);
318 disturb(creature_ptr, FALSE, FALSE);
324 * do_cmd_cast calls this function if the player's class is 'ninja'.
325 * @param caster_ptr プレーヤーへの参照ポインタ
326 * @param spell 発動する特殊技能のID
327 * @return 処理を実行したらTRUE、キャンセルした場合FALSEを返す。
329 bool cast_ninja_spell(player_type *caster_ptr, mind_ninja_type spell)
331 POSITION x = 0, y = 0;
333 PLAYER_LEVEL plev = caster_ptr->lev;
335 case DARKNESS_CREATION:
336 (void)unlite_area(caster_ptr, 0, 3);
340 wiz_lite(caster_ptr, TRUE);
342 detect_monsters_normal(caster_ptr, DETECT_RAD_DEFAULT);
344 detect_traps(caster_ptr, DETECT_RAD_DEFAULT, TRUE);
345 detect_doors(caster_ptr, DETECT_RAD_DEFAULT);
346 detect_stairs(caster_ptr, DETECT_RAD_DEFAULT);
350 detect_objects_normal(caster_ptr, DETECT_RAD_DEFAULT);
354 teleport_player(caster_ptr, 10, TELEPORT_SPONTANEOUS);
357 if (!(caster_ptr->special_defense & NINJA_KAWARIMI)) {
358 msg_print(_("敵の攻撃に対して敏感になった。", "You are now prepared to evade any attacks."));
359 caster_ptr->special_defense |= NINJA_KAWARIMI;
360 caster_ptr->redraw |= (PR_STATUS);
365 teleport_player(caster_ptr, caster_ptr->lev * 5, TELEPORT_SPONTANEOUS);
368 if (!hit_and_away(caster_ptr))
373 if (!get_aim_dir(caster_ptr, &dir))
376 (void)stasis_monster(caster_ptr, dir);
378 case ANCIENT_KNOWLEDGE:
379 return ident_spell(caster_ptr, FALSE, 0);
381 set_tim_levitation(caster_ptr, randint1(20) + 20, FALSE);
384 fire_ball(caster_ptr, GF_FIRE, 0, 50 + plev, plev / 10 + 2);
385 teleport_player(caster_ptr, 30, TELEPORT_SPONTANEOUS);
386 set_oppose_fire(caster_ptr, (TIME_EFFECT)plev, FALSE);
389 return rush_attack(caster_ptr, NULL);
390 case SYURIKEN_SPREADING: {
391 for (int i = 0; i < 8; i++) {
394 for (slot = 0; slot < INVEN_PACK; slot++) {
395 if (caster_ptr->inventory_list[slot].tval == TV_SPIKE)
399 if (slot == INVEN_PACK) {
401 msg_print(_("くさびを持っていない。", "You have no Iron Spikes."));
403 msg_print(_("くさびがなくなった。", "You have no more Iron Spikes."));
408 do_cmd_throw(caster_ptr, 1, FALSE, slot);
409 take_turn(caster_ptr, 100);
415 (void)fetch_monster(caster_ptr);
418 if (!get_aim_dir(caster_ptr, &dir))
421 fire_ball(caster_ptr, GF_OLD_CONF, dir, plev * 3, 3);
425 if (!get_aim_dir(caster_ptr, &dir)) {
431 (void)teleport_swap(caster_ptr, dir);
433 case EXPLOSION_GLYPH:
434 explosive_rune(caster_ptr, caster_ptr->y, caster_ptr->x);
437 (void)set_pass_wall(caster_ptr, randint1(plev / 2) + plev / 2, FALSE);
438 set_oppose_acid(caster_ptr, (TIME_EFFECT)plev, FALSE);
441 fire_ball(caster_ptr, GF_POIS, 0, 75 + plev * 2 / 3, plev / 5 + 2);
442 fire_ball(caster_ptr, GF_HYPODYNAMIA, 0, 75 + plev * 2 / 3, plev / 5 + 2);
443 fire_ball(caster_ptr, GF_CONFUSION, 0, 75 + plev * 2 / 3, plev / 5 + 2);
444 teleport_player(caster_ptr, 30, TELEPORT_SPONTANEOUS);
446 case PURGATORY_FLAME: {
447 int num = damroll(3, 9);
448 for (int k = 0; k < num; k++) {
449 EFFECT_ID typ = one_in_(2) ? GF_FIRE : one_in_(3) ? GF_NETHER : GF_PLASMA;
452 scatter(caster_ptr, &y, &x, caster_ptr->y, caster_ptr->x, 4, 0);
453 if (!player_bold(caster_ptr, y, x))
457 project(caster_ptr, 0, 0, y, x, damroll(6 + plev / 8, 10), typ, (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_KILL), -1);
463 set_multishadow(caster_ptr, 6 + randint1(6), FALSE);
466 msg_print(_("なに?", "Zap?"));