From e48766e842f0586ce575268ee7127f58d6d29f51 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Fri, 23 May 2008 15:15:10 +0000 Subject: Apply beam tracer prompt to helpless/fleeing etc. creatures when worshipping an appropriate god. I'm simply reusing dolorous unchivalric methods here. :) Also, don't prompt for harmless beams. Still TODO: Make the message differentiate between target and obstacles, and clean up the code a bit. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5193 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/beam.cc | 185 +++++++++++++++++++++++++++++----------- crawl-ref/source/beam.h | 7 -- crawl-ref/source/fight.cc | 6 +- crawl-ref/source/item_use.cc | 197 +++++++++++++++++++++++++------------------ crawl-ref/source/itemprop.cc | 3 +- crawl-ref/source/mon-util.cc | 2 +- crawl-ref/source/stuff.cc | 4 +- 7 files changed, 263 insertions(+), 141 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index cd12ea1dc0..18a2729039 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -82,7 +82,7 @@ static int opdir[] = { 2, 1, 4, 3 }; static FixedArray < bool, 19, 19 > explode_map; // helper functions (some of these should probably be public): -static void _sticky_flame_monster( int mn, kill_category who, int hurt_final ); +static void _sticky_flame_monster(int mn, kill_category who, int hurt_final); static bool _affects_wall(const bolt &beam, int wall_feature); static bool _isBouncy(bolt &beam, unsigned char gridtype); static int _beam_source(const bolt &beam); @@ -102,13 +102,16 @@ static void _explosion_map(bolt &beam, int x, int y, int count, int dir, int r); static void _explosion_cell(bolt &beam, int x, int y, bool drawOnly); -static void _ench_animation( int flavour, const monsters *mon = NULL, bool force = false); +static void _ench_animation(int flavour, const monsters *mon = NULL, + bool force = false); static void _zappy(zap_type z_type, int power, bolt &pbolt); static void _monster_die(monsters *mons, const bolt &beam); +static bool _nasty_beam(monsters *mon, bolt &beam); +static bool _nice_beam(monsters *mon, bolt &beam); static std::set beam_message_cache; -static bool _beam_is_blockable( bolt &pbolt ) +static bool _beam_is_blockable(bolt &pbolt) { // BEAM_ELECTRICITY is added here because chain lighting is not // a true beam (stops at the first target it gets to and redirects @@ -656,10 +659,17 @@ static void _get_max_range( zap_type z_type, int power, bolt &pbolt ) } } +// Returns true if the path is considered "safe", and false if there are +// monsters in the way the player doesn't want to hit. // FIXME: Also needs to check for fleeing monster with TSO and neutrals for // all good gods. bool player_tracer( zap_type ztype, int power, bolt &pbolt, int range) { + // Non-controlleable during confusion. + // (We'll shoot in a different direction anyway.) + if (you.duration[DUR_CONF]) + return (true); + _beam_set_default_values(pbolt, power); pbolt.name = "unimportant"; _get_max_range(ztype, power, pbolt); @@ -697,7 +707,6 @@ bool player_tracer( zap_type ztype, int power, bolt &pbolt, int range) // Set to non-tracing for actual firing. pbolt.is_tracer = false; return (true); - } dice_def calc_dice( int num_dice, int max_damage ) @@ -1737,7 +1746,7 @@ void fire_beam( bolt &pbolt, item_def *item, bool drop_item ) #ifdef USE_TILE int tile_beam = -1; - if (item) + if (item && !pbolt.is_tracer) { tile_beam = tileidx_item_throw(*item, pbolt.target_x-pbolt.source_x, @@ -4106,14 +4115,14 @@ static void _update_hurt_or_helped(bolt &beam, monsters *mon) { if (!mons_atts_aligned(beam.attitude, mons_attitude(mon))) { - if (nasty_beam(mon, beam)) + if (_nasty_beam(mon, beam)) beam.foe_hurt++; - else if (nice_beam(mon, beam)) + else if (_nice_beam(mon, beam)) beam.foe_helped++; } else { - if (nasty_beam(mon, beam)) + if (_nasty_beam(mon, beam)) { beam.fr_hurt++; @@ -4122,18 +4131,84 @@ static void _update_hurt_or_helped(bolt &beam, monsters *mon) if (midx == beam.beam_source) xom_is_stimulated(128); } - else if (nice_beam(mon, beam)) + else if (_nice_beam(mon, beam)) beam.fr_helped++; } } +static bool _beam_is_harmless(bolt &beam, monsters *mon) +{ + // For enchantments, this is already handled in _nasty_beam(). + if (beam.name[0] == '0') + return (!_nasty_beam(mon, beam)); + + // The others are handled here. + switch (beam.flavour) + { + case BEAM_DIGGING: + return (true); + + // Cleansing flame doesn't affect player's followers. + case BEAM_HOLY: + return (mons_is_holy(mon) + || is_good_god(you.religion) + && ( is_follower(mon) || mons_neutral(mon) )); + case BEAM_STEAM: + return (mons_res_steam(mon) >= 3); + case BEAM_FIRE: + return (mons_res_fire(mon) >= 3); + case BEAM_COLD: + return (mons_res_cold(mon) >= 3); + case BEAM_MIASMA: + case BEAM_NEG: + return (mons_res_negative_energy(mon) >= 3); + case BEAM_ELECTRICITY: + return (mons_res_elec(mon) >= 3); + case BEAM_POISON: + return (mons_res_poison(mon) >= 3); + case BEAM_ACID: + return (mons_res_acid(mon) >= 3); + default: + return (false); + } +} + +static bool _stop_unchivalric_attack(monsters *mon) +{ + const bool wontAttack = mons_wont_attack(mon); + const bool isFriendly = mons_friendly(mon); + const bool isNeutral = mons_neutral(mon); + const bool isUnchivalric = is_unchivalric_attack(&you, mon, mon); + const bool isHoly = mons_is_holy(mon); + + if (wontAttack + || is_good_god(you.religion) && (isNeutral || isHoly) + || you.religion == GOD_SHINING_ONE && isUnchivalric) + { + snprintf(info, INFO_SIZE, "Really fire through this " + "%s%s%screature?", + (isUnchivalric) ? "helpless " + : "", + (isFriendly) ? "friendly " : + (wontAttack) ? "non-hostile " : + (isNeutral) ? "neutral " + : "", + (isHoly) ? "holy " + : ""); + + if (!yesno(info, true, 'n')) + return (true); + } + return (false); +} + // return amount of range used up by affectation of this monster static int _affect_monster(bolt &beam, monsters *mon, item_def *item) { const int tid = mgrd[mon->x][mon->y]; - const int mons_type = menv[tid].type; - const int thrower = YOU_KILL(beam.thrower)? KILL_YOU_MISSILE - : KILL_MON_MISSILE; + const int mons_type = menv[tid].type; + const int thrower = YOU_KILL(beam.thrower) ? KILL_YOU_MISSILE + : KILL_MON_MISSILE; const bool submerged = mon->submerged(); int hurt; @@ -4153,8 +4228,9 @@ static int _affect_monster(bolt &beam, monsters *mon, item_def *item) // check for tracer if (beam.is_tracer) { - // check can see other monster - if (!beam.can_see_invis && menv[tid].invisible()) + // Can we see this monster? + if (!beam.can_see_invis && menv[tid].invisible() + || thrower == KILL_YOU_MISSILE && !see_grid(mon->x, mon->y)) { // Can't see this monster, ignore it. return 0; @@ -4186,14 +4262,22 @@ static int _affect_monster(bolt &beam, monsters *mon, item_def *item) } bool hit_woke_orc = false; - if (beam.name[0] == '0') + if (beam.name[0] == '0') // enchantments { if (beam.is_tracer) { // Enchant case -- enchantments always hit, so update target immed. if (!mons_atts_aligned(beam.attitude, mons_attitude(mon))) { - if (beam.thrower != KILL_YOU_MISSILE) + if (beam.thrower == KILL_YOU_MISSILE) + { + if (_stop_unchivalric_attack(mon)) + { + beam.fr_count = 1; + return (BEAM_STOP); + } + } + else { beam.foe_count += 1; beam.foe_power += mons_power(mons_type); @@ -4201,21 +4285,22 @@ static int _affect_monster(bolt &beam, monsters *mon, item_def *item) } else { - bool count_friend = true; if (beam.thrower == KILL_YOU_MISSILE) { - snprintf(info, INFO_SIZE, "Really fire through %s?", - mon->name(DESC_NOCAP_THE).c_str()); - - if (!yesno(info)) + if (!_beam_is_harmless(beam, mon)) { - beam.fr_count = 1; - return (BEAM_STOP); + snprintf(info, INFO_SIZE, "Really fire through %s?", + mon->name(DESC_NOCAP_THE).c_str()); + + if (!yesno(info, true, 'n')) + { + beam.fr_count = 1; + return (BEAM_STOP); + } } - else - count_friend = false; + // Don't count friends we don't want counted. } - if (count_friend) + else { beam.fr_count += 1; beam.fr_power += mons_power(mons_type); @@ -4236,7 +4321,7 @@ static int _affect_monster(bolt &beam, monsters *mon, item_def *item) // Nasty enchantments will annoy the monster, and are considered // naughty (even if a monster might resist). - if (nasty_beam(mon, beam)) + if (_nasty_beam(mon, beam)) { if (YOU_KILL(beam.thrower)) { @@ -4329,7 +4414,7 @@ static int _affect_monster(bolt &beam, monsters *mon, item_def *item) // Can't hurt submerged water creatures with electricity. if (beam.flavour == BEAM_ELECTRICITY) { - if (see_grid(mon->x, mon->y)) + if (see_grid(mon->x, mon->y) && !beam.is_tracer) { mprf("The %s arcs harmlessly into the water.", beam.name.c_str()); @@ -4386,7 +4471,15 @@ static int _affect_monster(bolt &beam, monsters *mon, item_def *item) // foe_power or fr_power. if (!mons_atts_aligned(beam.attitude, mons_attitude(mon))) { - if (beam.thrower != KILL_YOU_MISSILE) + if (beam.thrower == KILL_YOU_MISSILE) + { + if (_stop_unchivalric_attack(mon)) + { + beam.fr_count = 1; + return (BEAM_STOP); + } + } + else { // Counting foes is only important for monster tracers. beam.foe_count += 1; @@ -4396,24 +4489,22 @@ static int _affect_monster(bolt &beam, monsters *mon, item_def *item) } else { - bool count_friend = true; if (beam.thrower == KILL_YOU_MISSILE) { - snprintf(info, INFO_SIZE, "Really fire through %s?", - mon->name(DESC_NOCAP_THE).c_str()); - - if (!yesno(info)) + if (!_beam_is_harmless(beam, mon)) { - beam.fr_count = 1; - return (BEAM_STOP); - } - else - { - // Don't count friends we don't want counted. - count_friend = false; + snprintf(info, INFO_SIZE, "Really fire through %s?", + mon->name(DESC_NOCAP_THE).c_str()); + + if (!yesno(info, true, 'n')) + { + beam.fr_count = 1; + return (BEAM_STOP); + } } + // Don't count friends we don't want counted. } - if (count_friend) + else { beam.fr_count += 1; beam.fr_power += 2 * hurt_final * mons_power(mons_type) @@ -4438,7 +4529,7 @@ static int _affect_monster(bolt &beam, monsters *mon, item_def *item) god_conduct_trigger conduct; conduct.enabled = false; - if (nasty_beam(mon, beam)) + if (_nasty_beam(mon, beam)) { if (YOU_KILL(beam.thrower) && hurt_final > 0) { @@ -4692,7 +4783,7 @@ static int _affect_monster_enchantment(bolt &beam, monsters *mon) return (MON_UNAFFECTED); if (check_mons_resist_magic( mon, beam.ench_power )) - return mons_immune_magic(mon) ? MON_UNAFFECTED : MON_RESIST; + return (mons_immune_magic(mon) ? MON_UNAFFECTED : MON_RESIST); if (mon->mutate()) beam.obvious_effect = true; @@ -4902,7 +4993,7 @@ static int _affect_monster_enchantment(bolt &beam, monsters *mon) } // everything else? - if ( !death_check ) + if (!death_check) return (mons_ench_f2(mon, beam)); if (mon->hit_points < 1) @@ -5416,7 +5507,7 @@ static void _explosion_map( bolt &beam, int x, int y, // Only enchantments should need the actual monster type // to determine this; non-enchantments are pretty // straightforward. -bool nasty_beam(monsters *mon, bolt &beam) +static bool _nasty_beam(monsters *mon, bolt &beam) { // take care of non-enchantments if (beam.name[0] != '0') @@ -5454,7 +5545,7 @@ bool nasty_beam(monsters *mon, bolt &beam) return (true); } -bool nice_beam( monsters *mon, bolt &beam ) +static bool _nice_beam(monsters *mon, bolt &beam) { // haste/healing/invisibility if (beam.flavour == BEAM_HASTE || beam.flavour == BEAM_HEALING diff --git a/crawl-ref/source/beam.h b/crawl-ref/source/beam.h index 02fa3c106c..315b37f427 100644 --- a/crawl-ref/source/beam.h +++ b/crawl-ref/source/beam.h @@ -178,13 +178,6 @@ bool test_beam_hit(int attack, int defence); * *********************************************************************** */ void fire_beam( bolt &pbolt, item_def *item = NULL, bool drop_item = false ); -// last updated 19apr2001 {gdl} -/* *********************************************************************** - * called from: beam - * *********************************************************************** */ -bool nasty_beam( monsters *mon, struct bolt &beam ); -bool nice_beam( monsters *mon, struct bolt &beam ); - // last updated 12may2000 {dlb} /* *********************************************************************** * called from: ability - it_use3 - item_use - mstuff2 - religion - diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 84853eb97c..02b9016458 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -1909,7 +1909,7 @@ static inline int get_resistible_fraction(beam_type flavour) // (does handle monster acid damage), miasma, and other exotic // attacks. // -// beam_type is just use to determine the damage flavour, it does not +// beam_type is just used to determine the damage flavour, it does not // necessarily imply that the attack is a beam attack. int resist_adjust_damage(actor *defender, beam_type flavour, int res, int rawdamage, bool ranged) @@ -1917,12 +1917,12 @@ int resist_adjust_damage(actor *defender, beam_type flavour, if (!res) return (rawdamage); - const bool monster = defender->atype() == ACT_MONSTER; + const bool monster = (defender->atype() == ACT_MONSTER); // Check if this is a resist that pretends to be boolean for // damage purposes - only electricity at the moment, raw poison // damage uses the normal formula. - int res_base = is_boolean_resist(flavour)? 2 : 1; + int res_base = (is_boolean_resist(flavour) ? 2 : 1); const int resistible_fraction = get_resistible_fraction(flavour); int resistible = rawdamage * resistible_fraction / 100; diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 737fefe839..727a572ca9 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -1763,27 +1763,110 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, } } } + pbolt.set_target(thr); + + // Making a copy of the item: changed only for venom launchers + item_def item = you.inv[throw_2]; + item.quantity = 1; + item.slot = index_to_letter(item.link); + + // Get the ammo/weapon type. Convenience. + const object_class_type wepClass = item.base_type; + const int wepType = item.sub_type; + + // figure out if we're thrown or launched + const launch_retval projected = is_launched(&you, you.weapon(), item); + + pbolt.name = item.name(DESC_PLAIN, false, false, false); + pbolt.thrower = KILL_YOU_MISSILE; + pbolt.source_x = you.x_pos; + pbolt.source_y = you.y_pos; + pbolt.colour = item.colour; + pbolt.flavour = BEAM_MISSILE; + pbolt.aux_source.clear(); + // pbolt.range is set below + + if (projected) + { + if (wepType == MI_LARGE_ROCK) + { + pbolt.range = 1 + random2( you.strength / 5 ); + pbolt.rangeMax = you.strength / 5; + if (you.can_throw_rocks()) + { + pbolt.range += random_range(4, 7); + pbolt.rangeMax += 7; + } + if (pbolt.rangeMax > 12) + { + pbolt.rangeMax = 12; + if (pbolt.range > 12) + pbolt.range = 12; + } + } + else if (wepType == MI_THROWING_NET) + { + pbolt.rangeMax = pbolt.range = 2 + player_size(PSIZE_BODY); + } + else + { + pbolt.rangeMax = pbolt.range = 12; + } + } + else + { + // Range based on mass & strength, between 1 and 9. + pbolt.range = you.strength - item_mass(item) / 10 + 3; + if (pbolt.range < 1) + pbolt.range = 1; + + if (pbolt.range > 9) + pbolt.range = 9; + + pbolt.rangeMax = pbolt.range; + } + + pbolt.is_beam = false; + pbolt.beam_source = 0; + pbolt.can_see_invis = player_see_invis(); + pbolt.smart_monster = true; + pbolt.attitude = ATT_FRIENDLY; + pbolt.is_tracer = true; + + // init tracer variables + pbolt.foe_count = pbolt.fr_count = 0; + pbolt.foe_power = pbolt.fr_power = 0; + pbolt.fr_helped = pbolt.fr_hurt = 0; + pbolt.foe_helped = pbolt.foe_hurt = 0; + pbolt.foe_ratio = 100; + + // Don't do the tracing when confused. + if (!you.duration[DUR_CONF]) + fire_beam(pbolt); + + // Should only happen if the player answered 'n' to one of those + // "Fire through friendly?" prompts. + if (pbolt.fr_count > 0) + { + canned_msg(MSG_OK); + you.turn_is_over = false; + return (false); + } + + // Now start real firing! + origin_set_unknown(item); // Must unwield before fire_beam() makes a copy in order to remove things // like temporary branding. -- bwr if (throw_2 == you.equip[EQ_WEAPON] && you.inv[throw_2].quantity == 1) { unwield_item(); - canned_msg( MSG_EMPTY_HANDED ); + canned_msg(MSG_EMPTY_HANDED); } - // Making a copy of the item: changed only for venom launchers - item_def item = you.inv[throw_2]; - item.quantity = 1; - item.slot = index_to_letter(item.link); - origin_set_unknown(item); - - if (item.base_type == OBJ_POTIONS - && (item.sub_type == POT_BLOOD - || item.sub_type == POT_BLOOD_COAGULATED) - && you.inv[throw_2].quantity > 1) + if (is_blood_potion(item) && you.inv[throw_2].quantity > 1) { - // initialize thrown potion with oldest potion in stack + // Initialize thrown potion with oldest potion in stack. long val = remove_oldest_blood_potion(you.inv[throw_2]); val -= you.num_turns; item.props.clear(); @@ -1802,9 +1885,6 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, if (!teleport) pbolt.set_target(thr); - pbolt.flavour = BEAM_MISSILE; - // pbolt.range is set below - dungeon_char_type zapsym = DCHAR_SPACE; switch (item.base_type) { @@ -1825,23 +1905,11 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, pbolt.type = dchar_glyph(zapsym); - pbolt.source_x = you.x_pos; - pbolt.source_y = you.y_pos; - pbolt.colour = item.colour; - - pbolt.name = item.name(DESC_PLAIN, false, false, false); - - pbolt.thrower = KILL_YOU_MISSILE; - pbolt.aux_source.clear(); - - // get the ammo/weapon type. Convenience. - const object_class_type wepClass = item.base_type; - const int wepType = item.sub_type; - - // get the launcher class,type. Convenience. + // Get the launcher class,type. Convenience. if (you.equip[EQ_WEAPON] < 0) lnchType = NUM_WEAPONS; - else { + else + { lnchType = static_cast( you.inv[you.equip[EQ_WEAPON]].sub_type ); } @@ -1862,17 +1930,14 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, baseDam = 0; } - // figure out if we're thrown or launched - const launch_retval projected = is_launched(&you, you.weapon(), item); - - // extract launcher bonuses due to magic + // Extract launcher bonuses due to magic. if (projected == LRET_LAUNCHED) { lnchHitBonus = you.inv[you.equip[EQ_WEAPON]].plus; lnchDamBonus = you.inv[you.equip[EQ_WEAPON]].plus2; } - // extract weapon/ammo bonuses due to magic + // Extract weapon/ammo bonuses due to magic. ammoHitBonus = item.plus; ammoDamBonus = item.plus2; @@ -1892,7 +1957,7 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, baseHit = property( launcher, PWPN_HIT ); baseDam = lnch_base_dam + random2(1 + item_base_dam); - // Slings are terribly weakened otherwise + // Slings are terribly weakened otherwise. if (lnch_base_dam == 0) baseDam = item_base_dam; @@ -1903,7 +1968,7 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, baseDam = 4; // [dshaligram] This is a horrible hack - we force beam.cc to consider - // this beam "needle-like". + // this beam "needle-like". (XXX) if (wepClass == OBJ_MISSILES && wepType == MI_NEEDLE) pbolt.ench_power = AUTOMATIC_HIT; @@ -1915,10 +1980,10 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, item_base_dam, lnch_base_dam); #endif - // fix ammo damage bonus, since missiles only use inv_plus + // Fix ammo damage bonus, since missiles only use inv_plus. ammoDamBonus = ammoHitBonus; - // check for matches; dwarven, elven, orcish + // Check for matches; dwarven, elven, orcish. if (!get_equip_race(you.inv[you.equip[EQ_WEAPON]]) == 0) { if (get_equip_race( you.inv[you.equip[EQ_WEAPON]] ) @@ -2018,8 +2083,8 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, lnchDamBonus = 0; break; } - // Blowguns take a _very_ steady hand; a lot of the bonus - // comes from dexterity. (Dex bonus here as well as below). + // Blowguns take a _very_ steady hand; a lot of the bonus + // comes from dexterity. (Dex bonus here as well as below). case SK_DARTS: baseHit -= 2; exercise(SK_DARTS, (coinflip()? 2 : 1)); @@ -2125,8 +2190,8 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, pbolt.name += "poison "; pbolt.name += "flame"; - pbolt.colour = RED; - pbolt.type = dchar_glyph(DCHAR_FIRED_BOLT); + pbolt.colour = RED; + pbolt.type = dchar_glyph(DCHAR_FIRED_BOLT); pbolt.thrower = KILL_YOU_MISSILE; pbolt.aux_source.clear(); } @@ -2144,8 +2209,8 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, pbolt.name += "poison "; pbolt.name += "frost"; - pbolt.colour = WHITE; - pbolt.type = dchar_glyph(DCHAR_FIRED_BOLT); + pbolt.colour = WHITE; + pbolt.type = dchar_glyph(DCHAR_FIRED_BOLT); pbolt.thrower = KILL_YOU_MISSILE; pbolt.aux_source.clear(); } @@ -2187,8 +2252,8 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, // CALCULATIONS FOR THROWN WEAPONS if (projected == LRET_THROWN) { - returning = ((get_weapon_brand(item) == SPWPN_RETURNING || - get_ammo_brand(item) == SPMSL_RETURNING) && !teleport); + returning = (!teleport && (get_weapon_brand(item) == SPWPN_RETURNING + || get_ammo_brand(item) == SPMSL_RETURNING)); if (returning && !one_chance_in(1 + skill_bump(SK_THROWING))) did_return = true; @@ -2345,36 +2410,19 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, } } - // Range, dexterity bonus, possible skill increase for silly throwing. + // Dexterity bonus, and possible skill increase for silly throwing. if (projected) { - if (wepType == MI_LARGE_ROCK) - { - pbolt.range = 1 + random2( you.strength / 5 ); - if (you.can_throw_rocks()) - pbolt.range += random_range(4, 7); - if (pbolt.range > 12) - pbolt.range = 12; - - pbolt.rangeMax = pbolt.range; - } - else if (wepType == MI_THROWING_NET) - { - pbolt.rangeMax = pbolt.range = 2 + player_size(PSIZE_BODY); - } - else + if (wepType != MI_LARGE_ROCK && wepType != MI_THROWING_NET) { - pbolt.range = 12; - pbolt.rangeMax = 12; - exHitBonus += you.dex / 2; // slaying bonuses if (projected != LRET_LAUNCHED || wepType != MI_NEEDLE) { slayDam = slaying_bonus(PWPN_DAMAGE); - slayDam = slayDam < 0? -random2(1 - slayDam) - : random2(1 + slayDam); + slayDam = (slayDam < 0 ? -random2(1 - slayDam) + : random2(1 + slayDam)); } exHitBonus += slaying_bonus(PWPN_HIT); @@ -2382,17 +2430,6 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, } else { - // range based on mass & strength, between 1 and 9 - pbolt.range = you.strength - item_mass(item) / 10 + 3; - if (pbolt.range < 1) - pbolt.range = 1; - - if (pbolt.range > 9) - pbolt.range = 9; - - // set max range equal to range for this - pbolt.rangeMax = pbolt.range; - if (one_chance_in(20)) exercise(SK_THROWING, 1); @@ -2454,7 +2491,7 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, item.name(DESC_NOCAP_A).c_str() ); // Ensure we're firing a 'missile'-type beam. - pbolt.is_beam = false; + pbolt.is_beam = false; pbolt.is_tracer = false; // Mark this item as thrown if it's a missile, so that we'll pick it up diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index eb37710c5c..ad4c07ee98 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -602,7 +602,7 @@ unsigned long full_ident_mask( const item_def& item ) flagset = 0; break; case OBJ_MISCELLANY: - if ( item.sub_type == MISC_RUNE_OF_ZOT ) + if (item.sub_type == MISC_RUNE_OF_ZOT) flagset = 0; else flagset = ISFLAG_KNOW_TYPE; @@ -629,6 +629,7 @@ unsigned long full_ident_mask( const item_def& item ) break; case OBJ_WEAPONS: case OBJ_ARMOUR: + // all flags necessary for full identification default: break; } diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 4f65770fa1..ab2292ba6e 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -784,7 +784,7 @@ bool mons_immune_magic(const monsters *mon) int mons_resist_magic( const monsters *mon ) { - if ( mons_immune_magic(mon) ) + if (mons_immune_magic(mon)) return MAG_IMMUNE; int u = (get_monster_data(mon->type))->resist_magic; diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index 51cd1685c9..128a19de34 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -909,7 +909,7 @@ bool yesno( const char *str, bool safe, int safeanswer, bool clear_after, while (true) { - if ( !noprompt ) + if (!noprompt) mpr(prompt.c_str(), MSGCH_PROMPT); int tmp = getchm(KC_CONFIRM); @@ -925,7 +925,7 @@ bool yesno( const char *str, bool safe, int safeanswer, bool clear_after, if (Options.easy_confirm == CONFIRM_ALL_EASY || tmp == safeanswer - || (Options.easy_confirm == CONFIRM_SAFE_EASY && safe)) + || Options.easy_confirm == CONFIRM_SAFE_EASY && safe) { tmp = toupper( tmp ); } -- cgit v1.2.3-54-g00ecf