From d8537ce97fcc261408188af698b908948a0a2b84 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Fri, 2 Nov 2007 15:05:33 +0000 Subject: Experimental support for monster shields, needs more work for rationalising shield class for monsters with player and beam to-hit. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2727 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/beam.cc | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'crawl-ref/source/beam.cc') diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 4e532cb96d..ba3c94cacc 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -3129,14 +3129,14 @@ static int affect_player( bolt &beam ) #endif if (hit < block) { - you.shield_blocks++; mprf( "You block the %s.", beam.name.c_str() ); - exercise( SK_SHIELDS, exer + 1 ); + you.shield_block_succeeded(); return (BEAM_STOP); } // some training just for the "attempt" - exercise( SK_SHIELDS, exer ); + if (coinflip()) + exercise( SK_SHIELDS, exer ); } if (player_light_armour(true) && !beam.aimed_at_feet @@ -3878,6 +3878,26 @@ static int affect_monster(bolt &beam, monsters *mon) return (0); } + // The monster may block the beam. + if (!engulfs && beam_is_blockable(beam)) + { + const int shield_block = mon->shield_bonus(); + if (shield_block > 0) + { + const int hit = random2( beam.hit * 130 / 100 + + mon->shield_block_penalty() ); + if (hit < shield_block && mons_near(mon) + && player_monster_visible(mon)) + { + mprf("%s blocks the %s.", + mon->name(DESC_CAP_THE).c_str(), + beam.name.c_str()); + mon->shield_block_succeeded(); + return (BEAM_STOP); + } + } + } + update_hurt_or_helped(beam, mon); // the beam hit. -- cgit v1.2.3-54-g00ecf