コード例 #1
0
        public override void AddCooldown(Spell spell, Item casterItem)
        {
            bool flag   = casterItem != null && casterItem.Template.UseSpell != null;
            int  millis = 0;

            if (flag)
            {
                millis = casterItem.Template.UseSpell.Cooldown;
            }
            if (millis == 0)
            {
                millis = spell.GetCooldown(this.Owner);
            }
            if (millis <= 0)
            {
                return;
            }
            SpellIdCooldown spellIdCooldown = new SpellIdCooldown()
            {
                SpellId = spell.Id,
                Until   = DateTime.Now + TimeSpan.FromMilliseconds((double)millis)
            };

            if (flag)
            {
                spellIdCooldown.ItemId = casterItem.Template.Id;
            }
            this.m_idCooldowns.Add((ISpellIdCooldown)spellIdCooldown);
            this.OwnerChar.Map.CallDelayed(500,
                                           (Action)(() => Asda2SpellHandler.SendSetSkillCooldownResponse(this.OwnerChar, spell)));
            this.OwnerChar.Map.CallDelayed(millis,
                                           (Action)(() => Asda2SpellHandler.SendClearCoolDown(this.OwnerChar, spell.RealId)));
        }
コード例 #2
0
        public override void AddCooldown(Spell spell, Item casterItem)
        {
            var itemSpell = casterItem != null && casterItem.Template.UseSpell != null;

            var cd = 0;

            if (itemSpell)
            {
                cd = casterItem.Template.UseSpell.Cooldown;
            }
            if (cd == 0)
            {
                cd = spell.GetCooldown(Owner);
            }


            if (cd > 0)
            {
                var idCooldown = new SpellIdCooldown
                {
                    SpellId = spell.Id,
                    Until   = (DateTime.Now + TimeSpan.FromMilliseconds(cd))
                };

                if (itemSpell)
                {
                    idCooldown.ItemId = casterItem.Template.Id;
                }
                m_idCooldowns.Add(idCooldown);

                OwnerChar.Map.CallDelayed(500, () => Asda2SpellHandler.SendSetSkillCooldownResponse(OwnerChar, spell));
                OwnerChar.Map.CallDelayed(cd, () => Asda2SpellHandler.SendClearCoolDown(OwnerChar, spell.RealId));
            }
        }
コード例 #3
0
ファイル: Aura.cs プロジェクト: 0xFh/Asda2-Project
        /// <summary>Removes all of this Aura's occupied fields</summary>
        protected void RemoveFromClient()
        {
            if (!IsVisible)
            {
                return;
            }
            Character owner1 = Owner as Character;
            NPC       owner2 = Owner as NPC;

            if (owner2 != null)
            {
                Asda2CombatHandler.SendMonstrStateChangedResponse(owner2, Asda2NpcState.Ok);
            }
            if (owner1 == null)
            {
                return;
            }
            Asda2SpellHandler.SendBuffEndedResponse(owner1, Spell.RealId);
            if (owner1.IsInGroup)
            {
                Asda2GroupHandler.SendPartyMemberBuffInfoResponse(owner1);
            }
            if (owner1.SoulmateCharacter == null)
            {
                return;
            }
            Asda2SoulmateHandler.SendSoulmateBuffUpdateInfoResponse(owner1);
        }
コード例 #4
0
 public override void OnAttack(WCell.RealmServer.Misc.DamageAction action)
 {
     if (action.Spell != null)
     {
         return;
     }
     if (Owner.SplinterEffect > 0)
     {
         var targets = Owner.GetObjectsInRadius(2.5f, ObjectTypes.Attackable, false);
         foreach (var worldObject in targets)
         {
             if (!Owner.IsHostileWith(worldObject) || ReferenceEquals(worldObject, Owner))
             {
                 continue;
             }
             if (Utility.Random(0, 100000) > Owner.SplinterEffectChange)
             {
                 continue;
             }
             var targetChr = worldObject as Character;
             var targetNpc = worldObject as NPC;
             var a         = Owner.GetUnusedAction();
             a.Damage   = (int)(Owner.RandomDamage * Owner.SplinterEffect);
             a.Attacker = worldObject as Unit;
             a.Victim   = worldObject as Unit;
             a.DoAttack();
             if (Owner is Character)
             {
                 Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse(null, targetChr, targetNpc, a.ActualDamage);
             }
             action.OnFinished();
         }
     }
     base.OnAttack(action);
 }
コード例 #5
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();
                    }
                }
            }
        }
コード例 #6
0
 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();
                 }
             }
         }
     }
 }
コード例 #7
0
ファイル: Aura.cs プロジェクト: 0xFh/Asda2-Project
        /// <summary>
        /// Removes all of this Aura's occupied fields
        /// </summary>
        protected void RemoveFromClient()
        {
            if (!IsVisible)
            {
                return;
            }
            var character = Owner as Character;
            var owner     = Owner as NPC;

            if (owner != null)
            {
                Asda2CombatHandler.SendMonstrStateChangedResponse(owner, Asda2NpcState.Ok);
            }
            if (character != null)
            {
                Asda2SpellHandler.SendBuffEndedResponse(character, Spell.RealId);
                if (character.IsInGroup)
                {
                    Asda2GroupHandler.SendPartyMemberBuffInfoResponse(character);
                }
                if (character.SoulmateCharacter != null)
                {
                    Asda2SoulmateHandler.SendSoulmateBuffUpdateInfoResponse(character);
                }
            }

            //AuraHandler.SendRemoveAura(m_auras.Owner, this);
        }
コード例 #8
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();
                        }
                    }
                }
            }
        }
コード例 #9
0
 public static void SendAuraUpdate(Unit owner, Aura aura)
 {
     if (owner is NPC)
     {
         Asda2CombatHandler.SendNpcBuffedResponse((NPC)owner, aura);
     }
     else
     {
         if (!(owner is Character))
         {
             return;
         }
         Character character = (Character)owner;
         if (!character.CanMove)
         {
             Asda2MovmentHandler.SendEndMoveByFastInstantRegularMoveResponse(character);
         }
         Asda2SpellHandler.SendCharacterBuffedResponse(character, aura);
         if (character.IsInGroup)
         {
             Asda2GroupHandler.SendPartyMemberBuffInfoResponse(character);
         }
         if (character.SoulmateCharacter == null)
         {
             return;
         }
         Asda2SoulmateHandler.SendSoulmateBuffUpdateInfoResponse(character);
     }
 }
コード例 #10
0
ファイル: AuraHandler.cs プロジェクト: 0xFh/Asda2-Project
        public static void SendAuraUpdate(Unit owner, Aura aura)
        {
            if (owner is NPC)
            {
                Asda2CombatHandler.SendNpcBuffedResponse((NPC)owner, aura);
            }
            else if (owner is Character)
            {
                var chr = (Character)owner;
                if (!chr.CanMove)
                {
                    Asda2MovmentHandler.SendEndMoveByFastInstantRegularMoveResponse(chr);
                }
                Asda2SpellHandler.SendCharacterBuffedResponse(chr, aura);
                if (chr.IsInGroup)
                {
                    Asda2GroupHandler.SendPartyMemberBuffInfoResponse(chr);
                }
                if (chr.SoulmateCharacter != null)
                {
                    Asda2SoulmateHandler.SendSoulmateBuffUpdateInfoResponse(chr);
                }
            }

            /*if (!owner.IsAreaActive) return;
             *  using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AURA_UPDATE))
             *  {
             *          owner.EntityId.WritePacked(packet);
             *
             *          WriteAura(aura, packet);
             *
             *          owner.SendPacketToArea(packet);
             *  }*/
        }
コード例 #11
0
        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);
        }
コード例 #12
0
 public override void OnDefend(DamageAction action)
 {
     action.Victim.AddMessage((Action)(() =>
     {
         if (!action.Victim.MayAttack((IFactionMember)action.Attacker))
         {
             return;
         }
         action.Attacker.DealSpellDamage(action.Victim, this.SpellEffect,
                                         action.Damage * (this.SpellEffect.MiscValue / 100), true, true, false, true);
         Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse(this.m_aura.CasterUnit as Character,
                                                                  this.Owner as Character, this.Owner as NPC, action.ActualDamage);
     }));
     if (this.SpellEffect.MiscValueB == 0)
     {
         action.Resisted = action.Damage;
     }
     else
     {
         if (this.SpellEffect.MiscValueB != 20)
         {
             return;
         }
         Character casterUnit = this.m_aura.CasterUnit as Character;
         if (casterUnit == null || !casterUnit.IsInGroup)
         {
             return;
         }
         foreach (GroupMember groupMember in casterUnit.Group)
         {
             groupMember.Character.Heal(action.Damage * this.SpellEffect.MiscValue / 100, (Unit)null,
                                        (SpellEffect)null);
         }
     }
 }
コード例 #13
0
        /// <summary>
        /// Teaches a new spell to the unit. Also sends the spell learning animation, if applicable.
        /// </summary>
        private void AddSpell(Spell spell, bool sendPacket)
        {
            if (spell.Ability != null)
            {
                Skill skill = this.OwnerChar.Skills[spell.Ability.Skill.Id] ??
                              this.OwnerChar.Skills.Add(spell.Ability.Skill, true);
                if (skill.CurrentTierSpell == null || skill.CurrentTierSpell.SkillTier < spell.SkillTier)
                {
                    skill.CurrentTierSpell = spell;
                }
            }

            if (!this.m_byId.ContainsKey(spell.SpellId))
            {
                Character          ownerChar = this.OwnerChar;
                int                specIndex = this.GetSpecIndex(spell);
                List <SpellRecord> spellList = this.GetSpellList(spell);
                SpellRecord        record    = new SpellRecord(spell.SpellId, ownerChar.EntityId.Low, specIndex);
                record.SaveLater();
                spellList.Add(record);
                base.AddSpell(spell);
            }

            if (!this.m_sendPackets || !sendPacket)
            {
                return;
            }
            if (spell.Level == 1)
            {
                Asda2SpellHandler.SendSkillLearnedFirstTimeResponse(this.OwnerChar.Client, spell.RealId,
                                                                    spell.CooldownTime);
            }
            Asda2SpellHandler.SendSkillLearnedResponse(SkillLearnStatus.Ok, this.OwnerChar, (uint)spell.RealId,
                                                       spell.Level);
        }
コード例 #14
0
        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();
        }
コード例 #15
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();
        }
コード例 #16
0
        /// <summary>
        /// Teaches a new spell to the unit. Also sends the spell learning animation, if applicable.
        /// </summary>
        void AddSpell(Spell spell, bool sendPacket)
        {
            // make sure the char knows the skill that this spell belongs to
            if (spell.Ability != null)
            {
                var skill = OwnerChar.Skills[spell.Ability.Skill.Id];
                if (skill == null)
                {
                    // learn new skill
                    skill = OwnerChar.Skills.Add(spell.Ability.Skill, true);
                }

                if (skill.CurrentTierSpell == null || skill.CurrentTierSpell.SkillTier < spell.SkillTier)
                {
                    // upgrade tier
                    skill.CurrentTierSpell = spell;
                }
            }

            if (!m_byId.ContainsKey(spell.SpellId))
            {
                var owner = OwnerChar;


                var specIndex = GetSpecIndex(spell);
                var spells    = GetSpellList(spell);
                var newRecord = new SpellRecord(spell.SpellId, owner.EntityId.Low, specIndex);
                newRecord.SaveLater();
                spells.Add(newRecord);

                base.AddSpell(spell);
            }
            if (m_sendPackets && sendPacket)
            {
                if (spell.Level == 1)
                {
                    Asda2SpellHandler.SendSkillLearnedFirstTimeResponse(OwnerChar.Client, spell.RealId, spell.CooldownTime);
                }
                Asda2SpellHandler.SendSkillLearnedResponse(SkillLearnStatus.Ok, OwnerChar, (uint)spell.RealId, spell.Level);
                //SpellHandler.SendLearnedSpell(owner.Client, spell.Id);

                /*if (!spell.IsPassive)
                 * {
                 *  SpellHandler.SendVisual(owner, 362);	// ouchy: Unnamed constants
                 * }*/
            }
        }
コード例 #17
0
        /// <summary>
        /// Clears all pending spell cooldowns.
        /// </summary>
        public override void ClearCooldowns()
        {
            // send cooldown updates to client
            foreach (var cd in m_idCooldowns)
            {
                Asda2SpellHandler.SendClearCoolDown(OwnerChar, (SpellId)cd.SpellId);
            }

            foreach (var spell in m_byId.Values)
            {
                foreach (var cd in m_categoryCooldowns)
                {
                    if (spell.Category == cd.CategoryId)
                    {
                        Asda2SpellHandler.SendClearCoolDown(OwnerChar, spell.SpellId);
                        break;
                    }
                }
            }

            // remove and delete all cooldowns
            var cds    = m_idCooldowns.ToArray();
            var catCds = m_categoryCooldowns.ToArray();

            m_idCooldowns.Clear();
            m_categoryCooldowns.Clear();

            RealmServer.IOQueue.AddMessage(new Message(() =>
            {
                foreach (var cooldown in cds)
                {
                    if (cooldown is ActiveRecordBase)
                    {
                        ((ActiveRecordBase)cooldown).Delete();
                    }
                }
                foreach (var cooldown in catCds)
                {
                    if (cooldown is ActiveRecordBase)
                    {
                        ((ActiveRecordBase)cooldown).Delete();
                    }
                }
            }));
        }
コード例 #18
0
        /// <summary>Clears all pending spell cooldowns.</summary>
        public override void ClearCooldowns()
        {
            foreach (ISpellIdCooldown idCooldown in this.m_idCooldowns)
            {
                Asda2SpellHandler.SendClearCoolDown(this.OwnerChar, (SpellId)idCooldown.SpellId);
            }
            foreach (Spell spell in this.m_byId.Values)
            {
                foreach (ISpellCategoryCooldown categoryCooldown in this.m_categoryCooldowns)
                {
                    if ((int)spell.Category == (int)categoryCooldown.CategoryId)
                    {
                        Asda2SpellHandler.SendClearCoolDown(this.OwnerChar, spell.SpellId);
                        break;
                    }
                }
            }

            ISpellIdCooldown[]       cds    = this.m_idCooldowns.ToArray();
            ISpellCategoryCooldown[] catCds = this.m_categoryCooldowns.ToArray();
            this.m_idCooldowns.Clear();
            this.m_categoryCooldowns.Clear();
            ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((IMessage) new Message((Action)(() =>
            {
                foreach (ISpellIdCooldown spellIdCooldown in cds)
                {
                    if (spellIdCooldown is ActiveRecordBase)
                    {
                        ((ActiveRecordBase)spellIdCooldown).Delete();
                    }
                }

                foreach (ISpellCategoryCooldown categoryCooldown in catCds)
                {
                    if (categoryCooldown is ActiveRecordBase)
                    {
                        ((ActiveRecordBase)categoryCooldown).Delete();
                    }
                }
            })));
        }
コード例 #19
0
        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();
        }
コード例 #20
0
        /// <summary>Clears the cooldown for this spell</summary>
        public override void ClearCooldown(Spell cooldownSpell, bool alsoCategory = true)
        {
            Character ownerChar = this.OwnerChar;

            Asda2SpellHandler.SendClearCoolDown(ownerChar, cooldownSpell.SpellId);
            if (alsoCategory && cooldownSpell.Category != 0U)
            {
                foreach (Spell spell in this.m_byId.Values)
                {
                    if ((int)spell.Category == (int)cooldownSpell.Category)
                    {
                        Asda2SpellHandler.SendClearCoolDown(ownerChar, spell.SpellId);
                    }
                }
            }

            ISpellIdCooldown idCooldown =
                this.m_idCooldowns.RemoveFirst <ISpellIdCooldown>(
                    (Func <ISpellIdCooldown, bool>)(cd => (int)cd.SpellId == (int)cooldownSpell.Id));
            ISpellCategoryCooldown catCooldown = this.m_categoryCooldowns.RemoveFirst <ISpellCategoryCooldown>(
                (Func <ISpellCategoryCooldown, bool>)(cd => (int)cd.CategoryId == (int)cooldownSpell.Category));

            if (!(idCooldown is ActiveRecordBase) && !(catCooldown is ActiveRecordBase))
            {
                return;
            }
            ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((IMessage) new Message((Action)(() =>
            {
                if (idCooldown is ActiveRecordBase)
                {
                    ((ActiveRecordBase)idCooldown).Delete();
                }
                if (!(catCooldown is ActiveRecordBase))
                {
                    return;
                }
                ((ActiveRecordBase)catCooldown).Delete();
            })));
        }
コード例 #21
0
        /// <summary>
        /// Clears the cooldown for this spell
        /// </summary>
        public override void ClearCooldown(Spell cooldownSpell, bool alsoCategory = true)
        {
            var ownerChar = OwnerChar;

            // send cooldown update to client
            Asda2SpellHandler.SendClearCoolDown(ownerChar, cooldownSpell.SpellId);
            if (alsoCategory && cooldownSpell.Category != 0)
            {
                foreach (var spell in m_byId.Values)
                {
                    if (spell.Category == cooldownSpell.Category)
                    {
                        Asda2SpellHandler.SendClearCoolDown(ownerChar, spell.SpellId);
                    }
                }
            }

            // remove and delete
            ISpellIdCooldown       idCooldown  = m_idCooldowns.RemoveFirst(cd => cd.SpellId == cooldownSpell.Id);
            ISpellCategoryCooldown catCooldown = m_categoryCooldowns.RemoveFirst(cd => cd.CategoryId == cooldownSpell.Category);

            // enqueue task
            if (idCooldown is ActiveRecordBase || catCooldown is ActiveRecordBase)
            {
                RealmServer.IOQueue.AddMessage(new Message(() =>
                {
                    if (idCooldown is ActiveRecordBase)
                    {
                        ((ActiveRecordBase)idCooldown).Delete();
                    }
                    if (catCooldown is ActiveRecordBase)
                    {
                        ((ActiveRecordBase)catCooldown).Delete();
                    }
                }
                                                           ));
            }
        }
コード例 #22
0
        /// <summary>
        /// Apply the effect (by default to all targets of the targettype)
        /// Returns the reason for why it went wrong or SpellFailedReason.None
        /// </summary>
        public virtual void Apply()
        {
            if (m_targets != null)
            {
                var            npc     = Cast.CasterObject as NPC;
                var            chr     = Cast.CasterChar;
                DamageAction[] actions = null;
                for (CurrentTargetNo = 0; CurrentTargetNo < m_targets.Count; CurrentTargetNo++)
                {
                    var target = m_targets[CurrentTargetNo];
                    if (!target.IsInContext)
                    {
                        continue;
                    }
                    Apply(target, ref actions);

                    if (m_cast == null)
                    {
                        // spell got cancelled
                        return;
                    }
                }

                if (actions == null && Effect.Spell.Effect0_EffectType != SpellEffectType.DamageFromPrcAtack && Effect.Spell.Effect0_EffectType != SpellEffectType.InstantKill)
                {
                    //animate without actions
                    if (chr != null)
                    {
                        Asda2SpellHandler.SendAnimateSkillStrikeResponse(chr, Effect.Spell.RealId, null, InitialTarget);
                    }

                    else if (npc != null)
                    {
                        Asda2SpellHandler.SendMonstrUsedSkillResponse(npc, Effect.Spell.RealId, InitialTarget, actions);
                    }
                    return;
                }
                if (Effect.EffectType != SpellEffectType.CastAnotherSpell && actions != null)
                {
                    if (chr != null)
                    {
                        Asda2SpellHandler.SendAnimateSkillStrikeResponse(chr, Effect.Spell.RealId, actions,
                                                                         InitialTarget);
                    }
                    else if (npc != null)
                    {
                        Asda2SpellHandler.SendMonstrUsedSkillResponse(npc, Effect.Spell.RealId, InitialTarget, actions);
                    }
                    else
                    {
                        Cast.CasterObject.SendMessageToArea(
                            string.Format(
                                "Spell {0} has wrong target[{1}] or caster[{2}]. Please report to developers.",
                                Effect.Spell, InitialTarget, m_cast.CasterUnit), Color.LightGray);
                    }
                }
            }
            else
            {
                log.Warn("SpellEffectHandler has no targets, but Apply() is not overridden: " + this);
            }
        }
コード例 #23
0
        /// <summary>
        /// Apply the effect (by default to all targets of the targettype)
        /// Returns the reason for why it went wrong or SpellFailedReason.None
        /// </summary>
        public virtual void Apply()
        {
            if (this.m_targets != null)
            {
                NPC            casterObject = this.Cast.CasterObject as NPC;
                Character      casterChar   = this.Cast.CasterChar;
                DamageAction[] actions      = (DamageAction[])null;
                for (this.CurrentTargetNo = 0; this.CurrentTargetNo < this.m_targets.Count; ++this.CurrentTargetNo)
                {
                    WorldObject target = this.m_targets[this.CurrentTargetNo];
                    if (target.IsInContext)
                    {
                        this.Apply(target, ref actions);
                        if (this.m_cast == null)
                        {
                            return;
                        }
                    }
                }

                if (actions == null && this.Effect.Spell.Effect0_EffectType != SpellEffectType.DamageFromPrcAtack &&
                    this.Effect.Spell.Effect0_EffectType != SpellEffectType.InstantKill)
                {
                    if (casterChar != null)
                    {
                        Asda2SpellHandler.SendAnimateSkillStrikeResponse(casterChar, this.Effect.Spell.RealId,
                                                                         (DamageAction[])null, this.InitialTarget);
                    }
                    else
                    {
                        if (casterObject == null)
                        {
                            return;
                        }
                        Asda2SpellHandler.SendMonstrUsedSkillResponse(casterObject, this.Effect.Spell.RealId,
                                                                      this.InitialTarget, actions);
                    }
                }
                else
                {
                    if (this.Effect.EffectType == SpellEffectType.CastAnotherSpell || actions == null)
                    {
                        return;
                    }
                    if (casterChar != null)
                    {
                        Asda2SpellHandler.SendAnimateSkillStrikeResponse(casterChar, this.Effect.Spell.RealId, actions,
                                                                         this.InitialTarget);
                    }
                    else if (casterObject != null)
                    {
                        Asda2SpellHandler.SendMonstrUsedSkillResponse(casterObject, this.Effect.Spell.RealId,
                                                                      this.InitialTarget, actions);
                    }
                    else
                    {
                        this.Cast.CasterObject.SendMessageToArea(
                            string.Format(
                                "Spell {0} has wrong target[{1}] or caster[{2}]. Please report to developers.",
                                (object)this.Effect.Spell, (object)this.InitialTarget,
                                (object)this.m_cast.CasterUnit), Color.LightGray);
                    }
                }
            }
            else
            {
                SpellEffectHandler.log.Warn("SpellEffectHandler has no targets, but Apply() is not overridden: " +
                                            (object)this);
            }
        }