Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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);
            }
        }