/// <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); }
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(); }