fix(Core/Pets): Hunter pet scaling (#16959)

* fix(Core/Pets): Hunter pet scaling

* Fix pet scaling to properly take DBC data
* Edge case for Devilsaur where the DBC data is whack, therefore we use Spirit Beast data instead
* updated scale calculation based on client function (f09564b9d0)

Co-Authored-By: Ovahlord <18347559+Ovahlord@users.noreply.github.com>

* fix gcc

---------

Co-authored-by: Ovahlord <18347559+Ovahlord@users.noreply.github.com>
This commit is contained in:
Kitzunu
2023-08-09 00:11:41 +02:00
committed by GitHub
parent b31a1a875b
commit 026fe7c962

View File

@@ -2480,34 +2480,34 @@ Player* Pet::GetOwner() const
float Pet::GetNativeObjectScale() const
{
CreatureFamilyEntry const* creatureFamily = sCreatureFamilyStore.LookupEntry(GetCreatureTemplate()->family);
if (creatureFamily && creatureFamily->minScale > 0.0f && getPetType() == HUNTER_PET)
{
float scale;
if (GetLevel() >= creatureFamily->maxScaleLevel)
scale = creatureFamily->maxScale;
else if (GetLevel() <= creatureFamily->minScaleLevel)
scale = creatureFamily->minScale;
else
scale = creatureFamily->minScale + float(GetLevel() - creatureFamily->minScaleLevel) / creatureFamily->maxScaleLevel * (creatureFamily->maxScale - creatureFamily->minScale);
uint8 ctFamily = GetCreatureTemplate()->family;
if (CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId()))
{
if (displayInfo->scale > 1.f && GetCreatureTemplate()->IsExotic())
{
// Exotic pets have a scale of 1
scale = 1.0f;
}
else
{
scale *= displayInfo->scale;
}
}
// hackfix: Edge case where DBC scale values for DEVILSAUR pets make them too small.
// Therefore we take data from spirit beast instead.
if (ctFamily && ctFamily == CREATURE_FAMILY_DEVILSAUR)
ctFamily = CREATURE_FAMILY_SPIRIT_BEAST;
CreatureFamilyEntry const* creatureFamily = sCreatureFamilyStore.LookupEntry(ctFamily);
if (creatureFamily && creatureFamily->minScale > 0.0f && getPetType() & HUNTER_PET)
{
float minScaleLevel = creatureFamily->minScaleLevel;
uint8 level = getLevel();
float minLevelScaleMod = level >= minScaleLevel ? (level / minScaleLevel) : 0.0f;
float maxScaleMod = creatureFamily->maxScaleLevel - minScaleLevel;
if (minLevelScaleMod > maxScaleMod)
minLevelScaleMod = maxScaleMod;
float scaleMod = creatureFamily->maxScaleLevel != minScaleLevel ? minLevelScaleMod / maxScaleMod : 0.f;
float scale = (creatureFamily->maxScale - creatureFamily->minScale) * scaleMod + creatureFamily->minScale;
return scale;
}
// Fallback value if the conditions are not met
return 1.0f;
// take value for non-hunter pets from DB
return Guardian::GetNativeObjectScale();
}
std::string Pet::GenerateActionBarData() const