本文整理汇总了Python中wolfpack.getdefinition函数的典型用法代码示例。如果您正苦于以下问题:Python getdefinition函数的具体用法?Python getdefinition怎么用?Python getdefinition使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getdefinition函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add
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.')
示例2: add
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."))
示例3: loadMenu
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()
示例4: static
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>')
示例5: generateMenu
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])
示例6: go
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
示例7: onLoad
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)
示例8: getPlacementData
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)
示例9: static
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>"))
示例10: make
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)
示例11: sendresponse
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>')
示例12: givequestreportids
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
示例13: givequestxpreward
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)
示例14: givequestdescription
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
示例15: buildHouse
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()