From ae9788f34b5a5c817d99ca1e8b80da41fe6e3287 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Mon, 8 Oct 2018 13:56:45 +0200 Subject: [PATCH] Core/Pets: add missing data to pet_levelstats and use them again to calculate base stat values --- .../custom/custom_2018_10_08_00_world.sql | 7 +++ src/server/game/Entities/Pet/Pet.cpp | 31 +++++++++++++ src/server/game/Entities/Unit/StatSystem.cpp | 19 +++----- src/server/scripts/Spells/spell_pet.cpp | 44 +++++-------------- 4 files changed, 56 insertions(+), 45 deletions(-) create mode 100644 sql/updates/world/custom/custom_2018_10_08_00_world.sql diff --git a/sql/updates/world/custom/custom_2018_10_08_00_world.sql b/sql/updates/world/custom/custom_2018_10_08_00_world.sql new file mode 100644 index 00000000000..833389e6f90 --- /dev/null +++ b/sql/updates/world/custom/custom_2018_10_08_00_world.sql @@ -0,0 +1,7 @@ +DELETE FROM `pet_levelstats` WHERE `creature_entry`= 1 AND `level` BETWEEN 81 AND 85; +INSERT INTO `pet_levelstats` (`creature_entry`, `level`, `hp`, `mana`, `armor`, `str`, `agi`, `sta`, `inte`, `spi`) VALUES +(1, 81, 8519, 1, 10085, 410, 170, 371, 81, 127), +(1, 82, 12895, 1, 10385, 436, 183, 387, 92, 139), +(1, 83, 15290, 1, 10684, 462, 196, 403, 103, 151), +(1, 84, 18705, 1, 10984, 488, 209, 419, 115, 163), +(1, 85, 32474, 1, 11647, 516, 222, 435, 127, 175); diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 31c29df92d2..a4cb07a35eb 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -854,6 +854,37 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) SetModifierValue(UnitMods(UNIT_MOD_RESISTANCE_START + i), BASE_VALUE, float(cinfo->resistance[i])); + // Health, mana, armor and resistance + PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(creature_ID, petlevel); + if (pInfo) // exist in DB + { + SetCreateHealth(pInfo->health); + if (petType != HUNTER_PET) //hunter pet use focus + SetCreateMana(pInfo->mana); + + if (pInfo->armor > 0) + SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(pInfo->armor)); + + for (uint8 stat = 0; stat < MAX_STATS; ++stat) + SetCreateStat(Stats(stat), float(pInfo->stats[stat])); + } + else // not exist in DB, use some default fake data + { + // remove elite bonuses included in DB values + CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(petlevel, cinfo->unit_class); + SetCreateHealth(stats->BaseHealth[cinfo->expansion]); + SetCreateMana(stats->BaseMana); + + SetCreateStat(STAT_STRENGTH, 22); + SetCreateStat(STAT_AGILITY, 22); + SetCreateStat(STAT_STAMINA, 25); + SetCreateStat(STAT_INTELLECT, 28); + SetCreateStat(STAT_SPIRIT, 27); + + SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4))); + SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4))); + } + SetBonusDamage(0); switch (petType) { diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index 88372c21dae..fab4b52aeca 100644 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -1026,12 +1026,15 @@ void Guardian::UpdateArmor() void Guardian::UpdateMaxHealth() { UnitMods unitMod = UNIT_MOD_HEALTH; - float stamina = GetStat(STAT_STAMINA); + float stamina = GetStat(STAT_STAMINA) - GetCreateStat(STAT_STAMINA); float multiplicator = 10.0f; uint32 healthDamage = GetMaxHealth() - GetHealth(); switch (GetEntry()) { + case ENTRY_BLOODWORM: + multiplicator = 1.0f; + break; case ENTRY_WATER_ELEMENTAL: multiplicator = 7.5f; break; @@ -1079,18 +1082,10 @@ void Guardian::UpdateAttackPowerAndDamage(bool ranged) if (ranged) return; - float ap_per_agility = 2.0f; - float val = 0.0f; + float ap_per_strength = 2.0f; + float val = GetStat(STAT_STRENGTH) - 20.0f; - if (IsHunterPet()) - { - if (Unit* owner = GetOwner()) - { - // Base attack power value at level 85 is 932 - float agility = std::max(0.0f, owner->GetCreateStat(STAT_AGILITY) - 20.0f); - val += (agility * ap_per_agility) * 2.478f; - } - } + val *= ap_per_strength; UnitMods unitMod = UNIT_MOD_ATTACK_POWER; diff --git a/src/server/scripts/Spells/spell_pet.cpp b/src/server/scripts/Spells/spell_pet.cpp index 03b95467176..75af19500ad 100644 --- a/src/server/scripts/Spells/spell_pet.cpp +++ b/src/server/scripts/Spells/spell_pet.cpp @@ -96,7 +96,9 @@ class spell_warl_pet_scaling_01 : public AuraScript { if (Player* owner = pet->GetOwner()) { - float stamina = owner->GetStat(STAT_STAMINA) * 0.75f; + float stamina = std::min(0.0f, owner->GetStat(STAT_STAMINA) - owner->GetCreateStat(STAT_STAMINA)); + stamina *= 0.3f; + float healthBonus = 0.0f; switch (pet->GetEntry()) { @@ -505,26 +507,19 @@ class spell_hun_pet_scaling_01 : public AuraScript }); } - void CalculateHealthAmount(AuraEffect const* /* aurEff */, int32& amount, bool& canBeRecalculated) + void CalculateHealthAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) { canBeRecalculated = true; if (Pet* pet = GetUnitOwner()->ToPet()) { if (Player* owner = pet->GetOwner()) { - // Base Health value for all pets at level 85 is 32,474 - int32 bonus = int32(owner->GetCreateHealth() * 0.831877f); + float ratio = 10.0f; + if (gtOCTHpPerStaminaEntry const* hpBase = sGtOCTHpPerStaminaStore.LookupEntry((CLASS_HUNTER - 1) * GT_MAX_LEVEL + pet->getLevel() - 1)) + ratio = hpBase->ratio; - // Apply health scaling bonuses based on pet type - float mod = 0.0f; - if (pet->HasAura(SPELL_HUNTER_PET_FEROCITY_MARKER)) - mod = 0.67f; - else if (pet->HasAura(SPELL_HUNTER_PET_TENACITY_MARKER)) - mod = 0.78f; - else if (pet->HasAura(SPELL_HUNTER_PET_CUNNING_MARKER)) - mod = 0.725f; - - bonus += int32(owner->GetMaxHealth() * mod); + float stamina = std::max(0.0f, owner->GetStat(STAT_STAMINA) - owner->GetCreateStat(STAT_STAMINA)); + uint32 bonus = (stamina * 0.45) * ratio; amount = bonus; } } @@ -598,25 +593,8 @@ class spell_hun_pet_scaling_03 : public AuraScript int32 resistanceSchool = GetSpellInfo()->Effects[aurEff->GetEffIndex()].MiscValue; if (Pet* pet = GetUnitOwner()->ToPet()) - { if (Player* owner = pet->GetOwner()) - { - // 11,647 armor baseline at level 85 - int32 bonus = int32(owner->GetCreateHealth() * 0.2983579f); - - // Apply armor scaling bonuses based on pet type - float mod = 0.0f; - if (pet->HasAura(SPELL_HUNTER_PET_FEROCITY_MARKER)) - mod = 0.50f; - else if (pet->HasAura(SPELL_HUNTER_PET_TENACITY_MARKER)) - mod = 0.70f; - else if (pet->HasAura(SPELL_HUNTER_PET_CUNNING_MARKER)) - mod = 0.60f; - - bonus += int32(owner->GetArmor() * mod); - amount = bonus; - } - } + amount = owner->GetArmor() * 0.7f; } void Register() override @@ -1104,7 +1082,7 @@ class spell_mage_water_elemental_scaling_01 : public AuraScript canBeRecalculated = true; if (Pet* pet = GetUnitOwner()->ToPet()) if (Player* owner = pet->GetOwner()) - amount = int32(CalculatePct(owner->GetStat(STAT_STAMINA), 30)); + amount = int32(CalculatePct(std::max(0.0f, owner->GetStat(STAT_STAMINA) - owner->GetCreateStat(STAT_STAMINA)), 30)); } void Register() override