示例#1
0
文件: bowl.py 项目: thooge/Wolfpack
def target(player, arguments, target):
    bowl = wolfpack.finditem(arguments[0])  # Find the bowl that has been used

    # The bowl still has to exist and be a bowl
    if not bowl or bowl.baseid != BOWL_BASEID:
        return

    # Still has to be in our backpack
    if bowl.getoutmostitem() != player.getbackpack():
        player.socket.clilocmessage(
            1042664)  # You must have the object in your backpack to use it.
        return

    # Check if we can reach the target (3 tiles)
    if not player.canreach(target, 3):
        player.socket.clilocmessage(502825)  # That location is too far away
        return

    # Check if its an item and fertile dirt
    if target.item and target.item.baseid == FERTILEDIRT_BASEID:
        # Has to be in the backpack to use it
        if target.item.getoutmostitem() != player.getbackpack():
            player.socket.clilocmessage(
                1042664
            )  # You must have the object in your backpack to use it.

        # Need at least 40 fertile dirt to fill bowl
        elif target.item.amount < 40:
            player.socket.clilocmessage(
                1061896)  # You need more dirt to fill a plant bowl!

        # If we can create the bowl, consume the dirt
        elif makePlant(player, bowl, True):
            # Consume 40 dirt
            if target.item.amount == 40:
                target.item.delete()
            else:
                target.item.amount -= 40
                target.item.update()

    # Check if we targetted a dynamic/static dirt patch
    elif target.item and target.item.id in STATIC_DIRT and not player.canpickup(
            target.item):
        makePlant(player, bowl)

    # Assume the client sent valid data (this is BAD), the core should check if a static target is correct. MUCH faster.
    # This is a static tile
    elif not target.item and not target.char and target.model in STATIC_DIRT:
        makePlant(player, bowl)

    # Otherwise get the map at the given position
    elif not target.item and wolfpack.map(target.pos.x, target.pos.y,
                                          target.pos.map)['id'] in MAP_DIRT:
        makePlant(player, bowl)

    else:
        player.socket.clilocmessage(
            1061893
        )  # You'll want to gather fresh dirt in order to raise a healthy plant!
示例#2
0
def fillfrommap(target, item, cprops):
	mapTile = wolfpack.map( target.pos.x, target.pos.y, target.pos.map )
	if target.model in staticWater or mapTile[ "id" ] in mapWater:
		quantity = cprops[1]
		if quantity > 0:
			item.settag('fluid', 'water')
			item.settag('quantity', quantity)
			updateItemIdFromFluid(item, 'water')
			item.resendtooltip()
示例#3
0
def target(player, arguments, target):
	bowl = wolfpack.finditem(arguments[0]) # Find the bowl that has been used

	# The bowl still has to exist and be a bowl
	if not bowl or bowl.baseid != BOWL_BASEID:
		return

	# Still has to be in our backpack
	if bowl.getoutmostitem() != player.getbackpack():
		player.socket.clilocmessage(1042664) # You must have the object in your backpack to use it.
		return

	# Check if we can reach the target (3 tiles)
	if not player.canreach(target, 3):
		player.socket.clilocmessage(502825) # That location is too far away
		return

	# Check if its an item and fertile dirt
	if target.item and target.item.baseid == FERTILEDIRT_BASEID:
		# Has to be in the backpack to use it
		if target.item.getoutmostitem() != player.getbackpack():
			player.socket.clilocmessage(1042664) # You must have the object in your backpack to use it.

		# Need at least 40 fertile dirt to fill bowl
		elif target.item.amount < 40:
			player.socket.clilocmessage(1061896) # You need more dirt to fill a plant bowl!

		# If we can create the bowl, consume the dirt
		elif makePlant(player, bowl, True):
			# Consume 40 dirt
			if target.item.amount == 40:
				target.item.delete()
			else:
				target.item.amount -= 40
				target.item.update()

	# Check if we targetted a dynamic/static dirt patch
	elif target.item and target.item.id in STATIC_DIRT and not player.canpickup(target.item):
		makePlant(player, bowl)

	# Assume the client sent valid data (this is BAD), the core should check if a static target is correct. MUCH faster.
	# This is a static tile
	elif not target.item and not target.char and target.model in STATIC_DIRT:
		makePlant(player, bowl)

	# Otherwise get the map at the given position
	elif not target.item and wolfpack.map(target.pos.x, target.pos.y, target.pos.map)['id'] in MAP_DIRT:
		makePlant(player, bowl)

	else:
		player.socket.clilocmessage(1061893) # You'll want to gather fresh dirt in order to raise a healthy plant!
示例#4
0
def response( char, args, target ):
	socket = char.socket
	if not socket:
		return False

	pos = target.pos

	# Player can reach that ?
	if char.pos.map != pos.map or char.pos.distance( pos ) > MINING_MAX_DISTANCE:
		# That is too far away
		socket.clilocmessage( 500446, "", GRAY )
		return True

	tool = wolfpack.finditem(args[0])

	#Player also can't mine when riding, polymorphed and dead.
	#Mine char ?!
	if target.char:
		# You can't mine that.
		socket.clilocmessage( 501863, "", GRAY )
		return True

	#Find tile by it's position if we haven't model
	elif target.model == 0:
		map = wolfpack.map( target.pos.x, target.pos.y, target.pos.map )
		if ismountainorcave( map['id'] ):
			mining( char, target.pos, tool, sand = False )
		elif issand( map['id'] ) and char.hastag('sandmining'):
			mining( char, target.pos, tool, sand = True )
		else:
			# You can't mine there.
			socket.clilocmessage( 501862, "", GRAY )
		return True

	#Find tile by it's model
	elif target.model != 0:
		if ismountainorcave( target.model ):
			#add new ore gem here and mine
			mining( char, target.pos, tool )
		else:
			socket.clilocmessage( 501862, "", GRAY ) # You can't mine there.
		return True

	else:
		return False

	return True
示例#5
0
def infotargetresponse( char, args, target ):
	if not char.socket:
		return 0

	# map target
	if target.char:
		charinfo( char.socket, target.char )
		return 1
	elif target.item:
		iteminfo( char.socket, target.item )
		return 1
	elif target.model == 0:
		map = wolfpack.map( target.pos.x, target.pos.y, target.pos.map )
		tile = wolfpack.landdata( map['id'] )
		maptileinfo( char.socket, map, tile )
		return 1
	elif target.model != 0:
		tile = wolfpack.tiledata( target.model )
		statictileinfo( char.socket, target.model, target.pos, tile )
		return 1
	return 1
示例#6
0
def boom_timer(object, args):
	(x, y, map) = args

	z = wolfpack.map(x, y, map)['z']

	pos = wolfpack.coord(x, y, z, map)

	if 0.5 >= random.random():
		t = random.randint(0, 2)

		# Fire Column
		if t == 0:
			pos.effect(0x3709, 10, 30)
			pos.soundeffect(0x208)

		# Explosion
		elif t == 1:
			pos.effect(0x36bd, 20, 10)
			pos.soundeffect(0x307)

		# Ball of fire
		elif t == 2:
			pos.effect(0x36fe, 10, 10)
示例#7
0
def response( char, args, target ):
	socket = char.socket
	pos = target.pos

	if skills.skilltable[ FISHING ][ skills.UNHIDE ] and char.hidden:
		char.removefromview()
		char.hidden = False
		char.update()

	# First: Check Distance (easiest)
	if char.pos.map != pos.map or char.pos.distance( pos ) > FISHING_MAX_DISTANCE:
		socket.clilocmessage( 0x7a4f0, "", 0x3b2, 3, char ) # You need to be closer to the water to fish!
		return

	# Second: Check Map/Static/Dynamic Water and eventual blocking stuff above it
	validspot   = 0
	blockedspot = 0
	deepwater   = 0

	mapTile = wolfpack.map( pos.x, pos.y, pos.map )

	# Simple check for saving CPU time (trusted-check)
	if not target.model in staticWater and not mapTile[ "id" ] in mapWater:
		socket.clilocmessage( 0x7a4f2, "", 0x3b2, 3, char ) # You need water to fish in!
		return

	# Check dynamics first ( And check if any objects start at z -> z + 13 )
	items = wolfpack.items( pos.x, pos.y, pos.map, 1 ) # 1: Exact

	for item in items:
		if item.id in staticWater and item.pos.z == pos.z and item.visible:
			validspot = 1
			deepwater = 0
			break

	# Then check statics ( And check if any objects start at z -> z + 13 )
	staticitems = wolfpack.statics( pos.x, pos.y, pos.map, 1 ) # Don't put this in any conditional we need it later

	if not validspot:
		for item in staticitems:
			if item[0] in staticWater and item[3] == pos.z:
				validspot = 1
				deepwater = 0
				break

	# Last resort check (Map)
	if not validspot and ( mapTile[ "id" ] in mapWater and mapTile[ "z" ] == pos.z ):
		validspot = 1
		deepwater = 0

	if not validspot:
		socket.clilocmessage( 0x7a4f2, "", 0x3b2, 3, char ) # You need water to fish in!
		return

	# Check if there is *anything* above that spot
	for item in items:
		if ( not item.id in staticWater ) and ( item.pos.z >= pos.z ) and ( item.pos.z <= pos.z + FISHING_BLOCK_RANGE ):
			# Check if the tiledata defines this as "impassable" or "surface"
			tile = wolfpack.tiledata( item.id )

			if tile[ "blocking" ] or tile[ "floor" ]:
				blockedspot = 1
				break

	# only check if we're not blocked already
	if not blockedspot:
		for item in staticitems:
			if ( not item[ 'id' ] in staticWater ) and ( item[ "z" ] >= pos.z ) and ( item[ "z" ] <= pos.z + FISHING_BLOCK_RANGE ):
				tile = wolfpack.tiledata( item.id )

				if tile[ "blocking" ] or tile[ "floor" ]:
					blockedspot = 1
					break

	# If the targetted tile is below map height check that as well
	mapZ = mapTile[ "z" ]
	if not blockedspot and pos.z < mapZ:
		if pos.z > ( mapZ - FISHING_BLOCK_RANGE ):
			blockedspot = 1

	if blockedspot:
		socket.clilocmessage( 0x7a4f5, "", 0x3b2, 3, char ) # You can't reach the water there.
		return

	# Turn to the position we're fishing at
	char.turnto( pos )

	# Show the Fishing animation
	char.action( 0x0c )

	# Wearout of fishing poles ?
	# ID: 0x7AD86 (0)
	# You broke your fishing pole.

	socket.settag( 'is_fishing', int( wolfpack.time.currenttime() + 5000 ) ) # Times out after 5000ms
	char.addtimer( 2500, effecttimer, [ pos, deepwater ] )
	char.addtimer( 5000, itemtimer, [ pos, deepwater, args[0] ] )

	pass
示例#8
0
文件: mining.py 项目: thooge/Wolfpack
def response(char, args, target):
    socket = char.socket
    if not socket:
        return False

    pos = target.pos

    # Player can reach that ?
    if char.pos.map != pos.map or char.pos.distance(pos) > MINING_MAX_DISTANCE:
        # That is too far away
        socket.clilocmessage(500446, "", GRAY)
        return True

    tool = wolfpack.finditem(args[0])

    #Player also can't mine when riding, polymorphed and dead.
    #Mine char ?!
    if target.char:
        # You can't mine that.
        socket.clilocmessage(501863, "", GRAY)
        return True

    #Find tile by it's position if we haven't model
    elif target.model == 0:
        map = wolfpack.map(target.pos.x, target.pos.y, target.pos.map)
        ###########################
        # Searching for a Treasure
        ###########################
        bag = char.getbackpack()
        if bag.countresource(0x14eb) > 0:
            # Assign a variable to stop or not process
            foundtreas = 0
            # Loop content in player's Backpack
            for cmap in bag.content:
                if cmap.id == 0x14eb and cmap.hastag(
                        'level') and not cmap.hastag('founded'):
                    foundtreas = checktreaspoint(target.pos.x, target.pos.y,
                                                 target.pos.z, target.pos.map,
                                                 cmap, char)
                    if foundtreas == 1:
                        break
            # Stop Action
            if foundtreas == 1:
                return True

        if ismountainorcave(map['id']):
            mining(char, target.pos, tool, sand=False)
        elif issand(map['id']) and canminesand(char):
            mining(char, target.pos, tool, sand=True)
        else:
            # You can't mine there.
            socket.clilocmessage(501862, "", GRAY)
        return True

    #Find tile by it's model
    elif target.model != 0:
        ###########################
        # Searching for a Treasure
        ###########################
        bag = char.getbackpack()
        if bag.countresource(0x14eb) > 0:
            # Assign a variable to stop or not process
            foundtreas = 0
            # Loop content in player's Backpack
            for cmap in bag.content:
                if cmap.id == 0x14eb and cmap.hastag('level'):
                    foundtreas = checktreaspoint(target.pos.x, target.pos.y,
                                                 target.pos.z, target.pos.map,
                                                 cmap, char)
                    if foundtreas == 1:
                        break
            # Stop Action
            if foundtreas == 1:
                return True

        if ismountainorcave(target.model):
            #add new ore gem here and mine
            mining(char, target.pos, tool)
        else:
            socket.clilocmessage(501862, "", GRAY)  # You can't mine there.
        return True

    else:
        return False
示例#9
0
def docarve( char, item, target ):
	# Corpse => Carve
	# Wood => Kindling/Logs
	model = 0

	if target.item:
		if carve_item( char, item, target ):
			return
		else:
			model = target.item.id

	# This is for sheering only
	elif target.char and target.char.npc:
		if target.char.baseid == 'sheep_unsheered':
			target.char.id = 223
			target.char.baseid = 'sheep_sheered'
			target.char.update()

			# Create Wool
			wool = wolfpack.additem("df8")
			wool.amount = 2

			if not utilities.tobackpack(wool, char):
				wool.update()

			# Resend weight
			char.socket.resendstatus()

			char.socket.clilocmessage( 500452 ) # You place the gathered wool into your backpack.

			# Let the wool regrow (minutes)
			delay = settings.getnumber('Game Speed', 'Regrow Wool Minutes', 180, 1)
			delay *= 60000 # Miliseconds per Minute
			target.char.dispel(None, 1, "regrow_wool", [])
			target.char.addtimer(delay, regrow_wool, [], 1, 0, "regrow_wool")
			return
		elif target.char.baseid == 'sheep' or target.char.baseid == 'sheep_sheered':
			char.socket.clilocmessage( 500449 ) # This sheep is not yet ready to be shorn.
			return
		else:
			char.socket.clilocmessage( 500450 ) # You can only skin dead creatures.
			return
	else:
		model = target.model

	if target.model == 0:
		map = wolfpack.map( target.pos.x, target.pos.y, target.pos.map )
		treeid = map['id']
	elif target.model != 0:
		treeid = target.model

	if utilities.istree(treeid):
		# Axes/Polearms get Logs, Swords get kindling.
		# Also allows a mace's war axe to be use. 0x13af and 0x13b0
		if item.type == 1002 or item.id == 0x13af or item.id == 0x13b0:
			if not item or not item.container == char:
				char.message( 502641, "" ) # You must equip this item to use it.
				return
			else:
				skills.lumberjacking.response( [ target, item, char ] )
		# Swords and Fencing Weapons: Get kindling
		elif item.type == 1001 or item.type == 1005:
			skills.lumberjacking.hack_kindling( char, target.pos )
	else:
		char.socket.clilocmessage( 500494, "", GRAY ) # You can't use a bladed item on that.
		return False
示例#10
0
def response( char, args, target ):
	socket = char.socket
	if not socket:
		return False

	pos = target.pos

	# Player can reach that ?
	if char.pos.map != pos.map or char.pos.distance( pos ) > MINING_MAX_DISTANCE:
		# That is too far away
		socket.clilocmessage( 500446, "", GRAY )
		return True

	tool = wolfpack.finditem(args[0])

	#Player also can't mine when riding, polymorphed and dead.
	#Mine char ?!
	if target.char:
		# You can't mine that.
		socket.clilocmessage( 501863, "", GRAY )
		return True

	#Find tile by it's position if we haven't model
	elif target.model == 0:
		map = wolfpack.map( target.pos.x, target.pos.y, target.pos.map )
		###########################
		# Searching for a Treasure
		###########################
		bag = char.getbackpack()
		if bag.countresource(0x14eb) > 0:
			# Assign a variable to stop or not process
			foundtreas = 0
			# Loop content in player's Backpack
			for cmap in bag.content:
				if cmap.id == 0x14eb and cmap.hastag('level') and not cmap.hastag('founded'):
					foundtreas = checktreaspoint(target.pos.x, target.pos.y, target.pos.z, target.pos.map, cmap, char)
					if foundtreas == 1:
						break
			# Stop Action
			if foundtreas == 1:
				return True

		if ismountainorcave( map['id'] ):
			mining( char, target.pos, tool, sand = False )
		elif issand( map['id'] ) and canminesand(char):
			mining( char, target.pos, tool, sand = True )
		else:
			# You can't mine there.
			socket.clilocmessage( 501862, "", GRAY )
		return True

	#Find tile by it's model
	elif target.model != 0:
		###########################
		# Searching for a Treasure
		###########################
		bag = char.getbackpack()
		if bag.countresource(0x14eb) > 0:
			# Assign a variable to stop or not process
			foundtreas = 0
			# Loop content in player's Backpack
			for cmap in bag.content:
				if cmap.id == 0x14eb and cmap.hastag('level'):
					foundtreas = checktreaspoint(target.pos.x, target.pos.y, target.pos.z, target.pos.map, cmap, char)
					if foundtreas == 1:
						break
			# Stop Action
			if foundtreas == 1:
				return True

		if ismountainorcave( target.model ):
			#add new ore gem here and mine
			mining( char, target.pos, tool )
		else:
			socket.clilocmessage( 501862, "", GRAY ) # You can't mine there.
		return True

	else:
		return False
示例#11
0
def response(char, args, target):
    item = wolfpack.finditem(args[0])
    if not item:
        return

    if target.char and not char.canreach(target.char, 5):
        char.socket.clilocmessage(500312)
        return

    elif not target.item and not char.canreach(target.pos, 5):
        char.socket.clilocmessage(500312)
        return

        # Corpse => Carve
        # Wood => Kindling/Logs
    model = 0

    if target.item:
        if target.item.id == 0x2006 and target.item.corpse:
            if not char.canreach(target.item, 5):
                char.socket.clilocmessage(500312)
                return

            carve_corpse(char, target.item)
            return

            # For cutting fish
        elif target.item.id in fish:
            if target.item.getoutmostchar() != char:
                char.socket.clilocmessage(500312)
                return

            cut_fish(char, target.item)
            return

        else:
            model = target.item.id

            # This is for sheering only
    elif target.char and target.char.npc:
        if target.char.baseid == "sheep_unsheered":
            target.char.id = 223
            target.char.baseid = "sheep_sheered"
            target.char.update()

            # Create Wool
            wool = wolfpack.additem("df8")
            wool.amount = 2

            if not utilities.tobackpack(wool, char):
                wool.update()

            char.socket.clilocmessage(0x7A2E4)  # You place the gathered wool into your backpack.

            # Let the wool regrow (minutes)
            delay = settings.getnumber("Game Speed", "Regrow Wool Minutes", 180, 1)
            delay *= 60000  # Miliseconds per Minute
            target.char.dispel(None, 1, "regrow_wool", [])
            target.char.addtimer(delay, "blades.regrow_wool", [], 1, 0, "regrow_wool")
            return
        elif target.char.id == "sheep_sheered":
            char.socket.clilocmessage(0x7A2E1)  # This sheep is not yet ready to be shorn.
            return
        else:
            char.socket.clilocmessage(0x7A2E2)  # You can only skin dead creatures.
            return
    else:
        model = target.model

    if target.model == 0:
        map = wolfpack.map(target.pos.x, target.pos.y, target.pos.map)
        treeid = map["id"]
    elif target.model != 0:
        treeid = target.model

    if utilities.istree(treeid):
        # Axes/Polearms get Logs, Swords get kindling.
        # Also allows a mace's war axe to be use. 0x13af and 0x13b0
        if item.type == 1002 or item.id == 0x13AF or item.id == 0x13B0:
            if not item or not item.container == char:
                char.message("You must equip this item to use it on this target!")
                return
            else:
                skills.lumberjacking.response([target, item, char])
                # Swords and Fencing Weapons: Get kindling
        elif item.type == 1001 or item.type == 1005:
            skills.lumberjacking.hack_kindling(char, target.pos)
    else:
        # You can't use a bladed item on that.
        char.socket.clilocmessage(500494, "", GRAY)
        return False
示例#12
0
def refill_target(char, args, target):
    item = wolfpack.finditem(args[0])
    if not item:
        return

    if not CONTAINERS.has_key(item.id):
        return

    cprops = CONTAINERS[item.id]

    if not char.canreach(target.pos, 3):
        char.socket.clilocmessage(1019045)
        return

    if target.item:
        if CONTAINERS.has_key(target.item.id):
            quantity = 0
            if target.item.hastag("quantity"):
                quantity = int(target.item.gettag("quantity"))

            fluid = ""
            if target.item.hastag("fluid"):
                fluid = str(target.item.gettag("fluid"))

            if quantity > 0 and FLUIDS.has_key(fluid):
                item.settag("fluid", fluid)

                # How much can we refill?
                if quantity > cprops[1]:
                    quantity -= cprops[1]
                    target.item.settag("quantity", quantity)
                    target.item.resendtooltip()
                    item.settag("quantity", cprops[1])
                    updateItemIdFromFluid(item, "water")
                    item.resendtooltip()

                    # The source will be depleted
                else:
                    item.settag("quantity", quantity)
                    item.resendtooltip()

                    cprop = CONTAINERS[target.item.id]
                    if cprop[2] == 0:
                        target.item.delete()
                    else:
                        target.item.id = cprop[2]
                        target.item.update()
                        target.item.deltag("quantity")
                        target.item.deltag("fluid")
                        target.item.resendtooltip()

                return  # We refilled

                # A watersource
        if target.item.watersource:
            # Check if its depletable
            quantity = cprops[1]
            if target.item.hastag("quantity"):
                quantity = int(item.gettag("quantity"))

            if quantity > 0:
                item.settag("fluid", "water")
                item.settag("quantity", quantity)
                updateItemIdFromFluid(item, "water")
                item.resendtooltip()
        return

        # Check map if its a water source
    elif not target.char:
        mapTile = wolfpack.map(target.pos.x, target.pos.y, target.pos.map)
        if target.model in staticWater or mapTile["id"] in mapWater:
            quantity = cprops[1]
            if quantity > 0:
                item.settag("fluid", "water")
                item.settag("quantity", quantity)
                updateItemIdFromFluid(item, "water")
                item.resendtooltip()
def target(player, arguments, target):
	# Check the green thorn first
	item = wolfpack.finditem(arguments[0])
	
	# Check if we have the item in our backpack
	if not item or item.getoutmostitem() != player.getbackpack():
		player.socket.clilocmessage(1042038) # You must have the object in your backpack to use it.
		return
		
	# Check the green thorn delay
	if not checkUse(player):
		player.message(1061908) # * You must wait a while before planting another thorn. *
		return

	# This check should only happen for solen hives
	if player.pos.map not in [0, 1]:
		player.message(tr("No solen lairs exist on this facet.  Try again in Trammel or Felucca."), 0x2b2)
		return
		
	# Can we reach the target location?
	if not player.canreach(target.pos, 3):
		player.message(502825) # That location is too far away
		return
		
	# Get the land-tile id at the given location
	landid = wolfpack.map(target.pos.x, target.pos.y, player.pos.map)['id']
	
	callback = None # Callback for the green thorns effect
	
	# Check which effect should be used for the landtile type
	if landid in DIRT_TILES:
		callback = dirtCallback
		
	elif landid in FURROWS_TILES:
		callback = furrowsCallback
		
	elif landid in SWAMP_TILES:
		callback = swampCallback
	
	elif landid in SNOW_TILES:
		callback = snowCallback
	
	elif landid in SAND_TILES:
		callback = sandCallback

	if not callback:
		player.message(1061913)
	else:
		if item.amount <= 1:
			item.delete()
		else:
			item.amount -= 1
			item.update()
			
		# Show a message that we're planting a thorn
		player.socket.clilocmessage(1061914, "", 0x961, 3, player, "", False, True) # * You push the strange green thorn into the ground *
		listeners = wolfpack.chars(player.pos.x, player.pos.y, player.pos.map, 18)
		
		for listener in listeners:
			if listener != player and listener.socket:
				listener.socket.clilocmessage(1061915, player.name, 0x961, 3, player, "", False, True) # * ~1_PLAYER_NAME~ pushes a strange green thorn into the ground. *
		
		# Set the next use delay for this kind of item
		player.socket.settag('greenthorn_delay', wolfpack.currenttime() + GREENTHORN_DELAY)
		
		# Start the effect
		player.addtimer(2500, callback, [target.pos, 0])
示例#14
0
def target(player, arguments, target):
    # Check the green thorn first
    item = wolfpack.finditem(arguments[0])

    # Check if we have the item in our backpack
    if not item or item.getoutmostitem() != player.getbackpack():
        player.socket.clilocmessage(
            1042038)  # You must have the object in your backpack to use it.
        return

    # Check the green thorn delay
    if not checkUse(player):
        player.message(
            1061908
        )  # * You must wait a while before planting another thorn. *
        return

    # This check should only happen for solen hives
    if player.pos.map not in [0, 1]:
        player.message(
            tr("No solen lairs exist on this facet.  Try again in Trammel or Felucca."
               ), 0x2b2)
        return

    # Can we reach the target location?
    if not player.canreach(target.pos, 3):
        player.message(502825)  # That location is too far away
        return

    # Get the land-tile id at the given location
    landid = wolfpack.map(target.pos.x, target.pos.y, player.pos.map)['id']

    callback = None  # Callback for the green thorns effect

    # Check which effect should be used for the landtile type
    if landid in DIRT_TILES:
        callback = dirtCallback

    elif landid in FURROWS_TILES:
        callback = furrowsCallback

    elif landid in SWAMP_TILES:
        callback = swampCallback

    elif landid in SNOW_TILES:
        callback = snowCallback

    elif landid in SAND_TILES:
        callback = sandCallback

    if not callback:
        player.message(1061913)
    else:
        if item.amount <= 1:
            item.delete()
        else:
            item.amount -= 1
            item.update()

        # Show a message that we're planting a thorn
        player.socket.clilocmessage(
            1061914, "", 0x961, 3, player, "", False,
            True)  # * You push the strange green thorn into the ground *
        listeners = wolfpack.chars(player.pos.x, player.pos.y, player.pos.map,
                                   18)

        for listener in listeners:
            if listener != player and listener.socket:
                listener.socket.clilocmessage(
                    1061915, player.name, 0x961, 3, player, "", False, True
                )  # * ~1_PLAYER_NAME~ pushes a strange green thorn into the ground. *

        # Set the next use delay for this kind of item
        player.socket.settag('greenthorn_delay',
                             wolfpack.time.currenttime() + GREENTHORN_DELAY)

        # Start the effect
        player.addtimer(2500, callback, [target.pos, 0])
示例#15
0
def response( char, args, target ):
	socket = char.socket
	pos = target.pos

	if skills.skilltable[ FISHING ][ skills.UNHIDE ] and char.hidden:
		char.reveal()

	# Check Map/Static/Dynamic Water and eventual blocking stuff above it
	validspot   = 0
	blockedspot = 0
	deepwater   = 0

	mapTile = wolfpack.map( pos.x, pos.y, pos.map )

	# Simple check for saving CPU time (trusted-check)
	if not target.model in staticWater and not mapTile[ "id" ] in mapWater:
		socket.clilocmessage( 0x7a4f2, "", 0x3b2, 3, char ) # You need water to fish in!
		return

	# Check Distance
	if char.pos.map != pos.map or char.pos.distance( pos ) > FISHING_MAX_DISTANCE:
		socket.clilocmessage( 0x7a4f0, "", 0x3b2, 3, char ) # You need to be closer to the water to fish!
		return

	# Check dynamics first ( And check if any objects start at z -> z + 13 )
	items = wolfpack.items( pos.x, pos.y, pos.map, 1 ) # 1: Exact

	for item in items:
		if item.id in staticWater and item.pos.z == pos.z and item.visible:
			validspot = 1
			deepwater = 0
			break

	# Then check statics ( And check if any objects start at z -> z + 13 )
	staticitems = wolfpack.statics( pos.x, pos.y, pos.map, 1 ) # Don't put this in any conditional we need it later

	if not validspot:
		for item in staticitems:
			if item[0] in staticWater and item[3] == pos.z:
				validspot = 1
				deepwater = 0
				break

	# Last resort check (Map)
	if not validspot and ( mapTile[ "id" ] in mapWater and mapTile[ "z" ] == pos.z ):
		validspot = 1
		deepwater = 0

	if not validspot:
		socket.clilocmessage( 0x7a4f2, "", 0x3b2, 3, char ) # You need water to fish in!
		return

	# Check if there is *anything* above that spot
	for item in items:
		if ( not item.id in staticWater ) and ( item.pos.z >= pos.z ) and ( item.pos.z <= pos.z + FISHING_BLOCK_RANGE ):
			# Check if the tiledata defines this as "impassable" or "surface"
			tile = wolfpack.tiledata( item.id )

			if tile[ "blocking" ] or tile[ "floor" ]:
				blockedspot = 1
				break

	# only check if we're not blocked already
	if not blockedspot:
		for item in staticitems:
			if ( not item[ 0 ] in staticWater ) and ( item[ 3 ] >= pos.z ) and ( item[ 3 ] <= pos.z + FISHING_BLOCK_RANGE ):
				tile = wolfpack.tiledata( item[0] )

				if tile[ "blocking" ] or tile[ "floor" ]:
					blockedspot = 1
					break

	# If the targetted tile is below map height check that as well
	mapZ = mapTile[ "z" ]
	if not blockedspot and pos.z < mapZ:
		if pos.z > ( mapZ - FISHING_BLOCK_RANGE ):
			blockedspot = 1

	if blockedspot:
		socket.clilocmessage( 0x7a4f5, "", 0x3b2, 3, char ) # You can't reach the water there.
		return

	# Turn to the position we're fishing at
	char.turnto( pos )

	# Show the Fishing animation
	char.action( 0x0c )

	socket.settag( 'is_fishing', int( wolfpack.time.currenttime() + 5000 ) ) # Times out after 5000ms
	char.addtimer( 2500, effecttimer, [ pos, deepwater ] )
	char.addtimer( 5000, itemtimer, [ pos, deepwater, args[0] ] )

	pass