Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DBCStores.cpp - fix for wrong XP calculation in Worgen + Goblin start zones #38

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/game/DBCStores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
28 changes: 18 additions & 10 deletions src/game/Pet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -288,19 +292,22 @@ 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
DEBUG_LOG("New Pet has guid %u", GetGUIDLow());

if (owner->GetTypeId() == TYPEID_PLAYER)
{
((Player*)owner)->PetSpellInitialize();
if (!hideActionBar)
((Player*)owner)->PetSpellInitialize();
if (((Player*)owner)->GetGroup())
((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_PET);

Expand Down Expand Up @@ -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();
}

Expand Down
1 change: 1 addition & 0 deletions src/game/Spell.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
88 changes: 87 additions & 1 deletion src/game/SpellEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down