[7838] More fixes in pet's levelup spells.

* Fixed not updating levelup spells at warlock pet summon firsy time (overwriting by default original ranks in fact)
* Correctly upgrade/doungrade spell ranks in action bar.
* Fixed spell learning spam at warlock pet re-summon in some cases.

TODO: currently (before this commit and in it) PetSpellInitialize() called too oftern. Maybe possible cache update flag and do it one time somewhere in Pet::Update....
This commit is contained in:
VladimirMangos 2009-05-16 17:01:03 +04:00
parent 8cf9dc035b
commit 122c9c5785
6 changed files with 97 additions and 48 deletions

View file

@ -10396,20 +10396,30 @@ void CharmInfo::InitCharmCreateSpells()
bool CharmInfo::AddSpellToAB(uint32 oldid, uint32 newid, ActiveStates newstate)
{
// new spell already listed for example in case prepered switch to lesser rank in Pet::removeSpell
for(uint8 i = 0; i < 10; ++i)
if (PetActionBar[i].Type == ACT_DISABLED || PetActionBar[i].Type == ACT_ENABLED || PetActionBar[i].Type == ACT_PASSIVE)
if (newid && PetActionBar[i].SpellOrAction == newid)
return true;
// old spell can be leasted for example in case learn high rank
for(uint8 i = 0; i < 10; ++i)
{
if((PetActionBar[i].Type == ACT_DISABLED || PetActionBar[i].Type == ACT_ENABLED || PetActionBar[i].Type == ACT_PASSIVE) && PetActionBar[i].SpellOrAction == oldid)
if (PetActionBar[i].Type == ACT_DISABLED || PetActionBar[i].Type == ACT_ENABLED || PetActionBar[i].Type == ACT_PASSIVE)
{
PetActionBar[i].SpellOrAction = newid;
if(!oldid)
if (PetActionBar[i].SpellOrAction == oldid)
{
if(newstate == ACT_DECIDE)
PetActionBar[i].Type = ACT_DISABLED;
else
PetActionBar[i].Type = newstate;
}
PetActionBar[i].SpellOrAction = newid;
if (!oldid)
{
if (newstate == ACT_DECIDE)
PetActionBar[i].Type = ACT_DISABLED;
else
PetActionBar[i].Type = newstate;
}
return true;
return true;
}
}
}
return false;
@ -11399,6 +11409,7 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id)
// this enables pet details window (Shift+P)
pet->AIM_Initialize();
pet->InitPetCreateSpells();
pet->InitLevelupSpellsForLevel();
pet->InitTalentForLevel();
pet->SetHealth(pet->GetMaxHealth());