diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-10-13 05:17:12 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-10-13 05:17:12 +0000 |
commit | a3ba5a8ee29de19bb37c6718f56f5f184d58be6a (patch) | |
tree | e2ee6a6a9fb04218050fafcc263739d34c9a4b16 /crawl-ref/source/fight.cc | |
parent | 79c8875dd3844dcc3a027013d536b6d10ddc8480 (diff) | |
download | crawl-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/fight.cc')
-rw-r--r-- | crawl-ref/source/fight.cc | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 0972bcf624..605f06012b 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -479,6 +479,14 @@ bool melee_attack::attack() // Xom thinks fumbles are funny... if (attacker->fumbles_attack()) { + if (attacker->atype() == ACT_MONSTER) + { + // Make sure the monster uses up some energy, even though + // it didn't actually attack. + monsterentry *entry = get_monster_data(atk->type); + atk->speed_increment -= entry->energy_usage.attack; + } + // ... and thinks fumbling when trying to hit yourself is just // hilarious. if (attacker == defender) @@ -3362,7 +3370,7 @@ void melee_attack::mons_perform_attack_rounds() // Melee combat, tell attacker to wield its melee weapon. atk->wield_melee_weapon(); - + for (attack_number = 0; attack_number < nrounds; ++attack_number) { // Monster went away? @@ -3375,7 +3383,17 @@ void melee_attack::mons_perform_attack_rounds() const mon_attack_def attk = mons_attack_spec(atk, attack_number); if (attk.type == AT_NONE) + { + if (attack_number == 0) + { + // Make sure the monster uses up some energy, even + // though it didn't actually attack. + monsterentry *entry = get_monster_data(atk->type); + atk->speed_increment -= entry->energy_usage.attack; + } + break; + } if (attk.type == AT_SHOOT) continue; @@ -3568,8 +3586,16 @@ bool you_attack(int monster_attacked, bool unarmed_attacks) static void mons_lose_attack_energy(monsters *attacker, int wpn_speed, int which_attack) { - // Monsters lose energy only for the first two weapon attacks; subsequent - // hits are free. + monsterentry *entry = get_monster_data(attacker->type); + char atk_speed = entry->energy_usage.attack; + + // Initial attack causes energy to be used for all attacks. No + // additional energy is used for unarmed attacks. + if (which_attack == 0) + attacker->speed_increment -= atk_speed; + + // Monsters lose additional energy only for the first two weapon + // attacks; subsequent hits are free. if (which_attack > 1) return; @@ -3578,9 +3604,12 @@ static void mons_lose_attack_energy(monsters *attacker, int wpn_speed, { // only get one third penalty/bonus for second weapons. if (which_attack > 0) - wpn_speed = (20 + wpn_speed) / 3; + wpn_speed = div_rand_round( (2 * atk_speed + wpn_speed), 3 ); + + int delta = div_rand_round( (wpn_speed - 10 + (atk_speed - 10)), 2 ); - attacker->speed_increment -= (wpn_speed - 10) / 2; + if (delta > 0) + attacker->speed_increment -= delta; } } |