Example #1
0
		/// <summary>
		/// Stack or removes the given Aura, if possible.
		/// Returns whether the given incompatible Aura was removed or stacked.
		/// <param name="err">Ok, if stacked or no incompatible Aura was found</param>
		/// </summary>
		public static bool CheckStackOrOverride(Aura oldAura, CasterInfo caster, Spell spell, ref SpellFailedReason err)
		{
			if (oldAura.Spell.IsPreventionDebuff)
			{
				err = SpellFailedReason.AuraBounced;
				return false;
			}

			if (oldAura.Spell.CanStack && oldAura.Spell == spell)
			{
				// stack aura
				oldAura.Stack(caster);
			}
			else
			{
				if (caster == oldAura.CasterInfo)
				{
					if (spell != oldAura.Spell &&
						spell.AuraCasterGroup != null &&
						spell.AuraCasterGroup == oldAura.Spell.AuraCasterGroup &&
						spell.AuraCasterGroup.Count > 1)
					{
						err = SpellFailedReason.AuraBounced;
						return false;
					}
				}
				else if (!spell.CanOverride(oldAura.Spell))
				{
					err = SpellFailedReason.AuraBounced;
					return false;
				}

				// cancel previously existing Aura
				return oldAura.TryRemove(true);
			}
			return false;
		}