diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-05-26 03:16:36 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-05-26 03:16:36 +0000 |
commit | 14752e5f2cfddc5b99a104afe1c8d42a74aff22b (patch) | |
tree | 2130bf2a7e0dbf113651cc57a4ec9c455b67b253 /crawl-ref | |
parent | 091176830cb955eb4de98b900b7c6fa74e987309 (diff) | |
download | crawl-ref-14752e5f2cfddc5b99a104afe1c8d42a74aff22b.tar.gz crawl-ref-14752e5f2cfddc5b99a104afe1c8d42a74aff22b.zip |
monsters::lose_energy() now takes optional paramaters to multiply and/or
divide (rounded up) the amount of energy lost.
When a monster's attack is warded off the energy consumed is half that
of what the attack would normally have taken, a change from it not
taking any energy at all.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5249 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/externs.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/fight.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 4 |
3 files changed, 7 insertions, 4 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index ed86c042b7..b6e6e2bf18 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -126,7 +126,7 @@ public: // Need not be implemented for the player - player action costs // are explicitly calculated. - virtual void lose_energy(energy_use_type) + virtual void lose_energy(energy_use_type, int div = 1, int mult = 1) { } @@ -1091,7 +1091,7 @@ public: bool del_ench(enchant_type ench, bool quiet = false, bool effect = true); bool lose_ench_duration(const mon_enchant &e, int levels); bool lose_ench_levels(const mon_enchant &e, int lev); - void lose_energy(energy_use_type et); + void lose_energy(energy_use_type et, int div = 1, int mult = 1); void scale_hp(int num, int den); bool gain_exp(int exp); diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 8a26e078f8..7228295e86 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -3888,6 +3888,9 @@ bool melee_attack::mons_perform_attack() if (attacker != defender && mons_attack_warded_off()) { + // A warded-off attack takes half the normal energy. + attacker->lose_energy(EUT_ATTACK, 2); + perceived_attack = true; return (false); } diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index edd906743f..1c1d7fb53b 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -5860,9 +5860,9 @@ int monsters::action_energy(energy_use_type et) const return 10; } -void monsters::lose_energy(energy_use_type et) +void monsters::lose_energy(energy_use_type et, int div, int mult) { - speed_increment -= action_energy(et); + speed_increment -= div_round_up(mult * action_energy(et), div); } static inline monster_type _royal_jelly_ejectable_monster() |