Example #1
0
    def send(self, vendor, player):
        if len(self.items) == 0:
            return False

        socket = player.socket  # Cache the object

        # Make sure the packs are known to the player
        # If this fails, the client will CRASH!
        socket.sendobject(vendor.itemonlayer(LAYER_NPCRESTOCK))
        socket.sendobject(vendor.itemonlayer(LAYER_NPCNORESTOCK))
        socket.sendobject(vendor.itemonlayer(LAYER_NPCSELL))

        self.items.sort(
            lambda x, y: cmp(x[1], y[1]))  # Sort the itemlist by serials first

        self.createContentPacket(vendor).send(
            socket)  # Send the content packet
        self.createBuyInfoPacket(vendor).send(
            socket)  # Send the buy info packet
        self.createShowGumpPacket(vendor).send(socket)  # Show the buy gump
        socket.resendstatus()  # Resend the status (Gold)

        # Send the item tooltips to the client
        for item in self.tooltips:
            socket.sendtooltip(item)

        return True
Example #2
0
    def createBuyInfoPacket(self, vendor):
        size = 8

        for item in self.items:
            size += 6 + len(item[BuyList.ITEM_DESCRIPTION])

        # Get the restock container serial from the vendor
        restock = vendor.itemonlayer(LAYER_NPCRESTOCK)

        packet = wolfpack.packet(0x74, size)
        packet.setshort(1, size)

        if restock:
            packet.setint(3, restock.serial)
        else:
            packet.setint(3, -1)

        packet.setbyte(7, len(self.items))  # Set length of list

        offset = 8

        for item in self.items:
            packet.setint(offset, item[BuyList.ITEM_PRICE])  # Price
            packet.setbyte(offset + 4,
                           len(item[BuyList.ITEM_DESCRIPTION]) +
                           1)  # Length of Description
            packet.setascii(offset + 5, item[
                BuyList.ITEM_DESCRIPTION])  # Copy the string into the packet
            offset += 5 + len(item[BuyList.ITEM_DESCRIPTION]) + 1

        return packet
Example #3
0
	def createBuyInfoPacket(self, vendor):
		size = 8
		
		for item in self.items:
			size += 6 + len(item[BuyList.ITEM_DESCRIPTION])
		
		# Get the restock container serial from the vendor
		restock = vendor.itemonlayer(LAYER_NPCRESTOCK)
				
		packet = wolfpack.packet(0x74, size)
		packet.setshort(1, size)
		
		if restock:
			packet.setint(3, restock.serial)
		else:
			packet.setint(3, -1)
			
		packet.setbyte(7, len(self.items)) # Set length of list
		
		offset = 8
		
		for item in self.items:
			packet.setint(offset, item[BuyList.ITEM_PRICE]) # Price
			packet.setbyte(offset + 4, len(item[BuyList.ITEM_DESCRIPTION]) + 1) # Length of Description
			packet.setascii(offset + 5, item[BuyList.ITEM_DESCRIPTION]) # Copy the string into the packet
			offset += 5 + len(item[BuyList.ITEM_DESCRIPTION]) + 1
			
		return packet
Example #4
0
	def send(self, vendor, player):		
		if len(self.items) == 0:
			return False
		
		socket = player.socket # Cache the object
		
		# Make sure the packs are known to the player
		# If this fails, the client will CRASH!
		socket.sendobject(vendor.itemonlayer(LAYER_NPCRESTOCK))
		socket.sendobject(vendor.itemonlayer(LAYER_NPCNORESTOCK))
		socket.sendobject(vendor.itemonlayer(LAYER_NPCSELL))

		self.items.sort(lambda x,y : cmp(x[1], y[1])) # Sort the itemlist by serials first

		self.createContentPacket(vendor).send(socket) # Send the content packet
		self.createBuyInfoPacket(vendor).send(socket) # Send the buy info packet
		self.createShowGumpPacket(vendor).send(socket) # Show the buy gump
		socket.resendstatus() # Resend the status (Gold)
		
		# Send the item tooltips to the client
		for item in self.tooltips:
			socket.sendtooltip(item)
		
		return True