def incognito_expire(char, arguments): if not char.incognito or char.polymorph: return (oldhair, oldhaircolor, oldfacial, oldfacialcolor) = arguments hair = char.itemonlayer(LAYER_HAIR) if hair: hair.delete() if len(oldhair) != 0: hair = wolfpack.additem(oldhair) hair.color = oldhaircolor char.additem(LAYER_HAIR, hair) hair.update() facial = char.itemonlayer(LAYER_BEARD) if facial: facial.delete() if len(oldfacial) != 0: facial = wolfpack.additem(oldfacial) facial.color = oldfacialcolor char.additem(LAYER_BEARD, facial) facial.update() char.name = char.orgname char.skin = char.orgskin char.id = char.orgid char.incognito = 0 char.resendtooltip() char.update()
def createpack(char, killer, corpse, pack): # A pack is actually a list of lists for item in pack: packchance = item[ PACK_CHANCE ] packstackable = item[ PACK_STACKABLE ] packamount = item[ PACK_AMOUNT ] packitem = item[ PACK_ITEM ] if packchance >= random.random(): if type( packamount ) == str: amount = utilities.rolldice( packamount ) else: amount = int( packamount ) if packstackable == True: if type( packitem ) == list: itemid = random.choice( packitem ) elif type( packitem ) == str: itemid = str( packitem ) item = wolfpack.additem( itemid ) item.amount = amount dropitem(item, char, corpse) else: for i in range(0, amount): if type( packitem ) == list: itemid = random.choice( packitem ) elif type( packitem ) == str: itemid = str( packitem ) item = wolfpack.additem(itemid) dropitem(item, char, corpse)
def create_leaves(serial, fruittype="apple"): object = wolfpack.finditem(serial) # Lets figure out what kind of leaves we need if object.id == 0xD94: leaves = wolfpack.additem("d95") elif object.id == 0xD98: leaves = wolfpack.additem("d99") if leaves: object.settag("leaf_serial", leaves.serial) leaves = None leaves = wolfpack.finditem(object.gettag("leaf_serial")) leaves.pos = "%i,%i,%i,%i" % (object.pos.x, object.pos.y, object.pos.z, object.pos.map) if leaves.pos != object.pos: leaves.moveto(object.pos) # leaves.visible = 0 object.update() # 2 - 15 minutes leaves.addtimer(int(60000 * random.randint(2, 15)), leaves_progress, []) leaves.update() leaves.settag("fruit_count", 0) leaves.settag("fruit_type", str(fruittype)) leaves.settag("stage", 0) return True else: object.update() return False
def SackFlourOpen(char, args, target): item = wolfpack.finditem(args[0]) if not item or not target.item: return False if not target.item.getoutmostchar() == char: char.socket.clilocmessage(1042001) # That must be in your pack for you to use it. return True backpack = char.getbackpack() # wooden bowl if target.item.baseid == "15f8": bowl_flour = wolfpack.additem("a1e") if not tobackpack(bowl_flour, char): bowl_flour.update() # tribal berry elif target.item.baseid == "tribal_berry": if char.skill[COOKING] >= 800: tribal_paint = wolfpack.additem("tribal_paint") if not tobackpack(tribal_paint, char): tribal_paint.update() char.socket.clilocmessage( 1042002 ) # You combine the berry and the flour into the tribal paint worn by the savages. else: char.socket.clilocmessage(1042003) # You don't have the cooking skill to create the body paint. else: return False target.item.delete() consume(item)
def JarHoney(char, args, target): honey = wolfpack.finditem(args[0]) if not honey or not target.item: return False if not target.item.getoutmostchar() == char: char.socket.clilocmessage(1042001) # That must be in your pack for you to use it. return True backpack = char.getbackpack() # Dough if target.item.baseid == "103d": sweet_dough = wolfpack.additem("sweet_dough") if not tobackpack(sweet_dough, char): sweet_dough.update() # Bowl Flour elif target.item.baseid == "a1e": cookie_mix = wolfpack.additem("103f") if not tobackpack(cookie_mix, char): cookie_mix.update() else: return False if honey.amount > 1: honey.amount = honey.amount - 1 honey.update() else: honey.delete() target.item.delete()
def JarHoney(char, args, target): honey = wolfpack.finditem(args[0]) if not honey or not target.item: return False if not target.item.getoutmostchar() == char: char.socket.clilocmessage( 1042001) # That must be in your pack for you to use it. return True backpack = char.getbackpack() # Dough if target.item.baseid == "103d": sweet_dough = wolfpack.additem("sweet_dough") if not tobackpack(sweet_dough, char): sweet_dough.update() # Bowl Flour elif target.item.baseid == "a1e": cookie_mix = wolfpack.additem("103f") if not tobackpack(cookie_mix, char): cookie_mix.update() else: return False if honey.amount > 1: honey.amount = honey.amount - 1 honey.update() else: honey.delete() target.item.delete()
def water(char, args, target): item = wolfpack.finditem( args[0] ) cprops = args[1] quantity = args[2] if not item: return False if target.char and target.char == char: return drink(char, item) # Bowl Flour -> make dough elif target.item: if target.item.baseid == 'a1e': if not target.item.getoutmostchar() == char: char.socket.clilocmessage( 1042001 ) # That must be in your pack for you to use it. return True dough = wolfpack.additem( "103d" ) if not tobackpack( dough, char ): dough.update() wooden_bowl = wolfpack.additem( "15f8" ) if not tobackpack( wooden_bowl, char ): wooden_bowl.update() target.item.delete() consume(item) elif quantity < cprops[1]: fillfromitem( target, item, cprops ) return True
def createKeys(plank1, plank2, hold, boat, player): rkeyid = createkeysecret() packkey = wolfpack.additem('1010') packkey.settag('lock', rkeyid) packkey.name = "a ship key" packkey.settag('recall.link', boat.serial) tobackpack(packkey, player) packkey.update() player.say(502485, socket=player.socket) # A ship's key is now in my backpack. bankkey = wolfpack.additem('1010') bankkey.settag('lock', rkeyid) bankkey.name = "a ship key" bankkey.settag('recall.link', boat.serial) tobankbox(bankkey, player) player.say( 502484, socket=player.socket) # A ship's key is now in my safety deposit box. # Plank Section plank1.settag('lock', rkeyid) plank1.addscript('lock') plank1.settag('locked', 1) plank2.settag('lock', rkeyid) plank2.addscript('lock') plank2.settag('locked', 1) # Hold Section hold.settag('lock', rkeyid) hold.addscript('lock') hold.settag('locked', 1)
def SackFlourOpen(char, args, target): item = wolfpack.finditem(args[0]) if not item or not target.item: return False if not target.item.getoutmostchar() == char: char.socket.clilocmessage( 1042001) # That must be in your pack for you to use it. return True backpack = char.getbackpack() # wooden bowl if target.item.baseid == "15f8": bowl_flour = wolfpack.additem("a1e") if not tobackpack(bowl_flour, char): bowl_flour.update() # tribal berry elif target.item.baseid == "tribal_berry": if char.skill[COOKING] >= 800: tribal_paint = wolfpack.additem("tribal_paint") if not tobackpack(tribal_paint, char): tribal_paint.update() char.socket.clilocmessage( 1042002 ) # You combine the berry and the flour into the tribal paint worn by the savages. else: char.socket.clilocmessage( 1042003 ) # You don't have the cooking skill to create the body paint. else: return False target.item.delete() consume(item)
def create_leaves(serial, fruittype='apple'): object = wolfpack.finditem(serial) # Lets figure out what kind of leaves we need if object.id == 0xd94: leaves = wolfpack.additem('d95') elif object.id == 0xd98: leaves = wolfpack.additem('d99') if leaves: object.settag('leaf_serial', leaves.serial) leaves = None leaves = wolfpack.finditem(object.gettag('leaf_serial')) leaves.pos = "%i,%i,%i,%i" % (object.pos.x, object.pos.y, object.pos.z, object.pos.map) if leaves.pos != object.pos: leaves.moveto(object.pos) #leaves.visible = 0 object.update() # 2 - 15 minutes leaves.addtimer(int(60000 * random.randint(2, 15)), leaves_progress, []) leaves.update() leaves.settag('fruit_count', 0) leaves.settag('fruit_type', str(fruittype)) leaves.settag('stage', 0) return True else: object.update() return False
def createItems(self, vendor, player, item, amount = 1): if amount <= 0: return # Unable to comply backpack = player.getbackpack() # We will at the very least require one item, # so create that one here. bought = wolfpack.additem(self.baseid) stackable = bought.canstack(bought) # Check if bought could stack with bought if stackable: bought.amount = amount if not wolfpack.utilities.tobackpack(bought, player): bought.update() elif not stackable: if not wolfpack.utilities.tobackpack(bought, player): bought.update() # Create amount - 1 items for i in range(0, amount - 1): bought = wolfpack.additem(self.baseid) if not wolfpack.utilities.tobackpack(bought, player): bought.update()
def createKeys( plank1, plank2, hold, boat, player ): rkeyid = createkeysecret() packkey = wolfpack.additem('1010') packkey.settag('lock', rkeyid) packkey.name = "a ship key" packkey.settag('recall.link', boat.serial) tobackpack( packkey, player ) packkey.update() player.say( 502485, socket = player.socket ) # A ship's key is now in my backpack. bankkey = wolfpack.additem('1010') bankkey.settag('lock', rkeyid) bankkey.name = "a ship key" bankkey.settag('recall.link', boat.serial) tobankbox( bankkey, player ) player.say( 502484, socket = player.socket ) # A ship's key is now in my safety deposit box. # Plank Section plank1.settag('lock', rkeyid) plank1.addscript( 'lock' ) plank1.settag('locked',1) plank2.settag('lock', rkeyid) plank2.addscript( 'lock' ) plank2.settag('locked',1) # Hold Section hold.settag('lock', rkeyid) hold.addscript( 'lock' ) hold.settag('locked',1)
def giveAmmo( char, item ): # morex: Arrow count # morey: Bolt count boltCount = item.gettag( "bolt_count" ) arrowCount = item.gettag( "arrow_count" ) if not boltCount and not arrowCount: char.message( tr("The butte is empty.") ) return True if arrowCount: if arrowCount > 1: arrow = wolfpack.additem( "f3f" ) arrow.container = char.getbackpack() arrow.amount = arrowCount arrow.update() if boltCount: if boltCount > 1: bolt = wolfpack.additem( "1bfb" ) bolt.container = char.getbackpack() bolt.amount = boltCount bolt.update() #You gather the arrows and bolts. char.socket.clilocmessage(500592) # Reset the counters item.settag( "arrow_count", 0 ) item.settag( "bolt_count", 0 ) return 1
def sextant_parts( char, item ): if not char.checkskill( TINKERING, 0, 500 ): if random.randint( 1, 100 ) <= 25: additional = localemsg( 15 ) if item.amount > 1: item.amount -= 1 item.update() else: item.delete() else: additional = localemsg( 16 ) char.message( "%s%s" % ( localemsg( 14 ), additional ) ) else: if item.amount > 1: item.amount -= 1 item.update() else: item.delete() if item.id == 0x1059: item = wolfpack.additem( '1057' ) else: item = wolfpack.additem( '1058' ) char.getbackpack().additem( item, 1, 1, 0 ) item.update() char.message( localemsg( 17 ) ) return 1
def createItems(self, vendor, player, item, amount=1): if amount <= 0: return # Unable to comply backpack = player.getbackpack() # We will at the very least require one item, # so create that one here. bought = wolfpack.additem(self.baseid) stackable = bought.canstack( bought) # Check if bought could stack with bought if stackable: bought.amount = amount if not wolfpack.utilities.tobackpack(bought, player): bought.update() elif not stackable: if not wolfpack.utilities.tobackpack(bought, player): bought.update() # Create amount - 1 items for i in range(0, amount - 1): bought = wolfpack.additem(self.baseid) if not wolfpack.utilities.tobackpack(bought, player): bought.update()
def sextant_parts( char, item ): if not char.checkskill( TINKERING, 0, 500 ): if random.randint( 1, 100 ) <= 25: additional = tr(" and break the parts.") if item.amount > 1: item.amount -= 1 item.update() else: item.delete() else: additional = "." char.message( "%s%s" % ( tr("You fail to create the sextant"), additional ) ) else: if item.amount > 1: item.amount -= 1 item.update() else: item.delete() if item.id == 0x1059: item = wolfpack.additem( '1057' ) else: item = wolfpack.additem( '1058' ) char.getbackpack().additem( item, 1, 1, 0 ) item.update() char.message( tr("You put the sextant into your backpack") ) return 1
def giveAmmo(char, item): # morex: Arrow count # morey: Bolt count boltCount = item.gettag("bolt_count") arrowCount = item.gettag("arrow_count") if not boltCount and not arrowCount: char.message(tr("The butte is empty.")) return True if arrowCount: if arrowCount > 1: arrow = wolfpack.additem("f3f") arrow.container = char.getbackpack() arrow.amount = arrowCount arrow.update() if boltCount: if boltCount > 1: bolt = wolfpack.additem("1bfb") bolt.container = char.getbackpack() bolt.amount = boltCount bolt.update() #You gather the arrows and bolts. char.socket.clilocmessage(500592) # Reset the counters item.settag("arrow_count", 0) item.settag("bolt_count", 0) return 1
def foundation( char, target, width, height, multiid ): multi = wolfpack.multi( CUSTOMHOUSE ) char.socket.sysmessage( str( multi.serial ) ) multi.id = multiid + 0x4000 multi.decay = FALSE multi.moveto( target.pos ) left = width/2 right = left - ( width-1 ) bottom = height/2 top = bottom - ( height-1 ) #Draw floor for y in xrange( top+1,bottom+1 ): for x in xrange( right+1,left+1 ): if x == 0 and y == 0: multi.addchtile( 0x1, 0, 0, 0 ) multi.addchtile( 0x31f4, x, y, 7 ) #Draw corners multi.addchtile( 0x66, right, top, 0 ) multi.addchtile( 0x65, left, bottom, 0 ) #Draw sides for x in xrange( right+1,left+1 ): multi.addchtile( 0x63, x, top, 0 ) if x < left: multi.addchtile( 0x63, x, bottom, 0 ) for y in xrange( top+1, bottom+1 ): multi.addchtile( 0x64, right, y, 0 ) multi.addchtile( 0x64, left, y, 0 ) #Draw stairs for x in xrange( right+1,left+1 ): multi.addchtile( 0x0751, x, bottom+1, 0 ) multi.sendcustomhouse( char ) #woodenpost = wolfpack.additem( "9" ) signpost = wolfpack.additem( "b98" ) sign = wolfpack.additem( "bd2" ) #woodenpost.decay = FALSE signpost.decay = FALSE sign.decay = FALSE x = multi.pos.x + right y = multi.pos.y + bottom z = multi.pos.z + 7 map = multi.pos.map newpos = wolfpack.coord( x, y, z, map ) #woodenpost.moveto( newpos ) newpos.y += 1 signpost.moveto( newpos ) sign.moveto( newpos ) sign.settag( 'house', multi.serial ) sign.addscript( 'signpost' ) #woodenpost.update() signpost.update() sign.update()
def buildHouse(house, definition): node = wolfpack.getdefinition(WPDT_MULTI, definition) if not node: return if node.hasattribute('inherit'): value = str(node.getattribute('inherit')) buildHouse(house, value) # Recursion for i in range(0, node.childcount): child = node.getchild(i) # Inherit another definition if child.name == 'inherit': if child.hasattribute('id'): buildHouse(house, child.getattribute('id')) else: buildHouse(house, child.value) # Add a normal item to the house elif child.name == 'item': x = int(child.getattribute('x', '0')) y = int(child.getattribute('y', '0')) z = int(child.getattribute('z', '0')) id = str(child.getattribute('id', '')) item = wolfpack.additem(id) item.moveto(house.pos.x + x, house.pos.y + y, house.pos.z + z, house.pos.map) item.update() # Add a house door to the house elif child.name == 'door': x = int(child.getattribute('x', '0')) y = int(child.getattribute('y', '0')) z = int(child.getattribute('z', '0')) id = hex2dec(child.getattribute('id', '')) item = wolfpack.additem('housedoor') item.id = id item.moveto(house.pos.x + x, house.pos.y + y, house.pos.z + z, house.pos.map) item.update() # Add a sign to the house elif child.name == 'sign': x = int(child.getattribute('x', '0')) y = int(child.getattribute('y', '0')) z = int(child.getattribute('z', '0')) sign = wolfpack.additem('housesign') if child.hasattribute('id'): sign.id = hex2dec(child.getattribute('id', '')) sign.moveto(house.pos.x + x, house.pos.y + y, house.pos.z + z, house.pos.map) sign.update()
def response( char, args, target ): direction = char.directionto( target.pos ) if char.direction != direction: char.direction = direction char.update() item = wolfpack.finditem( args[0] ) # What we want to cook id = item.id if not item or item.getoutmostchar() != char: char.socket.clilocmessage( 0x7ACA2 ) # That belongs to someone else. return 1 # Are we too far away from the target ? if ( ( char.pos.x-target.pos.x )**2 + ( char.pos.y-target.pos.y )**2 > 4): char.socket.clilocmessage( 0x7A247 ) # You are too far away to do that. return 1 if abs( char.pos.z - target.pos.z ) > 5: char.socket.clilocmessage( 0x7A247 ) # You are too far away to do that. return 1 # We can only cook on dynamic ovens/fireplaces if not target.item or not target.item.id in ids_heat: char.socket.clilocmessage( 0x7A3D2 ) # You can't cook on that. return 1 # We're cooking one by one if item.amount > 1: item.amount -= 1 item.update() else: item.delete() # Succeess ? if char.checkskill( COOKING, 0, 1000 ): item = wolfpack.additem( ids[ id ][0] ) if not wolfpack.utilities.tobackpack( item, char ): item.update() char.socket.clilocmessage( random.choice( [ 0x7A3CF, 0x7A3D0 ] ) ) # Either "Looks delicious." or "Mmmm, smells good." char.socket.clilocmessage( 0x7A3D1 ) # You put the cooked food into your backpack. else: burned_id = ids[ id ][1] if burned_id != "": burned = wolfpack.additem( burned_id ) if not wolfpack.utilities.tobackpack( burned, char ): burned.update() char.socket.clilocmessage( 0x7A3CE ) # You burn the food to a crisp! It's ruined.
def carve_corpse( char, corpse ): if corpse.container: char.socket.sysmessage( "You can't carve corpses in a container" ) return if not char.canreach(corpse, 3): char.socket.clilocmessage( 0x7A258, "", 0x3b2, 3, corpse ) # You cannot reach that return # Human Bodies can always be carved if corpse.bodyid == 0x190 or corpse.bodyid == 0x191: char.message( "You can't carve a human body right now" ) return # Not carvable or already carved try: charbase = wolfpack.charbase(corpse.charbaseid) carve = charbase['carve'] except: char.socket.clilocmessage( 0x7A305, "", 0x3b2, 3, corpse ) # You see nothing useful to carve.. return if corpse.hastag('carved') or carve == '': char.socket.clilocmessage( 0x7A305, "", 0x3b2, 3, corpse ) # You see nothing useful to carve.. return # Create all items in the carve list carve = wolfpack.list(str(carve)) for id in carve: amount = 1 # Is amount contained in it ? if id.find( "," ) != -1: parts = id.split( "," ) id = parts[0] amount = int( parts[1] ) item = wolfpack.additem( id ) item.amount = amount if not utilities.tocontainer( item, corpse ): item.update() # Create Random Blood bloodid = whrandom.choice( blood ) blooditem = wolfpack.additem( bloodid ) blooditem.moveto( corpse.pos ) blooditem.decay = 1 blooditem.update() char.socket.clilocmessage( 0x7A2F3, "", 0x3b2, 3, corpse ) # You carve away some meat which remains on the corpse corpse.settag('carved', 1)
def carve_meat( char, corpse, tool, meat_type, meat ): if meat_type == 'bird': item = wolfpack.additem('9b9') # Raw Bird elif meat_type == 'lambleg': item = wolfpack.additem('1609') # Raw Lamb Leg elif meat_type == 'fishsteak': item = wolfpack.additem('97a') # Raw Fish Steak else: item = wolfpack.additem('9f1') # Raw Ribs item.amount = meat if not wolfpack.utilities.tocontainer(item, corpse): item.update() char.socket.clilocmessage( 500467, "", 0x3b2, 3 ) # You carve some meat, which remains on the corpse.
def carve_hides( char, corpse, tool, hides_type, hides ): if hides_type == 'spined': item = wolfpack.additem('spined_leather_hides') elif hides_type == 'horned': item = wolfpack.additem('horned_leather_hides') elif hides_type == 'barbed': item = wolfpack.additem('barbed_leather_hides') else: item = wolfpack.additem('leather_hides') item.amount = hides if not wolfpack.utilities.tocontainer(item, corpse): item.update() char.socket.clilocmessage( 500471, "", 0x3b2, 3 ) # You skin it, and the hides are now in the corpse.
def successmining(char, gem, resname, size): if not char: return False if skills.skilltable[MINING][skills.UNHIDE] and char.hidden: char.removefromview() char.hidden = False char.update() # Create the ore and put it into the players backpack if size == 1: item = wolfpack.additem("19b7") elif size == 2: item = wolfpack.additem(random.choice(["19b8", "19ba"])) elif size == 3: item = wolfpack.additem("19b9") else: raise RuntimeException, "Invalid ore size: %u" % size item.settag("resname", resname) item.color = ORES[resname][COLORID] if FELUCIA2XRESGAIN and char.pos.map == 0: item.amount = 2 else: item.amount = 1 if not tobackpack(item, char): item.update() # Resend weight char.socket.resendstatus() resourcecount = max(1, int(gem.gettag("resourcecount"))) gem.settag("resourcecount", resourcecount - 1) # Start respawning the ore if not gem.hastag("resource_empty") and resourcecount <= 1: delay = random.randint(MINING_REFILLTIME[0], MINING_REFILLTIME[1]) gem.addtimer(delay, "skills.mining.respawnvein", [], True) gem.settag("resource_empty", 1) message = ORES[resname][SUCCESSMESSAGE] # You dig some %s and put it in your backpack. if type(message) == int: char.socket.clilocmessage(message, "", GRAY) else: char.socket.sysmessage(unicode(message)) return True
def checknpcforquestloot(player, dead, corpse): for i in range(1, 11): # Checking if player have this Quest if player.hastag('Quest.'+ str(i) +'.ID'): # # Check if this NPC is one of targets # id = player.gettag('Quest.'+ str(i) +'.ID') # Get ID of this Quest npclist = givequestitemloots(id) # Get the List of NPCs that Drop items for j in range( 0, len(npclist) ): # Oh! Is this the NPC? if dead.baseid == npclist[j]: # Lets Check the Region npcregions = givequestitemlootsregions(id) if len(npcregions): if npcregions[j]: if not npcregions[j] == dead.region.name: return eachamount = givequestitemeachamount(id) # Amount for each Item for this Quest itemsquest = givequestitemtargets(id) # Items for this quest actualamount = player.getbackpack().countitems([itemsquest[j]]) # Actual amount of this item if int(actualamount) < int(eachamount[j]): # Lets create this item on Corpse newitem = wolfpack.additem(itemsquest[j]) corpse.additem(newitem)
def GetYarn( char, wheel, color ): # End the animations. if wheel.id == animids[0]: wheel.id = ids[0] wheel.update() elif wheel.id == animids[1]: wheel.id = ids[1] wheel.update() elif wheel.id == animids[2]: wheel.id = ids[2] wheel.update() elif wheel.id == animids[3]: wheel.id = ids[3] wheel.update() item_new = wolfpack.additem( 'e1d' ) # Yarn balls item_new.amount = 3 item_new.color = color if not wolfpack.utilities.tocontainer( item_new, char.getbackpack() ): item_new.update() if item_new.amount > 1: # You put the balls of yarn in your backpack. char.socket.clilocmessage( 1010576, '', GRAY ) else: # You put a ball of yarn in your backpack. char.socket.clilocmessage( 1010574, '', GRAY ) return True
def cow(char, player, amount): # List with id of empty pitcher pitcher_list = [0x9a7, 0xff6, 0xff7] found = 0 for pitcher in pitcher_list: foundn = player.countresource(pitcher) found += foundn if not found: player.socket.sysmessage(tr("You need something you can fill the milk in.")) return False player.soundeffect(0x30) if found < amount: amount = found amount_down = amount for pitcher in pitcher_list: # consume as many pitchers as needed if amount_down > 0: if player.useresource(amount, pitcher): amount_down -= 1 else: break # add as many pitchers as consumed (item.amount not possible, because not generic) for i in range(0, amount): milk = wolfpack.additem("9ad") if not wolfpack.utilities.tobackpack( milk, player ): milk.update() char.settag( "resourcecount", char.gettag("resourcecount") - amount) player.socket.sysmessage(tr("You melk the cow and fill the milk in an empty pitcher.")) return
def tileResponse(player, arguments, target): if len(arguments) < 3: player.socket.sysmessage('Please select the second corner.') player.socket.attachtarget("commands.tile.tileResponse", list(arguments) + [target.pos]) return x1 = min(arguments[2].x, target.pos.x) x2 = max(arguments[2].x, target.pos.x) y1 = min(arguments[2].y, target.pos.y) y2 = max(arguments[2].y, target.pos.y) z = arguments[0] ids = arguments[1] unlimited = player.account.authorized('Misc', 'Unlimited Tile') count = ((x2 - x1) + 1) * ((y2 - y1) + 1) # Cap at 500 items if not an admin is using it if not unlimited and count > 250: player.socket.sysmessage('You are not allowed to tile more than 250 items at once.') return player.log(LOG_MESSAGE, "Tiling %u items (%s) from %u,%u to %u,%u at z=%d.\n" % (count, ", ".join(ids), x1, y1, x2, y2, z)) player.socket.sysmessage('Creating %u items from %u,%u to %u,%u at z=%d.' % (count, x1, y1, x2, y2, z)) pos = player.pos pos.z = z for x in range(x1, x2 + 1): for y in range(y1, y2 + 1): pos.x = x pos.y = y item = wolfpack.additem(random.choice(ids)) item.moveto(pos) item.decay = 0 item.update()
def furrowsCallback(player, args): (pos, stroke) = args if stroke == 0: pos.soundeffect(0x106) pos.effect(0x3735, 1, 182) player.addtimer(4000, furrowsCallback, [pos, 1]) elif stroke == 1: pos.soundeffect(0x222) player.addtimer(4000, furrowsCallback, [pos, 2]) elif stroke == 2: pos.soundeffect(0x21f) player.addtimer(4000, furrowsCallback, [pos, 3]) elif stroke == 3: dummy = wolfpack.additem('1') dummy.name = 'Swamp' dummy.moveto(pos) dummy.update() dummy.say( tr("* A magical bunny leaps out of its hole, disturbed by the thorn's effect! *" )) wolfpack.addtimer(20000, deleteCallback, [dummy.serial], True) # Spawn one giant ice worm and three ice snakes npc = wolfpack.addnpc('vorpal_bunny', pos) if not spawnNpc(pos, npc): npc.delete() else: npc.update() # Start timer to dig away npc.addtimer(3 * 60 * 1000, vorpalbunny_dig, [], True)
def swampCallback(player, args): (pos, stroke) = args if stroke == 0: pos.soundeffect(0x106) pos.effect(0x3735, 1, 182) player.addtimer(4000, swampCallback, [pos, 1]) elif stroke == 1: pos.soundeffect(0x222) player.addtimer(4000, swampCallback, [pos, 2]) elif stroke == 2: pos.soundeffect(0x21f) player.addtimer(1000, swampCallback, [pos, 3]) elif stroke == 3: dummy = wolfpack.additem('1') dummy.name = 'Swamp' dummy.moveto(pos) dummy.update() dummy.say( tr("* Strange green tendrils rise from the ground, whipping wildly! *" )) wolfpack.addtimer(20000, deleteCallback, [dummy.serial], True) pos.soundeffect(0x2b0) # Spawn one giant ice worm and three ice snakes npc = wolfpack.addnpc('whipping_vine', pos) if not spawnNpc(pos, npc): npc.delete() else: npc.update()
def SweetDough(char, args, target): dough = wolfpack.finditem(args[0]) if not dough or not target.item: return False if not target.item.getoutmostchar() == char: char.socket.clilocmessage( 1042001) # That must be in your pack for you to use it. return True backpack = char.getbackpack() # Bowl Flour if target.item.baseid == "a1e": target.item.delete() cake_mix = wolfpack.additem("cake_mix") if not tobackpack(cake_mix, char): cake_mix.update() # Campfire elif target.item.baseid == "de3": char.soundeffect(0x225) char.addtimer(5000, delay_campfire, [target.item.serial]) else: return False dough.delete()
def GetThread( char, wheel, color ): # End the animations. if wheel.id == animids[0]: wheel.id = ids[0] wheel.update() elif wheel.id == animids[1]: wheel.id = ids[1] wheel.update() elif wheel.id == animids[2]: wheel.id = ids[2] wheel.update() elif wheel.id == animids[3]: wheel.id = ids[3] wheel.update() item_new = wolfpack.additem( 'fa0' ) # Spools of Thread item_new.amount = 6 item_new.color = color if not wolfpack.utilities.tocontainer( item_new, char.getbackpack() ): item_new.update() if item_new.amount > 1: # You put the spools of thread in your backpack. char.socket.clilocmessage( 1010577, '', GRAY ) else: # You put a spool of thread in your backpack. char.socket.clilocmessage( 1010575, '', GRAY ) return True
def stroke(player, arguments): (source, count) = arguments if player.dead or player.pos.map == 0xff: end(player, False) # End bleeding if dead, but dont message else: amount = random.randint(count, count * 2) if player.npc: amount *= 2 player.soundeffect(0x133) player.damage(DAMAGE_GODLY, amount, wolfpack.findchar(source)) if player.pos.map != 0xff: blood = wolfpack.additem(random.choice(BLOOD)) blood.movable = 3 # Not movable blood.decay = True # Make it decay blood.moveto(player.pos) blood.update() # There are still strokes left if count > 1 and not player.dead and player.pos.map != 0xff: player.addtimer(TIMERINTERVAL, stroke, [source, count - 1], False, False, TIMERID) else: end(player)
def peartree(char, item): pear = wolfpack.additem("994") if not wolfpack.utilities.tobackpack( pear, char ): pear.update() char.soundeffect(0x57) item.settag( "resourcecount", item.gettag("resourcecount") - 1) return True
def completequest(player, slot, id, npc): # # Lets Call Assignment Function # completefunc = givequestcompletefunction(id) if completefunc: if completefunc(player, npc): return # Get Backpack backpack = player.getbackpack() # Let's delete the tags player.deltag('Quest.'+ str(slot) +'.ID') player.deltag('Quest.'+ str(slot) +'.NPCDest') player.deltag('Quest.'+ str(slot) +'.ReqNPC') # Let's Consume required items itemtargets = givequestitemtargets(id) itemamount = len(itemtargets) eachitemamount = givequestitemeachamount(id) if itemamount: for i in range( 0, itemamount ): # Checking if we have less Items than necessay backpack = player.getbackpack() itemcount = backpack.countitems( [itemtargets[i]] ) backpack.removeitems( [itemtargets[i]], int(eachitemamount[i]) ) # Now, rewards time. First, lists. After, amount of rewards rewards = givequestrewards(id) rewardamounts = givequesteachrewardsamount(id) amountofrewards = len(rewards) # Lets see if reward is not an empty list if amountofrewards: # Loop giving the amounts for i in range( 0, amountofrewards ): # Add item, set amount, send to backpack item = wolfpack.additem( rewards[i] ) item.amount = int(rewardamounts[i]) backpack.additem( item ) item.update() # Lets save this Quest in a Tag to player never try this again with same character tagsection = int ( id / MAXQUESTSPERTAG ) if player.hastag('quest.'+ str(tagsection) +'.complete'): quests = str(player.gettag('quest.'+ str(tagsection) +'.complete')) quests += ',' + str(id) player.settag('quest.'+ str(tagsection) +'.complete', quests) else: player.settag('quest.'+ str(tagsection) +'.complete', id)
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
def appletree(char, item): apple = wolfpack.additem("9d0") if not wolfpack.utilities.tobackpack( apple, char ): apple.update() char.soundeffect(0x57) item.settag( "resourcecount", item.gettag("resourcecount") - 1) return True
def Unload(player, belt): belt_rem_uses = 0 belt_poison = -1 belt_pC = 0 if belt.hastag('poisoning_strength'): belt_poison = belt.gettag('poisoning_strength') if belt.hastag('poisoning_uses'): belt_pC = belt.gettag('poisoning_uses') if belt.hastag('remaining_uses'): belt_rem_uses = belt.gettag('remaining_uses') if belt_rem_uses < 1: return backpack = player.getbackpack() shuriken = wolfpack.additem('27ac') shuriken.settag('poisoning_strength', belt_poison) shuriken.settag('poisoning_uses', belt_pC) shuriken.amount = belt_rem_uses shuriken.settag('remaining_uses', belt_rem_uses) backpack.additem(shuriken) shuriken.update() belt.settag('remaining_uses', 0) belt.settag('poisoning_uses', 0) belt.settag('poisoning_strength', -1) belt.resendtooltip()
def smelt(self, player, arguments, target): if not checkanvilandforge(player): player.socket.clilocmessage(1042678) return tool = wolfpack.finditem(arguments[0]) if not checktool(player, tool): return if tool == target.item: player.socket.clilocmessage(1044271) return # Smelt a weapon item = target.item weapon = itemcheck(item, ITEM_WEAPON) shield = itemcheck(item, ITEM_SHIELD) armor = itemcheck(item, ITEM_ARMOR) # See if it's in our ore list. if weapon or shield or armor: if item.container != player.getbackpack(): player.socket.clilocmessage(1044274) return if item.hastag('resname'): resname = str(item.gettag('resname')) else: resname = None for metal in METALS: if metal[5] == resname: # Try to find out how many ingots this item would need menu = findmenu('BLACKSMITHING') action = menu.findcraftitem(item.baseid) returned = 0.25 + min(1000, player.skill[MINING]) / 2000 if action and action.submaterial1 > 0: amount = int(math.floor(action.submaterial1 * returned)) else: amount = 1 if amount > 0: # Randomly select one of the resources required by that metal item.delete() ingots = wolfpack.additem(random.choice(metal[3])) ingots.amount = amount if not tobackpack(ingots, player): ingots.update() player.soundeffect(0x2a) player.soundeffect(0x240) player.socket.clilocmessage(1044270) self.send(player, arguments) return player.socket.clilocmessage(1044272) self.send(player, arguments)
def createkey(char, id): keys = ['100e', '100f', '1010', '1013'] key = wolfpack.additem(random.choice(keys)) key.settag('lock', id) key.container = char.getbackpack() key.update() char.socket.sysmessage(tr('A key has been added to your backpack.'))
def completequest(player, slot, id, npc): # # Lets Call Assignment Function # completefunc = givequestcompletefunction(id) if completefunc: if completefunc(player, npc): return # Get Backpack backpack = player.getbackpack() # Let's delete the tags player.deltag('Quest.' + str(slot) + '.ID') player.deltag('Quest.' + str(slot) + '.NPCDest') player.deltag('Quest.' + str(slot) + '.ReqNPC') # Let's Consume required items itemtargets = givequestitemtargets(id) itemamount = len(itemtargets) eachitemamount = givequestitemeachamount(id) if itemamount: for i in range(0, itemamount): # Checking if we have less Items than necessay backpack = player.getbackpack() itemcount = backpack.countitems([itemtargets[i]]) backpack.removeitems([itemtargets[i]], int(eachitemamount[i])) # Now, rewards time. First, lists. After, amount of rewards rewards = givequestrewards(id) rewardamounts = givequesteachrewardsamount(id) amountofrewards = len(rewards) # Lets see if reward is not an empty list if amountofrewards: # Loop giving the amounts for i in range(0, amountofrewards): # Add item, set amount, send to backpack item = wolfpack.additem(rewards[i]) item.amount = int(rewardamounts[i]) backpack.additem(item) item.update() # Lets save this Quest in a Tag to player never try this again with same character tagsection = int(id / MAXQUESTSPERTAG) if player.hastag('quest.' + str(tagsection) + '.complete'): quests = str(player.gettag('quest.' + str(tagsection) + '.complete')) quests += ',' + str(id) player.settag('quest.' + str(tagsection) + '.complete', quests) else: player.settag('quest.' + str(tagsection) + '.complete', id)
def onUse(player, object): socket = player.socket leaves = None leaves = wolfpack.finditem(object.gettag('leaf_serial')) leaves.pos = "%i,%i,%i,%i" % (object.pos.x, object.pos.y, object.pos.z, object.pos.map) if leaves.pos != object.pos: leaves.moveto(object.pos) #leaves.visible = 0 leaves.update() if leaves.hastag('fruit_count') and leaves.hastag('fruit_type'): if int(leaves.gettag('fruit_count')) > 0: socket.sysmessage('You pick some fruit from the tree.') leaves.settag('fruit_count', int(int(leaves.gettag('fruit_count')) - 1)) fruit = leaves.gettag('fruit_type') # Create the fruit if fruit == 'apple': item = wolfpack.additem('9d0') else: item = None if item: if not wolfpack.utilities.tocontainer(item, player.getbackpack()): item.update() if int(leaves.gettag('fruit_count')) == 0: leaves.settag("picked", 1) leaves.id -= 1 leaves.update() else: socket.sysmessage('This tree has no fruit to gather.') return True
def polymorph_expire(char, arguments): # Remove all timers from this char char.dispel(None, True, 'POLYMORPH_EXPIRE') # Hidden beard? if char.hastag('polymorph_beard_id'): current = char.itemonlayer(LAYER_BEARD) if current: current.delete() newid = char.gettag('polymorph_beard_id') color = 0 if char.hastag('polymorph_beard_color'): color = int(char.gettag('polymorph_beard_color')) item = wolfpack.additem(newid) item.color = color char.additem(LAYER_BEARD, item) item.update() char.deltag('polymorph_beard_id') char.deltag('polymorph_beard_color') char.id = char.orgid char.skin = char.orgskin char.polymorph = 0 char.update()
def grapevines(char, item): grape = wolfpack.additem("9d1") if not wolfpack.utilities.tobackpack( grape, char ): grape.update() char.soundeffect(0x57) item.settag( "resourcecount", item.gettag("resourcecount") - 1) return True
def response(player, arguments, response): plant = wolfpack.finditem(arguments[0]) if response.button == 0 or not plant or plants.plant.getStatus(plant) >= STATUS_DECORATIVE or not player.canreach(plant, 3): return # Cancel if not plants.plant.checkAccess(player, plant): plant.say(1061856, '', '', False, 0x3b2, player.socket) return # Cancel if response.button == 1: plants.maingump.send(player, plant) # Help elif response.button == 2: send(player, plant) plants.sendCodexOfWisdom(player.socket, 71) # Ok elif response.button == 3: bowl = wolfpack.additem(plants.bowl.BOWL_BASEID) # Create an empty bowl if not wolfpack.utilities.tobackpack(bowl, player): bowl.update() status = plants.plant.getStatus(plant) # Create a seed if we have one if status > STATUS_DIRT and status < STATUS_PLANT: seed = plants.seed.create(plants.plant.getGenus(plant), plants.plant.getHue(plant), plants.plant.getShowType(plant)) if not wolfpack.utilities.tobackpack(seed, player): seed.update() plant.delete() # Delete the plant
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
def onUse ( char, item ): bank = char.getbankbox() if not item.getoutmostitem() == bank: char.socket.clilocmessage( 0xFF9F2, "", 0x3b2, 3 ) # That must be in your bankbox to use it. return True if not item.hastag ( "filled" ): char.socket.clilocmessage( 0xFF9F5, "", 0x3b2, 3 ) char.socket.attachtarget( "deeds.commoditydeed.response", [item.serial] ) return True amount = item.gettag( "amount" ) commodity = item.gettag( "commodity" ) color = item.gettag( "color" ) cname = item.gettag( "cname" ) redeemitem = wolfpack.additem( "%s" %commodity ) redeemitem.name = item.gettag( "cname" ) redeemitem.amount = item.gettag( "amount" ) redeemitem.color = item.gettag( "color" ) redeemitem.container = bank item.delete() char.socket.sendcontainer( bank ) char.socket.clilocmessage( 0xFF9F7, "", 0x3b2, 3 ) return True
def createkey(char, id): keys = ['100e', '100f', '1010', '1013'] key = wolfpack.additem(random.choice(keys)) key.settag('lock', id) key.container = char.getbackpack() key.update() char.socket.sysmessage('A key has been added to your backpack.')
def createsandgem(pos): gem = wolfpack.additem('sand_gem') gem.settag('resourcecount', random.randint(MINING_SAND[0], MINING_SAND[1])) # 6 - 13 ore gem.moveto(pos) gem.visible = 0 gem.update() return gem