예제 #1
0
        public override void StartBuff()
        {
            if (_buffInfo.CommandInfo != null)
            {
                for (byte i = 0; i < _buffInfo.CommandInfo.Count; ++i)
                {
                    if ((_buffInfo.CommandInfo[i].InvokeOn & BuffState) > 0)
                    {
                        BuffEffectInvoker.InvokeCommand(this, _buffInfo.CommandInfo[i], Target);
                    }
                }
            }

            BuffState = (byte)EBuffState.Running;

            NextTickTime = TCPManager.GetTimeStampMS() + _buffInfo.Interval;

            if (BuffLines.Count != 0)
            {
                SendBounceStart();
            }
            else
            {
                BuffHasExpired = true;
            }
        }
예제 #2
0
        public override void Update(long tick)
        {
            if (BuffState != (byte)EBuffState.Running)
            {
                return;
            }

            long curTime = TCPManager.GetTimeStampMS();

            if (EndTime > 0 && curTime >= EndTime)
            {
                BuffEnded(false, false);
            }
            else if (NextTickTime > 0 && curTime >= NextTickTime)
            {
                NextTickTime += _buffInfo.Interval;

                OnUpdate?.Invoke(this, HeldObject, tick);

                if (_buffInfo.CommandInfo != null)
                {
                    foreach (BuffCommandInfo command in _buffInfo.CommandInfo)
                    {
                        if ((command.InvokeOn & (byte)EBuffState.Running) > 0)
                        {
                            BuffEffectInvoker.InvokeCommand(this, command, Target);
                        }
                    }
                }
            }
        }
예제 #3
0
        public override void Update(long tick)
        {
            if (BuffState != (byte)EBuffState.Running)
            {
                return;
            }

            long curTime = TCPManager.GetTimeStampMS();

            if (EndTime > 0 && curTime >= EndTime)
            {
                BuffEnded(false, false);
            }
            else
            {
                if (NextTickTime > 0 && curTime >= NextTickTime)
                {
                    NextTickTime += _buffInfo.Interval;

                    foreach (BuffCommandInfo command in _buffInfo.CommandInfo)
                    {
                        if ((command.InvokeOn & (byte)EBuffState.Running) > 0)
                        {
                            BuffEffectInvoker.InvokeCommand(this, command, Target);
                        }
                    }
                }

                if (_nextAuraPropagationTime <= tick)
                {
                    _nextAuraPropagationTime = tick + _propInterval;
                    SpreadAura();
                }
            }
        }
예제 #4
0
        protected override void BuffEnded(bool wasRemoved, bool wasManual)
        {
            if (Interlocked.CompareExchange(ref BuffEndLock, 1, 0) != 0)
            {
                return;
            }

            BuffHasExpired     = true;
            WasManuallyRemoved = wasManual;

            if (wasRemoved)
            {
                BuffState = (byte)EBuffState.Removed;
            }
            else
            {
                BuffState = (byte)EBuffState.Ended;
            }

            Interlocked.Exchange(ref BuffEndLock, 0);

            if (_buffInfo.CommandInfo != null)
            {
                foreach (BuffCommandInfo Command in _buffInfo.CommandInfo)
                {
                    if ((Command.InvokeOn & (byte)EBuffState.Ended) > 0)
                    {
                        BuffEffectInvoker.InvokeCommand(this, Command, Target);
                    }
                }
            }

            SendBounceEnd();

            if (_linkedBuff != null && !_linkedBuff.BuffHasExpired)
            {
                _linkedBuff.BuffHasExpired = true;
            }
        }
예제 #5
0
        protected override void BuffEnded(bool wasRemoved, bool wasManual)
        {
            if (Interlocked.CompareExchange(ref BuffEndLock, 1, 0) != 0)
            {
                return;
            }

            BuffHasExpired     = true;
            WasManuallyRemoved = wasManual;

            if (wasRemoved)
            {
                BuffState = (byte)EBuffState.Removed;
            }
            else
            {
                BuffState = (byte)EBuffState.Ended;
            }

            Interlocked.Exchange(ref BuffEndLock, 0);

            if (_buffInfo.CommandInfo != null)
            {
                foreach (BuffCommandInfo command in _buffInfo.CommandInfo)
                {
                    if ((command.InvokeOn & (byte)EBuffState.Ended) > 0)
                    {
                        BuffEffectInvoker.InvokeCommand(this, command, Target);
                    }
                }
            }

            if (EventCommands.Count > 0)
            {
                foreach (var evtpair in EventCommands)
                {
                    _buffInterface.RemoveEventSubscription(this, evtpair.Item1);
                }
            }

            BuffHasExpired = true;

            BuffState = (byte)EBuffState.Removed;

            Player player = (Player)Caster;

            if (player.HeldObject != HeldObject)
            {
                Log.Error(player.Name, "Holding multiple objects!");
            }
            else
            {
                player.HeldObject = null;
            }

            HeldObject.HolderDied();

            Caster.OSInterface.RemoveEffect(0xB);

            SendEnded();
        }
        protected virtual void BuffEnded(bool wasRemoved, bool wasManual)
        {
            if (Interlocked.CompareExchange(ref BuffEndLock, 1, 0) != 0)
            {
                return;
            }

            BuffHasExpired     = true;
            WasManuallyRemoved = wasManual;

            if (wasRemoved)
            {
                BuffState = (byte)EBuffState.Removed;
            }
            else
            {
                BuffState = (byte)EBuffState.Ended;
            }

            Interlocked.Exchange(ref BuffEndLock, 0);

            // Flag exhaustion needs to send end before performing the swap
            if (Entry == 14323)
            {
                SendEnded();
            }

            if (_buffInfo.CommandInfo != null)
            {
                foreach (BuffCommandInfo command in _buffInfo.CommandInfo)
                {
                    if ((command.InvokeOn & (byte)EBuffState.Ended) > 0)
                    {
                        BuffEffectInvoker.InvokeCommand(this, command, Target);
                    }
                }
            }

            if (EventCommands.Count > 0)
            {
                foreach (var evtpair in EventCommands)
                {
                    _buffInterface.RemoveEventSubscription(this, evtpair.Item1);
                }
            }

            if (_buffInfo.CommandInfo != null)
            {
                foreach (BuffCommandInfo command in _buffInfo.CommandInfo)
                {
                    if (command.InvokeOn == 8 && command.TargetType == CommandTargetTypes.Caster)
                    {
                        Caster.BuffInterface.RemoveEventSubscription(this, command.EventID);
                    }
                }
            }

            if (Entry != 14323)
            {
                SendEnded();
            }

            if (_linkedBuff != null && !_linkedBuff.BuffHasExpired)
            {
                _linkedBuff.BuffHasExpired = true;
            }
        }
        public virtual void StartBuff()
        {
            if (_buffInfo.StackLine != 0)
            {
                AddBuffParameter(_buffInfo.StackLine, StackLevel);
            }

            // Invoke commands and register event subscriptions.
            if (_buffInfo.CommandInfo != null)
            {
                for (byte i = 0; i < _buffInfo.CommandInfo.Count; ++i)
                {
                    BuffCommandInfo command = _buffInfo.CommandInfo[i];

                    if (command.EventID != 0)
                    {
                        EventCommands.Add(new Tuple <byte, BuffCommandInfo>(command.EventID, command));
                        _buffInterface.AddEventSubscription(this, command.EventID);
                        //InvokeOn override - 8 == Invoke as permanent conditional effect while buff is active (for Channel)
                        if (command.InvokeOn == 8 && command.TargetType == CommandTargetTypes.Caster)
                        {
                            Caster.BuffInterface.AddEventSubscription(this, command.EventID);
                        }

                        if (command.InvokeOn == 0 && command.BuffLine > 0)
                        {
                            AddBuffParameter(command.BuffLine, command.PrimaryValue);
                        }
                    }
                    if ((command.InvokeOn & BuffState) > 0)
                    {
                        BuffEffectInvoker.InvokeCommand(this, command, Target);
                    }
                }
            }

            BuffState = (byte)EBuffState.Running;

            #region Check for CC block or no tooltip text
            // If a buff is crowd control and no tooltip text was added, a CC immunity blocked it.
            // In this case the buff is removed here.
            if (BuffLines.Count != 0)
            {
                if (Duration > 0)
                {
                    if (CrowdControl == 1)
                    {
                        DurationMs = (uint)(DurationMs * Target.StsInterface.GetStatReductionModifier(Stats.SnareDuration));
                        EndTime    = TCPManager.GetTimeStampMS() + DurationMs;
                    }
                    if (CrowdControl == 16)
                    {
                        DurationMs = (uint)(DurationMs * Target.StsInterface.GetStatReductionModifier(Stats.KnockdownDuration));
                        EndTime    = TCPManager.GetTimeStampMS() + DurationMs;
                    }
                }

                SendStart(null);

                ChannelHandler?.NotifyBuffStarted();
            }
            else
            {
                #if DEBUG
                Log.Info("Buff " + _buffInfo.Entry, "Couldn't find any buff lines.");
                if (CrowdControl == 0 && Caster is Player)
                {
                    ((Player)Caster).SendClientMessage(Entry + " " + AbilityMgr.GetAbilityNameFor(Entry) + ": Couldn't find any buff lines.");
                }
                #endif
                BuffHasExpired = true;
            }
            #endregion
        }