- Joined
- Dec 12, 2010
- Messages
- 2,074
Here's spellbook's pseudocode
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.
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.