diff --git a/src/game/DBCStores.cpp b/src/game/DBCStores.cpp index 8a2243ca58..29e59276ae 100644 --- a/src/game/DBCStores.cpp +++ b/src/game/DBCStores.cpp @@ -983,6 +983,12 @@ ContentLevels GetContentLevelsForMap(uint32 mapid) MapEntry const* mapEntry = sMapStore.LookupEntry(mapid); if (!mapEntry) return CONTENT_1_60; + + if (mapid = 654) //654 = Worgen Starter area. + return CONTENT_1_60; + + if (mapid = 648) //648 = Goblin Starter area. + return CONTENT_1_60; switch (mapEntry->Expansion()) { diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index cc807b9897..523f39d371 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -77,9 +77,10 @@ void Pet::RemoveFromWorld() bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool current) { m_loading = true; - + uint32 ownerid = owner->GetGUIDLow(); - + bool petControl = owner->HasSpell(79682); // 0 = Owner does not know spell 79682 = Pet Control + QueryResult* result; if (petnumber) @@ -242,9 +243,12 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c CharacterDatabase.CommitTransaction(); } - + bool hideActionBar = 0; // = 1 when it must be hidden + if ((!petControl) && (pet_type == HUNTER_PET)) + hideActionBar = 1; + // load action bar, if data broken will fill later by default spells. - if (!is_temporary_summoned) + if ((!is_temporary_summoned) || (!hideActionBar)) m_charmInfo->LoadPetActionBar(fields[12].GetCppString()); // since last save (in seconds) @@ -288,11 +292,13 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c map->Add((Creature*)this); // Spells should be loaded after pet is added to map, because in CheckCast is check on it - _LoadSpells(); - InitLevelupSpellsForLevel(); - - CleanupActionBar(); // remove unknown spells from action bar after load + if (!hideActionBar) + { + _LoadSpells(); + InitLevelupSpellsForLevel(); + CleanupActionBar(); // remove unknown spells from action bar after load + } _LoadSpellCooldowns(); owner->SetPet(this); // in DB stored only full controlled creature @@ -300,7 +306,8 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c if (owner->GetTypeId() == TYPEID_PLAYER) { - ((Player*)owner)->PetSpellInitialize(); + if (!hideActionBar) + ((Player*)owner)->PetSpellInitialize(); if (((Player*)owner)->GetGroup()) ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_PET); @@ -739,7 +746,8 @@ void Pet::GivePetLevel(uint32 level) } InitStatsForLevel(level); - InitLevelupSpellsForLevel(); + if (level >10) // only update spell for pets above level 10 + InitLevelupSpellsForLevel(); InitTalentForLevel(); } diff --git a/src/game/Spell.h b/src/game/Spell.h index d21d7dfce4..4ec4ad568e 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -364,6 +364,7 @@ class Spell void EffectQuestFail(SpellEffectEntry const* effect); void EffectQuestOffer(SpellEffectEntry const* effect); void EffectActivateRune(SpellEffectEntry const* effect); + void EffectCreateTamedPet(SpellEffectEntry const* effect); void EffectTeachTaxiNode(SpellEffectEntry const* effect); void EffectWMODamage(SpellEffectEntry const* effect); void EffectWMORepair(SpellEffectEntry const* effect); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index d61fdec456..632d838bea 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -215,7 +215,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS] = &Spell::EffectQuestOffer, //150 SPELL_EFFECT_QUEST_OFFER &Spell::EffectTriggerRitualOfSummoning, //151 SPELL_EFFECT_TRIGGER_SPELL_2 &Spell::EffectNULL, //152 SPELL_EFFECT_152 summon Refer-a-Friend - &Spell::EffectNULL, //153 SPELL_EFFECT_CREATE_PET misc value is creature entry + &Spell::EffectCreateTamedPet, //153 SPELL_EFFECT_CREATE_PET misc value is creature entry &Spell::EffectTeachTaxiNode, //154 SPELL_EFFECT_TEACH_TAXI_NODE single spell: Teach River's Heart Taxi Path &Spell::EffectTitanGrip, //155 SPELL_EFFECT_TITAN_GRIP Allows you to equip two-handed axes, maces and swords in one hand, but you attack $49152s1% slower than normal. &Spell::EffectEnchantItemPrismatic, //156 SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC @@ -11408,6 +11408,92 @@ void Spell::EffectRedirectThreat(SpellEffectEntry const* /*effect*/) m_caster->getHostileRefManager().SetThreatRedirection(unitTarget->GetObjectGuid(), uint32(damage)); } +void Spell::EffectCreateTamedPet(SpellEffectEntry const* effect) +{ + sLog.outErrorDb(" SpellEffectCreateTamedPet-WOLF: START"); + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || unitTarget->getClass() != CLASS_HUNTER) + return; + uint32 creatureEntry = m_spellInfo->GetEffectMiscValue(EFFECT_INDEX_0); + + Pet* OldSummon = m_caster->GetPet(); + + // if pet requested type already exist + if (OldSummon) + { + sLog.outErrorDb(" SpellEffectCreateTamedPet-WOLF: Already got a pet "); + return; + } + + sLog.outErrorDb(" SpellEffectCreateTamedPet-WOLF: CretureEntry: %u", creatureEntry); + + CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(creatureEntry); + + // == 0 in case call current pet, check only real summon case + if (creatureEntry && !cInfo) + { + sLog.outErrorDb("EffectCreateTamedPet: creature entry %u not found for spell %u.", creatureEntry, m_spellInfo->Id); + return; + } + + Pet* NewSummon = new Pet; + + CreatureCreatePos pos(m_caster, m_caster->GetOrientation()); + + Map* map = m_caster->GetMap(); + uint32 pet_number = sObjectMgr.GeneratePetNumber(); + if (!NewSummon->Create(map->GenerateLocalLowGuid(HIGHGUID_PET), pos, cInfo, pet_number)) + { + delete NewSummon; + return; + } + + NewSummon->SetRespawnCoord(pos); + + uint32 petlevel = m_caster->getLevel(); + NewSummon->setPetType(HUNTER_PET); + + uint32 faction = m_caster->getFaction(); + NewSummon->GetCharmInfo()->SetReactState(REACT_DEFENSIVE); + + NewSummon->SetOwnerGuid(m_caster->GetObjectGuid()); + NewSummon->SetCreatorGuid(m_caster->GetObjectGuid()); + NewSummon->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); + NewSummon->setFaction(faction); + NewSummon->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); + NewSummon->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); + NewSummon->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); + NewSummon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); + + NewSummon->GetCharmInfo()->SetPetNumber(pet_number, true); + // this enables pet details window (Shift+P) + + NewSummon->InitStatsForLevel(petlevel, m_caster); + NewSummon->InitPetCreateSpells(); + NewSummon->InitLevelupSpellsForLevel(); + NewSummon->InitTalentForLevel(); + + NewSummon->RemoveByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED); + NewSummon->SetByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_ABANDONED); + + NewSummon->AIM_Initialize(); + NewSummon->SetHealth(NewSummon->GetMaxHealth()); + NewSummon->SetPower(POWER_MANA, NewSummon->GetMaxPower(POWER_MANA)); + + float px, py, pz; + m_caster->GetClosePoint(px, py, pz, NewSummon->GetObjectBoundingRadius()); + NewSummon->Relocate(px, py, pz, m_caster->GetOrientation()); + + map->Add((Creature*)NewSummon); + + m_caster->SetPet(NewSummon); + DEBUG_LOG("New Pet has guid %u", NewSummon->GetGUIDLow()); + + NewSummon->SavePetToDB(PET_SAVE_AS_CURRENT); + //((Player*)m_caster)->PetSpellInitialize(); + sLog.outErrorDb(" SpellEffectCreateTamedPet-WOLF: Pet saved to DB"); + +} + void Spell::EffectTeachTaxiNode(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)