Futher pet spell work

This commit is contained in:
tomrus88 2008-11-06 13:22:43 +03:00
parent cdd1f4e098
commit ca8180ecd1
5 changed files with 19 additions and 27 deletions

View file

@ -1282,7 +1282,6 @@ bool Pet::addSpell(uint16 spell_id, uint16 active, PetSpellState state, uint16 s
ToggleAutocast(itr->first, false); ToggleAutocast(itr->first, false);
oldspell_id = itr->first; oldspell_id = itr->first;
//removeSpell(itr->first);
unlearnSpell(itr->first); unlearnSpell(itr->first);
break; break;
} }
@ -1340,16 +1339,18 @@ bool Pet::learnSpell(uint16 spell_id)
void Pet::learnLevelupSpells() void Pet::learnLevelupSpells()
{ {
PetLevelupSpellList const *levelupSpells = spellmgr.GetPetLevelupSpellList(GetCreatureInfo()->family); PetLevelupSpellSet const *levelupSpells = spellmgr.GetPetLevelupSpellList(GetCreatureInfo()->family);
if(!levelupSpells) if(!levelupSpells)
return; 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()) if(itr->first <= level)
learnSpell(itr->SpellId); learnSpell(itr->second);
else else
unlearnSpell(itr->SpellId); unlearnSpell(itr->second);
} }
} }

View file

@ -155,7 +155,8 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
} }
break; break;
case ACT_DISABLED: // 0x8100 spell (disabled), ignore case ACT_DISABLED: // 0x8100 spell (disabled), ignore
case ACT_ENABLED: //0xc100 spell case ACT_PASSIVE: // 0x0100
case ACT_ENABLED: // 0xC100 spell
{ {
Unit* unit_target; Unit* unit_target;
if(guid2) 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); 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 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 //sign for autocast
if(act_state == ACT_ENABLED && spell_id) if(act_state == ACT_ENABLED && spell_id)

View file

@ -1970,7 +1970,6 @@ void SpellMgr::LoadSpellPetAuras()
void SpellMgr::LoadPetLevelupSpellMap() void SpellMgr::LoadPetLevelupSpellMap()
{ {
PetLevelupSpell petSpell;
CreatureFamilyEntry const *creatureFamily; CreatureFamilyEntry const *creatureFamily;
SpellEntry const *spell; SpellEntry const *spell;
uint32 count = 0; uint32 count = 0;
@ -2140,10 +2139,7 @@ void SpellMgr::LoadPetLevelupSpellMap()
} }
} }
petSpell.SpellId = spell->Id; mPetLevelupSpellMap[creatureFamily->ID][spell->spellLevel] = spell->Id;
petSpell.ReqLevel = spell->spellLevel;
mPetLevelupSpellMap[creatureFamily->ID].push_back(petSpell);
count++; count++;
} }
} }

View file

@ -626,14 +626,8 @@ typedef std::multimap<uint32, SpellLearnSpellNode> SpellLearnSpellMap;
typedef std::multimap<uint32, SkillLineAbilityEntry const*> SkillLineAbilityMap; typedef std::multimap<uint32, SkillLineAbilityEntry const*> SkillLineAbilityMap;
struct PetLevelupSpell typedef std::map<uint32, uint32> PetLevelupSpellSet;
{ typedef std::map<uint32, PetLevelupSpellSet> PetLevelupSpellMap;
uint32 SpellId;
uint32 ReqLevel;
};
typedef std::vector<PetLevelupSpell> PetLevelupSpellList;
typedef std::map<uint32, PetLevelupSpellList> PetLevelupSpellMap;
inline bool IsPrimaryProfessionSkill(uint32 skill) inline bool IsPrimaryProfessionSkill(uint32 skill)
{ {
@ -850,7 +844,7 @@ class SpellMgr
return NULL; return NULL;
} }
PetLevelupSpellList const* GetPetLevelupSpellList(uint32 petFamily) const PetLevelupSpellSet const* GetPetLevelupSpellList(uint32 petFamily) const
{ {
PetLevelupSpellMap::const_iterator itr = mPetLevelupSpellMap.find(petFamily); PetLevelupSpellMap::const_iterator itr = mPetLevelupSpellMap.find(petFamily);
if(itr != mPetLevelupSpellMap.end()) if(itr != mPetLevelupSpellMap.end())

View file

@ -9897,7 +9897,7 @@ void CharmInfo::InitEmptyActionBar()
{ {
for(uint32 x = 1; x < 10; ++x) for(uint32 x = 1; x < 10; ++x)
{ {
PetActionBar[x].Type = ACT_ENABLED; PetActionBar[x].Type = ACT_PASSIVE;
PetActionBar[x].SpellOrAction = 0; PetActionBar[x].SpellOrAction = 0;
} }
PetActionBar[0].Type = ACT_COMMAND; PetActionBar[0].Type = ACT_COMMAND;
@ -9916,7 +9916,7 @@ void CharmInfo::InitPossessCreateSpells()
if (IsPassiveSpell(((Creature*)m_unit)->m_spells[x])) if (IsPassiveSpell(((Creature*)m_unit)->m_spells[x]))
m_unit->CastSpell(m_unit, ((Creature*)m_unit)->m_spells[x], true); m_unit->CastSpell(m_unit, ((Creature*)m_unit)->m_spells[x], true);
else 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 if(onlyselfcast || !IsPositiveSpell(spellId)) //only self cast and spells versus enemies are autocastable
newstate = ACT_DISABLED; newstate = ACT_DISABLED;
else else
newstate = ACT_ENABLED; newstate = ACT_PASSIVE;
AddSpellToAB(0, spellId, newstate); AddSpellToAB(0, spellId, newstate);
} }
@ -9970,7 +9970,7 @@ bool CharmInfo::AddSpellToAB(uint32 oldid, uint32 newid, ActiveStates newstate)
{ {
for(uint8 i = 0; i < 10; i++) 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; PetActionBar[i].SpellOrAction = newid;
if(!oldid) if(!oldid)