• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

HP upgrades over unit's max health causing suicide when Spellbook obtained

Status
Not open for further replies.
Level 19
Joined
Dec 12, 2010
Messages
2,074
Here's spellbook's pseudocode
C++:
class AbilityBase
{
virtual void OnAbilityAdded(UnitBase* u) = 0;
}

class SpellBook : public AbilityBase
{
std::list<AbilityBase*> _abilitiesContainer;
virtual void OnAbilityAdded(u)
{
  for (auto a : _7abilitiesContainer)
  {
     UnitAddAbilityInternal(u, a);
  }
}
}

void UnitAddAbilityInternal(UnitBase* u, AbilityBase* a)
{
  RemoveUnitAbilities(u);
  abilTable[u->GetID()].push_back(a);
  a->OnAbilityAdded(u);
  RestoreUnitAbilities(u);
}

If unit receives ability which is spellbook, then UnitAddAbilityInternal will be called recursively again, which will cause 2 instances of RemoveUnitAbilities(u).

Every time this func is called, it purges unit's ability stack, dropping any upgrade he has, and restrore values in the end.

Assuming we have 300 hp unit with 200 hp upgrade (500 total): he will went through spellbook worker just fine.
Once upgrade hits 300 hp bonus (600 total), we will have the followin situation:
remove 300 hp in 1st instance (300 left);
add spellbook, now adding it's spells;
remove 300 hp in 2nd instandce (0 left);
update hp (0);

Unit suicides in result.

It have to be fixed somehow, although I can't see how patches would be any kind of useful next to current possibilities.
 
Status
Not open for further replies.
Top