Use() public méthode

Handles attack.
public Use ( Creature attacker, Skill skill, long targetEntityId ) : CombatSkillResult
attacker Aura.Channel.World.Entities.Creature The creature attacking.
skill Skill The skill being used.
targetEntityId long The entity id of the target.
Résultat CombatSkillResult
Exemple #1
0
        /// <summary>
        /// Handles skill usage.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skill"></param>
        /// <param name="packet"></param>
        public void Use(Creature creature, Skill skill, Packet packet)
        {
            var targetEntityId = packet.GetLong();

            // Similar to WM there is a case where these aren't sent.
            // Apparently this can happen if you activate the skill while
            // targetting an enemy.
            var unk1 = (packet.Peek() != PacketElementType.None ? packet.GetInt() : 0);
            var unk2 = (packet.Peek() != PacketElementType.None ? packet.GetInt() : 0);

            if (_cm == null)
            {
                _cm = ChannelServer.Instance.SkillManager.GetHandler <CombatMastery>(SkillId.CombatMastery);
            }

            // TODO: Check duration

            var attackResult = false;

            var target = creature.Region.GetCreature(targetEntityId);

            if (target != null && !creature.IsStunned && creature.CanTarget(target))
            {
                var pos       = creature.GetPosition();
                var targetPos = target.GetPosition();
                var inRange   = pos.InRange(targetPos, creature.AttackRangeFor(target));

                if (!inRange)
                {
                    var telePos = pos.GetRelative(targetPos, -creature.AttackRangeFor(target) + 100);

                    // Check teleport distance
                    if (pos.GetDistance(telePos) > skill.RankData.Var3 + 100)
                    {
                        Send.Notice(creature, "Out of range");
                    }
                    else
                    {
                        Send.Effect(creature, Effect.SilentMoveTeleport, targetEntityId, (byte)0);

                        creature.SetPosition(telePos.X, telePos.Y);
                        Send.SkillTeleport(creature, telePos.X, telePos.Y);

                        inRange = true;
                    }
                }

                if (inRange)
                {
                    attackResult = (_cm.Use(creature, skill, targetEntityId) == CombatSkillResult.Okay);
                }
            }

            Send.CombatAttackR(creature, attackResult);

            Send.SkillUse(creature, skill.Info.Id, targetEntityId, unk1, unk2);
        }
Exemple #2
0
        /// <summary>
        /// Handles skill usage.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skill"></param>
        /// <param name="packet"></param>
        public void Use(Creature creature, Skill skill, Packet packet)
        {
            var targetEntityId = packet.GetLong();
            var unk1           = packet.GetInt();
            var unk2           = packet.GetInt();

            if (_cm == null)
            {
                _cm = ChannelServer.Instance.SkillManager.GetHandler <CombatMastery>(SkillId.CombatMastery);
            }

            // TODO: Check duration

            var attackResult = false;

            var target = creature.Region.GetCreature(targetEntityId);

            if (target != null && !creature.IsStunned && creature.CanTarget(target))
            {
                var pos       = creature.GetPosition();
                var targetPos = target.GetPosition();
                var inRange   = pos.InRange(targetPos, creature.AttackRangeFor(target));

                if (!inRange)
                {
                    var telePos = pos.GetRelative(targetPos, -creature.AttackRangeFor(target) + 100);

                    // Check teleport distance
                    if (pos.GetDistance(telePos) > skill.RankData.Var3 + 100)
                    {
                        Send.Notice(creature, "Out of range");
                    }
                    else
                    {
                        Send.Effect(creature, Effect.SilentMoveTeleport, targetEntityId, (byte)0);

                        creature.SetPosition(telePos.X, telePos.Y);
                        Send.SkillTeleport(creature, telePos.X, telePos.Y);

                        inRange = true;
                    }
                }

                if (inRange)
                {
                    attackResult = (_cm.Use(creature, skill, targetEntityId) == CombatSkillResult.Okay);
                }
            }

            Send.CombatAttackR(creature, attackResult);

            Send.SkillUse(creature, skill.Info.Id, targetEntityId, unk1, unk2);
        }