Esempio n. 1
0
 public void AddEventSubscription(NewBuff buff, byte eventID)
 {
     lock (_buffCombatSubs[eventID - 1])
     {
         _buffCombatSubs[eventID - 1].Add(buff);
     }
 }
Esempio n. 2
0
 public void RemoveEventSubscription(NewBuff buff, byte eventID)
 {
     lock (_buffCombatSubs[eventID - 1])
     {
         _buffCombatSubs[eventID - 1].Remove(buff);
     }
 }
Esempio n. 3
0
        public void RegisterSavedBuff(NewBuff b)
        {
            if (_playerOwner == null)
            {
                return;
            }

            foreach (CharacterSavedBuff buffSave in _playerOwner.Info.Buffs)
            {
                if (buffSave.BuffId == b.Entry)
                {
                    buffSave.EndTimeSeconds = (uint)TCPManager.GetTimeStamp() + b.Duration;
                    buffSave.Level          = b.BuffLevel;
                    buffSave.Dirty          = true;
                    CharMgr.Database.SaveObject(buffSave);
                    return;
                }
            }

            CharacterSavedBuff save = new CharacterSavedBuff {
                CharacterId = _playerOwner.Info.CharacterId, BuffId = b.Entry, Level = b.BuffLevel, StackLevel = b.StackLevel, EndTimeSeconds = (uint)TCPManager.GetTimeStamp() + b.Duration
            };

            _playerOwner.Info.Buffs.Add(save);
            CharMgr.Database.AddObject(save);
        }
        public void PostTargetCreate(NewBuff B)
        {
            if (B == null)
            {
                return;
            }
            _targetBuff = B;

            _Caster.BuffInterface.QueueBuff(new BuffQueueInfo(_Caster, _Caster.Level, AbilityMgr.GetBuffInfo(_desiredBuff, _Caster, _Caster), _creator, PostCasterCreate));
        }
Esempio n. 5
0
        /// <summary>
        /// <para>Creates and returns a new buff applied to the owner of this AbilityInterface.</para>
        /// </summary>
        public NewBuff TryCreateBuff(BuffQueueInfo buffQueueInfo)
        {
            if (buffQueueInfo.BuffInfo == null)
            {
                Log.Error("TryCreateBuff", "NULL BUFFINFO");
                return(null);
            }

            #if DEBUG && ABILITY_DEVELOPMENT
            _Owner.Say("+++ " + buffQueueInfo.BuffInfo.Name + " (" + buffQueueInfo.BuffInfo.Type + ")");
            #endif

            // Cap the level of same-faction buffs
            if (buffQueueInfo.Caster.Realm == _unitOwner.Realm && (float)buffQueueInfo.Caster.EffectiveLevel / _unitOwner.EffectiveLevel > 1.3f)
            {
                buffQueueInfo.DesiredLevel = _unitOwner.EffectiveLevel;
            }

            Tuple <ushort, byte> buffSlotInfo = CanAcceptBuff(buffQueueInfo);

            if (buffSlotInfo == null || buffSlotInfo.Item1 == 32000)
            {
                return(null);
            }

            NewBuff myBuff = buffQueueInfo.BuffCreator == null ? new NewBuff() : buffQueueInfo.BuffCreator();

            if (myBuff != null)
            {
                myBuff.Initialize(buffQueueInfo.Caster, (Unit)_Owner, buffSlotInfo.Item1,
                                  buffQueueInfo.DesiredLevel, Math.Min(buffQueueInfo.BuffInfo.MaxStack, buffSlotInfo.Item2),
                                  buffQueueInfo.BuffInfo, this);

                if (myBuff.BuffGroup == BuffGroups.SelfClassBuff)
                {
                    _careerBuffs[0] = myBuff;
                }
                else if (myBuff.BuffGroup == BuffGroups.SelfClassSecondaryBuff)
                {
                    _careerBuffs[1] = myBuff;
                }
                else if (myBuff.BuffGroup == BuffGroups.Guard && _Owner != myBuff.Caster)
                {
                    myBuff.IsGroupBuff = true;
                    _backingGuardBuffs?.Add((GuardBuff)myBuff);
                    _guardsChanged = true;
                }
                else if (myBuff is AuraBuff && myBuff.Caster == _Owner)
                {
                    _auraCount++;
                }
            }

            return(myBuff);
        }
Esempio n. 6
0
 public void BuffCallback(NewBuff buff)
 {
     if (_buffCallback != null)
     {
         if (buff == null && BuffInfo.BuffClass == BuffClass.Tactic)
         {
             Log.Info(BuffInfo.Name, "Tactic buff unsuccessfully applied!");
         }
         _buffCallback(buff);
     }
 }
Esempio n. 7
0
        public void RemoveFromPending(NewBuff buff, bool suppressNotify = false)
        {
            // Testing for Soul Willpower I proc
            if (suppressNotify && buff.Entry == 18139)
            {
                buff.SuppressEndNotification = true;
            }
            _pendingBuffs.Remove(buff);
            buff.RemoveBuff(true);

            _filledSlots[buff.BuffId] = false;
        }
Esempio n. 8
0
        public void InsertUnstoppable(BuffQueueInfo bqi)
        {
            NewBuff buff = TryCreateBuff(bqi);

            if (buff != null)
            {
                _pendingBuffs.Add(buff);
                _filledSlots[buff.BuffId] = true;
            }

            buff?.StartBuff();
        }
        public void PostCasterCreate(NewBuff B)
        {
            //This shouldn't really happen
            if (B == null)
            {
                _targetBuff.BuffHasExpired = true;
                return;
            }

            B.SetLinkedBuff(_targetBuff);
            _targetBuff.SetLinkedBuff(B);
        }
Esempio n. 10
0
        public void Hotswap(NewBuff oldBuff, ushort newBuffEntry)
        {
            BuffInfo newInfo = AbilityMgr.GetBuffInfo(newBuffEntry);

            NewBuff buff = new NewBuff();

            buff.Initialize(oldBuff.Caster, (Unit)_Owner, oldBuff.BuffId, 40, newInfo.MaxStack, newInfo, this);

            _pendingBuffs[_pendingBuffs.IndexOf(oldBuff)] = buff;
            _buffs[_buffs.IndexOf(oldBuff)] = buff;

            buff.StartBuff();
        }
Esempio n. 11
0
        public void RemoveBuffByID(byte buffID)
        {
            _buffRWLock.EnterReadLock();

            try
            {
                NewBuff toRemove = _buffs.Find(buff => buff.BuffId == buffID);
                if (toRemove == null)
                {
                    return;
                }
                if (toRemove.Caster == _Owner && (toRemove.Type == BuffTypes.Blessing || toRemove.Type == BuffTypes.Enchantment))
                {
                    toRemove.BuffHasExpired = true;
                }
            }

            finally { _buffRWLock.ExitReadLock(); }
        }
Esempio n. 12
0
        public void RemoveBuffByEntry(ushort buffEntry)
        {
            if (Stopping)
            {
                return;
            }

            _buffRWLock.EnterReadLock();

            try
            {
                NewBuff toRemove = _buffs.Find(buff => buff.Entry == buffEntry);
                if (toRemove != null)
                {
                    toRemove.BuffHasExpired = true;
                }
            }

            finally { _buffRWLock.ExitReadLock(); }
        }
Esempio n. 13
0
        public void RemoveSavedBuff(NewBuff b)
        {
            if (_playerOwner == null)
            {
                return;
            }

            List <CharacterSavedBuff> buffList = _playerOwner.Info.Buffs;

            if (buffList.Count == 0)
            {
                return;
            }

            for (int i = 0; i < buffList.Count; ++i)
            {
                if (buffList[i].BuffId == b.Entry)
                {
                    CharMgr.Database.DeleteObject(buffList[i]);
                    buffList.RemoveAt(i);
                    return;
                }
            }
        }
Esempio n. 14
0
        public override void Update(long tick)
        {
            bool bBuffsModified             = false;
            List <BuffQueueInfo> queuedList = null;

            // Pull in the buffinfo for buffs that are pending creation
            lock (_queuedInfo)
            {
                if (_queuedInfo.Count > 0)
                {
                    queuedList = new List <BuffQueueInfo>();
                    queuedList.AddRange(_queuedInfo);
                    _queuedInfo.Clear();
                }
            }

            int pendingLen = _pendingBuffs.Count;

            // Clear out any expired buffs from the pendingBuffs array
            for (int i = 0; i < pendingLen; ++i)
            {
                if (!_pendingBuffs[i].BuffHasExpired)
                {
                    continue;
                }

                NewBuff curBuff = _pendingBuffs[i];

                bBuffsModified = true;

                curBuff.RemoveBuff(false);

                if (curBuff.PersistsOnLogout && curBuff.BuffState == (byte)EBuffState.Ended)
                {
                    RemoveSavedBuff(curBuff);
                }

                _filledSlots[curBuff.BuffId] = false;

                if (curBuff.BuffGroup == BuffGroups.Guard && _Owner != curBuff.Caster)
                {
                    _backingGuardBuffs.Remove((GuardBuff)curBuff);
                    _guardsChanged = true;
                }
                else if (curBuff is AuraBuff && curBuff.Caster == _Owner)
                {
                    _auraCount--;
                }
                else if (curBuff.BuffGroup == BuffGroups.SelfClassBuff)
                {
                    _careerBuffs[0] = null;
                }
                else if (curBuff.BuffGroup == BuffGroups.SelfClassSecondaryBuff)
                {
                    _careerBuffs[1] = null;
                }

                #if DEBUG && ABILITY_DEVELOPMENT
                _Owner.Say("[X] " + curBuff.BuffName);
                #endif

                _pendingBuffs.RemoveAt(i);

                --i;
                pendingLen = _pendingBuffs.Count;
            }

            // Then add any queued buffs
            if (queuedList != null)
            {
                foreach (BuffQueueInfo bqi in queuedList)
                {
                    if (_unitOwner.IsDead && bqi.BuffInfo.RequiresTargetAlive)
                    {
                        continue;
                    }

                    if (!_unitOwner.IsDead && bqi.BuffInfo.RequiresTargetDead)
                    {
                        continue;
                    }

                    NewBuff buff = TryCreateBuff(bqi);
                    if (buff != null)
                    {
                        bBuffsModified = true;
                        _pendingBuffs.Add(buff);

                        _filledSlots[buff.BuffId] = true;
                    }

                    // Let the invoker of the buff know the result.
                    bqi.BuffCallback(buff);

                    if (buff != null)
                    {
                        buff.StartBuff();

                        if (buff.PersistsOnLogout)
                        {
                            RegisterSavedBuff(buff);
                        }
                    }
                }
            }

            if (_unitOwner != null && _unitOwner.IsDead && bBuffsModified)
            {
                pendingLen = _pendingBuffs.Count;

                for (int i = 0; i < pendingLen; ++i)
                {
                    if (_pendingBuffs[i].RequiresTargetAlive)
                    {
                        RemoveFromPending(_pendingBuffs[i]);
                        --pendingLen;
                        --i;
                    }
                }
            }

            // Manage Guard
            if (_guardsChanged)
            {
                _guardBuffs    = new List <GuardBuff>(_backingGuardBuffs);
                _guardsChanged = false;
            }

            // Copy the pending buffs into the used buff array
            if (bBuffsModified)
            {
                _buffRWLock.EnterWriteLock();
                try
                {
                    _buffs.Clear();
                    _buffs.AddRange(_pendingBuffs);
                }
                finally
                {
                    _buffRWLock.ExitWriteLock();
                }
            }

            // Update all the buffs
            if (_buffs.Count > 0 && TCPManager.GetTimeStampMS() > _nextBuffUpdateTime)
            {
                for (int index = 0; index < _buffs.Count; index++)
                {
                    _buffs[index].Update(tick);
                }

                _nextBuffUpdateTime = TCPManager.GetTimeStampMS() + BUFF_UPDATE_INTERVAL;
            }
        }
Esempio n. 15
0
 public void SetLinkedBuff(NewBuff linkedBuff)
 {
     _linkedBuff = linkedBuff;
 }