Beispiel #1
0
        /// <summary>Called when the Aura gets deactivated</summary>
        /// <param name="cancelled"></param>
        private void Deactivate(bool cancelled)
        {
            if (m_spell.ProcHandlers != null && CasterUnit != null)
            {
                foreach (ProcHandlerTemplate procHandler in m_spell.ProcHandlers)
                {
                    Owner.RemoveProcHandler(procHandler);
                }
            }

            if (m_spell.IsAuraProcHandler)
            {
                m_auras.Owner.RemoveProcHandler(this);
            }
            if (m_spell.IsAreaAura && Owner.EntityId == CasterReference.EntityId)
            {
                AreaAura areaAura = m_auras.Owner.GetAreaAura(m_spell);
                if (areaAura != null)
                {
                    areaAura.IsActivated = false;
                }
            }

            CallAllHandlers(handler => handler.DoRemove(cancelled));
            RemoveFromClient();
        }
Beispiel #2
0
        private void Activate()
        {
            if (m_spell.IsProc && CasterUnit != null && m_spell.ProcHandlers != null)
            {
                foreach (ProcHandlerTemplate procHandler in m_spell.ProcHandlers)
                {
                    Owner.AddProcHandler(new ProcHandler(CasterUnit, Owner, procHandler));
                }
            }

            if (m_spell.IsAuraProcHandler)
            {
                m_auras.Owner.AddProcHandler(this);
            }
            if (m_spell.IsAreaAura && Owner.EntityId == CasterReference.EntityId)
            {
                AreaAura areaAura = m_auras.Owner.GetAreaAura(m_spell);
                if (areaAura != null)
                {
                    areaAura.Start(m_controller, !HasTimeout);
                }
            }

            ApplyNonPeriodicEffects();
            SendToClient();
        }
Beispiel #3
0
        /// <summary>Called when the Aura gets deactivated</summary>
        /// <param name="cancelled"></param>
        private void Deactivate(bool cancelled)
        {
            if (this.m_spell.ProcHandlers != null && this.CasterUnit != null)
            {
                foreach (ProcHandlerTemplate procHandler in this.m_spell.ProcHandlers)
                {
                    this.Owner.RemoveProcHandler(procHandler);
                }
            }

            if (this.m_spell.IsAuraProcHandler)
            {
                this.m_auras.Owner.RemoveProcHandler((IProcHandler)this);
            }
            if (this.m_spell.IsAreaAura && this.Owner.EntityId == this.CasterReference.EntityId)
            {
                AreaAura areaAura = this.m_auras.Owner.GetAreaAura(this.m_spell);
                if (areaAura != null)
                {
                    areaAura.IsActivated = false;
                }
            }

            this.CallAllHandlers((Aura.HandlerDelegate)(handler => handler.DoRemove(cancelled)));
            this.RemoveFromClient();
        }
Beispiel #4
0
        private void Activate()
        {
            if (this.m_spell.IsProc && this.CasterUnit != null && this.m_spell.ProcHandlers != null)
            {
                foreach (ProcHandlerTemplate procHandler in this.m_spell.ProcHandlers)
                {
                    this.Owner.AddProcHandler((IProcHandler) new ProcHandler(this.CasterUnit, this.Owner, procHandler));
                }
            }

            if (this.m_spell.IsAuraProcHandler)
            {
                this.m_auras.Owner.AddProcHandler((IProcHandler)this);
            }
            if (this.m_spell.IsAreaAura && this.Owner.EntityId == this.CasterReference.EntityId)
            {
                AreaAura areaAura = this.m_auras.Owner.GetAreaAura(this.m_spell);
                if (areaAura != null)
                {
                    areaAura.Start(this.m_controller, !this.HasTimeout);
                }
            }

            this.ApplyNonPeriodicEffects();
            this.SendToClient();
        }
Beispiel #5
0
 /// <summary>
 /// Called when an Aura has been dynamically created (not called, when applying via SpellCast)
 /// </summary>
 private void OnCreated(Aura aura)
 {
     if (!aura.Spell.IsAreaAura || !(this.Owner.EntityId == aura.CasterReference.EntityId))
     {
         return;
     }
     AreaAura areaAura = new AreaAura((WorldObject)this.Owner, aura.Spell);
 }
Beispiel #6
0
		void CreateAuras(ref List<CastMiss> missedTargets, ref List<IAura> auras, DynamicObject dynObj)
		{
			auras = AuraListPool.Obtain();
			var allowDead = m_spell.PersistsThroughDeath;

			// create AreaAura
			if (m_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, m_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}",
						m_spell, dynObj, CasterObject, CasterUnit);
				}
			}

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

			// create Aura-Handlers
			for (var i = 0; i < m_handlers.Length; i++)
			{
				var spellHandler = m_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 = m_spell.IsHarmfulFor(CasterReference, target);

				if (!IsPassive && !m_spell.IsPreventionDebuff &&
					(missReason = CheckDebuffResist(target, m_spell, CasterReference.Level, hostile)) != CastMissReason.None)
				{
					// debuff miss
					missedTargets.Add(new CastMiss(target, missReason));
				}
				else
				{
					// create aura
					var newAura = target.Auras.CreateAura(CasterReference, m_spell, info.Handlers, UsedItem, !m_spell.IsPreventionDebuff && !hostile);
					if (newAura != null)
					{
						// check for debuff
						if (!m_spell.IsPreventionDebuff && hostile && target.IsInWorld && target.IsAlive)
						{
							// force combat mode
							target.IsInCombat = true;
						}
						// add Aura now
						auras.Add(newAura);
					}
				}
			}

			//m_auraApplicationInfos.Clear();
			//AuraAppListPool.Recycle(m_auraApplicationInfos);
			m_auraApplicationInfos = null;
		}
Beispiel #7
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;
		}
Beispiel #8
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);
		}
Beispiel #9
0
		void CreateAuras(ref List<CastMiss> missedTargets, ref List<IAura> auras, DynamicObject dynObj)
		{
			auras = AuraListPool.Obtain();
			var allowDead = m_spell.PersistsThroughDeath;

			// create AreaAura
			if (m_spell.IsAreaAura)
			{
				if (allowDead || !(Caster is Unit) || ((Unit)Caster).IsAlive)
				{
					// AreaAura is created at the target location if it is a DynamicObject, else its applied to the caster
					var areaAura = new AreaAura(dynObj ?? Caster, m_spell);
					auras.Add(areaAura);
				}
			}

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

			// create Aura-Handlers
			for (var i = 0; i < m_handlers.Length; i++)
			{
				var spellHandler = m_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 (info.Handlers == null || (!allowDead && !target.IsAlive))
				{
					continue;
				}

				// check for immunities and resistances
				CastMissReason missReason;
				var hostile = m_spell.IsHarmfulFor(Caster, target);
				var casterInfo = Caster.CasterInfo;

				if (!IsPassive && !m_spell.IsPreventionDebuff && 
					(missReason = CheckDebuffResist(target, m_spell, casterInfo.Level, hostile)) != CastMissReason.None)
				{
					missedTargets.Add(new CastMiss(target, missReason));
				}
				else
				{
					var newAura = target.Auras.AddAura(casterInfo, m_spell, info.Handlers, !m_spell.IsPreventionDebuff && !hostile);
					if (newAura != null)
					{
						auras.Add(newAura);

						// check for debuff
						if (!m_spell.IsPreventionDebuff && hostile && target.IsInWorld)
						{
							// trigger Debuff event
							target.OnDebuff(this, newAura);
						}
					}
				}
			}

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