Esempio n. 1
0
def onUse(char, item):
    if item.getoutmostchar() != char:
        char.socket.sysmessage(
            tr('The book has to be in your belongings to be used.'))
        return True

    # This is annoying and eats bandwith but its the only way to "reopen" the spellbook
    # once its already open.
    #char.socket.removeobject(item)
    if item.container and item.container.isitem():
        char.socket.sendobject(item.container)
    char.socket.sendobject(item)

    packet = wolfpack.packet(0x24, 7)
    packet.setint(1, item.serial)
    packet.setshort(5, 0xffff)
    packet.send(char.socket)

    packet = wolfpack.packet(0xbf, 23)
    packet.setshort(1, 23)  # Packet length
    packet.setshort(3, 0x1b)  # 0xbf subcommand
    packet.setshort(5, 1)  # Unknown. Maybe it's a subsubcommand ?
    packet.setint(7, item.serial)  # Spellbook serial
    packet.setshort(11, item.id)  # Item id
    packet.setshort(
        13, 201)  # Scroll offset (1 = regular, 101 = necro, 201 = paladin)

    for i in range(0, 2):
        if not item.hastag('circle' + str(i + 1)):
            packet.setbyte(15 + i, 0)
        else:
            packet.setbyte(15 + i, int(item.gettag('circle' + str(i + 1))))

    packet.send(char.socket)
    return True
def onUse(char, item):
	if item.getoutmostchar() != char:
		char.socket.sysmessage('The book has to be in your belongings to be used.')
		return 1

	packet = wolfpack.packet( 0x24, 7 )
	packet.setint( 1, item.serial )
	packet.setshort( 5, 0xffff )
	packet.send( char.socket )

	packet = wolfpack.packet( 0xbf, 23 )
	packet.setshort( 1, 23 )	 # Packet length
	packet.setshort( 3, 0x1b )	 # 0xbf subcommand
	packet.setshort( 5, 1	 )	 # Unknown. Maybe it's a subsubcommand ?
	packet.setint( 7, item.serial ) # Spellbook serial
	packet.setshort( 11, item.id ) # Item id
	packet.setshort( 13, 201 ) # Scroll offset (1 = regular, 101 = paladin, 201 = necro)

	for i in range( 0, 2 ):
		if not item.hastag( 'circle' + str( i + 1 ) ):
			packet.setbyte( 15 + i, 0 )
		else:
			packet.setbyte( 15 + i, int( item.gettag( 'circle' + str( i + 1 ) ) ) )

	packet.send( char.socket )
	return 1
def onUse(char, item):
	if item.getoutmostchar() != char:
		char.socket.sysmessage(tr('The book has to be in your belongings to be used.'))
		return True

	# This is annoying and eats bandwith but its the only way to "reopen" the spellbook
	# once its already open.
	#char.socket.removeobject(item)
	if item.container and item.container.isitem():
		char.socket.sendobject(item.container)
	char.socket.sendobject(item)

	packet = wolfpack.packet( 0x24, 7 )
	packet.setint( 1, item.serial )
	packet.setshort( 5, 0xffff )
	packet.send( char.socket )

	packet = wolfpack.packet( 0xbf, 23 )
	packet.setshort( 1, 23 )	 # Packet length
	packet.setshort( 3, 0x1b )	 # 0xbf subcommand
	packet.setshort( 5, 1	 )	 # Unknown. Maybe it's a subsubcommand ?
	packet.setint( 7, item.serial ) # Spellbook serial
	packet.setshort( 11, item.id ) # Item id
	packet.setshort( 13, 201 ) # Scroll offset (1 = regular, 101 = necro, 201 = paladin)

	for i in range( 0, 2 ):
		if not item.hastag( 'circle' + str( i + 1 ) ):
			packet.setbyte( 15 + i, 0 )
		else:
			packet.setbyte( 15 + i, int( item.gettag( 'circle' + str( i + 1 ) ) ) )

	packet.send( char.socket )
	return True
def onUse(char, board):
	if not char.canreach(board, 3):
		char.socket.clilocmessage(1019045)
		return 1

	# Build a packet for the bulletin board index
	packet = wolfpack.packet(0x71, 38)
	packet.setshort(1, 38)
	packet.setbyte(3, 0) # Display Bulletin Board
	packet.setint(4, board.serial) # Bulletin Board Serial

	# Bulletin Board name in UTF-8 encoding (max. 29 chars)
	if len(board.name) == 0:
		name = tr('bulletin board')
	else:
		name = board.name.encode('utf-8')

	for i in range(0,min(len(name),30)):
		packet.setbyte(8 + i, ord(name[i]))

	packet.send(char.socket)

	# Collect message information for this board
	messages = findMessages(board, [])

	# Sort the messages by time
	messages.sort(compare_message)

	# Send content of container to socket
	packet = wolfpack.packet(0x3c, 5 + 19 * len(messages))
	packet.setshort(1, packet.size)
	packet.setshort(3, len(messages))

	offset = 5

	for item in messages:
		packet.setint(offset, item[0])
		packet.setshort(offset + 4, 0xeb0)
		packet.setbyte(offset + 6, 0)
		packet.setshort(offset + 7, 0)
		packet.setshort(offset + 9, 0)
		packet.setshort(offset + 11, 0)
		packet.setint(offset + 13, board.serial)
		packet.setshort(offset + 17, 0)
		offset += 19

	packet.send(char.socket)

	return 1
Esempio n. 5
0
def onUse(char, board):
    if not char.canreach(board, 3):
        char.socket.clilocmessage(1019045)
        return 1

    # Build a packet for the bulletin board index
    packet = wolfpack.packet(0x71, 38)
    packet.setshort(1, 38)
    packet.setbyte(3, 0)  # Display Bulletin Board
    packet.setint(4, board.serial)  # Bulletin Board Serial

    # Bulletin Board name in UTF-8 encoding (max. 29 chars)
    if len(board.name) == 0:
        name = tr('bulletin board')
    else:
        name = board.name.encode('utf-8')

    for i in range(0, min(len(name), 30)):
        packet.setbyte(8 + i, ord(name[i]))

    packet.send(char.socket)

    # Collect message information for this board
    messages = findMessages(board, [])

    # Sort the messages by time
    messages.sort(compare_message)

    # Send content of container to socket
    packet = wolfpack.packet(0x3c, 5 + 19 * len(messages))
    packet.setshort(1, packet.size)
    packet.setshort(3, len(messages))

    offset = 5

    for item in messages:
        packet.setint(offset, item[0])
        packet.setshort(offset + 4, 0xeb0)
        packet.setbyte(offset + 6, 0)
        packet.setshort(offset + 7, 0)
        packet.setshort(offset + 9, 0)
        packet.setshort(offset + 11, 0)
        packet.setint(offset + 13, board.serial)
        packet.setshort(offset + 17, 0)
        offset += 19

    packet.send(char.socket)

    return 1
Esempio n. 6
0
def sendswing(attacker, defender):
	if attacker.socket:
		packet = wolfpack.packet(0x2f, 10)
		packet.setbyte(1, 0)
		packet.setint(2, attacker.serial)
		packet.setint(6, defender.serial)
		packet.send(attacker.socket)
Esempio n. 7
0
def target(player, arguments, target):
	# Check the target
	if not target.item or target.item.baseid not in ['fab', 'leatherdye', 'specialdye', 'runedye']:
		player.socket.clilocmessage(500857)
		return
		
	# Needs to in our belongings
	if target.item.getoutmostchar() != player:
		player.socket.clilocmessage(500364)
		return		

	# Wear out the tools
	dyes = wolfpack.finditem(arguments[0])
	if not checkdyes(player, dyes):
		return

	checkdyes(player, dyes, 1) # Wear out

	if target.item.baseid == 'leatherdye':
		leatherdye.pickHue(player, target.item) # Use special dye gump
		return
	elif target.item.baseid == 'specialdye':
		specialdye.pickHue(player, target.item) # Use special dye gump
		return
	elif target.item.baseid == 'runedye':
		runedye.pickHue(player, target.item) # Use special dye gump
		return

	# Send the dye dialog
	packet = wolfpack.packet(0x95, 9)
	packet.setint(1, target.item.serial)
	packet.setshort(7, 0xfab)
	packet.send(player.socket)
Esempio n. 8
0
def send_alreadyinconference(socket, channelname):

	chatpacket = wolfpack.packet(0xB2, 11 + (len(channelname) * 2))
	chatpacket.setshort(1, 11 + (len(channelname) * 2))
	chatpacket.setshort(3, 0x001A)
	chatpacket.setunicode(9,channelname + channelname)
	chatpacket.send(socket)
def sendmovingeffect(source, target, model, hue=0, speed=1, rendermode=0):
	# Build the packet
	packet = wolfpack.packet(0xC0, 36)
	packet.setbyte(1, 0) # Moving
	packet.setint(2, 0) # Source
	packet.setint(6, 0) # Target
	packet.setshort(10, model) # Effect Model
	packet.setshort(12, source.x) # Source X
	packet.setshort(14, source.y) # Source Y
	packet.setbyte(16, source.z) # Source Z
	packet.setshort(17, target.x) # Target X
	packet.setshort(19, target.y) # Target Y
	packet.setbyte(21, target.z) # Target Z	
	packet.setbyte(22, speed) # Speed
	packet.setbyte(23, 0) # Duration
	packet.setshort(24, 0) # Unknown
	packet.setbyte(26, 1) # Fixed Direction
	packet.setbyte(27, 0) # Explode on Impact
	packet.setint(28, hue) # Hue
	packet.setint(32, rendermode) # Rendermode
	
	# Search for sockets at the source location
	chars = wolfpack.chars(source.x, source.y, source.map, 18)
	for char in chars:
		if char.socket:	
			packet.send(char.socket)
Esempio n. 10
0
def sendmovingeffect(source, target, model, hue=0, speed=1, rendermode=0):
    # Build the packet
    packet = wolfpack.packet(0xC0, 36)
    packet.setbyte(1, 0)  # Moving
    packet.setint(2, 0)  # Source
    packet.setint(6, 0)  # Target
    packet.setshort(10, model)  # Effect Model
    packet.setshort(12, source.x)  # Source X
    packet.setshort(14, source.y)  # Source Y
    packet.setbyte(16, source.z)  # Source Z
    packet.setshort(17, target.x)  # Target X
    packet.setshort(19, target.y)  # Target Y
    packet.setbyte(21, target.z)  # Target Z
    packet.setbyte(22, speed)  # Speed
    packet.setbyte(23, 0)  # Duration
    packet.setshort(24, 0)  # Unknown
    packet.setbyte(26, 1)  # Fixed Direction
    packet.setbyte(27, 0)  # Explode on Impact
    packet.setint(28, hue)  # Hue
    packet.setint(32, rendermode)  # Rendermode

    # Search for sockets at the source location
    chars = wolfpack.chars(source.x, source.y, source.map, 18)
    for char in chars:
        if char.socket:
            packet.send(char.socket)
Esempio n. 11
0
def send_privatemessage(socket, message, language, targetsocket):

	# Get Chatname of Sender
	nick = socket.account.chatname

	# Decoding Message
	message = unicode(message, 'latin-1')

	# Data
	length = len(nick) * 2
	length += len(message) * 2
	length += 25
		
	# Send Packet
	chatpacket = wolfpack.packet(0xB2, length)
	chatpacket.setshort(1, length)
	chatpacket.setint(4, language)
	chatpacket.setshort(3, 0x0025)

	if socket == targetsocket:
		chatpacket.setbyte(9, 0x0034)
	elif socket.account.acl != 'player' or socket.hastag('Moderator'):
		chatpacket.setbyte(9, 0x0031)
	else:
		chatpacket.setshort(9, 0x0030)
	
	chatpacket.setunicode(11, '[PM] ' + nick + nick + ' [PM]')
	chatpacket.setunicode(23 + (len(nick) * 2), ' ' + message + message + ' ')
	chatpacket.send(targetsocket)
Esempio n. 12
0
def sendswing(attacker, defender):
	if attacker.socket:
		packet = wolfpack.packet(0x2f, 10)
		packet.setbyte(1, 0)
		packet.setint(2, attacker.serial)
		packet.setint(6, defender.serial)
		packet.send(attacker.socket)
Esempio n. 13
0
def onWalk(char, dir, sequence):
	# Find the spiderweb
	items = wolfpack.items(char.pos.x, char.pos.y, char.pos.map, 0)

	spiderweb = None

	for item in items:
		if item.hasscript( 'spiderweb' ):
			spiderweb = item
			break

	if spiderweb:
		# Damage the web until it disappears
		spiderweb.health = max(0, spiderweb.health - ceil(char.strength / 2.0))

		if spiderweb.health == 0:
			spiderweb.delete()
		else:
			if char.socket:
				if random.random() <= 0.25:
					char.socket.sysmessage( tr('You damage the spiderweb.') )
				packet = wolfpack.packet(0x21, 8)
				packet.setbyte(1, sequence)
				packet.setshort(2, char.pos.x)
				packet.setshort(4, char.pos.y)
				packet.setbyte(6, char.direction)
				packet.setbyte(7, char.pos.z)
				packet.send(char.socket)
				char.socket.walksequence = 0
			return True

	char.removescript( 'spiderweb' )
	if char.socket:
		char.socket.sysmessage( tr('You manage to break free of the spiderweb.') )
	return False
Esempio n. 14
0
def listusers(socket, channel):

	# Loop
	worldsocket = wolfpack.sockets.first()
	while worldsocket:

		# Checking for tags
		if worldsocket.hastag('InChat') and not worldsocket == socket:
			if worldsocket.gettag('ChatChannel') == channel:

				# Get Chatname
				chatname = worldsocket.account.chatname
				
				# Sending the message
				length = len(chatname) * 2
				extlength = length + 13
			
				chatpacket = wolfpack.packet(0xB2, extlength)
				chatpacket.setshort(1, extlength)
				chatpacket.setshort(3, 0x3EE)
				if worldsocket.account.acl != 'player' or worldsocket.hastag('Moderator'):
					chatpacket.setbyte(8, 0x31)
				else:
					chatpacket.setbyte(8, 0x30)
				chatpacket.setunicode(9, ' ' + chatname + chatname + ' ')
				chatpacket.send(socket)

		worldsocket = wolfpack.sockets.next()
Esempio n. 15
0
def target(player, arguments, target):
	# Check the target
	if not target.item or target.item.baseid not in ['fab', 'leatherdye', 'specialdye', 'runedye']:
		player.socket.clilocmessage(500857)
		return
		
	# Needs to in our belongings
	if target.item.getoutmostchar() != player:
		player.socket.clilocmessage(500364)
		return		

	# Wear out the tools
	dyes = wolfpack.finditem(arguments[0])
	if not checkdyes(player, dyes):
		return

	checkdyes(player, dyes, 1) # Wear out

	if target.item.baseid == 'leatherdye':
		leatherdye.pickHue(player, target.item) # Use special dye gump
		return
	elif target.item.baseid == 'specialdye':
		specialdye.pickHue(player, target.item) # Use special dye gump
		return
	elif target.item.baseid == 'runedye':
		runedye.pickHue(player, target.item) # Use special dye gump
		return

	# Send the dye dialog
	packet = wolfpack.packet(0x95, 9)
	packet.setint(1, target.item.serial)
	packet.setshort(7, 0xfab)
	packet.send(player.socket)
Esempio n. 16
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
Esempio n. 17
0
	def buildSellPacket(self, vendor):
		# Compile the size of the packet
		packetsize = 9
		for item in self.items:
			packetsize += 15 + len(item[SellList.ITEM_DESCRIPTION])
			
		packet = wolfpack.packet(0x9e, packetsize)
		packet.setshort(1, packetsize)
		packet.setint(3, vendor.serial)
		packet.setshort(7, len(self.items))

		offset = 9
		
		# Store every item in the sell list
		for item in self.items:
			packet.setint(offset, item[SellList.ITEM_SERIAL])
			packet.setshort(offset + 4, item[SellList.ITEM_ID])
			packet.setshort(offset + 6, item[SellList.ITEM_COLOR])
			packet.setshort(offset + 8, item[SellList.ITEM_AMOUNT])
			packet.setshort(offset + 10, item[SellList.ITEM_PRICE])
			packet.setshort(offset + 12, len(item[SellList.ITEM_DESCRIPTION]) + 1) # Description length
			packet.setascii(offset + 14, item[SellList.ITEM_DESCRIPTION])
			offset += 15 + len(item[SellList.ITEM_DESCRIPTION])
		
		return packet
Esempio n. 18
0
def send_message(worldsocket, socket, message, language):

	# Get Chatname of Sender
	chatname = socket.account.chatname

	# Decoding Message
	message = unicode(message, 'latin-1')
	
	# Data
	length = len(chatname) * 2
	length += len(message) * 2
	length += 17
		
	# Send Message
	chatpacket = wolfpack.packet(0xB2, length)
	chatpacket.setshort(1, length)
	chatpacket.setint(4, language)
	chatpacket.setshort(3, 0x0025)

	if socket == worldsocket:
		chatpacket.setbyte(9, 0x0034)
	elif socket.account.acl != 'player' or socket.hastag('Moderator'):
		chatpacket.setbyte(9, 0x0031)
	else:
		chatpacket.setshort(9, 0x0030)

	chatpacket.setunicode(11, ' ' + chatname + chatname + ' ')
	chatpacket.setunicode(15 + (len(chatname) * 2), ' ' + message + message + ' ')
	chatpacket.send(worldsocket)
Esempio n. 19
0
def sendtreasmap(player, item):

    # Get tags from map
    x = int(item.gettag('x'))
    y = int(item.gettag('y'))

    # Get Parameters
    width = 200
    height = 200
    xtop = x - 300
    ytop = y - 300
    xbottom = x + 300
    ybottom = y + 300

    # Send a map detail packet
    details = wolfpack.packet(0x90, 19)
    details.setint(1, item.serial)
    details.setshort(5, 0x139d)
    details.setshort(7, xtop)  # Upper Left X
    details.setshort(9, ytop)  # Upper Left Y
    details.setshort(11, xbottom)  # Lower Right X
    details.setshort(13, ybottom)  # Lower Right Y
    details.setshort(15, width)  # Gump Width
    details.setshort(17, height)  # Gump Height
    details.send(player.socket)

    # Remove all pins
    sendmapcommand(player.socket, item, 5)

    # Send all pins anew
    sendmapcommand(player.socket, item, 1, 0, 100, 100)

    # You cant edit this map
    sendmapcommand(player.socket, item, 7, 0)
Esempio n. 20
0
	def createContentPacket(self, vendor):
		size = 5 + len(self.items) * 19
		packet = wolfpack.packet(0x3c, size)
		
		packet.setshort(1, size)
		packet.setshort(3, len(self.items)) # Set the amount of items in the list
		
		offset = 5
		
		# I've always hated their way of sending vendor info
		for i in range(len(self.items) - 1, -1, -1):
			item = self.items[i] # Get the current item

			packet.setint(offset, item[BuyList.ITEM_SERIAL])
			packet.setshort(offset + 4, item[BuyList.ITEM_ID])
			packet.setbyte(offset + 6, 0) # ? -> offset
			packet.setshort(offset + 7, item[BuyList.ITEM_AMOUNT])
			packet.setshort(offset + 9, i + 1) # Starting at 1 instead of 0
			packet.setshort(offset + 11, 1) # y offset
			packet.setint(offset + 13, item[BuyList.ITEM_CONTAINER])
			packet.setshort(offset + 17, item[BuyList.ITEM_COLOR])
			
			offset += 19 # Increase offset
		
		return packet
Esempio n. 21
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
Esempio n. 22
0
    def buildSellPacket(self, vendor):
        # Compile the size of the packet
        packetsize = 9
        for item in self.items:
            packetsize += 15 + len(item[SellList.ITEM_DESCRIPTION])

        packet = wolfpack.packet(0x9e, packetsize)
        packet.setshort(1, packetsize)
        packet.setint(3, vendor.serial)
        packet.setshort(7, len(self.items))

        offset = 9

        # Store every item in the sell list
        for item in self.items:
            packet.setint(offset, item[SellList.ITEM_SERIAL])
            packet.setshort(offset + 4, item[SellList.ITEM_ID])
            packet.setshort(offset + 6, item[SellList.ITEM_COLOR])
            packet.setshort(offset + 8, item[SellList.ITEM_AMOUNT])
            packet.setshort(offset + 10, item[SellList.ITEM_PRICE])
            packet.setshort(offset + 12,
                            len(item[SellList.ITEM_DESCRIPTION]) +
                            1)  # Description length
            packet.setascii(offset + 14, item[SellList.ITEM_DESCRIPTION])
            offset += 15 + len(item[SellList.ITEM_DESCRIPTION])

        return packet
def sendtreasmap(player, item):

	# Get tags from map
	x = int(item.gettag('x'))
	y = int(item.gettag('y'))

	# Get Parameters
	width = 200
	height = 200
	xtop = x - 300
	ytop = y - 300
	xbottom = x + 300
	ybottom = y + 300

	# Send a map detail packet
	details = wolfpack.packet(0x90, 19)
	details.setint(1, item.serial)
	details.setshort(5, 0x139d)
	details.setshort(7, xtop) # Upper Left X
	details.setshort(9, ytop) # Upper Left Y
	details.setshort(11, xbottom) # Lower Right X
	details.setshort(13, ybottom) # Lower Right Y
	details.setshort(15, width) # Gump Width
	details.setshort(17, height) # Gump Height
	details.send(player.socket)

	# Remove all pins
	sendmapcommand(player.socket, item, 5)

	# Send all pins anew
	sendmapcommand(player.socket, item, 1, 0, 100, 100)

	# You cant edit this map
	sendmapcommand(player.socket, item, 7, 0)
Esempio n. 24
0
    def createContentPacket(self, vendor):
        size = 5 + len(self.items) * 19
        packet = wolfpack.packet(0x3c, size)

        packet.setshort(1, size)
        packet.setshort(3,
                        len(self.items))  # Set the amount of items in the list

        offset = 5

        # I've always hated their way of sending vendor info
        for i in range(len(self.items) - 1, -1, -1):
            item = self.items[i]  # Get the current item

            packet.setint(offset, item[BuyList.ITEM_SERIAL])
            packet.setshort(offset + 4, item[BuyList.ITEM_ID])
            packet.setbyte(offset + 6, 0)  # ? -> offset
            packet.setshort(offset + 7, item[BuyList.ITEM_AMOUNT])
            packet.setshort(offset + 9, i + 1)  # Starting at 1 instead of 0
            packet.setshort(offset + 11, 1)  # y offset
            packet.setint(offset + 13, item[BuyList.ITEM_CONTAINER])
            packet.setshort(offset + 17, item[BuyList.ITEM_COLOR])

            offset += 19  # Increase offset

        return packet
Esempio n. 25
0
def onUse(player, item):
  if checkdyes(player, item):
    packet = wolfpack.packet(0x95, 9)
    packet.setint(1, item.serial)
    packet.setshort(7, 0xfab)
    packet.send(player.socket)
  return 1
Esempio n. 26
0
def onUse(char, item):
    char.objectdelay = 0
    protected = False

    # If it's within another characters pack. This is true for player vendors for
    # instance.
    outmost = item.getoutmostchar()

    if outmost and outmost != char:
        protected = True

    if item.hastag("protected"):
        protected = True

        # Send BookOpen packet
        # Author / Title
    author = ""
    title = item.name

    if item.hastag("author"):
        author = item.gettag("author")

    title = title.encode("utf-8")
    author = author.encode("utf-8")

    # Calculate Packet Length
    packetlength = 15 + len(author) + 1 + len(title) + 1

    packet = wolfpack.packet(0xD4, packetlength)
    packet.setshort(1, packetlength)  # Packet length
    packet.setint(3, item.serial)  # Book Serial

    if not protected:
        packet.setbyte(7, 1)  # Flag Writeable
        packet.setbyte(8, 1)  # dito

    pages = 64
    if item.hastag("pages"):
        pages = int(item.gettag("pages"))

    packet.setshort(9, pages)

    packet.setshort(11, len(title) + 1)
    packet.setascii(13, title)

    packet.setshort(13 + len(title) + 1, len(author) + 1)
    packet.setascii(15 + len(title) + 1, author)

    packet.send(char.socket)

    if protected:
        return 1

        # Send a packet for each page !!
        # We could easily create packets bigger than 65k otherwise...
    for page in range(1, pages + 1):
        if item.hastag("page%u" % page):
            sendPage(char.socket, item.serial, page, item.gettag("page%u" % page).split("\n"))

    return 1
Esempio n. 27
0
def sendCodexOfWisdom(socket, topic, display = True):
	packet = wolfpack.packet(0xbf, 11)
	packet.setshort(1, 11)
	packet.setshort(3, 0x17) # SubCommand
	packet.setbyte(5, 1) # Unknown
	packet.setint(6, int(topic)) # The Topic ID
	packet.setbyte(10, int(display)) # Should the topic be displayed?
	packet.send(socket)
Esempio n. 28
0
def send_destroychannel(socket, channel):

	# Sending
	chatpacket = wolfpack.packet(0xB2, (len(channel) * 2) + 15)
	chatpacket.setshort(1, (len(channel) * 2) + 15)
	chatpacket.setshort(3, 0x3E9)
	chatpacket.setunicode(9,channel + channel)
	chatpacket.send(socket)
Esempio n. 29
0
def request(player, item, id):
	packet = wolfpack.packet(0x9a, 16)
	packet.setshort(1, 16)
	packet.setint(3, item.serial)
	packet.setint(7, id)
	packet.setint(11, 0) # Request/Reply
	packet.setbyte(15, 0)
	packet.send(player.socket)
Esempio n. 30
0
def sendCodexOfWisdom(socket, topic, display=True):
    packet = wolfpack.packet(0xbf, 11)
    packet.setshort(1, 11)
    packet.setshort(3, 0x17)  # SubCommand
    packet.setbyte(5, 1)  # Unknown
    packet.setint(6, int(topic))  # The Topic ID
    packet.setbyte(10, int(display))  # Should the topic be displayed?
    packet.send(socket)
Esempio n. 31
0
def sendmapcommand(socket, item, command, plotting=0, x=0, y=0):
    packet = wolfpack.packet(0x56, 11)
    packet.setint(1, item.serial)
    packet.setbyte(5, command)
    if plotting:
        packet.setbyte(6, 1)
    packet.setshort(7, x)
    packet.setshort(9, y)
    packet.send(socket)
Esempio n. 32
0
def sendmapcommand(socket, item, command, plotting=0, x=0, y=0):
    packet = wolfpack.packet(0x56, 11)
    packet.setint(1, item.serial)
    packet.setbyte(5, command)
    if plotting:
        packet.setbyte(6, 1)
    packet.setshort(7, x)
    packet.setshort(9, y)
    packet.send(socket)
Esempio n. 33
0
def sendmap(player, item, maptype):
    if maptype == 'preset' and item.hastag('preset'):
        preset = item.gettag('preset')
        if not preset in MAP_PRESETS:
            player.socket.sysmessage(tr('Unknown map preset: %s.') % preset)
            return
        (width, height, xtop, ytop, xbottom, ybottom) = MAP_PRESETS[preset]
    elif maptype == 'world':
        (width, height, xtop, ytop, xbottom, ybottom) = (400, 400, 0, 0, 5119,
                                                         4095)
    elif maptype == 'custom':
        (width, height, xtop, ytop, xbottom, ybottom) = (200, 200, 0, 0, 5119,
                                                         4095)
        if item.hastag('width'):
            width = int(item.gettag('width'))
        if item.hastag('height'):
            height = int(item.gettag('height'))
        if item.hastag('xtop'):
            xtop = int(item.gettag('xtop'))
        if item.hastag('xbottom'):
            xbottom = int(item.gettag('xbottom'))
        if item.hastag('ytop'):
            ytop = int(item.gettag('ytop'))
        if item.hastag('ybottom'):
            ybottom = int(item.gettag('ybottom'))
    else:
        player.socket.sysmessage(tr('Unknown map type: %s.') % maptype)
        return

    # Send a map detail packet
    details = wolfpack.packet(0x90, 19)
    details.setint(1, item.serial)
    details.setshort(5, 0x139d)
    details.setshort(7, xtop)  # Upper Left X
    details.setshort(9, ytop)  # Upper Left Y
    details.setshort(11, xbottom)  # Lower Right X
    details.setshort(13, ybottom)  # Lower Right Y
    details.setshort(15, width)  # Gump Width
    details.setshort(17, height)  # Gump Height
    details.send(player.socket)

    # Remove all pins
    sendmapcommand(player.socket, item, 5)

    # Send all pins anew
    pins = []
    if item.hastag('pins'):
        pins = item.gettag('pins').strip().split(';')

    for pin in pins:
        (x, y) = pin.split(',')
        sendmapcommand(player.socket, item, 1, x=int(x), y=int(y))

    protected = item.hastag('protected')
    editable = item.hastag('editable')
    sendmapcommand(player.socket, item, 7, not protected and editable)
Esempio n. 34
0
def sendclosetrade( socket, boxserial ):
	# 2 - close action
	action = 1
	packetlength = 8
	trade = wolfpack.packet( 0x6F, packetlength )
	trade.setshort( 1, packetlength )
	trade.setbyte( 3, action )
	trade.setint( 4, boxserial )
	trade.send( socket )
	return True
Esempio n. 35
0
def sendmap(player, item, maptype):
    if maptype == "preset" and item.hastag("preset"):
        preset = item.gettag("preset")
        if not preset in MAP_PRESETS:
            player.socket.sysmessage(tr("Unknown map preset: %s.") % preset)
            return
        (width, height, xtop, ytop, xbottom, ybottom) = MAP_PRESETS[preset]
    elif maptype == "world":
        (width, height, xtop, ytop, xbottom, ybottom) = (400, 400, 0, 0, 5119, 4095)
    elif maptype == "custom":
        (width, height, xtop, ytop, xbottom, ybottom) = (200, 200, 0, 0, 5119, 4095)
        if item.hastag("width"):
            width = int(item.gettag("width"))
        if item.hastag("height"):
            height = int(item.gettag("height"))
        if item.hastag("xtop"):
            xtop = int(item.gettag("xtop"))
        if item.hastag("xbottom"):
            xbottom = int(item.gettag("xbottom"))
        if item.hastag("ytop"):
            ytop = int(item.gettag("ytop"))
        if item.hastag("ybottom"):
            ybottom = int(item.gettag("ybottom"))
    else:
        player.socket.sysmessage(tr("Unknown map type: %s.") % maptype)
        return

        # Send a map detail packet
    details = wolfpack.packet(0x90, 19)
    details.setint(1, item.serial)
    details.setshort(5, 0x139D)
    details.setshort(7, xtop)  # Upper Left X
    details.setshort(9, ytop)  # Upper Left Y
    details.setshort(11, xbottom)  # Lower Right X
    details.setshort(13, ybottom)  # Lower Right Y
    details.setshort(15, width)  # Gump Width
    details.setshort(17, height)  # Gump Height
    details.send(player.socket)

    # Remove all pins
    sendmapcommand(player.socket, item, 5)

    # Send all pins anew
    pins = []
    if item.hastag("pins"):
        pins = item.gettag("pins").strip().split(";")

    for pin in pins:
        (x, y) = pin.split(",")
        sendmapcommand(player.socket, item, 1, x=int(x), y=int(y))

    protected = item.hastag("protected")
    editable = item.hastag("editable")
    sendmapcommand(player.socket, item, 7, not protected and editable)
Esempio n. 36
0
def sendmap(player, item, maptype):
	if maptype == 'preset' and item.hastag('preset'):
		preset = item.gettag('preset')
		if not MAP_PRESETS.has_key(preset):
			player.socket.sysmessage('Unknown map preset: %s.' % preset)
			return
		(width, height, xtop, ytop, xbottom, ybottom) = MAP_PRESETS[preset]
	elif maptype == 'world':
		(width, height, xtop, ytop, xbottom, ybottom) = (400, 400, 0, 0, 5119, 4095)
	elif maptype == 'custom':
		(width, height, xtop, ytop, xbottom, ybottom) = (200, 200, 0, 0, 5119, 4095)
		if item.hastag('width'):
			width = int(item.gettag('width'))
		if item.hastag('height'):
			height = int(item.gettag('height'))			
		if item.hastag('xtop'):
			xtop = int(item.gettag('xtop'))
		if item.hastag('xbottom'):
			xbottom = int(item.gettag('xbottom'))
		if item.hastag('ytop'):
			ytop = int(item.gettag('ytop'))
		if item.hastag('ybottom'):
			ybottom = int(item.gettag('ybottom'))						
	else:
		player.socket.sysmessage('Unknown map type: %s.' % maptype)
		return
	
	# Send a map detail packet
	details = wolfpack.packet(0x90, 19)
	details.setint(1, item.serial)
	details.setshort(5, 0x139d)
	details.setshort(7, xtop) # Upper Left X
	details.setshort(9, ytop) # Upper Left Y
	details.setshort(11, xbottom) # Lower Right X
	details.setshort(13, ybottom) # Lower Right Y
	details.setshort(15, width) # Gump Width
	details.setshort(17, height) # Gump Height
	details.send(player.socket)
	
	# Remove all pins
	sendmapcommand(player.socket, item, 5)
	
	# Send all pins anew
	pins = []
	if item.hastag('pins'):
		pins = item.gettag('pins').strip().split(';')
		
	for pin in pins:
		(x, y) = pin.split(',')
		sendmapcommand(player.socket, item, 1, x=int(x), y=int(y))
	
	protected = item.hastag('protected')
	editable = item.hastag('editable')
	sendmapcommand(player.socket, item, 7, not protected and editable)
Esempio n. 37
0
def send_removeuser(socket, chatname):

	# Data
	length = len(chatname) * 2
	extlength = length + 9
	
	# Sending
	chatpacket = wolfpack.packet(0xB2, extlength)
	chatpacket.setshort(1, extlength)
	chatpacket.setshort(3, 0x3EF)
	chatpacket.setunicode(5, ' ' + chatname + chatname + ' ')
	chatpacket.send(socket)
Esempio n. 38
0
def send_displaychat(socket, chatname):

	# Data
	length = len(chatname) * 2
	extlength = length + 13

	# Packet
	chatpacket = wolfpack.packet(0xB2, extlength)
	chatpacket.setshort(1, extlength)
	chatpacket.setshort(3, 0x3ED)
	chatpacket.setunicode(7, ' ' + chatname + chatname + ' ')
	chatpacket.send(socket)
Esempio n. 39
0
def send_joinconference(socket, channel):

	# Data
	length = len(channel) * 2
	extlength = length + 13

	# Send Packet
	chatpacket = wolfpack.packet(0xB2, extlength)
	chatpacket.setshort(1, extlength)
	chatpacket.setshort(3, 0x3F1)
	chatpacket.setunicode(7, ' ' + channel + channel + ' ')
	chatpacket.send(socket)
Esempio n. 40
0
def onUse(char, item):
	char.objectdelay = 0

	# Send BookOpen packet
	# Author / Title
	author = ''
	title = item.name

	if item.hastag('author'):
		author = item.gettag('author')

	title = title.encode('utf-8')
	author = author.encode('utf-8')

	# Calculate Packet Length
	packetlength = 15 + len(author) + 1 + len(title) + 1

	packet = wolfpack.packet(0xd4, packetlength)
	packet.setshort(1, packetlength)		 # Packet length
	packet.setint(3, item.serial)			 # Book Serial

	if not item.hastag('protected'):
		packet.setbyte(7, 1) # Flag Writeable
		packet.setbyte(8, 1) # dito
		pass

	pages = 64
	if item.hastag('pages'):
		pages = int(item.gettag('pages'))

	packet.setshort(9, pages)


	packet.setshort(11, len(title) + 1)
	packet.setascii(13, title)

	packet.setshort(13 + len(title) + 1, len(author) + 1)
	packet.setascii(15 + len(title) + 1, author)

	packet.send(char.socket)

	if item.hastag('protected'):
		return 1

	# Send a packet for each page !!
	# We could easily create packets bigger than 65k otherwise...
	for page in range(1, pages+1):
		if item.hastag('page%u' % page):
			sendPage(char.socket, item.serial, page, item.gettag('page%u' % page).split("\n"))

	return 1
Esempio n. 41
0
def handleStatus(socket, packet):
    statusPacket = 1
    for i in range(0, packet.size):
        if packet.getbyte(i) != statusRequest[i]:
            statusPacket = 0
            break

    if statusPacket:
        status = 'olfpack, Clients=%i, Items=%i, Chars=%i, Version="%s"' % (wolfpack.sockets.count(), wolfpack.itemcount(), wolfpack.charcount(), wolfpack.serverversion())

        packet = wolfpack.packet(87, len(status) + 2)
        packet.setascii(1, status)
        packet.send(socket)
        socket.log(LOG_MESSAGE, "Sent status information.\n")

    return statusPacket
Esempio n. 42
0
def send_conference(socket, channel, havepass):

	# Data
	length = len(channel) * 2
	extlength = length + 15

	# Creating basic Conference
	chatpacket = wolfpack.packet(0xB2, extlength)
	chatpacket.setshort(1, extlength)
	chatpacket.setshort(3, 0x3E8)
	chatpacket.setunicode(9,channel + channel)
	if havepass:
		chatpacket.setshort((len(channel) * 2) + 11, 0x0031)
	else:
		chatpacket.setshort((len(channel) * 2) + 11, 0x0030)
	chatpacket.send(socket)
Esempio n. 43
0
def changeMusic(char, oldregion, newregion):
	oldMusic = oldregion.midilist
	newMusic = newregion.midilist
	
	if oldMusic != newMusic:
		try:
			if len(newMusic) != 0:
				id = int(random.choice(newMusic.split(','))) # Choose randomly
			else:
				id = 0
			
			packet = wolfpack.packet(0x6d, 3)
			packet.setshort(1, id)
			packet.send(char.socket)
		except:
			raise
			pass
Esempio n. 44
0
def handleStatus(socket, packet):
    statusPacket = 1
    for i in range(0, packet.size):
        if packet.getbyte(i) != statusRequest[i]:
            statusPacket = 0
            break

    if statusPacket:
        status = 'olfpack, Clients=%i, Items=%i, Chars=%i, Version="%s"' % (
            wolfpack.sockets.count(), wolfpack.itemcount(),
            wolfpack.charcount(), wolfpack.serverversion())

        packet = wolfpack.packet(87, len(status) + 2)
        packet.setascii(1, status)
        packet.send(socket)
        socket.log(LOG_MESSAGE, "Sent status information.\n")

    return statusPacket
Esempio n. 45
0
def sendtradepacket( socket, action, partnerserial, box1serial, box2serial, playername ):
	#Sending 0x6F packet. Length may vary when playername is defined
	packetlength = 0x10
	trade = wolfpack.packet( 0x6F, packetlength )

	if playername != "":
		packetlength += len( playername ) + 2
		trade.resize( packetlength )
		trade.setbyte( 16, 1 )
		trade.setascii( 17, unicode(playername) )

	trade.setshort( 1, packetlength )
	trade.setbyte( 3, action )
	trade.setint( 4, partnerserial )
	trade.setint( 8, box1serial )
	trade.setint( 12, box2serial )
	trade.send( socket )

	return True
Esempio n. 46
0
def onWalk(char, direction, sequence):
    if maymove(char, direction, sequence):
        return False

    direction &= 0x7F

    # Just turning
    if direction != char.direction:
        return False

    # Disallow movement for players
    packet = wolfpack.packet(0x21, 8)
    packet.setbyte(1, sequence)
    packet.setshort(2, char.pos.x)
    packet.setshort(4, char.pos.y)
    packet.setbyte(6, char.direction)
    packet.setbyte(7, char.pos.z)
    packet.send(char.socket)
    char.socket.walksequence = 0
    return True
Esempio n. 47
0
def sendPage(socket, serial, page, lines):
    packetlength = 13

    for i in range(0, len(lines)):
        lines[i] = lines[i].encode('utf-8')
        packetlength += len(lines[i]) + 1

    packet = wolfpack.packet(0x66, packetlength)
    packet.setshort(1, packetlength)
    packet.setint(3, serial)
    packet.setshort(7, 1)  # Always a single page

    # Page Info
    packet.setshort(9, page)
    packet.setshort(11, len(lines))

    offset = 13
    for line in lines:
        packet.setascii(offset, line)
        offset += len(line) + 1

    packet.send(socket)
Esempio n. 48
0
def send_adduser(socket, worldsocket):

	# Get Chatname
	chatname = socket.account.chatname

	# Data
	length = len(chatname) * 2
	extlength = length + 13
			
	# Sending
	chatpacket = wolfpack.packet(0xB2, extlength)
	chatpacket.setshort(1, extlength)
	chatpacket.setshort(3, 0x3EE)
	
	if socket == worldsocket:
		chatpacket.setbyte(8, 0x34)
	elif socket.account.acl != 'player' or socket.hastag('Moderator'):
		chatpacket.setbyte(8, 0x31)
	else:
		chatpacket.setshort(8, 0x30)
	
	chatpacket.setunicode(9, ' ' + chatname + chatname + ' ')
	chatpacket.send(worldsocket)
Esempio n. 49
0
def playmusic(socket, command, arguments):
	packet = wolfpack.packet(0x6d, 3)
	packet.setshort(1, int(arguments))
	packet.send(socket)