コード例 #1
0
        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);
        }
コード例 #2
0
        /// <summary>Performs the initial modifications to the volatile ability properties.</summary>
        private byte ModifyInitials()
        {
            if (!_pendingInfo.ConstantInfo.IgnoreOwnModifiers)
            {
                List <AbilityModifier> myModifiers = AbilityMgr.GetAbilityPreCastModifiers(_pendingInfo.Entry);
                if (myModifiers != null)
                {
                    foreach (AbilityModifier modifier in myModifiers)
                    {
                        byte result = modifier.ModifyAbility(_caster, _pendingInfo);

                        if (result > 0)
                        {
                            return(result);
                        }
                    }
                }
            }

            // Morales and items should not run through general handlers
            if (_pendingInfo.SpecialCost < 0 || _pendingInfo.ConstantInfo.Origin == AbilityOrigin.AO_ITEM)
            {
                return(0);
            }

            if (_caster is Player)
            {
                ((Player)_caster).TacInterface.ModifyInitials(_pendingInfo);
            }
            _caster.StsInterface.ModifyAbilityVolatiles(_pendingInfo);
            return(0);
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        public void GrantAbility(ushort abilityEntry)
        {
            _abilities.Add(AbilityMgr.GetAbilityInfo(abilityEntry));
            _abilitySet.Add(abilityEntry);

            SendAbilityLevels();

            ResendCooldown(abilityEntry);
        }
コード例 #5
0
        private bool AllowCast()
        {
            AbilityResult myResult = AbilityResult.ABILITYRESULT_OK;

            if (AbInfo.Target != null)
            {
                if (AbInfo.Target.IsDead && !AbInfo.ConstantInfo.AffectsDead)
                {
                    myResult = AbilityResult.ABILITYRESULT_ILLEGALTARGET_DEAD;
                }
                else if (!AbInfo.Target.IsDead && AbInfo.ConstantInfo.AffectsDead)
                {
                    myResult = AbilityResult.ABILITYRESULT_ILLEGALTARGET_NOT_DEAD_ALLY;
                }

                else if (AbInfo.Target != _caster)
                {
                    if (AbInfo.ConstantInfo.CastAngle != 0 && _caster.IsMoving && !_caster.IsObjectInFront(AbInfo.Target, AbInfo.ConstantInfo.CastAngle))
                    {
                        myResult = AbilityResult.ABILITYRESULT_OUT_OF_ARC;
                    }

                    // Explicit LOS check for move-cast abilities
                    if (AbInfo.CastTime > 0 && AbInfo.CanCastWhileMoving && AbInfo.Target != null && !_caster.LOSHit(AbInfo.Target))
                    {
                        myResult = AbilityResult.ABILITYRESULT_NOT_VISIBLE;
                    }
                }
            }

            if (myResult != AbilityResult.ABILITYRESULT_OK)
            {
                CancelCast((ushort)myResult);
                return(false);
            }

            if (myResult == AbilityResult.ABILITYRESULT_OK && _caster.ItmInterface != null)
            {
                myResult = _caster.ItmInterface.WeaponCheck(AbInfo.ConstantInfo.WeaponNeeded);
            }

            if (AbInfo.ApCost > 0 && _caster is Player && !_caster.ConsumeActionPoints(AbInfo.ApCost))
            {
                myResult = AbilityResult.ABILITYRESULT_AP;
            }

            if (myResult != AbilityResult.ABILITYRESULT_OK)
            {
                CancelCast((ushort)myResult);
                return(false);
            }

            AbilityMgr.GetCommandsFor(_caster, AbInfo);

            return(true);
        }
コード例 #6
0
        private bool AllowCastAtPos()
        {
            if (AbInfo.ApCost > 0 && !_caster.ConsumeActionPoints(AbInfo.ApCost))
            {
                CancelCast(0);
                return(false);
            }

            AbilityMgr.GetCommandsFor(_caster, AbInfo);

            return(true);
        }
コード例 #7
0
        /// <summary>
        /// Takes old level and new level to handle .modify level
        /// </summary>
        /// <param name="oldLevel"></param>
        /// <param name="newLevel"></param>
        public void OnPlayerLeveled(byte oldLevel, byte newLevel)
        {
            List <AbilityInfo> newAbilities = AbilityMgr.GetAvailableCareerAbilities(((Player)_unitOwner).Info.CareerLine, oldLevel + 1, newLevel);

            _abilities.AddRange(newAbilities);

            foreach (AbilityInfo ab in newAbilities)
            {
                _abilitySet.Add(ab.Entry);
            }

            SendMasteryPointsUpdate();
            SendAbilityLevels();
        }
コード例 #8
0
        public override void Update(long msTick)
        {
            if (msTick <= _rezTime)
            {
                return;
            }

            _slayerChoppa.RezUnit(_slayerChoppa.Realm == Realms.REALMS_REALM_ORDER ? (ushort)1489 : (ushort)1795, 25, true);

            AbilityDamageInfo damageThisPass = AbilityMgr.GetExtraDamageFor(_slayerChoppa.Realm == Realms.REALMS_REALM_ORDER ? (ushort)1489 : (ushort)1795, 0, 0);

            List <Object> objects;

            lock (_slayerChoppa.PlayersInRange)
                objects = new List <Object>(_slayerChoppa.ObjectsInRange);

            int count = 0;

            foreach (Object obj in objects)
            {
                Unit unit = obj as Unit;
                if (unit == null || unit == _slayerChoppa)
                {
                    continue;
                }

                if (unit.ObjectWithinRadiusFeet(_slayerChoppa, 40) && CombatInterface.CanAttack(_slayerChoppa, unit) && _slayerChoppa.LOSHit(unit))
                {
                    CombatManager.InflictDamage(damageThisPass.Clone(), _slayerChoppa.AbtInterface.GetMasteryLevelFor(3), _slayerChoppa, unit);
                }

                ++count;

                if (count == 9)
                {
                    break;
                }
            }

            Dispose();
        }
コード例 #9
0
        public override bool Load()
        {
            if (_playerOwner != null)
            {
                InitializeCareerMastery();
                LoadCareerAbilities();
                RefreshBonusMasteryPoints();

                _abilityProcessor = new AbilityProcessor(_unitOwner, this);
            }

            Creature creature = _Owner as Creature;

            if (creature != null && !(_Owner is Pet))
            {
                NPCAbilities = AbilityMgr.GetCreatureAbilities(creature.Spawn.Proto.Entry);
            }

            _Owner.EvtInterface.AddEventNotify(EventName.OnMove, OnPlayerMoved);

            return(base.Load());
        }
コード例 #10
0
        private void LoadCareerAbilities()
        {
            _abilities = AbilityMgr.GetAvailableCareerAbilities(_playerOwner.Info.CareerLine, 0, _playerOwner.Level);

            foreach (AbilityInfo ab in _abilities)
            {
                _abilitySet.Add(ab.Entry);
            }

            List <AbilityInfo> masteryAbilities = AbilityMgr.GetMasteryAbilities(_playerOwner.Info.CareerLine);

            foreach (AbilityInfo ab in masteryAbilities)
            {
                byte entry = (byte)((ab.ConstantInfo.PointCost - 1) / 2 - 1);
                _masteryAbilities[ab.ConstantInfo.MasteryTree - 1, entry] = ab;

                if (_activeSkillsInTree[ab.ConstantInfo.MasteryTree - 1, entry] == 1)
                {
                    _abilities.Add(ab);
                    _abilitySet.Add(ab.Entry);
                }
            }
        }
コード例 #11
0
        private void InvokeChannelBuff()
        {
            byte desiredLevel = _channelInfo.Level;

            if (_channelInfo.BoostLevel > 0 && _caster != _target)
            {
                desiredLevel = _channelInfo.BoostLevel;

                    #if DEBUG
                ((Player)_caster).SendClientMessage("Boost debug: Casting with level " + desiredLevel + " on target " + _target.Name);
                    #endif
            }

            BuffInfo buffInfo = AbilityMgr.GetBuffInfo(_channelInfo.Entry, _host, _target);
            if (!string.IsNullOrEmpty(buffInfo.AuraPropagation))
            {
                _target.BuffInterface.QueueBuff(new BuffQueueInfo(_caster, desiredLevel, buffInfo, BuffEffectInvoker.CreateAura, ChannelInitialization));
            }
            else
            {
                _target.BuffInterface.QueueBuff(new BuffQueueInfo(_caster, desiredLevel, buffInfo, ChannelInitialization));
            }
        }
コード例 #12
0
        /// <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);
        }
コード例 #13
0
        /// <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);
                }
            }
        }
コード例 #14
0
        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);
            }
        }