def getPlacementData(definition, dispid = 0, xoffset = 0, yoffset = 0, zoffset = 0): node = wolfpack.getdefinition(WPDT_MULTI, definition) if not node: return (dispid, xoffset, yoffset, zoffset) # Return, wrong definition if node.hasattribute('inherit'): (dispid, xoffset, yoffset, zoffset) = getPlacementData(node.getattribute('inherit'), dispid, xoffset, yoffset, zoffset) count = node.childcount for i in range(0, count): subnode = node.getchild(i) if subnode.name == 'id': # Found the display id dispid = hex2dec(subnode.value) elif subnode.name == 'inherit': # Inherit another definition if subnode.hasattribute('id'): (dispid, xoffset, yoffset, zoffset) = getPlacementData(subnode.getattribute('id'), dispid, xoffset, yoffset, zoffset) else: (dispid, xoffset, yoffset, zoffset) = getPlacementData(subnode.value, dispid, xoffset, yoffset, zoffset) elif subnode.name == 'placement': # Placement info xoffset = hex2dec(subnode.getattribute('xoffset', '0')) yoffset = hex2dec(subnode.getattribute('yoffset', '0')) zoffset = hex2dec(subnode.getattribute('zoffset', '0')) return (dispid, xoffset, yoffset, zoffset)
def startElement(self, name, atts): if name == "item": self.itemid = str(atts.getValue("id")) if "hue" in atts: self.hue = int(hex2dec(str(atts.getValue("hue")))) else: self.hue = 0 if "amount" in atts: self.amount = int(atts.getValue("amount")) else: self.amount = 0 self.statements = [] elif name == "attribute": type = "str" if "type" in atts: type = str(atts.getValue("type")) if "value" in atts and "key" in atts: self.statements.append( str(atts.getValue("key")) + "," + type + "," + str(atts.getValue("value"))) elif name == "pos": if int(hex2dec(self.itemid)) >= 0x4000: item = wolfpack.addmulti("%x" % hex2dec(self.itemid)) else: item = wolfpack.additem("%x" % hex2dec(self.itemid)) if not item or item == None: return if self.hue > 0: item.color = self.hue if self.amount > 0: item.amount = self.amount for p in self.statements: parts = p.split(",") if hasattr(item, parts[0]): if parts[1] == "str": value = parts[2] elif parts[1] == "int": value = int(parts[2]) setattr(item, parts[0], value) x = int(atts.getValue("x")) y = int(atts.getValue("y")) z = int(atts.getValue("z")) map = int(atts.getValue("map")) item.moveto(x, y, z, map) item.movable = 3 # not movable item.decay = 0 # no decay item.update() elif name == "include": path = atts.getValue("file") if not os.path.isfile(path): console.log(LOG_ERROR, tr("File '%s' not found.\n") % (path)) return parser = xml.sax.make_parser() handler = DecorationHandler() parser.setContentHandler(handler) parser.parse(path)
def parseTxt( file, map ): warnings = '' count = 0 parseTickCount = 0 createTickCount = 0 propTickCount = 0 moveTickCount = 0 for line in file: step1 = wolfpack.tickcount() # Replace \r and \n's line = line.replace( "\r", "" ) line = line.replace( "\n", "" ) ( id, x, y, z, color ) = line.split( ' ' ) id = hex2dec( id ) baseid = '%x' % id color = hex2dec( color ) x = int( x ) y = int( y ) z = int( z ) step2 = wolfpack.tickcount() newitem = wolfpack.additem( '%s' % baseid ) # Generate a new serial for us step3 = wolfpack.tickcount() newitem.decay = 0 newitem.color = color newitem.id = id step4 = wolfpack.tickcount() newposition = wolfpack.coord( x, y, z, map ) if not isValidPosition( newposition ): newitem.delete() continue newitem.moveto( newposition ) step5 = wolfpack.tickcount() parseTickCount += step2 - step1 createTickCount += step3 - step2 propTickCount += step4 - step3 moveTickCount += step5 - step4 newitem.update() count += 1 print "Parsing: %i ticks" % parseTickCount print "Creating: %i ticks" % createTickCount print "Prop: %i ticks" % propTickCount print "Move: %i ticks" % moveTickCount return ( count, warnings )
def buildHouse(house, definition): node = wolfpack.getdefinition(WPDT_MULTI, definition) if not node: return if node.hasattribute('inherit'): value = str(node.getattribute('inherit')) buildHouse(house, value) # Recursion for i in range(0, node.childcount): child = node.getchild(i) # Inherit another definition if child.name == 'inherit': if child.hasattribute('id'): buildHouse(house, child.getattribute('id')) else: buildHouse(house, child.value) # Add a normal item to the house elif child.name == 'item': x = int(child.getattribute('x', '0')) y = int(child.getattribute('y', '0')) z = int(child.getattribute('z', '0')) id = str(child.getattribute('id', '')) item = wolfpack.additem(id) item.moveto(house.pos.x + x, house.pos.y + y, house.pos.z + z, house.pos.map) item.update() # Add a house door to the house elif child.name == 'door': x = int(child.getattribute('x', '0')) y = int(child.getattribute('y', '0')) z = int(child.getattribute('z', '0')) id = hex2dec(child.getattribute('id', '')) item = wolfpack.additem('housedoor') item.id = id item.moveto(house.pos.x + x, house.pos.y + y, house.pos.z + z, house.pos.map) item.update() # Add a sign to the house elif child.name == 'sign': x = int(child.getattribute('x', '0')) y = int(child.getattribute('y', '0')) z = int(child.getattribute('z', '0')) sign = wolfpack.additem('housesign') if child.hasattribute('id'): sign.id = hex2dec(child.getattribute('id', '')) sign.moveto(house.pos.x + x, house.pos.y + y, house.pos.z + z, house.pos.map) sign.update()
def createBoat(player, deed, pos): boat = wolfpack.addmulti(str(deed.gettag('multisection'))) if boat == None: player.socket.sysmessage( tr('This deed is broken. Failed to create boat')) boat.owner = player boat.settag('boat_anchored', 1) boat.settag('boat_facing', 0) # boat is facing north boat.settag('deedid', deed.baseid) # For DryDock boat.moveto(pos) boat.update() boat.decay = 0 if deed.hastag('hasname'): boat.name = deed.name splank = None pplank = None # Create special items node = wolfpack.getdefinition(WPDT_MULTI, str(deed.gettag('multisection'))) count = node.childcount for i in range(0, count): subnode = node.getchild(i) if subnode.name == 'ids': boat.settag('boat_id_north', hex2dec(subnode.getattribute('north', '0'))) boat.settag('boat_id_east', hex2dec(subnode.getattribute('east', '0'))) boat.settag('boat_id_south', hex2dec(subnode.getattribute('south', '0'))) boat.settag('boat_id_west', hex2dec(subnode.getattribute('west', '0'))) elif subnode.name == 'special_items': # Found section subsubnode = subnode.findchild('tillerman') if subsubnode != None: tillerman = createBoatSpecialItem('3e4e', subsubnode, boat) boat.settag('boat_tillerman', tillerman.serial) if deed.hastag('hasname'): tillerman.name = 'Tillerman of ' + boat.name subsubnode = subnode.findchild('hold') if subsubnode != None: hold = createBoatSpecialItem('3eae', subsubnode, boat) subsubnode = subnode.findchild('planks') if subsubnode != None: portclosed = subsubnode.findchild('port_closed') pplank = createBoatSpecialItem('3eb1', portclosed, boat) starclosed = subsubnode.findchild('star_closed') splank = createBoatSpecialItem('3eb2', starclosed, boat) splank.settag('plank_starboard', 1) if not deed.hastag('lock'): createKeys(splank, pplank, hold, boat, player) else: applyKeys(splank, pplank, hold, deed)
def startElement( self, name, atts ): if name == "item": self.itemid = str(atts.getValue("id")); if "hue" in atts: self.hue = int(hex2dec(str(atts.getValue("hue")))); else: self.hue = 0 if "amount" in atts: self.amount = int(atts.getValue("amount")); else: self.amount = 0 self.statements = [] elif name == "attribute": type = "str" if "type" in atts: type = str(atts.getValue("type")) if "value" in atts and "key" in atts: self.statements.append( str(atts.getValue("key")) + "," + type + ","+ str(atts.getValue("value")) ) elif name == "pos": if int(hex2dec( self.itemid )) >= 0x4000: item = wolfpack.addmulti( "%x" % hex2dec( self.itemid ) ) else: item = wolfpack.additem( "%x" % hex2dec( self.itemid ) ) if not item or item == None: return if self.hue > 0: item.color = self.hue if self.amount > 0: item.amount = self.amount for p in self.statements: parts = p.split(",") if hasattr(item, parts[0]): if parts[1] == "str": value = parts[2] elif parts[1] == "int": value = int(parts[2]) setattr(item, parts[0], value) x = int( atts.getValue("x") ) y = int( atts.getValue("y") ) z = int( atts.getValue("z") ) map = int( atts.getValue("map") ) item.moveto( x, y, z, map ) item.movable = 3 # not movable item.decay = 0 # no decay item.update() elif name == "include": path = atts.getValue("file") if not os.path.isfile(path): console.log(LOG_ERROR, tr("File '%s' not found.\n") % (path)) return parser = xml.sax.make_parser() handler = DecorationHandler() parser.setContentHandler(handler) parser.parse(path)
def parseTxt(file, map): warnings = "" count = 0 parseTickCount = 0 createTickCount = 0 propTickCount = 0 moveTickCount = 0 for line in file: step1 = wolfpack.tickcount() # Replace \r and \n's line = line.replace("\r", "") line = line.replace("\n", "") (baseid, id, x, y, z, map, color) = line.split(" ") baseid = baseid id = hex2dec(id) color = hex2dec(color) x = int(x) y = int(y) z = int(z) map = int(map) step2 = wolfpack.tickcount() newitem = wolfpack.additem("%s" % baseid) # Generate a new serial for us step3 = wolfpack.tickcount() newitem.decay = 0 newitem.color = color newitem.id = id step4 = wolfpack.tickcount() newitem.moveto(x, y, z, map, 1) step5 = wolfpack.tickcount() parseTickCount += step2 - step1 createTickCount += step3 - step2 propTickCount += step4 - step3 moveTickCount += step5 - step4 newitem.update() count += 1 print "Parsing: %i ticks" % parseTickCount print "Creating: %i ticks" % createTickCount print "Prop: %i ticks" % propTickCount print "Move: %i ticks" % moveTickCount return (count, warnings)
def createBoat( player, deed, pos ): boat = wolfpack.addmulti(str(deed.gettag('multisection'))) if boat == None: player.socket.sysmessage(tr('This deed is broken. Failed to create boat')) boat.owner = player boat.settag( 'boat_anchored', 1 ) boat.settag( 'boat_facing', 0 ) # boat is facing north boat.settag( 'deedid', deed.baseid ) # For DryDock boat.moveto(pos) boat.update() boat.decay = 0 if deed.hastag('hasname'): boat.name = deed.name splank = None pplank = None # Create special items node = wolfpack.getdefinition(WPDT_MULTI, str(deed.gettag('multisection')) ) count = node.childcount for i in range(0, count): subnode = node.getchild(i) if subnode.name == 'ids': boat.settag('boat_id_north', hex2dec( subnode.getattribute( 'north', '0' ) ) ) boat.settag('boat_id_east', hex2dec( subnode.getattribute( 'east', '0' ) ) ) boat.settag('boat_id_south', hex2dec( subnode.getattribute( 'south', '0' ) ) ) boat.settag('boat_id_west', hex2dec( subnode.getattribute( 'west', '0' ) ) ) elif subnode.name == 'special_items': # Found section subsubnode = subnode.findchild('tillerman') if subsubnode != None: tillerman = createBoatSpecialItem( '3e4e', subsubnode, boat ) boat.settag('boat_tillerman', tillerman.serial) if deed.hastag('hasname'): tillerman.name = 'Tillerman of ' + boat.name subsubnode = subnode.findchild('hold') if subsubnode != None: hold = createBoatSpecialItem( '3eae', subsubnode, boat ) subsubnode = subnode.findchild('planks') if subsubnode != None: portclosed = subsubnode.findchild('port_closed') pplank = createBoatSpecialItem( '3eb1', portclosed, boat ) starclosed = subsubnode.findchild('star_closed') splank = createBoatSpecialItem( '3eb2', starclosed, boat ) splank.settag('plank_starboard', 1) if not deed.hastag('lock'): createKeys( splank, pplank, hold, boat, player ) else: applyKeys( splank, pplank, hold, deed )
def sound( socket, command, arguments ): try: sound = hex2dec( str(arguments) ) socket.player.soundeffect( sound ) except: socket.sysmessage( 'Usage: sound <sound-id>' ) return
def commandSettag(socket, command, arguments): # Split Arguments if arguments.count(' ') < 2: socket.sysmessage('Usage: settag name (int|string|float) value...') return (name, argtype, value) = arguments.split(' ', 2) if argtype == 'int': try: value = hex2dec(value) except: socket.sysmessage('You specified an invalid integer value.') return elif argtype == 'float': try: value = float(value) except: socket.sysmessage('You specified an invalid floating point value.') return elif argtype == 'string': value = unicode(value) else: socket.sysmessage('Usage: settag name (int|string|float) value...') return socket.attachtarget("commands.tags.settagResponse", [name, value])
def commandSettag(socket, command, arguments): # Split Arguments if arguments.count(' ') < 2: socket.sysmessage('Usage: settag name (int|string|float) value...') return (name, argtype, value) = arguments.split(' ', 2) if argtype == 'int': try: value = hex2dec(value) except: socket.sysmessage('You specified an invalid integer value.') return elif argtype == 'float': try: value = float(value) except: socket.sysmessage('You specified an invalid floating point value.') return elif argtype == 'string': value = unicode(value) else: socket.sysmessage('Usage: settag name (int|string|float) value...') return socket.attachtarget("commands.tags.settagResponse", [name, value]) return
def parseMulti( file, pos ): warnings = '' count = 0 for line in file: # Replace \r and \n's line = line.replace( "\r", "" ) line = line.replace( "\n", "" ) if len(line.split(' ')) != 5: continue ( id, x, y, z, show ) = line.split(' ') if not int(show): continue id = hex2dec( id ) x = int( x ) y = int( y ) z = int( z ) newitem = wolfpack.newitem(1) # Generate a new serial for us newitem.decay = 0 newitem.id = id newitem.moveto( pos.x + x, pos.y + y, pos.z + z, pos.map, 1 ) newitem.update() count += 1 return ( count, warnings )
def sound(socket, command, arguments): try: sound = hex2dec(str(arguments)) socket.player.soundeffect(sound) except: socket.sysmessage('Usage: sound <sound-id>') return
def add(socket, command, arguments): if len(arguments) > 0: if wolfpack.getdefinition(WPDT_ITEM, arguments): socket.sysmessage(tr("Where do you want to place the item '%s'?") % arguments) socket.attachtarget("commands.add.additem", [arguments, False]) elif wolfpack.getdefinition(WPDT_NPC, arguments): socket.sysmessage(tr("Where do you want to spawn the npc '%s'?") % arguments) socket.attachtarget("commands.add.addnpc", [arguments]) elif wolfpack.getdefinition(WPDT_MULTI, arguments): node = wolfpack.getdefinition(WPDT_MULTI, arguments) count = node.childcount for i in range(0, count): subnode = node.getchild(i) if subnode.name == "id": # Found the display id dispid = hex2dec(subnode.value) socket.sysmessage(tr("Where do you want to place the multi '%s'?") % arguments) socket.attachmultitarget("commands.add.addmulti", dispid - 0x4000, [arguments, False], 0, 0, 0) else: socket.sysmessage(tr("No Item, NPC or Multi definition by that name found.")) return global generated if not generated: generated = True socket.sysmessage(tr("Generating add menu.")) socket.sysmessage(tr("Please wait...")) generateAddMenu(socket.player.serial) return menu = findmenu("ADDMENU") if menu: menu.send(socket.player) else: socket.sysmessage(tr("No ADDMENU menu found."))
def loadMenu(id, parent = None): definition = wolfpack.getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = TailoringMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log(LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: loadMenu(child.getattribute('id'), menu) # Craft an item elif child.name in ['tailor', 'setailor']: if not child.hasattribute('definition'): console.log(LOG_ERROR, "Tailor action without definition in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = wolfpack.getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: console.log(LOG_ERROR, "Tailor action with invalid definition %s in menu %s.\n" % (itemdef, menu.id)) else: itemid = hex2dec(child.getattribute('itemid', '0')) if child.hasattribute('name'): name = child.getattribute('name') else: name = generateNamefromDef(itemdef) if child.name == 'setailor': action = SeTailorItemAction(menu, name, int(itemid), itemdef) else: action = TailorItemAction(menu, name, int(itemid), itemdef) except: console.log(LOG_ERROR, "Tailor action with invalid item id in menu %s.\n" % menu.id) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) action.processnode(subchild, menu) # Sort the menu. This is important for the makehistory to make. menu.sort()
def processnode(self, node, menu): global CLOTH if node.name == 'cloth': amount = hex2dec(node.getattribute('amount', '1')) if amount > 0: self.cloth = amount else: CraftItemAction.processnode(self, node, menu)
def make(self, player, arguments, nodelay=0): node = wolfpack.getdefinition(WPDT_MULTI, self.definition) count = node.childcount for i in range(0, count): subnode = node.getchild(i) if subnode.name == "id": # Found the display id dispid = hex2dec(subnode.value) player.socket.sysmessage(tr("Where do you want to place the multi '%s'?") % self.definition) player.socket.attachmultitarget("commands.add.addmulti", dispid - 0x4000, [self.definition, False], 0, 0, 0) MakeAction.make(self, player, arguments, nodelay)
def startElement( self, name, atts ): if name == "item": self.itemid = str(atts.getValue("id")); if atts.has_key("hue"): self.hue = int(hex2dec(str(atts.getValue("hue")))); else: self.hue = 0 if atts.has_key("amount"): self.amount = int(atts.getValue("amount")); else: self.amount = 0 self.statements = [] elif name == "attribute": type = "str" if atts.has_key("type"): type = str(atts.getValue("type")) if atts.has_key("value") and atts.has_key("key"): self.statements.append( str(atts.getValue("key")) + "," + type + ","+ str(atts.getValue("value")) ) elif name == "pos": item = wolfpack.additem( "%x" % hex2dec( self.itemid ) ) if not item or item == None: return if self.hue > 0: item.color = self.hue if self.amount > 0: item.amount = self.amount for p in self.statements: parts = p.split(",") if hasattr(item, parts[0]): if parts[1] == "str": value = parts[2] elif parts[1] == "int": value = int(parts[2]) setattr(item, parts[0], value) x = int( atts.getValue("x") ) y = int( atts.getValue("y") ) z = int( atts.getValue("z") ) map = int( atts.getValue("map") ) item.moveto( x, y, z, map ) item.movable = 3 # not movable item.decay = 0 # no decay item.update()
def commandRemove(socket, cmd, args): if len(args) > 0: serial = hex2dec(args) doRemoveSerial( socket, serial ) return True socket.sysmessage( "Please select the object for removal." ) if( socket.account.authorized('Misc', 'May Remove Players') ): socket.sysmessage( "Caution: This can remove players!" ) socket.attachtarget( "commands.remove.doRemove", [] ) return True
def loadMenu(id, parent = None): definition = wolfpack.getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = GlassblowingMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log(LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: loadMenu(child.getattribute('id'), menu) # Craft an item elif child.name == 'glassblowing': if not child.hasattribute('definition'): console.log(LOG_ERROR, "Glassblowing action without definition in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = wolfpack.getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: itemid = hex2dec(child.getattribute('itemid', '0')) if child.hasattribute('name'): name = child.getattribute('name') else: name = generateNamefromDef(itemdef) action = GlassblowerItemAction(menu, name, int(itemid), itemdef) except: console.log(LOG_ERROR, "Glassblowing action with invalid item id in menu %s.\n" % menu.id) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) action.processnode(subchild, menu) # Sort the menu. This is important for the makehistory to make. menu.sort()
def gouid(socket, command, arguments): try: uid = hex2dec(arguments) except: socket.symsessage('Usage: gouid <serial>') return if uid > 0x40000000: item = wolfpack.finditem(uid) if item: container = item.getoutmostitem() if container.container: container = container.container # Going to container socket.sysmessage('Going to item 0x%x (%s) [Top: 0x%x].' % (uid, item.getname(), container.serial)) pos = container.pos socket.player.removefromview() socket.player.moveto(pos) socket.player.update() socket.resendworld() if item.container: socket.sendobject(item.container) if item.container.isitem(): socket.sendcontainer(item.container) else: socket.sysmessage('No item with the serial 0x%x could be found.' % uid) return elif uid > 0: char = wolfpack.findchar(uid) if char and char.rank <= socket.player.rank: pos = char.pos if pos.map == 0xFF: if char.npc: stablemaster = wolfpack.findobject(char.stablemaster) else: stablemaster = None if not stablemaster: socket.sysmessage("Not going to character '%s' [Serial: 0x%x]. They are on the internal map." % (char.name, uid)) else: socket.sysmessage("Character '%s' [Serial: 0x%x] is stabled in object 0x%x." % (char.name, uid, stablemaster.serial)) else: socket.sysmessage('Going to char 0x%x (%s).' % (uid, char.name)) socket.player.removefromview() socket.player.moveto(pos) socket.player.update() socket.resendworld() else: socket.sysmessage('No char with the serial 0x%x could be found.' % uid) return socket.sysmessage('You specified an invalid serial: 0x%x.' % uid)
def targetitem( char, args, target ): socket = char.socket if target.item: # Find the target item. finditem = wolfpack.finditem( target.item.serial ) # Safety Checks if not finditem: socket.sysmessage("You must target an item!") return True if ( finditem.lockeddown ) or ( not char.gm and finditem.movable > 1 ) or ( finditem.movable == 2 and finditem.owner != char ): socket.sysmessage("This object is not movable by you!") return True # Object Exists if finditem: # Turnable Furniture if finditem.id in TURNABLES: finditem.id = utilities.hex2dec(TURNABLES[finditem.id][0]) finditem.update() socket.sysmessage("You rotate the object.") # Turnable Deeds elif int(finditem.id) == utilities.hex2dec(0x14ef) and str(finditem.baseid) in TURNDEEDS: if finditem.container != char.getbackpack(): socket.sysmessage("This deed needs to be in your backpack to turn it!") return True else: finditem.settag( 'carpentry_type', str(TURNDEEDS[finditem.baseid][1]) ) finditem.name = str(TURNDEEDS[str(finditem.baseid)][2]) # Update BaseID Last finditem.baseid = str(TURNDEEDS[finditem.baseid][0]) finditem.update() socket.sysmessage("You rotate the deed's placement direction.") return # Error else: socket.sysmessage("This item is not turnable.") return True # Error else: socket.sysmessage("This item is not turnable.") return True
def bankself( socket, command, arguments ): layer = 0x1d if len( arguments ) > 0: try: layer = hex2dec( arguments ) except: socket.sysmessage( 'Usage: bank <layer-id>' ) return socket.sysmessage( 'Please choose a target.' ) socket.attachtarget( "commands.bank.callback_bankself", [ layer ] )
def targetitem( char, args, target ): socket = char.socket if target.item: # Find the target item. finditem = wolfpack.finditem( target.item.serial ) # Safety Checks if not finditem: socket.sysmessage(tr("You must target an item!")) return True if not canturn( char, finditem ): socket.sysmessage(tr("This object is not movable by you!")) return True # Turnable Furniture if finditem.id in TURNABLES: finditem.id = utilities.hex2dec(TURNABLES[finditem.id][0]) finditem.update() socket.sysmessage(tr("You rotate the object.")) # Turnable Deeds elif int(finditem.id) == utilities.hex2dec(0x14ef) and str(finditem.baseid) in TURNDEEDS: if finditem.container != char.getbackpack(): socket.sysmessage(tr("This deed needs to be in your backpack to turn it!")) return True else: finditem.settag( 'carpentry_type', str(TURNDEEDS[finditem.baseid][1]) ) finditem.name = str(TURNDEEDS[str(finditem.baseid)][2]) # Update BaseID Last finditem.baseid = str(TURNDEEDS[finditem.baseid][0]) finditem.update() socket.sysmessage(tr("You rotate the deed's placement direction.")) return # Error else: socket.sysmessage(tr("This item is not turnable.")) return True # Error else: socket.sysmessage(tr("This item is not turnable.")) return True
def bank( socket, command, arguments ): arguments = arguments.strip() # Remove trailing and leading whitespaces layer = 0x1d if len( arguments ) > 0: try: layer = hex2dec( arguments ) except: socket.sysmessage( 'Usage: bank <layer-id>' ) return socket.sysmessage( 'Please choose a target.' ) socket.attachtarget( "commands.bank.callback", [ layer ] )
def dupe(socket, command, arguments): arguments = arguments.strip() # Remove trailing and leading whitespaces amount = 1 if len( arguments ) > 0: try: amount = hex2dec(arguments) except: socket.sysmessage( 'Usage: dupe <amount>' ) return False socket.sysmessage( 'Please choose an item to dupe.' ) socket.attachtarget( "commands.dupe.callback", [amount] )
def dupe(socket, command, arguments): arguments = arguments.strip() # Remove trailing and leading whitespaces amount = 1 if len(arguments) > 0: try: amount = hex2dec(arguments) except: socket.sysmessage('Usage: dupe <amount>') return False socket.sysmessage('Please choose an item to dupe.') socket.attachtarget("commands.dupe.callback", [amount])
def make(self, player, arguments, nodelay=0): node = wolfpack.getdefinition(WPDT_MULTI, self.definition) count = node.childcount for i in range(0, count): subnode = node.getchild(i) if subnode.name == 'id': # Found the display id dispid = hex2dec(subnode.value) player.socket.sysmessage( tr("Where do you want to place the multi '%s'?") % self.definition) player.socket.attachmultitarget("commands.add.addmulti", dispid - 0x4000, [self.definition, False], 0, 0, 0) MakeAction.make(self, player, arguments, nodelay)
def playhurtsound(defender): if defender.id == 0x190: # Play a random soundeffect for a human male defender sounds = wolfpack.list('SOUNDS_COMBAT_HIT_HUMAN_MALE') if len(sounds) > 0: sound = hex2dec(random.choice(sounds)) defender.soundeffect(sound) else: defender.soundeffect(0x156) elif defender.id == 0x191: # Play a random soundeffect for a human female defender sounds = wolfpack.list('SOUNDS_COMBAT_HIT_HUMAN_FEMALE') if len(sounds) > 0: sound = hex2dec(random.choice(sounds)) defender.soundeffect(sound) else: defender.soundeffect(0x14b) else: # A standard monster defend sound defender.sound(SND_DEFEND)
def playhurtsound(defender): if defender.id in PLAYER_BODIES_ALIVE_MALE: # Play a random soundeffect for a human male defender sounds = wolfpack.list('SOUNDS_COMBAT_HIT_HUMAN_MALE') if len(sounds) > 0: sound = hex2dec(random.choice(sounds)) defender.soundeffect(sound) else: defender.soundeffect(0x156) elif defender.id == PLAYER_BODIES_ALIVE_FEMALE: # Play a random soundeffect for a human female defender sounds = wolfpack.list('SOUNDS_COMBAT_HIT_HUMAN_FEMALE') if len(sounds) > 0: sound = hex2dec(random.choice(sounds)) defender.soundeffect(sound) else: defender.soundeffect(0x14b) else: # A standard monster defend sound defender.sound(SND_DEFEND)
def static(socket, command, arguments): if len(arguments) > 0: if wolfpack.getdefinition(WPDT_ITEM, arguments): socket.sysmessage(tr("Where do you want to place the item '%s'?") % arguments) socket.attachtarget("commands.add.additem", [arguments, True]) elif wolfpack.getdefinition(WPDT_MULTI, arguments): node = wolfpack.getdefinition(WPDT_MULTI, arguments) count = node.childcount for i in range(0, count): subnode = node.getchild(i) if subnode.name == "id": # Found the display id dispid = hex2dec(subnode.value) socket.sysmessage(tr("Where do you want to place the multi '%s'?") % arguments) socket.attachmultitarget("commands.add.addmulti", dispid - 0x4000, [arguments, True], 0, 0, 0) else: socket.sysmessage(tr("No Item, NPC or Multi definition by that name found.")) else: socket.sysmessage(tr("Usage: static <id>"))
def gouid(socket, command, arguments): try: uid = hex2dec(arguments) except: socket.symsessage('Usage: gouid <serial>') return if uid > 0x40000000: item = wolfpack.finditem(uid) if item: container = item.getoutmostitem() if container.container: container = container.container # Going to container socket.sysmessage('Going to item 0x%x [Top: 0x%x].' % (uid, container.serial)) pos = container.pos socket.player.removefromview() socket.player.moveto(pos) socket.player.update() socket.resendworld() if item.container.isitem(): socket.sendobject(item.container) socket.sendcontainer(item.container) else: socket.sysmessage('No item with the serial 0x%x could be found.' % uid) return elif uid > 0: char = wolfpack.findchar(uid) if char: socket.sysmessage('Going to char 0x%x.' % (uid)) pos = char.pos socket.player.removefromview() socket.player.moveto(pos) socket.player.update() socket.resendworld() else: socket.sysmessage('No char with the serial 0x%x could be found.' % uid) return socket.sysmessage('You specified an invalid serial: 0x%x.' % uid)
def processnode(self, node, menu): if node.name == 'needoven': self.needoven = True elif node.name == 'needheat': self.needheat = True elif node.name == 'water': self.water = True elif node.name == 'nomark': self.markable = 0 elif node.name == 'useallres': self.useallres = True elif node.name == 'flour': amount = 1 if node.hasattribute('amount'): amount = hex2dec(node.getattribute('amount', '1')) self.flour = True self.flouramount = amount else: CraftItemAction.processnode(self, node, menu)
def processnode(self, node, menu): if node.name == "needoven": self.needoven = True elif node.name == "needheat": self.needheat = True elif node.name == "water": self.water = True elif node.name == "nomark": self.markable = 0 elif node.name == "useallres": self.useallres = True elif node.name == "flour": amount = 1 if node.hasattribute("amount"): amount = hex2dec(node.getattribute("amount", "1")) self.flour = True self.flouramount = amount else: CraftItemAction.processnode(self, node, menu)
def playeffect(char, arguments, target): # Default values id = 0 speed = 20 duration = 10 hue = 0 rendermode = 0 socket = char.socket if len(arguments) == 1 and arguments[0] != '': (id) = arguments[0] elif len(arguments) == 2: (id, speed) = arguments elif len(arguments) == 3: (id, speed, duration) = arguments elif len(arguments) == 4: (id, speed, duration, hue) = arguments elif len(arguments) == 5: (id, speed, duration, hue, rendermode) = arguments else: socket.sysmessage('Usage: effect <effect-id>[, speed, duration, hue, rendermode]') return False try: effect = hex2dec(id) speed = int(speed) duration = int(duration) hue = int(hue) rendermode = int(rendermode) if not target: socket.player.effect(effect, speed, duration, hue, rendermode) else: if target.char: target.char.effect(effect, speed, duration, hue, rendermode) elif target.item: target.item.effect(effect, speed, duration, hue, rendermode) else: wolfpack.effect(effect, target.pos, duration, speed) except: socket.sysmessage('Usage: effect <effect-id>[, speed, duration, hue, rendermode]')
def add(socket, command, arguments): if len(arguments) > 0: if wolfpack.getdefinition(WPDT_ITEM, arguments): socket.sysmessage( tr("Where do you want to place the item '%s'?") % arguments) socket.attachtarget("commands.add.additem", [arguments, False]) elif wolfpack.getdefinition(WPDT_NPC, arguments): socket.sysmessage( tr("Where do you want to spawn the npc '%s'?") % arguments) socket.attachtarget("commands.add.addnpc", [arguments]) elif wolfpack.getdefinition(WPDT_MULTI, arguments): node = wolfpack.getdefinition(WPDT_MULTI, arguments) count = node.childcount for i in range(0, count): subnode = node.getchild(i) if subnode.name == 'id': # Found the display id dispid = hex2dec(subnode.value) socket.sysmessage( tr("Where do you want to place the multi '%s'?") % arguments) socket.attachmultitarget("commands.add.addmulti", dispid - 0x4000, [arguments, False], 0, 0, 0) else: socket.sysmessage( tr('No Item, NPC or Multi definition by that name found.')) return global generated if not generated: generated = True socket.sysmessage(tr('Generating add menu.')) socket.sysmessage(tr('Please wait...')) generateAddMenu(socket.player.serial) return menu = findmenu('ADDMENU') if menu: menu.send(socket.player) else: socket.sysmessage(tr('No ADDMENU menu found.'))
def static(socket, command, arguments): if len(arguments) > 0: if wolfpack.getdefinition(WPDT_ITEM, arguments): socket.sysmessage( tr("Where do you want to place the item '%s'?") % arguments) socket.attachtarget("commands.add.additem", [arguments, True]) elif wolfpack.getdefinition(WPDT_MULTI, arguments): node = wolfpack.getdefinition(WPDT_MULTI, arguments) count = node.childcount for i in range(0, count): subnode = node.getchild(i) if subnode.name == 'id': # Found the display id dispid = hex2dec(subnode.value) socket.sysmessage( tr("Where do you want to place the multi '%s'?") % arguments) socket.attachmultitarget("commands.add.addmulti", dispid - 0x4000, [arguments, True], 0, 0, 0) else: socket.sysmessage( tr('No Item, NPC or Multi definition by that name found.')) else: socket.sysmessage(tr('Usage: static <id>'))
def generateAddMenu(serial=0, items=None): char = wolfpack.findchar(serial) if not char or not char.socket: char = None """if not items: items = wolfpack.getdefinitions(WPDT_ITEM) if char: char.socket.sysmessage('Done getting list of definitions.') wolfpack.queuecode(generateAddMenu, (serial, items)) return""" addmenu = MakeMenu('ADDMENU', None, 'Add Menu') submenus = {} # Process 100 at a time definitions = wolfpack.definitionsiterator(WPDT_ITEM) item = definitions.first while item: if not item.hasattribute('id'): item = definitions.next continue child = item.findchild('category') if not child: item = definitions.next continue categories = ['Items'] + child.text.split('\\') description = categories[len(categories) - 1] # Name of the action categories = categories[:len(categories) - 1] # Iterate trough the categories and see if they're all there category = '' if len(categories) > 0 and not submenus.has_key('\\'.join(categories) + '\\'): for subcategory in categories: if not submenus.has_key(category + subcategory + '\\'): # Category is our parent category parent = None if len(category) == 0: parent = addmenu elif category in submenus: parent = submenus[category] category += subcategory + '\\' menu = MakeMenu('ADDMENU_' + category, parent, subcategory) submenus[category] = menu else: category += subcategory + '\\' child = item.findchild('id') if child: try: id = int(child.value) except: id = 0 else: id = 0 definition = item.getattribute('id') # Parse the position of this makemenu entry if len(categories) == 0: additem = AddItemAction(addmenu, description, id, definition) else: additem = AddItemAction(submenus['\\'.join(categories) + '\\'], description, id, definition) additem.otherhtml = 'Definition: ' + definition item = definitions.next for menu in submenus.values(): menu.sort() npcs = wolfpack.definitionsiterator(WPDT_NPC) submenus = {} npc = npcs.first while npc: if not npc.hasattribute('id'): npc = npcs.next continue child = npc.findchild('category') if not child: npc = npcs.next continue id = npc.findchild('id') if id: try: if id.value.startswith('0x'): id = wolfpack.bodyinfo(hex2dec(id.value))['figurine'] else: id = wolfpack.bodyinfo(int(id.value))['figurine'] except: id = 0 else: id = 0 description = npc.findchild('desc') if description: description = description.value else: description = tr('No description available.') categories = ['NPCs'] + child.text.split('\\') title = categories[len(categories) - 1] # Name of the action categories = categories[:len(categories) - 1] # Iterate trough the categories and see if they're all there category = '' if len(categories) > 0 and not submenus.has_key('\\'.join(categories) + '\\'): for subcategory in categories: if not submenus.has_key(category + subcategory + '\\'): # Category is our parent category parent = None if len(category) == 0: parent = addmenu elif category in submenus: parent = submenus[category] category += subcategory + '\\' menu = MakeMenu('ADDMENU_' + category, parent, subcategory) submenus[category] = menu else: category += subcategory + '\\' definition = npc.getattribute('id') # Parse the position of this makemenu entry if len(categories) == 0: addnpc = AddNpcAction(addmenu, title, definition, definition) else: addnpc = AddNpcAction(submenus['\\'.join(categories) + '\\'], title, id, definition) addnpc.otherhtml = str(description) npc = npcs.next for menu in submenus.values(): menu.sort() multis = wolfpack.definitionsiterator(WPDT_MULTI) submenus = {} multi = multis.first while multi: if not multi.hasattribute('id'): multi = multi.next continue child = multi.findchild('category') if not child: multi = multis.next continue categories = ['Multis'] + child.text.split('\\') description = categories[len(categories) - 1] # Name of the action categories = categories[:len(categories) - 1] # Iterate trough the categories and see if they're all there category = '' if len(categories) > 0 and not submenus.has_key('\\'.join(categories) + '\\'): for subcategory in categories: if not submenus.has_key(category + subcategory + '\\'): # Category is our parent category parent = None if len(category) == 0: parent = addmenu elif category in submenus: parent = submenus[category] category += subcategory + '\\' menu = MakeMenu('ADDMENU_' + category, parent, subcategory) submenus[category] = menu else: category += subcategory + '\\' child = multi.findchild('id') if child: try: id = int(child.value) except: id = 0 else: id = 0 multi = multi.getattribute('id') # Parse the position of this makemenu entry if len(categories) == 0: addmulti = AddMultiAction(addmenu, description, id, multi) else: addmulti = AddMultiAction(submenus['\\'.join(categories) + '\\'], description, id, multi) addmulti.otherhtml = 'Definition: ' + multi multi = multis.next for menu in submenus.values(): menu.sort() addmenu.sort() if char: addmenu.send(char)
def loadMenu(id, parent = None): definition = wolfpack.getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = CarpentryMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log(LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: loadMenu(child.getattribute('id'), menu) # Craft an item elif child.name == 'craft': if not child.hasattribute('definition') or not child.hasattribute('name'): console.log(LOG_ERROR, "Carpenter action without definition or name in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') name = child.getattribute('name') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = wolfpack.getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: itemid = hex2dec(child.getattribute('itemid', '0')) action = CarpItemAction(menu, name, int(itemid), itemdef) except: console.log(LOG_ERROR, "Carpenter action with invalid item id in menu %s.\n" % menu.id) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) # How much of the primary resource should be consumed if subchild.name == 'ingots': action.submaterial1 = hex2dec(subchild.getattribute('amount', '0')) # Normal Material if subchild.name == 'boards' or subchild.name == 'wood' or subchild.name == 'cloth' or subchild.name == 'material': if not subchild.hasattribute('id'): console.log(LOG_ERROR, "Material element without id list in menu %s.\n" % menu.id) break else: ids = subchild.getattribute('id').split(';') try: amount = hex2dec(subchild.getattribute('amount', '1')) materialname = subchild.getattribute('name', 'Unknown') except: console.log(LOG_ERROR, "Material element with invalid id list in menu %s.\n" % menu.id) break action.materials.append([ids, amount, materialname]) # Consume all available materials scaled by the # amount of each submaterial elif subchild.name == 'stackable': action.stackable = 1 # Skill requirement elif subchild.name in skillnamesids: skill = skillnamesids[subchild.name] try: minimum = hex2dec(subchild.getattribute('min', '0')) except: console.log(LOG_ERROR, "%s element with invalid min value in menu %s.\n" % (subchild.name, menu.id)) try: maximum = hex2dec(subchild.getattribute('max', '1200')) except: console.log(LOG_ERROR, "%s element with invalid max value in menu %s.\n" % (subchild.name, menu.id)) action.skills[skill] = [minimum, maximum] # Sort the menu. This is important for the makehistory to make. menu.sort()
def loadMenu(id, parent = None): definition = wolfpack.getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = AlchemyMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log(LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: loadMenu(child.getattribute('id'), menu) # Craft an item elif child.name == 'craft': if not child.hasattribute('definition'): console.log(LOG_ERROR, "craft action without definition in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = wolfpack.getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: itemid = hex2dec(child.getattribute('itemid', '0')) except Exception, e: console.log(LOG_ERROR, "Craft action with invalid item id in menu %s: %s\n" % (menu.id, str(e))) if child.hasattribute('name'): name = child.getattribute('name') else: name = generateNamefromDef(itemdef) action = BrewItemAction(menu, name, int(itemid), itemdef) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) # Normal Material if subchild.name == 'material': if not subchild.hasattribute('id'): console.log(LOG_ERROR, "Material element without id list in menu %s.\n" % menu.id) break else: ids = subchild.getattribute('id').split(';') try: amount = hex2dec(subchild.getattribute('amount', '1')) materialname = subchild.getattribute('name', 'Unknown') except: console.log(LOG_ERROR, "Material element with invalid id list in menu %s.\n" % menu.id) break action.materials.append([ids, amount, materialname]) # Skill requirement elif subchild.name in skillnamesids: skill = skillnamesids[subchild.name] try: minimum = hex2dec(subchild.getattribute('min', '0')) except: console.log(LOG_ERROR, "%s element with invalid min value in menu %s.\n" % (subchild.name, menu.id)) try: maximum = hex2dec(subchild.getattribute('max', '1200')) except: console.log(LOG_ERROR, "%s element with invalid max value in menu %s.\n" % (subchild.name, menu.id)) action.skills[skill] = [minimum, maximum]
def dye(socket, command, arguments): try: color = int(hex2dec(str(arguments))) socket.attachtarget("commands.dye.response", [color]) except: socket.sysmessage('Usage: dye <color-id>')
def action(socket, command, arguments): try: action = hex2dec(arguments) socket.player.action(action) except: socket.sysmessage('Usage: action <animation-id>')
def accountSet( socket, username, key, value ): account = None characcount = None char = socket.player characcount = wolfpack.accounts.find( char.account.name ) account = wolfpack.accounts.find( username ) if not account: socket.sysmessage( "Error: No such account exists." ) return False if len( value ) == 0: socket.sysmessage( "Error: No value was given." ) return False # Usernames are limited to 16 characters in length if len( username ) > 16 or len( username ) == 0: if len( username ) > 16: socket.sysmessage( "Error: Username exceeds the 16 character limit!" ) if len( username ) == 0: socket.sysmessage( "Error: Username is NULL!" ) return False # Find the account elif account: if account.rank >= characcount.rank and account.name != characcount.name: socket.sysmessage( "Error: Your account rank does not permit this!" ) return False else: # ACL if key == 'acl': acl_list = None acl_list = wolfpack.accounts.acls() if not acl_list or len( acl_list ) == 0: socket.sysmessage( "Critical Error: No ACLs are defined!" ) return False if not value in acl_list: socket.sysmessage( "Error: %s is not a valid account.acl!" % value ) return False else: oldvalue = None oldvalue = str( account.acl ) if not oldvalue: socket.sysmessage( "Warning: This account previously had no ACL!" ) socket.sysmessage( "Previous: %s.acl = %s" % ( account.name, oldvalue ) ) account.acl = str( value ) if str( account.acl ) != str( value ): socket.sysmessage( "Error: Failure to set new account ACL!" ) return False socket.sysmessage( "Changed: %s.acl = %s" % ( account.name, account.acl ) ) char.log( LOG_MESSAGE, "Modified %s.acl ( %s :: %s ).\n" % ( account.name, oldvalue, value ) ) return True # Flags elif key == 'flags': oldvalue = account.flags socket.sysmessage( "Previous: %s.flags = %s" % ( account.name, account.flags ) ) account.flags = hex2dec( value ) socket.sysmessage( "Changed: %s.flags = %s" % ( account.name, account.flags ) ) char.log( LOG_MESSAGE, "Modified %s.flags ( %s :: %s ).\n" % ( account.name, oldvalue, value ) ) return True # MultiGems elif key == 'multigems': if value.lower() == "true" or value.lower() == "false" or value in [ 0, 1 ]: oldvalue = account.multigems socket.sysmessage( "Previous: %s.multigems = %s" % ( account.name, account.multigems ) ) account.multigems = value socket.sysmessage( "Changed: %s.multigems = %s" % ( account.name, account.multigems ) ) char.log( LOG_MESSAGE, "Modified %s.multigems ( %s :: %s ).\n" % ( account.name, oldvalue, value ) ) return True else: socket.sysmessage( "Error: The account.multigems property must be boolean!" ) return False # Password elif key == 'password': if len( value ) > 16 or len( value ) == 0: if len( value ) > 16: socket.sysmessage( "Error: Password exceeds the 16 character limit!" ) if len( value ) == 0: socket.sysmessage( "Error: Password is NULL!" ) return False else: oldvalue = account.password account.password = str( value ) socket.sysmessage( "Changed: %s.password" % account.name ) char.log( LOG_MESSAGE, "Modified %s.password.\n" % account.name ) return True # Email elif key == 'email': if len( value ) > 255 or len( value ) == 0: if len( value ) > 255: socket.sysmessage( "Error: Email exceeds the 255 character limit!" ) if len( value ) == 0: socket.sysmessage( "Error: Email is NULL!" ) return False else: oldvalue = account.email account.email = str( value ) socket.sysmessage( "Changed: %s.email" % account.name ) char.log( LOG_MESSAGE, "Modified %s.email.\n" % account.name ) return True # READ ONLY VALUES elif key in ['name','lastlogin','inuse','characters','rank']: char.log( LOG_MESSAGE, "Attempted modification of read-only value %s.%s.\n" % ( account.name, key ) ) socket.sysmessage( "Error: The account.%s property is read only!" % key ) return False # Unknown else: socket.sysmessage( "Error: Unknown account property given!" ) return False # Failure to find the account else: socket.sysmessage( "Error: Account %s could not be located!" % username ) return True
def find(socket, command, arguments): if (len(arguments) == 0): socket.sysmessage( tr('Usage: find <searchpattern>') ) return findsmenu = MakeMenu('FINDMENU', None, 'Find Menu') submenus = {} items = wolfpack.definitionsiterator(WPDT_ITEM) item = items.first while item: if not item.hasattribute('id'): item = items.next continue child = item.findchild('category') if not child: item = items.next continue categories = ['Items'] + child.text.split('\\') description = categories[len(categories)-1] # Name of the action categories = ['Items'] if ( re.search(arguments.lower(), description.lower()) ): # Iterate through the categories and see if they're all there category = '' if len(categories) > 0 and not submenus.has_key('\\'.join(categories) + '\\'): for subcategory in categories: if not submenus.has_key(category + subcategory + '\\'): # Category is our parent category parent = None if len(category) == 0: parent = findsmenu elif category in submenus: parent = submenus[category] category += subcategory + '\\' menu = MakeMenu('FINDMENU_' + category, parent, subcategory) submenus[category] = menu else: category += subcategory + '\\' child = item.findchild('id') if child: try: id = int(child.value) except: id = 0 else: id = 0 definition = item.getattribute('id') additem = AddItemAction(menu, description, id, definition) additem.otherhtml = 'Definition: ' + definition item = items.next npcs = wolfpack.definitionsiterator(WPDT_NPC) submenus = {} npc = npcs.first while npc: if not npc.hasattribute('id'): npc = npcs.next continue child = npc.findchild('category') if not child: npc = npcs.next continue id = npc.findchild('id') if id: try: if id.value.startswith('0x'): id = wolfpack.bodyinfo(hex2dec(id.value))['figurine'] else: id = wolfpack.bodyinfo(int(id.value))['figurine'] except: id = 0 else: id = 0 description = npc.findchild('desc') if description: description = description.value else: description = tr('No description available.') categories = ['NPCs'] + child.text.split('\\') title = categories[len(categories)-1] # Name of the action categories = ['NPCs'] if ( re.search(arguments.lower(), title.lower()) ): # Iterate trough the categories and see if they're all there category = '' if len(categories) > 0 and not submenus.has_key('\\'.join(categories) + '\\'): for subcategory in categories: if not submenus.has_key(category + subcategory + '\\'): # Category is our parent category parent = None if len(category) == 0: parent = findsmenu elif category in submenus: parent = submenus[category] category += subcategory + '\\' menu = MakeMenu('FINDMENU_' + category, parent, subcategory) submenus[category] = menu else: category += subcategory + '\\' definition = npc.getattribute('id') # Parse the position of this makemenu entry if len(categories) == 0: addnpc = AddNpcAction(menu, title , definition, definition) else: addnpc = AddNpcAction(submenus['\\'.join(categories) + '\\'], title, id, definition) addnpc.otherhtml = str(description) npc = npcs.next multis = wolfpack.definitionsiterator(WPDT_MULTI) submenus = {} multi = multis.first while multi: if not multi.hasattribute('id'): multi = multi.next continue child = multi.findchild('category') if not child: multi = multis.next continue categories = ['Multis'] + child.text.split('\\') description = categories[len(categories)-1] # Name of the action categories = ['Multis'] if ( re.search(arguments.lower(), description.lower()) ): # Iterate trough the categories and see if they're all there category = '' if len(categories) > 0 and not submenus.has_key('\\'.join(categories) + '\\'): for subcategory in categories: if not submenus.has_key(category + subcategory + '\\'): # Category is our parent category parent = None if len(category) == 0: parent = findsmenu elif category in submenus: parent = submenus[category] category += subcategory + '\\' menu = MakeMenu('FINDMENU_' + category, parent, subcategory) submenus[category] = menu else: category += subcategory + '\\' child = multi.findchild('id') if child: try: id = int(child.value) except: id = 0 else: id = 0 multi = multi.getattribute('id') # Parse the position of this makemenu entry if len(categories) == 0: addmulti = AddMultiAction(addmenu, description, id, multi) else: addmulti = AddMultiAction(submenus['\\'.join(categories) + '\\'], description, id, multi) addmulti.otherhtml = 'Definition: ' + multi multi = multis.next if ( len(findsmenu.submenus) > 0 ): findsmenu.send( socket ) else: socket.sysmessage( tr('Could not find any item, npc or multi matching the arguments.') )
def loadMenu(id, parent = None): definition = wolfpack.getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = TinkeringMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log(LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: loadMenu(child.getattribute('id'), menu) # Craft an item elif child.name == 'tinker': if not child.hasattribute('definition') or not child.hasattribute('name'): console.log(LOG_ERROR, "Tinker action without definition or name in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') name = child.getattribute('name') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = wolfpack.getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: itemid = hex2dec(child.getattribute('itemid', '0')) action = TinkerItemAction(menu, name, int(itemid), itemdef) except: console.log(LOG_ERROR, "Tinker action with invalid item id in menu %s.\n" % menu.id) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) # How much of the primary resource should be consumed if subchild.name == 'ingots': action.submaterial1 = hex2dec(subchild.getattribute('amount', '0')) elif subchild.name == 'gems': action.submaterial2 = hex2dec(subchild.getattribute('amount', '0')) # Standard material elif subchild.name == 'logs': amount = hex2dec(subchild.getattribute('amount', '0')) materialname = subchild.getattribute('name', 'Unknown') action.materials.append([['1bdd','1bde','1bdf','1be0','1be1','1be2','1bd7','1bd8','1bd9','1bda','1bdb','1bdc'], amount, 'Boards, Logs']) elif subchild.name == 'nomark': action.markable = 0 elif subchild.name == 'retaincolor': action.retaincolor = 1 # Normal Material elif subchild.name == 'material': if not subchild.hasattribute('id'): console.log(LOG_ERROR, "Material element without id list in menu %s.\n" % menu.id) break else: ids = subchild.getattribute('id').split(';') try: amount = hex2dec(subchild.getattribute('amount', '1')) materialname = subchild.getattribute('name', 'Unknown') except: console.log(LOG_ERROR, "Material element with invalid id list in menu %s.\n" % menu.id) break action.materials.append([ids, amount, materialname]) # Skill requirement elif subchild.name in skillnamesids: skill = skillnamesids[subchild.name] try: minimum = hex2dec(subchild.getattribute('min', '0')) except: console.log(LOG_ERROR, "%s element with invalid min value in menu %s.\n" % (subchild.name, menu.id)) try: maximum = hex2dec(subchild.getattribute('max', '1200')) except: console.log(LOG_ERROR, "%s element with invalid max value in menu %s.\n" % (subchild.name, menu.id)) try: penalty = hex2dec(subchild.getattribute('penalty','0')) except: console.log(LOG_ERROR, "%s element with invalid max value in menu %s.\n" % (subchild.name, menu.id)) action.skills[skill] = [minimum, maximum, penalty] # Sort the menu. This is important for the makehistory to make. menu.sort()
def accountSet(socket, username, key, value): account = None characcount = None char = socket.player characcount = wolfpack.accounts.find(char.account.name) account = wolfpack.accounts.find(username) if not account: socket.sysmessage("Error: No such account exists.") return False if len(value) == 0: socket.sysmessage("Error: No value was given.") return False # Usernames are limited to 16 characters in length if len(username) > 16 or len(username) == 0: if len(username) > 16: socket.sysmessage( "Error: Username exceeds the 16 character limit!") if len(username) == 0: socket.sysmessage("Error: Username is NULL!") return False # Find the account elif account: if account.rank >= characcount.rank and account.name != characcount.name: socket.sysmessage("Error: Your account rank does not permit this!") return False else: # ACL if key == 'acl': acl_list = None acl_list = wolfpack.accounts.acls() if not acl_list or len(acl_list) == 0: socket.sysmessage("Critical Error: No ACLs are defined!") return False if not value in acl_list: socket.sysmessage("Error: %s is not a valid account.acl!" % value) return False else: oldvalue = None oldvalue = str(account.acl) if not oldvalue: socket.sysmessage( "Warning: This account previously had no ACL!") socket.sysmessage("Previous: %s.acl = %s" % (account.name, oldvalue)) account.acl = str(value) if str(account.acl) != str(value): socket.sysmessage( "Error: Failure to set new account ACL!") return False socket.sysmessage("Changed: %s.acl = %s" % (account.name, account.acl)) char.log( LOG_MESSAGE, "Modified %s.acl ( %s :: %s ).\n" % (account.name, oldvalue, value)) return True # Flags elif key == 'flags': oldvalue = account.flags socket.sysmessage("Previous: %s.flags = %s" % (account.name, account.flags)) account.flags = hex2dec(value) socket.sysmessage("Changed: %s.flags = %s" % (account.name, account.flags)) char.log( LOG_MESSAGE, "Modified %s.flags ( %s :: %s ).\n" % (account.name, oldvalue, value)) return True # MultiGems elif key == 'multigems': if value.lower() == "true" or value.lower() == "false" or int( value) in [0, 1]: oldvalue = account.multigems socket.sysmessage("Previous: %s.multigems = %s" % (account.name, account.multigems)) account.multigems = value socket.sysmessage("Changed: %s.multigems = %s" % (account.name, account.multigems)) char.log( LOG_MESSAGE, "Modified %s.multigems ( %s :: %s ).\n" % (account.name, oldvalue, value)) return True else: socket.sysmessage( "Error: The account.multigems property must be boolean!" ) return False elif key == 'block': if value.lower() == "true" or (type(value) == int and int(value) == 1): if account.flags & 0x00000001: socket.sysmessage("Account already blocked!") return False else: account.flags |= 0x00000001 socket.sysmessage("Account '%s' blocked!" % account.name) char.log(LOG_MESSAGE, "Blocked account '%s'.\n" % account.name) return True elif value.lower() == "false" or (type(value) == int and int(value) == 0): if account.flags & 0x00000001: account.flags &= ~0x00000001 socket.sysmessage("Unblocked account '%s'!" % account.name) return True else: socket.sysmessage("Account is not blocked!") return False else: socket.sysmessage("Value must be false or 0, true or 1") return False # Password elif key == 'password': if len(value) > 16 or len(value) == 0: if len(value) > 16: socket.sysmessage( "Error: Password exceeds the 16 character limit!") if len(value) == 0: socket.sysmessage("Error: Password is NULL!") return False else: oldvalue = account.password account.password = str(value) socket.sysmessage("Changed: %s.password" % account.name) char.log(LOG_MESSAGE, "Modified %s.password.\n" % account.name) return True # Email elif key == 'email': if len(value) > 255 or len(value) == 0: if len(value) > 255: socket.sysmessage( "Error: Email exceeds the 255 character limit!") if len(value) == 0: socket.sysmessage("Error: Email is NULL!") return False else: oldvalue = account.email account.email = str(value) socket.sysmessage("Changed: %s.email" % account.name) char.log(LOG_MESSAGE, "Modified %s.email.\n" % account.name) return True # READ ONLY VALUES elif key in ['name', 'lastlogin', 'inuse', 'characters', 'rank']: char.log( LOG_MESSAGE, "Attempted modification of read-only value %s.%s.\n" % (account.name, key)) socket.sysmessage( "Error: The account.%s property is read only!" % key) return False # Unknown else: socket.sysmessage("Error: Unknown account property given!") return False # Failure to find the account else: socket.sysmessage("Error: Account %s could not be located!" % username) return True
def loadMenu(id, parent=None): definition = wolfpack.getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = CartographyMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log( LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: loadMenu(child.getattribute('id'), menu) # Craft an item elif child.name == 'craft': if not child.hasattribute('definition'): console.log( LOG_ERROR, "craft action without definition in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = wolfpack.getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: itemid = hex2dec(child.getattribute('itemid', '0')) except Exception, e: console.log( LOG_ERROR, "Craft action with invalid item id in menu %s: %s\n" % (menu.id, str(e))) if child.hasattribute('name'): name = child.getattribute('name') else: name = generateNamefromDef(itemdef) action = CartItemAction(menu, name, int(itemid), itemdef) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) # Normal Material if subchild.name == 'material': if not subchild.hasattribute('id'): console.log( LOG_ERROR, "Material element without id list in menu %s.\n" % menu.id) break else: ids = subchild.getattribute('id').split(';') try: amount = hex2dec( subchild.getattribute('amount', '1')) materialname = subchild.getattribute( 'name', 'Unknown') except: console.log( LOG_ERROR, "Material element with invalid id list in menu %s.\n" % menu.id) break action.materials.append( [ids, amount, materialname]) # Skill requirement elif subchild.name in skillnamesids: skill = skillnamesids[subchild.name] try: minimum = hex2dec(subchild.getattribute( 'min', '0')) except: console.log( LOG_ERROR, "%s element with invalid min value in menu %s.\n" % (subchild.name, menu.id)) try: maximum = hex2dec( subchild.getattribute('max', '1200')) except: console.log( LOG_ERROR, "%s element with invalid max value in menu %s.\n" % (subchild.name, menu.id)) action.skills[skill] = [minimum, maximum]
def find(socket, command, arguments): if (len(arguments) == 0): socket.sysmessage(tr('Usage: find <searchpattern>')) return findsmenu = MakeMenu('FINDMENU', None, 'Find Menu') submenus = {} items = wolfpack.definitionsiterator(WPDT_ITEM) item = items.first while item: if not item.hasattribute('id'): item = items.next continue child = item.findchild('category') if not child: item = items.next continue categories = ['Items'] + child.text.split('\\') description = categories[len(categories) - 1] # Name of the action categories = ['Items'] if (re.search(arguments.lower(), description.lower())): # Iterate through the categories and see if they're all there category = '' if len(categories) > 0 and not submenus.has_key( '\\'.join(categories) + '\\'): for subcategory in categories: if not submenus.has_key(category + subcategory + '\\'): # Category is our parent category parent = None if len(category) == 0: parent = findsmenu elif category in submenus: parent = submenus[category] category += subcategory + '\\' menu = MakeMenu('FINDMENU_' + category, parent, subcategory) submenus[category] = menu else: category += subcategory + '\\' child = item.findchild('id') if child: try: id = int(child.value) except: id = 0 else: id = 0 definition = item.getattribute('id') additem = AddItemAction(menu, description, id, definition) additem.otherhtml = 'Definition: ' + definition item = items.next npcs = wolfpack.definitionsiterator(WPDT_NPC) submenus = {} npc = npcs.first while npc: if not npc.hasattribute('id'): npc = npcs.next continue child = npc.findchild('category') if not child: npc = npcs.next continue id = npc.findchild('id') if id: try: if id.value.startswith('0x'): id = wolfpack.bodyinfo(hex2dec(id.value))['figurine'] else: id = wolfpack.bodyinfo(int(id.value))['figurine'] except: id = 0 else: id = 0 description = npc.findchild('desc') if description: description = description.value else: description = tr('No description available.') categories = ['NPCs'] + child.text.split('\\') title = categories[len(categories) - 1] # Name of the action categories = ['NPCs'] if (re.search(arguments.lower(), title.lower())): # Iterate trough the categories and see if they're all there category = '' if len(categories) > 0 and not submenus.has_key( '\\'.join(categories) + '\\'): for subcategory in categories: if not submenus.has_key(category + subcategory + '\\'): # Category is our parent category parent = None if len(category) == 0: parent = findsmenu elif category in submenus: parent = submenus[category] category += subcategory + '\\' menu = MakeMenu('FINDMENU_' + category, parent, subcategory) submenus[category] = menu else: category += subcategory + '\\' definition = npc.getattribute('id') # Parse the position of this makemenu entry if len(categories) == 0: addnpc = AddNpcAction(menu, title, definition, definition) else: addnpc = AddNpcAction(submenus['\\'.join(categories) + '\\'], title, id, definition) addnpc.otherhtml = str(description) npc = npcs.next multis = wolfpack.definitionsiterator(WPDT_MULTI) submenus = {} multi = multis.first while multi: if not multi.hasattribute('id'): multi = multi.next continue child = multi.findchild('category') if not child: multi = multis.next continue categories = ['Multis'] + child.text.split('\\') description = categories[len(categories) - 1] # Name of the action categories = ['Multis'] if (re.search(arguments.lower(), description.lower())): # Iterate trough the categories and see if they're all there category = '' if len(categories) > 0 and not submenus.has_key( '\\'.join(categories) + '\\'): for subcategory in categories: if not submenus.has_key(category + subcategory + '\\'): # Category is our parent category parent = None if len(category) == 0: parent = findsmenu elif category in submenus: parent = submenus[category] category += subcategory + '\\' menu = MakeMenu('FINDMENU_' + category, parent, subcategory) submenus[category] = menu else: category += subcategory + '\\' child = multi.findchild('id') if child: try: id = int(child.value) except: id = 0 else: id = 0 multi = multi.getattribute('id') # Parse the position of this makemenu entry if len(categories) == 0: addmulti = AddMultiAction(addmenu, description, id, multi) else: addmulti = AddMultiAction( submenus['\\'.join(categories) + '\\'], description, id, multi) addmulti.otherhtml = 'Definition: ' + multi multi = multis.next if (len(findsmenu.submenus) > 0): findsmenu.send(socket) else: socket.sysmessage( tr('Could not find any item, npc or multi matching the arguments.') )
def loadMenu(id, parent=None): definition = getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = BowcraftMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log( LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: loadMenu(child.getattribute('id'), menu) # Craft an item elif child.name in ['fletch', 'sefletch']: if not child.hasattribute('definition'): console.log( LOG_ERROR, "Bowcraft action without definition in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: console.log( LOG_ERROR, "Bowcraft action with invalid definition %s in menu %s.\n" % (itemdef, menu.id)) else: itemid = hex2dec(child.getattribute('itemid', '0')) if child.hasattribute('name'): name = child.getattribute('name') else: name = generateNamefromDef(itemdef) if child.name == 'sefletch': action = SeFletchItemAction(menu, name, int(itemid), itemdef) else: action = FletchItemAction(menu, name, int(itemid), itemdef) except: console.log( LOG_ERROR, "Bowcraft action with invalid item id in menu %s.\n" % menu.id) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) # How much of the primary resource should be consumed if subchild.name == 'logs': action.submaterial1 = hex2dec( subchild.getattribute('amount', '0')) # Normal Material if subchild.name == 'material': if not subchild.hasattribute('id'): console.log( LOG_ERROR, "Material element without id list in menu %s.\n" % menu.id) break else: ids = subchild.getattribute('id').split(';') try: amount = hex2dec( subchild.getattribute('amount', '1')) materialname = subchild.getattribute( 'name', 'Unknown') except: console.log( LOG_ERROR, "Material element with invalid id list in menu %s.\n" % menu.id) break action.materials.append( [ids, amount, materialname]) # Consume all available materials scaled by the # amount of each submaterial elif subchild.name == 'stackable': action.stackable = True # This item will never be exceptional elif subchild.name == 'nomark': action.markable = False # Skill requirement elif subchild.name in skillnamesids: skill = skillnamesids[subchild.name] try: minimum = hex2dec(subchild.getattribute( 'min', '0')) except: console.log( LOG_ERROR, "%s element with invalid min value in menu %s.\n" % (subchild.name, menu.id)) try: maximum = hex2dec( subchild.getattribute('max', '1200')) except: console.log( LOG_ERROR, "%s element with invalid max value in menu %s.\n" % (subchild.name, menu.id)) try: penalty = hex2dec( subchild.getattribute('penalty', '0')) except: console.log( LOG_ERROR, "%s element with invalid penalty value in menu %s.\n" % (subchild.name, menu.id)) action.skills[skill] = [minimum, maximum, penalty] # Sort the menu. This is important for the makehistory to make. menu.sort()
def loadMenu(id, parent=None): definition = wolfpack.getdefinition(WPDT_MENU, id) if not definition: if parent: console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id)) else: console.log(LOG_ERROR, "Unknown menu: %s.\n" % id) return name = definition.getattribute('name', '') menu = CarpentryMenu(id, parent, name) # See if we have any submenus for i in range(0, definition.childcount): child = definition.getchild(i) # Submenu if child.name == 'menu': if not child.hasattribute('id'): console.log( LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id) else: menuid = child.getattribute('id') # Don't show boards menu for simple carpentry if extended_carpentry or menuid != 'CARPENTRY_BOARDS': loadMenu(menuid, menu) # Craft an item elif child.name in ['carpenter', 'secarpenter']: if not child.hasattribute('definition'): console.log( LOG_ERROR, "Carpenter action without definition in menu %s.\n" % menu.id) else: itemdef = child.getattribute('definition') try: # See if we can find an item id if it's not given if not child.hasattribute('itemid'): item = wolfpack.getdefinition(WPDT_ITEM, itemdef) itemid = 0 if item: itemchild = item.findchild('id') if itemchild: itemid = itemchild.value else: console.log( LOG_ERROR, "Carpenter action with invalid definition %s in menu %s.\n" % (itemdef, menu.id)) else: itemid = hex2dec(child.getattribute('itemid', '0')) if child.hasattribute('name'): name = child.getattribute('name') else: name = generateNamefromDef(itemdef) if child.name == 'secarpenter': action = SeCarpItemAction(menu, name, int(itemid), itemdef) else: action = CarpItemAction(menu, name, int(itemid), itemdef) except: console.log( LOG_ERROR, "Carpenter action with invalid item id in menu %s.\n" % menu.id) # Process subitems for j in range(0, child.childcount): subchild = child.getchild(j) # How much of the primary resource should be consumed if subchild.name == 'boards': action.submaterial1 = hex2dec( subchild.getattribute('amount', '0')) # How much of the secondary resource should be consumed if subchild.name == 'ingots': action.submaterial2 = hex2dec( subchild.getattribute('amount', '0')) # Normal Material if subchild.name == 'wood' or subchild.name == 'cloth' or subchild.name == 'material': if not subchild.hasattribute('id'): console.log( LOG_ERROR, "Material element without id list in menu %s.\n" % menu.id) break else: ids = subchild.getattribute('id').split(';') try: amount = hex2dec( subchild.getattribute('amount', '1')) materialname = subchild.getattribute( 'name', 'Unknown') except: console.log( LOG_ERROR, "Material element with invalid id list in menu %s.\n" % menu.id) break action.materials.append( [ids, amount, materialname]) # Consume all available materials scaled by the # amount of each submaterial elif subchild.name == 'stackable': action.stackable = True elif subchild.name == 'nomark': action.markable = False elif subchild.name == 'noretaincolor': action.retaincolor = False # Skill requirement elif subchild.name in skillnamesids: skill = skillnamesids[subchild.name] try: minimum = hex2dec(subchild.getattribute( 'min', '0')) except: console.log( LOG_ERROR, "%s element with invalid min value in menu %s.\n" % (subchild.name, menu.id)) try: maximum = hex2dec( subchild.getattribute('max', '1200')) except: console.log( LOG_ERROR, "%s element with invalid max value in menu %s.\n" % (subchild.name, menu.id)) action.skills[skill] = [minimum, maximum] # Sort the menu. This is important for the makehistory to make. menu.sort()