diff options
author | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-02-08 02:16:32 +0000 |
---|---|---|
committer | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-02-08 02:16:32 +0000 |
commit | 44125ccb3573b67221fa49e3cdeef9020ea7c2b6 (patch) | |
tree | 67bcc3635a30afe222630f9ec9667b39ca583fdd /crawl-ref | |
parent | 20a096b93dc52950e35ff6d5323f0c00e0ac701b (diff) | |
download | crawl-ref-44125ccb3573b67221fa49e3cdeef9020ea7c2b6.tar.gz crawl-ref-44125ccb3573b67221fa49e3cdeef9020ea7c2b6.zip |
Add a power parameter to monsters::drain_exp(), and use it for the mass
drain card effect.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8972 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/decks.cc | 20 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 6 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 2 |
4 files changed, 9 insertions, 27 deletions
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index ec604db006..fccf5447a9 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -1744,26 +1744,8 @@ static int _drain_monsters(coord_def where, int pow, int, actor *) monsters& mon = menv[mnstr]; - if (mons_res_negative_energy(&mon)) + if (!mon.drain_exp(&you, false, pow / 50)) simple_monster_message(&mon, " is unaffected."); - else - { - simple_monster_message(&mon, " is drained!"); - - mon.hurt(&you, 2 + random2(50), BEAM_NEG); - - if (mon.alive()) - { - if (x_chance_in_y(pow / 60, 20)) - { - mon.hit_dice--; - mon.experience = 0; - } - - mon.max_hit_points -= 2 + random2(pow/50); - mon.hit_points = std::min(mon.max_hit_points, mon.hit_points); - } - } } return (1); diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index d8c61d5131..7149b5c265 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -330,7 +330,7 @@ public: virtual bool can_safely_mutate() const = 0; virtual bool can_bleed() const = 0; virtual bool mutate() = 0; - virtual bool drain_exp(actor *agent, bool quiet = false) = 0; + virtual bool drain_exp(actor *agent, bool quiet = false, int pow = 3) = 0; virtual bool rot(actor *agent, int amount, int immediate = 0, bool quiet = false) = 0; virtual int hurt(const actor *attacker, int amount, @@ -1071,7 +1071,7 @@ public: void slow_down(actor *, int str); void confuse(actor *, int strength); void heal(int amount, bool max_too = false); - bool drain_exp(actor *, bool quiet = false); + bool drain_exp(actor *, bool quiet = false, int pow = 3); bool rot(actor *, int amount, int immediate = 0, bool quiet = false); int hurt(const actor *attacker, int amount, beam_type flavour = BEAM_MISSILE, @@ -1505,7 +1505,7 @@ public: void petrify(actor *, int str); void slow_down(actor *, int str); void confuse(actor *, int strength); - bool drain_exp(actor *, bool quiet = false); + bool drain_exp(actor *, bool quiet = false, int pow = 3); bool rot(actor *, int amount, int immediate = 0, bool quiet = false); int hurt(const actor *attacker, int amount, beam_type flavour = BEAM_MISSILE, diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 6c5bc8c5a9..4e76321772 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -5937,7 +5937,7 @@ god_type monsters::deity() const return (god); } -bool monsters::drain_exp(actor *agent, bool quiet) +bool monsters::drain_exp(actor *agent, bool quiet, int pow) { if (x_chance_in_y(res_negative_energy(), 3)) return (false); @@ -5946,17 +5946,17 @@ bool monsters::drain_exp(actor *agent, bool quiet) mprf("%s is drained!", name(DESC_CAP_THE).c_str()); // If quiet, don't clean up the monster in order to credit properly. - hurt(agent, 2 + random2(3), BEAM_NEG, !quiet); + hurt(agent, 2 + random2(pow), BEAM_NEG, !quiet); if (alive()) { - if (one_chance_in(5)) + if (x_chance_in_y(pow, 15)) { hit_dice--; experience = 0; } - max_hit_points -= 2 + random2(3); + max_hit_points -= 2 + random2(pow); hit_points = std::min(max_hit_points, hit_points); } diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 7331b97a01..7da768afee 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -7019,7 +7019,7 @@ bool player::rot(actor *who, int amount, int immediate, bool quiet) return (true); } -bool player::drain_exp(actor *who, bool quiet) +bool player::drain_exp(actor *who, bool quiet, int pow) { return (::drain_exp()); } |