diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index ca6696832..6c88b614b 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -1282,7 +1282,6 @@ bool Pet::addSpell(uint16 spell_id, uint16 active, PetSpellState state, uint16 s ToggleAutocast(itr->first, false); oldspell_id = itr->first; - //removeSpell(itr->first); unlearnSpell(itr->first); break; } @@ -1340,16 +1339,18 @@ bool Pet::learnSpell(uint16 spell_id) void Pet::learnLevelupSpells() { - PetLevelupSpellList const *levelupSpells = spellmgr.GetPetLevelupSpellList(GetCreatureInfo()->family); + PetLevelupSpellSet const *levelupSpells = spellmgr.GetPetLevelupSpellList(GetCreatureInfo()->family); if(!levelupSpells) return; - for(PetLevelupSpellList::const_iterator itr = levelupSpells->begin(); itr != levelupSpells->end(); ++itr) + uint32 level = getLevel(); + + for(PetLevelupSpellSet::const_iterator itr = levelupSpells->begin(); itr != levelupSpells->end(); ++itr) { - if(itr->ReqLevel <= getLevel()) - learnSpell(itr->SpellId); + if(itr->first <= level) + learnSpell(itr->second); else - unlearnSpell(itr->SpellId); + unlearnSpell(itr->second); } } diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index d02080ccb..8c2359322 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -154,8 +154,9 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) break; } break; - case ACT_DISABLED: //0x8100 spell (disabled), ignore - case ACT_ENABLED: //0xc100 spell + case ACT_DISABLED: // 0x8100 spell (disabled), ignore + case ACT_PASSIVE: // 0x0100 + case ACT_ENABLED: // 0xC100 spell { Unit* unit_target; if(guid2) @@ -348,7 +349,7 @@ void WorldSession::HandlePetSetAction( WorldPacket & recv_data ) sLog.outDetail( "Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X\n", _player->GetName(), position, spell_id, act_state); //if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add - if(!((act_state == ACT_ENABLED || act_state == ACT_DISABLED) && spell_id && !pet->HasSpell(spell_id))) + if(!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id))) { //sign for autocast if(act_state == ACT_ENABLED && spell_id) diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index afb98e34b..02e2cdfa1 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -1970,7 +1970,6 @@ void SpellMgr::LoadSpellPetAuras() void SpellMgr::LoadPetLevelupSpellMap() { - PetLevelupSpell petSpell; CreatureFamilyEntry const *creatureFamily; SpellEntry const *spell; uint32 count = 0; @@ -2140,10 +2139,7 @@ void SpellMgr::LoadPetLevelupSpellMap() } } - petSpell.SpellId = spell->Id; - petSpell.ReqLevel = spell->spellLevel; - - mPetLevelupSpellMap[creatureFamily->ID].push_back(petSpell); + mPetLevelupSpellMap[creatureFamily->ID][spell->spellLevel] = spell->Id; count++; } } diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 87bcdb339..131da2a1f 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -626,14 +626,8 @@ typedef std::multimap SpellLearnSpellMap; typedef std::multimap SkillLineAbilityMap; -struct PetLevelupSpell -{ - uint32 SpellId; - uint32 ReqLevel; -}; - -typedef std::vector PetLevelupSpellList; -typedef std::map PetLevelupSpellMap; +typedef std::map PetLevelupSpellSet; +typedef std::map PetLevelupSpellMap; inline bool IsPrimaryProfessionSkill(uint32 skill) { @@ -850,7 +844,7 @@ class SpellMgr return NULL; } - PetLevelupSpellList const* GetPetLevelupSpellList(uint32 petFamily) const + PetLevelupSpellSet const* GetPetLevelupSpellList(uint32 petFamily) const { PetLevelupSpellMap::const_iterator itr = mPetLevelupSpellMap.find(petFamily); if(itr != mPetLevelupSpellMap.end()) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 415f6a7a3..808a69f01 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -9897,7 +9897,7 @@ void CharmInfo::InitEmptyActionBar() { for(uint32 x = 1; x < 10; ++x) { - PetActionBar[x].Type = ACT_ENABLED; + PetActionBar[x].Type = ACT_PASSIVE; PetActionBar[x].SpellOrAction = 0; } PetActionBar[0].Type = ACT_COMMAND; @@ -9916,7 +9916,7 @@ void CharmInfo::InitPossessCreateSpells() if (IsPassiveSpell(((Creature*)m_unit)->m_spells[x])) m_unit->CastSpell(m_unit, ((Creature*)m_unit)->m_spells[x], true); else - AddSpellToAB(0, ((Creature*)m_unit)->m_spells[x], ACT_ENABLED); + AddSpellToAB(0, ((Creature*)m_unit)->m_spells[x], ACT_PASSIVE); } } @@ -9959,7 +9959,7 @@ void CharmInfo::InitCharmCreateSpells() if(onlyselfcast || !IsPositiveSpell(spellId)) //only self cast and spells versus enemies are autocastable newstate = ACT_DISABLED; else - newstate = ACT_ENABLED; + newstate = ACT_PASSIVE; AddSpellToAB(0, spellId, newstate); } @@ -9970,7 +9970,7 @@ bool CharmInfo::AddSpellToAB(uint32 oldid, uint32 newid, ActiveStates newstate) { for(uint8 i = 0; i < 10; i++) { - if((PetActionBar[i].Type == ACT_DISABLED || PetActionBar[i].Type == ACT_ENABLED) && PetActionBar[i].SpellOrAction == oldid) + if((PetActionBar[i].Type == ACT_DISABLED || PetActionBar[i].Type == ACT_ENABLED || PetActionBar[i].Type == ACT_PASSIVE) && PetActionBar[i].SpellOrAction == oldid) { PetActionBar[i].SpellOrAction = newid; if(!oldid)