예제 #1
0
def check_spot(char):
    x = char.pos.x
    y = char.pos.y
    z = char.pos.z
    map = char.pos.map

    # We can build on floor
    # Check for dynamic items
    tile = wolfpack.items(x, y, map)
    if tile:
        dynamic_floor = wolfpack.tiledata(tile[0].id)["floor"]
        if len(tile) and not dynamic_floor:
            return False

    # Check for dynamic items
    tile = wolfpack.statics(x, y, map, True)
    if tile:
        for i in tile:
            height = i[3] > z and i[3] < (
                z + 20)  # something is between the ground and +20?
            static_floor = wolfpack.tiledata(i[0])["floor"]
            static_roof = wolfpack.tiledata(i[0])["flag1"] & 0x10
            if len(
                    tile
            ) and height:  #and and not static_floor and not static_roof: # seems that the floor flag is not used for all
                return False
    return True
예제 #2
0
def isWall(x, y, z, map):
	tiles = wolfpack.statics(x, y, map, 1)

	for tile in tiles:
		wall = wolfpack.tiledata(tile[0])["flag1"] & 0x010
		if wall and (z + 16) > tile[3] and (tile[3] + wolfpack.tiledata(tile[0])["height"]) > z:
			return True
	return False
예제 #3
0
def wash_response( char, args, target ):
	bandages = wolfpack.finditem( args[0] )

	if not bandages:
		return

	if (target.item and target.item.getoutmostchar() and target.item.getoutmostchar() != char) or not char.canreach(target.pos, 5):
		char.socket.clilocmessage(500312)
		return

	# Did we target something wet?
	id = 0

	if target.item:
		id = target.item.id
	else:
		id = target.model

	# Wash Basins are allowed.
	if not target.item or target.item.id != 0x1008:
		tiledata = wolfpack.tiledata(id)
		if not tiledata[ 'flag1' ] & 0x80:
			char.socket.sysmessage('You cannot wash your bandages here.')
			return

	char.socket.sysmessage('You wash your bandages and put the clean bandages into your backpack.')

	if bandages.id == 0xe20:
		bandages.id = 0xe21
	elif bandages.id == 0xe22:
		bandages.id = 0xee9

	bandages.update()
예제 #4
0
 def save(self):
     for map in self.maps:
         file = open("save_doors.%i.xml" % map, "w")
         file.write("<decoration>\n")
         for id in self.maps[map]:
             itemsbyhue = {}
             for item in self.maps[map][id]:
                 if not item.color in itemsbyhue:
                     itemsbyhue[item.color] = []
                 itemsbyhue[item.color].append(item)
             tiledata = wolfpack.tiledata(id)
             for hue in itemsbyhue:
                 file.write("""\t<!-- %s -->\n""" % tiledata["name"])
                 if hue != 0:
                     file.write("""\t<item id="0x%x" hue="0x%x">\n""" %
                                (id, hue))
                 else:
                     file.write("""\t<item id="0x%x">\n""" % id)
                 for item in itemsbyhue[hue]:
                     pos = item.pos
                     file.write(
                         """\t\t<pos x="%i" y="%i" z="%i" map="%i" />\n""" %
                         (pos.x, pos.y, pos.z, pos.map))
                 file.write("\t</item>\n")
         file.write("</decoration>\n")
         file.close()
예제 #5
0
def calcSpellId( item ):
	tile = wolfpack.tiledata( item.id )
	spell = tile[ "unknown1" ]

	if spell == 0:
		raise

	return ( spell - 1 )
예제 #6
0
def onUse(player, item):
	if item.container == player:
		return 0

	tile = wolfpack.tiledata(item.id)

	if not tile.has_key('layer'):
		return 0

	layer = tile['layer']

	if layer == 0 or not (tile['flag3'] & 0x40):
		return 0

	previous = player.itemonlayer(layer)
	if previous:
		tobackpack(previous, player)
		previous.soundeffect(0x57)
		previous.update()

	if layer == LAYER_RIGHTHAND or layer == LAYER_LEFTHAND:
		# Check if we're equipping on one of the standard layers
		righthand = player.itemonlayer(LAYER_RIGHTHAND)
		lefthand = player.itemonlayer(LAYER_LEFTHAND)

		if righthand and (righthand.twohanded or (layer == 2 and item.twohanded)):
			tobackpack(righthand, player)
			righthand.update()
			righthand.soundeffect(0x57)

		if lefthand and (lefthand.twohanded or (layer == 1 and item.twohanded)):
			tobackpack(lefthand, player)
			lefthand.update()
			lefthand.soundeffect(0x57)

	# Check if there is another dclick handler
	# in the eventchain somewhere. if not,
	# return 1 to handle the equip event.
	scripts = item.scripts

	for script in scripts:
		if wolfpack.hasevent(script, EVENT_WEARITEM):
			result = wolfpack.callevent(script, EVENT_WEARITEM, (player, player, item, layer))
			if result:
				return 1

	player.additem(layer, item)
	item.update()
	item.soundeffect(0x57)
	player.updatestats()

	for script in scripts[scripts.index("equipment")+1:]:
		if wolfpack.hasevent(script, EVENT_USE):
		 return 0

	return 1
예제 #7
0
def check_spot( char ):
	x = char.pos.x
	y = char.pos.y
	z = char.pos.z
	map = char.pos.map

	# We can build on floor
	# Check for dynamic items
	tile = wolfpack.items( x, y, map )
	if tile:
		dynamic_floor = wolfpack.tiledata(tile[0].id)["floor"]
		if len( tile ) and not dynamic_floor:
			return False

	# Check for dynamic items
	tile = wolfpack.statics(x, y, map, True)
	if tile:
		for i in tile:
			height = i[3] > z and i[3] < (z+20) # something is between the ground and +20?
			static_floor = wolfpack.tiledata(i[0])["floor"]
			static_roof = wolfpack.tiledata(i[0])["flag1"] & 0x10
			if len( tile ) and height: #and and not static_floor and not static_roof: # seems that the floor flag is not used for all
				return False
	return True
예제 #8
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
예제 #9
0
	def save( self ):
		for map in self.maps:
			file = open( "save_decoration.%i.xml" % map, "w" )
			file.write("<decoration>\n")
			for id in self.maps[map]:
				itemsbyhue = {}
				for item in self.maps[map][id]:
					if not itemsbyhue.has_key(item.color):
						itemsbyhue[item.color] = []
					itemsbyhue[item.color].append(item)
				tiledata = wolfpack.tiledata(id)
				for hue in itemsbyhue:
					file.write("""\t<!-- %s -->\n""" % tiledata["name"] )
					if hue != 0:
						file.write("""\t<item id="0x%x" hue="0x%x">\n""" % (id, hue) )
					else:
						file.write("""\t<item id="0x%x">\n""" % id )
					for item in itemsbyhue[hue]:
						pos = item.pos
						file.write("""\t\t<pos x="%i" y="%i" z="%i" map="%i">\n""" % (pos.x, pos.y, pos.z, pos.map) )
					file.write("\t</item>\n")
			file.write("</decoration>\n")
			file.close()
def searchidscmd( socket, command, arguments ):
	out = open( 'missingids.xml', "wb" )

	if os.name == 'posix':
		nl = "\n"
	else:
		nl = "\r\n"

	out.write( '<definitions>%s' % ( nl ) )
	for id in range(0x0, 0x4000):
		tile = tiledata( id )

		# unused ids have only 5 entries in tiledata
		if len( tile ) > 5:
			itemdef =  hex(id).split("x")[1]
			if not getdefinition(WPDT_ITEM, itemdef):
				out.write( '\t<!-- %s -->%s' % ( tile['name'], nl ) )
				out.write( '\t<item id="%s">%s' % ( itemdef, nl ) )
				out.write( '\t\t<id>%s</id>%s' % ( hex(id), nl ) )
				out.write( '\t</item>%s' % ( nl ) )
				out.write( nl )

	out.write( '</definitions>%s' % ( nl ) )
	out.close()
예제 #11
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
예제 #12
0
def onUse(player, item):
	if item.container == player:
		return False

	tile = wolfpack.tiledata(item.id)
	
	if not player.gm and (item.lockeddown or item.movable > 1 or tile['weight'] == 255):
		player.objectdelay = 0
		return True
	
	if not tile.has_key('layer'):
		return False

	layer = tile['layer']

	if layer == 0 or not (tile['flag3'] & 0x40):
		return False

	previous = player.itemonlayer(layer)
	if previous:
		tobackpack(previous, player)
		previous.soundeffect(0x57)
		previous.update()

	if layer == LAYER_RIGHTHAND or layer == LAYER_LEFTHAND:
		# Check if we're equipping on one of the standard layers
		righthand = player.itemonlayer(LAYER_RIGHTHAND)
		lefthand = player.itemonlayer(LAYER_LEFTHAND)

		if righthand and (righthand.twohanded or (layer == 2 and item.twohanded)):
			tobackpack(righthand, player)
			righthand.update()
			righthand.soundeffect(0x57)

		if lefthand and (lefthand.twohanded or (layer == 1 and item.twohanded)):
			tobackpack(lefthand, player)
			lefthand.update()
			lefthand.soundeffect(0x57)

	# Check if there is another dclick handler
	# in the eventchain somewhere. if not,
	# return True to handle the equip event.
	scripts = list(item.scripts) + item.basescripts.split(',')

	for script in scripts:
		if wolfpack.hasevent(script, EVENT_WEARITEM):
			result = wolfpack.callevent(script, EVENT_WEARITEM, (player, player, item, layer))
			if result:
				return True

	player.additem(layer, item)
	item.update()
	item.soundeffect(0x57)
	player.updatestats()

	# Remove the use delay, equipping should be for free...
	player.objectdelay = 0

	for script in scripts[scripts.index("equipment")+1:]:
		if wolfpack.hasevent(script, EVENT_USE):
			return True

	return True
예제 #13
0
def onUse(player, item):
    if item.container == player:
        return False
    if player.id in PLAYER_BODIES_ALIVE_MALE and item.id > 0x1c00 and item.id <= 0x1c0d:
        player.socket.sysmessage(tr("You cannot wear female armor."))
        return True
    tile = wolfpack.tiledata(item.id)

    if not player.gm and (item.lockeddown or item.movable > 1 or tile['weight']
                          == 255 or item.getoutmostchar() != player):
        player.objectdelay = 0
        return True

    if not 'layer' in tile:
        return False

    layer = tile['layer']

    if layer == 0 or not (tile['flag3'] & 0x40):
        return False

    previous = player.itemonlayer(layer)
    if previous:
        tobackpack(previous, player)
        previous.soundeffect(0x57)
        previous.update()

    if layer == LAYER_RIGHTHAND or layer == LAYER_LEFTHAND:
        # Check if we're equipping on one of the standard layers
        righthand = player.itemonlayer(LAYER_RIGHTHAND)
        lefthand = player.itemonlayer(LAYER_LEFTHAND)

        if righthand and (righthand.twohanded or
                          (layer == 2 and item.twohanded)):
            tobackpack(righthand, player)
            righthand.update()
            righthand.soundeffect(0x57)

        if lefthand and (lefthand.twohanded or
                         (layer == 1 and item.twohanded)):
            tobackpack(lefthand, player)
            lefthand.update()
            lefthand.soundeffect(0x57)

    # Check if there is another dclick handler
    # in the eventchain somewhere. if not,
    # return True to handle the equip event.
    scripts = list(item.scripts) + item.basescripts.split(',') + list(
        player.scripts) + player.basescripts.split(',')

    for script in scripts:
        if script and wolfpack.hasevent(script, EVENT_WEARITEM):
            result = wolfpack.callevent(script, EVENT_WEARITEM,
                                        (player, player, item, layer))
            if result:
                return True

    player.additem(layer, item)
    item.update()
    item.soundeffect(0x57)
    player.updatestats()

    # Remove the use delay, equipping should be for free...
    player.objectdelay = 0

    for script in scripts[scripts.index("equipment") + 1:]:
        if wolfpack.hasevent(script, EVENT_USE):
            return True

    return True
예제 #14
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