Esempio n. 1
0
 public override void InvokeDamageEvent(byte eventId, AbilityDamageInfo damageInfo, Unit eventInstigator)
 {
     if (BuffState != (byte)EBuffState.Running)
     {
         return;
     }
     if (!string.IsNullOrEmpty(EventCommands[0].Item2.EventCheck) && !BuffEffectInvoker.PerformCheck(this, damageInfo, EventCommands[0].Item2, eventInstigator))
     {
         return;
     }
     if (!CanHitTarget(eventInstigator))
     {
         return;
     }
     BuffEffectInvoker.InvokeDamageEventCommand(this, EventCommands[0].Item2, damageInfo, Target, eventInstigator);
 }
        public virtual void InvokeDamageEvent(byte eventId, AbilityDamageInfo damageInfo, Unit eventInstigator)
        {
            if (BuffState != (byte)EBuffState.Running)
            {
                return;
            }

            BuffCommandInfo myCommand = EventCommands.Find(evtpair => evtpair.Item1 == eventId).Item2;

            if (myCommand == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(myCommand.EventCheck) && !BuffEffectInvoker.PerformCheck(this, damageInfo, myCommand, eventInstigator))
            {
                return;
            }

            if (myCommand.EventChance > 0 && StaticRandom.Instance.Next(0, 100) > myCommand.EventChance)
            {
                return;
            }

            if (myCommand.RetriggerInterval != 0)
            {
                // If two threads clash here, we're guaranteed to be setting the next time anyway
                // so the thread which can't get the lock should just return
                if (Interlocked.CompareExchange(ref BuffTimerLock, 1, 0) != 0)
                {
                    return;
                }

                if (myCommand.NextTriggerTime != 0 && myCommand.NextTriggerTime > TCPManager.GetTimeStampMS())
                {
                    Interlocked.Exchange(ref BuffTimerLock, 0);
                    return;
                }

                myCommand.NextTriggerTime = TCPManager.GetTimeStampMS() + myCommand.RetriggerInterval;
                Interlocked.Exchange(ref BuffTimerLock, 0);
            }

            if (myCommand.ConsumesStack)
            {
                while (Interlocked.CompareExchange(ref BuffStackLock, 1, 0) != 0)
                {
                    ;
                }

                if (StackLevel == 0)
                {
                    Interlocked.Exchange(ref BuffStackLock, 0);
                    return;
                }

                RemoveStack();

                if (Entry == 8090 || Entry == 9393)
                {
                    ((Player)Caster).SendClientMessage((eventInstigator?.Name ?? "Something") + "'s " + AbilityMgr.GetAbilityNameFor(damageInfo.DisplayEntry) + " broke your stealth.");
                }


                Interlocked.Exchange(ref BuffStackLock, 0);
            }

            if (myCommand.CommandName == "None")
            {
                return;
            }

            BuffEffectInvoker.InvokeDamageEventCommand(this, myCommand, damageInfo, Target, eventInstigator);
        }