Example #1
1
bool Guardian::UpdateStats(Stats stat)
{
    if (stat > STAT_SPIRIT)
        return false;

    // value = ((base_value * base_pct) + total_value) * total_pct
    float value  = GetTotalStatValue(stat);

    Unit* owner = GetOwner();
    if (stat == STAT_STAMINA)
    {
        if (owner && (isHunterPet() || owner->getClass() == CLASS_WARLOCK))
            value += float(owner->GetStat(stat)) * 0.3f;
    }
    //warlock's and mage's pets gain 30% of owner's intellect
    else if (stat == STAT_INTELLECT && isPet())
    {
        if (owner && (owner->getClass() == CLASS_WARLOCK || owner->getClass() == CLASS_MAGE))
            value += float(owner->GetStat(stat)) * 0.3f;
    }

    SetStat(stat, int32(value));

    switch(stat)
    {
    case STAT_STRENGTH:
        UpdateAttackPowerAndDamage();
        break;
    case STAT_AGILITY:
        UpdateArmor();
        break;
    case STAT_STAMINA:
        UpdateMaxHealth();
        break;
    case STAT_INTELLECT:
        UpdateMaxPower(POWER_MANA);
        break;
    case STAT_SPIRIT:
    default:
        break;
    }

    return true;
}
Example #2
1
bool Pet::UpdateStats(Stats stat)
{
    if(stat > STAT_SPIRIT)
        return false;

    // value = ((base_value * base_pct) + total_value) * total_pct
    float value  = GetTotalStatValue(stat);

    Unit *owner = GetOwner();
    if ( stat == STAT_STAMINA )
    {
        if(owner)
        {
            if (getPetType() == HUNTER_PET)
                value += float(owner->GetStat(stat)) * 0.4725f;
            else
            {
                CreatureInfo const *cinfo = GetCreatureInfo();
                CreatureFamily petFamily = (CreatureFamily) cinfo->family;
                switch (petFamily)
                {
                case CREATURE_FAMILY_FELHUNTER:
                    value += float(owner->GetStat(stat)) * 0.7125f;
                    break;
                case CREATURE_FAMILY_VOIDWALKER:
                    value += float(owner->GetStat(stat)) * 0.825f;
                    break;
                case CREATURE_FAMILY_FELGUARD:
                    value += float(owner->GetStat(stat)) * 0.825f;
                    break;
                case CREATURE_FAMILY_SUCCUBUS:
                    value += float(owner->GetStat(stat)) * 0.6825f;
                    break;
                case CREATURE_FAMILY_IMP:
                    value += float(owner->GetStat(stat)) * 0.63f;
                    break;
                default:
                    value += float(owner->GetStat(stat)) * 0.3f;
                    break;
                }
            }
        }
    }
    //warlock's and mage's pets gain 30% of owner's intellect
    else if ( stat == STAT_INTELLECT && getPetType() == SUMMON_PET )
    {
        if(owner && (owner->getClass() == CLASS_WARLOCK || owner->getClass() == CLASS_MAGE) )
            value += float(owner->GetStat(stat)) * 0.3f;
    }

    SetStat(stat, int32(value));

    switch(stat)
    {
    case STAT_STRENGTH:
        UpdateAttackPowerAndDamage();
        break;
    case STAT_AGILITY:
        UpdateArmor();
        break;
    case STAT_STAMINA:
        UpdateMaxHealth();
        break;
    case STAT_INTELLECT:
        UpdateMaxPower(POWER_MANA);
        break;
    case STAT_SPIRIT:
    default:
        break;
    }

    return true;
}