OSDN Git Service

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