当前位置: 首页>>代码示例>>Python>>正文


Python properties.fromitem函数代码示例

本文整理汇总了Python中wolfpack.properties.fromitem函数的典型用法代码示例。如果您正苦于以下问题:Python fromitem函数的具体用法?Python fromitem怎么用?Python fromitem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了fromitem函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: applyproperties

	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])
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:28,代码来源:tailoring.py

示例2: damagetypes

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)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:54,代码来源:aos.py

示例3: hasHandFree

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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:13,代码来源:utilities.py

示例4: applyproperties

	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)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:27,代码来源:tinkering.py

示例5: modifiers

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, "")
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:26,代码来源:equipment.py

示例6: onWearItem

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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:47,代码来源:equipment.py

示例7: onShowTooltip

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, '')
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:8,代码来源:musicianship.py

示例8: playmisssound

def playmisssound(attacker, defender):
	weapon = attacker.getweapon()
	sounds = properties.fromitem(weapon, MISSSOUND)

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

	attacker.soundeffect(random.choice(sounds))
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:9,代码来源:utilities.py

示例9: fireweapon

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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:42,代码来源:aos.py

示例10: checkSlaying

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)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:11,代码来源:aos.py

示例11: weaponskill

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]
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:11,代码来源:utilities.py

示例12: modifiers

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, "")
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:41,代码来源:equipment.py

示例13: applyproperties

	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)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:51,代码来源:blacksmithing.py

示例14: playhitsound

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))
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:12,代码来源:utilities.py

示例15: fireweapon

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
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:23,代码来源:aos.py


注:本文中的wolfpack.properties.fromitem函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。