def checkskill(self, player, weapon):
		skill = self.getskill(player, weapon) # Get the required skill amount
		skillid = weaponskill(player, weapon, True) # Get the weaponskill used by the player
		
		result = player.skill[skillid] >= skill
		
		if not result and player.socket:
			player.socket.clilocmessage(1060182, '%0.f%%' % (skill / 10.0))
		
		return result
Example #2
0
    def checkskill(self, player, weapon):
        skill = self.getskill(player, weapon)  # Get the required skill amount
        skillid = weaponskill(player, weapon,
                              True)  # Get the weaponskill used by the player

        result = player.skill[skillid] >= skill

        if not result and player.socket:
            player.socket.clilocmessage(1060182, '%0.f%%' % (skill / 10.0))

        return result
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))
def onUse( char, item ):
	# Either the dummy is swinging or we aren't assigned to a dummy
	if( item.id != 0x1070 and item.id != 0x1074  ):
		char.socket.sysmessage( 'Wait until the dummy stops swinging.' )
		return True

	# Distance & Direction checks
	if( char.distanceto( item ) > 1 ):
		char.message( 'You must be standing in front of or behind the dummy to use it.' )
		return True

	# Calculates the direction we'll have to look
	# to focus the dummy
	direction = char.directionto( item )

	# For a n/s dummy we need to either face north or south
	if( item.id == 0x1070 and direction != 0 and direction != 4 ):
		char.message( 'You must be standing in front of or behind the dummy to use it.' )
		return True

	# For a e/w dummy we need to either face eath or west
	elif( item.id == 0x1074 and direction != 2 and direction != 6 ):
		char.message( 'You must be standing in front of or behind the dummy to use it.' )
		return True

	# Turn to the correct direction
	char.turnto( item )

 	# Determine the combat skill used by the character
	skill = weaponskill(char, char.getweapon())

	# We can only train FENCING+MACEFIGHTING+SWORDSMANSHIP+WRESTLING
	if( skill != FENCING and skill != MACEFIGHTING and skill != SWORDSMANSHIP and skill != WRESTLING ):
		char.message( "You can't train with this weapon on this dummy." )
		return True

	# If we've already learned all we can > cancel.
	if( char.skill[ skill ] >= 300 ):
		char.message( "You can learn much from a dummy but you have already learned it all." )
		return True

	# We'll get revealed if successfully punching the dummy
	char.reveal()
	
	# This increases the users skill
	char.checkskill( skill, 0, 1000 )

	# Display the char-action
	# (combat swing 1handed)
	char.action( 0x09 )

	if( item.id == 0x1070 or item.id == 0x1074 ):
		item.id += 1

	# Resend the item to surrounding clients after
	# changing the id and play the soundeffect
	# originating from the dummy
	item.update()
	item.soundeffect( 0x33 )

	# Add a timer to reset the id (serializable!)
	wolfpack.addtimer( random.randint( 2000, 3000 ), "training_dummy.resetid", [ item.serial ], 1 )

	return True
def onShowTooltip(viewer, object, tooltip):
	armor = properties.itemcheck(object, ITEM_ARMOR)
	weapon = properties.itemcheck(object, ITEM_WEAPON)
	shield = properties.itemcheck(object, ITEM_SHIELD)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		castspeed = properties.fromitem(object, CASTSPEEDBONUS)

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

		spelldamagebonus = properties.fromitem(object, SPELLDAMAGEBONUS)

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

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

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

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

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

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

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

	modifiers(object, tooltip)

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

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

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

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

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

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

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

				# Add a Bonus for the skill
				tooltip.add(1060451 + i, "#%u\t%u" % (1044060 + skill, int(bonus / 10)))
			except:
				object.deltag('skillbonus_%u' % i)
				continue
				
	return False
Example #6
0
def onUse(char, item):
    # Init the butte
    if (not item.hastag("arrow_count") or not item.hastag("bolt_count")):
        item.settag("arrow_count", 0)
        item.settag("bolt_count", 0)

    # Retrieve Arrows + Bolts when standing near
    # to the butte
    if char.distanceto(item) <= 1:
        return giveAmmo(char, item)

    if char.distanceto(item) > 10:
        #You are too far away from the archery butte to get an accurate shot.
        char.socket.clilocmessage(500598)
        return True
    elif char.distanceto(item) < 5:
        #You are too close to the target.
        char.socket.clilocmessage(500599)
        return True

    #riding?
    if char.ismounted():
        #You can't practice on this while on a mount.
        char.socket.clilocmessage(501829)
        return True

    # Sanity checks for the line-of-fire
    if not checkDirection(char, item):
        #You aren't properly lined up with the archery butte to get an accurate shot.
        char.socket.clilocmessage(500597)
        return True

    #Line of Sight Check
    if not char.canreach(item, 10):
        #You cannot reach ..
        char.socket.clilocmessage(500312)
        return True

    # Calculates the direction we'll have to look
    # to focus the dummy
    char.turnto(item)

    # Only Bows or Crossbows (Check ammo-type too)
    ammo = ammoType(char)

    if (weaponskill(char, char.getweapon()) != ARCHERY) or (ammo == -1):
        #You must practice with ranged weapons on this.
        char.socket.clilocmessage(500593)
        return True

    # If we've already learned all we can > cancel.
    if char.skill[ARCHERY] >= 300:
        #Your skill cannot improve any further by simply practicing with a dummy.
        char.socket.clilocmessage(501828)
        return True

    if ammo == 0xf3f:
        ammoname = "arrow"
        movingeff = 0xf42
        if (not char.useresource(1, ammo)):
            #You do not have any arrows with which to practice.
            char.socket.clilocmessage(500594)
            return True
    else:
        ammoname = "bolt"
        movingeff = 0x1bfe
        # Use ammo (if 0 was used = no ammo)
        if not char.useresource(1, ammo):
            #You do not have any crossbow bolts with which to practice.
            char.socket.clilocmessage(500595)
            return True

    #reveal the char if an arrow is fired
    char.reveal()

    char.movingeffect(movingeff, item, 1, 1, 1, 0, 1)

    # Display the char-action
    # (archery shot)
    # Soundeffect
    char.soundeffect(random.choice([0x224, 0x234]))
    if ammo == 0xf3f:
        char.action(ANIM_ATTACKBOW)
    else:
        char.action(ANIM_ATTACKXBOX)

    # This increases the users skill
    # 10% of destroying the ammo on failure
    if not char.checkskill(ARCHERY, 0, 1000):
        if not random.randrange(0, 9):
            char.emote(
                tr("You see %s's poor shot destroys the %s") %
                (char.name, ammoname))
        else:
            char.emote(
                tr("You see %s's %s") %
                (char.name, random.choice(failureText)))
    else:
        char.emote(
            tr("You see %s's %s") % (char.name, random.choice(successText)))

        # Increase the ammo we have in the butte
        if ammo == 0xf3f:
            item.settag("arrow_count", item.gettag("arrow_count") + 1)
        else:
            item.settag("bolt_count", item.gettag("bolt_count") + 1)

    return True
Example #7
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
Example #8
0
def onUse(char, item):
    # Either the dummy is swinging or we aren't assigned to a dummy
    if (item.id != 0x1070 and item.id != 0x1074):
        char.socket.clilocmessage(
            501815)  # You have to wait until it stops swinging.
        return True

    # Distance & Direction checks
    if (char.distanceto(item) > 1):
        char.message(500295, '')  # You are too far away to do that.
        return True

    if mounted(char):
        char.socket.clilocmessage(
            501829)  # You can't practice on this while on a mount.
        return True

    # Calculates the direction we'll have to look
    # to focus the dummy
    direction = char.directionto(item)

    # For a n/s dummy we need to either face north or south
    if (item.id == 0x1070 and direction != 0 and direction != 4):
        char.message(
            tr('You must be standing in front of or behind the dummy to use it.'
               ))
        return True

    # For a e/w dummy we need to either face eath or west
    elif (item.id == 0x1074 and direction != 2 and direction != 6):
        char.message(
            tr('You must be standing in front of or behind the dummy to use it.'
               ))
        return True

    # Turn to the correct direction
    char.turnto(item)

    # Determine the combat skill used by the character
    skill = weaponskill(char, char.getweapon())

    # We can only train FENCING+MACEFIGHTING+SWORDSMANSHIP+WRESTLING
    if (skill != FENCING and skill != MACEFIGHTING and skill != SWORDSMANSHIP
            and skill != WRESTLING):
        char.message(501822, '')  # You can't practice ranged weapons on this.
        return True

    # If we've already learned all we can > cancel.
    if (char.skill[skill] >= MAX_SKILL_FOR_DUMMIE):
        char.message(
            501828, ''
        )  # Your skill cannot improve any further by simply practicing with a dummy.
        return True

    # We'll get revealed if successfully punching the dummy
    char.reveal()

    # This increases the users skill
    char.checkskill(skill, 0, 1000)

    # Display the char-action
    # (combat swing 1handed)
    char.action(0x09)

    if (item.id == 0x1070 or item.id == 0x1074):
        item.id += 1

    # Resend the item to surrounding clients after
    # changing the id and play the soundeffect
    # originating from the dummy
    item.update()
    item.soundeffect(0x33)

    # Add a timer to reset the id (serializable!)
    item.addtimer(random.randint(2000, 3000), resetid, [], 1)

    return True
def onUse( char, item ):
	# Init the butte
	if( not item.hastag( "arrow_count" ) or not item.hastag( "bolt_count" ) ):
		item.settag( "arrow_count", 0 )
		item.settag( "bolt_count", 0 )

	# Retrieve Arrows + Bolts when standing near
	# to the butte
	if char.distanceto( item ) <= 1:
		return giveAmmo( char, item )

	if char.distanceto( item ) > 10:
		#You are too far away from the archery butte to get an accurate shot.
		char.socket.clilocmessage(500598)
		return True
	elif char.distanceto( item ) < 5:
		#You are too close to the target.
		char.socket.clilocmessage(500599)
		return True

	#riding?
	if char.ismounted():
		#You can't practice on this while on a mount.
		char.socket.clilocmessage(501829)
		return True

	# Sanity checks for the line-of-fire
	if not checkDirection(char, item):
		#You aren't properly lined up with the archery butte to get an accurate shot.
		char.socket.clilocmessage(500597)
		return True

	#Line of Sight Check
	if not char.canreach( item, 10 ):
		#You cannot reach ..
		char.socket.clilocmessage( 500312 )
		return True

	# Calculates the direction we'll have to look
	# to focus the dummy
	char.turnto( item )

	# Only Bows or Crossbows (Check ammo-type too)
	ammo = ammoType( char )

	if ( weaponskill(char, char.getweapon()) != ARCHERY ) or ( ammo == -1 ):
		#You must practice with ranged weapons on this.
		char.socket.clilocmessage(500593)
		return True

	# If we've already learned all we can > cancel.
	if char.skill[ ARCHERY ] >= 300:
		#Your skill cannot improve any further by simply practicing with a dummy.
		char.socket.clilocmessage(501828)
		return True

	if ammo == 0xf3f:
		ammoname = "arrow"
		movingeff = 0xf42
		if( not char.useresource( 1, ammo ) ):
			#You do not have any arrows with which to practice.
			char.socket.clilocmessage(500594)
			return True
	else:
		ammoname = "bolt"
		movingeff = 0x1bfe
		# Use ammo (if 0 was used = no ammo)
		if not char.useresource( 1, ammo ):
			#You do not have any crossbow bolts with which to practice.
			char.socket.clilocmessage(500595)
			return True

	#reveal the char if an arrow is fired
	char.reveal()

	char.movingeffect( movingeff, item, 1, 1, 1, 0, 1 )

	# Display the char-action
	# (archery shot)
	# Soundeffect
	char.soundeffect( random.choice( [0x224, 0x234] ) )
	if ammo == 0xf3f:
		char.action( ANIM_ATTACKBOW )
	else:
		char.action( ANIM_ATTACKXBOX )

	# This increases the users skill
	# 10% of destroying the ammo on failure
	if not char.checkskill( ARCHERY, 0, 1000 ):
		if not random.randrange( 0, 9 ):
			char.emote( tr("You see %s's poor shot destroys the %s") % (char.name, ammoname) )
		else:
			char.emote( tr("You see %s's %s") % (char.name, random.choice( failureText )) )
	else:
		char.emote( tr("You see %s's %s") % (char.name, random.choice( successText )) )

		# Increase the ammo we have in the butte
		if ammo == 0xf3f:
			item.settag( "arrow_count", item.gettag( "arrow_count" ) + 1 )
		else:
			item.settag( "bolt_count", item.gettag( "bolt_count" ) + 1 )

	return True
def onUse(char, item):
    # Init the butte
    if not item.hastag("arrow_count") or not item.hastag("bolt_count"):
        item.settag("arrow_count", 0)
        item.settag("bolt_count", 0)

        # Retrieve Arrows + Bolts when standing near
        # to the butte
    if char.distanceto(item) <= 1:
        return giveAmmo(char, item)

    if char.distanceto(item) > 10:
        char.socket.clilocmessage(500603)
        return True
    elif char.distanceto(item) < 5:
        char.socket.clilocmessage(500604)
        return True

        # Sanity checks for the line-of-fire
    if (item.id == 0x100B and (char.pos.x != item.pos.x or char.pos.y <= item.pos.y)) or (
        item.id == 0x100A and (char.pos.y != item.pos.y or char.pos.x <= item.pos.x)
    ):
        char.socket.clilocmessage(500597)
        return True

        # TODO: Check line of sight

        # Calculates the direction we'll have to look
        # to focus the dummy
    direction = char.directionto(item)

    if char.direction != direction:
        char.direction = direction
        char.update()

        # Only Bows or Crossbows (Check ammo-type too)
    ammo = ammoType(char)

    if (weaponskill(char, char.getweapon()) != ARCHERY) or (ammo == -1):
        char.socket.clilocmessage(500594)
        return True

        # If we've already learned all we can > cancel.
    if char.skill[ARCHERY] >= 300:
        char.socket.clilocmessage(501829)
        return True

        # Display the char-action
        # (archery shot)
        # Soundeffect
    char.soundeffect(0x224)
    char.action(0x09)

    if ammo == 0xF3F:
        ammoname = "arrow"
        movingeff = 0xF42
        if not char.useresource(1, ammo):
            char.socket.clilocmessage(500595)
            return True
    else:
        ammoname = "bolt"
        movingeff = 0x1BFE
        # Use ammo (if 0 was used = no ammo)
        if not char.useresource(1, ammo):
            char.socket.clilocmessage(500596)
            return True

    char.movingeffect(movingeff, item, 1, 1, 1, 0, 1)

    # This increases the users skill
    # 10% of destroying the ammo on failure
    if not char.checkskill(ARCHERY, 0, 1000):
        if not random.randrange(0, 9):
            char.emote("You see " + char.name + "'s poor shot destroys the " + ammoname)
        else:
            char.emote("You see " + char.name + "'s " + random.choice(failureText))
    else:
        char.emote("You see " + char.name + "'s " + random.choice(successText))

        # Increase the ammo we have in the butte
        if ammo == 0xF3F:
            item.settag("arrow_count", item.gettag("arrow_count") + 1)
        else:
            item.settag("bolt_count", item.gettag("bolt_count") + 1)

    return True
def onUse( char, item ):
	# Either the dummy is swinging or we aren't assigned to a dummy
	if( item.id != 0x1070 and item.id != 0x1074  ):
		char.socket.clilocmessage( 501815 ) # You have to wait until it stops swinging.
		return True

	# Distance & Direction checks
	if( char.distanceto( item ) > 1 ):
		char.message( 500295, '' ) # You are too far away to do that.
		return True

	if mounted(char):
		char.socket.clilocmessage( 501829 ) # You can't practice on this while on a mount.
		return True

	# Calculates the direction we'll have to look
	# to focus the dummy
	direction = char.directionto( item )

	# For a n/s dummy we need to either face north or south
	if( item.id == 0x1070 and direction != 0 and direction != 4 ):
		char.message( tr('You must be standing in front of or behind the dummy to use it.') )
		return True

	# For a e/w dummy we need to either face eath or west
	elif( item.id == 0x1074 and direction != 2 and direction != 6 ):
		char.message( tr('You must be standing in front of or behind the dummy to use it.') )
		return True

	# Turn to the correct direction
	char.turnto( item )

 	# Determine the combat skill used by the character
	skill = weaponskill(char, char.getweapon())

	# We can only train FENCING+MACEFIGHTING+SWORDSMANSHIP+WRESTLING
	if( skill != FENCING and skill != MACEFIGHTING and skill != SWORDSMANSHIP and skill != WRESTLING ):
		char.message( 501822, '' ) # You can't practice ranged weapons on this.
		return True

	# If we've already learned all we can > cancel.
	if( char.skill[ skill ] >= MAX_SKILL_FOR_DUMMIE ):
		char.message( 501828, '' ) # Your skill cannot improve any further by simply practicing with a dummy.
		return True

	# We'll get revealed if successfully punching the dummy
	char.reveal()

	# This increases the users skill
	char.checkskill( skill, 0, 1000 )

	# Display the char-action
	# (combat swing 1handed)
	char.action( 0x09 )

	if( item.id == 0x1070 or item.id == 0x1074 ):
		item.id += 1

	# Resend the item to surrounding clients after
	# changing the id and play the soundeffect
	# originating from the dummy
	item.update()
	item.soundeffect( 0x33 )

	# Add a timer to reset the id (serializable!)
	item.addtimer( random.randint( 2000, 3000 ), resetid, [], 1 )

	return True