1 #include "combat/shoot.h"
2 #include "art-definition/art-bow-types.h"
3 #include "mind/mind-sniper.h"
4 #include "core/stuff-handler.h"
5 #include "effect/effect-characteristics.h"
6 #include "effect/spells-effect-util.h"
7 #include "floor/floor-object.h"
8 #include "game-option/cheat-types.h"
9 #include "game-option/special-options.h"
10 #include "grid/feature.h"
11 #include "grid/grid.h"
12 #include "inventory/inventory-object.h"
13 #include "io/cursor.h"
14 #include "io/screen-util.h"
15 #include "io/targeting.h"
16 #include "main/sound-definitions-table.h"
17 #include "main/sound-of-music.h"
18 #include "mind/snipe-types.h"
19 #include "monster-race/monster-race.h"
20 #include "monster-race/race-flags-resistance.h"
21 #include "monster-race/race-flags1.h"
22 #include "monster-race/race-flags2.h"
23 #include "monster-race/race-flags3.h"
24 #include "monster-race/race-flags7.h"
25 #include "monster-race/race-indice-types.h"
26 #include "monster/monster-describer.h"
27 #include "monster-floor/monster-death.h"
28 #include "monster/monster-status.h"
29 #include "monster/monster-info.h"
30 #include "monster-floor/monster-move.h"
31 #include "monster/monster-update.h"
32 #include "object-enchant/artifact.h"
33 #include "object-enchant/tr-types.h"
34 #include "object-hook/hook-enchant.h"
35 #include "object/object-broken.h"
36 #include "object/object-flags.h"
37 #include "object/object-flavor.h"
38 #include "object/object-generator.h"
39 #include "object/object-kind.h"
40 #include "object/object-mark-types.h"
41 #include "object/object-info.h"
42 #include "player/avatar.h"
43 #include "player/player-class.h"
44 #include "player/player-personalities-types.h"
45 #include "player/player-skill.h"
46 #include "player/player-status.h"
47 #include "spell/process-effect.h"
48 #include "spell/spell-types.h"
49 #include "sv-definition/sv-bow-types.h"
50 #include "util/bit-flags-calculator.h"
51 #include "view/display-messages.h"
52 #include "wizard/wizard-messages.h"
53 #include "world/world-object.h"
56 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
57 * Determines the odds of an object breaking when thrown at a monster
58 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
59 * @param tdam 計算途中のダメージ量
60 * @param m_ptr 目標モンスターの構造体参照ポインタ
61 * @return スレイ倍率をかけたダメージ量
63 static MULTIPLY calc_shot_damage_with_slay(player_type *sniper_ptr, object_type *o_ptr, HIT_POINT tdam, monster_type *m_ptr, SPELL_IDX snipe_type)
67 monster_race *r_ptr = &r_info[m_ptr->r_idx];
69 BIT_FLAGS flgs[TR_FLAG_SIZE];
70 object_flags(sniper_ptr, o_ptr, flgs);
72 /* Some "weapons" and "ammo" do extra damage */
79 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
81 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
83 r_ptr->r_flags3 |= RF3_ANIMAL;
85 if (mult < 17) mult = 17;
88 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
90 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
92 r_ptr->r_flags3 |= RF3_ANIMAL;
94 if (mult < 27) mult = 27;
97 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
99 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
101 r_ptr->r_flags3 |= RF3_EVIL;
103 if (mult < 15) mult = 15;
106 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
108 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
110 r_ptr->r_flags3 |= RF3_EVIL;
112 if (mult < 25) mult = 25;
115 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
117 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
119 r_ptr->r_flags2 |= RF2_HUMAN;
121 if (mult < 17) mult = 17;
124 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
126 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
128 r_ptr->r_flags2 |= RF2_HUMAN;
130 if (mult < 27) mult = 27;
133 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
135 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
137 r_ptr->r_flags3 |= RF3_UNDEAD;
139 if (mult < 20) mult = 20;
142 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
144 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
146 r_ptr->r_flags3 |= RF3_UNDEAD;
148 if (mult < 30) mult = 30;
151 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
153 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
155 r_ptr->r_flags3 |= RF3_DEMON;
157 if (mult < 20) mult = 20;
160 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
162 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
164 r_ptr->r_flags3 |= RF3_DEMON;
166 if (mult < 30) mult = 30;
169 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
171 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
173 r_ptr->r_flags3 |= RF3_ORC;
175 if (mult < 20) mult = 20;
178 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
180 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
182 r_ptr->r_flags3 |= RF3_ORC;
184 if (mult < 30) mult = 30;
187 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
189 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
191 r_ptr->r_flags3 |= RF3_TROLL;
194 if (mult < 20) mult = 20;
197 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
199 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
201 r_ptr->r_flags3 |= RF3_TROLL;
203 if (mult < 30) mult = 30;
206 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
208 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
210 r_ptr->r_flags3 |= RF3_GIANT;
212 if (mult < 20) mult = 20;
215 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
217 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
219 r_ptr->r_flags3 |= RF3_GIANT;
221 if (mult < 30) mult = 30;
224 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
226 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
228 r_ptr->r_flags3 |= RF3_DRAGON;
230 if (mult < 20) mult = 20;
233 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
235 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
237 r_ptr->r_flags3 |= RF3_DRAGON;
239 if (mult < 30) mult = 30;
240 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
241 (sniper_ptr->inventory_list[INVEN_BOW].name1 == ART_BARD))
245 if (have_flag(flgs, TR_BRAND_ACID))
247 /* Notice immunity */
248 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
250 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
252 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
257 if (mult < 17) mult = 17;
261 if (have_flag(flgs, TR_BRAND_ELEC))
263 /* Notice immunity */
264 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
266 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
268 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
273 if (mult < 17) mult = 17;
277 if (have_flag(flgs, TR_BRAND_FIRE))
279 /* Notice immunity */
280 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
282 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
284 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
287 /* Otherwise, take the damage */
290 if (r_ptr->flags3 & RF3_HURT_FIRE)
292 if (mult < 25) mult = 25;
293 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
295 r_ptr->r_flags3 |= RF3_HURT_FIRE;
298 else if (mult < 17) mult = 17;
302 if (have_flag(flgs, TR_BRAND_COLD))
304 /* Notice immunity */
305 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
307 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
309 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
312 /* Otherwise, take the damage */
315 if (r_ptr->flags3 & RF3_HURT_COLD)
317 if (mult < 25) mult = 25;
318 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
320 r_ptr->r_flags3 |= RF3_HURT_COLD;
323 else if (mult < 17) mult = 17;
327 if (have_flag(flgs, TR_BRAND_POIS))
329 /* Notice immunity */
330 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
332 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
334 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
337 /* Otherwise, take the damage */
340 if (mult < 17) mult = 17;
344 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30)))
346 sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
347 sniper_ptr->redraw |= (PR_MANA);
355 if (snipe_type) mult = calc_snipe_damage_with_slay(sniper_ptr, mult, m_ptr, snipe_type);
357 /* Return the total damage */
358 return (tdam * mult / 10);
364 * Fire an object from the pack or floor.
365 * @param item 射撃するオブジェクトの所持ID
366 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
370 * You may only fire items that "match" your missile launcher.
371 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
372 * See "calc_bonuses()" for more calculations and such.
373 * Note that "firing" a missile is MUCH better than "throwing" it.
374 * Note: "unseen" monsters are very hard to hit.
375 * Objects are more likely to break if they "attempt" to hit a monster.
376 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
377 * The "extra shot" code works by decreasing the amount of energy
378 * required to make each shot, spreading the shots out over time.
379 * Note that when firing missiles, the launcher multiplier is applied
380 * after all the bonuses are added in, making multipliers very useful.
381 * Note that Bows of "Extra Might" get extra range and an extra bonus
382 * for the damage multiplier.
383 * Note that Bows of "Extra Shots" give an extra shot.
386 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
390 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
391 int tdam_base, tdis, thits, tmul;
393 int cur_dis, visible;
401 bool hit_body = FALSE;
403 GAME_TEXT o_name[MAX_NLEN];
405 u16b path_g[512]; /* For calcuration of path length */
407 int msec = delay_factor * delay_factor * delay_factor;
410 bool stick_to = FALSE;
412 /* Access the item (if in the pack) */
415 o_ptr = &shooter_ptr->inventory_list[item];
419 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
422 /* Sniper - Cannot shot a single arrow twice */
423 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
425 object_desc(shooter_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
427 /* Use the proper number of shots */
428 thits = shooter_ptr->num_fire;
430 /* Use a base distance */
433 /* Base damage from thrown object plus launcher bonus */
434 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
436 /* Actually "fire" the object */
437 bonus = (shooter_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
438 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
439 chance = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
441 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
443 shooter_ptr->energy_use = bow_energy(j_ptr->sval);
444 tmul = bow_tmul(j_ptr->sval);
446 /* Get extra "power" from "extra might" */
447 if (shooter_ptr->xtra_might) tmul++;
449 tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
451 /* Boost the damage */
456 tdis = 13 + tmul / 80;
457 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
459 if (shooter_ptr->concent)
460 tdis -= (5 - (shooter_ptr->concent + 1) / 2);
465 project_length = tdis + 1;
467 /* Get a direction (or cancel) */
468 if (!get_aim_dir(shooter_ptr, &dir))
470 free_turn(shooter_ptr);
472 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
474 /* need not to reset project_length (already did)*/
479 /* Predict the "target" location */
480 tx = shooter_ptr->x + 99 * ddx[dir];
481 ty = shooter_ptr->y + 99 * ddy[dir];
483 /* Check for "target request" */
484 if ((dir == 5) && target_okay(shooter_ptr))
490 /* Get projection path length */
491 tdis = project_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
493 project_length = 0; /* reset to default */
495 /* Don't shoot at my feet */
496 if (tx == shooter_ptr->x && ty == shooter_ptr->y)
498 free_turn(shooter_ptr);
500 /* project_length is already reset to 0 */
506 /* Take a (partial) turn */
507 shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
508 shooter_ptr->is_fired = TRUE;
510 /* Sniper - Difficult to shot twice at 1 turn */
511 if (snipe_type == SP_DOUBLE) shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
513 /* Sniper - Repeat shooting when double shots */
514 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
517 /* Start at the player */
521 object_copy(q_ptr, o_ptr);
526 vary_item(shooter_ptr, item, -1);
529 handle_stuff(shooter_ptr);
534 /* The shot does not hit yet */
537 /* Travel until stopped */
538 for (cur_dis = 0; cur_dis <= tdis; )
542 /* Hack -- Stop at the target */
543 if ((y == ty) && (x == tx)) break;
545 /* Calculate the new location (see "project()") */
548 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
551 if (snipe_type == SP_KILL_WALL)
553 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
555 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx)
557 if (g_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
558 /* Forget the wall */
559 g_ptr->info &= ~(CAVE_MARK);
560 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
562 /* Destroy the wall */
563 cave_alter_feat(shooter_ptr, ny, nx, FF_HURT_ROCK);
570 /* Stopped by walls/doors */
571 if (!cave_have_flag_bold(shooter_ptr->current_floor_ptr, ny, nx, FF_PROJECT) && !shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx) break;
573 /* Advance the distance */
577 if (snipe_type == SP_LITE)
579 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
580 note_spot(shooter_ptr, ny, nx);
581 lite_spot(shooter_ptr, ny, nx);
584 /* The player can see the (on screen) missile */
585 if (panel_contains(ny, nx) && player_can_see_bold(shooter_ptr, ny, nx))
587 SYMBOL_CODE c = object_char(q_ptr);
588 byte a = object_attr(q_ptr);
590 /* Draw, Hilite, Fresh, Pause, Erase */
591 print_rel(shooter_ptr, c, a, ny, nx);
592 move_cursor_relative(ny, nx);
594 Term_xtra(TERM_XTRA_DELAY, msec);
595 lite_spot(shooter_ptr, ny, nx);
599 /* The player cannot see the missile */
602 /* Pause anyway, for consistancy */
603 Term_xtra(TERM_XTRA_DELAY, msec);
607 if (snipe_type == SP_KILL_TRAP)
609 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP,
610 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
614 if (snipe_type == SP_EVILNESS)
616 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
617 note_spot(shooter_ptr, ny, nx);
618 lite_spot(shooter_ptr, ny, nx);
624 /* Save the new location */
628 /* Monster here, Try to hit it */
629 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx)
631 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
633 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
634 monster_race *r_ptr = &r_info[m_ptr->r_idx];
636 /* Check the visibility */
639 /* Note the collision */
642 if (monster_csleep_remaining(m_ptr))
644 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_COMPASSION, -1);
645 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_HONOUR, -1);
648 if ((r_ptr->level + 10) > shooter_ptr->lev)
650 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
651 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval])
654 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
655 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
656 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19)) amount = 10;
657 else if (shooter_ptr->lev > 34) amount = 2;
658 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
659 shooter_ptr->update |= (PU_BONUS);
663 if (shooter_ptr->riding)
665 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
666 && ((shooter_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[shooter_ptr->current_floor_ptr->m_list[shooter_ptr->riding].r_idx].level)
669 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
670 shooter_ptr->update |= (PU_BONUS);
674 /* Did we hit it (penalize range) */
675 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
678 int tdam = tdam_base;
680 /* Get extra damage from concentration */
681 if (shooter_ptr->concent) tdam = boost_concentration_damage(shooter_ptr, tdam);
683 /* Handle unseen monster */
686 /* Invisible monster */
687 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
690 /* Handle visible monster */
693 GAME_TEXT m_name[MAX_NLEN];
695 /* Get "the monster" or "it" */
696 monster_desc(shooter_ptr, m_name, m_ptr, 0);
698 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
702 if (!shooter_ptr->image) monster_race_track(shooter_ptr, m_ptr->ap_r_idx);
703 health_track(shooter_ptr, c_mon_ptr->m_idx);
707 if (snipe_type == SP_NEEDLE)
709 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1)
710 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
712 GAME_TEXT m_name[MAX_NLEN];
714 /* Get "the monster" or "it" */
715 monster_desc(shooter_ptr, m_name, m_ptr, 0);
717 tdam = m_ptr->hp + 1;
718 msg_format(_("%sの急所に突き刺さった!", "Your shot hit a fatal spot of %s!"), m_name);
724 /* Apply special damage */
725 tdam = calc_shot_damage_with_slay(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
726 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
728 /* No negative damage */
729 if (tdam < 0) tdam = 0;
731 /* Modify the damage */
732 tdam = mon_damage_mod(shooter_ptr, m_ptr, tdam, FALSE);
735 msg_format_wizard(shooter_ptr, CHEAT_MONSTER,
736 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
737 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
740 if (snipe_type == SP_EXPLODE)
742 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
744 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
745 project(shooter_ptr, 0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
750 if (snipe_type == SP_HOLYNESS)
752 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
753 note_spot(shooter_ptr, ny, nx);
754 lite_spot(shooter_ptr, ny, nx);
757 /* Hit the monster, check for death */
758 if (mon_take_hit(shooter_ptr, c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
767 if (object_is_fixed_artifact(q_ptr) &&
768 (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0))
770 GAME_TEXT m_name[MAX_NLEN];
772 monster_desc(shooter_ptr, m_name, m_ptr, 0);
775 msg_format(_("%sは%sに突き刺さった!", "%^s is stuck in %s!"), o_name, m_name);
778 message_pain(shooter_ptr, c_mon_ptr->m_idx, tdam);
780 /* Anger the monster */
781 if (tdam > 0) anger_monster(shooter_ptr, m_ptr);
783 if (fear && m_ptr->ml)
785 GAME_TEXT m_name[MAX_NLEN];
787 monster_desc(shooter_ptr, m_name, m_ptr, 0);
788 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
791 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
794 if (snipe_type == SP_RUSH)
796 int n = randint1(5) + 3;
797 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
799 for (; cur_dis <= tdis; )
806 /* Calculate the new location (see "project()") */
807 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
809 /* Stopped by wilderness boundary */
810 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx)) break;
812 /* Stopped by walls/doors */
813 if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break;
815 /* Stopped by monsters */
816 if (!is_cave_empty_bold(shooter_ptr, ny, nx)) break;
818 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
819 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
824 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
826 lite_spot(shooter_ptr, ny, nx);
827 lite_spot(shooter_ptr, oy, ox);
830 Term_xtra(TERM_XTRA_DELAY, msec);
842 if (snipe_type == SP_PIERCE)
844 if (shooter_ptr->concent < 1) break;
845 shooter_ptr->concent--;
854 /* Chance of breakage (during attacks) */
855 j = (hit_body ? breakage_chance(shooter_ptr, q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
859 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
860 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
861 OBJECT_IDX o_idx = o_pop(shooter_ptr->current_floor_ptr);
865 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
866 if (object_is_fixed_artifact(q_ptr))
868 a_info[j_ptr->name1].cur_num = 0;
873 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
874 object_copy(o_ptr, q_ptr);
877 o_ptr->marked &= OM_TOUCHED;
879 /* Forget location */
880 o_ptr->iy = o_ptr->ix = 0;
882 /* Memorize monster */
883 o_ptr->held_m_idx = m_idx;
886 o_ptr->next_o_idx = m_ptr->hold_o_idx;
889 m_ptr->hold_o_idx = o_idx;
891 else if (cave_have_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT))
893 /* Drop (or break) near that location */
894 (void)drop_near(shooter_ptr, q_ptr, j, y, x);
898 /* Drop (or break) near that location */
899 (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x);
902 /* Sniper - Repeat shooting when double shots */
905 /* Sniper - Loose his/her concentration after any shot */
906 if (shooter_ptr->concent) reset_concentration(shooter_ptr, FALSE);
911 * @brief プレイヤーからモンスターへの射撃命中判定 /
912 * Determine if the player "hits" a monster (normal combat).
913 * @param chance 基本命中値
914 * @param m_ptr モンスターの構造体参照ポインタ
915 * @param vis 目標を視界に捕らえているならばTRUEを指定
916 * @param o_name メッセージ表示時のモンスター名
917 * @return 命中と判定された場合TRUEを返す
918 * @note Always miss 5%, always hit 5%, otherwise random.
920 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char* o_name)
924 monster_race *r_ptr = &r_info[m_ptr->r_idx];
926 /* Percentile dice */
929 /* Snipers with high-concentration reduce instant miss percentage.*/
930 k += shooter_ptr->concent;
932 /* Hack -- Instant miss or hit */
933 if (k <= 5) return FALSE;
934 if (k > 95) return TRUE;
936 if (shooter_ptr->pseikaku == PERSONALITY_LAZY)
937 if (one_in_(20)) return FALSE;
940 if (chance <= 0) return FALSE;
943 if (shooter_ptr->concent)
945 ac *= (8 - shooter_ptr->concent);
949 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr)) ac *= 3;
951 /* Invisible monsters are harder to hit */
952 if (!vis) chance = (chance + 1) / 2;
954 /* Power competes against armor */
955 if (randint0(chance) < (ac * 3 / 4))
957 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr))
959 GAME_TEXT m_name[MAX_NLEN];
960 monster_desc(shooter_ptr, m_name, m_ptr, 0);
961 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
974 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
975 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
976 * @param weight 矢弾の重量
977 * @param plus_ammo 矢弾の命中修正
978 * @param plus_bow 弓の命中修正
979 * @param dam 現在算出中のダメージ値
980 * @return クリティカル修正が入ったダメージ値
982 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
985 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
987 /* Extract "shot" power */
988 i = shooter_ptr->to_h_b + plus_ammo;
990 if (shooter_ptr->tval_ammo == TV_BOLT)
991 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
993 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
996 /* Snipers can shot more critically with crossbows */
997 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
998 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
1000 /* Good bow makes more critical */
1001 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1004 if (randint1(10000) <= i)
1006 k = weight * randint1(500);
1010 msg_print(_("手ごたえがあった!", "It was a good hit!"));
1015 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
1020 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
1032 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
1033 * @param sval 射撃武器のアイテム副分類ID
1034 * @return 消費する基本エネルギー
1036 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
1038 ENERGY energy = 10000;
1040 /* Analyze the launcher */
1043 /* Sling and ammo */
1050 /* Short Bow and Arrow */
1057 /* Long Bow and Arrow */
1064 /* Bow of irresponsiblity and Arrow */
1071 /* Light Crossbow and Bolt */
1078 /* Heavy Crossbow and Bolt */
1093 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1097 /* Analyze the launcher */
1100 /* Sling and ammo */
1107 /* Short Bow and Arrow */
1114 /* Long Bow and Arrow */
1121 /* Bow of irresponsiblity and Arrow */
1128 /* Light Crossbow and Bolt */
1135 /* Heavy Crossbow and Bolt */
1148 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1149 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1150 * @param plus_ammo 矢弾のダメージ修正
1151 * @param plus_bow 弓のダメージ修正
1153 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1155 HIT_POINT calc_crit_ratio_shot(player_type* shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1158 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1160 /* Extract "shot" power */
1161 i = shooter_ptr->to_h_b + plus_ammo;
1163 if (shooter_ptr->tval_ammo == TV_BOLT)
1164 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1166 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1168 /* Snipers can shot more critically with crossbows */
1169 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
1170 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
1172 /* Good bow makes more critical */
1173 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1181 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1182 * @param weight 武器の重量
1183 * @param plus_ammo 矢弾のダメージ修正
1184 * @param plus_bow 弓のダメージ修正
1185 * @param dam 基本ダメージ量
1188 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1192 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1197 crit = MIN(500, 900 / weight);
1198 num += dam * 3 / 2 * crit;
1201 crit = MIN(500, 1350 / weight);
1203 num += dam * 2 * crit;
1209 num += dam * 3 * crit;
1215 num += (10000 - i) * dam;
1222 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1223 * @param shooter_ptr プレーヤーへの参照ポインタ
1224 * @param weight 武器の重量
1225 * @param plus 武器のダメージ修正
1227 * @param meichuu 命中値
1228 * @param dokubari 毒針処理か否か
1231 HIT_POINT calc_expect_crit(player_type *shooter_ptr, WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1234 if (dokubari) return dam;
1236 int i = (weight + (meichuu * 3 + plus * 5) + shooter_ptr->skill_thn);
1242 if (k < 400) num += (2 * dam + 5) * (400 - k);
1243 if (k < 700) num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1244 if (k > (700 - 650) && k < 900) num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1245 if (k > (900 - 650) && k < 1300) num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1246 if (k > (1300 - 650)) num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1249 if (shooter_ptr->pclass == CLASS_NINJA)
1252 num += (4444 - i) * dam;
1258 num += (5000 - i) * dam;