Esempio n. 1
0
        public SpellCastTargets()
        {
            Elevation = 0;
            Speed     = 0;
            strTarget = string.Empty;
            Src       = new SpellDestination();
            Dst       = new SpellDestination();

            ObjectTarget = null;
            ItemTarget   = null;

            ObjectTargetGUID = 0;
            ItemTargetGUID   = 0;
            ItemTargetEntry  = 0;

            TargetMask = 0;
        }
Esempio n. 2
0
        public Spell(Unit caster, SpellInfo info, TriggerCastFlags triggerFlags, ulong originalCasterGUID = 0, bool skipCheck = false)
        {
            m_spellInfo  = SpellMgr.GetSpellForDifficultyFromSpell(info, caster);
            m_caster     = Convert.ToBoolean(info.AttributesEx6 & SpellAttr6.CastByCharmer) ? null : caster;//&& caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster
            m_spellValue = new SpellValue(m_spellInfo);

            m_customError   = SpellCustomErrors.None;
            m_skipCheck     = skipCheck;
            m_selfContainer = null;
            m_referencedFromCurrentSpell = false;
            m_executedCurrently          = false;
            m_needComboPoints            = m_spellInfo.NeedsComboPoints();
            m_comboPointGain             = 0;
            m_delayStart         = 0;
            m_delayAtDamageCount = 0;

            m_applyMultiplierMask = 0;
            m_auraScaleMask       = 0;

            // Get data for type of attack
            switch (m_spellInfo.DmgClass)
            {
            case SpellDmgClass.Melee:
                if (Convert.ToBoolean(m_spellInfo.AttributesEx3 & SpellAttr3.ReqOffhand))
                {
                    m_attackType = WeaponAttackType.OffAttack;
                }
                else
                {
                    m_attackType = WeaponAttackType.BaseAttack;
                }
                break;

            case SpellDmgClass.Ranged:
                m_attackType = m_spellInfo.IsRangedWeaponSpell() ? WeaponAttackType.RangedAttack : WeaponAttackType.BaseAttack;
                break;

            default:
                // Wands
                if (Convert.ToBoolean(m_spellInfo.AttributesEx2 & SpellAttr2.AutorepeatFlag))
                {
                    m_attackType = WeaponAttackType.RangedAttack;
                }
                else
                {
                    m_attackType = WeaponAttackType.BaseAttack;
                }
                break;
            }

            m_spellSchoolMask = info.GetSchoolMask();           // Can be override for some spell (wand shoot for example)

            if (m_attackType == WeaponAttackType.RangedAttack)
            {
                if ((m_caster.getClassMask() & SharedConst.ClassMaskWandUsers) != 0 && m_caster.GetTypeId() == ObjectType.Player)
                {
                    Item pItem = m_caster.ToPlayer().GetWeaponForAttack(WeaponAttackType.RangedAttack);
                    //if (pItem != null)
                    //m_spellSchoolMask = (SpellSchoolMask)(1 << (int)pItem.ItemInfo.ItemSparse.DamageType);
                }
            }

            if (originalCasterGUID != 0)
            {
                m_originalCasterGUID = originalCasterGUID;
            }
            else
            {
                m_originalCasterGUID = m_caster.GetGUID();
            }

            if (m_originalCasterGUID == m_caster.GetGUID())
            {
                m_originalCaster = m_caster;
            }
            else
            {
                m_originalCaster = ObjMgr.GetObject <Unit>(m_caster, m_originalCasterGUID);
                if (m_originalCaster != null && !m_originalCaster.IsInWorld)
                {
                    m_originalCaster = null;
                }
            }

            m_spellState        = SpellState.None;
            _triggeredCastFlags = triggerFlags;
            if (Convert.ToBoolean(info.AttributesEx4 & SpellAttr4.Triggered))
            {
                _triggeredCastFlags = TriggerCastFlags.FullMask;
            }

            m_CastItem     = null;
            m_castItemGUID = 0;

            unitTarget     = null;
            itemTarget     = null;
            gameObjTarget  = null;
            focusObject    = null;
            m_cast_count   = 0;
            m_glyphIndex   = 0;
            m_preCastSpell = 0;
            //m_triggeredByAuraSpell  = null;
            //m_spellAura = null;

            //Auto Shot & Shoot (wand)
            m_autoRepeat = m_spellInfo.IsAutoRepeatRangedSpell();

            m_runesState = 0;
            m_powerCost  = 0;                                       // setup to correct value in Spell::prepare, must not be used before.
            m_casttime   = 0;                                       // setup to correct value in Spell::prepare, must not be used before.
            m_timer      = 0;                                       // will set to castime in prepare

            //m_channelTargetEffectMask = 0;

            // Determine if spell can be reflected back to the caster
            // Patch 1.2 notes: Spell Reflection no longer reflects abilities
            m_canReflect = m_spellInfo.DmgClass == SpellDmgClass.Magic && !Convert.ToBoolean(m_spellInfo.Attributes & SpellAttr0.Ability) &&
                           !Convert.ToBoolean(m_spellInfo.AttributesEx & SpellAttr1.CantBeReflected) && !Convert.ToBoolean(m_spellInfo.Attributes & SpellAttr0.UnaffectedByInvulnerability) &&
                           !m_spellInfo.IsPassive() && !m_spellInfo.IsPositive();

            CleanupTargetList();

            for (var i = 0; i < SharedConst.MaxSpellEffects; ++i)
            {
                m_destTargets[i] = new SpellDestination(m_caster);
            }
        }