public bool IsValidTactic(ushort tacticEntry) { AbilityConstants constInfo = AbilityMgr.GetAbilityInfo(tacticEntry).ConstantInfo; if (constInfo.MinimumRank > _unitOwner.AdjustedLevel) { return(false); } if (constInfo.MasteryTree == 0) { return(true); } int destTree = constInfo.MasteryTree - 1; for (int i = 0; i < MAX_TREE_ABILITIES; ++i) { if (_masteryAbilities[destTree, i] != null && _masteryAbilities[destTree, i].Entry == tacticEntry) { return(_activeSkillsInTree[destTree, i] == 1); } } return(false); }
public bool StartCastAtPos(Unit instigator, ushort abilityID, Point3D worldPos, ushort zoneId, byte castSequence) { if (PreventCasting) { if (_Owner is Player) { Player owner = _Owner as Player; owner?.SendClientMessage("A developer has disabled all abilities.", ChatLogFilters.CHATLOGFILTERS_USER_ERROR); } return(false); } // Allow only interruption of channeled skills of a different ID to the skill being used if (IsCasting() && (!_abilityProcessor.IsChannelling || _abilityProcessor.AbInfo.Entry == abilityID)) { return(false); } AbilityInfo abInfo = AbilityMgr.GetAbilityInfo(abilityID); if (abInfo == null || (abInfo.ConstantInfo.Origin != AbilityOrigin.AO_ITEM && !IsValidAbility(abInfo))) { return(false); } try { if (AbilityMgr.HasCommandsFor(abilityID) || abInfo.ConstantInfo.ChannelID != 0) { if (_abilityProcessor == null) { _abilityProcessor = new AbilityProcessor(_unitOwner, this); } abInfo.Instigator = instigator; if (!_abilityProcessor.HasInfo()) { _abilityProcessor.StartAbilityAtPos(abInfo, castSequence, worldPos, zoneId); } return(true); } if (_Owner is Player) { var owner = _Owner as Player; owner?.SendClientMessage(abilityID + " " + AbilityMgr.GetAbilityNameFor(abilityID) + " has no implementation.", ChatLogFilters.CHATLOGFILTERS_USER_ERROR); } return(false); } catch (Exception e) { if (_Owner is Player) { var owner = _Owner as Player; owner?.SendClientMessage(abilityID + " " + AbilityMgr.GetAbilityNameFor(abilityID) + " threw an unhandled " + e.GetType().Name + " from " + e.TargetSite + "."); } return(false); } }
public void GrantAbility(ushort abilityEntry) { _abilities.Add(AbilityMgr.GetAbilityInfo(abilityEntry)); _abilitySet.Add(abilityEntry); SendAbilityLevels(); ResendCooldown(abilityEntry); }
/// <summary> /// Sets and transmits the cooldown of the given ability. /// </summary> /// <param name="abilityId">Ifd of ability to reset</param> /// <param name="duration">Cooldown duration in milliseconds, -1 to reset</param> /// <param name="silent">False to transmit new value to client, true otherwise</param> public void SetCooldown(ushort abilityId, long duration, bool silent = false) { #if DEBUG && ABILITY_DEVELOPMENT duration = 0; #endif if (abilityId == ushort.MaxValue) { return; } AbilityInfo abInfo = AbilityMgr.GetAbilityInfo(abilityId); if (abInfo.IgnoreCooldownReduction == 1 && (abInfo.Cooldown * 1000) >= duration) { long nextTimestamp = 0; if (abInfo.CDcap != null && abInfo.CDcap * 1000 > duration) { nextTimestamp = (abInfo.CDcap * 1000) + TCPManager.GetTimeStampMS(); } else { nextTimestamp = (abInfo.Cooldown * 1000) + TCPManager.GetTimeStampMS(); } Cooldowns[abilityId] = nextTimestamp; if (silent) { return; } PacketOut Out = new PacketOut((byte)Opcodes.F_SET_ABILITY_TIMER, 12); Out.WriteUInt16(abilityId); Out.Fill(0, 2); Out.WriteUInt32(((uint)abInfo.Cooldown * 1000)); Out.Fill(0, 4); if (_Owner.IsPet()) { _Owner.GetPet().Owner.SendPacket(Out); } else { _playerOwner?.SendPacket(Out); } } if (abInfo.IgnoreCooldownReduction != 1 || (abInfo.IgnoreCooldownReduction == 1 && (abInfo.Cooldown * 1000) < duration)) { long nextTimestamp = 0; if (abInfo.CDcap != null && abInfo.CDcap * 1000 > duration) { nextTimestamp = (abInfo.CDcap * 1000) + TCPManager.GetTimeStampMS(); } else { nextTimestamp = (duration) + TCPManager.GetTimeStampMS(); } if (duration == -1 && abInfo.CDcap == null) { nextTimestamp = 0; } Cooldowns[abilityId] = nextTimestamp; if (silent) { return; } PacketOut Out = new PacketOut((byte)Opcodes.F_SET_ABILITY_TIMER, 12); Out.WriteUInt16(abilityId); Out.Fill(0, 2); Out.WriteUInt32(duration != -1 ? (uint)duration : 0); Out.Fill(0, 4); if (_Owner.IsPet()) { _Owner.GetPet().Owner.SendPacket(Out); } else { _playerOwner?.SendPacket(Out); } } }
public bool StartCast(Unit instigator, ushort abilityId, byte castSequence, byte cooldownGroup = 0, byte overrideAbilityLevel = 0, bool enemyVisible = true, bool friendlyVisible = true, bool moving = false) { if (PreventCasting) { if (_Owner is Player) { (_Owner as Player)?.SendClientMessage("A developer has disabled all abilities.", ChatLogFilters.CHATLOGFILTERS_USER_ERROR); } return(false); } // Allow only interruption of channeled skills of a different ID to the skill being used if (IsCasting() && (!_abilityProcessor.IsChannelling || _abilityProcessor.AbInfo.Entry == abilityId)) { return(false); } AbilityInfo abInfo = AbilityMgr.GetAbilityInfo(abilityId); if (abInfo == null || (abInfo.ConstantInfo.Origin != AbilityOrigin.AO_ITEM && !IsValidAbility(abInfo))) { return(false); } //Fix so that WE/WH cant use all their 3 openers at the same time, this is in conjunction with whats in AbilityProcessor if (_Owner is Player) { if ((_Owner as Player).StealthLevel == 0 && (abilityId == 9406 || abilityId == 9401 || abilityId == 9411 || abilityId == 8091 || abilityId == 8096 || abilityId == 8098)) { return(false); } } try { if (AbilityMgr.HasCommandsFor(abilityId) || abInfo.ConstantInfo.ChannelID != 0) { if (_abilityProcessor == null) { _abilityProcessor = new AbilityProcessor(_unitOwner, this); } abInfo.Instigator = instigator; abInfo.Level = overrideAbilityLevel; return(_abilityProcessor.StartAbility(abInfo, castSequence, cooldownGroup, enemyVisible, friendlyVisible, moving)); } if (_Owner is Player) { Player owner = _Owner as Player; owner?.SendClientMessage(abilityId + " " + AbilityMgr.GetAbilityNameFor(abilityId) + " has no implementation.", ChatLogFilters.CHATLOGFILTERS_USER_ERROR); } return(false); } catch (Exception e) { if (_Owner is Player) { (_Owner as Player)?.SendClientMessage(abilityId + " " + AbilityMgr.GetAbilityNameFor(abilityId) + " threw an unhandled " + e.GetType().Name + " from " + e.TargetSite + "."); } Log.Error("Ability System", e.ToString()); return(false); } }