- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_DEMON;
- }
-
- if (mult < 30) mult = 30;
- }
-
- /* Slay Orc */
- if ((have_flag(flgs, TR_SLAY_ORC)) &&
- (r_ptr->flags3 & RF3_ORC))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_ORC;
- }
-
- if (mult < 20) mult = 20;
- }
-
- /* Kill Orc */
- if ((have_flag(flgs, TR_KILL_ORC)) &&
- (r_ptr->flags3 & RF3_ORC))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_ORC;
- }
-
- if (mult < 30) mult = 30;
- }
-
- /* Slay Troll */
- if ((have_flag(flgs, TR_SLAY_TROLL)) &&
- (r_ptr->flags3 & RF3_TROLL))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_TROLL;
- }
-
- if (mult < 20) mult = 20;
- }
-
- /* Kill Troll */
- if ((have_flag(flgs, TR_KILL_TROLL)) &&
- (r_ptr->flags3 & RF3_TROLL))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_TROLL;
- }
-
- if (mult < 30) mult = 30;
- }
-
- /* Slay Giant */
- if ((have_flag(flgs, TR_SLAY_GIANT)) &&
- (r_ptr->flags3 & RF3_GIANT))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_GIANT;
- }
-
- if (mult < 20) mult = 20;
- }
-
- /* Kill Giant */
- if ((have_flag(flgs, TR_KILL_GIANT)) &&
- (r_ptr->flags3 & RF3_GIANT))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_GIANT;
- }
-
- if (mult < 30) mult = 30;
- }
-
- /* Slay Dragon */
- if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
- (r_ptr->flags3 & RF3_DRAGON))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_DRAGON;
- }
-
- if (mult < 20) mult = 20;
- }
-
- /* Execute Dragon */
- if ((have_flag(flgs, TR_KILL_DRAGON)) &&
- (r_ptr->flags3 & RF3_DRAGON))
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_DRAGON;
- }
-
- if (mult < 30) mult = 30;
-
- if ((o_ptr->name1 == ART_BARD_ARROW) &&
- (m_ptr->r_idx == MON_SMAUG) &&
- (inventory[INVEN_BOW].name1 == ART_BARD))
- mult *= 5;
- }
-
- /* Brand (Acid) */
- if (have_flag(flgs, TR_BRAND_ACID))
- {
- /* Notice immunity */
- if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
- }
- }
-
- /* Otherwise, take the damage */
- else
- {
- if (mult < 17) mult = 17;
- }
- }
-
- /* Brand (Elec) */
- if (have_flag(flgs, TR_BRAND_ELEC))
- {
- /* Notice immunity */
- if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
- }
- }
-
- /* Otherwise, take the damage */
- else
- {
- if (mult < 17) mult = 17;
- }
- }
-
- /* Brand (Fire) */
- if (have_flag(flgs, TR_BRAND_FIRE))
- {
- /* Notice immunity */
- if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
- }
- }
-
- /* Otherwise, take the damage */
- else
- {
- if (r_ptr->flags3 & RF3_HURT_FIRE)
- {
- if (mult < 25) mult = 25;
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_HURT_FIRE;
- }
- }
- else if (mult < 17) mult = 17;
- }
- }
-
- /* Brand (Cold) */
- if (have_flag(flgs, TR_BRAND_COLD))
- {
- /* Notice immunity */
- if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
- }
- }
- /* Otherwise, take the damage */
- else
- {
- if (r_ptr->flags3 & RF3_HURT_COLD)
- {
- if (mult < 25) mult = 25;
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flags3 |= RF3_HURT_COLD;
- }
- }
- else if (mult < 17) mult = 17;
- }
- }
-
- /* Brand (Poison) */
- if (have_flag(flgs, TR_BRAND_POIS))
- {
- /* Notice immunity */
- if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
- {
- if (is_original_ap_and_seen(m_ptr))
- {
- r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
- }
- }
-
- /* Otherwise, take the damage */
- else
- {
- if (mult < 17) mult = 17;
- }
- }
-
- if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
- {
- p_ptr->csp -= (1+(p_ptr->msp / 30));
- p_ptr->redraw |= (PR_MANA);
- mult = mult * 5 / 2;
- }
- break;
- }
- }
-
- /* Sniper */
- if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
-
- /* Return the total damage */
- return (tdam * mult / 10);
-}
-
-
-/*
- * Fire an object from the pack or floor.
- *
- * You may only fire items that "match" your missile launcher.
- *
- * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
- *
- * See "calc_bonuses()" for more calculations and such.
- *
- * Note that "firing" a missile is MUCH better than "throwing" it.
- *
- * Note: "unseen" monsters are very hard to hit.
- *
- * Objects are more likely to break if they "attempt" to hit a monster.
- *
- * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
- *
- * The "extra shot" code works by decreasing the amount of energy
- * required to make each shot, spreading the shots out over time.
- *
- * Note that when firing missiles, the launcher multiplier is applied
- * after all the bonuses are added in, making multipliers very useful.
- *
- * Note that Bows of "Extra Might" get extra range and an extra bonus
- * for the damage multiplier.
- *
- * Note that Bows of "Extra Shots" give an extra shot.
- */
-void do_cmd_fire_aux(int item, object_type *j_ptr)
-{
- int dir;
- int i, j, y, x, ny, nx, ty, tx, prev_y, prev_x;
- int tdam_base, tdis, thits, tmul;
- int bonus, chance;
- int cur_dis, visible;
-
- object_type forge;
- object_type *q_ptr;
-
- object_type *o_ptr;
-
- bool hit_body = FALSE;
-
- char o_name[MAX_NLEN];
-
- u16b path_g[512]; /* For calcuration of path length */
-
- int msec = delay_factor * delay_factor * delay_factor;
-
- /* STICK TO */
- bool stick_to = FALSE;
-
- /* Access the item (if in the pack) */
- if (item >= 0)
- {
- o_ptr = &inventory[item];
- }
- else
- {
- o_ptr = &o_list[0 - item];
- }
-
- /* Sniper - Cannot shot a single arrow twice */
- if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
-
- /* Describe the object */
- object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
-
- /* Use the proper number of shots */
- thits = p_ptr->num_fire;
-
- /* Use a base distance */
- tdis = 10;
-
- /* Base damage from thrown object plus launcher bonus */
- tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
-
- /* Actually "fire" the object */
- bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
- if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
- chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
- else
- chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
-
- energy_use = bow_energy(j_ptr->sval);
- tmul = bow_tmul(j_ptr->sval);
-
- /* Get extra "power" from "extra might" */
- if (p_ptr->xtra_might) tmul++;
-
- tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
-
- /* Boost the damage */
- tdam_base *= tmul;
- tdam_base /= 100;
-
- /* Base range */
- tdis = 13 + tmul/80;
- if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
- {
- if (p_ptr->concent)
- tdis -= (5 - (p_ptr->concent + 1) / 2);
- else
- tdis -= 5;
- }
-
- project_length = tdis + 1;
-
- /* Get a direction (or cancel) */
- if (!get_aim_dir(&dir))
- {
- energy_use = 0;
-
- if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
-
- /* need not to reset project_length (already did)*/
-
- return;
- }
-
- /* Predict the "target" location */
- tx = px + 99 * ddx[dir];
- ty = py + 99 * ddy[dir];
-
- /* Check for "target request" */
- if ((dir == 5) && target_okay())
- {
- tx = target_col;
- ty = target_row;
- }
-
- /* Get projection path length */
- tdis = project_path(path_g, project_length, py, px, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
-
- project_length = 0; /* reset to default */
-
- /* Don't shoot at my feet */
- if (tx == px && ty == py)
- {
- energy_use = 0;
-
- /* project_length is already reset to 0 */
-
- return;
- }
-
-
- /* Take a (partial) turn */
- energy_use = (energy_use / thits);
- is_fired = TRUE;
-
- /* Sniper - Difficult to shot twice at 1 turn */
- if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
-
- /* Sniper - Repeat shooting when double shots */
- for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
- {
-
- /* Start at the player */
- y = py;
- x = px;
-
- /* Get local object */
- q_ptr = &forge;
-
- /* Obtain a local object */
- object_copy(q_ptr, o_ptr);
-
- /* Single object */
- q_ptr->number = 1;
-
- /* Reduce and describe inventory */
- if (item >= 0)
- {
- inven_item_increase(item, -1);
- inven_item_describe(item);
- inven_item_optimize(item);
- }
-
- /* Reduce and describe floor item */
- else
- {
- floor_item_increase(0 - item, -1);
- floor_item_optimize(0 - item);
- }
-
- /* Sound */
- sound(SOUND_SHOOT);
-
- /* Hack -- Handle stuff */
- handle_stuff();
-
- /* Save the old location */
- prev_y = y;
- prev_x = x;
-
- /* The shot does not hit yet */
- hit_body = FALSE;
-
- /* Travel until stopped */
- for (cur_dis = 0; cur_dis <= tdis; )
- {
- cave_type *c_ptr;
-
- /* Hack -- Stop at the target */
- if ((y == ty) && (x == tx)) break;
-
- /* Calculate the new location (see "project()") */
- ny = y;
- nx = x;
- mmove2(&ny, &nx, py, px, ty, tx);
-
- /* Shatter Arrow */
- if (snipe_type == SP_KILL_WALL)
- {
- c_ptr = &cave[ny][nx];
-
- if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
- {
-#ifdef JP
- if (c_ptr->info & (CAVE_MARK)) msg_print("´ä¤¬ºÕ¤±»¶¤Ã¤¿¡£");
-#else
- if (c_ptr->info & (CAVE_MARK)) msg_print("Wall rocks were shattered.");
-#endif
- /* Forget the wall */
- c_ptr->info &= ~(CAVE_MARK);
-
- p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
-
- /* Destroy the wall */
- cave_alter_feat(ny, nx, FF_HURT_ROCK);
-
- hit_body = TRUE;
- break;
- }
- }
-
- /* Stopped by walls/doors */
- if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
-
- /* Advance the distance */
- cur_dis++;
-
- /* Sniper */
- if (snipe_type == SP_LITE)
- {
- cave[ny][nx].info |= (CAVE_GLOW);
-
- /* Notice */
- note_spot(ny, nx);
-
- /* Redraw */
- lite_spot(ny, nx);
- }
-
- /* The player can see the (on screen) missile */
- if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
- {
- char c = object_char(q_ptr);
- byte a = object_attr(q_ptr);
-
- /* Draw, Hilite, Fresh, Pause, Erase */
- print_rel(c, a, ny, nx);
- move_cursor_relative(ny, nx);
- Term_fresh();
- Term_xtra(TERM_XTRA_DELAY, msec);
- lite_spot(ny, nx);
- Term_fresh();
- }
-
- /* The player cannot see the missile */
- else
- {
- /* Pause anyway, for consistancy */
- Term_xtra(TERM_XTRA_DELAY, msec);
- }
-
- /* Sniper */
- if (snipe_type == SP_KILL_TRAP)
- {
- project(0, 0, ny, nx, 0, GF_KILL_TRAP,
- (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
- }
-
- /* Sniper */
- if (snipe_type == SP_EVILNESS)
- {
- cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
-
- /* Notice */
- note_spot(ny, nx);
-
- /* Redraw */
- lite_spot(ny, nx);
- }
-
- /* Save the old location */
- prev_y = y;
- prev_x = x;
-
- /* Save the new location */
- x = nx;
- y = ny;
-
-
- /* Monster here, Try to hit it */
- if (cave[y][x].m_idx)
- {
- int armour;
- cave_type *c_ptr = &cave[y][x];
-
- monster_type *m_ptr = &m_list[c_ptr->m_idx];
- monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
- /* Check the visibility */
- visible = m_ptr->ml;
-
- /* Note the collision */
- hit_body = TRUE;
-
- if (MON_CSLEEP(m_ptr))
- {
- if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
- if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
- }
-
- if ((r_ptr->level + 10) > p_ptr->lev)
- {
- int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
- if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
- {
- int amount = 0;
- if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
- else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
- else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
- else if (p_ptr->lev > 34) amount = 2;
- p_ptr->weapon_exp[0][j_ptr->sval] += amount;
- p_ptr->update |= (PU_BONUS);
- }
- }
-
- if (p_ptr->riding)
- {
- if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
- && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
- && one_in_(2))
- {
- p_ptr->skill_exp[GINOU_RIDING] += 1;
- p_ptr->update |= (PU_BONUS);
- }
- }
-
- /* Some shots have hit bonus */
- armour = r_ptr->ac;
- if (p_ptr->concent)
- {
- armour *= (10 - p_ptr->concent);
- armour /= 10;
- }
-
- /* Did we hit it (penalize range) */
- if (test_hit_fire(chance - cur_dis, armour, m_ptr->ml))
- {
- bool fear = FALSE;
- int tdam = tdam_base;
-
- /* Get extra damage from concentration */
- if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
-
- /* Handle unseen monster */
- if (!visible)
- {
- /* Invisible monster */
-#ifdef JP
- msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
-#else
- msg_format("The %s finds a mark.", o_name);
-#endif
-
- }
-
- /* Handle visible monster */
- else
- {
- char m_name[80];
-
- /* Get "the monster" or "it" */
- monster_desc(m_name, m_ptr, 0);
-
- /* Message */
-#ifdef JP
- msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
-#else
- msg_format("The %s hits %s.", o_name, m_name);
-#endif
-
- if (m_ptr->ml)
- {
- /* Hack -- Track this monster race */
- if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-
- /* Hack -- Track this monster */
- health_track(c_ptr->m_idx);
- }
- }
-
- if (snipe_type == SP_NEEDLE)
- {
- if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
- && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
- {
- char m_name[80];
-
- /* Get "the monster" or "it" */
- monster_desc(m_name, m_ptr, 0);
-
- tdam = m_ptr->hp + 1;
-#ifdef JP
- msg_format("%s¤ÎµÞ½ê¤ËÆͤ»É¤µ¤Ã¤¿¡ª", m_name);
-#else
- msg_format("Your shot sticked on a fatal spot of %s!", m_name);
-#endif
- }
- else tdam = 1;
- }
- else
- {
- /* Apply special damage XXX XXX XXX */
- tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
- tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
-
- /* No negative damage */
- if (tdam < 0) tdam = 0;
-
- /* Modify the damage */
- tdam = mon_damage_mod(m_ptr, tdam, FALSE);
- }
-
- /* Complex message */
- if (p_ptr->wizard || cheat_xtra)
- {
-#ifdef JP
- msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
- tdam, m_ptr->hp);
-#else
- msg_format("You do %d (out of %d) damage.",
- tdam, m_ptr->hp);
-#endif
-
- }
-
- /* Sniper */
- if (snipe_type == SP_EXPLODE)
- {
- u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
-
- sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
- project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
- break;
- }
-
- /* Sniper */
- if (snipe_type == SP_HOLYNESS)
- {
- cave[ny][nx].info |= (CAVE_GLOW);
-
- /* Notice */
- note_spot(ny, nx);
-
- /* Redraw */
- lite_spot(ny, nx);
- }
-
- /* Hit the monster, check for death */
- if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
- {
- /* Dead monster */
- }
-
- /* No death */
- else
- {
- /* STICK TO */
- if (object_is_fixed_artifact(q_ptr))
- {
- char m_name[80];
-
- monster_desc(m_name, m_ptr, 0);
-
- stick_to = TRUE;
-#ifdef JP
- msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
-#else
- msg_format("%^s have stuck into %s!",o_name, m_name);
-#endif
- }
-
- /* Message */
- message_pain(c_ptr->m_idx, tdam);
-
- /* Anger the monster */
- if (tdam > 0) anger_monster(m_ptr);
-
- /* Take note */
- if (fear && m_ptr->ml)
- {
- char m_name[80];
-
- /* Sound */
- sound(SOUND_FLEE);
-
- /* Get the monster name (or "it") */
- monster_desc(m_name, m_ptr, 0);
-
- /* Message */
-#ifdef JP
- msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
-#else
- msg_format("%^s flees in terror!", m_name);
-#endif
-
- }
-
- set_target(m_ptr, py, px);
-
- /* Sniper */
- if (snipe_type == SP_RUSH)
- {
- int n = randint1(5) + 3;
- int m_idx = c_ptr->m_idx;
-
- for ( ; cur_dis <= tdis; )
- {
- int ox = nx;
- int oy = ny;
-
- if (!n) break;
-
- /* Calculate the new location (see "project()") */
- mmove2(&ny, &nx, py, px, ty, tx);
-
- /* Stopped by wilderness boundary */
- if (!in_bounds2(ny, nx)) break;
-
- /* Stopped by walls/doors */
- if (!player_can_enter(cave[ny][nx].feat, 0)) break;
-
- /* Stopped by monsters */
- if (!cave_empty_bold(ny, nx)) break;
-
- cave[ny][nx].m_idx = m_idx;
- cave[oy][ox].m_idx = 0;
-
- m_ptr->fx = nx;
- m_ptr->fy = ny;
-
- /* Update the monster (new location) */
- update_mon(c_ptr->m_idx, TRUE);
-
- lite_spot(ny, nx);
- lite_spot(oy, ox);
-
- Term_fresh();
- Term_xtra(TERM_XTRA_DELAY, msec);
-
- x = nx;
- y = ny;
- cur_dis++;
- n--;
- }
- }
- }
- }
-
- /* Sniper */
- if (snipe_type == SP_PIERCE)
- {
- if(p_ptr->concent < 1) break;
- p_ptr->concent--;
- continue;