Example #1
0
        public void _ApplyWeaponDamage(byte slot, Item item, bool apply)
        {
            ItemTemplate     proto   = item.GetTemplate();
            WeaponAttackType attType = GetAttackBySlot(slot, proto.GetInventoryType());

            if (!IsInFeralForm() && apply && !CanUseAttackType(attType))
            {
                return;
            }

            float damage = 0.0f;
            uint  itemLevel = item.GetItemLevel(this);
            float minDamage, maxDamage;

            proto.GetDamage(itemLevel, out minDamage, out maxDamage);

            if (minDamage > 0)
            {
                damage = apply ? minDamage : SharedConst.BaseMinDamage;
                SetBaseWeaponDamage(attType, WeaponDamageRange.MinDamage, damage);
            }

            if (maxDamage > 0)
            {
                damage = apply ? maxDamage : SharedConst.BaseMaxDamage;
                SetBaseWeaponDamage(attType, WeaponDamageRange.MaxDamage, damage);
            }

            SpellShapeshiftFormRecord shapeshift = CliDB.SpellShapeshiftFormStorage.LookupByKey(GetShapeshiftForm());

            if (proto.GetDelay() != 0 && !(shapeshift != null && shapeshift.CombatRoundTime != 0))
            {
                SetBaseAttackTime(attType, apply ? proto.GetDelay() : SharedConst.BaseAttackTime);
            }

            int weaponBasedAttackPower           = apply ? (int)(proto.GetDPS(itemLevel) * 6.0f) : 0;

            switch (attType)
            {
            case WeaponAttackType.BaseAttack:
                SetMainHandWeaponAttackPower(weaponBasedAttackPower);
                break;

            case WeaponAttackType.OffAttack:
                SetOffHandWeaponAttackPower(weaponBasedAttackPower);
                break;

            case WeaponAttackType.RangedAttack:
                SetRangedWeaponAttackPower(weaponBasedAttackPower);
                break;

            default:
                break;
            }

            if (CanModifyStats() && (damage != 0 || proto.GetDelay() != 0))
            {
                UpdateDamagePhysical(attType);
            }
        }
Example #2
0
        public void _ApplyWeaponDamage(uint slot, Item item, bool apply)
        {
            ItemTemplate     proto   = item.GetTemplate();
            WeaponAttackType attType = WeaponAttackType.BaseAttack;
            float            damage  = 0.0f;

            if (slot == EquipmentSlot.MainHand && (proto.GetInventoryType() == InventoryType.Ranged || proto.GetInventoryType() == InventoryType.RangedRight))
            {
                attType = WeaponAttackType.RangedAttack;
            }
            else if (slot == EquipmentSlot.OffHand)
            {
                attType = WeaponAttackType.OffAttack;
            }

            float minDamage, maxDamage;

            item.GetDamage(this, out minDamage, out maxDamage);

            if (minDamage > 0)
            {
                damage = apply ? minDamage : SharedConst.BaseMinDamage;
                SetBaseWeaponDamage(attType, WeaponDamageRange.MinDamage, damage);
            }

            if (maxDamage > 0)
            {
                damage = apply ? maxDamage : SharedConst.BaseMaxDamage;
                SetBaseWeaponDamage(attType, WeaponDamageRange.MaxDamage, damage);
            }

            SpellShapeshiftFormRecord shapeshift = CliDB.SpellShapeshiftFormStorage.LookupByKey(GetShapeshiftForm());

            if (proto.GetDelay() != 0 && !(shapeshift != null && shapeshift.CombatRoundTime != 0))
            {
                SetBaseAttackTime(attType, apply ? proto.GetDelay() : SharedConst.BaseAttackTime);
            }

            if (CanModifyStats() && (damage != 0 || proto.GetDelay() != 0))
            {
                UpdateDamagePhysical(attType);
            }
        }