OSDN Git Service

[Refactor] #40512 Separated wizard-messages.c/h from display-messages.c/h
[hengband/hengband.git] / src / combat / shoot.c
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"
54
55 /*!
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 スレイ倍率をかけたダメージ量
62  */
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)
64 {
65         MULTIPLY mult = 10;
66
67         monster_race *r_ptr = &r_info[m_ptr->r_idx];
68
69         BIT_FLAGS flgs[TR_FLAG_SIZE];
70         object_flags(sniper_ptr, o_ptr, flgs);
71
72         /* Some "weapons" and "ammo" do extra damage */
73         switch (o_ptr->tval)
74         {
75         case TV_SHOT:
76         case TV_ARROW:
77         case TV_BOLT:
78         {
79                 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
80                 {
81                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
82                         {
83                                 r_ptr->r_flags3 |= RF3_ANIMAL;
84                         }
85                         if (mult < 17) mult = 17;
86                 }
87
88                 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
89                 {
90                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
91                         {
92                                 r_ptr->r_flags3 |= RF3_ANIMAL;
93                         }
94                         if (mult < 27) mult = 27;
95                 }
96
97                 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
98                 {
99                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
100                         {
101                                 r_ptr->r_flags3 |= RF3_EVIL;
102                         }
103                         if (mult < 15) mult = 15;
104                 }
105
106                 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
107                 {
108                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
109                         {
110                                 r_ptr->r_flags3 |= RF3_EVIL;
111                         }
112                         if (mult < 25) mult = 25;
113                 }
114
115                 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
116                 {
117                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
118                         {
119                                 r_ptr->r_flags2 |= RF2_HUMAN;
120                         }
121                         if (mult < 17) mult = 17;
122                 }
123
124                 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
125                 {
126                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
127                         {
128                                 r_ptr->r_flags2 |= RF2_HUMAN;
129                         }
130                         if (mult < 27) mult = 27;
131                 }
132
133                 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
134                 {
135                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
136                         {
137                                 r_ptr->r_flags3 |= RF3_UNDEAD;
138                         }
139                         if (mult < 20) mult = 20;
140                 }
141
142                 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
143                 {
144                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
145                         {
146                                 r_ptr->r_flags3 |= RF3_UNDEAD;
147                         }
148                         if (mult < 30) mult = 30;
149                 }
150
151                 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
152                 {
153                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
154                         {
155                                 r_ptr->r_flags3 |= RF3_DEMON;
156                         }
157                         if (mult < 20) mult = 20;
158                 }
159
160                 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
161                 {
162                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
163                         {
164                                 r_ptr->r_flags3 |= RF3_DEMON;
165                         }
166                         if (mult < 30) mult = 30;
167                 }
168
169                 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
170                 {
171                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
172                         {
173                                 r_ptr->r_flags3 |= RF3_ORC;
174                         }
175                         if (mult < 20) mult = 20;
176                 }
177
178                 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
179                 {
180                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
181                         {
182                                 r_ptr->r_flags3 |= RF3_ORC;
183                         }
184                         if (mult < 30) mult = 30;
185                 }
186
187                 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
188                 {
189                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
190                         {
191                                 r_ptr->r_flags3 |= RF3_TROLL;
192                         }
193
194                         if (mult < 20) mult = 20;
195                 }
196
197                 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
198                 {
199                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
200                         {
201                                 r_ptr->r_flags3 |= RF3_TROLL;
202                         }
203                         if (mult < 30) mult = 30;
204                 }
205
206                 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
207                 {
208                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
209                         {
210                                 r_ptr->r_flags3 |= RF3_GIANT;
211                         }
212                         if (mult < 20) mult = 20;
213                 }
214
215                 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
216                 {
217                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
218                         {
219                                 r_ptr->r_flags3 |= RF3_GIANT;
220                         }
221                         if (mult < 30) mult = 30;
222                 }
223
224                 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
225                 {
226                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
227                         {
228                                 r_ptr->r_flags3 |= RF3_DRAGON;
229                         }
230                         if (mult < 20) mult = 20;
231                 }
232
233                 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
234                 {
235                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
236                         {
237                                 r_ptr->r_flags3 |= RF3_DRAGON;
238                         }
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))
242                                 mult *= 5;
243                 }
244
245                 if (have_flag(flgs, TR_BRAND_ACID))
246                 {
247                         /* Notice immunity */
248                         if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
249                         {
250                                 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
251                                 {
252                                         r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
253                                 }
254                         }
255                         else
256                         {
257                                 if (mult < 17) mult = 17;
258                         }
259                 }
260
261                 if (have_flag(flgs, TR_BRAND_ELEC))
262                 {
263                         /* Notice immunity */
264                         if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
265                         {
266                                 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
267                                 {
268                                         r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
269                                 }
270                         }
271                         else
272                         {
273                                 if (mult < 17) mult = 17;
274                         }
275                 }
276
277                 if (have_flag(flgs, TR_BRAND_FIRE))
278                 {
279                         /* Notice immunity */
280                         if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
281                         {
282                                 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
283                                 {
284                                         r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
285                                 }
286                         }
287                         /* Otherwise, take the damage */
288                         else
289                         {
290                                 if (r_ptr->flags3 & RF3_HURT_FIRE)
291                                 {
292                                         if (mult < 25) mult = 25;
293                                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
294                                         {
295                                                 r_ptr->r_flags3 |= RF3_HURT_FIRE;
296                                         }
297                                 }
298                                 else if (mult < 17) mult = 17;
299                         }
300                 }
301
302                 if (have_flag(flgs, TR_BRAND_COLD))
303                 {
304                         /* Notice immunity */
305                         if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
306                         {
307                                 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
308                                 {
309                                         r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
310                                 }
311                         }
312                         /* Otherwise, take the damage */
313                         else
314                         {
315                                 if (r_ptr->flags3 & RF3_HURT_COLD)
316                                 {
317                                         if (mult < 25) mult = 25;
318                                         if (is_original_ap_and_seen(sniper_ptr, m_ptr))
319                                         {
320                                                 r_ptr->r_flags3 |= RF3_HURT_COLD;
321                                         }
322                                 }
323                                 else if (mult < 17) mult = 17;
324                         }
325                 }
326
327                 if (have_flag(flgs, TR_BRAND_POIS))
328                 {
329                         /* Notice immunity */
330                         if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
331                         {
332                                 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
333                                 {
334                                         r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
335                                 }
336                         }
337                         /* Otherwise, take the damage */
338                         else
339                         {
340                                 if (mult < 17) mult = 17;
341                         }
342                 }
343
344                 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30)))
345                 {
346                         sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
347                         sniper_ptr->redraw |= (PR_MANA);
348                         mult = mult * 5 / 2;
349                 }
350                 break;
351         }
352         }
353
354         /* Sniper */
355         if (snipe_type) mult = calc_snipe_damage_with_slay(sniper_ptr, mult, m_ptr, snipe_type);
356
357         /* Return the total damage */
358         return (tdam * mult / 10);
359 }
360
361
362 /*!
363  * @brief 射撃処理実行 /
364  * Fire an object from the pack or floor.
365  * @param item 射撃するオブジェクトの所持ID
366  * @param j_ptr 射撃武器のオブジェクト参照ポインタ
367  * @return なし
368  * @details
369  * <pre>
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.
384  * </pre>
385  */
386 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
387 {
388         DIRECTION dir;
389         int i;
390         POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
391         int tdam_base, tdis, thits, tmul;
392         int bonus, chance;
393         int cur_dis, visible;
394         PERCENTAGE j;
395
396         object_type forge;
397         object_type *q_ptr;
398
399         object_type *o_ptr;
400
401         bool hit_body = FALSE;
402
403         GAME_TEXT o_name[MAX_NLEN];
404
405         u16b path_g[512];       /* For calcuration of path length */
406
407         int msec = delay_factor * delay_factor * delay_factor;
408
409         /* STICK TO */
410         bool stick_to = FALSE;
411
412         /* Access the item (if in the pack) */
413         if (item >= 0)
414         {
415                 o_ptr = &shooter_ptr->inventory_list[item];
416         }
417         else
418         {
419                 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
420         }
421
422         /* Sniper - Cannot shot a single arrow twice */
423         if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
424
425         object_desc(shooter_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
426
427         /* Use the proper number of shots */
428         thits = shooter_ptr->num_fire;
429
430         /* Use a base distance */
431         tdis = 10;
432
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;
435
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);
440         else
441                 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
442
443         shooter_ptr->energy_use = bow_energy(j_ptr->sval);
444         tmul = bow_tmul(j_ptr->sval);
445
446         /* Get extra "power" from "extra might" */
447         if (shooter_ptr->xtra_might) tmul++;
448
449         tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
450
451         /* Boost the damage */
452         tdam_base *= tmul;
453         tdam_base /= 100;
454
455         /* Base range */
456         tdis = 13 + tmul / 80;
457         if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
458         {
459                 if (shooter_ptr->concent)
460                         tdis -= (5 - (shooter_ptr->concent + 1) / 2);
461                 else
462                         tdis -= 5;
463         }
464
465         project_length = tdis + 1;
466
467         /* Get a direction (or cancel) */
468         if (!get_aim_dir(shooter_ptr, &dir))
469         {
470                 free_turn(shooter_ptr);
471
472                 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
473
474                 /* need not to reset project_length (already did)*/
475
476                 return;
477         }
478
479         /* Predict the "target" location */
480         tx = shooter_ptr->x + 99 * ddx[dir];
481         ty = shooter_ptr->y + 99 * ddy[dir];
482
483         /* Check for "target request" */
484         if ((dir == 5) && target_okay(shooter_ptr))
485         {
486                 tx = target_col;
487                 ty = target_row;
488         }
489
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;
492
493         project_length = 0; /* reset to default */
494
495         /* Don't shoot at my feet */
496         if (tx == shooter_ptr->x && ty == shooter_ptr->y)
497         {
498                 free_turn(shooter_ptr);
499
500                 /* project_length is already reset to 0 */
501
502                 return;
503         }
504
505
506         /* Take a (partial) turn */
507         shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
508         shooter_ptr->is_fired = TRUE;
509
510         /* Sniper - Difficult to shot twice at 1 turn */
511         if (snipe_type == SP_DOUBLE)  shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
512
513         /* Sniper - Repeat shooting when double shots */
514         for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
515         {
516
517                 /* Start at the player */
518                 y = shooter_ptr->y;
519                 x = shooter_ptr->x;
520                 q_ptr = &forge;
521                 object_copy(q_ptr, o_ptr);
522
523                 /* Single object */
524                 q_ptr->number = 1;
525
526                 vary_item(shooter_ptr, item, -1);
527
528                 sound(SOUND_SHOOT);
529                 handle_stuff(shooter_ptr);
530
531                 prev_y = y;
532                 prev_x = x;
533
534                 /* The shot does not hit yet */
535                 hit_body = FALSE;
536
537                 /* Travel until stopped */
538                 for (cur_dis = 0; cur_dis <= tdis; )
539                 {
540                         grid_type *g_ptr;
541
542                         /* Hack -- Stop at the target */
543                         if ((y == ty) && (x == tx)) break;
544
545                         /* Calculate the new location (see "project()") */
546                         ny = y;
547                         nx = x;
548                         mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
549
550                         /* Shatter Arrow */
551                         if (snipe_type == SP_KILL_WALL)
552                         {
553                                 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
554
555                                 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx)
556                                 {
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);
561
562                                         /* Destroy the wall */
563                                         cave_alter_feat(shooter_ptr, ny, nx, FF_HURT_ROCK);
564
565                                         hit_body = TRUE;
566                                         break;
567                                 }
568                         }
569
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;
572
573                         /* Advance the distance */
574                         cur_dis++;
575
576                         /* Sniper */
577                         if (snipe_type == SP_LITE)
578                         {
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);
582                         }
583
584                         /* The player can see the (on screen) missile */
585                         if (panel_contains(ny, nx) && player_can_see_bold(shooter_ptr, ny, nx))
586                         {
587                                 SYMBOL_CODE c = object_char(q_ptr);
588                                 byte a = object_attr(q_ptr);
589
590                                 /* Draw, Hilite, Fresh, Pause, Erase */
591                                 print_rel(shooter_ptr, c, a, ny, nx);
592                                 move_cursor_relative(ny, nx);
593                                 Term_fresh();
594                                 Term_xtra(TERM_XTRA_DELAY, msec);
595                                 lite_spot(shooter_ptr, ny, nx);
596                                 Term_fresh();
597                         }
598
599                         /* The player cannot see the missile */
600                         else
601                         {
602                                 /* Pause anyway, for consistancy */
603                                 Term_xtra(TERM_XTRA_DELAY, msec);
604                         }
605
606                         /* Sniper */
607                         if (snipe_type == SP_KILL_TRAP)
608                         {
609                                 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP,
610                                         (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
611                         }
612
613                         /* Sniper */
614                         if (snipe_type == SP_EVILNESS)
615                         {
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);
619                         }
620
621                         prev_y = y;
622                         prev_x = x;
623
624                         /* Save the new location */
625                         x = nx;
626                         y = ny;
627
628                         /* Monster here, Try to hit it */
629                         if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx)
630                         {
631                                 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
632
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];
635
636                                 /* Check the visibility */
637                                 visible = m_ptr->ml;
638
639                                 /* Note the collision */
640                                 hit_body = TRUE;
641
642                                 if (monster_csleep_remaining(m_ptr))
643                                 {
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);
646                                 }
647
648                                 if ((r_ptr->level + 10) > shooter_ptr->lev)
649                                 {
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])
652                                         {
653                                                 SUB_EXP amount = 0;
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);
660                                         }
661                                 }
662
663                                 if (shooter_ptr->riding)
664                                 {
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)
667                                                 && one_in_(2))
668                                         {
669                                                 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
670                                                 shooter_ptr->update |= (PU_BONUS);
671                                         }
672                                 }
673
674                                 /* Did we hit it (penalize range) */
675                                 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
676                                 {
677                                         bool fear = FALSE;
678                                         int tdam = tdam_base;
679
680                                         /* Get extra damage from concentration */
681                                         if (shooter_ptr->concent) tdam = boost_concentration_damage(shooter_ptr, tdam);
682
683                                         /* Handle unseen monster */
684                                         if (!visible)
685                                         {
686                                                 /* Invisible monster */
687                                                 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
688                                         }
689
690                                         /* Handle visible monster */
691                                         else
692                                         {
693                                                 GAME_TEXT m_name[MAX_NLEN];
694
695                                                 /* Get "the monster" or "it" */
696                                                 monster_desc(shooter_ptr, m_name, m_ptr, 0);
697
698                                                 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
699
700                                                 if (m_ptr->ml)
701                                                 {
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);
704                                                 }
705                                         }
706
707                                         if (snipe_type == SP_NEEDLE)
708                                         {
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))
711                                                 {
712                                                         GAME_TEXT m_name[MAX_NLEN];
713
714                                                         /* Get "the monster" or "it" */
715                                                         monster_desc(shooter_ptr, m_name, m_ptr, 0);
716
717                                                         tdam = m_ptr->hp + 1;
718                                                         msg_format(_("%sの急所に突き刺さった!", "Your shot hit a fatal spot of %s!"), m_name);
719                                                 }
720                                                 else tdam = 1;
721                                         }
722                                         else
723                                         {
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);
727
728                                                 /* No negative damage */
729                                                 if (tdam < 0) tdam = 0;
730
731                                                 /* Modify the damage */
732                                                 tdam = mon_damage_mod(shooter_ptr, m_ptr, tdam, FALSE);
733                                         }
734
735                                         msg_format_wizard(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);
738
739                                         /* Sniper */
740                                         if (snipe_type == SP_EXPLODE)
741                                         {
742                                                 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
743
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);
746                                                 break;
747                                         }
748
749                                         /* Sniper */
750                                         if (snipe_type == SP_HOLYNESS)
751                                         {
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);
755                                         }
756
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))))
759                                         {
760                                                 /* Dead monster */
761                                         }
762
763                                         /* No death */
764                                         else
765                                         {
766                                                 /* STICK TO */
767                                                 if (object_is_fixed_artifact(q_ptr) &&
768                                                         (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0))
769                                                 {
770                                                         GAME_TEXT m_name[MAX_NLEN];
771
772                                                         monster_desc(shooter_ptr, m_name, m_ptr, 0);
773
774                                                         stick_to = TRUE;
775                                                         msg_format(_("%sは%sに突き刺さった!", "%^s is stuck in %s!"), o_name, m_name);
776                                                 }
777
778                                                 message_pain(shooter_ptr, c_mon_ptr->m_idx, tdam);
779
780                                                 /* Anger the monster */
781                                                 if (tdam > 0) anger_monster(shooter_ptr, m_ptr);
782
783                                                 if (fear && m_ptr->ml)
784                                                 {
785                                                         GAME_TEXT m_name[MAX_NLEN];
786                                                         sound(SOUND_FLEE);
787                                                         monster_desc(shooter_ptr, m_name, m_ptr, 0);
788                                                         msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
789                                                 }
790
791                                                 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
792
793                                                 /* Sniper */
794                                                 if (snipe_type == SP_RUSH)
795                                                 {
796                                                         int n = randint1(5) + 3;
797                                                         MONSTER_IDX m_idx = c_mon_ptr->m_idx;
798
799                                                         for (; cur_dis <= tdis; )
800                                                         {
801                                                                 POSITION ox = nx;
802                                                                 POSITION oy = ny;
803
804                                                                 if (!n) break;
805
806                                                                 /* Calculate the new location (see "project()") */
807                                                                 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
808
809                                                                 /* Stopped by wilderness boundary */
810                                                                 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx)) break;
811
812                                                                 /* Stopped by walls/doors */
813                                                                 if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break;
814
815                                                                 /* Stopped by monsters */
816                                                                 if (!is_cave_empty_bold(shooter_ptr, ny, nx)) break;
817
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;
820
821                                                                 m_ptr->fx = nx;
822                                                                 m_ptr->fy = ny;
823
824                                                                 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
825
826                                                                 lite_spot(shooter_ptr, ny, nx);
827                                                                 lite_spot(shooter_ptr, oy, ox);
828
829                                                                 Term_fresh();
830                                                                 Term_xtra(TERM_XTRA_DELAY, msec);
831
832                                                                 x = nx;
833                                                                 y = ny;
834                                                                 cur_dis++;
835                                                                 n--;
836                                                         }
837                                                 }
838                                         }
839                                 }
840
841                                 /* Sniper */
842                                 if (snipe_type == SP_PIERCE)
843                                 {
844                                         if (shooter_ptr->concent < 1) break;
845                                         shooter_ptr->concent--;
846                                         continue;
847                                 }
848
849                                 /* Stop looking */
850                                 break;
851                         }
852                 }
853
854                 /* Chance of breakage (during attacks) */
855                 j = (hit_body ? breakage_chance(shooter_ptr, q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
856
857                 if (stick_to)
858                 {
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);
862
863                         if (!o_idx)
864                         {
865                                 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
866                                 if (object_is_fixed_artifact(q_ptr))
867                                 {
868                                         a_info[j_ptr->name1].cur_num = 0;
869                                 }
870                                 return;
871                         }
872
873                         o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
874                         object_copy(o_ptr, q_ptr);
875
876                         /* Forget mark */
877                         o_ptr->marked &= OM_TOUCHED;
878
879                         /* Forget location */
880                         o_ptr->iy = o_ptr->ix = 0;
881
882                         /* Memorize monster */
883                         o_ptr->held_m_idx = m_idx;
884
885                         /* Build a stack */
886                         o_ptr->next_o_idx = m_ptr->hold_o_idx;
887
888                         /* Carry object */
889                         m_ptr->hold_o_idx = o_idx;
890                 }
891                 else if (cave_have_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT))
892                 {
893                         /* Drop (or break) near that location */
894                         (void)drop_near(shooter_ptr, q_ptr, j, y, x);
895                 }
896                 else
897                 {
898                         /* Drop (or break) near that location */
899                         (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x);
900                 }
901
902                 /* Sniper - Repeat shooting when double shots */
903         }
904
905         /* Sniper - Loose his/her concentration after any shot */
906         if (shooter_ptr->concent) reset_concentration(shooter_ptr, FALSE);
907 }
908
909
910 /*!
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.
919 */
920 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char* o_name)
921 {
922         int k;
923         ARMOUR_CLASS ac;
924         monster_race *r_ptr = &r_info[m_ptr->r_idx];
925
926         /* Percentile dice */
927         k = randint1(100);
928
929         /* Snipers with high-concentration reduce instant miss percentage.*/
930         k += shooter_ptr->concent;
931
932         /* Hack -- Instant miss or hit */
933         if (k <= 5) return FALSE;
934         if (k > 95) return TRUE;
935
936         if (shooter_ptr->pseikaku == PERSONALITY_LAZY)
937                 if (one_in_(20)) return FALSE;
938
939         /* Never hit */
940         if (chance <= 0) return FALSE;
941
942         ac = r_ptr->ac;
943         if (shooter_ptr->concent)
944         {
945                 ac *= (8 - shooter_ptr->concent);
946                 ac /= 8;
947         }
948
949         if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr)) ac *= 3;
950
951         /* Invisible monsters are harder to hit */
952         if (!vis) chance = (chance + 1) / 2;
953
954         /* Power competes against armor */
955         if (randint0(chance) < (ac * 3 / 4))
956         {
957                 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr))
958                 {
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);
962                 }
963                 return FALSE;
964         }
965
966         /* Assume hit */
967         return TRUE;
968 }
969
970
971
972
973 /*!
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 クリティカル修正が入ったダメージ値
981 */
982 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
983 {
984         int i, k;
985         object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
986
987         /* Extract "shot" power */
988         i = shooter_ptr->to_h_b + plus_ammo;
989
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);
992         else
993                 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
994
995
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;
999
1000         /* Good bow makes more critical */
1001         i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1002
1003         /* Critical hit */
1004         if (randint1(10000) <= i)
1005         {
1006                 k = weight * randint1(500);
1007
1008                 if (k < 900)
1009                 {
1010                         msg_print(_("手ごたえがあった!", "It was a good hit!"));
1011                         dam += (dam / 2);
1012                 }
1013                 else if (k < 1350)
1014                 {
1015                         msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
1016                         dam *= 2;
1017                 }
1018                 else
1019                 {
1020                         msg_print(_("会心の一撃だ!", "It was a superb hit!"));
1021                         dam *= 3;
1022                 }
1023         }
1024
1025         return (dam);
1026 }
1027
1028
1029
1030
1031 /*!
1032  * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
1033  * @param sval 射撃武器のアイテム副分類ID
1034  * @return 消費する基本エネルギー
1035  */
1036 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
1037 {
1038         ENERGY energy = 10000;
1039
1040         /* Analyze the launcher */
1041         switch (sval)
1042         {
1043                 /* Sling and ammo */
1044         case SV_SLING:
1045         {
1046                 energy = 8000;
1047                 break;
1048         }
1049
1050         /* Short Bow and Arrow */
1051         case SV_SHORT_BOW:
1052         {
1053                 energy = 10000;
1054                 break;
1055         }
1056
1057         /* Long Bow and Arrow */
1058         case SV_LONG_BOW:
1059         {
1060                 energy = 10000;
1061                 break;
1062         }
1063
1064         /* Bow of irresponsiblity and Arrow */
1065         case SV_NAMAKE_BOW:
1066         {
1067                 energy = 7777;
1068                 break;
1069         }
1070
1071         /* Light Crossbow and Bolt */
1072         case SV_LIGHT_XBOW:
1073         {
1074                 energy = 12000;
1075                 break;
1076         }
1077
1078         /* Heavy Crossbow and Bolt */
1079         case SV_HEAVY_XBOW:
1080         {
1081                 energy = 13333;
1082                 break;
1083         }
1084         }
1085
1086         return (energy);
1087 }
1088
1089
1090 /*
1091  * Return bow tmul
1092  */
1093 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1094 {
1095         int tmul = 0;
1096
1097         /* Analyze the launcher */
1098         switch (sval)
1099         {
1100                 /* Sling and ammo */
1101         case SV_SLING:
1102         {
1103                 tmul = 2;
1104                 break;
1105         }
1106
1107         /* Short Bow and Arrow */
1108         case SV_SHORT_BOW:
1109         {
1110                 tmul = 2;
1111                 break;
1112         }
1113
1114         /* Long Bow and Arrow */
1115         case SV_LONG_BOW:
1116         {
1117                 tmul = 3;
1118                 break;
1119         }
1120
1121         /* Bow of irresponsiblity and Arrow */
1122         case SV_NAMAKE_BOW:
1123         {
1124                 tmul = 3;
1125                 break;
1126         }
1127
1128         /* Light Crossbow and Bolt */
1129         case SV_LIGHT_XBOW:
1130         {
1131                 tmul = 3;
1132                 break;
1133         }
1134
1135         /* Heavy Crossbow and Bolt */
1136         case SV_HEAVY_XBOW:
1137         {
1138                 tmul = 4;
1139                 break;
1140         }
1141         }
1142
1143         return (tmul);
1144 }
1145
1146
1147 /*!
1148  * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1149  * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1150  * @param plus_ammo 矢弾のダメージ修正
1151  * @param plus_bow 弓のダメージ修正
1152  * @return ダメージ期待値
1153  * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1154  */
1155 HIT_POINT calc_crit_ratio_shot(player_type* shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1156 {
1157         HIT_POINT i;
1158         object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1159
1160         /* Extract "shot" power */
1161         i = shooter_ptr->to_h_b + plus_ammo;
1162
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);
1165         else
1166                 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1167
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;
1171
1172         /* Good bow makes more critical */
1173         i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1174
1175         if (i < 0) i = 0;
1176
1177         return i;
1178 }
1179
1180 /*!
1181  * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1182  * @param weight 武器の重量
1183  * @param plus_ammo 矢弾のダメージ修正
1184  * @param plus_bow 弓のダメージ修正
1185  * @param dam 基本ダメージ量
1186  * @return ダメージ期待値
1187  */
1188 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1189 {
1190         u32b num;
1191         int i, k, crit;
1192         i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1193
1194         k = 0;
1195         num = 0;
1196
1197         crit = MIN(500, 900 / weight);
1198         num += dam * 3 / 2 * crit;
1199         k = crit;
1200
1201         crit = MIN(500, 1350 / weight);
1202         crit -= k;
1203         num += dam * 2 * crit;
1204         k += crit;
1205
1206         if (k < 500)
1207         {
1208                 crit = 500 - k;
1209                 num += dam * 3 * crit;
1210         }
1211
1212         num /= 500;
1213
1214         num *= i;
1215         num += (10000 - i) * dam;
1216         num /= 10000;
1217
1218         return num;
1219 }
1220
1221 /*!
1222  * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1223  * @param shooter_ptr プレーヤーへの参照ポインタ
1224  * @param weight 武器の重量
1225  * @param plus 武器のダメージ修正
1226  * @param dam 基本ダメージ
1227  * @param meichuu 命中値
1228  * @param dokubari 毒針処理か否か
1229  * @return ダメージ期待値
1230  */
1231 HIT_POINT calc_expect_crit(player_type *shooter_ptr, WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1232 {
1233         u32b k, num;
1234         if (dokubari) return dam;
1235
1236         int i = (weight + (meichuu * 3 + plus * 5) + shooter_ptr->skill_thn);
1237         if (i < 0) i = 0;
1238
1239         k = weight;
1240         num = 0;
1241
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));
1247
1248         num /= 650;
1249         if (shooter_ptr->pclass == CLASS_NINJA)
1250         {
1251                 num *= i;
1252                 num += (4444 - i) * dam;
1253                 num /= 4444;
1254         }
1255         else
1256         {
1257                 num *= i;
1258                 num += (5000 - i) * dam;
1259                 num /= 5000;
1260         }
1261
1262         return num;
1263 }
1264