Beispiel #1
0
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."))
Beispiel #2
0
def add(socket, command, arguments):
	if len(arguments) > 0:
		if wolfpack.getdefinition(WPDT_ITEM, arguments):
			socket.sysmessage("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("Where do you want to spawn the npc '%s'?" % arguments)
			socket.attachtarget("commands.add.addnpc", [arguments])
		elif wolfpack.getdefinition(WPDT_MULTI, arguments):
			socket.sysmessage("Where do you want to place the multi '%s'?" % arguments)
			socket.attachtarget("commands.add.addmulti", [arguments, False])
		else:
			socket.sysmessage('No Item, NPC or Multi definition by that name found.')
		return

	global generated
	if not generated:
		socket.sysmessage('Generating add menu.')
		socket.sysmessage('Please wait...')
		generateAddMenu()
		generated = 1

	menu = findmenu('ADDMENU')
	if menu:
		menu.send(socket.player)
	else:
		socket.sysmessage('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()
Beispiel #4
0
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()
Beispiel #5
0
def static(socket, command, arguments):
	if len(arguments) > 0:
		if wolfpack.getdefinition(WPDT_ITEM, arguments):
			socket.sysmessage("Where do you want to place the item '%s'?" % arguments)
			socket.attachtarget("commands.add.additem", [arguments, True])
		elif wolfpack.getdefinition(WPDT_MULTI, arguments):
			socket.sysmessage("Where do you want to place the multi '%s'?" % arguments)
			socket.attachtarget("commands.add.addmulti", [arguments, True])
		else:
			socket.sysmessage('No Item, NPC or Multi definition by that name found.')
	else:
		socket.sysmessage('Usage: static <id>')
def generateMenu( id, parent = None ):
	titleid = 1015162
	menu0 = InscriptionMenu(id, parent, titleid)
	# add spell scrolls
	# loop circles
	for i in range(0, 8):
		menu = InscriptionMenu(id + str(i), menu0, circle_ids[i])
		# loop spells
		for j in range(0, 8):
			spell_num = i * 8 + j
			# if reactive armor spell
			if spell_num == 6:
				spell_num = 0
			elif spell_num < 6:
				spell_num += 1
			# spell < weaken
			itemdef = str(hex(int(0x1f2d) + spell_num)).replace('0x', '')
			item2 = wolfpack.getdefinition(WPDT_ITEM, itemdef)
			if item2:
				itemchild = item2.findchild('id')
				if itemchild:
					itemid = int(itemchild.value)
			actionid = 1027981 + spell_num
			action = InsItemAction(menu, itemid, itemdef, actionid)
			# required mana
			action.mana = req_manas[i]
			# empty scroll
			action.materials.append([['ef3','e34'], 1, 1044377])
			# required reagents
			regs = spell_regs[spell_num]
			for k in range(0, len(regs)):
				action.materials.append([[regs[k]], 1, reagents[regs[k]] + 1044353])
			# skill
			action.skills[INSCRIPTION] = req_skills[i]

	# Others
	menu = InscriptionMenu(id + '8', menu0, 1044294)
	# runebook
	itemdef = '22c5'
	item2 = wolfpack.getdefinition(WPDT_ITEM, itemdef)
	itemchild = item2.findchild('id')
	itemid = int(itemchild.value)
	actionid = 1041267
	action = InsItemAction(menu, itemid, itemdef, actionid)
	# recall scroll
	action.materials.append([['1f4c'], 1, 1044445])
	# gate travel scroll
	action.materials.append([['1f60'], 1, 1044446])
	# 8 runes
	action.materials.append([['1f14'], 8, 1044447])
Beispiel #7
0
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 onLoad():
	wolfpack.registerglobal(EVENT_SKILLGAIN, "system.skillgain")

	# Load all the neccesary data from the definitions
	for i in range(0, ALLSKILLS):
		skilldef = wolfpack.getdefinition(WPDT_SKILL, str(i))

		# Load the skill information
		if skilldef:
			SKILLS[i] = {
				SKILL_GAINFACTOR: 1.0,
				SKILL_STRCHANCE: 0.0,
				SKILL_DEXCHANCE: 0.0,
				SKILL_INTCHANCE: 0.0
			}

			for j in range(0, skilldef.childcount):
				child = skilldef.getchild(j)
				if child.name == 'name':
					SKILLS[i][SKILL_NAME] = child.value
				elif child.name == 'title':
					SKILLS[i][SKILL_TITLE] = child.value
				elif child.name == 'defname':
					SKILLS[i][SKILL_DEFNAME] = child.value
				elif child.name == 'gainchance':
					SKILLS[i][SKILL_GAINFACTOR] = float(child.value)
				elif child.name == 'strchance':
					SKILLS[i][SKILL_STRCHANCE] = float(child.value)
				elif child.name == 'dexchance':
					SKILLS[i][SKILL_DEXCHANCE] = float(child.value)
				elif child.name == 'intchance':
					SKILLS[i][SKILL_INTCHANCE] = float(child.value)
Beispiel #9
0
def go(socket, command, arguments):
    player = socket.player

    if len(arguments) == 0:
        global generated
        if not generated:
            socket.sysmessage("Generating go menu.")
            socket.sysmessage("Please wait...")
            generateGoMenu()
            generated = 1

        menu = findmenu("GOMENU")
        if menu:
            socket.sysmessage("Bringing up the travel gump.")
            menu.send(player)
        else:
            socket.sysmessage("Didn't find the GOMENU menu.")
        return
    elif arguments.count(",") >= 1:
        parts = arguments.split(",")
        pos = player.pos

        try:
            pos.x = int(parts[0])
            pos.y = int(parts[1])
            if len(parts) >= 3:
                pos.z = int(parts[2])

            if len(parts) >= 4:
                pos.map = int(parts[3])

            if not isValidPosition(pos):
                socket.sysmessage("Error: Destination invalid!")
                return False

            player.removefromview()
            player.moveto(pos)
            player.update()
            player.socket.resendworld()
            return
        except:
            pass

            # If we reach this point it was no valid coordinate
            # See if we can get a def
    location = wolfpack.getdefinition(WPDT_LOCATION, arguments)

    if location:
        (x, y, z, map) = location.text.split(",")
        pos = wolfpack.coord(int(x), int(y), int(z), int(map))
        if not isValidPosition(pos):
            socket.sysmessage("Error: Destination invalid!")
            return False
        player.removefromview()
        player.moveto(pos)
        player.update()
        player.socket.resendworld()
    else:
        socket.sysmessage("Usage: <x, y, z, map>|<location>")
    return
Beispiel #10
0
def go(socket, command, arguments):
    player = socket.player

    if len(arguments) == 0:
        global generated
        if not generated:
            socket.sysmessage('Generating go menu.')
            socket.sysmessage('Please wait...')
            generateGoMenu()
            generated = 1

        menu = findmenu('GOMENU')
        if menu:
            socket.sysmessage('Bringing up the travel gump.')
            menu.send(player)
        else:
            socket.sysmessage("Didn't find the GOMENU menu.")
        return
    elif arguments.count(',') >= 1:
        parts = arguments.split(',')
        pos = player.pos

        try:
            pos.x = int(parts[0])
            pos.y = int(parts[1])
            if len(parts) >= 3:
                pos.z = int(parts[2])

            if len(parts) >= 4:
                pos.map = int(parts[3])

            if not isValidPosition(pos):
                socket.sysmessage("Error: Destination invalid!")
                return False

            player.removefromview()
            player.moveto(pos)
            player.update()
            player.socket.resendworld()
            return
        except:
            pass

    # If we reach this point it was no valid coordinate
    # See if we can get a def
    location = wolfpack.getdefinition(WPDT_LOCATION, arguments)

    if location:
        (x, y, z, map) = location.text.split(',')
        pos = wolfpack.coord(int(x), int(y), int(z), int(map))
        if not isValidPosition(pos):
            socket.sysmessage("Error: Destination invalid!")
            return False
        player.removefromview()
        player.moveto(pos)
        player.update()
        player.socket.resendworld()
    else:
        socket.sysmessage('Usage: <x, y, z, map>|<location>')
    return
Beispiel #11
0
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)
Beispiel #12
0
def onLoad():
    wolfpack.registerglobal(EVENT_SKILLUSE, "skills")
    # Load all the neccesary data from the definitions
    for i in range(0, ALLSKILLS):
        skilldef = wolfpack.getdefinition(WPDT_SKILL, str(i))

        # Load the skill information
        if skilldef:
            SKILLS[i] = {
                SKILL_GAINFACTOR: 1.0,
                SKILL_STRCHANCE: 0.0,
                SKILL_DEXCHANCE: 0.0,
                SKILL_INTCHANCE: 0.0
            }

            for j in range(0, skilldef.childcount):
                child = skilldef.getchild(j)
                if child.name == 'name':
                    SKILLS[i][SKILL_NAME] = child.value
                elif child.name == 'title':
                    SKILLS[i][SKILL_TITLE] = child.value
                elif child.name == 'defname':
                    SKILLS[i][SKILL_DEFNAME] = child.value
                elif child.name == 'gainchance':
                    SKILLS[i][SKILL_GAINFACTOR] = float(child.value)
                elif child.name == 'strchance':
                    SKILLS[i][SKILL_STRCHANCE] = float(child.value)
                elif child.name == 'dexchance':
                    SKILLS[i][SKILL_DEXCHANCE] = float(child.value)
                elif child.name == 'intchance':
                    SKILLS[i][SKILL_INTCHANCE] = float(child.value)
Beispiel #13
0
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()
Beispiel #14
0
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>"))
Beispiel #15
0
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)
Beispiel #16
0
 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)
Beispiel #17
0
def sendresponse(player, arguments, target):
	if target.item:
		object = target.item
	elif target.char:
		if target.char.rank > player.rank and player != target.char:
			player.socket.sysmessage("You've burnt your fingers!")
			return

		object = target.char
	else:
		player.socket.sysmessage('You need to target a character or an item.')
		return

	# Maybe we need to choose a location
	if len(arguments) == 0:
		player.socket.sysmessage('Where do you want to send the targetted object?')
		player.socket.attachtarget('commands.go.sendresponse2', [object.serial])
	else:
		# Try to parse a target location for the object.
		parts = arguments[0].split(',')
		pos = player.pos
		try:
			pos.x = int(parts[0])
			pos.y = int(parts[1])
			if len(parts) >= 3:
				pos.z = int(parts[2])

			if len(parts) >= 4:
				pos.map = int(parts[3])

			object.removefromview()
			object.moveto(pos)
			object.update()
			if not object.ischar() or not object.socket:
				return
			object.socket.resendworld()
			return
		except:
			pass

		# If we reach this point it was no valid coordinate
		# See if we can get a def
		location = wolfpack.getdefinition(WPDT_LOCATION, arguments[0])

		if location:
			(x,y,z,map) = location.text.split(',')
			pos = wolfpack.coord(int(x), int(y), int(z), int(map))
			object.removefromview()
			object.moveto(pos)
			object.update()
			
			if object.ischar() and object.socket:
				object.socket.resendworld()
		else:
			player.socket.sysmessage('Usage: send <x, y, z, map>|<location>')
Beispiel #18
0
def givequestdescription(id):
    quest = ''
    node = wolfpack.getdefinition(WPDT_QUEST, str(id))

    count = node.childcount
    for i in range(0, count):
        subnode = node.getchild(i)
        if subnode.name == 'description':
            quest = subnode.text

    return quest
Beispiel #19
0
def givequestreportids(id):
    quest = ''
    node = wolfpack.getdefinition(WPDT_QUEST, str(id))

    count = node.childcount
    for i in range(0, count):
        subnode = node.getchild(i)
        if subnode.name == 'reportid':
            quest = subnode.text.split(',')

    return quest
Beispiel #20
0
def givequestxpreward(id):
    quest = ''
    node = wolfpack.getdefinition(WPDT_QUEST, str(id))

    count = node.childcount
    for i in range(0, count):
        subnode = node.getchild(i)
        if subnode.name == 'rewardxp':
            quest = subnode.text

    return int(quest)
Beispiel #21
0
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()
Beispiel #22
0
def givequestxpreward(id):
	quest = ''
	node = wolfpack.getdefinition(WPDT_QUEST, str(id))

	count = node.childcount
	for i in range(0, count):
		subnode = node.getchild(i)
		if subnode.name == 'rewardxp':
			quest = subnode.text

	return int(quest)
Beispiel #23
0
def givequestdescription(id):
	quest = ''
	node = wolfpack.getdefinition(WPDT_QUEST, str(id))

	count = node.childcount
	for i in range(0, count):
		subnode = node.getchild(i)
		if subnode.name == 'description':
			quest = subnode.text

	return quest
Beispiel #24
0
def givequestreportids(id):
	quest = ''
	node = wolfpack.getdefinition(WPDT_QUEST, str(id))

	count = node.childcount
	for i in range(0, count):
		subnode = node.getchild(i)
		if subnode.name == 'reportid':
			quest = subnode.text.split(',')

	return quest
Beispiel #25
0
def givequestrequiredlevel(id):
    quest = 0
    node = wolfpack.getdefinition(WPDT_QUEST, str(id))

    count = node.childcount
    for i in range(0, count):
        subnode = node.getchild(i)
        if subnode.name == 'requiredlevel':
            if len(subnode.text):
                quest = subnode.text

    return int(quest)
Beispiel #26
0
def givequestitemeachamount(id):
	quest = ''
	node = wolfpack.getdefinition(WPDT_QUEST, str(id))

	count = node.childcount
	for i in range(0, count):
		subnode = node.getchild(i)
		if subnode.name == 'itemamounts':
			quest = subnode.text.split(',')

	# Returning the list
	return quest
Beispiel #27
0
def givequestrequiredskills(id):
    skills = ''
    node = wolfpack.getdefinition(WPDT_QUEST, str(id))

    count = node.childcount
    for i in range(0, count):
        subnode = node.getchild(i)
        if subnode.name == 'requiredskills':
            if len(subnode.text):
                skills = subnode.text.split(',')

    return skills
Beispiel #28
0
def givequestrequiredskills(id):
	skills = ''
	node = wolfpack.getdefinition(WPDT_QUEST, str(id))

	count = node.childcount
	for i in range(0, count):
		subnode = node.getchild(i)
		if subnode.name == 'requiredskills':
			if len(subnode.text):
				skills = subnode.text.split(',')

	return skills
Beispiel #29
0
def givequestrequiredlevel(id):
	quest = 0
	node = wolfpack.getdefinition(WPDT_QUEST, str(id))

	count = node.childcount
	for i in range(0, count):
		subnode = node.getchild(i)
		if subnode.name == 'requiredlevel':
			if len(subnode.text):
				quest = subnode.text

	return int(quest)
Beispiel #30
0
def givequestitemeachamount(id):
    quest = ''
    node = wolfpack.getdefinition(WPDT_QUEST, str(id))

    count = node.childcount
    for i in range(0, count):
        subnode = node.getchild(i)
        if subnode.name == 'itemamounts':
            quest = subnode.text.split(',')

    # Returning the list
    return quest
Beispiel #31
0
 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)
Beispiel #32
0
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>'))
Beispiel #33
0
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.'))
Beispiel #34
0
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 )
Beispiel #35
0
def givenpcname(id):
	npc = ''

	node = wolfpack.getdefinition(WPDT_NPC, str(id))

	if node:
		count = node.childcount
		for i in range(0, count):
			subnode = node.getchild(i)
			if subnode.name == 'name':
				npc = subnode.text

		return npc

	else:

		return "Error"
Beispiel #36
0
def givequestname(id):
	quest = ''

	node = wolfpack.getdefinition(WPDT_QUEST, str(id))

	if node:
		count = node.childcount
		for i in range(0, count):
			subnode = node.getchild(i)
			if subnode.name == 'name':
				quest = subnode.text

		return quest

	else:

		return "Error"
Beispiel #37
0
def giveitemname(id):
	item = ''

	node = wolfpack.getdefinition(WPDT_ITEM, str(id))

	if node:
		count = node.childcount
		for i in range(0, count):
			subnode = node.getchild(i)
			if subnode.name == 'name':
				item = subnode.text

		return item

	else:

		return "Error"
Beispiel #38
0
def givenpcname(id):
    npc = ''

    node = wolfpack.getdefinition(WPDT_NPC, str(id))

    if node:
        count = node.childcount
        for i in range(0, count):
            subnode = node.getchild(i)
            if subnode.name == 'name':
                npc = subnode.text

        return npc

    else:

        return "Error"
Beispiel #39
0
def giveitemname(id):
    item = ''

    node = wolfpack.getdefinition(WPDT_ITEM, str(id))

    if node:
        count = node.childcount
        for i in range(0, count):
            subnode = node.getchild(i)
            if subnode.name == 'name':
                item = subnode.text

        return item

    else:

        return "Error"
Beispiel #40
0
def givequestname(id):
    quest = ''

    node = wolfpack.getdefinition(WPDT_QUEST, str(id))

    if node:
        count = node.childcount
        for i in range(0, count):
            subnode = node.getchild(i)
            if subnode.name == 'name':
                quest = subnode.text

        return quest

    else:

        return "Error"
def searchidscmd( socket, command, arguments ):
	out = open( 'missingids.xml', "wb" )

	if os.name == 'posix':
		nl = "\n"
	else:
		nl = "\r\n"

	out.write( '<definitions>%s' % ( nl ) )
	for id in range(0x0, 0x4000):
		tile = tiledata( id )

		# unused ids have only 5 entries in tiledata
		if len( tile ) > 5:
			itemdef =  hex(id).split("x")[1]
			if not getdefinition(WPDT_ITEM, itemdef):
				out.write( '\t<!-- %s -->%s' % ( tile['name'], nl ) )
				out.write( '\t<item id="%s">%s' % ( itemdef, nl ) )
				out.write( '\t\t<id>%s</id>%s' % ( hex(id), nl ) )
				out.write( '\t</item>%s' % ( nl ) )
				out.write( nl )

	out.write( '</definitions>%s' % ( nl ) )
	out.close()
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]
Beispiel #43
0
def adddecor( socket, command, args ):
	if len(args) > 0:
		args= str( args.strip() )
		args = args.split( ' ' )
		if len( args ) == 2:
			( key, value ) = args
			# Tree Lists
			if key == 'tree':
				# Random Forest Trees
				if value == 'forest':
					if socket.hastag( 'last_tree_forest' ):
						templist = []
						for choice in forestlist:
							if choice != str( socket.gettag( 'last_tree_forest' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_tree_forest', str( item ) )
					else:
						item = random.choice( forestlist )
						socket.settag( 'last_tree_forest', str( item ) )
					if item in trees:
						if wolfpack.getdefinition( WPDT_ITEM, trees[item][TREE] ) and wolfpack.getdefinition( WPDT_ITEM, trees[item][LEAVES] ):
							socket.sysmessage( "Where do you want to place the tree '%s', '%s' ?" % ( trees[item][TREE], trees[item][LEAVES ]) )
							socket.attachtarget( 'commands.adddecor.createtree', [ item ] )
						return True
				# Random Fruit Tree
				elif value == 'fruit':
					item = random.choice( fruitlist )
					if socket.hastag( 'last_tree_fruit' ):
						templist = []
						for choice in fruitlist:
							if choice != str( socket.gettag( 'last_tree_fruit' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_tree_fruit', str( item ) )
					else:
						item = random.choice( fruitlist )
						socket.settag( 'last_tree_fruit', str( item ) )
					if item in trees:
						if wolfpack.getdefinition( WPDT_ITEM, trees[item][TREE] ) and wolfpack.getdefinition( WPDT_ITEM, trees[item][LEAVES] ):
							socket.sysmessage( "Where do you want to place the tree '%s', '%s' ?" % ( trees[item][TREE], trees[item][LEAVES ]) )
							socket.attachtarget( 'commands.adddecor.createtree', [ item ] )
						return True
				# Random Swamp Tree
				elif value == 'swamp':
					item = random.choice( swamplist )
					if socket.hastag( 'last_tree_swamp' ):
						templist = []
						for choice in swamplist:
							if choice != str( socket.gettag( 'last_tree_swamp' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_tree_swamp', str( item ) )
					else:
						item = random.choice( swamplist )
						socket.settag( 'last_tree_swamp', str( item ) )
					if item in trees:
						if wolfpack.getdefinition( WPDT_ITEM, trees[item][TREE] ) and wolfpack.getdefinition( WPDT_ITEM, trees[item][LEAVES] ):
							socket.sysmessage( "Where do you want to place the tree '%s', '%s' ?" % ( trees[item][TREE], trees[item][LEAVES ]) )
							socket.attachtarget( 'commands.adddecor.createtree', [ item ] )
						return True
				# Random Trees
				elif value == 'random':
					if socket.hastag( 'last_tree_random' ):
						templist = []
						for choice in treeindex:
							if choice != str( socket.gettag( 'last_tree_random' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_tree_random', str( item ) )
					else:
						item = random.choice( treeindex )
						socket.settag( 'last_tree_random', str( item ) )
					if item in trees:
						if wolfpack.getdefinition( WPDT_ITEM, trees[item][TREE] ) and wolfpack.getdefinition( WPDT_ITEM, trees[item][LEAVES] ):
							socket.sysmessage( "Where do you want to place the tree '%s', '%s' ?" % ( trees[item][TREE], trees[item][LEAVES ]) )
							socket.attachtarget( 'commands.adddecor.createtree', [ item ] )
						return True
				# Yew Trees
				elif value == 'yew':
					socket.sysmessage( "Where do you want to place the yew tree?" )
					socket.attachtarget( 'commands.adddecor.createyewtree', [] )
					return True
				# Tree Logs log1, log2
				elif value in [ 'log1', 'log2' ]: #added by Jim 20040814
					item = value
					socket.sysmessage( "Where do you want to place the fallen log [%s]?" % ( item ) )
					socket.attachtarget( 'commands.adddecor.createlog', [ item ] )
					return True
				# Jungle Trees
				elif value == 'jungle':
					if socket.hastag( 'last_tree_jungle' ):
						templist = []
						for choice in jungleindex:
							if choice != str( socket.gettag( 'last_tree_jungle' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_tree_jungle', str( item ) )
					else:
						item = random.choice( jungleindex )
						socket.settag( 'last_tree_jungle', str( item ) )
					socket.sysmessage( "Where do you want to place the jungle tree [%s]?" %( item ) )
					socket.attachtarget(  'commands.adddecor.createjungletree', [ item ] )
					return True
				# Specific Tree
				elif value in trees:
					item = value
					if wolfpack.getdefinition( WPDT_ITEM, trees[item][TREE] ) and wolfpack.getdefinition( WPDT_ITEM, trees[item][LEAVES] ):
						socket.sysmessage( "Where do you want to place the tree '%s', '%s' ?" % ( trees[item][TREE], trees[item][LEAVES]) )
						socket.attachtarget( 'commands.adddecor.createtree', [ item ] )
						return True
				else:
					socket.sysmessage( "Usage: adddecor tree [ id, yew, jungle, random, forest, fruit, swamp, log[1-2] ]" )
					return False
			elif key == 'ground':
				# Forest Ground Decoration
				if value == "forest":
					if socket.hastag( 'last_ground_forest' ):
						templist = []
						for choice in forest_decor:
							if choice != str( socket.gettag( 'last_ground_forest' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_ground_forest', str( item ) )
					else:
						item = random.choice( forest_decor )
						socket.settag( 'last_ground_forest', str( item ) )
					socket.attachtarget( 'commands.adddecor.createground', [ item ] )
					return True
				# Swamp Ground Decoration
				elif value == "swamp":
					if socket.hastag( 'last_ground_swamp' ):
						templist = []
						for choice in swamp_decor:
							if choice != str( socket.gettag( 'last_ground_swamp' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_ground_swamp', str( item ) )
					else:
						item = random.choice( swamp_decor )
						socket.settag( 'last_ground_swamp', str( item ) )
					socket.attachtarget( 'commands.adddecor.createground', [ item ] )
					return True
				# Plains/Grass Ground Decoration
				elif value == "plains":
					if socket.hastag( 'last_ground_plains' ):
						templist = []
						for choice in plains_decor:
							if choice != str( socket.gettag( 'last_ground_plains' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_ground_plains', str( item ) )
					else:
						item = random.choice( plains_decor )
						socket.settag( 'last_ground_plains', str( item ) )
					socket.attachtarget( 'commands.adddecor.createground', [ item ] )
					return True
				# Jungle Ground Decoration
				elif value == "jungle":
					if socket.hastag( 'last_ground_jungle' ):
						templist = []
						for choice in jungle_decor:
							if choice != str( socket.gettag( 'last_ground_jungle' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_ground_jungle', str( item ) )
					else:
						item = random.choice( jungle_decor )
						socket.settag( 'last_ground_jungle', str( item ) )
					socket.attachtarget( 'commands.adddecor.createground', [ item ] )
					return True
				# Desert Ground Decoration
			 	elif value == "desert":
					if socket.hastag( 'last_ground_desert' ):
						templist = []
						for choice in desert_decor:
							if choice != str( socket.gettag( 'last_ground_desert' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_ground_desert', str( item ) )
					else:
						item = random.choice( desert_decor )
						socket.settag( 'last_ground_desert', str( item ) )
					socket.attachtarget( 'commands.adddecor.createground', [ item ] )
					return True
				# Random Ground Flowers
				elif value in [ "flowers", "smallflowers", "bigflowers" ]:
					if value == "flowers":
						flowers = flowers_decor
					elif value == "smallflowers":
						flowers = smallflowers_decor
					elif value == "bigflowers":
						flowers = bigflowers_decor
					if socket.hastag( 'last_ground_flowers' ):
						templist = []
						for choice in flowers:
							if choice != str( socket.gettag( 'last_ground_flowers' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_ground_flowers', str( item ) )
					else:
						item = random.choice( flowers )
						socket.settag( 'last_ground_flowers', str( item ) )
					socket.attachtarget( 'commands.adddecor.createground', [ item ] )
					return True
					#ferns
				elif value == "fern":
					if socket.hastag( 'last_ground_fern' ):
						templist = []
						for choice in fern_decor:
							if choice != str( socket.gettag( 'last_ground_fern' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_ground_fern', str( item ) )
					else:
						item = random.choice( fern_decor )
						socket.settag( 'last_ground_fern', str( item ) )
					socket.attachtarget( 'commands.adddecor.createground', [ item ] )
					return True
				# Nothing
				else:
					socket.sysmessage( "Usage: adddecor ground [ forest, swamp, plains, jungle, desert ]" )
					return False
			# No Args
			else:
				socket.sysmessage( "Usage: adddecor [ tree, ground ]" )
				socket.sysmessage( "Usage: adddecor tree [ id, yew, jungle, random, forest, fruit, swamp, log[1-2] ]" )
				socket.sysmessage( "Usage: adddecor ground [ forest, swamp, plains, jungle, desert ]" )
				return False
		# No Args
		else:
			socket.sysmessage( "Usage: adddecor [ tree, ground ]" )
			return False
	# No Args
	else:
		socket.sysmessage( "Usage: adddecor [ tree, ground ]" )
		return False
	return False
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()
Beispiel #45
0
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 adddecor( socket, command, args ):
	if len(args) > 0:
		args= str( args.strip() )
		args = args.split( ' ' )
		if len( args ) == 2:
			( key, value ) = args
			# Tree Lists
			if key == 'tree':
				# Random Forest Trees
				if value == 'forest':
					if socket.hastag( 'last_tree_forest' ):
						templist = []
						for choice in forestlist:
							if choice != str( socket.gettag( 'last_tree_forest' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_tree_forest', str( item ) )
					else:
						item = random.choice( forestlist )
						socket.settag( 'last_tree_forest', str( item ) )
					if item in trees:
						if wolfpack.getdefinition( WPDT_ITEM, trees[item][TREE] ) and wolfpack.getdefinition( WPDT_ITEM, trees[item][LEAVES] ):
							socket.sysmessage( "Where do you want to place the tree '%s', '%s' ?" % ( trees[item][TREE], trees[item][LEAVES ]) )
							socket.attachtarget( 'commands.adddecor.createtree', [ item ] )
						return True
				# Random Fruit Tree
				elif value == 'fruit':
					item = random.choice( fruitlist )
					if socket.hastag( 'last_tree_fruit' ):
						templist = []
						for choice in fruitlist:
							if choice != str( socket.gettag( 'last_tree_fruit' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_tree_fruit', str( item ) )
					else:
						item = random.choice( fruitlist )
						socket.settag( 'last_tree_fruit', str( item ) )
					if item in trees:
						if wolfpack.getdefinition( WPDT_ITEM, trees[item][TREE] ) and wolfpack.getdefinition( WPDT_ITEM, trees[item][LEAVES] ):
							socket.sysmessage( "Where do you want to place the tree '%s', '%s' ?" % ( trees[item][TREE], trees[item][LEAVES ]) )
							socket.attachtarget( 'commands.adddecor.createtree', [ item ] )
						return True
				# Random Swamp Tree
				elif value == 'swamp':
					item = random.choice( swamplist )
					if socket.hastag( 'last_tree_swamp' ):
						templist = []
						for choice in swamplist:
							if choice != str( socket.gettag( 'last_tree_swamp' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_tree_swamp', str( item ) )
					else:
						item = random.choice( swamplist )
						socket.settag( 'last_tree_swamp', str( item ) )
					if item in trees:
						if wolfpack.getdefinition( WPDT_ITEM, trees[item][TREE] ) and wolfpack.getdefinition( WPDT_ITEM, trees[item][LEAVES] ):
							socket.sysmessage( "Where do you want to place the tree '%s', '%s' ?" % ( trees[item][TREE], trees[item][LEAVES ]) )
							socket.attachtarget( 'commands.adddecor.createtree', [ item ] )
						return True
				# Random Trees
				elif value == 'random':
					if socket.hastag( 'last_tree_random' ):
						templist = []
						for choice in treeindex:
							if choice != str( socket.gettag( 'last_tree_random' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_tree_random', str( item ) )
					else:
						item = random.choice( treeindex )
						socket.settag( 'last_tree_random', str( item ) )
					if item in trees:
						if wolfpack.getdefinition( WPDT_ITEM, trees[item][TREE] ) and wolfpack.getdefinition( WPDT_ITEM, trees[item][LEAVES] ):
							socket.sysmessage( "Where do you want to place the tree '%s', '%s' ?" % ( trees[item][TREE], trees[item][LEAVES ]) )
							socket.attachtarget( 'commands.adddecor.createtree', [ item ] )
						return True
				# Yew Trees
				elif value == 'yew':
					socket.sysmessage( "Where do you want to place the yew tree?" )
					socket.attachtarget( 'commands.adddecor.createyewtree', [] )
					return True
				# Tree Logs log1, log2
				elif value in [ 'log1', 'log2' ]: #added by Jim 20040814
					item = value
					socket.sysmessage( "Where do you want to place the fallen log [%s]?" % ( item ) )
					socket.attachtarget( 'commands.adddecor.createlog', [ item ] )
					return True
				# Jungle Trees
				elif value == 'jungle':
					if socket.hastag( 'last_tree_jungle' ):
						templist = []
						for choice in jungleindex:
							if choice != str( socket.gettag( 'last_tree_jungle' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_tree_jungle', str( item ) )
					else:
						item = random.choice( jungleindex )
						socket.settag( 'last_tree_jungle', str( item ) )
					socket.sysmessage( "Where do you want to place the jungle tree [%s]?" %( item ) )
					socket.attachtarget(  'commands.adddecor.createjungletree', [ item ] )
					return True
				# Specific Tree
				elif value in trees:
					item = value
					if wolfpack.getdefinition( WPDT_ITEM, trees[item][TREE] ) and wolfpack.getdefinition( WPDT_ITEM, trees[item][LEAVES] ):
						socket.sysmessage( "Where do you want to place the tree '%s', '%s' ?" % ( trees[item][TREE], trees[item][LEAVES]) )
						socket.attachtarget( 'commands.adddecor.createtree', [ item ] )
						return True
				else:
					socket.sysmessage( "Usage: adddecor tree [ id, yew, jungle, random, forest, fruit, swamp, log[1-2] ]" )
					return False
			elif key == 'ground':
				# Forest Ground Decoration
				if value == "forest":
					if socket.hastag( 'last_ground_forest' ):
						templist = []
						for choice in forest_decor:
							if choice != str( socket.gettag( 'last_ground_forest' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_ground_forest', str( item ) )
					else:
						item = random.choice( forest_decor )
						socket.settag( 'last_ground_forest', str( item ) )
					socket.attachtarget( 'commands.adddecor.createground', [ item ] )
					return True
				# Swamp Ground Decoration
				elif value == "swamp":
					if socket.hastag( 'last_ground_swamp' ):
						templist = []
						for choice in swamp_decor:
							if choice != str( socket.gettag( 'last_ground_swamp' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_ground_swamp', str( item ) )
					else:
						item = random.choice( swamp_decor )
						socket.settag( 'last_ground_swamp', str( item ) )
					socket.attachtarget( 'commands.adddecor.createground', [ item ] )
					return True
				# Plains/Grass Ground Decoration
				elif value == "plains":
					if socket.hastag( 'last_ground_plains' ):
						templist = []
						for choice in plains_decor:
							if choice != str( socket.gettag( 'last_ground_plains' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_ground_plains', str( item ) )
					else:
						item = random.choice( plains_decor )
						socket.settag( 'last_ground_plains', str( item ) )
					socket.attachtarget( 'commands.adddecor.createground', [ item ] )
					return True
				# Jungle Ground Decoration
				elif value == "jungle":
					if socket.hastag( 'last_ground_jungle' ):
						templist = []
						for choice in jungle_decor:
							if choice != str( socket.gettag( 'last_ground_jungle' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_ground_jungle', str( item ) )
					else:
						item = random.choice( jungle_decor )
						socket.settag( 'last_ground_jungle', str( item ) )
					socket.attachtarget( 'commands.adddecor.createground', [ item ] )
					return True
				# Desert Ground Decoration
				elif value == "desert":
					if socket.hastag( 'last_ground_desert' ):
						templist = []
						for choice in desert_decor:
							if choice != str( socket.gettag( 'last_ground_desert' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_ground_desert', str( item ) )
					else:
						item = random.choice( desert_decor )
						socket.settag( 'last_ground_desert', str( item ) )
					socket.attachtarget( 'commands.adddecor.createground', [ item ] )
					return True
				# Random Ground Flowers
				elif value in [ "flowers", "smallflowers", "bigflowers" ]:
					if value == "flowers":
						flowers = flowers_decor
					elif value == "smallflowers":
						flowers = smallflowers_decor
					elif value == "bigflowers":
						flowers = bigflowers_decor
					if socket.hastag( 'last_ground_flowers' ):
						templist = []
						for choice in flowers:
							if choice != str( socket.gettag( 'last_ground_flowers' ) ):
								templist += [ choice ]
						item = random.choice( templist )
						socket.settag( 'last_ground_flowers', str( item ) )
					else:
						item = random.choice( flowers )
						socket.settag( 'last_ground_flowers', str( item ) )
					socket.attachtarget( 'commands.adddecor.createground', [ item ] )
					return True
				# Nothing
				else:
					socket.sysmessage( "Usage: adddecor ground [ forest, swamp, plains, jungle, desert ]" )
					return False
			# No Args
			else:
				socket.sysmessage( "Usage: adddecor [ tree, ground ]" )
				socket.sysmessage( "Usage: adddecor tree [ id, yew, jungle, random, forest, fruit, swamp, log[1-2] ]" )
				socket.sysmessage( "Usage: adddecor ground [ forest, swamp, plains, jungle, desert ]" )
				return False
		# No Args
		else:
			socket.sysmessage( "Usage: adddecor [ tree, ground ]" )
			return False
	# No Args
	else:
		socket.sysmessage( "Usage: adddecor [ tree, ground ]" )
		return False
	return False
Beispiel #47
0
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]
Beispiel #48
0
def sendresponse(player, arguments, target):
    if target.item:
        object = target.item
    elif target.char:
        if target.char.rank > player.rank and player != target.char:
            player.socket.sysmessage("You've burnt your fingers!")
            return

        object = target.char
    else:
        player.socket.sysmessage('You need to target a character or an item.')
        return

    # Maybe we need to choose a location
    if len(arguments) == 0:
        player.socket.sysmessage(
            'Where do you want to send the targetted object?')
        player.socket.attachtarget('commands.go.sendresponse2',
                                   [object.serial])
    else:
        # Try to parse a target location for the object.
        parts = arguments[0].split(',')
        pos = player.pos
        try:
            if len(parts) >= 3:
                pos.z = int(parts[2])
            if len(parts) >= 4:
                pos.map = int(parts[3])

            pos.x = int(parts[0])
            pos.y = int(parts[1])

            if not isValidPosition(pos):
                player.socket.sysmessage("Error: Destination invalid!")
                return False

            object.removefromview()
            object.moveto(pos)
            object.update()
            if not object.ischar() or not object.socket:
                return
            object.socket.resendworld()
            return
        except:
            pass

        # If we reach this point it was no valid coordinate
        # See if we can get a def
        location = wolfpack.getdefinition(WPDT_LOCATION, arguments[0])

        if location:
            (x, y, z, map) = location.text.split(',')
            pos = wolfpack.coord(int(x), int(y), int(z), int(map))
            if not isValidPosition(pos):
                player.socket.sysmessage("Error: Destination invalid!")
                return False
            object.removefromview()
            object.moveto(pos)
            object.update()

            if object.ischar() and object.socket:
                object.socket.resendworld()
        else:
            player.socket.sysmessage('Usage: send <x, y, z, map>|<location>')
    return
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 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()
Beispiel #51
0
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()