SetPosition() public method

Sets position and destination.
public SetPosition ( int x, int y ) : Position
x int
y int
return Position
Esempio n. 1
0
		public void Use(Creature creature, Skill skill, Packet packet)
		{
			var targetPos = new Position(packet.GetLong());

			// Check distance to target position
			if (!creature.GetPosition().InRange(targetPos, (int)skill.RankData.Var2 + DistanceBuffer))
			{
				Send.Notice(creature, Localization.Get("Out of range."));
				Send.SkillUse(creature, skill.Info.Id, 0);
				return;
			}

			// Stop creature's movement.
			creature.StopMove();

			// Teleport effect (does not actually teleport)
			Send.Effect(creature, Effect.SilentMoveTeleport, (byte)2, targetPos.X, targetPos.Y);

			// Teleport player to target position
			creature.SetPosition(targetPos.X, targetPos.Y);
			Send.SkillTeleport(creature, targetPos.X, targetPos.Y);

			Send.SkillUse(creature, skill.Info.Id, 1);
		}
Esempio n. 2
0
		/// <summary>
		/// Sets new position for target, based on attacker's position
		/// and the distance, takes collision into consideration.
		/// </summary>
		/// <param name="target">Entity to be knocked back</param>
		/// <param name="distance">Distance to knock back the target</param>
		/// <returns>New position</returns>
		public Position Shove(Creature target, int distance)
		{
			var attackerPosition = this.GetPosition();
			var targetPosition = target.GetPosition();

			var newPos = attackerPosition.GetRelative(targetPosition, distance);

			Position intersection;
			if (target.Region.Collisions.Find(targetPosition, newPos, out intersection))
				newPos = targetPosition.GetRelative(intersection, -50);

			target.SetPosition(newPos.X, newPos.Y);

			return newPos;
		}
Esempio n. 3
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);
        }
Esempio n. 4
0
File: Door.cs Progetto: xKamuna/aura
		/// <summary>
		/// Door's behavior when it's not locked.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="prop"></param>
		private void WarpInside(Creature creature, Prop prop)
		{
			var creaturePos = creature.GetPosition();
			var cCoord = new Position(creaturePos.X / Dungeon.TileSize, creaturePos.Y / Dungeon.TileSize);

			if (cCoord == _closedFrom)
			{
				Send.Notice(creature, NoticeType.MiddleSystem, Localization.Get("There is a monster still standing.\nYou must defeat all the monsters for the door to open."));
				return;
			}

			var x = _closedFrom.X * Dungeon.TileSize + Dungeon.TileSize / 2;
			var y = _closedFrom.Y * Dungeon.TileSize + Dungeon.TileSize / 2;

			if (cCoord.X < _closedFrom.X)
				x -= 1000;
			else if (cCoord.X > _closedFrom.X)
				x += 1000;
			else if (cCoord.Y < _closedFrom.Y)
				y -= 1000;
			else if (cCoord.Y > _closedFrom.Y)
				y += 1000;

			creature.SetPosition(x, y);
			Send.SetLocation(creature, x, y);
		}
Esempio n. 5
0
		public void Use(Creature creature, Skill skill, long targetEntityId, int unk1, int unk2)
		{

			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.IsOnAttackDelay && creature.CanTarget(target) && creature.CanAttack(target))
			{
				var pos = creature.GetPosition();
				var targetPos = target.GetPosition();
				var inRange = (pos.InRange(targetPos, creature.AttackRangeFor(target))
				&& !creature.Region.Collisions.Any(pos, targetPos) // Check collisions between position
				&& !target.Conditions.Has(ConditionsA.Invisible)); // Check visiblility (GM)

				if (!inRange && !target.IsNotReadyToBeHit)
				{
					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);
		}