Example #1
0
        private GameObject GoCreator()
        {
            var portal =
                Portal.Create(
                    new WorldLocation((MapId)FromMap, new Vector3(FromX + 1000 * FromMap, FromY + 1000 * FromMap)),
                    new WorldLocation((MapId)ToMap, new Vector3(ToX + 1000 * ToMap, ToY + 1000 * ToMap)));
            var spell = new Spell()
            {
                Id = 50000, Range = new SimpleRange(0, 10)
            };
            var effect = new SpellEffect(spell, 0)
            {
                MiscValue  = ToMap,
                MiscValueB = ToX + 1000 * ToMap,
                MiscValueC = ToY + 1000 * ToMap,
                Radius     = 3f,
                EffectType = SpellEffectType.PortalTeleport, ImplicitTargetA = ImplicitSpellTargetType.AllAroundLocation
            };

            spell.Effects    = new SpellEffect[1];
            spell.Duration   = int.MaxValue;
            spell.IsAreaAura = true;

            /*spell.AuraAmplitude = 10000;
             * spell.CastDelay = 10000;*/
            spell.Effects[0] = effect;
            spell.Initialize();
            spell.Init2();
            var aura = new AreaAura(portal, spell);

            aura.Start(null, true);
            return(portal);
        }
Example #2
0
        protected internal override void InitGO(GameObject trap)
        {
            trap.Level       = this.Level;
            trap.IsStealthed = this.Stealthed;
            if (trap.HasAreaAuras)
            {
                return;
            }
            if (this.Spell != null)
            {
                AreaAura areaAura = new AreaAura((WorldObject)trap, this.Spell, (ISpellParameters)this);
            }

            trap.m_IsTrap = true;
        }
Example #3
0
        protected internal override void InitGO(GameObject trap)
        {
            trap.Level       = Level;
            trap.IsStealthed = Stealthed;
            if (trap.HasAreaAuras)
            {
                return;
            }
            if (Spell != null)
            {
                AreaAura areaAura = new AreaAura(trap, Spell, this);
            }

            trap.m_IsTrap = true;
        }
Example #4
0
 /// <summary>
 /// Called when AreaAura is created
 /// </summary>
 internal void AddAreaAura(AreaAura aura)
 {
     if (m_areaAuras == null)
     {
         m_areaAuras = new List <AreaAura>(2);
     }
     else if (aura.Spell.AttributesExB.HasFlag(SpellAttributesExB.ExclusiveAreaAura))
     {
         // cannot be applied with other AreaAuras of that type
         foreach (var aaura in m_areaAuras)
         {
             if (aura.Spell.AttributesExB.HasFlag(SpellAttributesExB.ExclusiveAreaAura))
             {
                 aaura.Remove(true);
                 break;
             }
         }
     }
     m_areaAuras.Add(aura);
 }
Example #5
0
        /// <summary>
        /// Called by AreaAura.Remove
        /// </summary>
        internal bool CancelAreaAura(AreaAura aura)
        {
            if (m_areaAuras == null)
            {
                return(false);
            }

            if (m_areaAuras.Remove(aura))
            {
                if (this is Unit)
                {
                    ((Unit)this).Auras.Remove(aura.Spell);
                }
                else if (m_areaAuras.Count == 0 && (IsTrap || this is DynamicObject))
                {
                    // remove trap & dynamic object when aura gets removed
                    Delete();
                }
                return(true);
            }
            return(false);
        }
Example #6
0
        void CreateAuras(ref List <MissedTarget> missedTargets, ref List <IAura> auras, DynamicObject dynObj)
        {
            auras = AuraListPool.Obtain();

            var allowDead = Spell.PersistsThroughDeath;

            // create AreaAura
            if (Spell.IsAreaAura)
            {
                if (dynObj != null || (CasterObject != null && (allowDead || !(CasterObject is Unit) || ((Unit)CasterObject).IsAlive)))
                {
                    // AreaAura is created at the target location if it is a DynamicObject, else its applied to the caster
                    var aaura = new AreaAura(dynObj ?? CasterObject, Spell);
                    if (dynObj != null)
                    {
                        // also start the area aura
                        auras.Add(aaura);
                    }
                    // else: Is coupled to an Aura instance
                }
                else
                {
                    LogManager.GetCurrentClassLogger().Warn(
                        "Tried to cast Spell {0} with invalid dynObj or Caster - dynObj: {1}, CasterObject: {2}, CasterUnit: {3}",
                        Spell, dynObj, CasterObject, CasterUnit);
                }
            }

            // remove missed targets
            for (var i = m_auraApplicationInfos.Count - 1; i >= 0; i--)
            {
                var app = m_auraApplicationInfos[i];
                if (!Targets.Contains(app.Target))
                {
                    m_auraApplicationInfos.RemoveAt(i);
                }
            }
            if (m_auraApplicationInfos.Count == 0)
            {
                return;
            }

            // create Aura-Handlers
            for (var i = 0; i < Handlers.Length; i++)
            {
                var spellHandler = Handlers[i];
                if (spellHandler is ApplyAuraEffectHandler)
                {
                    ((ApplyAuraEffectHandler)spellHandler).AddAuraHandlers(m_auraApplicationInfos);
                }
            }
            if (missedTargets == null)
            {
                missedTargets = CastMissListPool.Obtain();
            }

            // apply all new Auras
            for (var i = 0; i < m_auraApplicationInfos.Count; i++)
            {
                var info   = m_auraApplicationInfos[i];
                var target = info.Target;

                if (!target.IsInContext)
                {
                    continue;
                }

                if (info.Handlers == null || (!allowDead && !target.IsAlive))
                {
                    continue;
                }

                // check for immunities and resistances
                CastMissReason missReason;
                var            hostile = Spell.IsHarmfulFor(CasterReference, target);

                if (!IsPassive && !Spell.IsPreventionDebuff &&
                    (missReason = CheckDebuffResist(target, Spell, CasterReference.Level, hostile)) != CastMissReason.None)
                {
                    // debuff miss
                    missedTargets.Add(new MissedTarget(target, missReason));
                }
                else
                {
                    // create aura
                    var newAura = target.Auras.CreateAura(CasterReference, Spell, info.Handlers, TargetItem, !Spell.IsPreventionDebuff && !hostile);
                    if (newAura != null)
                    {
                        // check for debuff and if the spell causes no threat we aren't put in combat
                        if (!Spell.IsPreventionDebuff && !((Spell.AttributesExC & SpellAttributesExC.NoInitialAggro) != 0) && hostile && target.IsInWorld && target.IsAlive)
                        {
                            // force combat mode
                            target.IsInCombat = true;
                            if (target is NPC && CasterUnit != null)
                            {
                                ((NPC)target).ThreatCollection.AddNewIfNotExisted(CasterUnit);
                            }
                        }
                        // add Aura now
                        auras.Add(newAura);
                    }
                }
            }

            //m_auraApplicationInfos.Clear();
            //AuraAppListPool.Recycle(m_auraApplicationInfos);
            m_auraApplicationInfos = null;
        }