public void Move(Packet inPacket) { byte portalCount = inPacket.ReadByte(); if (portalCount != this.PortalCount) { MainForm.Instance.Log("Character '{0}' is moving with an invalid Portal Count '{1}'.", this.Name, portalCount); return; } Movements movements = Movements.Parse(inPacket); foreach (Movement movement in movements) { if (movement is AbsoluteMovement) { this.Position = ((AbsoluteMovement)movement).Position; } if (!(movement is EquipmentMovement)) { this.Stance = movement.NewStance; } } inPacket.Reset(2); using (Packet p = new Packet(ServerMessages.CharacterMovement)) { p.WriteInt(this.ID); p.WriteBytes(inPacket.ReadLeftoverBytes()); this.Field.Broadcast(p, this); } }
public void Move(Packet inPacket) { short movementId = inPacket.ReadShort(); bool useSkill = (inPacket.ReadByte() & 0xF) != 0; int skillUnknown1 = inPacket.ReadByte() & 0xFF; byte skillId = inPacket.ReadByte(); byte skillLevel = inPacket.ReadByte(); short delay = inPacket.ReadShort(); Point startPosition = null; if (inPacket.ReadBool()) { startPosition = new Point(inPacket.ReadShort(), inPacket.ReadShort()); } inPacket.Skip(27); Movements movements = Movements.Parse(inPacket.ReadBytes()); MobSkill skill = null; if (useSkill && this.Skills.Count > 0) { skill = this.Skills.Random; } else if ((skillId >= 100 && skillId <= 200) && this.Skills.Contains(skillId, skillLevel)) // TODO: Is this necessary? { skill = this.Skills[skillId]; } if (skill != null) { if (this.CurrentHP * 100 / this.MaxHP > skill.PercentageLimitHP || (this.Cooldowns.ContainsKey(skill) && this.Cooldowns[skill].AddSeconds(skill.Cooldown) >= DateTime.Now) || ((MobSkillName)skill.MapleID) == MobSkillName.Summon && this.Map.Mobs.Count >= 100) { skill = null; } } if (skill != null) { skill.Cast(this); } using (Packet outPacket = new Packet(MapleServerOperationCode.MoveMonsterResponse)) { outPacket.WriteInt(this.ObjectID); outPacket.WriteShort(movementId); outPacket.WriteBool(useSkill); outPacket.WriteShort((short)this.CurrentMP); outPacket.WriteByte((byte)(skill == null ? 0 : skill.MapleID)); outPacket.WriteByte((byte)(skill == null ? 0 : skill.Level)); outPacket.WriteInt(); this.Controller.Client.Send(outPacket); } using (Packet outPacket = new Packet(MapleServerOperationCode.MoveMonster)) { outPacket.WriteInt(this.ObjectID); outPacket.WriteShort(); outPacket.WriteBool(useSkill); outPacket.WriteByte((byte)skillUnknown1); outPacket.WriteByte(skillId); outPacket.WriteByte(skillLevel); outPacket.WriteShort(delay); outPacket.WriteShort(); if (startPosition != null) { outPacket.WriteShort(startPosition.X); outPacket.WriteShort(startPosition.Y); } outPacket.WriteShort(this.Position.X); outPacket.WriteShort(this.Position.Y); outPacket.WriteInt(); outPacket.WriteBytes(movements.ToByteArray()); this.Controller.Map.Broadcast(this.Controller, outPacket); } foreach (Movement movement in movements) // TODO: Inheritable. Moves, has stance... AnimatedMapleMap? F**k I hate inheritance. { if (movement is AbsoluteMovement) { this.Position = ((AbsoluteMovement)movement).Position; } if (!(movement is EquipmentMovement)) { this.Stance = movement.NewStance; } } }