mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-15 17:25:32 +00:00
Restore support for negative healing.
The 1.10 implementation did not rule this out, so I've (finally) tried to restore what 1.10 allowed, with slightly better accounting of multiple sources of negative healing. I don't know if this is the best thing to do, but some UMC authors wanted it back. (They did not want it enough to answer my questions about it, though.)
This commit is contained in:
parent
c0ee2c8e87
commit
8394f3ae0f
@ -134,6 +134,9 @@ Version 1.11.6+dev:
|
||||
* Allow WML menu items to use hotkeys alongside/instead of the menu.
|
||||
* Really added sighted events for ambushing units.
|
||||
* [scroll] now takes an optional side filter.
|
||||
* Some support for negative healing. This is not guaranteed to work correctly
|
||||
in all cases, but it does restore the basic functionality that was
|
||||
(probably accidentally) in 1.10.
|
||||
* Units:
|
||||
* Gave the Death Knight proper skeletal resistances, as well as submerge.
|
||||
* User interface:
|
||||
|
@ -153,6 +153,28 @@ namespace {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the current healing and harming amounts based on a new value.
|
||||
* This is a helper function for heal_amount().
|
||||
* @returns true if an amount was updated.
|
||||
*/
|
||||
inline bool update_healing(int & healing, int & harming, int value)
|
||||
{
|
||||
// If the new value magnifies the healing, update and return true.
|
||||
if ( value > healing ) {
|
||||
healing = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the new value magnifies the harming, update and return true.
|
||||
if ( value < harming ) {
|
||||
harming = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Keeping the same values as before.
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Calculate how much @patient heals this turn.
|
||||
* If healed by units, those units are added to @a healers.
|
||||
@ -162,17 +184,19 @@ namespace {
|
||||
unit_map &units = *resources::units;
|
||||
|
||||
int healing = 0;
|
||||
int harming = 0;
|
||||
|
||||
|
||||
if ( patient.side() == side )
|
||||
{
|
||||
// Village healing?
|
||||
healing = resources::game_map->gives_healing(patient.get_location());
|
||||
update_healing(healing, harming,
|
||||
resources::game_map->gives_healing(patient.get_location()));
|
||||
|
||||
// Regeneration?
|
||||
unit_ability_list regen_list = patient.get_abilities("regenerate");
|
||||
unit_abilities::effect regen_effect(regen_list, 0, false);
|
||||
healing = std::max(healing, regen_effect.get_composite_value());
|
||||
update_healing(healing, harming, regen_effect.get_composite_value());
|
||||
}
|
||||
|
||||
// Check healing from other units.
|
||||
@ -191,10 +215,8 @@ namespace {
|
||||
|
||||
// Now we can get the aggregate healing amount.
|
||||
unit_abilities::effect heal_effect(heal_list, 0, false);
|
||||
int unit_heal = heal_effect.get_composite_value();
|
||||
if ( unit_heal > healing )
|
||||
if ( update_healing(healing, harming, heal_effect.get_composite_value()) )
|
||||
{
|
||||
healing = unit_heal;
|
||||
// Collect the healers involved.
|
||||
BOOST_FOREACH (const unit_abilities::individual_effect & heal, heal_effect)
|
||||
healers.push_back(&*units.find(heal.loc));
|
||||
@ -204,7 +226,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
return healing;
|
||||
return healing + harming;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user