示例#1
0
def shrinktarget(char, args, target):
    if not target.char:
        char.socket.sysmessage(tr('You can only shrink characters.'))
        return
    if target.char.player:
        char.socket.sysmessage(tr('You cannot shrink other players.'))
        return

    bodyinfo = wolfpack.bodyinfo(target.char.id)

    if bodyinfo['figurine'] <= 0 or bodyinfo['figurine'] >= 0x4000:
        char.socket.sysmessage(tr('You cannot shrink that.'))
        return

    target.char.sound(SND_IDLE)

    # Create a new figurine and make it newbie
    figurine = wolfpack.additem('%x' % bodyinfo['figurine'])
    figurine.newbie = True
    figurine.addscript('figurine')
    figurine.settag('pet', target.char.serial)
    figurine.color = target.char.skin
    figurine.name = target.char.name
    figurine.update()
    figurine.moveto(target.char.pos)
    figurine.update()

    target.char.removefromview()
    target.char.owner = None
    target.char.stablemaster = figurine.serial
    target.char.addscript('figurine')  # This is a figurined NPC
示例#2
0
def shrinktarget( char, args, target ):
	if not target.char:
		char.socket.sysmessage(tr('You can only shrink characters.'))
		return
	if target.char.player:
		char.socket.sysmessage(tr('You cannot shrink other players.'))
		return
		
	bodyinfo = wolfpack.bodyinfo(target.char.id)
		
	if bodyinfo['figurine'] <= 0 or bodyinfo['figurine'] >= 0x4000:
		char.socket.sysmessage(tr('You cannot shrink that.'))
		return
			
	target.char.sound(SND_IDLE)

	# Create a new figurine and make it newbie
	figurine = wolfpack.additem('%x' % bodyinfo['figurine'])
	figurine.newbie = True
	figurine.addscript('figurine')
	figurine.settag('pet', target.char.serial)
	figurine.color = target.char.skin
	figurine.name = target.char.name
	figurine.update()
	figurine.moveto(target.char.pos)
	figurine.update()

	target.char.removefromview()
	target.char.owner = None
	target.char.stablemaster = figurine.serial
	target.char.addscript('figurine') # This is a figurined NPC
示例#3
0
文件: shrink.py 项目: thooge/Wolfpack
def potion(player, arguments, target):
    potion = wolfpack.finditem(arguments[0])

    if not potion or not player.canreach(potion, -1):
        player.socket.sysmessage(
            tr('The shrink potion has to be in your backpack to use it.'))
        return False

    if not canUsePotion(player, potion):
        return False

    if not target.char:
        player.socket.sysmessage(tr('You can only shrink pets owned by you.'))
        return False

    if not player.canreach(target.char, 1):
        player.socket.clilocmessage(500312)
        return False

    if target.char.player:
        player.socket.sysmessage(tr('You cannot shrink other players.'))
        return False

    if target.char.owner != player:
        player.socket.sysmessage(tr("You don't own that creature."))
        return False

    if target.char.id in PLAYER_BODIES_ALL:
        player.socket.sysmessage(
            tr('You can only shrink animals and monsters!'))
        return False

    bodyinfo = wolfpack.bodyinfo(target.char.id)

    if bodyinfo['figurine'] <= 0 or bodyinfo['figurine'] >= 0x4000:
        player.socket.sysmessage(tr('You cannot shrink that.'))
        return False

    target.char.sound(SND_IDLE)

    # Create a new figurine and make it newbie
    figurine = wolfpack.additem('%x' % bodyinfo['figurine'])
    figurine.newbie = True
    figurine.addscript('figurine')
    figurine.settag('pet', target.char.serial)
    figurine.color = target.char.skin
    figurine.name = target.char.name
    figurine.update()
    player.getbackpack().additem(figurine, True, True,
                                 False)  # Random pos, no auto stacking
    figurine.update()

    target.char.removefromview()
    target.char.owner = None
    target.char.stablemaster = figurine.serial
    target.char.addscript('figurine')  # This is a figurined NPC

    consumePotion(player, potion)
    return True
示例#4
0
def potion( player, arguments, target ):
	potion = wolfpack.finditem(arguments[0])
	
	if not potion or not player.canreach( potion, -1 ):
		player.socket.sysmessage( tr( 'The shrink potion has to be in your backpack to use it.' ) )
		return False

	if not canUsePotion( player, potion ):
		return False

	if not target.char:
		player.socket.sysmessage(tr('You can only shrink pets owned by you.'))
		return False

	if not player.canreach(target.char, 1):
		player.socket.clilocmessage(500312)
		return False

	if target.char.player:
		player.socket.sysmessage(tr('You cannot shrink other players.'))
		return False

	if target.char.owner != player:
		player.socket.sysmessage(tr("You don't own that creature."))
		return False

	if target.char.id in PLAYER_BODIES_ALL:
		player.socket.sysmessage(tr('You can only shrink animals and monsters!'))
		return False

	bodyinfo = wolfpack.bodyinfo(target.char.id)

	if bodyinfo['figurine'] <= 0 or bodyinfo['figurine'] >= 0x4000:
		player.socket.sysmessage(tr('You cannot shrink that.'))
		return False

	target.char.sound(SND_IDLE)

	# Create a new figurine and make it newbie
	figurine = wolfpack.additem('%x' % bodyinfo['figurine'])
	figurine.newbie = True
	figurine.addscript('figurine')
	figurine.settag('pet', target.char.serial)
	figurine.color = target.char.skin
	figurine.name = target.char.name
	figurine.update()
	player.getbackpack().additem(figurine, True, True, False) # Random pos, no auto stacking
	figurine.update()

	target.char.removefromview()
	target.char.owner = None
	target.char.stablemaster = figurine.serial
	target.char.addscript('figurine') # This is a figurined NPC

	consumePotion(player, potion)
	return True
示例#5
0
def TrackWhoGump(char, liste, startpoint, ran):

	socket = char.socket

	socket.closegump( 0x87651592 ) # TrackWhatGump/TrackWhoGump
	gump = cGump( x=20, y=30, callback=trackWhoResponse, type=0x87651592 )

	gump.startPage( 0 )
	gump.addBackground( 5054, 440, 135 )
	gump.addResizeGump( 10, 10, 2620, 420, 75 )
	gump.addResizeGump( 10, 85, 3000, 420, 25 )


	pages = ceil(len(liste) / 4)
	
	for page in range(1, pages + 1):
		gump.startPage(page)
		
		if page > 1:
			gump.addPageButton(5, 115, 5223, 5223, page - 1)
		
		if page < pages:
			gump.addPageButton(415, 115, 5224, 5224, page + 1)
		
		xoffset = 0
		for i in range(0, 4):
			if (page - 1) * 4 + i >= len(liste):
				break
			
			npc = liste[(page - 1) * 4 + i]
			
			bodyinfo = wolfpack.bodyinfo(npc.id)
			showid = bodyinfo['figurine']	
			
			gump.addTilePic( 20 + xoffset, 20, showid )
			gump.addButton( 25 + xoffset, 110, 4005, 4007, npc.serial )
			gump.addText(24 + xoffset, 90, npc.name, 0)
			
			xoffset += 100

	gump.setArgs( [liste, ran] )

	gump.send( char )

	if skills.skilltable[ TRACKING ][ skills.UNHIDE ] and char.hidden:
		char.reveal()
	return True
示例#6
0
def TrackWhoGump(char, liste, startpoint, ran):

    socket = char.socket

    socket.closegump(0x87651592)  # TrackWhatGump/TrackWhoGump
    gump = cGump(x=20, y=30, callback=trackWhoResponse, type=0x87651592)

    gump.startPage(0)
    gump.addBackground(5054, 440, 135)
    gump.addResizeGump(10, 10, 2620, 420, 75)
    gump.addResizeGump(10, 85, 3000, 420, 25)

    pages = ceil(len(liste) / 4)

    for page in range(1, pages + 1):
        gump.startPage(page)

        if page > 1:
            gump.addPageButton(5, 115, 5223, 5223, page - 1)

        if page < pages:
            gump.addPageButton(415, 115, 5224, 5224, page + 1)

        xoffset = 0
        for i in range(0, 4):
            if (page - 1) * 4 + i >= len(liste):
                break

            npc = liste[(page - 1) * 4 + i]

            bodyinfo = wolfpack.bodyinfo(npc.id)
            showid = bodyinfo['figurine']

            gump.addTilePic(20 + xoffset, 20, showid)
            gump.addButton(25 + xoffset, 110, 4005, 4007, npc.serial)
            gump.addText(24 + xoffset, 90, npc.name, 0)

            xoffset += 100

    gump.setArgs([liste, ran])

    gump.send(char)

    if skills.skilltable[TRACKING][skills.UNHIDE] and char.hidden:
        char.reveal()
    return True
示例#7
0
def find(socket, command, arguments):
	if (len(arguments) == 0):
		socket.sysmessage( tr('Usage: find <searchpattern>') )
		return

	findsmenu = MakeMenu('FINDMENU', None, 'Find Menu')
	submenus = {}

	items = wolfpack.definitionsiterator(WPDT_ITEM)
	item = items.first
	while item:
		if not item.hasattribute('id'):
			item = items.next
			continue

		child = item.findchild('category')
		if not child:
			item = items.next
			continue

		categories = ['Items'] + child.text.split('\\')
		description = categories[len(categories)-1] # Name of the action
		categories = ['Items']

		if ( re.search(arguments.lower(), description.lower()) ):
			# Iterate through the categories and see if they're all there
			category = ''
			if len(categories) > 0 and not submenus.has_key('\\'.join(categories) + '\\'):
				for subcategory in categories:
					if not submenus.has_key(category + subcategory + '\\'):
						# Category is our parent category
						parent = None
						if len(category) == 0:
							parent = findsmenu
						elif category in submenus:
							parent = submenus[category]

						category += subcategory + '\\'
						menu = MakeMenu('FINDMENU_' + category, parent, subcategory)
						submenus[category] = menu
					else:
						category += subcategory + '\\'

			child = item.findchild('id')
			if child:
				try:
					id = int(child.value)
				except:
					id = 0
			else:
				id = 0

			definition = item.getattribute('id')
			additem = AddItemAction(menu, description, id, definition)
			additem.otherhtml = 'Definition: ' + definition

		item = items.next

	npcs = wolfpack.definitionsiterator(WPDT_NPC)
	submenus = {}

	npc = npcs.first
	while npc:
		if not npc.hasattribute('id'):
			npc = npcs.next
			continue

		child = npc.findchild('category')
		if not child:
			npc = npcs.next
			continue

		id = npc.findchild('id')
		if id:
			try:
				if id.value.startswith('0x'):
					id = wolfpack.bodyinfo(hex2dec(id.value))['figurine']
				else:
					id = wolfpack.bodyinfo(int(id.value))['figurine']
			except:
				id = 0
		else:
			id = 0

		description = npc.findchild('desc')
		if description:
			description = description.value
		else:
			description = tr('No description available.')

		categories = ['NPCs'] + child.text.split('\\')
		title = categories[len(categories)-1] # Name of the action
		categories = ['NPCs']
			
		if ( re.search(arguments.lower(), title.lower()) ):

			# Iterate trough the categories and see if they're all there
			category = ''
			if len(categories) > 0 and not submenus.has_key('\\'.join(categories) + '\\'):
				for subcategory in categories:
					if not submenus.has_key(category + subcategory + '\\'):
						# Category is our parent category
						parent = None
						if len(category) == 0:
							parent = findsmenu
						elif category in submenus:
							parent = submenus[category]

						category += subcategory + '\\'
						menu = MakeMenu('FINDMENU_' + category, parent, subcategory)
						submenus[category] = menu
					else:
						category += subcategory + '\\'

			definition = npc.getattribute('id')

			# Parse the position of this makemenu entry
			if len(categories) == 0:
				addnpc = AddNpcAction(menu, title , definition, definition)
			else:
				addnpc = AddNpcAction(submenus['\\'.join(categories) + '\\'], title, id, definition)
			addnpc.otherhtml = str(description)
		npc = npcs.next
		
		
	multis = wolfpack.definitionsiterator(WPDT_MULTI)
	submenus = {}
		
	multi = multis.first
	while multi:
		if not multi.hasattribute('id'):
			multi = multi.next
			continue

		child = multi.findchild('category')
		if not child:
			multi = multis.next
			continue

		categories = ['Multis'] + child.text.split('\\')
		description = categories[len(categories)-1] # Name of the action
		categories = ['Multis']

		if ( re.search(arguments.lower(), description.lower()) ):
			# Iterate trough the categories and see if they're all there
			category = ''
			if len(categories) > 0 and not submenus.has_key('\\'.join(categories) + '\\'):
				for subcategory in categories:
					if not submenus.has_key(category + subcategory + '\\'):
						# Category is our parent category
						parent = None
						if len(category) == 0:
							parent = findsmenu
						elif category in submenus:
							parent = submenus[category]

						category += subcategory + '\\'
						menu = MakeMenu('FINDMENU_' + category, parent, subcategory)
						submenus[category] = menu
					else:
						category += subcategory + '\\'

			child = multi.findchild('id')
			if child:
				try:
					id = int(child.value)
				except:
					id = 0
			else:
				id = 0
			multi = multi.getattribute('id')
			# Parse the position of this makemenu entry
			if len(categories) == 0:
				addmulti = AddMultiAction(addmenu, description, id, multi)
			else:
				addmulti = AddMultiAction(submenus['\\'.join(categories) + '\\'], description, id, multi)
			addmulti.otherhtml = 'Definition: ' + multi
		multi = multis.next

	if ( len(findsmenu.submenus) > 0 ):
		findsmenu.send( socket )
	else:
		socket.sysmessage( tr('Could not find any item, npc or multi matching the arguments.') )
示例#8
0
def generateAddMenu(serial=0, items=None):
    char = wolfpack.findchar(serial)
    if not char or not char.socket:
        char = None
    """if not items:
		items = wolfpack.getdefinitions(WPDT_ITEM)
		if char:
			char.socket.sysmessage('Done getting list of definitions.')
		wolfpack.queuecode(generateAddMenu, (serial, items))
		return"""

    addmenu = MakeMenu('ADDMENU', None, 'Add Menu')
    submenus = {}

    # Process 100 at a time
    definitions = wolfpack.definitionsiterator(WPDT_ITEM)
    item = definitions.first
    while item:
        if not item.hasattribute('id'):
            item = definitions.next
            continue

        child = item.findchild('category')
        if not child:
            item = definitions.next
            continue

        categories = ['Items'] + child.text.split('\\')
        description = categories[len(categories) - 1]  # Name of the action
        categories = categories[:len(categories) - 1]

        # Iterate trough the categories and see if they're all there
        category = ''
        if len(categories) > 0 and not submenus.has_key('\\'.join(categories) +
                                                        '\\'):
            for subcategory in categories:
                if not submenus.has_key(category + subcategory + '\\'):
                    # Category is our parent category
                    parent = None
                    if len(category) == 0:
                        parent = addmenu
                    elif category in submenus:
                        parent = submenus[category]

                    category += subcategory + '\\'
                    menu = MakeMenu('ADDMENU_' + category, parent, subcategory)
                    submenus[category] = menu
                else:
                    category += subcategory + '\\'

        child = item.findchild('id')
        if child:
            try:
                id = int(child.value)
            except:
                id = 0
        else:
            id = 0
        definition = item.getattribute('id')

        # Parse the position of this makemenu entry
        if len(categories) == 0:
            additem = AddItemAction(addmenu, description, id, definition)
        else:
            additem = AddItemAction(submenus['\\'.join(categories) + '\\'],
                                    description, id, definition)
        additem.otherhtml = 'Definition: ' + definition
        item = definitions.next

    for menu in submenus.values():
        menu.sort()

    npcs = wolfpack.definitionsiterator(WPDT_NPC)
    submenus = {}

    npc = npcs.first
    while npc:
        if not npc.hasattribute('id'):
            npc = npcs.next
            continue

        child = npc.findchild('category')
        if not child:
            npc = npcs.next
            continue

        id = npc.findchild('id')
        if id:
            try:
                if id.value.startswith('0x'):
                    id = wolfpack.bodyinfo(hex2dec(id.value))['figurine']
                else:
                    id = wolfpack.bodyinfo(int(id.value))['figurine']
            except:
                id = 0
        else:
            id = 0

        description = npc.findchild('desc')
        if description:
            description = description.value
        else:
            description = tr('No description available.')

        categories = ['NPCs'] + child.text.split('\\')
        title = categories[len(categories) - 1]  # Name of the action
        categories = categories[:len(categories) - 1]

        # Iterate trough the categories and see if they're all there
        category = ''
        if len(categories) > 0 and not submenus.has_key('\\'.join(categories) +
                                                        '\\'):
            for subcategory in categories:
                if not submenus.has_key(category + subcategory + '\\'):
                    # Category is our parent category
                    parent = None
                    if len(category) == 0:
                        parent = addmenu
                    elif category in submenus:
                        parent = submenus[category]

                    category += subcategory + '\\'
                    menu = MakeMenu('ADDMENU_' + category, parent, subcategory)
                    submenus[category] = menu
                else:
                    category += subcategory + '\\'

        definition = npc.getattribute('id')

        # Parse the position of this makemenu entry
        if len(categories) == 0:
            addnpc = AddNpcAction(addmenu, title, definition, definition)
        else:
            addnpc = AddNpcAction(submenus['\\'.join(categories) + '\\'],
                                  title, id, definition)
        addnpc.otherhtml = str(description)
        npc = npcs.next

    for menu in submenus.values():
        menu.sort()

    multis = wolfpack.definitionsiterator(WPDT_MULTI)
    submenus = {}

    multi = multis.first
    while multi:
        if not multi.hasattribute('id'):
            multi = multi.next
            continue

        child = multi.findchild('category')
        if not child:
            multi = multis.next
            continue

        categories = ['Multis'] + child.text.split('\\')
        description = categories[len(categories) - 1]  # Name of the action
        categories = categories[:len(categories) - 1]

        # Iterate trough the categories and see if they're all there
        category = ''
        if len(categories) > 0 and not submenus.has_key('\\'.join(categories) +
                                                        '\\'):
            for subcategory in categories:
                if not submenus.has_key(category + subcategory + '\\'):
                    # Category is our parent category
                    parent = None
                    if len(category) == 0:
                        parent = addmenu
                    elif category in submenus:
                        parent = submenus[category]

                    category += subcategory + '\\'
                    menu = MakeMenu('ADDMENU_' + category, parent, subcategory)
                    submenus[category] = menu
                else:
                    category += subcategory + '\\'

        child = multi.findchild('id')
        if child:
            try:
                id = int(child.value)
            except:
                id = 0
        else:
            id = 0
        multi = multi.getattribute('id')
        # Parse the position of this makemenu entry
        if len(categories) == 0:
            addmulti = AddMultiAction(addmenu, description, id, multi)
        else:
            addmulti = AddMultiAction(submenus['\\'.join(categories) + '\\'],
                                      description, id, multi)
        addmulti.otherhtml = 'Definition: ' + multi
        multi = multis.next

    for menu in submenus.values():
        menu.sort()

    addmenu.sort()

    if char:
        addmenu.send(char)
示例#9
0
def generateAddMenu(serial=0, items=None):
    char = wolfpack.findchar(serial)
    if not char or not char.socket:
        char = None

    """if not items:
		items = wolfpack.getdefinitions(WPDT_ITEM)
		if char:
			char.socket.sysmessage('Done getting list of definitions.')
		wolfpack.queuecode(generateAddMenu, (serial, items))
		return"""

    addmenu = MakeMenu("ADDMENU", None, "Add Menu")
    submenus = {}

    # Process 100 at a time
    definitions = wolfpack.definitionsiterator(WPDT_ITEM)
    item = definitions.first
    while item:
        if not item.hasattribute("id"):
            item = definitions.next
            continue

        child = item.findchild("category")
        if not child:
            item = definitions.next
            continue

        categories = ["Items"] + child.text.split("\\")
        description = categories[len(categories) - 1]  # Name of the action
        categories = categories[: len(categories) - 1]

        # Iterate trough the categories and see if they're all there
        category = ""
        if len(categories) > 0 and not submenus.has_key("\\".join(categories) + "\\"):
            for subcategory in categories:
                if not submenus.has_key(category + subcategory + "\\"):
                    # Category is our parent category
                    parent = None
                    if len(category) == 0:
                        parent = addmenu
                    elif category in submenus:
                        parent = submenus[category]

                    category += subcategory + "\\"
                    menu = MakeMenu("ADDMENU_" + category, parent, subcategory)
                    submenus[category] = menu
                else:
                    category += subcategory + "\\"

        child = item.findchild("id")
        if child:
            try:
                id = int(child.value)
            except:
                id = 0
        else:
            id = 0
        definition = item.getattribute("id")

        # Parse the position of this makemenu entry
        if len(categories) == 0:
            additem = AddItemAction(addmenu, description, id, definition)
        else:
            additem = AddItemAction(submenus["\\".join(categories) + "\\"], description, id, definition)
        additem.otherhtml = "Definition: " + definition
        item = definitions.next

    for menu in submenus.values():
        menu.sort()

    npcs = wolfpack.definitionsiterator(WPDT_NPC)
    submenus = {}

    npc = npcs.first
    while npc:
        if not npc.hasattribute("id"):
            npc = npcs.next
            continue

        child = npc.findchild("category")
        if not child:
            npc = npcs.next
            continue

        id = npc.findchild("id")
        if id:
            try:
                if id.value.startswith("0x"):
                    id = wolfpack.bodyinfo(hex2dec(id.value))["figurine"]
                else:
                    id = wolfpack.bodyinfo(int(id.value))["figurine"]
            except:
                id = 0
        else:
            id = 0

        description = npc.findchild("desc")
        if description:
            description = description.value
        else:
            description = tr("No description available.")

        categories = ["NPCs"] + child.text.split("\\")
        title = categories[len(categories) - 1]  # Name of the action
        categories = categories[: len(categories) - 1]

        # Iterate trough the categories and see if they're all there
        category = ""
        if len(categories) > 0 and not submenus.has_key("\\".join(categories) + "\\"):
            for subcategory in categories:
                if not submenus.has_key(category + subcategory + "\\"):
                    # Category is our parent category
                    parent = None
                    if len(category) == 0:
                        parent = addmenu
                    elif category in submenus:
                        parent = submenus[category]

                    category += subcategory + "\\"
                    menu = MakeMenu("ADDMENU_" + category, parent, subcategory)
                    submenus[category] = menu
                else:
                    category += subcategory + "\\"

        definition = npc.getattribute("id")

        # Parse the position of this makemenu entry
        if len(categories) == 0:
            addnpc = AddNpcAction(addmenu, title, definition, definition)
        else:
            addnpc = AddNpcAction(submenus["\\".join(categories) + "\\"], title, id, definition)
        addnpc.otherhtml = str(description)
        npc = npcs.next

    for menu in submenus.values():
        menu.sort()

    multis = wolfpack.definitionsiterator(WPDT_MULTI)
    submenus = {}

    multi = multis.first
    while multi:
        if not multi.hasattribute("id"):
            multi = multi.next
            continue

        child = multi.findchild("category")
        if not child:
            multi = multis.next
            continue

        categories = ["Multis"] + child.text.split("\\")
        description = categories[len(categories) - 1]  # Name of the action
        categories = categories[: len(categories) - 1]

        # Iterate trough the categories and see if they're all there
        category = ""
        if len(categories) > 0 and not submenus.has_key("\\".join(categories) + "\\"):
            for subcategory in categories:
                if not submenus.has_key(category + subcategory + "\\"):
                    # Category is our parent category
                    parent = None
                    if len(category) == 0:
                        parent = addmenu
                    elif category in submenus:
                        parent = submenus[category]

                    category += subcategory + "\\"
                    menu = MakeMenu("ADDMENU_" + category, parent, subcategory)
                    submenus[category] = menu
                else:
                    category += subcategory + "\\"

        child = multi.findchild("id")
        if child:
            try:
                id = int(child.value)
            except:
                id = 0
        else:
            id = 0
        multi = multi.getattribute("id")
        # Parse the position of this makemenu entry
        if len(categories) == 0:
            addmulti = AddMultiAction(addmenu, description, id, multi)
        else:
            addmulti = AddMultiAction(submenus["\\".join(categories) + "\\"], description, id, multi)
        addmulti.otherhtml = "Definition: " + multi
        multi = multis.next

    for menu in submenus.values():
        menu.sort()

    addmenu.sort()

    if char:
        addmenu.send(char)
示例#10
0
def find(socket, command, arguments):
    if (len(arguments) == 0):
        socket.sysmessage(tr('Usage: find <searchpattern>'))
        return

    findsmenu = MakeMenu('FINDMENU', None, 'Find Menu')
    submenus = {}

    items = wolfpack.definitionsiterator(WPDT_ITEM)
    item = items.first
    while item:
        if not item.hasattribute('id'):
            item = items.next
            continue

        child = item.findchild('category')
        if not child:
            item = items.next
            continue

        categories = ['Items'] + child.text.split('\\')
        description = categories[len(categories) - 1]  # Name of the action
        categories = ['Items']

        if (re.search(arguments.lower(), description.lower())):
            # Iterate through the categories and see if they're all there
            category = ''
            if len(categories) > 0 and not submenus.has_key(
                    '\\'.join(categories) + '\\'):
                for subcategory in categories:
                    if not submenus.has_key(category + subcategory + '\\'):
                        # Category is our parent category
                        parent = None
                        if len(category) == 0:
                            parent = findsmenu
                        elif category in submenus:
                            parent = submenus[category]

                        category += subcategory + '\\'
                        menu = MakeMenu('FINDMENU_' + category, parent,
                                        subcategory)
                        submenus[category] = menu
                    else:
                        category += subcategory + '\\'

            child = item.findchild('id')
            if child:
                try:
                    id = int(child.value)
                except:
                    id = 0
            else:
                id = 0

            definition = item.getattribute('id')
            additem = AddItemAction(menu, description, id, definition)
            additem.otherhtml = 'Definition: ' + definition

        item = items.next

    npcs = wolfpack.definitionsiterator(WPDT_NPC)
    submenus = {}

    npc = npcs.first
    while npc:
        if not npc.hasattribute('id'):
            npc = npcs.next
            continue

        child = npc.findchild('category')
        if not child:
            npc = npcs.next
            continue

        id = npc.findchild('id')
        if id:
            try:
                if id.value.startswith('0x'):
                    id = wolfpack.bodyinfo(hex2dec(id.value))['figurine']
                else:
                    id = wolfpack.bodyinfo(int(id.value))['figurine']
            except:
                id = 0
        else:
            id = 0

        description = npc.findchild('desc')
        if description:
            description = description.value
        else:
            description = tr('No description available.')

        categories = ['NPCs'] + child.text.split('\\')
        title = categories[len(categories) - 1]  # Name of the action
        categories = ['NPCs']

        if (re.search(arguments.lower(), title.lower())):

            # Iterate trough the categories and see if they're all there
            category = ''
            if len(categories) > 0 and not submenus.has_key(
                    '\\'.join(categories) + '\\'):
                for subcategory in categories:
                    if not submenus.has_key(category + subcategory + '\\'):
                        # Category is our parent category
                        parent = None
                        if len(category) == 0:
                            parent = findsmenu
                        elif category in submenus:
                            parent = submenus[category]

                        category += subcategory + '\\'
                        menu = MakeMenu('FINDMENU_' + category, parent,
                                        subcategory)
                        submenus[category] = menu
                    else:
                        category += subcategory + '\\'

            definition = npc.getattribute('id')

            # Parse the position of this makemenu entry
            if len(categories) == 0:
                addnpc = AddNpcAction(menu, title, definition, definition)
            else:
                addnpc = AddNpcAction(submenus['\\'.join(categories) + '\\'],
                                      title, id, definition)
            addnpc.otherhtml = str(description)
        npc = npcs.next

    multis = wolfpack.definitionsiterator(WPDT_MULTI)
    submenus = {}

    multi = multis.first
    while multi:
        if not multi.hasattribute('id'):
            multi = multi.next
            continue

        child = multi.findchild('category')
        if not child:
            multi = multis.next
            continue

        categories = ['Multis'] + child.text.split('\\')
        description = categories[len(categories) - 1]  # Name of the action
        categories = ['Multis']

        if (re.search(arguments.lower(), description.lower())):
            # Iterate trough the categories and see if they're all there
            category = ''
            if len(categories) > 0 and not submenus.has_key(
                    '\\'.join(categories) + '\\'):
                for subcategory in categories:
                    if not submenus.has_key(category + subcategory + '\\'):
                        # Category is our parent category
                        parent = None
                        if len(category) == 0:
                            parent = findsmenu
                        elif category in submenus:
                            parent = submenus[category]

                        category += subcategory + '\\'
                        menu = MakeMenu('FINDMENU_' + category, parent,
                                        subcategory)
                        submenus[category] = menu
                    else:
                        category += subcategory + '\\'

            child = multi.findchild('id')
            if child:
                try:
                    id = int(child.value)
                except:
                    id = 0
            else:
                id = 0
            multi = multi.getattribute('id')
            # Parse the position of this makemenu entry
            if len(categories) == 0:
                addmulti = AddMultiAction(addmenu, description, id, multi)
            else:
                addmulti = AddMultiAction(
                    submenus['\\'.join(categories) + '\\'], description, id,
                    multi)
            addmulti.otherhtml = 'Definition: ' + multi
        multi = multis.next

    if (len(findsmenu.submenus) > 0):
        findsmenu.send(socket)
    else:
        socket.sysmessage(
            tr('Could not find any item, npc or multi matching the arguments.')
        )
示例#11
0
def spawn(spawner, spawntype, spawndef, current, area):
	try:
		if spawntype == 1:
			npc = wolfpack.addnpc(spawndef, spawner.pos)
			npc.settag('spawner', spawner.serial)
			# NPCs with Area 0 have to stay on Origin Point
			if not area == 0:
				npc.wandertype = 3
			else:
				npc.wandertype = 0
			npc.wanderx1 = spawner.pos.x
			npc.wandery1 = spawner.pos.y
			npc.wanderradius = area
			npc.addscript( 'system.spawns' )

			# Now Adv. Settings
			if spawner.hastag('color'):
				npc.skin = int(spawner.gettag('color'))

			if spawner.hastag('modstr'):
				npc.strength = npc.strength * float(spawner.gettag('modstr'))

			if spawner.hastag('moddex'):
				npc.dexterity = npc.dexterity * float(spawner.gettag('moddex'))

			if spawner.hastag('modint'):
				npc.intelligence = npc.intelligence * float(spawner.gettag('modint'))

			if spawner.hastag('modmaxhits'):
				npc.maxhitpoints = npc.maxhitpoints * float(spawner.gettag('modmaxhits'))

			if spawner.hastag('modmaxstam'):
				npc.maxstamina = npc.maxstamina * float(spawner.gettag('modmaxstam'))

			if spawner.hastag('modmaxmana'):
				npc.maxmana = npc.maxmana * float(spawner.gettag('modmaxmana'))

			if spawner.hastag('name'):
				npc.name = spawner.gettag('name')

			if spawner.hastag('nameprefix'):
				npc.settag('name.prefix', spawner.gettag('nameprefix'))

			if spawner.hastag('namesuffix'):
				npc.settag('name.suffix', spawner.gettag('namesuffix'))

			npc.update()

			# Updating visual of Spawn
			if SHOWNPCICON:
				bodyinfo = wolfpack.bodyinfo(npc.id)
				spawner.id = bodyinfo['figurine']
				spawner.update()
		elif spawntype == 0:
			newitem = wolfpack.additem(spawndef)
			newitem.pos = spawner.pos
			newitem.settag('spawner', spawner.serial)
			newitem.decay = 0
			newitem.addscript('system.spawns')
			newitem.update()
	except:
		if( spawner ):
			console.log(LOG_WARNING, "Invalid spawner: 0x%x.\n" % spawner.serial)
		return

	spawner.settag('current', current + 1)
	spawner.resendtooltip()
示例#12
0
文件: spawns.py 项目: thooge/Wolfpack
def spawn(spawner, spawntype, spawndef, current, area):
    try:
        if spawntype == 1:
            npc = wolfpack.addnpc(spawndef, spawner.pos)
            npc.settag('spawner', spawner.serial)
            # NPCs with Area 0 have to stay on Origin Point
            if not area == 0:
                npc.wandertype = 3
            else:
                npc.wandertype = 0
            npc.wanderx1 = spawner.pos.x
            npc.wandery1 = spawner.pos.y
            npc.wanderradius = area
            npc.addscript('system.spawns')

            # Now Adv. Settings
            if spawner.hastag('color'):
                npc.skin = int(spawner.gettag('color'))

            if spawner.hastag('modstr'):
                npc.strength = npc.strength * float(spawner.gettag('modstr'))

            if spawner.hastag('moddex'):
                npc.dexterity = npc.dexterity * float(spawner.gettag('moddex'))

            if spawner.hastag('modint'):
                npc.intelligence = npc.intelligence * float(
                    spawner.gettag('modint'))

            if spawner.hastag('modmaxhits'):
                npc.maxhitpoints = npc.maxhitpoints * float(
                    spawner.gettag('modmaxhits'))

            if spawner.hastag('modmaxstam'):
                npc.maxstamina = npc.maxstamina * float(
                    spawner.gettag('modmaxstam'))

            if spawner.hastag('modmaxmana'):
                npc.maxmana = npc.maxmana * float(spawner.gettag('modmaxmana'))

            if spawner.hastag('name'):
                npc.name = spawner.gettag('name')

            if spawner.hastag('nameprefix'):
                npc.settag('name.prefix', spawner.gettag('nameprefix'))

            if spawner.hastag('namesuffix'):
                npc.settag('name.suffix', spawner.gettag('namesuffix'))

            npc.update()

            # Updating visual of Spawn
            if SHOWNPCICON:
                bodyinfo = wolfpack.bodyinfo(npc.id)
                spawner.id = bodyinfo['figurine']
                spawner.update()
        elif spawntype == 0:
            newitem = wolfpack.additem(spawndef)
            newitem.pos = spawner.pos
            newitem.settag('spawner', spawner.serial)
            newitem.decay = 0
            newitem.addscript('system.spawns')
            newitem.update()
    except:
        if (spawner):
            console.log(LOG_WARNING,
                        "Invalid spawner: 0x%x.\n" % spawner.serial)
        return

    spawner.settag('current', current + 1)
    spawner.resendtooltip()