Core/Auras: Prevent getting negative scale with auras

Port From (https://github.com/TrinityCore/TrinityCore/commit/679e9910e09a55dd1743f236dbd99b7fa48fe9c1)
This commit is contained in:
hondacrx
2022-02-18 16:40:32 -05:00
parent e7eba5907d
commit a031530b2a
5 changed files with 39 additions and 19 deletions
+19
View File
@@ -1458,6 +1458,25 @@ namespace Game.Entities
return base.GetOwner().ToPlayer();
}
public override float GetNativeObjectScale()
{
var creatureFamily = CliDB.CreatureFamilyStorage.LookupByKey(GetCreatureTemplate().Family);
if (creatureFamily != null && creatureFamily.MinScale > 0.0f && GetPetType() == PetType.Hunter)
{
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);
return scale;
}
return base.GetNativeObjectScale();
}
public override void SetDisplayId(uint modelId, float displayScale = 1f)
{
base.SetDisplayId(modelId, displayScale);