Beispiel #1
0
def dosmelt(char, args):
	ore = args[0]
	forge = args[1]
	resname = args[2]

	if not mining.ORES.has_key(resname):
		char.socket.sysmessage('You cannot smelt that kind of ore.')
		return 0

	success = 0
	reqskill = mining.ORES[resname][mining.REQSKILL]
	chance = max(0, char.skill[MINING] - mining.ORES[resname][mining.MINSKILL]) / 1000.0

	if not char.skill[MINING] >= reqskill:
		char.socket.clilocmessage(501986, '', GRAY) # You have no idea how to smelt this strange ore!
		return False

	if ore.amount >= 1 and char.skill[ MINING ] >= reqskill:
		if not skills.checkskill(char, MINING, chance):
			success = 0
		else:
			if ore.baseid == DEF_ORES[3]:
				amount = (ore.amount * 2)
				successsmelt(char, resname, amount)
				ore.delete()
			elif ore.baseid == DEF_ORES[2] or ore.baseid == DEF_ORES[1]:
				amount = ore.amount
				successsmelt(char, resname, amount)
				ore.delete()
			elif ore.baseid == DEF_ORES[0]:
				if evenorodd( ore.amount ) == "even":
					amount = ( ore.amount / 2 )
					successsmelt(char, resname, amount)
					ore.delete()
				elif evenorodd( ore.amount ) == "odd" and ore.amount > 1:
					amount = ( ( ore.amount - 1 ) / 2 )
					successsmelt(char, resname, amount)
					ore.amount = 1
					ore.update()
				elif ore.amount == 1:
					# There is not enough metal-bearing ore in this pile to make an ingot.
					char.socket.clilocmessage( 501987, '', GRAY )
					return False
			success = 1

	if success == 0:
		if ore.amount >= 2:
			# You burn away the impurities but are left with less useable metal.
			char.socket.clilocmessage( 501990, '', GRAY )
			ore.amount -= ( ore.amount / 2 )
			ore.update()
		else:
			# You burn away the impurities but are left with no useable metal.
			char.socket.clilocmessage( 501989, '', GRAY )
			ore.delete()

	return True
Beispiel #2
0
def domining(char, args):
    char.soundeffect(random.choice([0x125, 0x126]))
    tool = wolfpack.finditem(args[0])
    pos = args[1]
    socket = char.socket
    if socket.hastag('is_mining'):
        socket.deltag('is_mining')

    if not tool:
        return False

    # Recheck distance
    #if not char.canreach(pos, MINING_MAX_DISTANCE):
    #	socket.clilocmessage(501867)
    #	return False

    # Finding the Default Ore table for this Region
    region = char.region
    Oretable = FindOreTable(region)

    veingem = getvein(Oretable, pos, char)

    if not veingem or not veingem.hastag('resourcecount'):
        return False

    # 50% chance to dig up primary resource,
    # even if the vein has something else.
    if veingem.hastag('resname2') and random.random() >= 0.50:
        resname = veingem.gettag('resname2')
    else:
        resname = veingem.gettag('resname')

    resourcecount = veingem.gettag('resourcecount')
    reqskill = Oretable[resname][REQSKILL]

    # Refill the resource gem.
    if resourcecount == 0:
        socket.sysmessage(tr("There is no ore here to mine."))

        if not veingem.hastag('resource_empty'):
            # Picking the next amount
            nextamount = random.randint(Oretable[resname][MINAMOUNT],
                                        Oretable[resname][MAXAMOUNT])
            duration = random.randint(MINING_REFILLTIME[0],
                                      MINING_REFILLTIME[1])
            veingem.addtimer(duration, respawnvein, [nextamount], True)
            veingem.settag('resource_empty', 1)
        return False

    # You loosen some rocks but fail to find any usable ore.
    if char.skill[MINING] < reqskill:
        socket.clilocmessage(501869)
        return False

    chance = max(0, char.skill[MINING] - Oretable[resname][MINSKILL]) / 1000.0
    success = 0

    if not skills.checkskill(char, MINING, chance):
        socket.clilocmessage(501869)
        return False

    # Digs up the large ore.
    if resourcecount >= 5:
        successmining(Oretable, char, veingem, resname, 3)

    # Picks one of the smaller ore types
    elif resourcecount == 3 or resourcecount == 4:
        successmining(Oretable, char, veingem, resname, 2)

    # Smallest ore only
    elif resourcecount == 1 or resourcecount == 2:
        successmining(Oretable, char, veingem, resname, 1)
    wearout(char, tool)
def domining(char, args):
	char.soundeffect( random.choice([0x125, 0x126]) )
	tool = wolfpack.finditem(args[0])
	pos = args[1]
	socket = char.socket
	if socket.hastag('is_mining'):
		socket.deltag( 'is_mining' )

	if not tool:
		return False

	# Recheck distance
	#if not char.canreach(pos, MINING_MAX_DISTANCE):
	#	socket.clilocmessage(501867)
	#	return False

	# Finding the Default Ore table for this Region
	region = char.region
	Oretable = FindOreTable(region)

	veingem = getvein(Oretable, pos, char)

	if not veingem or not veingem.hastag('resourcecount'):
		return False

	# 50% chance to dig up primary resource,
	# even if the vein has something else.
	if veingem.hastag('resname2') and random.random() >= 0.50:
		resname = veingem.gettag('resname2')
	else:
		resname = veingem.gettag('resname')

	resourcecount = veingem.gettag('resourcecount')
	reqskill = Oretable[resname][REQSKILL]

	# Refill the resource gem.
	if resourcecount == 0:
		socket.sysmessage( tr("There is no ore here to mine.") )

		if not veingem.hastag('resource_empty'):
			# Picking the next amount
			nextamount = random.randint(Oretable[resname][MINAMOUNT], Oretable[resname][MAXAMOUNT])
			duration = random.randint(MINING_REFILLTIME[0], MINING_REFILLTIME[1])
			veingem.addtimer( duration, respawnvein, [nextamount], True )
			veingem.settag('resource_empty', 1)
		return False

	# You loosen some rocks but fail to find any usable ore.
	if char.skill[MINING] < reqskill:
		socket.clilocmessage(501869)
		return False

	chance = max(0, char.skill[MINING] - Oretable[resname][MINSKILL]) / 1000.0
	success = 0

	if not skills.checkskill(char, MINING, chance):
		socket.clilocmessage(501869)
		return False

	# Digs up the large ore.
	if resourcecount >= 5:
		successmining(Oretable, char, veingem, resname, 3)

	# Picks one of the smaller ore types
	elif resourcecount == 3 or resourcecount == 4:
		successmining(Oretable, char, veingem, resname, 2)

	# Smallest ore only
	elif resourcecount == 1 or resourcecount == 2:
		successmining(Oretable, char, veingem, resname, 1)
	wearout(char, tool)
def domining(char, args):
    char.soundeffect(SOUND_MINING)
    tool = wolfpack.finditem(args[0])
    pos = args[1]
    socket = char.socket
    socket.deltag("is_mining")

    if not tool:
        return False

        # Recheck distance
        # if not char.canreach(pos, MINING_MAX_DISTANCE):
        # 	socket.clilocmessage(501867)
        # 	return False

    veingem = getvein(socket, pos)

    if not veingem or not veingem.hastag("resourcecount"):
        return False

        # 50% chance to dig up primary resource,
        # even if the vein has something else.
    if veingem.hastag("resname2") and random.random() >= 0.50:
        resname = veingem.gettag("resname2")
    else:
        resname = veingem.gettag("resname")

    resourcecount = veingem.gettag("resourcecount")
    reqskill = ORES[resname][REQSKILL]

    # Refill the resource gem.
    if resourcecount == 0:
        socket.sysmessage("There is no ore here to mine.")

        if not veingem.hastag("resource_empty"):
            duration = random.randint(MINING_REFILLTIME[0], MINING_REFILLTIME[1])
            veingem.addtimer(duration, "skills.mining.respawnvein", [], True)
            veingem.settag("resource_empty", 1)
        return False

        # You loosen some rocks but fail to find any usable ore.
    if char.skill < reqskill:
        socket.clilocmessage(501869)
        return False

    chance = max(0, char.skill[MINING] - ORES[resname][MINSKILL]) / 1000.0
    success = 0

    if not skills.checkskill(char, MINING, chance):
        socket.clilocmessage(501869)
        return False

        # Digs up the large ore.
    if resourcecount >= 5:
        successmining(char, veingem, resname, 3)

        # Picks one of the smaller ore types
    elif resourcecount == 3 or resourcecount == 4:
        successmining(char, veingem, resname, 2)

        # Smallest ore only
    elif resourcecount == 1 or resourcecount == 2:
        successmining(char, veingem, resname, 1)

        # Remaining Tool Uses
    if not tool.hastag("remaining_uses"):
        tool.settag("remaining_uses", tool.health)
    else:
        remaining_uses = int(tool.gettag("remaining_uses"))
        if remaining_uses > 1:
            tool.settag("remaining_uses", remaining_uses - 1)
            tool.resendtooltip()
        else:
            tool.delete()
            socket.clilocmessage(1044038)  # You have worn out your tool!

    return True