Esempio n. 1
0
// WritePacket write the needed object data to a Packet and returns it
func (m *TurnMessage) WritePacket() pnet.IPacket {
	packet := pnet.NewPacketExt(m.GetHeader())
	packet.AddUint64(m.Creature.GetUID())
	packet.AddUint16(m.Direction)

	return packet
}
Esempio n. 2
0
// WritePacket write the needed object data to a Packet and returns it
func (m *WalkMessage) WritePacket() pnet.IPacket {
	packet := pnet.NewPacketExt(m.GetHeader())
	packet.AddUint64(m.Creature.GetUID())
	packet.AddUint16(uint16(m.From.X))
	packet.AddUint16(uint16(m.From.Y))
	packet.AddUint16(uint16(m.To.X))
	packet.AddUint16(uint16(m.To.Y))

	return packet
}
Esempio n. 3
0
// WritePacket write the needed object data to a Packet and returns it
func (m *SendTilesMessage) WritePacket() pnet.IPacket {
	totalTiles := uint16(len(m.tiles))
	packet := pnet.NewPacketExt(m.GetHeader())
	packet.AddUint16(totalTiles)

	if totalTiles == 0 {
		return packet
	}

	for _, tile := range m.tiles {
		if tile == nil {
			continue
		}

		packet.AddUint16(uint16(tile.GetX()))
		packet.AddUint16(uint16(tile.GetY()))

		// Loop TilePointLayers
		tilePointLayers := tile.GetTilePointLayers()
		packet.AddUint16(uint16(len(tilePointLayers)))
		for level, tilePointLayer := range tilePointLayers {
			if tilePointLayer == nil {
				continue
			}

			packet.AddUint8(uint8(level))
			packet.AddUint16(uint16(tilePointLayer.GetBlocking()))

			// Loop TilePointTileLayers
			tilePointTileLayers := tilePointLayer.GetTilePointTileLayers()
			packet.AddUint16(uint16(len(tilePointTileLayers)))
			for layer, tilePointTileLayer := range tilePointTileLayers {
				if tilePointTileLayer == nil {
					continue
				}

				packet.AddUint8(uint8(layer))
				packet.AddString(tilePointTileLayer.GetTileId())
			}
		}
	}

	m.tiles = make(map[int64]*world.TilePoint)

	return packet
}
// WritePacket write the needed object data to a Packet and returns it
func (m *SendPlayerData) WritePacket() pnet.IPacket {
	packet := pnet.NewPacketExt(m.GetHeader())
	packet.AddUint64(uint64(m.UID))
	packet.AddString(m.Name)
	packet.AddUint16(uint16(m.Position.X))
	packet.AddUint16(uint16(m.Position.Y))
	packet.AddUint16(m.Direction)
	packet.AddUint32(uint32(m.Money))

	/*packet.AddUint8(uint8(m.Outfit.GetOutfitStyle(pul.OUTFIT_UPPER)))
	packet.AddUint32(uint32(m.Outfit.GetOutfitColour(pul.OUTFIT_UPPER)))
	packet.AddUint8(uint8(m.Outfit.GetOutfitStyle(pul.OUTFIT_NEK)))
	packet.AddUint32(uint32(m.Outfit.GetOutfitColour(pul.OUTFIT_NEK)))
	packet.AddUint8(uint8(m.Outfit.GetOutfitStyle(pul.OUTFIT_HEAD)))
	packet.AddUint32(uint32(m.Outfit.GetOutfitColour(pul.OUTFIT_HEAD)))
	packet.AddUint8(uint8(m.Outfit.GetOutfitStyle(pul.OUTFIT_FEET)))
	packet.AddUint32(uint32(m.Outfit.GetOutfitColour(pul.OUTFIT_FEET)))
	packet.AddUint8(uint8(m.Outfit.GetOutfitStyle(pul.OUTFIT_LOWER)))
	packet.AddUint32(uint32(m.Outfit.GetOutfitColour(pul.OUTFIT_LOWER)))*/

	return packet
}
Esempio n. 5
0
// WritePacket write the needed object data to a Packet and returns it
func (m *CreatureAddMessage) WritePacket() pnet.IPacket {
	packet := pnet.NewPacketExt(m.GetHeader())
	packet.AddUint64(m.Creature.GetUID())
	packet.AddString(m.Creature.GetName())
	packet.AddUint16(uint16(m.Creature.GetPosition().X))
	packet.AddUint16(uint16(m.Creature.GetPosition().Y))
	packet.AddUint16(m.Creature.GetDirection())

	// Outfit
	/*packet.AddUint8(uint8(m.Creature.GetOutfit().GetOutfitStyle(pul.OUTFIT_UPPER)))
	packet.AddUint32(uint32(m.Creature.GetOutfit().GetOutfitColour(pul.OUTFIT_UPPER)))
	packet.AddUint8(uint8(m.Creature.GetOutfit().GetOutfitStyle(pul.OUTFIT_NEK)))
	packet.AddUint32(uint32(m.Creature.GetOutfit().GetOutfitColour(pul.OUTFIT_NEK)))
	packet.AddUint8(uint8(m.Creature.GetOutfit().GetOutfitStyle(pul.OUTFIT_HEAD)))
	packet.AddUint32(uint32(m.Creature.GetOutfit().GetOutfitColour(pul.OUTFIT_HEAD)))
	packet.AddUint8(uint8(m.Creature.GetOutfit().GetOutfitStyle(pul.OUTFIT_UPPER)))
	packet.AddUint32(uint32(m.Creature.GetOutfit().GetOutfitColour(pul.OUTFIT_UPPER)))
	packet.AddUint8(uint8(m.Creature.GetOutfit().GetOutfitStyle(pul.OUTFIT_FEET)))
	packet.AddUint32(uint32(m.Creature.GetOutfit().GetOutfitColour(pul.OUTFIT_FEET)))
	packet.AddUint8(uint8(m.Creature.GetOutfit().GetOutfitStyle(pul.OUTFIT_LOWER)))
	packet.AddUint32(uint32(m.Creature.GetOutfit().GetOutfitColour(pul.OUTFIT_LOWER)))*/

	return packet
}
Esempio n. 6
0
// WritePacket write the needed object data to a Packet and returns it
func (m *LoginMessage) WritePacket() pnet.IPacket {
	packet := pnet.NewPacketExt(m.GetHeader())
	packet.AddUint32(uint32(m.Status))

	return packet
}
// WritePacket write the needed object data to a Packet and returns it
func (m *CreatureRemoveMessage) WritePacket() pnet.IPacket {
	packet := pnet.NewPacketExt(m.GetHeader())
	packet.AddUint64(m.Creature.GetUID())

	return packet
}