From ed15698b38cd638552f6a0a12e0ddceef57c9e07 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Sun, 15 Jul 2007 14:12:39 +0000 Subject: Corona overrides invisibility. To check if something is *really* invisible, use foo.invisible(), not foo.has_ench(ENCH_INVIS) or foo.duration[DUR_INVIS]. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1874 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/beam.cc | 24 +++++++++++++++++------- crawl-ref/source/externs.h | 2 +- crawl-ref/source/fight.cc | 2 +- crawl-ref/source/it_use2.cc | 3 +++ crawl-ref/source/mon-util.cc | 19 +++++++++++++------ crawl-ref/source/monspeak.cc | 2 +- crawl-ref/source/monstuff.cc | 5 ++--- crawl-ref/source/output.cc | 4 ---- crawl-ref/source/player.cc | 6 +++--- crawl-ref/source/skills2.cc | 2 +- crawl-ref/source/spells2.cc | 3 +++ crawl-ref/source/spells4.cc | 25 +++++++++++++++---------- crawl-ref/source/view.cc | 4 ++++ 13 files changed, 64 insertions(+), 37 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 78725baf45..38985e7100 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -2001,14 +2001,17 @@ int mons_ench_f2(monsters *monster, bolt &pbolt) if (!monster->has_ench(ENCH_INVIS) && monster->add_ench(ENCH_INVIS)) { + // A casting of invisibility erases backlight. + monster->del_ench(ENCH_BACKLIGHT); + // Can't use simple_monster_message here, since it checks // for visibility of the monster (and its now invisible) -- bwr if (mons_near( monster )) { mprf("%s flickers %s", monster_name.c_str(), - player_see_invis() ? "for a moment." - : "and vanishes!" ); + player_monster_visible(monster) ? "for a moment." + : "and vanishes!" ); } pbolt.obvious_effect = true; @@ -2421,8 +2424,8 @@ void beam_drop_object( bolt &beam, item_def *item, int x, int y ) // for monsters without see invis firing tracers at the player. static bool found_player(const bolt &beam, int x, int y) { - const bool needs_fuzz = beam.is_tracer && !beam.can_see_invis - && you.duration[DUR_INVIS]; + const bool needs_fuzz = + beam.is_tracer && !beam.can_see_invis && you.invisible(); const int dist = needs_fuzz? 2 : 0; return (grid_distance(x, y, you.x_pos, you.y_pos) <= dist); @@ -2994,7 +2997,7 @@ static int affect_player( bolt &beam ) if (beam.is_tracer) { // check can see player - if (beam.can_see_invis || !you.duration[DUR_INVIS] + if (beam.can_see_invis || !you.invisible() || fuzz_invis_tracer(beam)) { if (beam.is_friendly) @@ -3018,7 +3021,7 @@ static int affect_player( bolt &beam ) int beamHit = beam.hit; // Monsters shooting at an invisible player are very inaccurate. - if (you.duration[DUR_INVIS] && !beam.can_see_invis) + if (you.invisible() && !beam.can_see_invis) beamHit /= 2; if (beam.name[0] != '0') @@ -3132,6 +3135,13 @@ static int affect_player( bolt &beam ) beam.obvious_effect = true; } + else + { + mpr("You feel strangely conspicuous."); + if ((you.duration[DUR_BACKLIGHT] += random_range(3, 5)) > 250) + you.duration[DUR_BACKLIGHT] = 250; + beam.obvious_effect = true; + } break; case BEAM_POLYMORPH: @@ -3424,7 +3434,7 @@ static int affect_monster(bolt &beam, monsters *mon) if (beam.is_tracer) { // check can see other monster - if (!beam.can_see_invis && menv[tid].has_ench(ENCH_INVIS)) + if (!beam.can_see_invis && menv[tid].invisible()) { // can't see this monster, ignore it return 0; diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 2875f8f832..81965334bd 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1178,7 +1178,7 @@ private: bool pickup(item_def &item, int slot, int near, bool force_merge = false); void equip_weapon(const item_def &item, int near); - bool decay_enchantment(const mon_enchant &me, bool decay_degree = false); + bool decay_enchantment(const mon_enchant &me, bool decay_degree = true); bool drop_item(int eslot, int near); bool wants_weapon(const item_def &item) const; diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 6cfed06cd3..a49b3846b8 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -2175,7 +2175,7 @@ int melee_attack::player_to_hit(bool random_factor) const bool see_invis = player_see_invis(); // if you can't see yourself, you're a little less acurate. - if (you.duration[DUR_INVIS] && !see_invis) + if (you.invisible() && !see_invis) your_to_hit -= 5; // fighting contribution diff --git a/crawl-ref/source/it_use2.cc b/crawl-ref/source/it_use2.cc index eac0ba2cac..87bfe44cff 100644 --- a/crawl-ref/source/it_use2.cc +++ b/crawl-ref/source/it_use2.cc @@ -215,6 +215,9 @@ bool potion_effect( potion_type pot_eff, int pow ) mpr( (!you.duration[DUR_INVIS]) ? "You fade into invisibility!" : "You fade further into invisibility." ); + // Invisibility cancels backlight. + you.duration[DUR_BACKLIGHT] = 0; + // now multiple invisiblity casts aren't as good -- bwr if (!you.duration[DUR_INVIS]) you.duration[DUR_INVIS] = 15 + random2(pow); diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 29e35a0134..7fb476eadb 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -492,7 +492,7 @@ bool mons_see_invis(const monsters *mon) bool mons_monster_visible( struct monsters *mon, struct monsters *targ ) { if (targ->has_ench(ENCH_SUBMERGED) - || (targ->has_ench(ENCH_INVIS) && !mons_see_invis(mon))) + || (targ->invisible() && !mons_see_invis(mon))) { return (false); } @@ -504,7 +504,7 @@ bool mons_monster_visible( struct monsters *mon, struct monsters *targ ) // with respect to mon's perception, but doesn't do walls or range. bool mons_player_visible( struct monsters *mon ) { - if (you.duration[DUR_INVIS]) + if (you.invisible()) { if (player_in_water()) return (true); @@ -3468,9 +3468,10 @@ bool monsters::del_ench(enchant_type ench, bool quiet) if (i == enchantments.end()) return (false); + const mon_enchant me = i->second; const enchant_type et = i->first; - remove_enchantment_effect(i->second, quiet); enchantments.erase(et); + remove_enchantment_effect(me, quiet); return (true); } @@ -3527,7 +3528,7 @@ void monsters::remove_enchantment_effect(const mon_enchant &me, bool quiet) && !has_ench( ENCH_SUBMERGED )) { if (!quiet) - mprf("%s appears!", name(DESC_CAP_A).c_str() ); + mprf("%s appears!", name(DESC_CAP_A, true).c_str() ); seen_monster(this); } @@ -3550,7 +3551,13 @@ void monsters::remove_enchantment_effect(const mon_enchant &me, bool quiet) case ENCH_BACKLIGHT: if (!quiet) - simple_monster_message(this, " stops glowing."); + { + if (player_monster_visible(this)) + simple_monster_message(this, " stops glowing."); + else if (has_ench(ENCH_INVIS) && mons_near(this)) + mprf("%s stops glowing and disappears.", + name(DESC_CAP_THE, true).c_str()); + } break; case ENCH_STICKY_FLAME: @@ -4149,7 +4156,7 @@ bool monsters::can_see_invisible() const bool monsters::invisible() const { - return (has_ench(ENCH_INVIS)); + return (has_ench(ENCH_INVIS) && !backlit()); } void monsters::mutate() diff --git a/crawl-ref/source/monspeak.cc b/crawl-ref/source/monspeak.cc index a0441ea42c..6a4077704a 100644 --- a/crawl-ref/source/monspeak.cc +++ b/crawl-ref/source/monspeak.cc @@ -159,7 +159,7 @@ bool mons_speaks(const monsters *monster) const std::string m_name = monster->name(DESC_CAP_THE); strcpy(info, m_name.c_str()); - if (monster->has_ench(ENCH_INVIS)) + if (monster->invisible()) return false; // invisible monster tries to remain unnoticed diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 2941a2ba9e..ff41163450 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -1098,8 +1098,7 @@ bool monster_polymorph( monsters *monster, monster_type targetc, // messaging: {dlb} bool invis = (mons_class_flag( targetc, M_INVIS ) - || monster->has_ench(ENCH_INVIS)) && - (!player_see_invis()); + || monster->invisible()) && !player_see_invis(); if (monster->has_ench(ENCH_GLOWING_SHAPESHIFTER, ENCH_SHAPESHIFTER)) str_polymon = " changes into "; @@ -1557,7 +1556,7 @@ static void handle_behaviour(monsters *mon) // change proxPlayer depending on invisibility and standing // in shallow water - if (proxPlayer && you.duration[DUR_INVIS]) + if (proxPlayer && you.invisible()) { if (!mons_player_visible( mon )) proxPlayer = false; diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index 1480f03cfc..cec30a9acd 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -1358,10 +1358,6 @@ std::string status_mut_abilities() if (you.duration[DUR_SILENCE]) text += "radiating silence, "; -// resistance part already says so -// if (you.duration[DUR_SEE_INVISIBLE]) -// text += "see invisible, "; - if (you.duration[DUR_INVIS]) text += "invisible, "; diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index ee1e061ac2..93088eff46 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -262,7 +262,7 @@ bool move_player_to_grid( int x, int y, bool stepped, bool allow_shift, mpr("Moving in this stuff is going to be slow."); - if (you.duration[DUR_INVIS]) + if (you.invisible()) mpr( "... and don't expect to remain undetected." ); } } @@ -2178,7 +2178,7 @@ int player_see_invis(bool calc_unid) bool player_monster_visible( const monsters *mon ) { if (mon->has_ench(ENCH_SUBMERGED) - || (mon->has_ench(ENCH_INVIS) && !player_see_invis())) + || (mon->invisible() && !player_see_invis())) { return (false); } @@ -5498,7 +5498,7 @@ bool player::can_see_invisible() const bool player::invisible() const { - return (duration[DUR_INVIS]); + return (duration[DUR_INVIS] && !backlit()); } bool player::backlit() const diff --git a/crawl-ref/source/skills2.cc b/crawl-ref/source/skills2.cc index fdd25cc9db..220618fec9 100644 --- a/crawl-ref/source/skills2.cc +++ b/crawl-ref/source/skills2.cc @@ -1644,7 +1644,7 @@ const int spec_skills[ NUM_SPECIES ][40] = 140, // SK_BOWS 140, // SK_CROSSBOWS 140, // SK_DARTS - 140, // SK_THROWING + 140, // SK_RANGED_COMBAT 140, // SK_ARMOUR 110, // SK_DODGING 50, // SK_STEALTH diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 13fe97e359..fb93985dc0 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -822,6 +822,9 @@ void cast_toxic_radiance(void) if (monster->type != -1 && mons_near(monster)) { + // Monsters affected by corona are still invisible in that + // radiation passes through them without affecting them. Therefore, + // this check should not be !monster->invisible(). if (!monster->has_ench(ENCH_INVIS)) { poison_monster(monster, KC_YOU); diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index 15c749342e..6ad9864151 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -1840,11 +1840,6 @@ bool backlight_monsters(int x, int y, int pow, int garbage) switch (menv[mon].type) { - //case MONS_INSUBSTANTIAL_WISP: //jmf: I'm not sure if these glow or not - //case MONS_VAPOUR: - case MONS_UNSEEN_HORROR: // consider making this visible? probably not. - return (false); - case MONS_FIRE_VORTEX: case MONS_ANGEL: case MONS_FIEND: @@ -1871,7 +1866,21 @@ bool backlight_monsters(int x, int y, int pow, int garbage) } mon_enchant bklt = menv[mon].get_ench(ENCH_BACKLIGHT); - int lvl = bklt.degree; + const int lvl = bklt.degree; + + // this enchantment overrides invisibility (neat) + if (menv[mon].has_ench(ENCH_INVIS)) + { + if (!menv[mon].has_ench(ENCH_BACKLIGHT)) + { + menv[mon].add_ench( + mon_enchant(ENCH_BACKLIGHT, 1, KC_OTHER, random_range(30, 50))); + simple_monster_message( &menv[mon], " is limned in light." ); + } + return (true); + } + + menv[mon].add_ench(mon_enchant(ENCH_BACKLIGHT, 1)); if (lvl == 0) simple_monster_message( &menv[mon], " is outlined in light." ); @@ -1880,10 +1889,6 @@ bool backlight_monsters(int x, int y, int pow, int garbage) else simple_monster_message( &menv[mon], " glows brighter." ); - // this enchantment wipes out invisibility (neat) - menv[mon].del_ench(ENCH_INVIS); - menv[mon].add_ench(mon_enchant(ENCH_BACKLIGHT, 1)); - return (true); } // end backlight_monsters() diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index a1f462e987..27fc295798 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -599,6 +599,10 @@ static int get_mons_colour(const monsters *mons) col |= COLFLAG_ITEM_HEAP; } + // Backlit monsters are fuzzy and override brands. + if (mons->has_ench(ENCH_INVIS) && mons->has_ench(ENCH_BACKLIGHT)) + col = DARKGREY; + return (col); } -- cgit v1.2.3-54-g00ecf