7 #include "monster-status.h"
8 #include "monster-spell.h"
11 #include "player-status.h"
12 #include "player-skill.h"
13 #include "player-class.h"
14 #include "player-personality.h"
15 #include "object-hook.h"
16 #include "object-broken.h"
20 #include "object-flavor.h"
24 #include "view-mainwindow.h"
25 #include "objectkind.h"
26 #include "targeting.h"
29 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
30 * Determines the odds of an object breaking when thrown at a monster
31 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
32 * @param tdam 計算途中のダメージ量
33 * @param m_ptr 目標モンスターの構造体参照ポインタ
34 * @return スレイ倍率をかけたダメージ量
36 static MULTIPLY tot_dam_aux_shot(player_type *sniper_ptr, object_type *o_ptr, HIT_POINT tdam, monster_type *m_ptr, SPELL_IDX snipe_type)
40 monster_race *r_ptr = &r_info[m_ptr->r_idx];
42 BIT_FLAGS flgs[TR_FLAG_SIZE];
43 object_flags(o_ptr, flgs);
45 /* Some "weapons" and "ammo" do extra damage */
52 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
54 if (is_original_ap_and_seen(m_ptr))
56 r_ptr->r_flags3 |= RF3_ANIMAL;
58 if (mult < 17) mult = 17;
61 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
63 if (is_original_ap_and_seen(m_ptr))
65 r_ptr->r_flags3 |= RF3_ANIMAL;
67 if (mult < 27) mult = 27;
70 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
72 if (is_original_ap_and_seen(m_ptr))
74 r_ptr->r_flags3 |= RF3_EVIL;
76 if (mult < 15) mult = 15;
79 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
81 if (is_original_ap_and_seen(m_ptr))
83 r_ptr->r_flags3 |= RF3_EVIL;
85 if (mult < 25) mult = 25;
88 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
90 if (is_original_ap_and_seen(m_ptr))
92 r_ptr->r_flags2 |= RF2_HUMAN;
94 if (mult < 17) mult = 17;
97 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
99 if (is_original_ap_and_seen(m_ptr))
101 r_ptr->r_flags2 |= RF2_HUMAN;
103 if (mult < 27) mult = 27;
106 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
108 if (is_original_ap_and_seen(m_ptr))
110 r_ptr->r_flags3 |= RF3_UNDEAD;
112 if (mult < 20) mult = 20;
115 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
117 if (is_original_ap_and_seen(m_ptr))
119 r_ptr->r_flags3 |= RF3_UNDEAD;
121 if (mult < 30) mult = 30;
124 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
126 if (is_original_ap_and_seen(m_ptr))
128 r_ptr->r_flags3 |= RF3_DEMON;
130 if (mult < 20) mult = 20;
133 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
135 if (is_original_ap_and_seen(m_ptr))
137 r_ptr->r_flags3 |= RF3_DEMON;
139 if (mult < 30) mult = 30;
142 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
144 if (is_original_ap_and_seen(m_ptr))
146 r_ptr->r_flags3 |= RF3_ORC;
148 if (mult < 20) mult = 20;
151 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
153 if (is_original_ap_and_seen(m_ptr))
155 r_ptr->r_flags3 |= RF3_ORC;
157 if (mult < 30) mult = 30;
160 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
162 if (is_original_ap_and_seen(m_ptr))
164 r_ptr->r_flags3 |= RF3_TROLL;
167 if (mult < 20) mult = 20;
170 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
172 if (is_original_ap_and_seen(m_ptr))
174 r_ptr->r_flags3 |= RF3_TROLL;
176 if (mult < 30) mult = 30;
179 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
181 if (is_original_ap_and_seen(m_ptr))
183 r_ptr->r_flags3 |= RF3_GIANT;
185 if (mult < 20) mult = 20;
188 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
190 if (is_original_ap_and_seen(m_ptr))
192 r_ptr->r_flags3 |= RF3_GIANT;
194 if (mult < 30) mult = 30;
197 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
199 if (is_original_ap_and_seen(m_ptr))
201 r_ptr->r_flags3 |= RF3_DRAGON;
203 if (mult < 20) mult = 20;
206 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
208 if (is_original_ap_and_seen(m_ptr))
210 r_ptr->r_flags3 |= RF3_DRAGON;
212 if (mult < 30) mult = 30;
213 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
214 (sniper_ptr->inventory_list[INVEN_BOW].name1 == ART_BARD))
218 if (have_flag(flgs, TR_BRAND_ACID))
220 /* Notice immunity */
221 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
223 if (is_original_ap_and_seen(m_ptr))
225 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
230 if (mult < 17) mult = 17;
234 if (have_flag(flgs, TR_BRAND_ELEC))
236 /* Notice immunity */
237 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
239 if (is_original_ap_and_seen(m_ptr))
241 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
246 if (mult < 17) mult = 17;
250 if (have_flag(flgs, TR_BRAND_FIRE))
252 /* Notice immunity */
253 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
255 if (is_original_ap_and_seen(m_ptr))
257 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
260 /* Otherwise, take the damage */
263 if (r_ptr->flags3 & RF3_HURT_FIRE)
265 if (mult < 25) mult = 25;
266 if (is_original_ap_and_seen(m_ptr))
268 r_ptr->r_flags3 |= RF3_HURT_FIRE;
271 else if (mult < 17) mult = 17;
275 if (have_flag(flgs, TR_BRAND_COLD))
277 /* Notice immunity */
278 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
280 if (is_original_ap_and_seen(m_ptr))
282 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
285 /* Otherwise, take the damage */
288 if (r_ptr->flags3 & RF3_HURT_COLD)
290 if (mult < 25) mult = 25;
291 if (is_original_ap_and_seen(m_ptr))
293 r_ptr->r_flags3 |= RF3_HURT_COLD;
296 else if (mult < 17) mult = 17;
300 if (have_flag(flgs, TR_BRAND_POIS))
302 /* Notice immunity */
303 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
305 if (is_original_ap_and_seen(m_ptr))
307 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
310 /* Otherwise, take the damage */
313 if (mult < 17) mult = 17;
317 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30)))
319 sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
320 sniper_ptr->redraw |= (PR_MANA);
328 if (snipe_type) mult = tot_dam_aux_snipe(sniper_ptr, mult, m_ptr, snipe_type);
330 /* Return the total damage */
331 return (tdam * mult / 10);
337 * Fire an object from the pack or floor.
338 * @param item 射撃するオブジェクトの所持ID
339 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
343 * You may only fire items that "match" your missile launcher.
344 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
345 * See "calc_bonuses()" for more calculations and such.
346 * Note that "firing" a missile is MUCH better than "throwing" it.
347 * Note: "unseen" monsters are very hard to hit.
348 * Objects are more likely to break if they "attempt" to hit a monster.
349 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
350 * The "extra shot" code works by decreasing the amount of energy
351 * required to make each shot, spreading the shots out over time.
352 * Note that when firing missiles, the launcher multiplier is applied
353 * after all the bonuses are added in, making multipliers very useful.
354 * Note that Bows of "Extra Might" get extra range and an extra bonus
355 * for the damage multiplier.
356 * Note that Bows of "Extra Shots" give an extra shot.
359 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
363 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
364 int tdam_base, tdis, thits, tmul;
366 int cur_dis, visible;
374 bool hit_body = FALSE;
376 GAME_TEXT o_name[MAX_NLEN];
378 u16b path_g[512]; /* For calcuration of path length */
380 int msec = delay_factor * delay_factor * delay_factor;
383 bool stick_to = FALSE;
385 /* Access the item (if in the pack) */
388 o_ptr = &shooter_ptr->inventory_list[item];
392 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
395 /* Sniper - Cannot shot a single arrow twice */
396 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
398 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
400 /* Use the proper number of shots */
401 thits = shooter_ptr->num_fire;
403 /* Use a base distance */
406 /* Base damage from thrown object plus launcher bonus */
407 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
409 /* Actually "fire" the object */
410 bonus = (shooter_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
411 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
412 chance = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
414 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
416 shooter_ptr->energy_use = bow_energy(j_ptr->sval);
417 tmul = bow_tmul(j_ptr->sval);
419 /* Get extra "power" from "extra might" */
420 if (shooter_ptr->xtra_might) tmul++;
422 tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
424 /* Boost the damage */
429 tdis = 13 + tmul / 80;
430 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
432 if (shooter_ptr->concent)
433 tdis -= (5 - (shooter_ptr->concent + 1) / 2);
438 project_length = tdis + 1;
440 /* Get a direction (or cancel) */
441 if (!get_aim_dir(&dir))
443 free_turn(shooter_ptr);
445 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
447 /* need not to reset project_length (already did)*/
452 /* Predict the "target" location */
453 tx = shooter_ptr->x + 99 * ddx[dir];
454 ty = shooter_ptr->y + 99 * ddy[dir];
456 /* Check for "target request" */
457 if ((dir == 5) && target_okay())
463 /* Get projection path length */
464 tdis = project_path(path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
466 project_length = 0; /* reset to default */
468 /* Don't shoot at my feet */
469 if (tx == shooter_ptr->x && ty == shooter_ptr->y)
471 free_turn(shooter_ptr);
473 /* project_length is already reset to 0 */
479 /* Take a (partial) turn */
480 shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
481 shooter_ptr->is_fired = TRUE;
483 /* Sniper - Difficult to shot twice at 1 turn */
484 if (snipe_type == SP_DOUBLE) shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
486 /* Sniper - Repeat shooting when double shots */
487 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
490 /* Start at the player */
494 object_copy(q_ptr, o_ptr);
499 /* Reduce and describe shooter_ptr->inventory_list */
502 inven_item_increase(item, -1);
503 inven_item_describe(item);
504 inven_item_optimize(item);
507 /* Reduce and describe floor item */
510 floor_item_increase(0 - item, -1);
511 floor_item_optimize(0 - item);
520 /* The shot does not hit yet */
523 /* Travel until stopped */
524 for (cur_dis = 0; cur_dis <= tdis; )
528 /* Hack -- Stop at the target */
529 if ((y == ty) && (x == tx)) break;
531 /* Calculate the new location (see "project()") */
534 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
537 if (snipe_type == SP_KILL_WALL)
539 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
541 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx)
543 if (g_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
544 /* Forget the wall */
545 g_ptr->info &= ~(CAVE_MARK);
546 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
548 /* Destroy the wall */
549 cave_alter_feat(ny, nx, FF_HURT_ROCK);
556 /* Stopped by walls/doors */
557 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx) break;
559 /* Advance the distance */
563 if (snipe_type == SP_LITE)
565 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
570 /* The player can see the (on screen) missile */
571 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
573 char c = object_char(q_ptr);
574 byte a = object_attr(q_ptr);
576 /* Draw, Hilite, Fresh, Pause, Erase */
577 print_rel(c, a, ny, nx);
578 move_cursor_relative(ny, nx);
580 Term_xtra(TERM_XTRA_DELAY, msec);
585 /* The player cannot see the missile */
588 /* Pause anyway, for consistancy */
589 Term_xtra(TERM_XTRA_DELAY, msec);
593 if (snipe_type == SP_KILL_TRAP)
595 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
596 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
600 if (snipe_type == SP_EVILNESS)
602 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
610 /* Save the new location */
614 /* Monster here, Try to hit it */
615 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx)
617 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
619 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
620 monster_race *r_ptr = &r_info[m_ptr->r_idx];
622 /* Check the visibility */
625 /* Note the collision */
628 if (MON_CSLEEP(m_ptr))
630 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_COMPASSION, -1);
631 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_HONOUR, -1);
634 if ((r_ptr->level + 10) > shooter_ptr->lev)
636 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
637 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval])
640 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
641 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
642 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19)) amount = 10;
643 else if (shooter_ptr->lev > 34) amount = 2;
644 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
645 shooter_ptr->update |= (PU_BONUS);
649 if (shooter_ptr->riding)
651 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
652 && ((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)
655 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
656 shooter_ptr->update |= (PU_BONUS);
660 /* Did we hit it (penalize range) */
661 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
664 int tdam = tdam_base;
666 /* Get extra damage from concentration */
667 if (shooter_ptr->concent) tdam = boost_concentration_damage(shooter_ptr, tdam);
669 /* Handle unseen monster */
672 /* Invisible monster */
673 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
676 /* Handle visible monster */
679 GAME_TEXT m_name[MAX_NLEN];
681 /* Get "the monster" or "it" */
682 monster_desc(m_name, m_ptr, 0);
684 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
688 if (!shooter_ptr->image) monster_race_track(m_ptr->ap_r_idx);
689 health_track(c_mon_ptr->m_idx);
693 if (snipe_type == SP_NEEDLE)
695 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1)
696 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
698 GAME_TEXT m_name[MAX_NLEN];
700 /* Get "the monster" or "it" */
701 monster_desc(m_name, m_ptr, 0);
703 tdam = m_ptr->hp + 1;
704 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
710 /* Apply special damage */
711 tdam = tot_dam_aux_shot(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
712 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
714 /* No negative damage */
715 if (tdam < 0) tdam = 0;
717 /* Modify the damage */
718 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
721 msg_format_wizard(CHEAT_MONSTER,
722 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
723 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
726 if (snipe_type == SP_EXPLODE)
728 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
730 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
731 project(0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
736 if (snipe_type == SP_HOLYNESS)
738 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
743 /* Hit the monster, check for death */
744 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
753 if (object_is_fixed_artifact(q_ptr) &&
754 (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0))
756 GAME_TEXT m_name[MAX_NLEN];
758 monster_desc(m_name, m_ptr, 0);
761 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"), o_name, m_name);
764 message_pain(c_mon_ptr->m_idx, tdam);
766 /* Anger the monster */
767 if (tdam > 0) anger_monster(m_ptr);
769 if (fear && m_ptr->ml)
771 GAME_TEXT m_name[MAX_NLEN];
773 monster_desc(m_name, m_ptr, 0);
774 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
777 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
780 if (snipe_type == SP_RUSH)
782 int n = randint1(5) + 3;
783 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
785 for (; cur_dis <= tdis; )
792 /* Calculate the new location (see "project()") */
793 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
795 /* Stopped by wilderness boundary */
796 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx)) break;
798 /* Stopped by walls/doors */
799 if (!player_can_enter(shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break;
801 /* Stopped by monsters */
802 if (!cave_empty_bold(p_ptr->current_floor_ptr, ny, nx)) break;
804 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
805 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
810 update_monster(c_mon_ptr->m_idx, TRUE);
816 Term_xtra(TERM_XTRA_DELAY, msec);
828 if (snipe_type == SP_PIERCE)
830 if (shooter_ptr->concent < 1) break;
831 shooter_ptr->concent--;
840 /* Chance of breakage (during attacks) */
841 j = (hit_body ? breakage_chance(q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
845 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
846 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
847 OBJECT_IDX o_idx = o_pop();
851 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
852 if (object_is_fixed_artifact(q_ptr))
854 a_info[j_ptr->name1].cur_num = 0;
859 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
860 object_copy(o_ptr, q_ptr);
863 o_ptr->marked &= OM_TOUCHED;
865 /* Forget location */
866 o_ptr->iy = o_ptr->ix = 0;
868 /* Memorize monster */
869 o_ptr->held_m_idx = m_idx;
872 o_ptr->next_o_idx = m_ptr->hold_o_idx;
875 m_ptr->hold_o_idx = o_idx;
877 else if (cave_have_flag_bold(y, x, FF_PROJECT))
879 /* Drop (or break) near that location */
880 (void)drop_near(q_ptr, j, y, x);
884 /* Drop (or break) near that location */
885 (void)drop_near(q_ptr, j, prev_y, prev_x);
888 /* Sniper - Repeat shooting when double shots */
891 /* Sniper - Loose his/her concentration after any shot */
892 if (shooter_ptr->concent) reset_concentration(shooter_ptr, FALSE);
897 * @brief プレイヤーからモンスターへの射撃命中判定 /
898 * Determine if the player "hits" a monster (normal combat).
899 * @param chance 基本命中値
900 * @param m_ptr モンスターの構造体参照ポインタ
901 * @param vis 目標を視界に捕らえているならばTRUEを指定
902 * @param o_name メッセージ表示時のモンスター名
903 * @return 命中と判定された場合TRUEを返す
904 * @note Always miss 5%, always hit 5%, otherwise random.
906 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char* o_name)
910 monster_race *r_ptr = &r_info[m_ptr->r_idx];
912 /* Percentile dice */
915 /* Snipers with high-concentration reduce instant miss percentage.*/
916 k += shooter_ptr->concent;
918 /* Hack -- Instant miss or hit */
919 if (k <= 5) return (FALSE);
920 if (k > 95) return (TRUE);
922 if (shooter_ptr->pseikaku == SEIKAKU_NAMAKE)
923 if (one_in_(20)) return (FALSE);
926 if (chance <= 0) return (FALSE);
929 if (shooter_ptr->concent)
931 ac *= (8 - shooter_ptr->concent);
935 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr)) ac *= 3;
937 /* Invisible monsters are harder to hit */
938 if (!vis) chance = (chance + 1) / 2;
940 /* Power competes against armor */
941 if (randint0(chance) < (ac * 3 / 4))
943 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr))
945 GAME_TEXT m_name[MAX_NLEN];
946 monster_desc(m_name, m_ptr, 0);
947 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
960 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
961 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
962 * @param weight 矢弾の重量
963 * @param plus_ammo 矢弾の命中修正
964 * @param plus_bow 弓の命中修正
965 * @param dam 現在算出中のダメージ値
966 * @return クリティカル修正が入ったダメージ値
968 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
971 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
973 /* Extract "shot" power */
974 i = shooter_ptr->to_h_b + plus_ammo;
976 if (shooter_ptr->tval_ammo == TV_BOLT)
977 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
979 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
982 /* Snipers can shot more critically with crossbows */
983 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
984 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
986 /* Good bow makes more critical */
987 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
990 if (randint1(10000) <= i)
992 k = weight * randint1(500);
996 msg_print(_("手ごたえがあった!", "It was a good hit!"));
1001 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
1006 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
1018 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
1019 * @param sval 射撃武器のアイテム副分類ID
1020 * @return 消費する基本エネルギー
1022 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
1024 ENERGY energy = 10000;
1026 /* Analyze the launcher */
1029 /* Sling and ammo */
1036 /* Short Bow and Arrow */
1043 /* Long Bow and Arrow */
1050 /* Bow of irresponsiblity and Arrow */
1057 /* Light Crossbow and Bolt */
1064 /* Heavy Crossbow and Bolt */
1079 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1083 /* Analyze the launcher */
1086 /* Sling and ammo */
1093 /* Short Bow and Arrow */
1100 /* Long Bow and Arrow */
1107 /* Bow of irresponsiblity and Arrow */
1114 /* Light Crossbow and Bolt */
1121 /* Heavy Crossbow and Bolt */
1134 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1135 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1136 * @param plus_ammo 矢弾のダメージ修正
1137 * @param plus_bow 弓のダメージ修正
1139 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1141 HIT_POINT calc_crit_ratio_shot(player_type* shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1144 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1146 /* Extract "shot" power */
1147 i = shooter_ptr->to_h_b + plus_ammo;
1149 if (shooter_ptr->tval_ammo == TV_BOLT)
1150 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1152 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1154 /* Snipers can shot more critically with crossbows */
1155 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
1156 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
1158 /* Good bow makes more critical */
1159 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1167 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1168 * @param weight 武器の重量
1169 * @param plus_ammo 矢弾のダメージ修正
1170 * @param plus_bow 弓のダメージ修正
1171 * @param dam 基本ダメージ量
1174 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1178 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1183 crit = MIN(500, 900 / weight);
1184 num += dam * 3 / 2 * crit;
1187 crit = MIN(500, 1350 / weight);
1189 num += dam * 2 * crit;
1195 num += dam * 3 * crit;
1201 num += (10000 - i) * dam;
1208 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1209 * @param weight 武器の重量
1210 * @param plus 武器のダメージ修正
1212 * @param meichuu 命中値
1213 * @param dokubari 毒針処理か否か
1216 HIT_POINT calc_expect_crit(WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1221 if (dokubari) return dam;
1223 i = (weight + (meichuu * 3 + plus * 5) + p_ptr->skill_thn);
1229 if (k < 400) num += (2 * dam + 5) * (400 - k);
1230 if (k < 700) num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1231 if (k > (700 - 650) && k < 900) num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1232 if (k > (900 - 650) && k < 1300) num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1233 if (k > (1300 - 650)) num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1236 if (p_ptr->pclass == CLASS_NINJA)
1239 num += (4444 - i) * dam;
1245 num += (5000 - i) * dam;