本文整理汇总了Python中wolfpack.packet函数的典型用法代码示例。如果您正苦于以下问题:Python packet函数的具体用法?Python packet怎么用?Python packet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了packet函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: onUse
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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:33,代码来源:chivalryspellbook.py
示例2: onUse
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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:26,代码来源:necrospellbook.py
示例3: onUse
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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:49,代码来源:bulletinboard.py
示例4: send_message
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)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:29,代码来源:chat.py
示例5: send_privatemessage
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)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:29,代码来源:chat.py
示例6: sendswing
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)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:7,代码来源:utilities.py
示例7: onWalk
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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:35,代码来源:spiderweb.py
示例8: listusers
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()
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:28,代码来源:chat.py
示例9: send_alreadyinconference
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)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:7,代码来源:chat.py
示例10: target
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)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:33,代码来源:dyes.py
示例11: sendtreasmap
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)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:34,代码来源:treasure_map.py
示例12: onUse
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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:7,代码来源:dyes.py
示例13: sendmovingeffect
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)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:26,代码来源:specialmoves.py
示例14: onUse
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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:60,代码来源:book.py
示例15: buildSellPacket
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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:25,代码来源:packets.py
示例16: createBuyInfoPacket
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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:28,代码来源:packets.py
示例17: createContentPacket
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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:25,代码来源:packets.py
示例18: sendCodexOfWisdom
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)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:8,代码来源:__init__.py
示例19: request
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)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:8,代码来源:input.py
示例20: send_destroychannel
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)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:8,代码来源:chat.py
注:本文中的wolfpack.packet函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论