From 17652535bdeaf8d56ee88ed9296708ff6efd8a31 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Mon, 21 Jul 2008 18:22:37 +0000 Subject: Add immunity checks for prompts about beams potentially hitting yourself (not counting self-targetting since what we're trying to avoid in that case is loss of magic as well as self-damage) and add some special cases for Evaporate, so the potions use appropriate resistances without leaking information on the random choices. Let Enhancers start with Short Blades skill 1. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6627 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/beam.cc | 141 +++++++++++++++++++++++++++++--------------- crawl-ref/source/enum.h | 22 +++---- crawl-ref/source/newgame.cc | 1 + crawl-ref/source/player.cc | 10 ++-- crawl-ref/source/spells1.cc | 5 +- crawl-ref/source/spells4.cc | 27 +++++++-- 6 files changed, 136 insertions(+), 70 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 681971bd5f..4513b0b511 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -3629,6 +3629,99 @@ static std::string _beam_zapper(const bolt &beam) return menv[beam_src].name(DESC_PLAIN); } +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 _beam_is_harmless_player(bolt &beam) +{ +#ifdef DEBUG_DIAGNOSTICS + mprf(MSGCH_DIAGNOSTICS, "beam flavour: %d", beam.flavour); +#endif + + // Shouldn't happen anyway since enchantments are either aimed at self + // (not prompted) or cast at monsters and don't explode or bounce. + if (beam.name[0] == '0') + return (false); + + // 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 (is_good_god(you.religion)); + + case BEAM_STEAM: + return (player_res_steam(false) >= 3); + + case BEAM_MIASMA: + case BEAM_NEG: + return (player_prot_life(false) >= 3); + + case BEAM_POISON: + return (player_res_poison(false)); + + case BEAM_POTION_STINKING_CLOUD: + return (player_res_poison(false) || player_mental_clarity(false)); + + case BEAM_ELECTRICITY: + return (player_res_electricity(false)); + + case BEAM_FIRE: + case BEAM_COLD: + case BEAM_ACID: + // Fire and ice can destroy inventory items, acid damage equipment. + return (false); + + default: + return (false); + } +} + // Returns amount of extra range used up by affectation of the player. static int _affect_player( bolt &beam, item_def *item ) { @@ -3643,7 +3736,8 @@ static int _affect_player( bolt &beam, item_def *item ) if (YOU_KILL(beam.thrower)) { // Don't ask if we're aiming at ourselves. - if (!beam.aimed_at_feet && !beam.dont_stop_player) + if (!beam.aimed_at_feet && !beam.dont_stop_player + && !_beam_is_harmless_player(beam)) { if (yesno("That beam is likely to hit yourself. Continue " "anyway?", false, 'n')) @@ -4259,51 +4353,6 @@ static void _update_hurt_or_helped(bolt &beam, monsters *mon) } } -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); - } -} - // Returns amount of range used up by affectation of this monster. static int _affect_monster(bolt &beam, monsters *mon, item_def *item) { diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index a64e47be70..40049ec070 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -203,62 +203,62 @@ enum beam_type // beam[].flavour BEAM_MMISSILE, // and similarly irresistible things BEAM_FIRE, BEAM_COLD, - BEAM_MAGIC, + BEAM_MAGIC, // 5 BEAM_ELECTRICITY, BEAM_POISON, BEAM_NEG, BEAM_ACID, - BEAM_MIASMA, + BEAM_MIASMA, // 10 BEAM_SPORE, BEAM_POISON_ARROW, BEAM_HELLFIRE, BEAM_NAPALM, - BEAM_STEAM, + BEAM_STEAM, // 15 BEAM_HELLFROST, BEAM_ENERGY, BEAM_HOLY, // aka beam of cleansing, golden flame BEAM_FRAG, - BEAM_LAVA, + BEAM_LAVA, // 20 BEAM_BACKLIGHT, BEAM_SLEEP, BEAM_ICE, BEAM_NUKE, - BEAM_RANDOM, // currently translates into FIRE..ACID + BEAM_RANDOM, // 25 - currently translates into FIRE..ACID // These used to be handled in the colour field: BEAM_SLOW, // BLACK BEAM_HASTE, // BLUE BEAM_HEALING, // GREEN BEAM_PARALYSIS, // CYAN - BEAM_CONFUSION, // RED + BEAM_CONFUSION, // RED - 30 BEAM_INVISIBILITY, // MAGENTA BEAM_DIGGING, // BROWN BEAM_TELEPORT, // LIGHTGREY BEAM_POLYMORPH, // DARKGREY - BEAM_CHARM, // LIGHTBLUE + BEAM_CHARM, // LIGHTBLUE - 35 BEAM_BANISH, // LIGHTGREEN BEAM_DEGENERATE, // LIGHTCYAN BEAM_ENSLAVE_UNDEAD, // LIGHTRED BEAM_PAIN, // LIGHTMAGENTA - BEAM_DISPEL_UNDEAD, // YELLOW + BEAM_DISPEL_UNDEAD, // YELLOW - 40 BEAM_DISINTEGRATION, // WHITE BEAM_ENSLAVE_DEMON, // colour "16" BEAM_BLINK, BEAM_PETRIFY, // new beams for evaporate - BEAM_POTION_STINKING_CLOUD, + BEAM_POTION_STINKING_CLOUD, // 45 BEAM_POTION_POISON, BEAM_POTION_MIASMA, BEAM_POTION_STEAM, BEAM_POTION_FIRE, - BEAM_POTION_COLD, + BEAM_POTION_COLD, // 50 BEAM_POTION_BLACK_SMOKE, BEAM_POTION_GREY_SMOKE, BEAM_POTION_BLUE_SMOKE, BEAM_POTION_PURP_SMOKE, - BEAM_POTION_RANDOM, + BEAM_POTION_RANDOM, // 55 BEAM_LINE_OF_SIGHT // only used for checking monster LOS }; diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index e3bca59230..91586103f1 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -5021,6 +5021,7 @@ bool _give_items_skills() else you.skills[SK_DARTS] = 1; + you.skills[SK_SHORT_BLADES] = 1; you.skills[SK_ENCHANTMENTS] = 4; you.skills[SK_SPELLCASTING] = 1; you.skills[SK_DODGING] = 2; diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 550bbf5851..d8a70c7848 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -1535,12 +1535,12 @@ int player_res_poison(bool calc_unid, bool temp, bool items) // mutations: rp += player_mutation_level(MUT_POISON_RESISTANCE); + // Only thirsty vampires are naturally poison resistant. + if (you.species == SP_VAMPIRE && you.hunger_state < HS_SATIATED) + rp++; + if (temp) { - // Only thirsty vampires are naturally poison resistant. - if (you.species == SP_VAMPIRE && you.hunger_state < HS_SATIATED) - rp++; - // spells: if (you.duration[DUR_RESIST_POISON] > 0) rp++; @@ -4201,7 +4201,7 @@ int player_mental_clarity(bool calc_unid, bool items) { const int ret = (3 * player_equip(EQ_AMULET, AMU_CLARITY, calc_unid) * items) - + player_mutation_level(MUT_CLARITY); + + player_mutation_level(MUT_CLARITY); return ((ret > 3) ? 3 : ret); } diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index e544ecfb7c..5f9b8a3f4c 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -571,7 +571,6 @@ bool stinking_cloud( int pow, bolt &beem ) beem.damage = dice_def( 1, 0 ); beem.hit = 20; beem.type = dchar_glyph(DCHAR_FIRED_ZAP); - beem.flavour = BEAM_MMISSILE; beem.ench_power = pow; beem.beam_source = MHITYOU; beem.thrower = KILL_YOU; @@ -588,10 +587,11 @@ bool stinking_cloud( int pow, bolt &beem ) beem.smart_monster = true; beem.attitude = ATT_FRIENDLY; beem.fr_count = 0; + beem.flavour = BEAM_POTION_STINKING_CLOUD; beem.is_tracer = true; fire_beam(beem); - if (beem.fr_count > 0) + if (beem.beam_cancelled) { // We don't want to fire through friendlies. canned_msg(MSG_OK); @@ -600,6 +600,7 @@ bool stinking_cloud( int pow, bolt &beem ) } // Really fire. + beem.flavour = BEAM_MMISSILE; beem.is_tracer = false; fire_beam(beem); diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index b93f977425..ae095ebe9a 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -1336,26 +1336,31 @@ bool cast_evaporate(int pow, bolt& beem, int potion) beem.ench_power = pow; // used for duration only? beem.flavour = BEAM_POTION_STINKING_CLOUD; + beam_type tracer_flavour = BEAM_MMISSILE; switch (you.inv[potion].sub_type) { case POT_STRONG_POISON: - beem.flavour = BEAM_POTION_POISON; + beem.flavour = BEAM_POTION_POISON; + tracer_flavour = BEAM_POISON; beem.ench_power *= 2; break; case POT_DEGENERATION: beem.effect_known = false; - beem.flavour = (coinflip() ? BEAM_POTION_POISON : BEAM_POTION_MIASMA); + beem.flavour = (coinflip() ? BEAM_POTION_POISON : BEAM_POTION_MIASMA); + tracer_flavour = BEAM_MIASMA; beem.ench_power *= 2; break; case POT_POISON: - beem.flavour = BEAM_POTION_POISON; + beem.flavour = BEAM_POTION_POISON; + tracer_flavour = BEAM_POISON; break; case POT_DECAY: - beem.flavour = BEAM_POTION_MIASMA; + beem.flavour = BEAM_POTION_MIASMA; + tracer_flavour = BEAM_MIASMA; beem.ench_power *= 2; break; @@ -1364,12 +1369,12 @@ bool cast_evaporate(int pow, bolt& beem, int potion) // fall through case POT_CONFUSION: case POT_SLOWING: - beem.flavour = BEAM_POTION_STINKING_CLOUD; + tracer_flavour = beem.flavour = BEAM_POTION_STINKING_CLOUD; break; case POT_WATER: case POT_PORRIDGE: - beem.flavour = BEAM_POTION_STEAM; + tracer_flavour = beem.flavour = BEAM_STEAM; break; case POT_BLOOD: @@ -1380,6 +1385,10 @@ bool cast_evaporate(int pow, bolt& beem, int potion) case POT_BERSERK_RAGE: beem.effect_known = false; beem.flavour = (coinflip() ? BEAM_POTION_FIRE : BEAM_POTION_STEAM); + if (you.inv[potion].sub_type == POT_BERSERK_RAGE) + tracer_flavour = BEAM_FIRE; + else + tracer_flavour = BEAM_RANDOM; break; case POT_MUTATION: @@ -1397,6 +1406,7 @@ bool cast_evaporate(int pow, bolt& beem, int potion) case 3: beem.flavour = BEAM_POTION_MIASMA; break; default: beem.flavour = BEAM_POTION_RANDOM; break; } + tracer_flavour = BEAM_RANDOM; break; default: @@ -1413,6 +1423,7 @@ bool cast_evaporate(int pow, bolt& beem, int potion) case 7: beem.flavour = BEAM_POTION_PURP_SMOKE; break; default: beem.flavour = BEAM_POTION_STEAM; break; } + tracer_flavour = BEAM_RANDOM; break; } @@ -1425,6 +1436,9 @@ bool cast_evaporate(int pow, bolt& beem, int potion) beem.fr_count = 0; beem.beam_cancelled = false; beem.is_tracer = true; + + beam_type real_flavour = beem.flavour; + beem.flavour = tracer_flavour; fire_beam(beem); if (beem.beam_cancelled) @@ -1438,6 +1452,7 @@ bool cast_evaporate(int pow, bolt& beem, int potion) exercise( SK_THROWING, 1 ); // Really fire. + beem.flavour = real_flavour; beem.is_tracer = false; fire_beam(beem); -- cgit v1.2.3-54-g00ecf