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);
501 inven_item_increase(item, -1);
502 inven_item_describe(item);
503 inven_item_optimize(item);
507 floor_item_increase(0 - item, -1);
508 floor_item_optimize(0 - item);
517 /* The shot does not hit yet */
520 /* Travel until stopped */
521 for (cur_dis = 0; cur_dis <= tdis; )
525 /* Hack -- Stop at the target */
526 if ((y == ty) && (x == tx)) break;
528 /* Calculate the new location (see "project()") */
531 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
534 if (snipe_type == SP_KILL_WALL)
536 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
538 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx)
540 if (g_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
541 /* Forget the wall */
542 g_ptr->info &= ~(CAVE_MARK);
543 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
545 /* Destroy the wall */
546 cave_alter_feat(ny, nx, FF_HURT_ROCK);
553 /* Stopped by walls/doors */
554 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx) break;
556 /* Advance the distance */
560 if (snipe_type == SP_LITE)
562 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
567 /* The player can see the (on screen) missile */
568 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
570 char c = object_char(q_ptr);
571 byte a = object_attr(q_ptr);
573 /* Draw, Hilite, Fresh, Pause, Erase */
574 print_rel(c, a, ny, nx);
575 move_cursor_relative(ny, nx);
577 Term_xtra(TERM_XTRA_DELAY, msec);
582 /* The player cannot see the missile */
585 /* Pause anyway, for consistancy */
586 Term_xtra(TERM_XTRA_DELAY, msec);
590 if (snipe_type == SP_KILL_TRAP)
592 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP,
593 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
597 if (snipe_type == SP_EVILNESS)
599 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
607 /* Save the new location */
611 /* Monster here, Try to hit it */
612 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx)
614 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
616 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
617 monster_race *r_ptr = &r_info[m_ptr->r_idx];
619 /* Check the visibility */
622 /* Note the collision */
625 if (MON_CSLEEP(m_ptr))
627 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_COMPASSION, -1);
628 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_HONOUR, -1);
631 if ((r_ptr->level + 10) > shooter_ptr->lev)
633 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
634 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval])
637 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
638 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
639 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19)) amount = 10;
640 else if (shooter_ptr->lev > 34) amount = 2;
641 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
642 shooter_ptr->update |= (PU_BONUS);
646 if (shooter_ptr->riding)
648 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
649 && ((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)
652 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
653 shooter_ptr->update |= (PU_BONUS);
657 /* Did we hit it (penalize range) */
658 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
661 int tdam = tdam_base;
663 /* Get extra damage from concentration */
664 if (shooter_ptr->concent) tdam = boost_concentration_damage(shooter_ptr, tdam);
666 /* Handle unseen monster */
669 /* Invisible monster */
670 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
673 /* Handle visible monster */
676 GAME_TEXT m_name[MAX_NLEN];
678 /* Get "the monster" or "it" */
679 monster_desc(m_name, m_ptr, 0);
681 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
685 if (!shooter_ptr->image) monster_race_track(m_ptr->ap_r_idx);
686 health_track(c_mon_ptr->m_idx);
690 if (snipe_type == SP_NEEDLE)
692 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1)
693 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
695 GAME_TEXT m_name[MAX_NLEN];
697 /* Get "the monster" or "it" */
698 monster_desc(m_name, m_ptr, 0);
700 tdam = m_ptr->hp + 1;
701 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
707 /* Apply special damage */
708 tdam = tot_dam_aux_shot(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
709 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
711 /* No negative damage */
712 if (tdam < 0) tdam = 0;
714 /* Modify the damage */
715 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
718 msg_format_wizard(CHEAT_MONSTER,
719 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
720 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
723 if (snipe_type == SP_EXPLODE)
725 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
727 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
728 project(shooter_ptr, 0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
733 if (snipe_type == SP_HOLYNESS)
735 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
740 /* Hit the monster, check for death */
741 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
750 if (object_is_fixed_artifact(q_ptr) &&
751 (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0))
753 GAME_TEXT m_name[MAX_NLEN];
755 monster_desc(m_name, m_ptr, 0);
758 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"), o_name, m_name);
761 message_pain(c_mon_ptr->m_idx, tdam);
763 /* Anger the monster */
764 if (tdam > 0) anger_monster(m_ptr);
766 if (fear && m_ptr->ml)
768 GAME_TEXT m_name[MAX_NLEN];
770 monster_desc(m_name, m_ptr, 0);
771 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
774 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
777 if (snipe_type == SP_RUSH)
779 int n = randint1(5) + 3;
780 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
782 for (; cur_dis <= tdis; )
789 /* Calculate the new location (see "project()") */
790 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
792 /* Stopped by wilderness boundary */
793 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx)) break;
795 /* Stopped by walls/doors */
796 if (!player_can_enter(shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break;
798 /* Stopped by monsters */
799 if (!cave_empty_bold(p_ptr->current_floor_ptr, ny, nx)) break;
801 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
802 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
807 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
813 Term_xtra(TERM_XTRA_DELAY, msec);
825 if (snipe_type == SP_PIERCE)
827 if (shooter_ptr->concent < 1) break;
828 shooter_ptr->concent--;
837 /* Chance of breakage (during attacks) */
838 j = (hit_body ? breakage_chance(q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
842 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
843 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
844 OBJECT_IDX o_idx = o_pop();
848 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
849 if (object_is_fixed_artifact(q_ptr))
851 a_info[j_ptr->name1].cur_num = 0;
856 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
857 object_copy(o_ptr, q_ptr);
860 o_ptr->marked &= OM_TOUCHED;
862 /* Forget location */
863 o_ptr->iy = o_ptr->ix = 0;
865 /* Memorize monster */
866 o_ptr->held_m_idx = m_idx;
869 o_ptr->next_o_idx = m_ptr->hold_o_idx;
872 m_ptr->hold_o_idx = o_idx;
874 else if (cave_have_flag_bold(y, x, FF_PROJECT))
876 /* Drop (or break) near that location */
877 (void)drop_near(q_ptr, j, y, x);
881 /* Drop (or break) near that location */
882 (void)drop_near(q_ptr, j, prev_y, prev_x);
885 /* Sniper - Repeat shooting when double shots */
888 /* Sniper - Loose his/her concentration after any shot */
889 if (shooter_ptr->concent) reset_concentration(shooter_ptr, FALSE);
894 * @brief プレイヤーからモンスターへの射撃命中判定 /
895 * Determine if the player "hits" a monster (normal combat).
896 * @param chance 基本命中値
897 * @param m_ptr モンスターの構造体参照ポインタ
898 * @param vis 目標を視界に捕らえているならばTRUEを指定
899 * @param o_name メッセージ表示時のモンスター名
900 * @return 命中と判定された場合TRUEを返す
901 * @note Always miss 5%, always hit 5%, otherwise random.
903 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char* o_name)
907 monster_race *r_ptr = &r_info[m_ptr->r_idx];
909 /* Percentile dice */
912 /* Snipers with high-concentration reduce instant miss percentage.*/
913 k += shooter_ptr->concent;
915 /* Hack -- Instant miss or hit */
916 if (k <= 5) return (FALSE);
917 if (k > 95) return (TRUE);
919 if (shooter_ptr->pseikaku == SEIKAKU_NAMAKE)
920 if (one_in_(20)) return (FALSE);
923 if (chance <= 0) return (FALSE);
926 if (shooter_ptr->concent)
928 ac *= (8 - shooter_ptr->concent);
932 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr)) ac *= 3;
934 /* Invisible monsters are harder to hit */
935 if (!vis) chance = (chance + 1) / 2;
937 /* Power competes against armor */
938 if (randint0(chance) < (ac * 3 / 4))
940 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr))
942 GAME_TEXT m_name[MAX_NLEN];
943 monster_desc(m_name, m_ptr, 0);
944 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
957 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
958 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
959 * @param weight 矢弾の重量
960 * @param plus_ammo 矢弾の命中修正
961 * @param plus_bow 弓の命中修正
962 * @param dam 現在算出中のダメージ値
963 * @return クリティカル修正が入ったダメージ値
965 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
968 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
970 /* Extract "shot" power */
971 i = shooter_ptr->to_h_b + plus_ammo;
973 if (shooter_ptr->tval_ammo == TV_BOLT)
974 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
976 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
979 /* Snipers can shot more critically with crossbows */
980 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
981 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
983 /* Good bow makes more critical */
984 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
987 if (randint1(10000) <= i)
989 k = weight * randint1(500);
993 msg_print(_("手ごたえがあった!", "It was a good hit!"));
998 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
1003 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
1015 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
1016 * @param sval 射撃武器のアイテム副分類ID
1017 * @return 消費する基本エネルギー
1019 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
1021 ENERGY energy = 10000;
1023 /* Analyze the launcher */
1026 /* Sling and ammo */
1033 /* Short Bow and Arrow */
1040 /* Long Bow and Arrow */
1047 /* Bow of irresponsiblity and Arrow */
1054 /* Light Crossbow and Bolt */
1061 /* Heavy Crossbow and Bolt */
1076 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1080 /* Analyze the launcher */
1083 /* Sling and ammo */
1090 /* Short Bow and Arrow */
1097 /* Long Bow and Arrow */
1104 /* Bow of irresponsiblity and Arrow */
1111 /* Light Crossbow and Bolt */
1118 /* Heavy Crossbow and Bolt */
1131 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1132 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1133 * @param plus_ammo 矢弾のダメージ修正
1134 * @param plus_bow 弓のダメージ修正
1136 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1138 HIT_POINT calc_crit_ratio_shot(player_type* shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1141 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1143 /* Extract "shot" power */
1144 i = shooter_ptr->to_h_b + plus_ammo;
1146 if (shooter_ptr->tval_ammo == TV_BOLT)
1147 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1149 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1151 /* Snipers can shot more critically with crossbows */
1152 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
1153 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
1155 /* Good bow makes more critical */
1156 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1164 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1165 * @param weight 武器の重量
1166 * @param plus_ammo 矢弾のダメージ修正
1167 * @param plus_bow 弓のダメージ修正
1168 * @param dam 基本ダメージ量
1171 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1175 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1180 crit = MIN(500, 900 / weight);
1181 num += dam * 3 / 2 * crit;
1184 crit = MIN(500, 1350 / weight);
1186 num += dam * 2 * crit;
1192 num += dam * 3 * crit;
1198 num += (10000 - i) * dam;
1205 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1206 * @param weight 武器の重量
1207 * @param plus 武器のダメージ修正
1209 * @param meichuu 命中値
1210 * @param dokubari 毒針処理か否か
1213 HIT_POINT calc_expect_crit(WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1218 if (dokubari) return dam;
1220 i = (weight + (meichuu * 3 + plus * 5) + p_ptr->skill_thn);
1226 if (k < 400) num += (2 * dam + 5) * (400 - k);
1227 if (k < 700) num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1228 if (k > (700 - 650) && k < 900) num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1229 if (k > (900 - 650) && k < 1300) num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1230 if (k > (1300 - 650)) num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1233 if (p_ptr->pclass == CLASS_NINJA)
1236 num += (4444 - i) * dam;
1242 num += (5000 - i) * dam;