Aura.Channel.Skills.Combat.FinalHit.Use C# (CSharp) Method

Use() public method

Handles skill usage.
public Use ( Creature creature, Skill skill, Aura.Shared.Network.Packet packet ) : void
creature Aura.Channel.World.Entities.Creature
skill Skill
packet Aura.Shared.Network.Packet
return void
		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);

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