コード例 #1
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])
コード例 #2
0
ファイル: aos.py プロジェクト: BackupTheBerlios/wolfpack-svn
def damagetypes(char, defender):
	fire = 0
	cold = 0
	poison = 0
	energy = 0

	weapon = char.getweapon()

	# See if the npc has specific energy distribution values.
	if char.npc and not weapon:
		fire = char.getintproperty( 'dmg_fire', 0 )
		if char.hastag('dmg_fire'):
			fire = int(char.gettag('dmg_fire'))

		cold = char.getintproperty( 'dmg_cold', 0 )
		if char.hastag('dmg_cold'):
			cold = int(char.gettag('dmg_cold'))

		poison = char.getintproperty( 'dmg_poison', 0 )
		if char.hastag('dmg_poison'):
			poison = int(char.gettag('dmg_poison'))

		energy = char.getintproperty( 'dmg_energy', 0 )
		if char.hastag('dmg_energy'):
			energy = int(char.gettag('dmg_energy'))
	elif weapon:
		if magic.chivalry.isConsecrated(weapon):
			(physical, fire, cold, poison, energy) = consecratedweapon( defender )

		else:
			fire = properties.fromitem(weapon, DAMAGE_FIRE)

			cold = properties.fromitem(weapon, DAMAGE_COLD)

			poison = properties.fromitem(weapon, DAMAGE_POISON)

			energy = properties.fromitem(weapon, DAMAGE_ENERGY)

	# See if the energy distribution is correct
	if fire + cold + poison + energy > 100:
		fire = 0
		cold = 0
		poison = 0
		energy = 0
		if weapon:
			if DEBUG_COMBAT_INFO == 1:
				char.log(LOG_WARNING, "Character is using broken weapon (0x%x) with wrong damage types.\n" % weapon.serial)
		else:
			if DEBUG_COMBAT_INFO == 1:
				char.log(LOG_WARNING, "NPC (0x%x) has wrong damage types.\n" % char.serial)

	physical = 100 - (fire + cold + poison + energy)

	return (physical, fire, cold, poison, energy)
コード例 #3
0
def hasHandFree( char, item ):
	firsthand = char.itemonlayer( 1 )
	secondhand = char.itemonlayer( 2 )

	if not firsthand and not secondhand:
		return True

	if firsthand and not secondhand and not firsthand.twohanded or properties.fromitem(firsthand, BALANCED):
		return True

	if not firsthand and secondhand and not secondhand.twohanded or properties.fromitem(secondhand, BALANCED):
		return True
	return False
コード例 #4
0
def modifiers(object, tooltip):
	modifiers = {
		"boni_dex": 1060409,
		"boni_int": 1060432,
		"boni_str": 1060485,
		"remaining_uses": 1060584,
		"aos_boni_damage": 1060401,
		"regenhitpoints": 1060444,
		"regenstamina": 1060443,
		"regenmana": 1060440,
	}

	for (tag, cliloc) in modifiers.items():
		if object.hastag(tag):
			tooltip.add(cliloc, str(object.gettag(tag)))

	reflectphysical = properties.fromitem(object, REFLECTPHYSICAL)

	if reflectphysical:
		tooltip.add(1060442, str(reflectphysical))

	if object.hastag("bestskill"):
		tooltip.add(1060400, "")

	if object.hastag('magearmor'):
		tooltip.add(1060437, "")
コード例 #5
0
	def applyproperties(self, player, arguments, item, exceptional):
		item.decay = 1

		# See if this item
		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

		# Reduce the uses remain count
		checktool(player, wolfpack.finditem(arguments[0]), 1)
コード例 #6
0
def onWearItem(player, wearer, item, layer):
	lower = properties.fromitem(item, LOWERREQS) / 100.0

	req_str = properties.fromitem(item, REQSTR)
	if lower:
		req_str = int(ceil(req_str) * (1.0 - lower))

	req_dex = properties.fromitem(item, REQDEX)
	if lower:
		req_dex = int(ceil(req_dex) * (1.0 - lower))

	req_int = properties.fromitem(item, REQINT)
	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
コード例 #7
0
def onShowTooltip(viewer, object, tooltip):
	slayer = properties.fromitem(object, SLAYER)
	if slayer != '':
		slayers = slayer.split(',')
		for slayer in slayers:
			slayer = system.slayer.findEntry(slayer)
			if slayer:
				tooltip.add(slayer.name, '')
コード例 #8
0
def playmisssound(attacker, defender):
	weapon = attacker.getweapon()
	sounds = properties.fromitem(weapon, MISSSOUND)

	# No sounds
	if len(sounds) == 0:
		return

	attacker.soundeffect(random.choice(sounds))
コード例 #9
0
ファイル: aos.py プロジェクト: BackupTheBerlios/wolfpack-svn
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
コード例 #10
0
def weaponskill(char, weapon, bestskill = False):
	if not weapon:
		return WRESTLING
	else:
		if bestskill and properties.fromitem(weapon, BESTSKILL):
			return getbestskill(char)

		if not WEAPON_INFORMATION.has_key(weapon.type):
			return WRESTLING
		else:
			return WEAPON_INFORMATION[weapon.type][SKILL]
コード例 #11
0
ファイル: aos.py プロジェクト: BackupTheBerlios/wolfpack-svn
def checkSlaying(weapon, defender):
	slayer = properties.fromitem(weapon, SLAYER)
	if slayer == '':
		return False
				
	slayer = system.slayer.findEntry(slayer)
	
	if not slayer:
		return False
		
	return slayer.slays(defender)
コード例 #12
0
def checkSlaying(weapon, defender):
    slayer = properties.fromitem(weapon, SLAYER)
    if slayer == '':
        return False

    slayer = system.slayer.findEntry(slayer)

    if not slayer:
        return False

    return slayer.slays(defender)
コード例 #13
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)
コード例 #14
0
def modifiers(object, tooltip):
	modifiers = {
		"boni_dex": 1060409,
		"boni_int": 1060432,
		"boni_str": 1060485,
		"remaining_uses": 1060584,
		"aos_boni_damage": 1060401,
		"regenhitpoints": 1060444,
		"regenstamina": 1060443,
		"regenmana": 1060440,
	}

	for (tag, cliloc) in modifiers.items():
		if object.hastag(tag):
			tooltip.add(cliloc, str(object.gettag(tag)))

	reflectphysical = properties.fromitem(object, REFLECTPHYSICAL)

	if reflectphysical:
		tooltip.add(1060442, str(reflectphysical))
		
	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))	

	if object.hastag("bestskill"):
		tooltip.add(1060400, "")

	if object.hastag('magearmor'):
		tooltip.add(1060437, "")
コード例 #15
0
ファイル: utilities.py プロジェクト: thooge/Wolfpack
def playhitsound(attacker, defender):
	weapon = attacker.getweapon()

	# Play a special sound for monsters
	if not weapon and attacker.id < 0x190:
		attacker.sound(SND_ATTACK)
	else:
		sounds = properties.fromitem(weapon, HITSOUND)

		# Only play a sound if there are any
		if len(sounds) != 0:
			attacker.soundeffect(random.choice(sounds))
コード例 #16
0
def playhitsound(attacker, defender):
	weapon = attacker.getweapon()

	# Play a special sound for monsters
	if not weapon and attacker.id < 0x190:
		attacker.sound(SND_ATTACK)
	else:
		sounds = properties.fromitem(weapon, HITSOUND)

		# Only play a sound if there are any
		if len(sounds) != 0:
			attacker.soundeffect(random.choice(sounds))
コード例 #17
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						
コード例 #18
0
ファイル: aos.py プロジェクト: BackupTheBerlios/wolfpack-svn
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
コード例 #19
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
コード例 #20
0
ファイル: musicianship.py プロジェクト: thooge/Wolfpack
def GetDifficultyFor(player, instrument, target):
    # Difficulty TODO: Add another 100 points for each of the following abilities:
    #	- Radiation or Aura Damage (Heat, Cold etc.)
    #	- Summoning Undead
    #
    totalskills = 0
    val = target.hitpoints + target.stamina + target.mana
    skills = target.skill
    for i in range(0, ALLSKILLS):
        totalskills += skills[i] / 100.0

    if val > 700:
        val = 700 + ((val - 700) / 3.66667)

    # Target is Magery Creature
    if target.ai == "Monster_Mage" and target.skill[MAGERY] > 50:
        val += 100

    #if IsFireBreathingCreature( bc ):
    #	val += 100

    if IsPoisonImmune(target):
        val += 100

    if target.id == 317:
        val += 100

    val += (target.getintproperty('hit_poison_level', 0) + 1) * 20

    val /= 10

    #if ( bc != null && bc.IsParagon )
    #	val += 40.0;

    if instrument.hastag('exceptional'):
        val -= 5.0  # 10%

    slayer = properties.fromitem(instrument, SLAYER)
    if slayer != '':
        slayers = slayer.split(',')
        for slayer in slayers:
            slayer = system.slayer.findEntry(slayer)
            if slayer:
                if slayer.slays(target):
                    val -= 10.0  # 20%
                elif slayer.group.opposition.super.slays(
                        target):  # not sure if this is correct
                    val += 10.0  # -20%
    return val
コード例 #21
0
def requirements(object, tooltip):
	# Tag will override.
	lower = properties.fromitem(object, LOWERREQS)
	if lower:
		tooltip.add(1060435, str(lower))
	lower /= 100.0

	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))
コード例 #22
0
def requirements(object, tooltip):
    # Tag will override.
    lower = properties.fromitem(object, LOWERREQS)
    if lower:
        tooltip.add(1060435, str(lower))
    lower /= 100.0

    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))
コード例 #23
0
def GetDifficultyFor( player, instrument, target ):
	# Difficulty TODO: Add another 100 points for each of the following abilities:
	#	- Radiation or Aura Damage (Heat, Cold etc.)
	#	- Summoning Undead
	#
	totalskills = 0
	val = target.hitpoints + target.stamina + target.mana
	skills = target.skill
	for i in range(0, ALLSKILLS):
		totalskills += skills[i] / 100.0

	if val > 700:
		val = 700 + ((val - 700) / 3.66667)

	# Target is Magery Creature
	if target.ai == "Monster_Mage" and target.skill[MAGERY] > 50:
		val += 100

	#if IsFireBreathingCreature( bc ):
	#	val += 100

	if IsPoisonImmune( target ):
		val += 100

	if target.id == 317:
		val += 100

	val += (target.getintproperty('hit_poison_level', 0) + 1) * 20

	val /= 10

	#if ( bc != null && bc.IsParagon )
	#	val += 40.0;

	if instrument.hastag('exceptional'):
		val -= 5.0 # 10%

	slayer = properties.fromitem(instrument, SLAYER)
	if slayer != '':
		slayers = slayer.split(',')
		for slayer in slayers:
			slayer = system.slayer.findEntry(slayer)
			if slayer:
				if slayer.slays(target):
					val -= 10.0 # 20%
				elif slayer.group.opposition.super.slays(target): # not sure if this is correct
					val += 10.0 # -20%
	return val
コード例 #24
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)
コード例 #25
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
コード例 #26
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
コード例 #27
0
ファイル: tinkering.py プロジェクト: thooge/Wolfpack
	def applyproperties(self, player, arguments, item, exceptional):
		item.decay = 1

		# 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()

		# See if this item
		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.name = name_item( item, material )
			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
コード例 #28
0
ファイル: utilities.py プロジェクト: thooge/Wolfpack
def playswinganimation(char, target, weapon):
	char.turnto(target)

	# Monsters
	if char.id < 0x190:
		action = random.randint(4, 6)

		# Anti Blink Bit
		if char.antiblink:
			action += 1

		char.action(action)

	# Humans
	else:
		if weapon:
			action = properties.fromitem(weapon, SWING)
		else:
			action = [0x1f]

		char.action( random.choice(action) )
コード例 #29
0
def playswinganimation(char, target, weapon):
	char.turnto(target)

	# Monsters
	if char.id < 0x190:
		action = random.randint(4, 6)

		# Anti Blink Bit
		if char.antiblink:
			action += 1

		char.action(action)

	# Humans
	else:
		if weapon:
			action = properties.fromitem(weapon, SWING)
		else:
			action = [0x1f]

		char.action( random.choice(action) )
コード例 #30
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)
コード例 #31
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)
コード例 #32
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])
コード例 #33
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)
コード例 #34
0
def modifiers(object, tooltip):
    modifiers = {
        "remaining_uses": 1060584,
    }

    for (tag, cliloc) in modifiers.items():
        if object.hastag(tag):
            tooltip.add(cliloc, str(object.gettag(tag)))

    damagebonus = properties.fromitem(object, DAMAGEBONUS)
    if damagebonus != 0:
        tooltip.add(1060401, str(damagebonus))

    speedbonus = properties.fromitem(object, SPEEDBONUS)
    if speedbonus != 0:
        tooltip.add(1060486, str(speedbonus))

    hitbonus = properties.fromitem(object, HITBONUS)
    if hitbonus != 0:
        tooltip.add(1060415, str(hitbonus))

    defensebonus = properties.fromitem(object, DEFENSEBONUS)
    if defensebonus != 0:
        tooltip.add(1060408, str(defensebonus))

    enhancepotions = properties.fromitem(object, ENHANCEPOTIONS)
    if enhancepotions != 0:
        tooltip.add(1060411, str(enhancepotions))

    reflectphysical = properties.fromitem(object, REFLECTPHYSICAL)

    if reflectphysical:
        tooltip.add(1060442, str(reflectphysical))

    luck = properties.fromitem(object, LUCK)
    if luck != 0:
        tooltip.add(1060436, str(luck))

    bonus = properties.fromitem(object, BONUSSTRENGTH)
    if bonus != 0:
        tooltip.add(1060485, str(bonus))

    bonus = properties.fromitem(object, BONUSDEXTERITY)
    if bonus != 0:
        tooltip.add(1060409, str(bonus))

    bonus = properties.fromitem(object, BONUSINTELLIGENCE)
    if bonus != 0:
        tooltip.add(1060432, str(bonus))

    bonus = properties.fromitem(object, BONUSHITPOINTS)
    if bonus != 0:
        tooltip.add(1060431, str(bonus))

    bonus = properties.fromitem(object, BONUSSTAMINA)
    if bonus != 0:
        tooltip.add(1060484, str(bonus))

    bonus = properties.fromitem(object, BONUSMANA)
    if bonus != 0:
        tooltip.add(1060439, str(bonus))

    regenhitpoints = properties.fromitem(object, REGENHITPOINTS)
    if regenhitpoints:
        tooltip.add(1060444, str(regenhitpoints))

    regenstamina = properties.fromitem(object, REGENSTAMINA)
    if regenstamina:
        tooltip.add(1060443, str(regenstamina))

    regenmana = properties.fromitem(object, REGENMANA)
    if regenmana:
        tooltip.add(1060440, str(regenmana))

    if properties.fromitem(object, BESTSKILL):
        tooltip.add(1060400, "")

    mageweapon = properties.fromitem(object, MAGEWEAPON)
    if mageweapon != 0:
        tooltip.add(1060438, str(mageweapon))

    if properties.fromitem(object, MAGEARMOR) and not object.allowmeditation:
        tooltip.add(1060437, "")

    nightsight = properties.fromitem(object, NIGHTSIGHT)
    if nightsight:
        tooltip.add(1060441, "")

    selfrepair = properties.fromitem(object, SELFREPAIR)
    if selfrepair != 0:
        tooltip.add(1060450, str(selfrepair))
コード例 #35
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
コード例 #36
0
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)

    # Enemy of One (chivalry)
    if attacker.npc:
        if defender.player:
            if defender.hastag("enemyofonetype") and defender.gettag(
                    "enemyofonetype") != attacker.id:
                damage *= 2
    if defender.npc:  # only NPC
        if attacker.player:
            if attacker.hastag("waitingforenemy"):
                attacker.settag("enemyofonetype", defender.id)
                attacker.deltag("waitingforenemy")
            if attacker.hastag("enemyofonetype") and attacker.gettag(
                    "enemyofonetype") == defender.id:
                defender.effect(0x37B9, 10, 5)
                damage += scaledamage(attacker, 50)

    packInstinctBonus = GetPackInstinctBonus(attacker, defender)
    if packInstinctBonus:
        damage += scaledamage(attacker, packInstinctBonus)

    slayer = properties.fromitem(weapon, SLAYER)
    if slayer and slayer == "silver" and magic.necromancy.transformed(
            defender) and not defender.hasscript("magic.horrificbeast"):
        damage += scaledamage(
            attacker, 25
        )  # Every necromancer transformation other than horrific beast takes an additional 25% damage

    # Give the defender a chance to absorb damage
    damage = absorbdamage(defender, damage)
    blocked = damage <= 0

    # If the attack was parried, the ability was wasted
    if AGEOFSHADOWS and blocked:
        if attacker.socket:
            attacker.socket.clilocmessage(1061140)  # Your attack was parried
        clearability(attacker)

    ignorephysical = False
    if ability:
        ignorephysical = ability.ignorephysical

    # Get the damage distribution of the attackers weapon
    (physical, fire, cold, poison, energy) = damagetypes(attacker, defender)
    damagedone = energydamage(defender,
                              attacker,
                              damage,
                              physical,
                              fire,
                              cold,
                              poison,
                              energy,
                              0,
                              DAMAGE_PHYSICAL,
                              ignorephysical=ignorephysical)

    # Wear out the weapon
    if weapon:
        # Leeching
        if not blocked:
            # Making default Leechs to prevent errors

            lifeleech = 0
            staminaleech = 0
            manaleech = 0

            leech = properties.fromitem(weapon, LIFELEECH)
            if leech and leech > random.randint(
                    0, 99) and attacker.maxhitpoints > attacker.hitpoints:
                lifeleech = (damagedone * 30) / 100  # Leech 30% Health

            leech = properties.fromitem(weapon, STAMINALEECH)
            if leech and leech > random.randint(
                    0, 99) and attacker.maxhitpoints > attacker.stamina:
                staminaleech = (damagedone * 100) / 100  # Leech 100% Stamina

            leech = properties.fromitem(weapon, MANALEECH)
            if leech and leech > random.randint(
                    0, 99) and attacker.maxmana > attacker.mana:
                manaleech = (damagedone * 40) / 100  # Leech 40% Mana

            # Now leech life, stamina and mana
            if lifeleech > 0:
                attacker.hitpoints = min(attacker.maxhitpoints,
                                         attacker.hitpoints + lifeleech)
                attacker.updatehealth()

            if staminaleech > 0:
                attacker.stamina = min(attacker.maxstamina,
                                       attacker.stamina + staminaleech)
                attacker.updatehealth()

            if manaleech > 0:
                attacker.mana = min(attacker.maxmana,
                                    attacker.mana + manaleech)
                attacker.updatemana()

            # Poisoning (50% chance)
            if weapon.hastag('poisoning_uses'):
                poisoning_uses = int(weapon.gettag('poisoning_uses'))
                if poisoning_uses <= 0:
                    weapon.deltag('poisoning_uses')
                    weapon.resendtooltip()
                else:
                    poisoning_uses -= 1
                    if poisoning_uses <= 0:
                        weapon.deltag('poisoning_uses')
                        weapon.resendtooltip()
                    else:
                        weapon.settag('poisoning_uses', poisoning_uses)

                    poisoning_strength = 0  # Assume lesser unless the tag tells so otherwise
                    if weapon.hastag('poisoning_strength'):
                        poisoning_strength = int(
                            weapon.gettag('poisoning_strength'))
                    if defender.hasscript(
                            "magic.evilomen") and poisoning_strength < 4:
                        poisoning_strength += 1
                    if random.random() >= 0.50:
                        if system.poison.poison(defender, poisoning_strength):
                            if attacker.socket:
                                attacker.socket.clilocmessage(
                                    1008096, "", 0x3b2, 3, None, defender.name,
                                    False, False)
                            if defender.socket:
                                attacker.socket.clilocmessage(
                                    1008097, "", 0x3b2, 3, None, attacker.name,
                                    False, True)

            # 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, excludechar=defender)

            # 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)

        # Slime or Toxic Elemental, 4% chance for losing one hitpoint
        if weapon.maxhealth > 0 and (
            (weapon.getintproperty('range', 1) <= 1 and
             (defender.id == 51 or defender.id == 158))
                or 0.04 >= random.random()):
            if (weapon.getintproperty('range', 1) <= 1
                    and (defender.id == 51 or defender.id == 158)):
                attacker.message(500263, '')  # *Acid blood scars your weapon!*

            # If it's a self repairing item, grant health instead of reducing it
            selfrepair = properties.fromitem(weapon, SELFREPAIR)
            if AGEOFSHADOWS and selfrepair > 0:
                if selfrepair > random.randint(0, 9):
                    weapon.health += 2
                    weapon.resendtooltip()
            else:
                if weapon.health > 0:
                    weapon.health -= 1
                elif weapon.maxhealth > 1:
                    weapon.maxhealth -= 1
                    attacker.message(1061121,
                                     '')  # Your equipment is severely damaged.
                else:
                    weapon.delete()
                if weapon:
                    weapon.resendtooltip()

        #if weapon.health <= 0:
        #	tobackpack(weapon, attacker)
        #	weapon.update()
        #	if attacker.socket:
        #		attacker.socket.clilocmessage(500645)

    # Notify the weapon ability
    if not blocked and ability:
        ability.hit(attacker, defender, damage)
コード例 #37
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
コード例 #38
0
def onUnequip(char, item, layer):
	changed = 0

	# Bonus Str
	if item.hastag('real_strength_bonus'):
		value = int(item.gettag('real_strength_bonus'))
		char.strength = max(1, char.strength - value)
		char.strength2 -= value
		changed = True
		item.deltag('real_strength_bonus')

	# Bonus Dex
	if item.hastag('real_dexterity_bonus'):
		value = int(item.gettag('real_dexterity_bonus'))
		char.dexterity = max(1, char.dexterity - value)
		char.dexterity2 -= value
		changed = True
		item.deltag('real_dexterity_bonus')

	# Bonus Int
	if item.hastag('real_intelligence_bonus'):
		value = int(item.gettag('real_intelligence_bonus'))
		char.intelligence = max(1, char.intelligence - value)
		char.intelligence2 -= value
		changed = True
		item.deltag('real_intelligence_bonus')

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

				if bonus == 0 or skill < 0 or skill >= ALLSKILLS:
					item.deltag('real_skillbonus_%u' % i)
					continue

				# If the bonus would add over the skill limit,
				# make sure it doesnt
				if char.skill[skill] - bonus < 0:
					bonus = char.skill[skill]

				item.deltag('real_skillbonus_%u' % i, bonus)
				char.skill[skill] -= bonus

				# Update the bonus tag for the character
				tagname = 'skillbonus_%u' % skill
				if char.hastag(tagname):
					value = int(char.gettag(tagname)) - bonus

					if value != 0:
						char.settag(tagname, value)
					else:
						char.deltag(tagname)
			except:
				item.deltag('real_skillbonus_%u' % i)
				continue

	# Bonus Hitpoints
	bonushitpoints = properties.fromitem(item, BONUSHITPOINTS)
	if bonushitpoints != 0:
		char.hitpointsbonus -= bonushitpoints
		changed = True

	# Bonus Stamina
	bonusstamina = properties.fromitem(item, BONUSSTAMINA)
	if bonusstamina != 0:
		char.staminabonus -= bonusstamina
		changed = True

	# Bonus Mana
	bonusmana = properties.fromitem(item, BONUSMANA)
	if bonusmana != 0:
		char.manabonus -= bonusmana
		changed = True

	# Remove hitpoint regeneration rate bonus
	regenhitpoints = properties.fromitem(item, REGENHITPOINTS)
	if regenhitpoints and char.hastag('regenhitpoints'):
		value = int(char.gettag('regenhitpoints')) - regenhitpoints

		if value <= 0:
			char.deltag('regenhitpoints')
		else:
			char.settag('regenhitpoints', value)

	# Remove stamina regeneration rate bonus
	regenstamina = properties.fromitem(item, REGENSTAMINA)
	if regenstamina and char.hastag('regenstamina'):
		value = int(char.gettag('regenstamina')) - regenstamina

		if value <= 0:
			char.deltag('regenstamina')
		else:
			char.settag('regenstamina', value)

	# Remove mana regeneration rate bonus
	regenmana = properties.fromitem(item, REGENMANA)
	if regenmana and char.hastag('regenmana'):
		value = int(char.gettag('regenmana')) - regenmana

		if value <= 0:
			char.deltag('regenmana')
		else:
			char.settag('regenmana', value)

	# Update Stats
	if changed:
		char.updatestats()
コード例 #39
0
def onEquip(char, item, layer):
    changed = False

    # Bonus Str
    bonus = properties.fromitem(item, BONUSSTRENGTH)
    if char.strength + bonus < 1:
        bonus = 1 - char.strength
    if char.strength + bonus > char.strengthcap:
        bonus = max(0, char.strengthcap - char.strength)
    if bonus != 0:
        char.strength += bonus
        char.strength2 += bonus
        item.settag('real_strength_bonus', bonus)
        changed = True
    else:
        item.deltag('real_strength_bonus')

    # Bonus Dex
    bonus = properties.fromitem(item, BONUSDEXTERITY)
    if char.dexterity + bonus < 1:
        bonus = 1 - char.dexterity
    if char.dexterity + bonus > char.dexteritycap:
        bonus = max(0, char.dexteritycap - char.dexterity)
    if bonus != 0:
        char.dexterity += bonus
        char.dexterity2 += bonus
        item.settag('real_dexterity_bonus', bonus)
        changed = True
    else:
        item.deltag('real_dexterity_bonus')

    # Bonus Int
    bonus = properties.fromitem(item, BONUSINTELLIGENCE)
    if char.intelligence + bonus < 1:
        bonus = 1 - char.intelligence
    if char.intelligence + bonus > char.intelligencecap:
        bonus = max(0, char.intelligencecap - char.intelligence)
    if bonus != 0:
        char.intelligence += bonus
        char.intelligence2 += bonus
        item.settag('real_intelligence_bonus', bonus)
        changed = True
    else:
        item.deltag('real_intelligence_bonus')

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

                if bonus == 0 or skill < 0 or skill >= ALLSKILLS:
                    item.deltag('real_skillbonus_%u' % i)
                    continue

                # Add a Bonus for the skill
                if char.skill[skill] + bonus < 0:
                    bonus = -char.skill[skill]

                item.settag('real_skillbonus_%u' % i, '%u,%u' % (skill, bonus))
                char.skill[skill] += bonus
            except:
                item.deltag('skillbonus_%u' % i)
                continue

            # Update the bonus tag for the character
            tagname = 'skillbonus_%u' % skill
            if char.hastag(tagname):
                value = int(char.gettag(tagname)) + bonus
            else:
                value = bonus
            char.settag(tagname, value)
        else:
            item.deltag('real_skillbonus_%u' % i)

    # if maximum values aren't updated automatically
    # we have to do it manually

    # Bonus Hitpoints
    bonushitpoints = properties.fromitem(item, BONUSHITPOINTS)
    if bonushitpoints != 0:
        if auto_refresh_max:
            char.hitpointsbonus += bonushitpoints
            changed = True
        else:
            if char.maxhitpoints + bonushitpoints < 1:
                bonushitpoints = 1 - char.maxhitpoints
            if bonushitpoints != 0:
                char.maxhitpoints += bonushitpoints
                char.hitpointsbonus += bonushitpoints
                item.settag('real_hitpoint_bonus', bonushitpoints)
                changed = True
            else:
                item.deltag('real_hitpoint_bonus')

    # Bonus Stamina
    bonusstamina = properties.fromitem(item, BONUSSTAMINA)
    if bonusstamina != 0:
        if auto_refresh_max:
            char.staminabonus += bonusstamina
            changed = True
        else:
            if char.maxstamina + bonusstamina < 1:
                bonusstamina = 1 - char.maxstamina
            if bonusstamina != 0:
                char.maxstamina += bonusstamina
                char.staminabonus += bonusstamina
                item.settag('real_stamina_bonus', bonusstamina)
                changed = True
            else:
                item.deltag('real_stamina_bonus')

    # Bonus Mana
    bonusmana = properties.fromitem(item, BONUSMANA)
    if bonusmana != 0:
        if auto_refresh_max:
            char.manabonus += bonusmana
            changed = True
        else:
            if char.maxmana + bonusmana < 1:
                bonusmana = 1 - char.maxmana
            if bonusmana != 0:
                char.maxmana += bonusmana
                char.manabonus += bonusmana
                item.settag('real_mana_bonus', bonusmana)
                changed = True
            else:
                item.deltag('real_mana_bonus')

    # Add hitpoint regeneration rate bonus
    regenhitpoints = properties.fromitem(item, REGENHITPOINTS)
    if regenhitpoints:
        if char.hastag('regenhitpoints'):
            regenhitpoints += int(char.gettag('regenhitpoints'))

        char.settag('regenhitpoints', regenhitpoints)

    # Add stamina regeneration rate bonus
    regenstamina = properties.fromitem(item, REGENSTAMINA)
    if regenstamina:
        if char.hastag('regenstamina'):
            regenstamina += int(char.gettag('regenstamina'))

        char.settag('regenstamina', regenstamina)

    # Add mana regeneration rate bonus
    regenmana = properties.fromitem(item, REGENMANA)
    if regenmana:
        if char.hastag('regenmana'):
            regenmana += int(char.gettag('regenmana'))

        char.settag('regenmana', regenmana)

    # Add nightsight
    nightsight = properties.fromitem(item, NIGHTSIGHT)
    if nightsight and char.player:
        char.settag('nightsight', 127)
        char.lightbonus = 127
        if char.socket:
            char.socket.updatelightlevel()

    # Update Stats
    if changed:
        char.updatestats()
コード例 #40
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
コード例 #41
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))
コード例 #42
0
def onUnequip(char, item, layer):
    changed = 0

    # Bonus Str
    if item.hastag('real_strength_bonus'):
        value = int(item.gettag('real_strength_bonus'))
        char.strength = max(1, char.strength - value)
        char.strength2 -= value
        changed = True
        item.deltag('real_strength_bonus')

    # Bonus Dex
    if item.hastag('real_dexterity_bonus'):
        value = int(item.gettag('real_dexterity_bonus'))
        char.dexterity = max(1, char.dexterity - value)
        char.dexterity2 -= value
        changed = True
        item.deltag('real_dexterity_bonus')

    # Bonus Int
    if item.hastag('real_intelligence_bonus'):
        value = int(item.gettag('real_intelligence_bonus'))
        char.intelligence = max(1, char.intelligence - value)
        char.intelligence2 -= value
        changed = True
        item.deltag('real_intelligence_bonus')

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

                if bonus == 0 or skill < 0 or skill >= ALLSKILLS:
                    item.deltag('real_skillbonus_%u' % i)
                    continue

                # If the bonus would add over the skill limit,
                # make sure it doesnt
                if char.skill[skill] - bonus < 0:
                    bonus = char.skill[skill]

                item.deltag('real_skillbonus_%u' % i, bonus)
                char.skill[skill] -= bonus

                # Update the bonus tag for the character
                tagname = 'skillbonus_%u' % skill
                if char.hastag(tagname):
                    value = int(char.gettag(tagname)) - bonus

                    if value != 0:
                        char.settag(tagname, value)
                    else:
                        char.deltag(tagname)
            except:
                item.deltag('real_skillbonus_%u' % i)
                continue

    # if maximum values aren't updated automatically
    # we have to do it manually

    # Bonus Hitpoints
    bonushitpoints = properties.fromitem(item, BONUSHITPOINTS)
    if bonushitpoints != 0:
        if auto_refresh_max:
            char.hitpointsbonus -= bonushitpoints
            changed = True
        else:
            if item.hastag('real_hitpoint_bonus'):
                value = int(item.gettag('real_hitpoint_bonus'))
                char.maxhitpoints = max(1, char.maxhitpoints - value)
                char.hitpointsbonus -= value
                char.hitpoints = min(char.hitpoints, char.maxhitpoints)
                changed = True
                item.deltag('real_hitpoint_bonus')

    # Bonus Stamina
    bonusstamina = properties.fromitem(item, BONUSSTAMINA)
    if bonusstamina != 0:
        if auto_refresh_max:
            char.staminabonus -= bonusstamina
            changed = True
        else:
            if item.hastag('real_stamina_bonus'):
                value = int(item.gettag('real_stamina_bonus'))
                char.maxstamina = max(1, char.maxstamina - value)
                char.staminabonus -= value
                char.stamina = min(char.stamina, char.maxstamina)
                changed = True
                item.deltag('real_stamina_bonus')

    # Bonus Mana
    bonusmana = properties.fromitem(item, BONUSMANA)
    if bonusmana != 0:
        if auto_refresh_max:
            char.manabonus -= bonusmana
            changed = True
        else:
            if item.hastag('real_mana_bonus'):
                value = int(item.gettag('real_mana_bonus'))
                char.maxmana = max(1, char.maxmana - value)
                char.manabonus -= value
                char.mana = min(char.mana, char.maxmana)
                changed = True
                item.deltag('real_mana_bonus')

    # Remove hitpoint regeneration rate bonus
    regenhitpoints = properties.fromitem(item, REGENHITPOINTS)
    if regenhitpoints and char.hastag('regenhitpoints'):
        value = int(char.gettag('regenhitpoints')) - regenhitpoints

        if value <= 0:
            char.deltag('regenhitpoints')
        else:
            char.settag('regenhitpoints', value)

    # Remove stamina regeneration rate bonus
    regenstamina = properties.fromitem(item, REGENSTAMINA)
    if regenstamina and char.hastag('regenstamina'):
        value = int(char.gettag('regenstamina')) - regenstamina

        if value <= 0:
            char.deltag('regenstamina')
        else:
            char.settag('regenstamina', value)

    # Remove mana regeneration rate bonus
    regenmana = properties.fromitem(item, REGENMANA)
    if regenmana and char.hastag('regenmana'):
        value = int(char.gettag('regenmana')) - regenmana

        if value <= 0:
            char.deltag('regenmana')
        else:
            char.settag('regenmana', value)

    # Add nightsight
    nightsight = properties.fromitem(item, NIGHTSIGHT)
    if nightsight and char.player and char.hastag('nightsight'):
        # Check if another nightsight item is equipped
        found = False
        for i in range(LAYER_RIGHTHAND, LAYER_LEGS):
            if char.itemonlayer(i) and char.itemonlayer(i).hastag(
                    'nightsight'):
                found = True
                break
        # We have magic spell on char e.g.
        if char.hasscript('magic.nightsight'):
            found = True
        if not found:
            bonus = char.gettag('nightsight')
            char.lightbonus = max(0, char.lightbonus - bonus)
            char.deltag('nightsight')
            char.socket.updatelightlevel()
    # Update Stats
    if changed:
        char.updatestats()
コード例 #43
0
def modifiers(object, tooltip):
	modifiers = {
		"remaining_uses": 1060584,
		"aos_boni_damage": 1060401,
	}

	for (tag, cliloc) in modifiers.items():
		if object.hastag(tag):
			tooltip.add(cliloc, str(object.gettag(tag)))

	speedbonus = properties.fromitem(object, SPEEDBONUS)
	if speedbonus != 0:
		tooltip.add(1060486, str(speedbonus))


	hitbonus = properties.fromitem(object, HITBONUS)
	if hitbonus != 0:
		tooltip.add(1060415, str(hitbonus))

	defensebonus = properties.fromitem(object, DEFENSEBONUS)
	if defensebonus != 0:
		tooltip.add(1060408, str(defensebonus))

	enhancepotions = properties.fromitem(object, ENHANCEPOTIONS)
	if enhancepotions != 0:
		tooltip.add(1060411, str(enhancepotions))

	reflectphysical = properties.fromitem(object, REFLECTPHYSICAL)

	if reflectphysical:
		tooltip.add(1060442, str(reflectphysical))

	luck = properties.fromitem(object, LUCK)
	if luck != 0:
		tooltip.add(1060436, str(luck))

	bonus = properties.fromitem(object, BONUSSTRENGTH)
	if bonus != 0:
		tooltip.add(1060485, str(bonus))

	bonus = properties.fromitem(object, BONUSDEXTERITY)
	if bonus != 0:
		tooltip.add(1060409, str(bonus))

	bonus = properties.fromitem(object, BONUSINTELLIGENCE)
	if bonus != 0:
		tooltip.add(1060432, str(bonus))

	bonus = properties.fromitem(object, BONUSHITPOINTS)
	if bonus != 0:
		tooltip.add(1060431, str(bonus))

	bonus = properties.fromitem(object, BONUSSTAMINA)
	if bonus != 0:
		tooltip.add(1060484, str(bonus))

	bonus = properties.fromitem(object, BONUSMANA)
	if bonus != 0:
		tooltip.add(1060439, str(bonus))

	regenhitpoints = properties.fromitem(object, REGENHITPOINTS)
	if regenhitpoints:
		tooltip.add(1060444, str(regenhitpoints))

	regenstamina = properties.fromitem(object, REGENSTAMINA)
	if regenstamina:
		tooltip.add(1060443, str(regenstamina))

	regenmana = properties.fromitem(object, REGENMANA)
	if regenmana:
		tooltip.add(1060440, str(regenmana))

	if properties.fromitem(object, BESTSKILL):
		tooltip.add(1060400, "")

	mageweapon = properties.fromitem(object, MAGEWEAPON)
	if mageweapon != 0:
		tooltip.add(1060438, str(mageweapon))

	if properties.fromitem(object, MAGEARMOR) and not object.allowmeditation:
		tooltip.add(1060437, "")

	selfrepair = properties.fromitem(object, SELFREPAIR)
	if selfrepair != 0:
		tooltip.add(1060450, str(selfrepair))
コード例 #44
0
ファイル: aos.py プロジェクト: BackupTheBerlios/wolfpack-svn
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)
コード例 #45
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
コード例 #46
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
コード例 #47
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)
コード例 #48
0
def onEquip(char, item, layer):
	changed = 0

	# Bonus Str
	bonus = properties.fromitem(item, BONUSSTRENGTH)
	if char.strength + bonus < 1:
		bonus = 1 - char.strength
	if char.strength + bonus > char.strengthcap:
		bonus = max(0, char.strengthcap - char.strength)
	if bonus != 0:
		char.strength += bonus
		char.strength2 += bonus
		item.settag('real_strength_bonus', bonus)
		changed = True
	else:
		item.deltag('real_strength_bonus')

	# Bonus Dex
	bonus = properties.fromitem(item, BONUSDEXTERITY)
	if char.dexterity + bonus < 1:
		bonus = 1 - char.dexterity
	if char.dexterity + bonus > char.dexteritycap:
		bonus = max(0, char.dexteritycap - char.dexterity)
	if bonus != 0:
		char.dexterity += bonus
		char.dexterity2 += bonus
		item.settag('real_dexterity_bonus', bonus)
		changed = True
	else:
		item.deltag('real_dexterity_bonus')

	# Bonus Int
	bonus = properties.fromitem(item, BONUSINTELLIGENCE)
	if char.intelligence + bonus < 1:
		bonus = 1 - char.intelligence
	if char.intelligence + bonus > char.intelligencecap:
		bonus = max(0, char.intelligencecap - char.intelligence)
	if bonus != 0:
		char.intelligence += bonus
		char.intelligence2 += bonus
		item.settag('real_intelligence_bonus', bonus)
		changed = True
	else:
		item.deltag('real_intelligence_bonus')

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

				if bonus == 0 or skill < 0 or skill >= ALLSKILLS:
					item.deltag('real_skillbonus_%u' % i)
					continue

				# Add a Bonus for the skill
				if char.skill[skill] + bonus < 0:
					bonus = - char.skill[skill]

				item.settag('real_skillbonus_%u' % i, '%u,%u' % (skill, bonus))
				char.skill[skill] += bonus
			except:
				item.deltag('skillbonus_%u' % i)
				continue

			# Update the bonus tag for the character
			tagname = 'skillbonus_%u' % skill
			if char.hastag(tagname):
				value = int(char.gettag(tagname)) + bonus
			else:
				value = bonus
			char.settag(tagname, value)
		else:
			item.deltag('real_skillbonus_%u' % i)

	# Bonus Hitpoints
	bonushitpoints = properties.fromitem(item, BONUSHITPOINTS)
	if bonushitpoints != 0:
		char.hitpointsbonus += bonushitpoints
		changed = True

	# Bonus Stamina
	bonusstamina = properties.fromitem(item, BONUSSTAMINA)
	if bonusstamina != 0:
		char.staminabonus += bonusstamina
		changed = True

	# Bonus Mana
	bonusmana = properties.fromitem(item, BONUSMANA)
	if bonusmana != 0:
		char.manabonus += bonusmana
		changed = True

	# Add hitpoint regeneration rate bonus
	regenhitpoints = properties.fromitem(item, REGENHITPOINTS)
	if regenhitpoints:
		if char.hastag('regenhitpoints'):
			regenhitpoints += int(char.gettag('regenhitpoints'))

		char.settag('regenhitpoints', regenhitpoints)

	# Add stamina regeneration rate bonus
	regenstamina = properties.fromitem(item, REGENSTAMINA)
	if regenstamina:
		if char.hastag('regenstamina'):
			regenstamina += int(char.gettag('regenstamina'))

		char.settag('regenstamina', regenstamina)

	# Add mana regeneration rate bonus
	regenmana = properties.fromitem(item, REGENMANA)
	if regenmana:
		if char.hastag('regenmana'):
			regenmana += int(char.gettag('regenmana'))

		char.settag('regenmana', regenmana)

	# Update Stats
	if changed:
		char.updatestats()