Пример #1
0
        /// <summary>
        /// Get an Aura that is incompatible with the one represented by the given spell
        /// </summary>
        /// <returns>Whether or not another Aura may be applied</returns>
        public Aura GetAura(ObjectReference caster, AuraIndexId id, Spell spell)
        {
            Aura aura1 = this[id];

            if (aura1 != null)
            {
                return(aura1);
            }
            if (spell.AuraCasterGroup != null)
            {
                int num = 0;
                foreach (Aura aura2 in this.m_AuraArray)
                {
                    if (aura2.CasterReference.EntityId == caster.EntityId &&
                        spell.AuraCasterGroup == aura2.Spell.AuraCasterGroup)
                    {
                        ++num;
                        if (num >= spell.AuraCasterGroup.MaxCount)
                        {
                            return(aura2);
                        }
                    }
                }
            }

            return((Aura)null);
        }
Пример #2
0
        /// <summary>
        /// Get an Aura that is incompatible with the one represented by the given spell
        /// </summary>
        /// <returns>Whether or not another Aura may be applied</returns>
        public Aura GetAura(ObjectReference caster, AuraIndexId id, Spell spell)
        {
            var oldAura = this[id];

            if (oldAura != null)
            {
                return(oldAura);
            }
            else
            {
                // no aura found
                // check for per-caster-restrictions
                if (spell.AuraCasterGroup != null)
                {
                    var count = 0;
                    foreach (var aura in m_AuraArray)
                    {
                        if (aura.CasterReference.EntityId == caster.EntityId && spell.AuraCasterGroup == aura.Spell.AuraCasterGroup)
                        {
                            count++;
                            if (count >= spell.AuraCasterGroup.MaxCount)
                            {
                                return(aura);
                            }
                        }
                    }
                }
            }
            return(null);
        }
Пример #3
0
        public bool Remove(uint auraUID, bool positive)
        {
            var id = new AuraIndexId {
                AuraUID = auraUID, IsPositive = positive
            };

            return(Remove(id));
        }
Пример #4
0
 public Aura this[AuraIndexId auraId]
 {
     get
     {
         Aura aura;
         this.m_auras.TryGetValue(auraId, out aura);
         return(aura);
     }
 }
Пример #5
0
        /// <summary>
        /// Stack or removes the Aura represented by the given spell, if possible.
        /// Returns true if there is no incompatible Aura or if the Aura could be removed.
        /// <param name="err">Ok, if stacked or no incompatible Aura is blocking a new Aura</param>
        /// </summary>
        internal bool PrepareStackOrOverride(ObjectReference caster, AuraIndexId id, Spell spell, ref SpellFailedReason err, SpellCast triggeringCast = null)
        {
            var oldAura = GetAura(caster, id, spell);

            if (oldAura != null)
            {
                return(PrepareStackOrOverride(caster, oldAura, spell, ref err, triggeringCast));
            }
            return(true);
        }
Пример #6
0
        public bool Remove(AuraIndexId auraId)
        {
            Aura aura;

            if (!this.m_auras.TryGetValue(auraId, out aura))
            {
                return(false);
            }
            aura.Remove(true);
            return(true);
        }
Пример #7
0
 internal Aura(AuraCollection auras, ObjectReference caster, AuraRecord record, List <AuraEffectHandler> handlers,
               byte index)
 {
     m_record          = record;
     m_auras           = auras;
     m_spell           = record.Spell;
     m_beneficial      = record.IsBeneficial;
     Id                = m_spell.GetAuraUID(m_beneficial);
     m_handlers        = handlers;
     m_CasterReference = caster;
     m_index           = index;
     m_auraLevel       = (byte)record.Level;
     m_stackCount      = record.StackCount;
     SetupValues();
     m_duration = record.MillisLeft;
     SetupTimer();
 }
Пример #8
0
 /// <summary>Creates a new Aura</summary>
 /// <param name="auras"></param>
 /// <param name="casterReference">Information about who casted</param>
 /// <param name="spell">The spell that this Aura represents</param>
 /// <param name="handlers">All handlers must have the same AuraUID</param>
 internal Aura(AuraCollection auras, ObjectReference casterReference, Spell spell,
               List <AuraEffectHandler> handlers, byte index, bool beneficial)
 {
     m_auras           = auras;
     m_spell           = spell;
     m_beneficial      = beneficial;
     Id                = spell.GetAuraUID(beneficial);
     m_handlers        = handlers;
     m_CasterReference = casterReference;
     m_index           = index;
     m_auraLevel       = (byte)casterReference.Level;
     m_stackCount      = (byte)m_spell.InitialStackCount;
     if (m_stackCount > 0 && casterReference.UnitMaster != null)
     {
         m_stackCount =
             casterReference.UnitMaster.Auras.GetModifiedInt(SpellModifierType.Charges, m_spell,
                                                             m_stackCount);
     }
     SetupValues();
 }
Пример #9
0
        /// <summary>
        /// Applies the given spell as a buff or debuff.
        /// Does not necessarily create
        /// Also, initializes new Auras.
        /// </summary>
        /// <returns>null if Spell is not an Aura or an already existing version of the Aura that was refreshed</returns>
        public Aura CreateAura(ObjectReference caster, Spell spell, WCell.RealmServer.Entities.Item usedItem = null)
        {
            try
            {
                bool              flag    = spell.IsBeneficialFor(caster, (WorldObject)this.m_owner);
                AuraIndexId       auraUid = spell.GetAuraUID(flag);
                SpellFailedReason err     = SpellFailedReason.Ok;
                Aura              aura1   = this.GetAura(caster, auraUid, spell);
                if (aura1 != null && !this.PrepareStackOrOverride(caster, aura1, spell, ref err, (SpellCast)null))
                {
                    if (err == SpellFailedReason.Ok)
                    {
                        return(aura1);
                    }
                    if (caster.Object is Character)
                    {
                        SpellHandler.SendCastFailed((IPacketReceiver)caster.Object, spell, err);
                    }
                    return((Aura)null);
                }

                List <AuraEffectHandler> auraEffectHandlers = spell.CreateAuraEffectHandlers(caster, this.m_owner, flag);
                if (auraEffectHandlers != null)
                {
                    Aura aura2 = this.CreateAura(caster, spell, auraEffectHandlers, usedItem, flag);
                    if (aura2 != null)
                    {
                        this.OnCreated(aura2);
                    }
                    return(aura2);
                }
            }
            catch (Exception ex)
            {
                LogUtil.ErrorException(ex, "Unable to add new Aura \"{0}\" by \"{1}\" to: {2}", (object)spell,
                                       (object)caster, (object)this.m_owner);
            }

            return((Aura)null);
        }
Пример #10
0
        /// <summary>Adds an already created Aura and optionally starts it</summary>
        public virtual void AddAura(Aura aura, bool start = true)
        {
            AuraIndexId id = aura.Id;

            if (this.m_auras.ContainsKey(aura.Id))
            {
                LogManager.GetCurrentClassLogger()
                .Warn("Tried to add Aura \"{0}\" by \"{1}\" when it was already added, to: {2}", (object)aura,
                      (object)aura.CasterReference, (object)this.Owner);
            }
            else
            {
                foreach (Aura aura1 in this.m_auras.Values)
                {
                    if ((int)aura1.Spell.RealId == (int)aura.Spell.RealId)
                    {
                        aura1.Remove(true);
                        break;
                    }
                }

                this.m_auras.Add(id, aura);
                if (!aura.Spell.IsPassive)
                {
                    this.m_visibleAuras[(int)aura.Index] = aura;
                    ++this.m_visAuraCount;
                }

                this.InvalidateAurasCopy();
                aura.IsAdded = true;
                if (!start)
                {
                    return;
                }
                aura.Start();
            }
        }
Пример #11
0
		public Aura this[AuraIndexId auraId]
		{
			get
			{
				Aura aura;
				m_auras.TryGetValue(auraId, out aura);
				return aura;
			}
		}
Пример #12
0
		public bool Contains(AuraIndexId id)
		{
			return this[id] != null;
		}
Пример #13
0
 public bool Contains(AuraIndexId id)
 {
     return(this[id] != null);
 }
Пример #14
0
		/// <summary>
		/// Stack or removes the Aura represented by the given spell, if possible.
		/// Returns true if there is no incompatible Aura or if it could be removed.
		/// <param name="err">Ok, if stacked or no incompatible Aura is blocking a new Aura</param>
		/// </summary>
		public bool CheckStackOrOverride(CasterInfo caster, AuraIndexId id, Spell spell, ref SpellFailedReason err)
		{
			var oldAura = GetAura(caster, id, spell);
			if (oldAura != null)
			{
				return CheckStackOrOverride(oldAura, caster, spell, ref err);
			}
			return true;
		}
Пример #15
0
		public bool Cancel(uint auraUID, bool positive)
		{
			var id = new AuraIndexId { AuraUID = auraUID, IsPositive = positive };
			return Cancel(id);
		}
Пример #16
0
		/// <summary>
		/// Get an Aura that is incompatible with the one represented by the given spell.
		/// </summary>
		/// <returns>Whether or not another Aura may be applied</returns>
		public Aura GetAura(CasterInfo caster, AuraIndexId id, Spell spell)
		{
			var oldAura = this[id];
			if (oldAura != null)
			{
				return oldAura;
			}
			else
			{
				// no aura found
				// check for per-caster-restrictions
				if (spell.AuraCasterGroup != null)
				{
					var count = 0;
					foreach (var aura in m_AuraArray)
					{
						if (aura.CasterInfo.CasterId == caster.CasterId && spell.AuraCasterGroup == aura.Spell.AuraCasterGroup)
						{
							count++;
							if (count >= spell.AuraCasterGroup.MaxCount)
							{
								return aura;
							}
						}
					}
				}
			}
			return null;
		}
Пример #17
0
		public bool Cancel(AuraIndexId auraId)
		{
			Aura aura;
			if (m_auras.TryGetValue(auraId, out aura))
			{
				aura.Cancel();
				return true;
			}
			return false;
		}