public static void HandleNpcMove(MapleClient client, InPacket iPacket) { int objectID = iPacket.ReadInt(); Npc npc; try { npc = client.Character.ControlledNpcs[objectID]; } catch (KeyNotFoundException) { return; } byte a = iPacket.ReadByte(); byte b = iPacket.ReadByte(); Movements movements = null; using (OutPacket oPacket = new OutPacket(SendOps.NpcMove)) { oPacket .WriteInt(npc.ObjectID) .WriteByte(a) .WriteByte(b); if (npc.Data.IsMoving) { movements = Movements.Decode(iPacket); movements.Encode(oPacket); } client.Character.Map.Broadcast(oPacket); } }
public static void OnMobMove(MapleClient client, InPacket iPacket) { int objectID = iPacket.ReadInt(); Mob mob; try { mob = client.Character.ControlledMobs[objectID]; } catch (KeyNotFoundException) { return; } short moveAction = iPacket.ReadShort(); bool cheatResult = (iPacket.ReadByte() & 0xF) != 0; byte centerSplit = iPacket.ReadByte(); int illegalVelocity = iPacket.ReadInt(); byte unknown = iPacket.ReadByte(); iPacket.ReadInt(); Movements movements = Movements.Decode(iPacket); Movement lastMovement = movements[movements.Count - 1]; mob.Position = lastMovement.Position; mob.Foothold = lastMovement.Foothold; mob.Stance = lastMovement.Stance; using (OutPacket oPacket = new OutPacket(SendOps.MobCtrlAck)) { oPacket .WriteInt(objectID) .WriteShort(moveAction) .WriteBool(cheatResult) .WriteShort() // NOTE: Mob mana. .WriteByte() // NOTE: Ability ID. .WriteByte(); // NOTE: Ability level. client.Send(oPacket); } using (OutPacket oPacket = new OutPacket(SendOps.MobMove)) { oPacket .WriteInt(objectID) .WriteBool(cheatResult) .WriteByte(centerSplit) .WriteInt(illegalVelocity); movements.Encode(oPacket); client.Character.Map.Broadcast(oPacket, client.Character); } }
public static void OnMove(MapleClient client, InPacket iPacket) { Movements movements = Movements.Decode(iPacket); // TODO: Validate movements. Movement lastMovement = movements[movements.Count - 1]; client.Character.Position = lastMovement.Position; client.Character.Foothold = lastMovement.Foothold; client.Character.Stance = lastMovement.Stance; using (OutPacket oPacket = new OutPacket(SendOps.UserMove)) { oPacket.WriteInt(client.Character.ID); movements.Encode(oPacket); client.Character.Map.Broadcast(oPacket, client.Character); } }