OSDN Git Service

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