コード例 #1
0
	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)
コード例 #2
0
	def applyproperties(self, player, arguments, item, exceptional):
		# Get the color of the cloth this item has been crafted with
		if self.cloth > 0:
			assert(len(arguments) >= 2)
			item.color = arguments[1]		
		
		# All tailoring items crafted out of leather gain the special color
		if self.submaterial1 > 0:
			material = self.parent.getsubmaterial1used(player, arguments)
			material = self.parent.submaterials1[material]
			item.color = material[4]
			item.settag('resname', material[5])

		# Distribute another 6 points randomly between the resistances an armor alread
		# has. There are no tailored weapons.
		if exceptional:
			if itemcheck(item, ITEM_ARMOR) or itemcheck(item, ITEM_SHIELD):
				# Copy all the values to tags
				boni = [0, 0, 0, 0, 0]

				for i in range(0, 6):
					boni[random.randint(0,4)] += 1

				item.settag('res_physical', fromitem(item, RESISTANCE_PHYSICAL) + boni[0])
				item.settag('res_fire', fromitem(item, RESISTANCE_FIRE) + boni[1])
				item.settag('res_cold', fromitem(item, RESISTANCE_COLD) + boni[2])
				item.settag('res_energy', fromitem(item, RESISTANCE_ENERGY) + boni[3])
				item.settag('res_poison', fromitem(item, RESISTANCE_POISON) + boni[4])
コード例 #3
0
	def applyproperties(self, player, arguments, item, exceptional):
		# Stackable items consume all resources
		if self.stackable:
			backpack = player.getbackpack()
			count = -1
			for (materials, amount, name) in self.materials:
				items = backpack.countitems(materials)
				if count == -1:
					count = items / amount
				else:
					count = min(count, items / amount)
			for (materials, amount, name) in self.materials:
				backpack.removeitems( materials, count )
			if count != -1:
				item.amount += count
			else:
				item.amount = 1 + count
			item.update()
		
		# All carpentry items crafted out of ingots keep a resname
		if self.submaterial1 > 0:
			material = self.parent.getsubmaterial1used(player, arguments)
			material = self.parent.submaterials1[material]
			item.color = material[4]
			item.settag('resname', material[5])

		# Distribute another 6 points randomly between the resistances an armor alread
		# has. There are no tailored weapons.
		if exceptional:
			if properties.itemcheck(item, ITEM_SHIELD):
				# Copy all the values to tags
				boni = [0, 0, 0, 0, 0]

				for i in range(0, 6):
					boni[random.randint(0,4)] += 1

				item.settag('res_physical', properties.fromitem(item, RESISTANCE_PHYSICAL) + boni[0])
				item.settag('res_fire', properties.fromitem(item, RESISTANCE_FIRE) + boni[1])
				item.settag('res_cold', properties.fromitem(item, RESISTANCE_COLD) + boni[2])
				item.settag('res_energy', properties.fromitem(item, RESISTANCE_ENERGY) + boni[3])
				item.settag('res_poison', properties.fromitem(item, RESISTANCE_POISON) + boni[4])

			elif properties.itemcheck(item, ITEM_WEAPON):
				# Increase the damage bonus by 20%
				bonus = properties.fromitem(item, DAMAGEBONUS)
				bonus += 20
				item.settag('aos_boni_damage', bonus)

			# Exceptional Containers get a key
			if item.type == 1:
				if item.baseid == '9aa' or item.baseid == '9a9' or item.baseid == 'e3f' or item.baseid == 'e3d' or item.baseid == 'e42' or item.baseid == 'a4d' or item.baseid == 'a4f':
					createlockandkey( item )

		# Reduce the uses remain count
		checktool(player, wolfpack.finditem(arguments[0]), 1)
コード例 #4
0
	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)
コード例 #5
0
def onWearItem(player, wearer, item, layer):
	lower = properties.fromitem(item, LOWERREQS) / 100.0

	req_str = item.getintproperty( 'req_strength', 0 )
	if item.hastag( 'req_strength' ):
		req_str = int( item.gettag( 'req_strength' ) )
	if lower:
		req_str = int(ceil(req_str) * (1.0 - lower))

	req_dex = item.getintproperty( 'req_dexterity', 0 )
	if item.hastag( 'req_dexterity' ):
		req_dex = int( item.gettag( 'req_dexterity' ) )
	if lower:
		req_dex = int(ceil(req_dex) * (1.0 - lower))

	req_int = item.getintproperty( 'req_intelligence', 0 )
	if item.hastag( 'req_intelligence' ):
		req_int = int( item.gettag( 'req_intelligence' ) )
	if lower:
		req_int = int(ceil(req_int) * (1.0 - lower))

	if wearer.strength < req_str:
		if player != wearer:
			player.socket.sysmessage('This person can\'t wear that item, seems not strong enough.')
		else:
			player.socket.clilocmessage(500213)
		return 1

	if wearer.dexterity < req_dex:
		if player != wearer:
			player.socket.sysmessage('This person can\'t wear that item, seems not agile enough.')
		else:
			player.socket.clilocmessage(502077)
		return 1

	if wearer.intelligence < req_int:
		if player != wearer:
			player.socket.sysmessage('This person can\'t wear that item, seems not smart enough.')
		else:
			player.socket.sysmessage('You are not ingellgent enough to equip this item.')
		return 1

	# Reject equipping an item with durability 1 or less
	# if it's an armor, shield or weapon
	armor = properties.itemcheck(item, ITEM_ARMOR)
	weapon = properties.itemcheck(item, ITEM_WEAPON)
	shield = properties.itemcheck(item, ITEM_SHIELD)

	if (armor or weapon or shield) and item.health < 1:
		player.socket.sysmessage('You need to repair this before using it again.')
		return 1

	return 0
コード例 #6
0
	def applyproperties(self, player, arguments, item, exceptional):
		# See if special ingots were used in the creation of
		# this item. All items crafted by blacksmiths gain the
		# color!
		if self.submaterial1 > 0:
			material = self.parent.getsubmaterial1used(player, arguments)
			material = self.parent.submaterials1[material]
			item.color = material[4]
			item.settag('resname', material[5])

		# Apply properties of secondary material
		if self.submaterial2 > 0:
			material = self.parent.getsubmaterial2used(player, arguments)
			material = self.parent.submaterials2[material]
			item.color = material[4]
			item.settag('resname2', material[5])

		# Apply one-time boni
		healthbonus = fromitem(item, DURABILITYBONUS)
		if healthbonus != 0:
			bonus = int(math.ceil(item.maxhealth * (healthbonus / 100.0)))
			item.maxhealth = max(1, item.maxhealth + bonus)
			item.health = item.maxhealth

		#weightbonus = fromitem(item, WEIGHTBONUS)
		#if weightbonus != 0:
			#bonus = int(math.ceil(item.weight * (weightbonus / 100.0)))
			#item.weight = max(0, item.weight + bonus)

		# Distribute another 6 points randomly between the resistances this armor already has
		if exceptional:
			if itemcheck(item, ITEM_ARMOR) or itemcheck(item, ITEM_SHIELD):
				# Copy all the values to tags
				boni = [0, 0, 0, 0, 0]

				for i in range(0, 6):
					boni[random.randint(0,4)] += 1

				item.settag('res_physical', fromitem(item, RESISTANCE_PHYSICAL) + boni[0])
				item.settag('res_fire', fromitem(item, RESISTANCE_FIRE) + boni[1])
				item.settag('res_cold', fromitem(item, RESISTANCE_COLD) + boni[2])
				item.settag('res_energy', fromitem(item, RESISTANCE_ENERGY) + boni[3])
				item.settag('res_poison', fromitem(item, RESISTANCE_POISON) + boni[4])
			elif itemcheck(item, ITEM_WEAPON):
				# Increase the damage bonus by 20%
				bonus = fromitem(item, DAMAGEBONUS)
				bonus += 20
				item.settag('aos_boni_damage', bonus)

		# Reduce the uses remain count
		checktool(player, wolfpack.finditem(arguments[0]), 1)
コード例 #7
0
def target(player, arguments, target):
	dyetub = wolfpack.finditem(arguments[0])

	if not dyetub or not player.canreach(dyetub, 1):
		player.socket.clilocmessage(500446)
		return
		
	if not target.item:
		player.socket.clilocmessage(1042418) # You can only dye leather with this tub.
		return

	if target.item.getoutmostchar() != player:
		player.socket.clilocmessage(500446) # Too far away
		return
		
	if target.item.container == player:
		player.socket.clilocmessage(500861) # Can't Dye clothing that is being worn.
		return
		
	global ARMORLIST
	if not properties.itemcheck(target.item, ITEM_ARMOR) or target.item.baseid not in ARMORLIST:
		player.socket.clilocmessage(1042418) # Can only dye leaether
		return	
	
	target.item.color = dyetub.color
	target.item.update()
	player.log( LOG_MESSAGE, "Dying item (%x,%x) using tub (%x,%x)\n" % ( target.item.serial, target.item.color, dyetub.serial, dyetub.color ) )
	player.soundeffect(0x23e)
コード例 #8
0
def target(player, arguments, target):
    dyetub = wolfpack.finditem(arguments[0])

    if not dyetub or not player.canreach(dyetub, 1):
        player.socket.clilocmessage(500446)
        return

    if not target.item:
        player.socket.clilocmessage(
            1042418)  # You can only dye leather with this tub.
        return

    if target.item.getoutmostchar() != player:
        player.socket.clilocmessage(500446)  # Too far away
        return

    if target.item.container == player:
        player.socket.clilocmessage(
            500861)  # Can't Dye clothing that is being worn.
        return

    global ARMORLIST
    if not properties.itemcheck(
            target.item, ITEM_ARMOR) or target.item.baseid not in ARMORLIST:
        player.socket.clilocmessage(1042418)  # Can only dye leaether
        return

    target.item.color = dyetub.color
    target.item.update()
    player.log(
        LOG_MESSAGE, "Dying item (%x,%x) using tub (%x,%x)\n" %
        (target.item.serial, target.item.color, dyetub.serial, dyetub.color))
    player.soundeffect(0x23e)
コード例 #9
0
	def repair(self, player, arguments, target):
		if not target.item:
			player.socket.clilocmessage(500426)
			return

		if target.item.container != player.getbackpack():
			player.socket.clilocmessage(1044275)
			return

		item = target.item
		weapon = itemcheck(item, ITEM_WEAPON)

		if weapon:
			# Item in full repair
			if item.maxhealth <= 0 or item.health >= item.maxhealth:
				player.socket.clilocmessage(500423)
				return

			skill = player.skill[BOWCRAFT]
			if skill >= 900:
				weaken = 1
			elif skill >= 700:
				weaken = 2
			else:
				weaken = 3

			action = self.findcraftitem(item.baseid)

			# We can't craft it, so we can't repair it.
			if not action:
				player.socket.clilocmessage(1044277)
				return

			# We will either destroy or repair it from here on
			# So we can play the craft effect.
			player.soundeffect(0x55)

			if item.maxhealth <= weaken:
				player.socket.clilocmessage(500424)
				item.delete()
			elif player.checkskill(BOWCRAFT, 0, 1000):
				player.socket.clilocmessage(1044279)
				item.maxhealth -= weaken
				item.health = item.maxhealth
				item.resendtooltip()
			else:
				player.socket.clilocmessage(1044280)
				item.maxhealth -= weaken
				item.health = max(0, item.health - weaken)
				item.resendtooltip()

			# Warn the user if we'll break the item next time
			if item.maxhealth <= weaken:
				player.socket.clilocmessage(1044278)

			return

		player.socket.clilocmessage(1044277)
コード例 #10
0
    def repair(self, player, arguments, target):
        if not target.item:
            player.socket.clilocmessage(500426)
            return

        if target.item.container != player.getbackpack():
            player.socket.clilocmessage(1044275)
            return

        item = target.item
        weapon = itemcheck(item, ITEM_WEAPON)

        if weapon:
            # Item in full repair
            if item.maxhealth <= 0 or item.health >= item.maxhealth:
                player.socket.clilocmessage(500423)
                return

            skill = player.skill[BOWCRAFT]
            if skill >= 900:
                weaken = 1
            elif skill >= 700:
                weaken = 2
            else:
                weaken = 3

            action = self.findcraftitem(item.baseid)

            # We can't craft it, so we can't repair it.
            if not action:
                player.socket.clilocmessage(1044277)
                return

            # We will either destroy or repair it from here on
            # So we can play the craft effect.
            player.soundeffect(0x55)

            if item.maxhealth <= weaken:
                player.socket.clilocmessage(500424)
                item.delete()
            elif player.checkskill(BOWCRAFT, 0, 1000):
                player.socket.clilocmessage(1044279)
                item.maxhealth -= weaken
                item.health = item.maxhealth
                item.resendtooltip()
            else:
                player.socket.clilocmessage(1044280)
                item.maxhealth -= weaken
                item.health = max(0, item.health - weaken)
                item.resendtooltip()

            # Warn the user if we'll break the item next time
            if item.maxhealth <= weaken:
                player.socket.clilocmessage(1044278)

            return

        player.socket.clilocmessage(1044277)
コード例 #11
0
	def applyproperties(self, player, arguments, item, exceptional):
		# Use all available resources if the item we make is
		# flagged as "stackable".
		if self.stackable:
			backpack = player.getbackpack()
			count = -1
			for (materials, amount, name) in self.materials:
				items = backpack.countitems(materials)
				if count == -1:
					count = items / amount
				else:
					count = min(count, items / amount)
			for (materials, amount, name) in self.materials:
				backpack.removeitems( materials, count )
			if count != -1:
				item.amount += count
			else:
				item.amount = 1 + count
			item.update()


		# Distribute another 6 points randomly between the resistances an armor alread
		# has. There are no tailored weapons.
		if exceptional:
			if itemcheck(item, ITEM_ARMOR) or itemcheck(item, ITEM_SHIELD):
				# Copy all the values to tags
				boni = [0, 0, 0, 0, 0]

				for i in range(0, 6):
					boni[random.randint(0,4)] += 1

				item.settag('res_physical', fromitem(item, RESISTANCE_PHYSICAL) + boni[0])
				item.settag('res_fire', fromitem(item, RESISTANCE_FIRE) + boni[1])
				item.settag('res_cold', fromitem(item, RESISTANCE_COLD) + boni[2])
				item.settag('res_energy', fromitem(item, RESISTANCE_ENERGY) + boni[3])
				item.settag('res_poison', fromitem(item, RESISTANCE_POISON) + boni[4])
			elif itemcheck(item, ITEM_WEAPON):
				# Increase the damage bonus by 20%
				bonus = fromitem(item, DAMAGEBONUS)
				bonus += 20
				item.settag('aos_boni_damage', bonus)


		# Reduce the uses remain count
		checktool(player, wolfpack.finditem(arguments[0]), 1)
コード例 #12
0
	def applyproperties(self, player, arguments, item, exceptional):
		# See if special ingots were used in the creation of
		# this item. All items crafted by blacksmiths gain the
		# color!
		if self.retaincolor and self.submaterial1 > 0:
			material = self.parent.getsubmaterial1used(player, arguments)
			material = self.parent.submaterials1[material]
			item.color = material[4]
			item.settag('resname', material[5])

		# Apply properties of secondary material
		if self.submaterial2 > 0:
			material = self.parent.getsubmaterial2used(player, arguments)
			material = self.parent.submaterials2[material]
			item.color = material[4]
			item.settag('resname2', material[5])

		# Apply one-time boni
		healthbonus = fromitem(item, DURABILITYBONUS)
		if healthbonus != 0:
			bonus = int(math.ceil(item.maxhealth * (healthbonus / 100.0)))
			item.maxhealth = max(1, item.maxhealth + bonus)
			item.health = item.maxhealth

		# Distribute another 6 points randomly between the resistances this armor already has
		if exceptional:
			if itemcheck(item, ITEM_ARMOR) or itemcheck(item, ITEM_SHIELD):
				# Copy all the values to tags
				boni = [0, 0, 0, 0, 0]

				for i in range(0, 6):
					boni[random.randint(0,4)] += 1

				item.settag('res_physical', fromitem(item, RESISTANCE_PHYSICAL) + boni[0])
				item.settag('res_fire', fromitem(item, RESISTANCE_FIRE) + boni[1])
				item.settag('res_cold', fromitem(item, RESISTANCE_COLD) + boni[2])
				item.settag('res_energy', fromitem(item, RESISTANCE_ENERGY) + boni[3])
				item.settag('res_poison', fromitem(item, RESISTANCE_POISON) + boni[4])
			elif itemcheck(item, ITEM_WEAPON):
				# Increase the damage bonus by 20%
				bonus = fromitem(item, DAMAGEBONUS)
				bonus += 20
				item.settag('aos_boni_damage', bonus)
コード例 #13
0
ファイル: tailoring.py プロジェクト: thooge/Wolfpack
    def applyproperties(self, player, arguments, item, exceptional):
        # Get the color of the cloth this item has been crafted with
        if self.cloth > 0:
            assert (len(arguments) >= 2)
            item.color = arguments[1]

        # All tailoring items crafted out of leather gain the special color
        if self.submaterial1 > 0:
            material = self.parent.getsubmaterial1used(player, arguments)
            material = self.parent.submaterials1[material]
            item.color = material[4]
            item.settag('resname', material[5])

        # Apply one-time boni
        healthbonus = fromitem(item, DURABILITYBONUS)
        if healthbonus != 0:
            bonus = int(math.ceil(item.maxhealth * (healthbonus / 100.0)))
            item.maxhealth = max(1, item.maxhealth + bonus)
            item.health = item.maxhealth

        # Distribute another 6 points randomly between the resistances an armor alread
        # has. There are no tailored weapons.
        if exceptional:
            if itemcheck(item, ITEM_ARMOR) or itemcheck(item, ITEM_SHIELD):
                # Copy all the values to tags
                boni = [0, 0, 0, 0, 0]

                for i in range(0, 6):
                    boni[random.randint(0, 4)] += 1

                item.settag('res_physical',
                            fromitem(item, RESISTANCE_PHYSICAL) + boni[0])
                item.settag('res_fire',
                            fromitem(item, RESISTANCE_FIRE) + boni[1])
                item.settag('res_cold',
                            fromitem(item, RESISTANCE_COLD) + boni[2])
                item.settag('res_energy',
                            fromitem(item, RESISTANCE_ENERGY) + boni[3])
                item.settag('res_poison',
                            fromitem(item, RESISTANCE_POISON) + boni[4])
コード例 #14
0
	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 properties.fromitem(weapon, SPELLCHANNELING) == 0:
			return False
		else:
			return True						
コード例 #15
0
ファイル: spell.py プロジェクト: thooge/Wolfpack
    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 wolfpack.utilities.tobackpack(weapon, char):
                weapon.update()

            return True
        else:
            return True
コード例 #16
0
	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 wolfpack.utilities.tobackpack(weapon, char):
				weapon.update()

			return True
		else:
			return True
コード例 #17
0
	def repair(self, player, arguments, target):
		if not checkanvilandforge(player):
			player.socket.clilocmessage(1044282)
			return

		if not checktool(player, wolfpack.finditem(arguments[0])):
			return

		if not target.item:
			player.socket.clilocmessage(500426)
			return

		if target.item.container != player.getbackpack():
			player.socket.clilocmessage(1044275)
			return

		item = target.item
		weapon = itemcheck(item, ITEM_WEAPON)
		shield = itemcheck(item, ITEM_SHIELD)
		armor = itemcheck(item, ITEM_ARMOR)

		if weapon or armor or shield:
			# Item in full repair
			if item.maxhealth <= 0 or item.health >= item.maxhealth:
				player.socket.clilocmessage(500423)
				return

			skill = player.skill[BLACKSMITHING]
			if skill >= 900:
				weaken = 1
			elif skill >= 700:
				weaken = 2
			else:
				weaken = 3

			action = self.findcraftitem(item.baseid)

			# We can't craft it, so we can't repair it.
			if not action:
				player.socket.clilocmessage(1044277)
				return

			# We will either destroy or repair it from here on
			# So we can play the craft effect.
			player.soundeffect(0x2a)

			if item.maxhealth <= weaken:
				player.socket.clilocmessage(500424)
				item.delete()
			elif player.checkskill(BLACKSMITHING, 0, 1000):
				player.socket.clilocmessage(1044279)
				item.maxhealth -= weaken
				item.health = item.maxhealth
				item.resendtooltip()
			else:
				player.socket.clilocmessage(1044280)
				item.maxhealth -= weaken
				item.health = max(0, item.health - weaken)
				item.resendtooltip()

			# Warn the user if we'll break the item next time
			if item.maxhealth <= weaken:
				player.socket.clilocmessage(1044278)

			return

		player.socket.clilocmessage(1044277)
コード例 #18
0
def onWearItem(player, wearer, item, layer):
	if wearer.socket and wearer.socket.hastag('block_equip'):
		expire = int(wearer.socket.gettag('block_equip'))
		if expire < wolfpack.currenttime():
			wearer.socket.deltag('block_equip')
		else:
			if player == wearer:
				player.socket.sysmessage(tr('You cannot equip another so soon after being disarmed.'))
			else:
				player.socket.sysmessage(tr('They cannot equip another so soon after being disarmed.'))
			return True
	
	lower = properties.fromitem(item, LOWERREQS) / 100.0

	req_str = item.getintproperty( 'req_strength', 0 )
	if item.hastag( 'req_strength' ):
		req_str = int( item.gettag( 'req_strength' ) )
	if lower:
		req_str = int(ceil(req_str) * (1.0 - lower))

	req_dex = item.getintproperty( 'req_dexterity', 0 )
	if item.hastag( 'req_dexterity' ):
		req_dex = int( item.gettag( 'req_dexterity' ) )
	if lower:
		req_dex = int(ceil(req_dex) * (1.0 - lower))

	req_int = item.getintproperty( 'req_intelligence', 0 )
	if item.hastag( 'req_intelligence' ):
		req_int = int( item.gettag( 'req_intelligence' ) )
	if lower:
		req_int = int(ceil(req_int) * (1.0 - lower))

	if wearer.strength < req_str:
		if player != wearer:
			player.socket.sysmessage('This person can\'t wear that item, seems not strong enough.')
		else:
			player.socket.clilocmessage(500213)
		return True

	if wearer.dexterity < req_dex:
		if player != wearer:
			player.socket.sysmessage('This person can\'t wear that item, seems not agile enough.')
		else:
			player.socket.clilocmessage(502077)
		return True

	if wearer.intelligence < req_int:
		if player != wearer:
			player.socket.sysmessage('This person can\'t wear that item, seems not smart enough.')
		else:
			player.socket.sysmessage('You are not intelligent enough to equip this item.')
		return True

	# Reject equipping an item with durability 1 or less
	# if it's an armor, shield or weapon
	armor = properties.itemcheck(item, ITEM_ARMOR)
	weapon = properties.itemcheck(item, ITEM_WEAPON)
	shield = properties.itemcheck(item, ITEM_SHIELD)

	if (armor or weapon or shield) and item.health < 1:
		player.socket.sysmessage('You need to repair this before using it again.')
		return True

	return False
コード例 #19
0
def onShowTooltip(viewer, object, tooltip):
	armor = properties.itemcheck(object, ITEM_ARMOR)
	weapon = properties.itemcheck(object, ITEM_WEAPON)
	shield = properties.itemcheck(object, ITEM_SHIELD)

	if (armor or weapon or shield) and object.amount == 1:
		# Reinsert the name if we need an ore prefix
		prefix1 = None
		if object.hastag('resname'):
			resname = str(object.gettag('resname'))
			if (armor or shield) and wolfpack.armorinfo.ARMOR_RESNAME_BONI.has_key(resname):
				resinfo = wolfpack.armorinfo.ARMOR_RESNAME_BONI[resname]
				if resinfo.has_key(MATERIALPREFIX):
					prefix1 = resinfo[MATERIALPREFIX]
			if weapon and wolfpack.weaponinfo.WEAPON_RESNAME_BONI.has_key(resname):
				resinfo = wolfpack.weaponinfo.WEAPON_RESNAME_BONI[resname]
				if resinfo.has_key(MATERIALPREFIX):
					prefix1 = resinfo[MATERIALPREFIX]
		elif object.hasstrproperty( 'resname' ):
			resname = str( object.getstrproperty( 'resname' ) )
			if (armor or shield) and wolfpack.armorinfo.ARMOR_RESNAME_BONI.has_key(resname):
				resinfo = wolfpack.armorinfo.ARMOR_RESNAME_BONI[resname]
				if resinfo.has_key(MATERIALPREFIX):
					prefix1 = resinfo[MATERIALPREFIX]
			if weapon and wolfpack.weaponinfo.WEAPON_RESNAME_BONI.has_key(resname):
				resinfo = wolfpack.weaponinfo.WEAPON_RESNAME_BONI[resname]
				if resinfo.has_key(MATERIALPREFIX):
					prefix1 = resinfo[MATERIALPREFIX]

		prefix2 = None
		if object.hastag('resname2'):
			resname2 = str(object.gettag('resname2'))
			if (armor or shield) and wolfpack.armorinfo.ARMOR_RESNAME_BONI.has_key(resname2):
				resinfo = wolfpack.armorinfo.ARMOR_RESNAME_BONI[resname2]
				if resinfo.has_key(MATERIALPREFIX):
					prefix2 = resinfo[MATERIALPREFIX]
			if weapon and wolfpack.weaponinfo.WEAPON_RESNAME_BONI.has_key(resname2):
				resinfo = wolfpack.weaponinfo.WEAPON_RESNAME_BONI[resname2]
				if resinfo.has_key(MATERIALPREFIX):
					prefix2 = resinfo[MATERIALPREFIX]
		elif object.hasstrproperty( 'resname2' ):
			resname2 = str( object.getstrproperty( 'resname2' ) )
			if (armor or shield) and wolfpack.armorinfo.ARMOR_RESNAME_BONI.has_key(resname2):
				resinfo = wolfpack.armorinfo.ARMOR_RESNAME_BONI[resname2]
				if resinfo.has_key(MATERIALPREFIX):
					prefix2 = resinfo[MATERIALPREFIX]
			if weapon and wolfpack.weaponinfo.WEAPON_RESNAME_BONI.has_key(resname2):
				resinfo = wolfpack.weaponinfo.WEAPON_RESNAME_BONI[resname2]
				if resinfo.has_key(MATERIALPREFIX):
					prefix2 = resinfo[MATERIALPREFIX]

		if len(object.name) == 0:
			itemname = '#' + str(1020000 + object.id)
		else:
			itemname = object.name

		if prefix1 and prefix2:
			tooltip.reset()
			tooltip.add(1053099, "%s %s\t%s" % (prefix1, prefix2, itemname))
		elif prefix1 and not prefix2:
			tooltip.reset()
			tooltip.add(1053099, "%s\t%s" % (prefix1, itemname))
		elif not prefix1 and prefix2:
			tooltip.reset()
			tooltip.add(1053099, "%s\t%s" % (prefix2, itemname))

	# Exceptional item?
	if object.hastag('exceptional'):
		tooltip.add(1060636, '')

		# 1050043: Crafted by ~param~
		serial = int(object.gettag('exceptional'))
		crafter = wolfpack.findchar(serial)
		if crafter:
			tooltip.add(1050043, crafter.name)

	# Only Armors and Weapons have durability
	if weapon or armor or shield:
		tooltip.add(1060639, "%u\t%u" % (object.health, object.maxhealth))

		durabilitybonus = properties.fromitem(object, DURABILITYBONUS)
		if durabilitybonus:
			if durabilitybonus > 0:
				tooltip.add(1060410, '+' + str(durabilitybonus))
			else:
				tooltip.add(1060410, str(durabilitybonus))

	# Weapon specific properties
	if weapon:
		# Leeching
		leech = properties.fromitem(object, LIFELEECH)
		if leech:
			tooltip.add(1060422, str(leech))
		leech = properties.fromitem(object, STAMINALEECH)
		if leech:
			tooltip.add(1060430, str(leech))
		leech = properties.fromitem(object, MANALEECH)
		if leech:
			tooltip.add(1060427, str(leech))						
	
		# Splash 
		for (effect, cliloc) in {SPLASHPHYSICAL: 1060428, SPLASHFIRE: 1060419, SPLASHCOLD: 1060416, SPLASHPOISON: 1060429, SPLASHENERGY: 1060418}.items():
			effect = properties.fromitem(object, effect)
			if effect > 0:
				tooltip.add(cliloc, str(effect))
	
		# Hit Effects
		for (effect, cliloc) in {HITMAGICARROW: 1060426, HITHARM: 1060421, HITFIREBALL: 1060420, HITLIGHTNING: 1060423, HITDISPEL: 1060417}.items():
			effect = properties.fromitem(object, effect)
			if effect > 0:
				tooltip.add(cliloc, str(effect))

		# Slayer
		slayer = properties.fromitem(object, SLAYER)
		if slayer != '':
			slayer = system.slayer.findEntry(slayer)
			if slayer:
				tooltip.add(slayer.name, '')

		# One or twohanded weapon
		if object.twohanded:
			tooltip.add(1061171, '')
		else:
			tooltip.add(1061824, '')

		# Used weaponskill
		skill = weaponskill(viewer, object)
		if skill == SWORDSMANSHIP:
			tooltip.add(1061172, '')
		elif skill == MACEFIGHTING:
			tooltip.add(1061173, '')
		elif skill == FENCING:
			tooltip.add(1061174, '')
		elif skill == ARCHERY:
			tooltip.add(1061175, '')
		#elif skill == WRESTLING:
		#	tooltip.add(1061172, '')

		# Special weapon range
		if object.hasintproperty( 'range' ) or object.hastag( 'range' ):
			if object.hastag( 'range' ):
				weaponrange = int( object.gettag( 'range' ) )
			else:
				weaponrange = int( object.getintproperty( 'range', 12 ) )
			if weaponrange > 1:
				tooltip.add( 1061169, str(weaponrange) )

		# Max-Mindamage
		mindamage = object.getintproperty( 'mindamage', 1 )
		if object.hastag( 'mindamage' ):
			mindamage = int( object.gettag( 'mindamage' ) )
		maxdamage = object.getintproperty( 'maxdamage', 2 )
		if object.hastag( 'maxdamage' ):
			maxdamage = int( object.gettag( 'maxdamage' ) )
		tooltip.add( 1061168, "%u\t%u" % ( mindamage, maxdamage ) )

		# Speed
		speed = object.getintproperty( 'speed', 10 )
		if object.hastag( 'speed' ):
			speed = int( object.gettag( 'speed' ) )
		tooltip.add(1061167, str(speed))

		# Physical Damage Distribution
		fire = properties.fromitem(object, DAMAGE_FIRE)
		cold = properties.fromitem(object, DAMAGE_COLD)
		poison = properties.fromitem(object, DAMAGE_POISON)
		energy = properties.fromitem(object, DAMAGE_ENERGY)

		# This must always total 100
		physical = 100 - (fire + cold + poison + energy)
		if (physical + fire + cold + poison + energy) != 100:
			physical = 100
			fire = 0
			cold = 0
			poison = 0
			energy = 0

		if physical:
			tooltip.add(1060403, str(physical))

		if fire:
			tooltip.add(1060405, str(fire))

		if cold:
			tooltip.add(1060404, str(cold))

		if poison:
			tooltip.add(1060406, str(poison))

		if energy:
			tooltip.add(1060407, str(energy))

	if weapon or shield:
		# Spell Channeling
		spellchanneling = properties.fromitem(object, SPELLCHANNELING)
		if spellchanneling:
			tooltip.add(1060482, "")
	else:
		spellchanneling = False

	# Those are only relevant if its not a shield/weapon or for spellchanneling items
	if (not weapon and not shield) or spellchanneling:
		castrecovery = properties.fromitem(object, CASTRECOVERYBONUS)

		if castrecovery:
			tooltip.add(1060412, str(castrecovery))

		castspeed = properties.fromitem(object, CASTSPEEDBONUS)

		if castspeed:
			tooltip.add(1060413, str(castspeed))

		spelldamagebonus = properties.fromitem(object, SPELLDAMAGEBONUS)

		if spelldamagebonus:
			tooltip.add(1060483, str(spelldamagebonus))

	physical = properties.fromitem(object, RESISTANCE_PHYSICAL)
	fire = properties.fromitem(object, RESISTANCE_FIRE)
	cold = properties.fromitem(object, RESISTANCE_COLD)
	poison = properties.fromitem(object, RESISTANCE_POISON)
	energy = properties.fromitem(object, RESISTANCE_ENERGY)

	if physical:
		tooltip.add(1060448, str(physical))

	if fire:
		tooltip.add(1060447, str(fire))

	if cold:
		tooltip.add(1060445, str(cold))

	if poison:
		tooltip.add(1060449, str(poison))

	if energy:
		tooltip.add(1060446, str(energy))

	modifiers(object, tooltip)

	lowermana = properties.fromitem(object, LOWERMANACOST)
	if lowermana:
		tooltip.add(1060433, str(lowermana))

	lowerreags = properties.fromitem(object, LOWERREAGENTCOST)
	if lowerreags:
		tooltip.add(1060434, str(lowerreags))

	lower = properties.fromitem(object, LOWERREQS)
	if lower:
		tooltip.add(1060435, str(lower))
	lower /= 100.0

	# Tag will override.
	req_str = object.getintproperty( 'req_strength', 0 )
	if object.hastag( 'req_strength' ):
		req_str = int( object.gettag( 'req_strength' ) )

	if lower:
		req_str = int(ceil(req_str) * (1.0 - lower))
	if req_str:
		tooltip.add(1061170, str(req_str))

	# Skill Boni (1-5)
	for i in range(0, 5):
		if object.hastag('skillbonus_%u' % i):
			try:
				(skill, bonus) = object.gettag('skillbonus_%u' % i).split(',')
				(skill, bonus) = (int(skill), int(bonus))

				if bonus == 0 or skill < 0 or skill >= ALLSKILLS:
					continue

				# Add a Bonus for the skill
				tooltip.add(1060451 + i, "#%u\t%u" % (1044060 + skill, int(bonus / 10)))
			except:
				object.deltag('skillbonus_%u' % i)
				continue
				
	return False
コード例 #20
0
def onShowTooltip(viewer, object, tooltip):
    armor = properties.itemcheck(object, ITEM_ARMOR)
    weapon = properties.itemcheck(object, ITEM_WEAPON)
    shield = properties.itemcheck(object, ITEM_SHIELD)
    footwear = object.id in range(0x170b, 0x1713)  #leather foorwear

    if (armor or weapon or shield or footwear) and object.amount == 1:
        # Reinsert the name if we need an ore prefix
        prefix1 = None
        if object.hastag('resname'):
            resname = str(object.gettag('resname'))
            if (armor or shield or footwear) and resname in ARMOR_RESNAME_BONI:
                resinfo = ARMOR_RESNAME_BONI[resname]
                if MATERIALPREFIX in resinfo:
                    prefix1 = resinfo[MATERIALPREFIX]
            if weapon and resname in WEAPON_RESNAME_BONI:
                resinfo = WEAPON_RESNAME_BONI[resname]
                if MATERIALPREFIX in resinfo:
                    prefix1 = resinfo[MATERIALPREFIX]
        elif object.hasstrproperty('resname'):
            resname = str(object.getstrproperty('resname'))
            if (armor or shield or footwear) and resname in ARMOR_RESNAME_BONI:
                resinfo = ARMOR_RESNAME_BONI[resname]
                if MATERIALPREFIX in resinfo:
                    prefix1 = resinfo[MATERIALPREFIX]
            if weapon and resname in WEAPON_RESNAME_BONI:
                resinfo = WEAPON_RESNAME_BONI[resname]
                if MATERIALPREFIX in resinfo:
                    prefix1 = resinfo[MATERIALPREFIX]

        prefix2 = None
        if object.hastag('resname2'):
            resname2 = str(object.gettag('resname2'))
            if (armor or shield
                    or footwear) and resname2 in ARMOR_RESNAME_BONI:
                resinfo = ARMOR_RESNAME_BONI[resname2]
                if MATERIALPREFIX in resinfo:
                    prefix2 = resinfo[MATERIALPREFIX]
            if weapon and resname2 in WEAPON_RESNAME_BONI:
                resinfo = WEAPON_RESNAME_BONI[resname2]
                if MATERIALPREFIX in resinfo:
                    prefix2 = resinfo[MATERIALPREFIX]
        elif object.hasstrproperty('resname2'):
            resname2 = str(object.getstrproperty('resname2'))
            if (armor or shield
                    or footwear) and resname2 in ARMOR_RESNAME_BONI:
                resinfo = ARMOR_RESNAME_BONI[resname2]
                if MATERIALPREFIX in resinfo:
                    prefix2 = resinfo[MATERIALPREFIX]
            if weapon and resname2 in WEAPON_RESNAME_BONI:
                resinfo = WEAPON_RESNAME_BONI[resname2]
                if MATERIALPREFIX in resinfo:
                    prefix2 = resinfo[MATERIALPREFIX]

        if len(object.name) == 0:
            itemname = '#' + str(1020000 + object.id)
        else:
            itemname = object.name

        if prefix1 and prefix2:
            tooltip.reset()
            tooltip.add(1053099, "%s %s\t%s" % (prefix1, prefix2, itemname))
        elif prefix1 and not prefix2:
            tooltip.reset()
            tooltip.add(1053099, "%s\t%s" % (prefix1, itemname))
        elif not prefix1 and prefix2:
            tooltip.reset()
            tooltip.add(1053099, "%s\t%s" % (prefix2, itemname))

    # Exceptional item?
    if object.hastag('exceptional'):
        tooltip.add(1060636, '')

        # 1050043: Crafted by ~param~
        serial = int(object.gettag('exceptional'))
        crafter = wolfpack.findchar(serial)
        if crafter:
            tooltip.add(1050043, crafter.name)
    if object.hastag('arcane'):
        tooltip.add(
            1061837, "%s\t%s" %
            (object.gettag('arcane'), object.gettag('maxArcaneCharges'))
        )  # arcane charges: ~1_val~ / ~2_val~
    if object.hasintproperty('artifact_rarity'):
        tooltip.add(1061078, "%s" % object.getintproperty('artifact_rarity'))
    # Only Armors and Weapons have durability
    if weapon or armor or shield:
        tooltip.add(1060639, "%u\t%u" % (object.health, object.maxhealth))

        durabilitybonus = properties.fromitem(object, DURABILITYBONUS)
        if durabilitybonus:
            if durabilitybonus > 0:
                tooltip.add(1060410, '+' + str(durabilitybonus))
            else:
                tooltip.add(1060410, str(durabilitybonus))

    # Weapon specific properties
    if weapon:
        # Leeching
        leech = properties.fromitem(object, LIFELEECH)
        if leech:
            tooltip.add(1060422, str(leech))
        leech = properties.fromitem(object, STAMINALEECH)
        if leech:
            tooltip.add(1060430, str(leech))
        leech = properties.fromitem(object, MANALEECH)
        if leech:
            tooltip.add(1060427, str(leech))

        # Splash
        for (effect, cliloc) in {
                SPLASHPHYSICAL: 1060428,
                SPLASHFIRE: 1060419,
                SPLASHCOLD: 1060416,
                SPLASHPOISON: 1060429,
                SPLASHENERGY: 1060418
        }.items():
            effect = properties.fromitem(object, effect)
            if effect > 0:
                tooltip.add(cliloc, str(effect))

        # Hit Effects
        for (effect, cliloc) in {
                HITMAGICARROW: 1060426,
                HITHARM: 1060421,
                HITFIREBALL: 1060420,
                HITLIGHTNING: 1060423,
                HITDISPEL: 1060417,
                HITLOWERDEFENSE: 1060425,
                HITLOWERATTACK: 1060424
        }.items():
            effect = properties.fromitem(object, effect)
            if effect > 0:
                tooltip.add(cliloc, str(effect))

        # Slayer
        slayer = properties.fromitem(object, SLAYER)
        if slayer != '':
            slayer = system.slayer.findEntry(slayer)
            if slayer:
                tooltip.add(slayer.name, '')

        # Balanced
        balanced = properties.fromitem(object, BALANCED)
        if balanced:
            tooltip.add(1072792, '')

        # One or twohanded weapon
        if object.twohanded:
            tooltip.add(1061171, '')
        else:
            tooltip.add(1061824, '')

        # Used weaponskill
        skill = weaponskill(viewer, object)
        if skill == SWORDSMANSHIP:
            tooltip.add(1061172, '')
        elif skill == MACEFIGHTING:
            tooltip.add(1061173, '')
        elif skill == FENCING:
            tooltip.add(1061174, '')
        elif skill == ARCHERY:
            tooltip.add(1061175, '')
        #elif skill == WRESTLING:
        #	tooltip.add(1061172, '')

        # Special weapon range
        if object.hasintproperty('range') or object.hastag('range'):
            if object.hastag('range'):
                weaponrange = int(object.gettag('range'))
            else:
                weaponrange = int(object.getintproperty('range', 12))
            if weaponrange > 1:
                tooltip.add(1061169, str(weaponrange))

        # Max-Mindamage
        mindamage = object.getintproperty('mindamage', 1)
        if object.hastag('mindamage'):
            mindamage = int(object.gettag('mindamage'))
        maxdamage = object.getintproperty('maxdamage', 2)
        if object.hastag('maxdamage'):
            maxdamage = int(object.gettag('maxdamage'))
        tooltip.add(1061168, "%u\t%u" % (mindamage, maxdamage))

        # Speed
        speed = object.getintproperty('speed', 10)
        if object.hastag('speed'):
            speed = int(object.gettag('speed'))
        tooltip.add(1061167, str(speed))

        # Physical Damage Distribution
        fire = properties.fromitem(object, DAMAGE_FIRE)
        cold = properties.fromitem(object, DAMAGE_COLD)
        poison = properties.fromitem(object, DAMAGE_POISON)
        energy = properties.fromitem(object, DAMAGE_ENERGY)

        # This must always total 100
        physical = 100 - (fire + cold + poison + energy)
        if (physical + fire + cold + poison + energy) != 100:
            physical = 100
            fire = 0
            cold = 0
            poison = 0
            energy = 0

        if physical:
            tooltip.add(1060403, str(physical))

        if fire:
            tooltip.add(1060405, str(fire))

        if cold:
            tooltip.add(1060404, str(cold))

        if poison:
            tooltip.add(1060406, str(poison))

        if energy:
            tooltip.add(1060407, str(energy))

        if object.hastag('poisoning_uses'):
            poisoning_uses = int(object.gettag('poisoning_uses'))
            if poisoning_uses > 0:
                tooltip.add(1017383, '')

    if weapon or shield:
        # Spell Channeling
        spellchanneling = properties.fromitem(object, SPELLCHANNELING)
        if spellchanneling:
            tooltip.add(1060482, "")
    else:
        spellchanneling = False

    # Those are only relevant if its not a shield/weapon or for spellchanneling items
    if (not weapon and not shield) or spellchanneling:
        castrecovery = properties.fromitem(object, CASTRECOVERYBONUS)

        if castrecovery:
            tooltip.add(1060412, str(castrecovery))

        castspeed = properties.fromitem(object, CASTSPEEDBONUS)

        if castspeed:
            tooltip.add(1060413, str(castspeed))

        spelldamagebonus = properties.fromitem(object, SPELLDAMAGEBONUS)

        if spelldamagebonus:
            tooltip.add(1060483, str(spelldamagebonus))

    physical = properties.fromitem(object, RESISTANCE_PHYSICAL)
    fire = properties.fromitem(object, RESISTANCE_FIRE)
    cold = properties.fromitem(object, RESISTANCE_COLD)
    poison = properties.fromitem(object, RESISTANCE_POISON)
    energy = properties.fromitem(object, RESISTANCE_ENERGY)

    if physical:
        tooltip.add(1060448, str(physical))

    if fire:
        tooltip.add(1060447, str(fire))

    if cold:
        tooltip.add(1060445, str(cold))

    if poison:
        tooltip.add(1060449, str(poison))

    if energy:
        tooltip.add(1060446, str(energy))

    modifiers(object, tooltip)

    lowermana = properties.fromitem(object, LOWERMANACOST)
    if lowermana:
        tooltip.add(1060433, str(lowermana))

    lowerreags = properties.fromitem(object, LOWERREAGENTCOST)
    if lowerreags:
        tooltip.add(1060434, str(lowerreags))

    requirements(object, tooltip)

    # Skill Boni (1-5)
    for i in range(0, 5):
        if object.hastag('skillbonus_%u' % i):
            try:
                (skill, bonus) = object.gettag('skillbonus_%u' % i).split(',')
                (skill, bonus) = (int(skill), int(bonus))

                if bonus == 0 or skill < 0 or skill >= ALLSKILLS:
                    continue

                # Add a Bonus for the skill
                tooltip.add(1060451 + i,
                            "#%u\t%u" % (1044060 + skill, int(bonus / 10)))
            except:
                object.deltag('skillbonus_%u' % i)
                continue
    return False
コード例 #21
0
def onWearItem(player, wearer, item, layer):
    if wearer.socket and wearer.socket.hastag('block_equip'):
        expire = int(wearer.socket.gettag('block_equip'))
        if expire < wolfpack.time.currenttime():
            wearer.socket.deltag('block_equip')
        else:
            if player == wearer:
                player.socket.sysmessage(
                    tr('You cannot equip another so soon after being disarmed.'
                       ))
            else:
                player.socket.sysmessage(
                    tr('They cannot equip another so soon after being disarmed.'
                       ))
            return True

    lower = properties.fromitem(item, LOWERREQS) / 100.0

    req_str = item.getintproperty('req_strength', 0)
    if item.hastag('req_strength'):
        req_str = int(item.gettag('req_strength'))
    if lower:
        req_str = int(ceil(req_str) * (1.0 - lower))

    req_dex = item.getintproperty('req_dexterity', 0)
    if item.hastag('req_dexterity'):
        req_dex = int(item.gettag('req_dexterity'))
    if lower:
        req_dex = int(ceil(req_dex) * (1.0 - lower))

    req_int = item.getintproperty('req_intelligence', 0)
    if item.hastag('req_intelligence'):
        req_int = int(item.gettag('req_intelligence'))
    if lower:
        req_int = int(ceil(req_int) * (1.0 - lower))

    if wearer.strength < req_str:
        if player != wearer:
            player.socket.sysmessage(
                tr('This person can\'t wear that item, seems not strong enough.'
                   ))
        else:
            player.socket.clilocmessage(500213)
        return True

    if wearer.dexterity < req_dex:
        if player != wearer:
            player.socket.sysmessage(
                tr('This person can\'t wear that item, seems not agile enough.'
                   ))
        else:
            player.socket.clilocmessage(502077)
        return True

    if wearer.intelligence < req_int:
        if player != wearer:
            player.socket.sysmessage(
                tr('This person can\'t wear that item, seems not smart enough.'
                   ))
        else:
            player.socket.sysmessage(
                tr('You are not intelligent enough to equip this item.'))
        return True

    # Reject equipping an item with durability 1 or less
    # if it's an armor, shield or weapon
    armor = properties.itemcheck(item, ITEM_ARMOR)
    weapon = properties.itemcheck(item, ITEM_WEAPON)
    shield = properties.itemcheck(item, ITEM_SHIELD)

    if (armor or weapon or shield) and item.health < 1:
        player.socket.sysmessage(
            tr('You need to repair this before using it again.'))
        return True

    return False
コード例 #22
0
ファイル: aos.py プロジェクト: BackupTheBerlios/wolfpack-svn
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
コード例 #23
0
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
コード例 #24
0
    def applyproperties(self, player, arguments, item, exceptional):
        # Use all available resources if the item we make is
        # flagged as "stackable".
        if self.stackable:
            backpack = player.getbackpack()
            count = -1
            # count  how many items we could make
            for (materials, amount, name) in self.materials:
                items = backpack.countitems(materials)
                if count == -1:
                    count = items / amount
                else:
                    count = min(count, items / amount)

            # count  how many items we could make
            if (self.submaterial1 > 0):
                material = self.parent.getsubmaterial1used(player, arguments)
                material = self.parent.submaterials1[material]
                items = backpack.countitems(material[3])
                if count == -1:
                    count = items / self.submaterial1
                else:
                    count = min(count, items / self.submaterial1)

            # consume material
            for (materials, amount, name) in self.materials:
                backpack.removeitems(materials, int(count * amount))

            # consume material
            if self.submaterial1 > 0:
                material = self.parent.getsubmaterial1used(player, arguments)
                material = self.parent.submaterials1[material]
                backpack.removeitems(material[3],
                                     int(count * self.submaterial1))

            if count != -1:
                item.amount += (count * self.amount)
            else:
                item.amount = 1 + count
            item.update()

            # Resend weight
            player.socket.resendstatus()

        else:
            if extended_carpentry:
                if self.submaterial1 > 0:
                    material = self.parent.getsubmaterial1used(
                        player, arguments)
                    material = self.parent.submaterials1[material]
                    item.color = material[4]
                    item.settag('resname', material[5])

            # Apply one-time boni
            healthbonus = properties.fromitem(item, DURABILITYBONUS)
            if healthbonus != 0:
                bonus = int(ceil(item.maxhealth * (healthbonus / 100.0)))
                item.maxhealth = max(1, item.maxhealth + bonus)
                item.health = item.maxhealth

            # increase damage of exceptional weapons
            if exceptional:
                if itemcheck(item, ITEM_WEAPON):
                    # Increase the damage bonus by 20%
                    bonus = fromitem(item, DAMAGEBONUS)
                    bonus += 20
                    item.settag('aos_boni_damage', bonus)
コード例 #25
0
def onShowTooltip(viewer, object, tooltip):
	armor = properties.itemcheck(object, ITEM_ARMOR)
	weapon = properties.itemcheck(object, ITEM_WEAPON)
	shield = properties.itemcheck(object, ITEM_SHIELD)

	if (armor or weapon or shield) and object.amount == 1:
		# Reinsert the name if we need an ore prefix
		prefix1 = None
		if object.hastag('resname'):
			resname = str(object.gettag('resname'))
			if (armor or shield) and wolfpack.armorinfo.ARMOR_RESNAME_BONI.has_key(resname):
				resinfo = wolfpack.armorinfo.ARMOR_RESNAME_BONI[resname]
				if resinfo.has_key(MATERIALPREFIX):
					prefix1 = resinfo[MATERIALPREFIX]
			if weapon and wolfpack.weaponinfo.WEAPON_RESNAME_BONI.has_key(resname):
				resinfo = wolfpack.weaponinfo.WEAPON_RESNAME_BONI[resname]
				if resinfo.has_key(MATERIALPREFIX):
					prefix1 = resinfo[MATERIALPREFIX]
		elif object.hasstrproperty( 'resname' ):
			resname = str( object.getstrproperty( 'resname' ) )
			if (armor or shield) and wolfpack.armorinfo.ARMOR_RESNAME_BONI.has_key(resname):
				resinfo = wolfpack.armorinfo.ARMOR_RESNAME_BONI[resname]
				if resinfo.has_key(MATERIALPREFIX):
					prefix1 = resinfo[MATERIALPREFIX]
			if weapon and wolfpack.weaponinfo.WEAPON_RESNAME_BONI.has_key(resname):
				resinfo = wolfpack.weaponinfo.WEAPON_RESNAME_BONI[resname]
				if resinfo.has_key(MATERIALPREFIX):
					prefix1 = resinfo[MATERIALPREFIX]

		prefix2 = None
		if object.hastag('resname2'):
			resname2 = str(object.gettag('resname2'))
			if (armor or shield) and wolfpack.armorinfo.ARMOR_RESNAME_BONI.has_key(resname2):
				resinfo = wolfpack.armorinfo.ARMOR_RESNAME_BONI[resname2]
				if resinfo.has_key(MATERIALPREFIX):
					prefix2 = resinfo[MATERIALPREFIX]
			if weapon and wolfpack.weaponinfo.WEAPON_RESNAME_BONI.has_key(resname2):
				resinfo = wolfpack.weaponinfo.WEAPON_RESNAME_BONI[resname2]
				if resinfo.has_key(MATERIALPREFIX):
					prefix2 = resinfo[MATERIALPREFIX]
		elif object.hasstrproperty( 'resname2' ):
			resname2 = str( object.getstrproperty( 'resname2' ) )
			if (armor or shield) and wolfpack.armorinfo.ARMOR_RESNAME_BONI.has_key(resname2):
				resinfo = wolfpack.armorinfo.ARMOR_RESNAME_BONI[resname2]
				if resinfo.has_key(MATERIALPREFIX):
					prefix2 = resinfo[MATERIALPREFIX]
			if weapon and wolfpack.weaponinfo.WEAPON_RESNAME_BONI.has_key(resname2):
				resinfo = wolfpack.weaponinfo.WEAPON_RESNAME_BONI[resname2]
				if resinfo.has_key(MATERIALPREFIX):
					prefix2 = resinfo[MATERIALPREFIX]

		if len(object.name) == 0:
			itemname = '#' + str(1020000 + object.id)
		else:
			itemname = object.name

		if prefix1 and prefix2:
			tooltip.reset()
			tooltip.add(1053099, "%s %s\t%s" % (prefix1, prefix2, itemname))
		elif prefix1 and not prefix2:
			tooltip.reset()
			tooltip.add(1053099, "%s\t%s" % (prefix1, itemname))
		elif not prefix1 and prefix2:
			tooltip.reset()
			tooltip.add(1053099, "%s\t%s" % (prefix2, itemname))

	# Exceptional item?
	if object.hastag('exceptional'):
		tooltip.add(1060636, '')

		# 1050043: Crafted by ~param~
		serial = int(object.gettag('exceptional'))
		crafter = wolfpack.findchar(serial)
		if crafter:
			tooltip.add(1050043, crafter.name)

	# Only Armors and Weapons have durability
	if weapon or armor or shield:
		tooltip.add(1060639, "%u\t%u" % (object.health, object.maxhealth))

		durabilitybonus = properties.fromitem(object, DURABILITYBONUS)
		if durabilitybonus:
			if durabilitybonus > 0:
				tooltip.add(1060410, '+' + str(durabilitybonus))
			else:
				tooltip.add(1060410, str(durabilitybonus))

	# Weapon specific properties
	if weapon:
		# One or twohanded weapon
		if object.twohanded:
			tooltip.add(1061171, '')
		else:
			tooltip.add(1061824, '')

		# Used weaponskill
		skill = weaponskill(viewer, object)
		if skill == SWORDSMANSHIP:
			tooltip.add(1061172, '')
		elif skill == MACEFIGHTING:
			tooltip.add(1061173, '')
		elif skill == FENCING:
			tooltip.add(1061174, '')
		elif skill == ARCHERY:
			tooltip.add(1061175, '')

		# Special weapon range
		if object.hasintproperty( 'range' ) or object.hastag( 'range' ):			
			if object.hastag( 'range' ):
				weaponrange = int( object.gettag( 'range' ) )
			else:
				weaponrange = int( object.getintproperty( 'range', 12 ) )
			if weaponrange > 1:
				tooltip.add( 1061169, str(weaponrange) )

		# Max-Mindamage
		mindamage = object.getintproperty( 'mindamage', 1 )
		if object.hastag( 'mindamage' ):
			mindamage = int( object.gettag( 'mindamage' ) )
		maxdamage = object.getintproperty( 'maxdamage', 2 )
		if object.hastag( 'maxdamage' ):
			mindamage = int( object.gettag( 'maxdamage' ) )
		tooltip.add( 1061168, "%u\t%u" % ( mindamage, maxdamage ) )

		# Speed
		speed = object.getintproperty( 'speed', 10 )
		if object.hastag( 'speed' ):
			speed = int( object.gettag( 'speed' ) )
		tooltip.add(1061167, str(speed))

		# Physical Damage Distribution
		fire = properties.fromitem(object, DAMAGE_FIRE)
		cold = properties.fromitem(object, DAMAGE_COLD)
		poison = properties.fromitem(object, DAMAGE_POISON)
		energy = properties.fromitem(object, DAMAGE_ENERGY)

		# This must always total 100
		physical = 100 - (fire + cold + poison + energy)
		if (physical + fire + cold + poison + energy) != 100:
			physical = 100
			fire = 0
			cold = 0
			poison = 0
			energy = 0

		if physical:
			tooltip.add(1060403, str(physical))

		if fire:
			tooltip.add(1060405, str(fire))

		if cold:
			tooltip.add(1060404, str(cold))

		if poison:
			tooltip.add(1060406, str(poison))

		if energy:
			tooltip.add(1060407, str(energy))

		# Spell Channeling
		spellchanneling = properties.fromitem(object, SPELLCHANNELING)
		if spellchanneling != 0:
			tooltip.add(1060482, "")

	physical = properties.fromitem(object, RESISTANCE_PHYSICAL)
	fire = properties.fromitem(object, RESISTANCE_FIRE)
	cold = properties.fromitem(object, RESISTANCE_COLD)
	poison = properties.fromitem(object, RESISTANCE_POISON)
	energy = properties.fromitem(object, RESISTANCE_ENERGY)

	if physical:
		tooltip.add(1060448, str(physical))

	if fire:
		tooltip.add(1060447, str(fire))

	if cold:
		tooltip.add(1060445, str(cold))

	if poison:
		tooltip.add(1060449, str(poison))

	if energy:
		tooltip.add(1060446, str(energy))

	modifiers(object, tooltip)

	lower = properties.fromitem(object, LOWERREQS)
	if lower:
		tooltip.add(1060435, str(lower))
	lower /= 100.0

	# Tag will override.
	req_str = object.getintproperty( 'req_strength', 0 )
	if object.hastag( 'req_strength' ):
		req_str = int( object.gettag( 'req_strength' ) )

	if lower:
		req_str = int(ceil(req_str) * (1.0 - lower))
	if req_str:
		tooltip.add(1061170, str(req_str))
コード例 #26
0
def blockdamage(defender, damage):
    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 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()

    # we can't gain parrying 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:
            if random.randint(0, 2) == 0:
                wear = random.randint(0, 1)
                if wear > 0 and shield.maxhealth > 0:
                    if shield.health >= wear:
                        shield.health -= wear
                        wear = 0
                    else:
                        wear -= shield.hitpoints
                        shield.hitpoints = 0

                    if wear > 0:
                        if shield.maxhitpoints > wear:
                            shield.maxhitpoints -= wear
                            defender.message(
                                1061121,
                                '')  # Your equipment is severely damaged.
                        else:
                            shield.delete()
                    if shield:
                        shield.resendtooltip()

            # 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
コード例 #27
0
	def applyproperties(self, player, arguments, item, exceptional):
		# Use all available resources if the item we make is
		# flagged as "stackable".
		if self.stackable:
			backpack = player.getbackpack()
			count = -1
			# count  how many items we could make
			for (materials, amount, name) in self.materials:
				items = backpack.countitems(materials)
				if count == -1:
					count = items / amount
				else:
					count = min(count, items / amount)

			# count  how many items we could make
			if( self.submaterial1 > 0 ):
				material = self.parent.getsubmaterial1used(player, arguments)
				material = self.parent.submaterials1[material]
				items = backpack.countitems(material[3])
				if count == -1:
					count = items / self.submaterial1
				else:
					count = min(count, items / self.submaterial1)

			# consume material
			for (materials, amount, name) in self.materials:
				backpack.removeitems( materials, int(count * amount) )

			# consume material
			if self.submaterial1 > 0:
				material = self.parent.getsubmaterial1used(player, arguments)
				material = self.parent.submaterials1[material]
				backpack.removeitems( material[3], int(count * self.submaterial1) )

			if count != -1:
				item.amount += (count * self.amount)
			else:
				item.amount = 1 + count
			item.update()

			# Resend weight
			player.socket.resendstatus()

		else:
			if extended_carpentry:
				if self.submaterial1 > 0:
					material = self.parent.getsubmaterial1used(player, arguments)
					material = self.parent.submaterials1[material]
					item.color = material[4]
					item.settag('resname', material[5])

			# Apply one-time boni
			healthbonus = properties.fromitem(item, DURABILITYBONUS)
			if healthbonus != 0:
				bonus = int( ceil(item.maxhealth * (healthbonus / 100.0)) )
				item.maxhealth = max(1, item.maxhealth + bonus)
				item.health = item.maxhealth

			# increase damage of exceptional weapons
			if exceptional:
				if itemcheck(item, ITEM_WEAPON):
					# Increase the damage bonus by 20%
					bonus = fromitem(item, DAMAGEBONUS)
					bonus += 20
					item.settag('aos_boni_damage', bonus)
コード例 #28
0
ファイル: aos.py プロジェクト: BackupTheBerlios/wolfpack-svn
def blockdamage(defender, damage):
	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 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()

	# we can't gain parrying 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:
			if random.randint(0, 2) == 0:
				wear = random.randint(0, 1)
				if wear > 0 and shield.maxhealth > 0:
					if shield.health >= wear:
						shield.health -= wear
						wear = 0
					else:
						wear -= shield.hitpoints
						shield.hitpoints = 0

					if wear > 0:
						if shield.maxhitpoints > wear:
							shield.maxhitpoints -= wear
							defender.message(1061121, '') # Your equipment is severely damaged.
						else:
							shield.delete()
					if shield:
						shield.resendtooltip()

			# 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
コード例 #29
0
ファイル: aos.py プロジェクト: BackupTheBerlios/wolfpack-svn
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
コード例 #30
0
ファイル: carpentry.py プロジェクト: thooge/Wolfpack
    def applyproperties(self, player, arguments, item, exceptional):
        # Stackable items consume all resources
        if self.stackable:
            backpack = player.getbackpack()
            count = -1
            for (materials, amount, name) in self.materials:
                items = backpack.countitems(materials)
                if count == -1:
                    count = items / amount
                else:
                    count = min(count, items / amount)
            for (materials, amount, name) in self.materials:
                backpack.removeitems(materials, count)
            if count != -1:
                item.amount += count
            else:
                item.amount = 1 + count
            item.update()

        # All carpentry items crafted out of ingots keep a resname
        if self.retaincolor and self.submaterial1 > 0:
            material = self.parent.getsubmaterial1used(player, arguments)
            material = self.parent.submaterials1[material]
            item.color = material[4]
            item.settag('resname', material[5])

        if self.submaterial2 > 0:
            material = self.parent.getsubmaterial2used(player, arguments)
            material = self.parent.submaterials2[material]
            if not self.submaterial1:
                item.color = material[4]
            item.settag('resname2', material[5])

        # Apply one-time boni
        healthbonus = properties.fromitem(item, DURABILITYBONUS)
        if healthbonus != 0:
            bonus = int(math.ceil(item.maxhealth * (healthbonus / 100.0)))
            item.maxhealth = max(1, item.maxhealth + bonus)
            item.health = item.maxhealth

        # Distribute another 6 points randomly between the resistances an armor alread
        # has. There are no tailored weapons.
        if exceptional:
            if properties.itemcheck(item, ITEM_SHIELD):
                # Copy all the values to tags
                boni = [0, 0, 0, 0, 0]

                for i in range(0, 6):
                    boni[random.randint(0, 4)] += 1

                item.settag(
                    'res_physical',
                    properties.fromitem(item, RESISTANCE_PHYSICAL) + boni[0])
                item.settag(
                    'res_fire',
                    properties.fromitem(item, RESISTANCE_FIRE) + boni[1])
                item.settag(
                    'res_cold',
                    properties.fromitem(item, RESISTANCE_COLD) + boni[2])
                item.settag(
                    'res_energy',
                    properties.fromitem(item, RESISTANCE_ENERGY) + boni[3])
                item.settag(
                    'res_poison',
                    properties.fromitem(item, RESISTANCE_POISON) + boni[4])

            elif properties.itemcheck(item, ITEM_WEAPON):
                # Increase the damage bonus by 20%
                bonus = properties.fromitem(item, DAMAGEBONUS)
                bonus += 20
                item.settag('aos_boni_damage', bonus)

            # Exceptional Containers get a key
            if item.type == 1:
                if item.baseid == '9aa' or item.baseid == '9a9' or item.baseid == 'e3f' or item.baseid == 'e3d' or item.baseid == 'e42' or item.baseid == 'a4d' or item.baseid == 'a4f':
                    createlockandkey(item)