/// <summary>Performs the final modifications to the ability commands.</summary> private bool ModifyFinals() { if (!AbInfo.ConstantInfo.IgnoreOwnModifiers) { List <AbilityModifier> myModifiers = AbilityMgr.GetAbilityModifiers(AbInfo.Entry); if (myModifiers != null) { foreach (var modifier in myModifiers) { var result = modifier.ModifyAbility(_caster, AbInfo); if (result > 0) { if (result > 1) { _abInterface.SetCooldown(AbInfo.ConstantInfo.CooldownEntry != 0 ? AbInfo.ConstantInfo.CooldownEntry : AbInfo.Entry, AbInfo.Cooldown * 1000); _abInterface.SetGlobalCooldown(); } return(false); } } } } // Morales and items should not run through general handlers if (AbInfo.SpecialCost < 0 || AbInfo.ConstantInfo.Origin == AbilityOrigin.AO_ITEM) { return(true); } var player = _caster as Player; player?.TacInterface.ModifyFinals(AbInfo); return(true); }
public void ReloadTactics() { List <ushort> tacList = new List <ushort>(); bool sendTacticUpdate = false; if (_myPlayer._Value.Tactic1 != 0 && !tacList.Contains(_myPlayer._Value.Tactic1)) { tacList.Add(_myPlayer._Value.Tactic1); } if (_myPlayer._Value.Tactic2 != 0 && !tacList.Contains(_myPlayer._Value.Tactic2)) { tacList.Add(_myPlayer._Value.Tactic2); } if (_myPlayer._Value.Tactic3 != 0 && !tacList.Contains(_myPlayer._Value.Tactic3)) { tacList.Add(_myPlayer._Value.Tactic3); } if (_myPlayer._Value.Tactic4 != 0 && !tacList.Contains(_myPlayer._Value.Tactic4)) { tacList.Add(_myPlayer._Value.Tactic4); } int maxAllowedTactics = _myPlayer.AdjustedLevel / 10; while (tacList.Count > maxAllowedTactics) { tacList.RemoveAt(tacList.Count - 1); sendTacticUpdate = true; } foreach (NewBuff buff in _activeBuffs) { buff.BuffHasExpired = true; if (_modifyingTactics.Contains(buff.Entry)) { _modifyingTactics.Remove(buff.Entry); List <ushort> toRemove = new List <ushort>(); if (AbilityMgr.HasPreCastModifiers(buff.Entry)) { foreach (AbilityModifier mod in AbilityMgr.GetAbilityPreCastModifiers(buff.Entry)) { if (mod.Affecting == 0) { _generalPreCastModifiers.RemoveAll(fmod => fmod.Source == buff.Entry); } else if (mod.Affecting <= 3) { _speclinePreCastModifiers[(byte)(mod.Affecting - 1)].RemoveAll(fmod => fmod.Source == buff.Entry); } else { toRemove.Add(mod.Affecting); } } foreach (ushort rem in toRemove) { _abilityPreCastModifiers[rem].RemoveAll(fmod => fmod.Source == buff.Entry); } toRemove.Clear(); } if (AbilityMgr.HasModifiers(buff.Entry)) { foreach (AbilityModifier mod in AbilityMgr.GetAbilityModifiers(buff.Entry)) { if (mod.Affecting == 0) { _generalModifiers.RemoveAll(fmod => fmod.Source == buff.Entry); } else if (mod.Affecting <= 3) { _speclineModifiers[(byte)(mod.Affecting - 1)].RemoveAll(fmod => fmod.Source == buff.Entry); } else { toRemove.Add(mod.Affecting); } } foreach (ushort rem in toRemove) { _abilityModifiers[rem].RemoveAll(fmod => fmod.Source == buff.Entry); } toRemove.Clear(); } if (AbilityMgr.HasBuffModifiers(buff.Entry)) { foreach (AbilityModifier mod in AbilityMgr.GetBuffModifiers(buff.Entry)) { if (mod.Affecting == 0) { _generalBuffModifiers.RemoveAll(fmod => fmod.Source == buff.Entry); } else if (mod.Affecting <= 3) { _speclineBuffModifiers[(byte)(mod.Affecting - 1)].RemoveAll(fmod => fmod.Source == buff.Entry); } else { toRemove.Add(mod.Affecting); } } foreach (ushort rem in toRemove) { _buffModifiers[rem].RemoveAll(fmod => fmod.Source == buff.Entry); } } } _activeTactics.Remove(buff.Entry); } _activeBuffs.Clear(); foreach (ushort id in tacList) { if (id == 0 || _activeTactics.Contains(id)) { continue; } BuffInfo b = AbilityMgr.GetBuffInfo(id); if (b == null) { _myPlayer.SendClientMessage("Nonexistent tactic: " + id + " " + AbilityMgr.GetAbilityNameFor(id)); continue; } if (!_myPlayer.AbtInterface.IsValidTactic(id)) { _myPlayer.SendClientMessage("Invalid tactic: " + id + " " + AbilityMgr.GetAbilityNameFor(id)); sendTacticUpdate = true; continue; } if (!string.IsNullOrEmpty(b.AuraPropagation)) { _myPlayer.BuffInterface.QueueBuff(new BuffQueueInfo(_myPlayer, _myPlayer.AbtInterface.GetMasteryLevelFor(AbilityMgr.GetMasteryTreeFor(b.Entry)), b, BuffEffectInvoker.CreateAura, RegisterTacticBuff)); } else { _myPlayer.BuffInterface.QueueBuff(new BuffQueueInfo(_myPlayer, _myPlayer.AbtInterface.GetMasteryLevelFor(AbilityMgr.GetMasteryTreeFor(b.Entry)), b, RegisterTacticBuff)); } _activeTactics.Add(id); } // Update the saved list for the server for (int i = 0; i < 4; ++i) { _myPlayer._Value.SetTactic((byte)(i + 1), i < _activeTactics.Count ? _activeTactics[i] : (ushort)0); } if (sendTacticUpdate) { SendTactics(); } }
public void UnregisterGeneralBuff(NewBuff buff) { List <ushort> toRemove = new List <ushort>(); #region PreCast if (AbilityMgr.HasPreCastModifiers(buff.Entry)) { foreach (AbilityModifier mod in AbilityMgr.GetAbilityPreCastModifiers(buff.Entry)) { if (mod.Affecting == 0) { _generalPreCastModifiers.RemoveAll(fmod => fmod.Source == buff.Entry); } else if (mod.Affecting <= 3) { _speclinePreCastModifiers[(byte)(mod.Affecting - 1)].RemoveAll(fmod => fmod.Source == buff.Entry); } else { toRemove.Add(mod.Affecting); } } foreach (ushort rem in toRemove) { _abilityPreCastModifiers[rem].RemoveAll(fmod => fmod.Source == buff.Entry); } toRemove.Clear(); } #endregion #region Cast if (AbilityMgr.HasModifiers(buff.Entry)) { foreach (AbilityModifier mod in AbilityMgr.GetAbilityModifiers(buff.Entry)) { if (mod.Affecting == 0) { _generalModifiers.RemoveAll(fmod => fmod.Source == buff.Entry); } else if (mod.Affecting <= 3) { _speclineModifiers[(byte)(mod.Affecting - 1)].RemoveAll(fmod => fmod.Source == buff.Entry); } else { toRemove.Add(mod.Affecting); } } foreach (ushort rem in toRemove) { _abilityModifiers[rem].RemoveAll(fmod => fmod.Source == buff.Entry); } toRemove.Clear(); } #endregion #region Buff if (AbilityMgr.HasBuffModifiers(buff.Entry)) { foreach (AbilityModifier mod in AbilityMgr.GetBuffModifiers(buff.Entry)) { if (mod.Affecting == 0) { _generalBuffModifiers.RemoveAll(fmod => fmod.Source == buff.Entry); } else if (mod.Affecting <= 3) { _speclineBuffModifiers[(byte)(mod.Affecting - 1)].RemoveAll(fmod => fmod.Source == buff.Entry); } else { toRemove.Add(mod.Affecting); } } foreach (ushort rem in toRemove) { _buffModifiers[rem].RemoveAll(fmod => fmod.Source == buff.Entry); } } #endregion }
/// <summary> /// Registers a given buff's ability and buff modifiers. /// </summary> public void RegisterGeneralBuff(NewBuff buff) { #region PreCast if (AbilityMgr.HasPreCastModifiers(buff.Entry)) { List <AbilityModifier> abilityPreCastModifiers = AbilityMgr.GetAbilityPreCastModifiers(buff.Entry); foreach (AbilityModifier mod in abilityPreCastModifiers) { if (mod.Affecting == 0) { _generalPreCastModifiers.Add(mod); } else if (mod.Affecting <= 3) { if (!_speclinePreCastModifiers.ContainsKey((ushort)(mod.Affecting - 1))) { _speclinePreCastModifiers.Add((ushort)(mod.Affecting - 1), new List <AbilityModifier>()); } _speclinePreCastModifiers[(byte)(mod.Affecting - 1)].Add(mod); } else { if (!_abilityPreCastModifiers.ContainsKey(mod.Affecting)) { _abilityPreCastModifiers.Add(mod.Affecting, new List <AbilityModifier>()); } _abilityPreCastModifiers[mod.Affecting].Add(mod); } for (AbilityModifierEffect effect = mod.Effect; effect != null; effect = effect.nextMod) { buff.AddBuffParameter(effect.BuffLine, effect.PrimaryValue); } } } #endregion #region Cast if (AbilityMgr.HasModifiers(buff.Entry)) { List <AbilityModifier> abilityModifiers = AbilityMgr.GetAbilityModifiers(buff.Entry); foreach (AbilityModifier mod in abilityModifiers) { if (mod.Affecting == 0) { _generalModifiers.Add(mod); } else if (mod.Affecting <= 3) { if (!_speclineModifiers.ContainsKey((ushort)(mod.Affecting - 1))) { _speclineModifiers.Add((ushort)(mod.Affecting - 1), new List <AbilityModifier>()); } _speclineModifiers[(byte)(mod.Affecting - 1)].Add(mod); } else { if (!_abilityModifiers.ContainsKey(mod.Affecting)) { _abilityModifiers.Add(mod.Affecting, new List <AbilityModifier>()); } _abilityModifiers[mod.Affecting].Add(mod); } for (AbilityModifierEffect effect = mod.Effect; effect != null; effect = effect.nextMod) { buff.AddBuffParameter(effect.BuffLine, effect.PrimaryValue); } } } #endregion #region Buff if (AbilityMgr.HasBuffModifiers(buff.Entry)) { List <AbilityModifier> buffModifiers = AbilityMgr.GetBuffModifiers(buff.Entry); foreach (AbilityModifier mod in buffModifiers) { if (mod.Affecting == 0) { _generalBuffModifiers.Add(mod); } else if (mod.Affecting <= 3) { if (!_speclineBuffModifiers.ContainsKey((ushort)(mod.Affecting - 1))) { _speclineBuffModifiers.Add((ushort)(mod.Affecting - 1), new List <AbilityModifier>()); } _speclineBuffModifiers[(byte)(mod.Affecting - 1)].Add(mod); } else { if (!_buffModifiers.ContainsKey(mod.Affecting)) { _buffModifiers.Add(mod.Affecting, new List <AbilityModifier>()); } _buffModifiers[mod.Affecting].Add(mod); } for (AbilityModifierEffect effect = mod.Effect; effect != null; effect = effect.nextMod) { buff.AddBuffParameter(effect.BuffLine, effect.PrimaryValue); } } } #endregion }
/// <summary> /// Registers the tactic's ability and buff modifiers. /// </summary> public void RegisterTacticBuff(NewBuff b) { bool bAdded = false; _activeBuffs.Add(b); #region PreCast if (AbilityMgr.HasPreCastModifiers(b.Entry)) { List <AbilityModifier> tacPrecastModifiers = AbilityMgr.GetAbilityPreCastModifiers(b.Entry); foreach (AbilityModifier mod in tacPrecastModifiers) { if (mod.Affecting == 0) { _generalPreCastModifiers.Add(mod); } else if (mod.Affecting <= 3) { if (!_speclinePreCastModifiers.ContainsKey((ushort)(mod.Affecting - 1))) { _speclinePreCastModifiers.Add((ushort)(mod.Affecting - 1), new List <AbilityModifier>()); } _speclinePreCastModifiers[(byte)(mod.Affecting - 1)].Add(mod); } else { if (!_abilityPreCastModifiers.ContainsKey(mod.Affecting)) { _abilityPreCastModifiers.Add(mod.Affecting, new List <AbilityModifier>()); } _abilityPreCastModifiers[mod.Affecting].Add(mod); } for (AbilityModifierEffect effect = mod.Effect; effect != null; effect = effect.nextMod) { b.AddBuffParameter(effect.BuffLine, effect.PrimaryValue); } } bAdded = true; } #endregion #region Cast if (AbilityMgr.HasModifiers(b.Entry)) { List <AbilityModifier> tacModifiers = AbilityMgr.GetAbilityModifiers(b.Entry); foreach (AbilityModifier mod in tacModifiers) { if (mod.Affecting == 0) { _generalModifiers.Add(mod); } else if (mod.Affecting <= 3) { if (!_speclineModifiers.ContainsKey((ushort)(mod.Affecting - 1))) { _speclineModifiers.Add((ushort)(mod.Affecting - 1), new List <AbilityModifier>()); } _speclineModifiers[(byte)(mod.Affecting - 1)].Add(mod); } else { if (!_abilityModifiers.ContainsKey(mod.Affecting)) { _abilityModifiers.Add(mod.Affecting, new List <AbilityModifier>()); } _abilityModifiers[mod.Affecting].Add(mod); } for (AbilityModifierEffect effect = mod.Effect; effect != null; effect = effect.nextMod) { b.AddBuffParameter(effect.BuffLine, effect.PrimaryValue); } } bAdded = true; } #endregion #region Buff if (AbilityMgr.HasBuffModifiers(b.Entry)) { List <AbilityModifier> tacBuffModifiers = AbilityMgr.GetBuffModifiers(b.Entry); foreach (AbilityModifier mod in tacBuffModifiers) { if (mod.Affecting == 0) { _generalBuffModifiers.Add(mod); } else if (mod.Affecting <= 3) { if (!_speclineBuffModifiers.ContainsKey((ushort)(mod.Affecting - 1))) { _speclineBuffModifiers.Add((ushort)(mod.Affecting - 1), new List <AbilityModifier>()); } _speclineBuffModifiers[(byte)(mod.Affecting - 1)].Add(mod); } else { if (!_buffModifiers.ContainsKey(mod.Affecting)) { _buffModifiers.Add(mod.Affecting, new List <AbilityModifier>()); } _buffModifiers[mod.Affecting].Add(mod); } for (AbilityModifierEffect effect = mod.Effect; effect != null; effect = effect.nextMod) { b.AddBuffParameter(effect.BuffLine, effect.PrimaryValue); } } bAdded = true; } #endregion if (bAdded) { _modifyingTactics.Add(b.Entry); } }
/// <summary> /// Verifies that the player can legitimately assign the requested tactic. /// </summary> public void ValidateTactics() { List <NewBuff> removeList = new List <NewBuff>(); foreach (var buff in _activeBuffs) { if (!_myPlayer.AbtInterface.IsValidTactic(buff.Entry)) { buff.BuffHasExpired = true; if (_modifyingTactics.Contains(buff.Entry)) { _modifyingTactics.Remove(buff.Entry); List <ushort> toRemove = new List <ushort>(); if (AbilityMgr.HasPreCastModifiers(buff.Entry)) { foreach (AbilityModifier mod in AbilityMgr.GetAbilityPreCastModifiers(buff.Entry)) { if (mod.Affecting == 0) { _generalPreCastModifiers.RemoveAll(fmod => fmod.Source == buff.Entry); } else if (mod.Affecting <= 3) { _speclinePreCastModifiers[(byte)(mod.Affecting - 1)].RemoveAll(fmod => fmod.Source == buff.Entry); } else { toRemove.Add(mod.Affecting); } } foreach (ushort rem in toRemove) { _abilityPreCastModifiers[rem].RemoveAll(fmod => fmod.Source == buff.Entry); } toRemove.Clear(); } if (AbilityMgr.HasModifiers(buff.Entry)) { foreach (AbilityModifier mod in AbilityMgr.GetAbilityModifiers(buff.Entry)) { if (mod.Affecting == 0) { _generalModifiers.RemoveAll(fmod => fmod.Source == buff.Entry); } else if (mod.Affecting <= 3) { _speclineModifiers[(byte)(mod.Affecting - 1)].RemoveAll(fmod => fmod.Source == buff.Entry); } else { toRemove.Add(mod.Affecting); } } foreach (ushort rem in toRemove) { _abilityModifiers[rem].RemoveAll(fmod => fmod.Source == buff.Entry); } toRemove.Clear(); } if (AbilityMgr.HasBuffModifiers(buff.Entry)) { foreach (AbilityModifier mod in AbilityMgr.GetBuffModifiers(buff.Entry)) { if (mod.Affecting == 0) { _generalBuffModifiers.RemoveAll(fmod => fmod.Source == buff.Entry); } else if (mod.Affecting <= 3) { _speclineBuffModifiers[(byte)(mod.Affecting - 1)].RemoveAll(fmod => fmod.Source == buff.Entry); } else { toRemove.Add(mod.Affecting); } } foreach (ushort rem in toRemove) { _buffModifiers[rem].RemoveAll(fmod => fmod.Source == buff.Entry); } } } removeList.Add(buff); _activeTactics.Remove(buff.Entry); } } foreach (var buff in removeList) { _activeBuffs.Remove(buff); } SendTactics(); }