예제 #1
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)
예제 #2
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.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)