protected override void Apply()
        {
            Unit owner = Owner;

            if (!owner.IsAlive)
            {
                return;
            }
            float num = (float)(SpellEffect.MiscValue * (m_aura.CasterUnit != null
                             ? (m_aura.CasterUnit.Class == ClassId.AtackMage ||
                                m_aura.CasterUnit.Class == ClassId.SupportMage ||
                                m_aura.CasterUnit.Class == ClassId.HealMage
                               ? m_aura.CasterUnit.RandomMagicDamage
                               : m_aura.CasterUnit.RandomDamage)
                             : 666.0) / 100.0 * 3.0);

            if (m_aura.Spell.Mechanic == SpellMechanic.Bleeding)
            {
                int bleedBonusPercent = m_aura.Auras.GetBleedBonusPercent();
                num += (float)((num * (double)bleedBonusPercent + 50.0) / 100.0);
                m_aura.Owner.IncMechanicCount(SpellMechanic.Bleeding, false);
            }

            DamageAction damageAction = owner.DealSpellDamage(m_aura.CasterUnit, m_spellEffect, (int)num,
                                                              true, true, false, false);

            if (damageAction == null)
            {
                return;
            }
            Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse(m_aura.CasterUnit as Character,
                                                                     Owner as Character, Owner as NPC, damageAction.ActualDamage);
            damageAction.OnFinished();
        }
        public override void OnAttack(DamageAction action)
        {
            if (action.Spell != null)
            {
                return;
            }
            if ((double)this.Owner.SplinterEffect > 0.0)
            {
                foreach (WorldObject objectsInRadiu in (IEnumerable <WorldObject>) this.Owner.GetObjectsInRadius <Unit>(
                             2.5f, ObjectTypes.Attackable, false, int.MaxValue))
                {
                    if (this.Owner.IsHostileWith((IFactionMember)objectsInRadiu) &&
                        !object.ReferenceEquals((object)objectsInRadiu, (object)this.Owner) &&
                        Utility.Random(0, 100000) <= this.Owner.SplinterEffectChange)
                    {
                        Character    targetChr    = objectsInRadiu as Character;
                        NPC          targetNpc    = objectsInRadiu as NPC;
                        DamageAction unusedAction = this.Owner.GetUnusedAction();
                        unusedAction.Damage =
                            (int)((double)this.Owner.RandomDamage * (double)this.Owner.SplinterEffect);
                        unusedAction.Attacker = objectsInRadiu as Unit;
                        unusedAction.Victim   = objectsInRadiu as Unit;
                        int num = (int)unusedAction.DoAttack();
                        if (this.Owner is Character)
                        {
                            Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse((Character)null, targetChr,
                                                                                     targetNpc, unusedAction.ActualDamage);
                        }
                        action.OnFinished();
                    }
                }
            }

            base.OnAttack(action);
        }
示例#3
0
        public override void OnAttack(DamageAction action)
        {
            if (action.Spell == null || action.SpellEffect.AuraType == AuraType.ExplosiveArrow)
            {
                return;
            }
            var targets = action.Victim.GetObjectsInRadius(6, ObjectTypes.Unit, false);

            foreach (var worldObject in targets)
            {
                if (!worldObject.IsHostileWith(action.Attacker))
                {
                    continue;
                }
                var unit = worldObject as Unit;
                if (unit == null)
                {
                    continue;
                }
                var a = unit.DealSpellDamage(action.Attacker, SpellEffect, (int)(action.Attacker.RandomDamage * SpellEffect.MiscValue / 190), true, true, false, false);
                if (a == null)
                {
                    continue;
                }
                WCell.RealmServer.Handlers.Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse(m_aura.CasterUnit as Character, Owner as Character, unit as NPC, a.ActualDamage);
                action.OnFinished();
            }
        }
示例#4
0
        protected override void Apply()
        {
            IList <WorldObject> objectsInRadius =
                this.Owner.GetObjectsInRadius <Unit>(6f, ObjectTypes.Unit, false, int.MaxValue);

            if (objectsInRadius == null)
            {
                return;
            }
            foreach (WorldObject worldObject in (IEnumerable <WorldObject>)objectsInRadius)
            {
                Unit unit = worldObject as Unit;
                if (unit != null && this.Owner != null &&
                    (this.m_aura != null && unit.IsHostileWith((IFactionMember)this.Owner)))
                {
                    DamageAction damageAction = unit.DealSpellDamage(this.Owner, this.SpellEffect,
                                                                     (int)((double)this.Owner.RandomDamage * (double)this.SpellEffect.MiscValue / 100.0), true,
                                                                     true, false, false);
                    if (damageAction != null)
                    {
                        Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse(this.m_aura.CasterUnit as Character,
                                                                                 unit as Character, unit as NPC, damageAction.ActualDamage);
                        damageAction.OnFinished();
                    }
                }
            }
        }
 public override void OnAttack(DamageAction action)
 {
     if (action.Spell == null || action.SpellEffect.AuraType == AuraType.ExplosiveArrow)
     {
         return;
     }
     foreach (WorldObject objectsInRadiu in (IEnumerable <WorldObject>)action.Victim.GetObjectsInRadius <Unit>(6f,
                                                                                                               ObjectTypes.Unit, false, int.MaxValue))
     {
         if (objectsInRadiu.IsHostileWith((IFactionMember)action.Attacker))
         {
             Unit unit = objectsInRadiu as Unit;
             if (unit != null)
             {
                 DamageAction damageAction = unit.DealSpellDamage(action.Attacker, this.SpellEffect,
                                                                  (int)((double)action.Attacker.RandomDamage * (double)this.SpellEffect.MiscValue / 100.0),
                                                                  true, true, false, false);
                 if (damageAction != null)
                 {
                     Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse(
                         this.m_aura.CasterUnit as Character, this.Owner as Character, unit as NPC,
                         damageAction.ActualDamage);
                     action.OnFinished();
                 }
             }
         }
     }
 }
示例#6
0
        protected override void Remove(bool cancelled)
        {
            Unit casterUnit = m_aura.CasterUnit;

            if (casterUnit == null)
            {
                return;
            }
            foreach (WorldObject objectsInRadiu in Owner.GetObjectsInRadius(6f,
                                                                            ObjectTypes.Unit, false, int.MaxValue))
            {
                if (casterUnit.IsHostileWith(objectsInRadiu))
                {
                    Unit unit = objectsInRadiu as Unit;
                    if (unit != null)
                    {
                        DamageAction damageAction = unit.DealSpellDamage(casterUnit, SpellEffect,
                                                                         (int)(casterUnit.RandomDamage * (double)SpellEffect.MiscValue / 100.0),
                                                                         true, true, false, false);
                        if (damageAction != null)
                        {
                            Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse(
                                m_aura.CasterUnit as Character, Owner as Character, unit as NPC,
                                damageAction.ActualDamage);
                            damageAction.OnFinished();
                        }
                    }
                }
            }
        }
示例#7
0
        protected override void Apply()
        {
            IList <WorldObject> objectsInRadius =
                this.Owner.GetObjectsInRadius <Unit>(3f, ObjectTypes.Unit, false, int.MaxValue);
            bool flag = false;

            foreach (WorldObject worldObject in (IEnumerable <WorldObject>)objectsInRadius)
            {
                Unit unit = worldObject as Unit;
                if (unit != null && unit.IsHostileWith((IFactionMember)this.Owner))
                {
                    flag = true;
                    break;
                }
            }

            if (!flag)
            {
                return;
            }
            foreach (WorldObject objectsInRadiu in (IEnumerable <WorldObject>) this.Owner.GetObjectsInRadius <Unit>(12f,
                                                                                                                    ObjectTypes.Unit, false, int.MaxValue))
            {
                Unit pos = objectsInRadiu as Unit;
                if (pos != null && pos.IsHostileWith((IFactionMember)this.Owner))
                {
                    if (this.SpellEffect.MiscValueB == 1)
                    {
                        Spell spell = SpellHandler.Get(775U);
                        pos.Auras.CreateAndStartAura(this.Owner.SharedReference, spell, false, (Item)null);
                    }
                    else if (this.SpellEffect.MiscValueB == 0)
                    {
                        float dist = pos.GetDist((IHasPosition)this.Owner);
                        float num  = 1f;
                        if ((double)dist >= 3.0)
                        {
                            num /= (float)Math.Pow((double)dist, 0.600000023841858);
                        }
                        DamageAction damageAction = pos.DealSpellDamage(this.Owner, this.SpellEffect,
                                                                        (int)((double)this.Owner.RandomDamage * (double)this.SpellEffect.MiscValue / 100.0 *
                                                                              (double)num), true, true, false, false);
                        if (damageAction != null)
                        {
                            if (this.m_aura != null)
                            {
                                Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse(
                                    this.m_aura.CasterUnit as Character, objectsInRadiu as Character,
                                    objectsInRadiu as NPC, damageAction.ActualDamage);
                            }
                            damageAction.OnFinished();
                        }
                    }
                }
            }

            this.Aura.Cancel();
        }
        protected override void Apply()
        {
            int dmg   = Owner.Health * SpellEffect.MiscValue / 100;
            NPC owner = Owner as NPC;

            if (owner != null && owner.Entry.IsBoss)
            {
                return;
            }
            DamageAction damageAction =
                Owner.DealSpellDamage(Owner, SpellEffect, dmg, true, true, false, false);

            if (damageAction == null || m_aura == null)
            {
                return;
            }
            Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse(m_aura.CasterUnit as Character,
                                                                     Owner as Character, Owner as NPC, damageAction.ActualDamage);
            damageAction.OnFinished();
            Aura.Cancel();
        }
示例#9
0
        /// <summary>
        /// Do a single attack on the target using given weapon, ability and action.
        /// </summary>
        public ProcHitFlags Strike(IAsda2Weapon weapon, DamageAction action, Unit target, SpellCast ability)
        {
            ProcHitFlags procHitFlags = ProcHitFlags.None;

            EnsureContext();
            if (!IsAlive)
            {
                return(procHitFlags);
            }

            if (!target.IsInContext || !target.IsAlive)
            {
                return(procHitFlags);
            }

            if (weapon == null)
            {
                log.Info("Trying to strike without weapon: " + this);
                return(procHitFlags);
            }

            //if (IsMovementControlled)
            //{
            //    // stop running when landing a hit
            //    m_Movement.Stop();
            //}

            target.IsInCombat = true;

            action.Victim   = target;
            action.Attacker = this;
            action.Weapon   = weapon;

            if (ability != null)
            {
                action.Schools     = ability.Spell.SchoolMask;
                action.SpellEffect = ability.Spell.Effects[0];

                // calc damage
                GetWeaponDamage(action, weapon, ability);
                procHitFlags = action.DoAttack();
                if (ability.Spell.AttributesExC.HasFlag(SpellAttributesExC.RequiresTwoWeapons) && m_offhandWeapon != null)
                {
                    // also strike with offhand
                    action.Reset(this, target, m_offhandWeapon);
                    GetWeaponDamage(action, m_offhandWeapon, ability);
                    procHitFlags       |= action.DoAttack();
                    m_lastOffhandStrike = Environment.TickCount;
                }
            }
            else
            {
                // no combat ability
                m_extraAttacks += 1;
                do
                {
                    // calc damage
                    GetWeaponDamage(action, weapon, null);

                    action.Schools = weapon.Damages.AllSchools();
                    if (action.Schools == DamageSchoolMask.None)
                    {
                        action.Schools = DamageSchoolMask.Physical;
                    }

                    // normal attack
                    action.DoAttack();
                } while (--m_extraAttacks > 0);
            }
            action.OnFinished();
            return(procHitFlags);
        }
示例#10
0
        public static void SendAnimateSkillStrikeResponse(Character caster, short spellRealId, DamageAction[] actions,
                                                          Unit initialTarget)
        {
            SendSetAtackStateGuiResponse(caster);
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.AnimateSkillStrike))
            {
                NPC       npc       = initialTarget as NPC;
                Character character = initialTarget as Character;
                if (character == null && npc == null)
                {
                    caster.SendSystemMessage(string.Format("Wrong spell target {0}. can't animate cast. SpellId {1}",
                                                           initialTarget, spellRealId));
                }
                packet.WriteInt16(caster.SessionId);
                packet.WriteInt16(spellRealId);
                packet.WriteInt16(6);
                packet.WriteByte(1);
                packet.WriteByte(npc == null ? (byte)1 : (byte)0);
                if (character != null && actions != null)
                {
                    for (int index = 0; index < actions.Length; ++index)
                    {
                        DamageAction action = actions[index];
                        if (action != null)
                        {
                            SpellHitStatus spellHitStatus = SpellHitStatus.Ok;
                            if (action.IsCritical)
                            {
                                spellHitStatus = SpellHitStatus.Crit;
                            }
                            else if (action.Damage == 0)
                            {
                                spellHitStatus = SpellHitStatus.Miss;
                            }
                            else if (action.Blocked > 0)
                            {
                                spellHitStatus = SpellHitStatus.Bloced;
                            }
                            if (index < 16)
                            {
                                packet.WriteUInt16(character.SessionId);
                                packet.WriteInt32(action.ActualDamage);
                                packet.WriteInt32((byte)spellHitStatus);
                                packet.WriteInt32(797);
                                packet.WriteSkip(unk12);
                            }

                            action.OnFinished();
                        }
                    }
                }
                else if (actions != null)
                {
                    for (int index = 0; index < actions.Length; ++index)
                    {
                        DamageAction action = actions[index];
                        if (action != null)
                        {
                            SpellHitStatus spellHitStatus = SpellHitStatus.Ok;
                            if (action.IsCritical)
                            {
                                spellHitStatus = SpellHitStatus.Crit;
                            }
                            else if (action.Damage == 0)
                            {
                                spellHitStatus = SpellHitStatus.Miss;
                            }
                            else if (action.Blocked > 0)
                            {
                                spellHitStatus = SpellHitStatus.Bloced;
                            }
                            ushort val = 0;
                            if (initialTarget is NPC)
                            {
                                val = action.Victim == null || !(action.Victim is NPC)
                  ? ushort.MaxValue
                  : action.Victim.UniqIdOnMap;
                            }
                            if (index < 16)
                            {
                                packet.WriteUInt16(val);
                                packet.WriteInt32(action.ActualDamage);
                                packet.WriteInt32((byte)spellHitStatus);
                                packet.WriteInt32(797);
                                packet.WriteSkip(unk12);
                            }

                            action.OnFinished();
                        }
                    }
                }
                else if (character != null)
                {
                    packet.WriteUInt16(character.SessionId);
                    packet.WriteInt32(0);
                    packet.WriteInt32(3);
                    packet.WriteInt32(0);
                    packet.WriteSkip(unk12);
                }

                caster.SendPacketToArea(packet, true, false, Locale.Any, new float?());
            }
        }