Example #1
1
void Guardian::UpdateAttackPowerAndDamage(bool ranged)
{
    if (ranged)
        return;

    float val = 0.0f;
    float bonusAP = 0.0f;
    UnitMods unitMod = UNIT_MOD_ATTACK_POWER;

    if (GetEntry() == 416)                                   // imp's attack power
        val = GetStat(STAT_STRENGTH) - 10.0f;
    else
        val = 2 * GetStat(STAT_STRENGTH) - 20.0f;

    Unit* owner = GetOwner();
    if (owner && owner->GetTypeId() == TYPEID_PLAYER)
    {
        if (isHunterPet())                      //hunter pets benefit from owner's attack power
        {
            bonusAP = owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.22f;
            SetBonusDamage(int32(owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.125f));
        }
        //demons benefit from warlocks shadow or fire damage
        else if (isPet() && owner->getClass() == CLASS_WARLOCK)
        {
            int32 fire  = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FIRE);
            int32 shadow = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_SHADOW);
            int32 maximum  = (fire > shadow) ? fire : shadow;
            if (maximum < 0)
                maximum = 0;
            SetBonusDamage(int32(maximum * 0.15f));
            bonusAP = maximum * 0.57f;
        }
        //water elementals benefit from mage's frost damage
        else if (GetEntry() == 510 && owner->getClass() == CLASS_MAGE)
        {
            int32 frost = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FROST)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FROST);
            if (frost < 0)
                frost = 0;
            SetBonusDamage(int32(frost * 0.4f));
        }
    }

    SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, val + bonusAP);

    //in BASE_VALUE of UNIT_MOD_ATTACK_POWER for creatures we store data of meleeattackpower field in DB
    float base_attPower  = GetModifierValue(unitMod, BASE_VALUE) * GetModifierValue(unitMod, BASE_PCT);
    float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE);
    float attPowerMultiplier = GetModifierValue(unitMod, TOTAL_PCT) - 1.0f;

    //UNIT_FIELD_(RANGED)_ATTACK_POWER field
    SetInt32Value(UNIT_FIELD_ATTACK_POWER, (int32)base_attPower);
    //UNIT_FIELD_(RANGED)_ATTACK_POWER_MODS field
    SetInt32Value(UNIT_FIELD_ATTACK_POWER_MODS, (int32)attPowerMod);
    //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field
    SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER, attPowerMultiplier);

    //automatically update weapon damage after attack power modification
    UpdateDamagePhysical(BASE_ATTACK);
}
Example #2
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 #3
1
void Guardian::UpdateResistances(uint32 school)
{
    if (school > SPELL_SCHOOL_NORMAL)
    {
        float value  = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school));

        Unit* owner = GetOwner();
        // hunter and warlock pets gain 40% of owner's resistance
        if (owner && (isHunterPet() || (isPet() && owner->getClass() == CLASS_WARLOCK)))
            value += float(owner->GetResistance(SpellSchools(school))) * 0.4f;

        SetResistance(SpellSchools(school), int32(value));
    }
    else
        UpdateArmor();
}
Example #4
1
void Guardian::UpdateArmor()
{
    float value = 0.0f;
    float bonus_armor = 0.0f;
    UnitMods unitMod = UNIT_MOD_ARMOR;

    Unit* owner = GetOwner();
    // hunter and warlock pets gain 35% of owner's armor value
    if (owner && (isHunterPet() || (isPet() && owner->getClass() == CLASS_WARLOCK)))
        bonus_armor = 0.35f * float(owner->GetArmor());

    value  = GetModifierValue(unitMod, BASE_VALUE);
    value *= GetModifierValue(unitMod, BASE_PCT);
    value += GetStat(STAT_AGILITY) * 2.0f;
    value += GetModifierValue(unitMod, TOTAL_VALUE) + bonus_armor;
    value *= GetModifierValue(unitMod, TOTAL_PCT);

    SetArmor(int32(value));
}
        void UpdateAI(const uint32 diff)
        {
            if (!UpdateVictim())
                return;

            if (TargetTimer <= diff && Enslaved == false)
            {
                EnslaveTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                TargetTimer = 1000;
            } else TargetTimer -= diff;

            if (EnslaveEndTimer <= diff && Enslaved == true)
            {
                me->SetReactState(REACT_AGGRESSIVE);
                EnslaveTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                EnslaveTarget->RemoveAurasDueToSpell(SPELL_ENSLAVE);
                EnslaveTarget->RemoveAurasDueToSpell(SPELL_ENSLAVE_BUFF);
                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                Enslaved = false;
                EnslaveTimer = 30000;
                AbsorbMagicTimer = 20000;
                MindFogTimer = urand(6000,12000);
                UnrelentingAgonyTimer = 10000;
                EnslaveEndTimer = 90000;
            } else EnslaveEndTimer -= diff;

            if (EnslaveTimer <= diff && Enslaved == false)
            {
                if (EnslaveTarget)
                {
                    DoZoneInCombat();
                    me->SetReactState(REACT_PASSIVE);
                    DoCast(EnslaveTarget, SPELL_ENSLAVE);
                    DoCast(EnslaveTarget, SPELL_ENSLAVE_BUFF);
                    me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    DoScriptText(RAND(SAY_MIND_CONTROL_1,SAY_MIND_CONTROL_2,SAY_MIND_CONTROL_3), me);
                    Enslaved = true;
                    EnslaveTimer = 180000;
                    AbsorbMagicTimer = 180000;
                    MindFogTimer = 180000;
                    UnrelentingAgonyTimer = 180000;
                    EnslaveEndTimer = DUNGEON_MODE(60000,30000);
                    CastTimer = 2000;
                }
                EnslaveTimer = 1000;
            } else EnslaveTimer -= diff;

            if (EnslaveTarget && Enslaved == true)
                if (EnslaveTarget->HealthBelowPct(50))
                {
                    me->SetReactState(REACT_AGGRESSIVE);
                    EnslaveTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                    EnslaveTarget->RemoveAurasDueToSpell(SPELL_ENSLAVE);
                    EnslaveTarget->RemoveAurasDueToSpell(SPELL_ENSLAVE_BUFF);
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    Enslaved = false;
                    EnslaveTimer = 30000;
                    AbsorbMagicTimer = 20000;
                    MindFogTimer = urand(6000,12000);
                    UnrelentingAgonyTimer = 10000;
                }

            if (CastTimer <= diff && Enslaved == true)
            {
                if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, NotCharmedTargetSelector()))
                {
                    switch(EnslaveTarget->getClass())
                    {
                    case CLASS_DRUID:
                        if (urand(0,1))
                            EnslaveTarget->CastSpell(pTarget, 8921, false);
                        else
                            EnslaveTarget->CastSpell(me, 774, false);
                        break;
                    case CLASS_HUNTER:
                        EnslaveTarget->CastSpell(pTarget, RAND(2643, 1978), false);
                        break;
                    case CLASS_MAGE:
                        EnslaveTarget->CastSpell(pTarget, RAND(44614, 30455), false);
                        break;
                    case CLASS_WARLOCK:
                        EnslaveTarget->CastSpell(pTarget, RAND(980, 686), true);
                        break;
                    case CLASS_WARRIOR:
                        EnslaveTarget->CastSpell(pTarget, RAND(46924, 845), false);
                        break;
                    case CLASS_PALADIN:
                        if (urand(0,1))
                            EnslaveTarget->CastSpell(pTarget, 853, false);
                        else
                            EnslaveTarget->CastSpell(me, 20473, false);
                        break;
                    case CLASS_PRIEST:
                        if (urand(0,1))
                            EnslaveTarget->CastSpell(pTarget, 34914, false);
                        else
                            EnslaveTarget->CastSpell(me, 139, false);
                        break;
                    case CLASS_SHAMAN:
                        if (urand(0,1))
                            EnslaveTarget->CastSpell(pTarget, 421, false);
                        else
                            EnslaveTarget->CastSpell(me, 61295, false);
                        break;
                    case CLASS_ROGUE:
                        EnslaveTarget->CastSpell(pTarget, RAND(16511, 1329), false);
                        break;
                    case CLASS_DEATH_KNIGHT:
                        if (urand(0,1))
                            EnslaveTarget->CastSpell(pTarget, 45462, true);
                        else
                            EnslaveTarget->CastSpell(pTarget, 49184, true);
                        break;
                    }
                }
                CastTimer = 3000;
            } else CastTimer -= diff;

            if (AbsorbMagicTimer <= diff && Enslaved == false)
            {
                DoCast(me, SPELL_ABSORB_MAGIC);
                AbsorbMagicTimer = urand(15000,20000);
            } else AbsorbMagicTimer -= diff;

            if (MindFogTimer <= diff && Enslaved == false)
            {
                DoCast(me, SPELL_MIND_FOG_SUMMON);
                DoScriptText(SAY_MIND_FOG, me);
                MindFogTimer = 18000;
            } else MindFogTimer -= diff;

            if (UnrelentingAgonyTimer <= diff && Enslaved == false)
            {
                DoCastAOE(SPELL_UNRELENTING_AGONY);
                UnrelentingAgonyTimer = 20000;
            } else UnrelentingAgonyTimer -= diff;

            DoMeleeAttackIfReady();
        }
Example #6
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;
}