Trinitycore: [3.3.5/master] Incorrect pet size

Created on 30 Dec 2016  路  11Comments  路  Source: TrinityCore/TrinityCore

Description:
If you compare the size of pets on retail and trinity you can easily see, that pets on trinity are smaller in comparison to those from retail, here is one example (1 level pandaren hunter):
Retail:
retail

Trinity:
trinity

Branch(es): master

TC rev. hash/commit: 5c1503f85976

TDB version: TDB 703.00

Operating system: Windows 7 Ultimate with SP1

Branch-3.3.5a Branch-master Comp-Core Priority-Cosmetic Sub-PetMinion

Most helpful comment

@tkrokli doesnt change anything
@MrSmite hope the calculation comment is not serious, please go back to the operators priority (still its math basics). As for the dbc, im just saying current formulars are incorrect. If dbc values are correct and mean what they mean, they miss some other factor.

All 11 comments

IIRC The pet scale has always been incorrect with TC. It needs to be adjusted for 7.x from 3.3.5a, due to the pet scaled with you as you level.

Somewhere the min and max size is way off.

src/server/game/Entities/Pet/Pet.cpp:838

 //scale
    CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family);
    if (cFamily && cFamily->MinScale > 0.0f && petType == HUNTER_PET)
    {
        float scale;
        if (getLevel() >= cFamily->MaxScaleLevel)
            scale = cFamily->MaxScale;
        else if (getLevel() <= cFamily->MinScaleLevel)
            scale = cFamily->MinScale;
        else
            scale = cFamily->MinScale + float(getLevel() - cFamily->MinScaleLevel) / cFamily->MaxScaleLevel * (cFamily->MaxScale - cFamily->MinScale);

        SetObjectScale(scale);
    }

I changed this to always scale in range 0.5, 1.0 and it seemed just about right (had no more complaints from players about pet size, at least for 3.3.5a).

    CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family);
    if (cFamily && cFamily->minScale > 0.0f && petType == HUNTER_PET)
    {
        float scale;
        if (getLevel() >= cFamily->maxScaleLevel)
            scale = 1.0f;
        else if (getLevel() <= cFamily->minScaleLevel)
            scale = 0.5f;
        else
            scale = 0.5f + 0.5f * float(getLevel() - cFamily->minScaleLevel) / float(cFamily->maxScaleLevel  - cFamily->minScaleLevel);

        SetObjectScale(scale);
    }

Pet scale in 3.3.5 is fine, the pet is supposed to grow as it levels. I currently have a level 26 Bear which is noticeably larger than it was when I tamed it at 10.

@Heaven31415

The scale values are taken from DBC so setting them to 1.0f and 0.5f is a hack. From our sources: CreatureDisplayInfo.dbc. And here is what that DBC holds:

https://wowdev.wiki/DB/CreatureDisplayInfo
Scale - Float - Default scale
Stacks (by multiplying) with other scale settings (in creature_template, applied auras...).

@xinef1

0.5f + 0.5f is 1.0f so that math is kindof unnecessary:

scale = 0.5f + 0.5f * float(getLevel() - cFamily->minScaleLevel) / float(cFamily->maxScaleLevel - cFamily->minScaleLevel);

@MrSmite read all ifs, this is to scale between min and max. Im not saying my code is ok, but current is wrong for sure. Just because someone named dbc Field that way doesnt mean it is exactly that, check exotic pets for example and some other families to see that pets at 80 are smaller than on retail.

@xinef1

That website I quoted is the go-to DBC reference site, it is where the majority of the DBC editing tools get their info. I've been around Trinity since the beginning and they even used that site for the initial database. The first database created and used a table for every DBC file instead of the way the core does it now.

Also, I understand the IF statements and I don't necessarily disagree, the general rule around Trinity is that you don't assign arbitrary values to things taken from the DBC without good reason.

As for the math, what I was referring to is the part where you add 0.5+0.5 and then multiply it by the result of everything in the parenthesis. Since 0.5+0.5 = 1 then it is unnecessary.

eg:
0.5 + 0.5 * (1 + 2 + 7) = 1 * (1 + 2 + 7) = (1 + 2 + 7)

Doesn't multiplication take presedence over addition in C++, so you need to add more parentheses for the calculation to be different enough from the other one? What if you add the following parentheses:

    CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family);
    if (cFamily && cFamily->minScale > 0.0f && petType == HUNTER_PET)
    {
        float scale;
        if (getLevel() >= cFamily->maxScaleLevel)
            scale = 1.0f;
        else if (getLevel() <= cFamily->minScaleLevel)
            scale = 0.5f;
        else
            scale = 0.5f + ((0.5f * float(getLevel()) - cFamily->minScaleLevel)) / float(cFamily->maxScaleLevel  - cFamily->minScaleLevel);

        SetObjectScale(scale);
    }

@tkrokli doesnt change anything
@MrSmite hope the calculation comment is not serious, please go back to the operators priority (still its math basics). As for the dbc, im just saying current formulars are incorrect. If dbc values are correct and mean what they mean, they miss some other factor.

The cringe here is unreal

@xinef1

I looked at your original equation again and didn't notice they were separate groups. In this part:

float(getLevel() - cFamily->minScaleLevel) / float(cFamily->maxScaleLevel

I missed the closing bracket between minScaleLevel) / float(cFamily and thought the whole thing was one large bracketed group. Honestly thought I could've done without the snarky comments about _order of operation_ and _basic math_. A simple mention about reading the equation again is enough.

As for the DBC goes, yes, the values are directly from the DBC so it's possible there is some other factor involved. As pets level up though they do become proper size so if anything it only seems noticeable when they are low level.

I have to argue as the difference is most visible with exotic pets at level 80, sorry for the abusive comment.

The size difference is apparent particularly when you are on the login screen, the Devilsaur for instance is just a little taller than the Draenai female hunter. When logged in, the Devilsaur is significantly smaller than the player.

c5fa08afc1d1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jonne733 picture Jonne733  路  3Comments

funjoker picture funjoker  路  3Comments

Blasphemous picture Blasphemous  路  3Comments

Keader picture Keader  路  3Comments

tje3d picture tje3d  路  3Comments