summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-util.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-13 05:17:12 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-13 05:17:12 +0000
commita3ba5a8ee29de19bb37c6718f56f5f184d58be6a (patch)
treee2ee6a6a9fb04218050fafcc263739d34c9a4b16 /crawl-ref/source/mon-util.cc
parent79c8875dd3844dcc3a027013d536b6d10ddc8480 (diff)
downloadcrawl-ref-a3ba5a8ee29de19bb37c6718f56f5f184d58be6a.tar.gz
crawl-ref-a3ba5a8ee29de19bb37c6718f56f5f184d58be6a.zip
This change breaks savefile compatibility.
Removed speed_inc field from monsterentry struct and added field energy_usage, which lets a monster take different amounts of time for different types of actions, defaulting to 10 points of energy for everything but picking up an object, which defaults to 100% of the monster's speed (the same as before this change). This is currently only used to make curse toes move at half the speed with which they attack (which was previously hard-coded), but is could be used for a lot of interesting things. A related change is that the manner in which apply_enchantment() deals with a monster moving at a different rate than the player has changed for monsters with non-zero-speed. As an example, giant bats have a speed of 30, which means that apply_enchantments() gets called three times per player move if the player is at normal speed; apply_enchantment() has to compensate for this so that a poisoned bat doesn't suffer three times the damage as a monster with speed 10. Monsters being able to do things in energy increments of other than 10 complicated this, and the easiest way to deal with the complication was to keep track of how much energy a monster had recently expended with the new monsters class member ench_countdown, and use that to call apply_enchantments() once for every normal-speed player move (zero-speed monsters are still dealt with in the same manner as before). Because of this, the "spd" variable in apply_enchantment() and decay_enchantment() is normalized to 10 for all non-zero-speed monsters. This doesn't work for ENCH_HELD, since a fast monster should be able to escape from a net more quickly than a slow monster. I've tried to compensate for this, but I'm not sure if I've done it right. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2450 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mon-util.cc')
-rw-r--r--crawl-ref/source/mon-util.cc29
1 files changed, 23 insertions, 6 deletions
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 024b3e3878..6d28f94c0b 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -1486,6 +1486,7 @@ void define_monster(int index)
// reset monster enchantments
mons.enchantments.clear();
+ mons.ench_countdown = 0;
} // end define_monster()
static std::string str_monam(const monsters& mon, description_level_type desc,
@@ -2841,8 +2842,11 @@ bool monsters::unequip(item_def &item, int slot, int near, bool force)
void monsters::lose_pickup_energy()
{
- if (speed_increment > 25 && speed < speed_increment)
- speed_increment -= speed;
+ monsterentry* entry = get_monster_data(type);
+ int delta = speed * entry->energy_usage.pickup_percent / 100;
+
+ if (speed_increment > 25 && delta < speed_increment)
+ speed_increment -= delta;
}
void monsters::pickup_message(const item_def &item, int near)
@@ -3201,7 +3205,10 @@ void monsters::swap_weapons(int near)
// Monsters can swap weapons really fast. :-)
if ((weap || alt) && speed_increment >= 2)
- speed_increment -= 2;
+ {
+ monsterentry *entry = get_monster_data(type);
+ speed_increment -= div_rand_round(entry->energy_usage.attack, 5);
+ }
}
void monsters::wield_melee_weapon(int near)
@@ -3619,6 +3626,7 @@ void monsters::ghost_init()
inv.init(NON_ITEM);
enchantments.clear();
+ ench_countdown = 0;
find_place_to_live();
}
@@ -3723,6 +3731,7 @@ void monsters::reset()
destroy_inventory();
enchantments.clear();
+ ench_countdown = 0;
inv.init(NON_ITEM);
flags = 0;
@@ -4182,7 +4191,10 @@ static inline int mod_speed( int val, int speed )
bool monsters::decay_enchantment(const mon_enchant &me, bool decay_degree)
{
- const int spd = speed == 0? you.time_taken : speed;
+ // Faster monsters can wiggle out of the net more quickly.
+ const int spd = (speed == 0) ? you.time_taken :
+ (me.ench == ENCH_HELD) ? speed :
+ 10;
const int actdur = speed_to_duration(spd);
if (lose_ench_duration(me, actdur))
return (true);
@@ -4217,7 +4229,7 @@ bool monsters::decay_enchantment(const mon_enchant &me, bool decay_degree)
void monsters::apply_enchantment(const mon_enchant &me)
{
- const int spd = speed == 0? you.time_taken : speed;
+ const int spd = speed == 0? you.time_taken : 10;
switch (me.ench)
{
case ENCH_BERSERK:
@@ -4348,7 +4360,12 @@ void monsters::apply_enchantment(const mon_enchant &me)
// berserking doubles damage dealt
if (has_ench(ENCH_BERSERK))
damage *= 2;
-
+
+ // Faster monsters can damage the net more often per
+ // time period.
+ if (speed != 0)
+ damage = div_rand_round(damage * speed, spd);
+
mitm[net].plus -= damage;
if (mitm[net].plus < -7)