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 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 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 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 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 hit(attacker, defender, weapon, time): combat.utilities.playhitsound(attacker, defender) (mindamage, maxdamage) = properties.getdamage(attacker) damage = random.randint(mindamage, maxdamage) damage = scaledamage(attacker, damage) # Give the defender a chance to absorb damage damage = absorbdamage(defender, damage) # Get the damage distribution of the attackers weapon (physical, fire, cold, poison, energy) = damagetypes(attacker) energydamage(defender, attacker, damage, physical, fire, cold, poison, energy, 0, DAMAGE_PHYSICAL) # Wear out the weapon if weapon: # poisoning if weapon.hastag( 'poisoning_uses' ): poisoning.hitEffect( defender, weapon ) # 4% chance for losing one hitpoint if 0.04 >= random.random(): if weapon.health > 0: weapon.health -= 1 weapon.resendtooltip() if weapon.health <= 0: tobackpack(weapon, attacker) weapon.update() if attacker.socket: attacker.socket.clilocmessage(500645)
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 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 response(player, arguments, response): if response.button == 0: return command = (response.button >> 28) & 0xC item = wolfpack.finditem((response.button & 0x3FFFFFFF) | 0x40000000) target = item.container # Delete Item if command == 0x04: player.log(LOG_MESSAGE, 'Deleting item 0x%x from character 0x%x.\n' % (item.serial, item.container.serial)) item.delete() showEditGump(player, target) # Bounce Item elif command == 0x08: player.log(LOG_MESSAGE, 'Bouncing item 0x%x from character 0x%x.\n' % (item.serial, item.container.serial)) if not tobackpack(item, player): item.update() showEditGump(player, target) # Show Info For Item elif command == 0x0C: player.log(LOG_MESSAGE, 'Showing info gump for item 0x%x from character 0x%x.\n' % (item.serial, item.container.serial)) iteminfo(player.socket, item) else: player.socket.sysmessage('Unknown command.')
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 fireweapon(attacker, defender, weapon): ammo = properties.fromitem(weapon, AMMUNITION) # Only consume ammo if this weapon requires it if len(ammo) != 0: if not consumeresources(attacker.getbackpack(), ammo, 1): if attacker.socket: attacker.socket.sysmessage('You are out of ammo.') if attacker.npc: tobackpack(weapon, attacker) return False if random.random() >= 0.50: if defender.player: item = wolfpack.additem(ammo) if not tobackpack(item, defender): item.update() else: # Search for items at the same position items = wolfpack.items(defender.pos.x, defender.pos.y, defender.pos.map) handled = 0 for item in items: if item.baseid == ammo: item.amount += 1 item.update() handled = 1 break if not handled: item = wolfpack.additem(ammo) item.moveto(defender.pos) item.update() projectile = properties.fromitem(weapon, PROJECTILE) # Fire a projectile if applicable. if projectile: hue = properties.fromitem(weapon, PROJECTILEHUE) attacker.movingeffect(projectile, defender, 0, 0, 14, hue) return True
def smelt(self, player, arguments, target): if not self.checktool(player, wolfpack.finditem(arguments[0])): return False tool = wolfpack.finditem(arguments[0]) 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 action = self.topmostmenu().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 make(self, player, arguments, nodelay=0): item = wolfpack.additem(self.definition) if not item: console.log(LOG_ERROR, "Unknown item definition used in action %u of menu %s.\n" % \ (self.parent.subactions.index(self), self.parent.id)) else: if self.amount > 0: item.amount = self.amount if not tobackpack(item, player): item.update() player.socket.sysmessage('You put the new item into your backpack.') MakeAction.make(self, player, arguments, nodelay)
def onDropOnChar(char, item): # See if it's not hostile if char.npc and char.id < 0x190: player = item.container if not char.tamed: return 0 if not player.canreach(char, 2): player.socket.clilocmessage(500312) if not tobackpack( item, player ): item.update() return 1 if char.hunger >= 6: player.message('They don''t seem to be hungry.') if not tobackpack( item, player ): item.update() return 1 if item.amount > 6 - char.hunger: item.amount -= 6 - char.hunger char.hunger = 6 if not tobackpack(item, player): item.update() item.resendtooltip() else: char.hunger += item.amount item.delete() # Fidget animation and munch munch sound char.soundeffect( random.choice([0x03a, 0x03b, 0x03c]), 1 ) if not char.itemonlayer( LAYER_MOUNT ): char.action(ANIM_FIDGET3) return 1 #char.say('Dropped item on char') return 0
def fireweapon(attacker, defender, weapon): ammo = properties.fromitem(weapon, AMMUNITION) # Only consume ammo if this weapon requires it if len(ammo) != 0: if not consumeresources(attacker.getbackpack(), ammo, 1): if attacker.socket: attacker.socket.sysmessage(tr('You are out of ammo.')) if attacker.npc: tobackpack(weapon, attacker) return False # The ammo is created and packed into the defenders backpack/put on the ground createammo(defender, ammo) projectile = properties.fromitem(weapon, PROJECTILE) # Fire a projectile if applicable. if projectile: hue = properties.fromitem(weapon, PROJECTILEHUE) attacker.movingeffect(projectile, defender, 0, 0, 14, hue) return True
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 poisonit( char, args ): potion = args[ 0 ] item = args[ 1 ] if not potion or not item: return skill = char.skill[ POISONING ] # poison strength : lesser(1), normal, greater, deadly(4) strength = int( potion.gettag( 'potiontype' ) ) - 13 # consume the potion / add a blank bottle potion.delete() bottle = wolfpack.additem( 'f0e' ) if not tobackpack( bottle, char ): bottle.moveto( char.pos.x, char.pos.y, char.pos.z, char.pos.map ) bottle.update() # FIXME : success / fail chance if skill < ( strength + 0.8 ) * 200: # failed to poison item char.socket.clilocmessage( 1010518 ) return 1 # check skill advance char.checkskill( POISONING, 0, 1000 ) # FIXME : less / strong chance if random.randint( 0, 20 ) > ( skill - strength * 200 ): strength = strength - 1 if strength < 1: # failed to poison char.socket.clilocmessage( 502148 ) return 1 char.socket.clilocmessage( 1010518 ) else: char.socket.clilocmessage( 1010517 ) # decrease karma / fame # set poisoning infos as tags item.settag( 'poisoning_char', char.serial ) item.settag( 'poisoning_strength', strength ) item.settag( 'poisoning_skill', skill ) # weapon : poison chance when hit % = char.skill[ POISONING ] / 4 # number of uses before the poison wears off if item.hasscript( 'blades' ): item.settag( 'poisoning_uses', 20 - strength * 2 ) return 1
def make(self, player, arguments, nodelay=0): item = wolfpack.additem(self.definition) if not item: console.log( LOG_ERROR, "Unknown item definition used in action %u of menu %s.\n" % (self.parent.subactions.index(self), self.parent.id), ) else: if self.amount > 0: item.amount = self.amount if not tobackpack(item, player): item.update() player.socket.clilocmessage(500442) CraftAction.make(self, player, arguments, nodelay)
def checkweapon(self, char): weapon = char.itemonlayer(LAYER_RIGHTHAND) if not weapon or not properties.itemcheck(weapon, ITEM_WEAPON): weapon = char.itemonlayer(LAYER_LEFTHAND) if not weapon: return True # Check if the spellchanneling property is true for this item if not properties.fromitem(weapon, SPELLCHANNELING): if not utilities.tobackpack(weapon, char): weapon.update() return True else: return True
def hit(self, attacker, defender, damage): if not self.checkuse(attacker): return # Clear Ability, then check if it really can be used clearability(attacker) if defender.dead or defender.pos.map == 0xFF: return # Out of reach weapon = defender.getweapon() # Doesnt have a weapon to disarm if not weapon: if attacker.socket: attacker.socket.clilocmessage(1060849) # Already unarmed ... # The weapon is immovable elif weapon.lockeddown or weapon.movable > 1: if attacker.socket: attacker.socket.clilocmessage(1004001) # You cannot disarm ... else: self.use(attacker) if attacker.socket: attacker.socket.clilocmessage( 1060092) # You disarm their weapon! if defender.socket: defender.socket.clilocmessage( 1060093) # Your weapon has been disarmed! defender.soundeffect(0x3b9) defender.effect(0x37be, 232, 25) layer = weapon.layer # Save the weapon layer if not tobackpack(weapon, defender): # Unequip the weapon weapon.update() # Players cannot equip another weapon for 5000 ms if defender.socket: defender.socket.settag('block_equip', wolfpack.time.currenttime() + 5000) elif defender.npc: defender.addtimer(random.randint(5000, 7500), reequip_weapon, [weapon.serial, layer], True)
def delay_campfire(char, args): campfire = wolfpack.finditem(args[0]) if not char.socket or not campfire: return False # if ( m_From.GetDistanceToSqrt( m_Campfire ) > 3 ): # char.socket.clilocmessage( 500686 ) # You burn the food to a crisp! It's ruined. # return if char.checkskill(COOKING, 0, 100): muffins = wolfpack.additem("9eb") if not tobackpack(muffins, char): muffins.update() char.soundeffect(0x57) else: char.socket.clilocmessage(500686) # You burn the food to a crisp! It's ruined. return True
def delay_campfire(char, args): campfire = wolfpack.finditem(args[0]) if not char.socket or not campfire: return False #if ( m_From.GetDistanceToSqrt( m_Campfire ) > 3 ): # char.socket.clilocmessage( 500686 ) # You burn the food to a crisp! It's ruined. # return if char.checkskill(COOKING, 0, 100): muffins = wolfpack.additem("9eb") if not tobackpack(muffins, char): muffins.update() char.soundeffect(0x57) else: char.socket.clilocmessage( 500686) # You burn the food to a crisp! It's ruined. return True
def successsandmining(char, gem): sand = wolfpack.additem("sand") if not tobackpack(sand, char): sand.update() # Resend weight char.socket.resendstatus() resourcecount = max( 1, int( gem.gettag('resourcecount') ) ) gem.settag('resourcecount', resourcecount - 1) # Start respawning the sand if not gem.hastag('resource_empty') and resourcecount <= 1: delay = random.randint(MINING_REFILLTIME[0], MINING_REFILLTIME[1]) gem.addtimer( delay, respawnvein, [], True ) gem.settag( 'resource_empty', 1 ) char.socket.clilocmessage(1044631) # You carefully dig up sand of sufficient quality for glassblowing.
def cast(self, char, mode, args=[], target=None, item=None): if not self.consumerequirements(char, mode, args, target, item): return # Randomly select one id of food foodinfo = [["9d1", "a grape bunch"], ["9d2", "a peach"], ["9c9", "a ham"], ["97c", "a wedge of cheese"], ["9eb", "muffins"], ["9f2", "cut of ribs"], ["97b", "a fish steak"], ["9b7", "a cooked bird"]] food = random.choice(foodinfo) item = wolfpack.additem(food[0]) foodname = " " + food[1] if not tobackpack(item, char): item.update() if char.socket: char.socket.clilocmessage(1042695, "", 0x3b2, 3, None, foodname) char.soundeffect(0x1e2)
def hit(self, attacker, defender, damage): if not self.checkuse(attacker): return # Clear Ability, then check if it really can be used clearability(attacker) if defender.dead or defender.pos.map == 0xFF: return # Out of reach weapon = defender.getweapon() # Doesnt have a weapon to disarm if not weapon: if attacker.socket: attacker.socket.clilocmessage(1060849) # Already unarmed ... # The weapon is immovable elif weapon.lockeddown or weapon.movable > 1: if attacker.socket: attacker.socket.clilocmessage(1004001) # You cannot disarm ... else: self.use(attacker) if attacker.socket: attacker.socket.clilocmessage(1060092) # You disarm their weapon! if defender.socket: defender.socket.clilocmessage(1060093) # Your weapon has been disarmed! defender.soundeffect(0x3B9) defender.effect(0x37BE, 232, 25) layer = weapon.layer # Save the weapon layer if not tobackpack(weapon, defender): # Unequip the weapon weapon.update() # Players cannot equip another weapon for 5000 ms if defender.socket: defender.socket.settag("block_equip", wolfpack.currenttime() + 5000) elif defender.npc: defender.addtimer(random.randint(5000, 7500), reequip_weapon, [weapon.serial, layer], True)
def response(player, arguments, response): if response.button == 0: return command = (response.button >> 28) & 0xC item = wolfpack.finditem((response.button & 0x3FFFFFFF) | 0x40000000) if not item: return target = arguments[0] # Delete Item if command == 0x04: player.log( LOG_MESSAGE, 'Deleting item 0x%x from character 0x%x.\n' % (item.serial, item.container.serial)) item.delete() showEditGump(player, target) # Bounce Item elif command == 0x08: player.log( LOG_MESSAGE, 'Bouncing item 0x%x from character 0x%x.\n' % (item.serial, item.container.serial)) if not tobackpack(item, player): item.update() showEditGump(player, target) # Show Info For Item elif command == 0x0C: player.log( LOG_MESSAGE, 'Showing info gump for item 0x%x from character 0x%x.\n' % (item.serial, item.container.serial)) iteminfo(player.socket, item) else: player.socket.sysmessage('Unknown command.')
def cotton( char, item ): if item.hastag( 'lastpick' ): lastpick = item.gettag( 'lastpick' ) if lastpick + COTTONPLANTS_REGROW > wolfpack.time.currenttime(): char.message( tr("You cannot pick cotton here yet.") ) return 1 char.action( ANIM_ATTACK5 ) char.soundeffect( 0x13e ) cotton = wolfpack.additem( 'df9' ) if cotton and not tobackpack( cotton, char ): cotton.update() char.message( tr("You reach down and pick some cotton.") ) # Set a timer for the cotton plant item.settag( 'lastpick', wolfpack.time.currenttime() ) return 1
def createammo(defender, ammo): if random.random() >= 0.50: if defender.player: item = wolfpack.additem(ammo) if not tobackpack(item, defender): item.update() else: # Search for items at the same position items = wolfpack.items(defender.pos.x, defender.pos.y, defender.pos.map) handled = 0 for item in items: if item.baseid == ammo: item.amount += 1 item.update() handled = 1 break if not handled: item = wolfpack.additem(ammo) item.moveto(defender.pos) item.update()
def successsandmining(char, gem): sand = wolfpack.additem("sand") if not tobackpack(sand, char): sand.update() # Resend weight char.socket.resendstatus() resourcecount = max(1, int(gem.gettag('resourcecount'))) gem.settag('resourcecount', resourcecount - 1) # Start respawning the sand if not gem.hastag('resource_empty') and resourcecount <= 1: # Picking the next amount nextamount = random.randint(MINING_ORE[0], MINING_ORE[1]) delay = random.randint(MINING_REFILLTIME[0], MINING_REFILLTIME[1]) gem.addtimer(delay, respawnvein, [nextamount], True) gem.settag('resource_empty', 1) char.socket.clilocmessage( 1044631 ) # You carefully dig up sand of sufficient quality for glassblowing.
def response(player, arguments, response): if response.button == 0: return command = (response.button >> 28) & 0xC item = wolfpack.finditem((response.button & 0x3FFFFFFF) | 0x40000000) # Delete Item if command == 0x04: item.delete() # Bounce Item elif command == 0x08: if not tobackpack(item, player): item.update() # Show Info For Item elif command == 0x0C: iteminfo(player.socket, item) else: player.socket.sysmessage('Unknown command.')
def cotton( char, item ): if item.hastag( 'lastpick' ): lastpick = item.gettag( 'lastpick' ) if lastpick + COTTONPLANTS_REGROW > wolfpack.time.currenttime(): char.message( localemsg( 4 ) ) return 1 char.action( ANIM_ATTACK5 ) char.soundeffect( 0x13e ) cotton = wolfpack.additem( 'df9' ) if cotton and not tobackpack( cotton, char ): cotton.update() char.message( localemsg( 5 ) ) # Set a timer for the cotton plant item.settag( 'lastpick', wolfpack.time.currenttime() ) return 1
def minegranite(Oretable, char, resname, gem): granite = wolfpack.additem('%s_granite' % resname) granite.color = Oretable[resname][COLORID] if not tobackpack(granite, char): granite.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: # Picking the next amount nextamount = random.randint(Oretable[resname][MINAMOUNT], Oretable[resname][MAXAMOUNT]) delay = random.randint(MINING_REFILLTIME[0], MINING_REFILLTIME[1]) gem.addtimer( delay, respawnvein, [nextamount], True ) gem.settag( 'resource_empty', 1 ) # You carefully extract some workable stone from the ore vein! char.socket.clilocmessage( 1044606, "", GRAY ) return True
def Dough(char, args, target): dough = wolfpack.finditem(args[0]) if not dough or not target.item: return False backpack = char.getbackpack() if not target.item.getoutmostchar() == char: char.socket.clilocmessage( 1042001) # That must be in your pack for you to use it. return True # Eggs if target.item.baseid == "9b5": eggshells = wolfpack.additem("9b4") unbaked_quiche = wolfpack.additem("unbaked_quiche") if not tobackpack(eggshells, char): eggshells.update() if not tobackpack(unbaked_quiche, char): unbaked_quiche.update() # Cheese Wheel elif target.item.baseid == "97e": unbaked_cheesepizza = wolfpack.additem("unbaked_cheesepizza") if not tobackpack(unbaked_cheesepizza, char): unbaked_cheesepizza.update() # Sausage elif target.item.baseid in ["9c0", "9c1"]: unbaked_sausagepizza = wolfpack.additem("unbaked_sausagepizza") if not tobackpack(unbaked_sausagepizza, char): unbaked_sausagepizza.update() # Apple elif target.item.baseid == "9d0": unbaked_applepie = wolfpack.additem("unbaked_applepie") if not tobackpack(unbaked_applepie, char): unbaked_applepie.update() # Peach elif target.item.baseid in ["9d2", "172c"]: unbaked_peachcobbler = wolfpack.additem("unbaked_peachcobbler") if not tobackpack(unbaked_peachcobbler, char): unbaked_peachcobbler.update() else: return False dough.delete() target.item.delete()
def Dough(char, args, target): dough = wolfpack.finditem(args[0]) if not dough or not target.item: return False backpack = char.getbackpack() if not target.item.getoutmostchar() == char: char.socket.clilocmessage(1042001) # That must be in your pack for you to use it. return True # Eggs if target.item.baseid == "9b5": eggshells = wolfpack.additem("9b4") unbaked_quiche = wolfpack.additem("unbaked_quiche") if not tobackpack(eggshells, char): eggshells.update() if not tobackpack(unbaked_quiche, char): unbaked_quiche.update() # Cheese Wheel elif target.item.baseid == "97e": unbaked_cheesepizza = wolfpack.additem("unbaked_cheesepizza") if not tobackpack(unbaked_cheesepizza, char): unbaked_cheesepizza.update() # Sausage elif target.item.baseid in ["9c0", "9c1"]: unbaked_sausagepizza = wolfpack.additem("unbaked_sausagepizza") if not tobackpack(unbaked_sausagepizza, char): unbaked_sausagepizza.update() # Apple elif target.item.baseid == "9d0": unbaked_applepie = wolfpack.additem("unbaked_applepie") if not tobackpack(unbaked_applepie, char): unbaked_applepie.update() # Peach elif target.item.baseid in ["9d2", "172c"]: unbaked_peachcobbler = wolfpack.additem("unbaked_peachcobbler") if not tobackpack(unbaked_peachcobbler, char): unbaked_peachcobbler.update() else: return False dough.delete() target.item.delete()
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 minegranite(Oretable, char, resname, gem): granite = wolfpack.additem('%s_granite' % resname) granite.color = Oretable[resname][COLORID] if not tobackpack(granite, char): granite.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: # Picking the next amount nextamount = random.randint(Oretable[resname][MINAMOUNT], Oretable[resname][MAXAMOUNT]) delay = random.randint(MINING_REFILLTIME[0], MINING_REFILLTIME[1]) gem.addtimer(delay, respawnvein, [nextamount], True) gem.settag('resource_empty', 1) # You carefully extract some workable stone from the ore vein! char.socket.clilocmessage(1044606, "", GRAY) return True
def hit(attacker, defender, weapon, time): combat.utilities.playhitsound(attacker, defender) (mindamage, maxdamage) = properties.getdamage(attacker) damage = random.randint(mindamage, maxdamage) damage = scaledamage(attacker, damage, checkability = True) # Slaying? (only against NPCs) if weapon and defender.npc and checkSlaying(weapon, defender): defender.effect(0x37B9, 5, 10) damage *= 2 # Get the ability used by the attacker ability = getability(attacker) # Scale Damage using a weapons ability if ability: damage = ability.scaledamage(attacker, defender, damage) # Give the defender a chance to absorb damage damage = absorbdamage(defender, damage) # If the attack was parried, the ability was wasted if damage == 0 and ability: ability.use(attacker) if attacker.socket: attacker.socket.clilocmessage(1061140) # Your attack was parried ability = None # Reset ability ignorephysical = False if ability: ignorephysical = ability.ignorephysical # Get the damage distribution of the attackers weapon (physical, fire, cold, poison, energy) = damagetypes(attacker) damagedone = energydamage(defender, attacker, damage, physical, fire, cold, poison, energy, 0, DAMAGE_PHYSICAL, ignorephysical=ignorephysical) # Wear out the weapon if weapon: # Leeching leech = properties.fromitem(weapon, LIFELEECH) if leech and leech > random.randint(0, 99) and attacker.maxhitpoints > attacker.hitpoints: amount = (damagedone * 30) / 100 # Leech 30% Health if amount > 0: attacker.hitpoints = min(attacker.maxhitpoints, attacker.hitpoints + amount) attacker.updatehealth() leech = properties.fromitem(weapon, STAMINALEECH) if leech and leech > random.randint(0, 99) and attacker.maxhitpoints > attacker.stamina: amount = (damagedone * 100) / 100 # Leech 100% Stamina if amount > 0: attacker.stamina = min(attacker.maxstamina, attacker.stamina + amount) attacker.updatehealth() leech = properties.fromitem(weapon, MANALEECH) if leech and leech > random.randint(0, 99) and attacker.maxmana > attacker.mana: amount = (damagedone * 40) / 100 # Leech 40% Mana if amount > 0: attacker.mana = min(attacker.maxmana, attacker.mana + amount) attacker.updatemana() # Splash Damage for effectid in [SPLASHPHYSICAL, SPLASHFIRE, SPLASHCOLD, SPLASHPOISON, SPLASHENERGY]: effect = properties.fromitem(weapon, effectid) if effect and effect > random.randint(0, 99): splashdamage(attacker, effectid) # Hit Spell effects for (effectid, callback) in combat.hiteffects.EFFECTS.items(): effect = properties.fromitem(weapon, effectid) if effect and effect > random.randint(0, 99): callback(attacker, defender) # poisoning doesn't work that way anymore #if weapon.hastag( 'poisoning_uses' ): # poisoning.hitEffect( defender, weapon ) # 4% chance for losing one hitpoint if 0.04 >= random.random(): # If it's a self repairing item, grant health instead of reducing it selfrepair = properties.fromitem(weapon, SELFREPAIR) if selfrepair > 0 and weapon.health < weapon.maxhealth - 1: if selfrepair > random.randint(0, 9): weapon.health += 2 weapon.resendtooltip() elif weapon.health > 0: weapon.health -= 1 weapon.resendtooltip() if weapon.health <= 0: tobackpack(weapon, attacker) weapon.update() if attacker.socket: attacker.socket.clilocmessage(500645) # Notify the weapon ability if ability: ability.hit(attacker, defender, damage)
def absorbdamage(defender, damage): # I think RunUO does this in a good fashion. # Determine the layer using a floating point chance. position = random.random() armor = None # 7% chance: Neck if position <= 0.07: armor = defender.itemonlayer(LAYER_NECK) # 7% chance: Gloves elif position <= 0.14: armor = defender.itemonlayer(LAYER_GLOVES) # 14% chance: Arms elif position <= 0.28: armor = defender.itemonlayer(LAYER_ARMS) # 15% chance: Head elif position <= 0.43: armor = defender.itemonlayer(LAYER_HELM) # 22% chance: Legs elif position <= 0.65: armor = defender.itemonlayer(LAYER_LEGS) # 35% chance: Chest else: armor = defender.itemonlayer(LAYER_CHEST) # See if it's really an armor if not properties.itemcheck(armor, ITEM_ARMOR): armor = None # If there is armor at the given position, # it should be damaged. This implementation is so crappy because # we lack the required properties for armors yet. if armor and armor.health > 0: # 4% chance for losing one hitpoint if 0.04 >= random.random(): # If it's a self repairing item, grant health instead of reducing it selfrepair = properties.fromitem(armor, SELFREPAIR) if selfrepair > 0 and armor.health < armor.maxhealth - 1: if selfrepair > random.randint(0, 9): armor.health += 2 armor.resendtooltip() else: armor.health -= 1 armor.resendtooltip() # Unequip the armor if armor and armor.health <= 1: tobackpack(armor, defender) armor.update() if defender.socket: defender.socket.clilocmessage(500645) armor = None # Only players can parry using a shield or a weapon if defender.player or defender.skill[PARRYING] > 0: shield = defender.itemonlayer(LAYER_LEFTHAND) weapon = defender.getweapon() blocked = 0 if not properties.itemcheck(shield, ITEM_SHIELD): shield = None if not properties.itemcheck(weapon, ITEM_MELEE): weapon = None # If we have a shield determine if we blocked the blow by # really checking the parry skill if shield: # There is a 0.3% chance to block for each skill point chance = defender.skill[PARRYING] * 0.0003 defender.checkskill(PARRYING, 0, 1200) blocked = chance >= random.random() # Otherwise just use the parry skill as a chance value # we can't gain it using a weapon as a shield. # Note: no ranged weapons elif weapon and weapon.twohanded: # There is a 0.15% chance to block for each skill point chance = defender.skill[PARRYING] * 0.00015 blocked = chance >= random.random() # If we blocked the blow. Show it, absorb the damage # and damage the shield if there is any if blocked: defender.effect(0x37B9, 10, 16) damage = 0 # This is as lame as above if shield and shield.health > 0: # 4% chance for losing one hitpoint if 0.04 >= random.random(): selfrepair = properties.fromitem(shield, SELFREPAIR) if selfrepair > 0 and shield.health < shield.maxhealth - 1: if selfrepair > random.randint(0, 9): shield.health += 2 shield.resendtooltip() else: shield.health -= 1 shield.resendtooltip() if shield and shield.health <= 0: tobackpack(shield, defender) shield.update() if defender.socket: defender.socket.clilocmessage(500645) return damage
def successmining(Oretable, char, gem, resname, size): if not char: return False if skills.skilltable[MINING][skills.UNHIDE] and char.hidden: char.reveal() if canminegranite(char) and char.hastag("mining") and char.gettag( "mining") == "ore,stone": # 50% possibility of mining granite if random.randint(1, 100) <= 50: minegranite(Oretable, char, resname, gem) return True # 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 = Oretable[resname][COLORID] # Getting ResourceCount from Spot resourcecount = max(1, int(gem.gettag('resourcecount'))) # Checking the Amount of Ores if char.skill[MINING] < 1000: amountofore = random.randint( ((MAXAMOUNTCANGET * char.skill[MINING]) / 1000) / 2, (MAXAMOUNTCANGET * char.skill[MINING]) / 1000) if amountofore < 1: amountofore = 1 else: amountofore = random.randint(MAXAMOUNTCANGET / 2, MAXAMOUNTCANGET) if amountofore < 1: amountofore = 1 if amountofore > resourcecount: # Just checking if its not picking more Ore than Vein Have amountofore = resourcecount # Holding the Amount of Resources generated # Double resources for Felucia if its defined if FELUCIA2XRESGAIN and char.pos.map == 0: item.amount = 2 * amountofore else: item.amount = amountofore if not tobackpack(item, char): item.update() # Resend weight char.socket.resendstatus() gem.settag('resourcecount', resourcecount - amountofore) # Start respawning the ore if not gem.hastag('resource_empty') and resourcecount <= 1: # Picking the next amount nextamount = random.randint(Oretable[resname][MINAMOUNT], Oretable[resname][MAXAMOUNT]) delay = random.randint(MINING_REFILLTIME[0], MINING_REFILLTIME[1]) gem.addtimer(delay, respawnvein, [nextamount], True) gem.settag('resource_empty', 1) message = Oretable[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 make(self, player, arguments, nodelay=0): # See if we have enough skills to attempt if not self.checkskills(player, arguments): player.socket.clilocmessage(1044153) return 0 # See if we have enough material first if not self.checkmaterial(player, arguments): self.parent.send(player, arguments) return 0 if player.socket.hastag("makemenu_crafting"): player.socket.clilocmessage(500119) self.parent.send(player, arguments) return 0 # Is this action delayed? if self.parent.delay != 0 and not nodelay: self.playcrafteffect(player, arguments) player.socket.settag("makemenu_crafting", 1) # Create a copy of the arguments list and transform all char/item objects using # the ObjectWrapper function. wrapped = [] for arg in arguments: if type(arg).__name__ in ["wpchar", "wpitem"]: wrapped.append(ObjectWrapper(arg)) else: wrapped.append(arg) player.addtimer(self.parent.delay, "system.makemenus.craft_timer", [self, wrapped]) return 0 elif self.parent.delay == 0: self.playcrafteffect(player, arguments) success = 0 success = self.checkskills(player, arguments, 1) # 50% chance to loose half of the material if not success: lostmaterials = 0.5 >= random.random() if lostmaterials: self.consumematerial(player, arguments, 1) self.fail(player, arguments, lostmaterials) self.parent.send(player, arguments) else: self.consumematerial(player, arguments, 0) # Calculate if we did an exceptional job exceptional = self.getexceptionalchance(player, arguments) >= random.random() # Create the item item = wolfpack.additem(self.definition) item.decay = 1 # Should always decay item.movable = 1 # Should always be movable if self.amount > 0: item.amount = self.amount if not item: console.log( LOG_ERROR, "Unknown item definition used in action %u of menu %s.\n" % (self.parent.subactions.index(self), self.parent.id), ) else: self.applyproperties(player, arguments, item, exceptional) if exceptional: if self.parent.allowmark and self.markable and player.hastag("markitem"): item.settag("exceptional", int(player.serial)) self.success(player, arguments, item, 1, 1) else: item.settag("exceptional", 0) self.success(player, arguments, item, 1, 0) else: self.success(player, arguments, item, 0, 0) if not tobackpack(item, player): item.update() # Register in make history MakeAction.make(self, player, arguments, nodelay) return success
def docarve( char, item, target ): # Corpse => Carve # Wood => Kindling/Logs model = 0 if target.item: if carve_item( char, item, target ): return else: model = target.item.id # This is for sheering only elif target.char and target.char.npc: if target.char.baseid == 'sheep_unsheered': target.char.id = 223 target.char.baseid = 'sheep_sheered' target.char.update() # Create Wool wool = wolfpack.additem("df8") wool.amount = 2 if not utilities.tobackpack(wool, char): wool.update() # Resend weight char.socket.resendstatus() char.socket.clilocmessage( 500452 ) # You place the gathered wool into your backpack. # Let the wool regrow (minutes) delay = settings.getnumber('Game Speed', 'Regrow Wool Minutes', 180, 1) delay *= 60000 # Miliseconds per Minute target.char.dispel(None, 1, "regrow_wool", []) target.char.addtimer(delay, regrow_wool, [], 1, 0, "regrow_wool") return elif target.char.baseid == 'sheep' or target.char.baseid == 'sheep_sheered': char.socket.clilocmessage( 500449 ) # This sheep is not yet ready to be shorn. return else: char.socket.clilocmessage( 500450 ) # You can only skin dead creatures. return else: model = target.model if target.model == 0: map = wolfpack.map( target.pos.x, target.pos.y, target.pos.map ) treeid = map['id'] elif target.model != 0: treeid = target.model if utilities.istree(treeid): # Axes/Polearms get Logs, Swords get kindling. # Also allows a mace's war axe to be use. 0x13af and 0x13b0 if item.type == 1002 or item.id == 0x13af or item.id == 0x13b0: if not item or not item.container == char: char.message( 502641, "" ) # You must equip this item to use it. return else: skills.lumberjacking.response( [ target, item, char ] ) # Swords and Fencing Weapons: Get kindling elif item.type == 1001 or item.type == 1005: skills.lumberjacking.hack_kindling( char, target.pos ) else: char.socket.clilocmessage( 500494, "", GRAY ) # You can't use a bladed item on that. return False
def absorbdamage(defender, damage): # I think RunUO does this in a good fashion. # Determine the layer using a floating point chance. position = random.random() armor = None # 7% chance: Neck if position <= 0.07: armor = defender.itemonlayer(LAYER_NECK) # 7% chance: Gloves elif position <= 0.14: armor = defender.itemonlayer(LAYER_GLOVES) # 14% chance: Arms elif position <= 0.28: armor = defender.itemonlayer(LAYER_ARMS) # 15% chance: Head elif position <= 0.43: armor = defender.itemonlayer(LAYER_HELM) # 22% chance: Legs elif position <= 0.65: armor = defender.itemonlayer(LAYER_PANTS) # 35% chance: Chest else: armor = defender.itemonlayer(LAYER_CHEST) # See if it's really an armor if not properties.itemcheck(armor, ITEM_ARMOR): armor = None # If there is armor at the given position, # it should be damaged. This implementation is so crappy because # we lack the required properties for armors yet. if armor and armor.health > 0: # 25% chance for losing one hitpoint if 0.25 >= random.random(): # If it's a self repairing item, grant health instead of reducing it selfrepair = properties.fromitem(armor, SELFREPAIR) if selfrepair > 0 and armor.health < armor.maxhealth - 1: if selfrepair > random.randint(0, 9): armor.health += 2 armor.resendtooltip() else: armor.health -= 1 armor.resendtooltip() # Unequip the armor if armor and armor.health <= 1: tobackpack(armor, defender) armor.update() if defender.socket: defender.socket.clilocmessage(500645) armor = None # Only players can parry using a shield or a weapon if defender.player or defender.skill[PARRYING] > 0: damage = blockdamage(defender, damage) return damage