def decoration( socket, command, arguments ):
    if len(arguments) > 0:
        args = str(arguments)
        if args == 'save':
            saveObject = DecorationSaveHandler(socket)
            socket.sysmessage("Sorting items, please wait...")
            saveObject.sort()
            socket.sysmessage("Writting file...")
            saveObject.save()

    else:
        parser = xml.sax.make_parser()
        handler = DecorationHandler()
        parser.setContentHandler(handler)
        if wolfpack.hasmap(0):
            socket.sysmessage("Decorating map 0, please wait...")
            parser.parse("data/decoration.0.xml")
        if wolfpack.hasmap(1):
            socket.sysmessage("Decorating map 1, please wait...")
            parser.parse("data/decoration.1.xml")
        if wolfpack.hasmap(2):
            socket.sysmessage("Decorating map 2, please wait...")
            parser.parse("data/decoration.2.xml")
        if wolfpack.hasmap(3):
            socket.sysmessage("Decorating map 2, please wait...")
            parser.parse("data/decoration.3.xml")
def decoration( socket, command, arguments ):
	if len(arguments) > 0:
		args = str(arguments)
		if args == 'save':
			saveObject = DecorationSaveHandler(socket)
			socket.sysmessage(tr("Sorting items, please wait..."))
			saveObject.sort()
			socket.sysmessage(tr("Writting file..."))
			saveObject.save()
			return
		
	parser = xml.sax.make_parser()
	handler = DecorationHandler()
	parser.setContentHandler(handler)
	maps = []
	try:
		maponly = int(arguments)
		maps.append(maponly)
	except ValueError:
                maps = [0, 1, 2, 3]
		pass

	for map in maps:
            if wolfpack.hasmap(map):
                socket.sysmessage(tr("Decorating map %i, please wait...") % map)
                parser.parse("definitions/decoration/decoration.%i.xml" % map)
def isValidPosition( pos ):
	# Check if the map is valid.
	if wolfpack.hasmap( pos.map ):
		# Z Checking
		if pos.z > 127 or pos.z < -127:
			return False
		# X & Y Checking
		# Felucca & Trammel
		if pos.map == 0 or pos.map == 1:
			if pos.x >= 6144 or pos.x < 0:
				return False
			if pos.y >= 4096 or pos.y < 0:
				return False
		# Ilshenar
		elif pos.map == 2:
			if pos.x >= 2304 or pos.x < 0:
				return False
			if pos.y >= 1600 or pos.y < 0:
				return False
		# Malas
		elif pos.map == 3:
			if pos.x >= 2560 or pos.x < 0:
				return False
			if pos.y >= 2048 or pos.y < 0:
				return False
		# Tokuno Islands
		elif pos.map == 4:
			if pos.x >= 1448 or pos.x < 0:
				return False
			if pos.y >= 1448 or pos.y < 0:
				return False
	else:
		return False

	return True
Example #4
0
def commandMove( socket, cmd, args ):
	char = socket.player
	args = args.strip()
	if len(args) == 0:
		socket.sysmessage( "Moves an object relative to its current position." )
		socket.sysmessage( "Usage: move [x]" )
		socket.sysmessage( "Usage: move [x],[y]" )
		socket.sysmessage( "Usage: move [x],[y],[z]" )
		socket.sysmessage( "Usage: move [x],[y],[z],[map]" )
		return False
	else:
		args = args.split( "," )
		for i in args:
			try:
				i = int(i)
			except:
				socket.sysmessage( "'%s' must be a number." % i )
				return True
			
		if len( args ) >= 1 and len( args ) <= 4:
			if len( args ) == 4:
				xmod = int( args[0] )
				ymod = int( args[1] )
				zmod = int( args[2] )
				newmap = int( args[3] )
				if not wolfpack.hasmap( newmap ):
					newmap = None
			elif len( args ) == 3:
				xmod = int( args[0] )
				ymod = int( args[1] )
				zmod = int( args[2] )
				newmap = None
			elif len( args ) == 2:
				xmod = int( args[0] )
				ymod = int( args[1] )
				zmod = 0
				newmap = None
			elif len( args ) == 1:
				xmod = int( args[0] )
				ymod = 0
				zmod = 0
				newmap = None
			if newmap != None:
				socket.sysmessage( "Please select a target to move %i,%i,%i,%i" % ( xmod, ymod, zmod, newmap ) )
			else:
				socket.sysmessage( "Please select a target to move %i,%i,%i" % ( xmod, ymod, zmod ) )
			socket.attachtarget( "commands.move.response", [ int(xmod), int(ymod), int(zmod), newmap ] )
			return True
		else:
			socket.sysmessage( "Moves an object relative to its current position." )
			socket.sysmessage( "Usage: move [x]" )
			socket.sysmessage( "Usage: move [x],[y]" )
			socket.sysmessage( "Usage: move [x],[y],[z]" )
			socket.sysmessage( "Usage: move [x],[y],[z],[map]" )
			return False
Example #5
0
def Format( char ):
	map = char.pos.map

	if not wolfpack.hasmap(map):
		return False

	x = char.pos.x
	y = char.pos.y

	if not ComputeMapDetails( map, x, y ):
		return False
	else:
		(xCenter, yCenter, xWidth, yHeight) = ComputeMapDetails(map, x, y)

	absLong = float(((x - xCenter) * 360) / xWidth)
	absLat  = float(((y - yCenter) * 360) / yHeight)

	if absLong > 180.0:
		absLong = -180.0 + (absLong % 180.0)

	if absLat > 180.0:
		absLat = -180.0 + (absLat % 180.0)

	east = (absLong >= 0)
	south = (absLat >= 0)

	if absLong < 0.0:
		absLong = -absLong

	if absLat < 0.0:
		absLat = -absLat

	xLong = int(absLong)
	yLat  = int(absLat)

	#char.socket.sysmessage(str(absLong))

	xMins = int((absLong % 1.0) * 60)
	yMins = int((absLat  % 1.0) * 60)
	#char.socket.sysmessage(str(xMins))

	return (yLat, yMins, xLong, xMins, east, south)
Example #6
0
def Format(char):
    map = char.pos.map

    if not wolfpack.hasmap(map):
        return False

    x = char.pos.x
    y = char.pos.y

    if not ComputeMapDetails(map, x, y):
        return False
    else:
        (xCenter, yCenter, xWidth, yHeight) = ComputeMapDetails(map, x, y)

    absLong = float(((x - xCenter) * 360) / xWidth)
    absLat = float(((y - yCenter) * 360) / yHeight)

    if absLong > 180.0:
        absLong = -180.0 + (absLong % 180.0)

    if absLat > 180.0:
        absLat = -180.0 + (absLat % 180.0)

    east = (absLong >= 0)
    south = (absLat >= 0)

    if absLong < 0.0:
        absLong = -absLong

    if absLat < 0.0:
        absLat = -absLat

    xLong = int(absLong)
    yLat = int(absLat)

    #char.socket.sysmessage(str(absLong))

    xMins = int((absLong % 1.0) * 60)
    yMins = int((absLat % 1.0) * 60)
    #char.socket.sysmessage(str(xMins))

    return (yLat, yMins, xLong, xMins, east, south)
Example #7
0
def decoration(socket, command, arguments):
    if len(arguments) > 0:
        args = str(arguments.split()[0])
        if args == 'save':
            saveObject = DecorationSaveHandler()
            socket.sysmessage(tr("Sorting items, please wait..."))
            saveObject.sort()
            socket.sysmessage(tr("Writing file..."))
            saveObject.save()
            socket.sysmessage(tr("Done."))
        elif args == 'savedoors':
            saveObject = DoorSaveHandler()
            socket.sysmessage(tr("Sorting doors, please wait..."))
            saveObject.sort()
            socket.sysmessage(tr("Writing file..."))
            saveObject.save()
            socket.sysmessage(tr("Done."))
        elif args == 'load':
            parser = xml.sax.make_parser()
            handler = DecorationHandler()
            parser.setContentHandler(handler)
            maps = []
            try:
                maponly = int(arguments.split()[1])
                maps.append(maponly)
            except ValueError:
                maps = [0, 1, 2, 3, 4]
                pass

            for map in maps:
                if wolfpack.hasmap(map):
                    socket.sysmessage(
                        tr("Decorating map %i, please wait...") % map)
                    parser.parse("definitions/decoration/decoration.%i.xml" %
                                 map)
        else:
            socket.sysmessage(tr('Usage: decoration save|savedoors|load'))
    else:
        socket.sysmessage(tr('Usage: decoration save|savedoors|load'))
Example #8
0
def isValidPosition( pos ):
	# Check if the map is valid.
	if wolfpack.hasmap( pos.map ):
		# Z Checking
		if pos.z > 127 or pos.z < -128:
			return False
		# X & Y Checking
		# Felucca & Trammel
		if pos.map == 0 or pos.map == 1:
			if usesMondaingsLegacyMap:
				if pos.x >= 7168 or pos.x < 0:
					return False
			else:
				if pos.x >= 6144 or pos.x < 0:
					return False
			if pos.y >= 4096 or pos.y < 0:
				return False
		# Ilshenar
		elif pos.map == 2:
			if pos.x >= 2304 or pos.x < 0:
				return False
			if pos.y >= 1600 or pos.y < 0:
				return False
		# Malas
		elif pos.map == 3:
			if pos.x >= 2560 or pos.x < 0:
				return False
			if pos.y >= 2048 or pos.y < 0:
				return False
		# Tokuno Islands
		elif pos.map == 4:
			if pos.x >= 1448 or pos.x < 0:
				return False
			if pos.y >= 1448 or pos.y < 0:
				return False
	else:
		return False

	return True
def decoration( socket, command, arguments ):
	if len(arguments) > 0:
		args = str(arguments.split()[0])
		if args == 'save':
			saveObject = DecorationSaveHandler()
			socket.sysmessage(tr("Sorting items, please wait..."))
			saveObject.sort()
			socket.sysmessage(tr("Writing file..."))
			saveObject.save()
			socket.sysmessage(tr("Done."))
		elif args == 'savedoors':
			saveObject = DoorSaveHandler()
			socket.sysmessage(tr("Sorting doors, please wait..."))
			saveObject.sort()
			socket.sysmessage(tr("Writing file..."))
			saveObject.save()
			socket.sysmessage(tr("Done."))
		elif args == 'load':
			parser = xml.sax.make_parser()
			handler = DecorationHandler()
			parser.setContentHandler(handler)
			maps = []
			try:
				maponly = int(arguments.split()[1])
				maps.append(maponly)
			except ValueError:
				maps = [0, 1, 2, 3, 4]
				pass
		
			for map in maps:
				if wolfpack.hasmap(map):
					socket.sysmessage(tr("Decorating map %i, please wait...") % map)
					parser.parse("definitions/decoration/decoration.%i.xml" % map)
		else:
			socket.sysmessage( tr('Usage: decoration save|savedoors|load') )
	else:
		socket.sysmessage( tr('Usage: decoration save|savedoors|load') )
Example #10
0
def commandMove( socket, cmd, args ):
	moveself = cmd.upper() == 'SMOVE'

	char = socket.player
	args = args.strip()
	if len(args) == 0:
		socket.sysmessage( "Moves an object relative to its current position." )
		socket.sysmessage( "Usage: move [x]" )
		socket.sysmessage( "Usage: move [x],[y]" )
		socket.sysmessage( "Usage: move [x],[y],[z]" )
		socket.sysmessage( "Usage: move [x],[y],[z],[map]" )
		return False
	else:
		args = args.split( "," )
		for i in args:
			try:
				i = int(i)
			except:
				socket.sysmessage( "'%s' must be a number." % i )
				return True

		if len( args ) >= 1 and len( args ) <= 4:
			if len( args ) == 4:
				xmod = int( args[0] )
				ymod = int( args[1] )
				zmod = int( args[2] )
				newmap = int( args[3] )
				if not wolfpack.hasmap( newmap ):
					newmap = None
			elif len( args ) == 3:
				xmod = int( args[0] )
				ymod = int( args[1] )
				zmod = int( args[2] )
				newmap = None
			elif len( args ) == 2:
				xmod = int( args[0] )
				ymod = int( args[1] )
				zmod = 0
				newmap = None
			elif len( args ) == 1:
				xmod = int( args[0] )
				ymod = 0
				zmod = 0
				newmap = None

			if moveself:
				pos = char.pos
				if newmap != None:
					newposition = wolfpack.coord( (pos.x + xmod) , (pos.y + ymod ), (pos.z + zmod), newmap )
				else:
					newposition = wolfpack.coord( (pos.x + xmod) , (pos.y + ymod ), (pos.z + zmod), pos.map )

				if not( utilities.isValidPosition(newposition) ):
					char.socket.sysmessage( "Error: Destination invalid!"  )
					return False

				char.removefromview()
				char.moveto( newposition )
				char.update()
				if char.socket:
					char.socket.resendworld()
				return True
			else:
				if newmap != None:
					socket.sysmessage( "Please select a target to move %i,%i,%i,%i" % ( xmod, ymod, zmod, newmap ) )
				else:
					socket.sysmessage( "Please select a target to move %i,%i,%i" % ( xmod, ymod, zmod ) )
				socket.attachtarget( "commands.move.response", [ int(xmod), int(ymod), int(zmod), newmap ] )
				return True
		else:
			socket.sysmessage( "Moves an object relative to its current position." )
			socket.sysmessage( "Usage: move [x]" )
			socket.sysmessage( "Usage: move [x],[y]" )
			socket.sysmessage( "Usage: move [x],[y],[z]" )
			socket.sysmessage( "Usage: move [x],[y],[z],[map]" )
			return False
Example #11
0
def commandTileMove(socket, command, arguments):
	arguments = arguments.strip()
	if( len(arguments) == 0 or arguments.count(" ") > 1 ):
		socket.sysmessage( "Usage: tilemove [z0] x" )
		socket.sysmessage( "Usage: tilemove [z0] x[,y]" )
		socket.sysmessage( "Usage: tilemove [z0] x[,y][,z]" )
		socket.sysmessage( "Usage: tilemove [z0] x[,y][,z][,map]" )
		return False

	mode = MODE_NONE
	z0 = 0

	if arguments.count(' ') >= 1:
		(z0, arguments) = arguments.split(" ")
		try:
			if z0.startswith('<='):
				mode = MODE_LESSEREQUAL
				z0 = int(z0[2:])
			elif z0.startswith('>='):
				mode = MODE_GREATEREQUAL
				z0 = int(z0[2:])
			elif z0.startswith('>'):
				mode = MODE_GREATER
				z0 = int(z0[1:])
			elif z0.startswith('<'):
				mode = MODE_LESSER
				z0 = int(z0[1:])
			elif z0.startswith('!='):
				mode = MODE_NOTEQUAL
				z0 = int(z0[2:])
			else:
				mode = MODE_EQUAL
				z0 = int(z0)
		except:
			socket.sysmessage( "'%s' must be a number." % z0 )
			return True

	socket.sysmessage('MODE: %u' % mode)
	socket.sysmessage('Z0: %u' % z0)

	arguments = arguments.split( "," )
	for i in arguments:
		try:
			i = int( i )
		except:
			socket.sysmessage( "'%s' must be a number." % i )
			return True

	if( len(arguments) < 1 or len(arguments) > 4 ):
		socket.sysmessage( "Usage: tilemove [z0] x" )
		socket.sysmessage( "Usage: tilemove [z0] x[,y]" )
		socket.sysmessage( "Usage: tilemove [z0] x[,y][,z]" )
		socket.sysmessage( "Usage: tilemove [z0] x[,y][,z][,map]" )
		return False

	if len( arguments ) == 4:
		xmod = int( arguments[0] )
		ymod = int( arguments[1] )
		zmod = int( arguments[2] )
		newmap = int( arguments[3] )
		if not wolfpack.hasmap( newmap ):
			newmap = None
	elif len( arguments ) == 3:
		xmod = int( arguments[0] )
		ymod = int( arguments[1] )
		zmod = int( arguments[2] )
		newmap = None
	elif len( arguments ) == 2:
		xmod = int( arguments[0] )
		ymod = int( arguments[1] )
		zmod = 0
		newmap = None
	elif len( arguments ) == 1:
		xmod = int( arguments[0] )
		ymod = 0
		zmod = 0
		newmap = None
	if newmap:
		socket.sysmesage( "Please select the first corner. [Move: %i,%i,%i,%i]" % ( xmod, ymod, zmod, newmap ) )
	else:
		socket.sysmessage( "Please select the first corner. [Move: %i,%i,%i]" % ( xmod, ymod, zmod ) )

	socket.attachtarget( "commands.tilemove.tileResponse", [ xmod, ymod, zmod, newmap, mode, z0 ] )
	return True
Example #12
0
def commandTileMove(socket, command, arguments):
	arguments = arguments.strip()
	if( len(arguments) == 0 or arguments.count(" ") > 1 ):
		socket.sysmessage( "Usage: tilemove [z0] x" )
		socket.sysmessage( "Usage: tilemove [z0] x[,y]" )
		socket.sysmessage( "Usage: tilemove [z0] x[,y][,z]" )
		socket.sysmessage( "Usage: tilemove [z0] x[,y][,z][,map]" )
		return False

	if( arguments.count(" ") == 0 ):
	        z0 = None
	else:
		(z0, arguments) = arguments.split( " " )
		try:
			z0 = int( z0 )
		except:
			socket.sysmessage( "'%s' must be a number." % z0 )
			return True
	
	arguments = arguments.split( "," )
	for i in arguments:
		try:
			i = int( i )
		except:
			socket.sysmessage( "'%s' must be a number." % i )
			return True
	        
	if( len(arguments) < 1 or len(arguments) > 4 ):
	        socket.sysmessage( "Usage: tilemove [z0] x" )
	        socket.sysmessage( "Usage: tilemove [z0] x[,y]" )
	        socket.sysmessage( "Usage: tilemove [z0] x[,y][,z]" )
	        socket.sysmessage( "Usage: tilemove [z0] x[,y][,z][,map]" )
	        return False

	if len( arguments ) == 4:
		xmod = int( arguments[0] )
		ymod = int( arguments[1] )
		zmod = int( arguments[2] )
		newmap = int( arguments[3] )
		if not wolfpack.hasmap( newmap ):
			newmap = None
	elif len( arguments ) == 3:
		xmod = int( arguments[0] )
		ymod = int( arguments[1] )
		zmod = int( arguments[2] )
		newmap = None
	elif len( arguments ) == 2:
		xmod = int( arguments[0] )
		ymod = int( arguments[1] )
		zmod = 0
		newmap = None
	elif len( arguments ) == 1:
		xmod = int( arguments[0] )
		ymod = 0
		zmod = 0
		newmap = None
	if newmap:
		socket.sysmesage( "Please select the first corner. [Move: %i,%i,%i,%i]" % ( xmod, ymod, zmod, newmap ) )
	else:
		socket.sysmessage( "Please select the first corner. [Move: %i,%i,%i]" % ( xmod, ymod, zmod ) )

	socket.attachtarget( "commands.tilemove.tileResponse", [ xmod, ymod, zmod, newmap, z0 ] )
	return True
Example #13
0
def commandTileMove(socket, command, arguments):
	arguments = arguments.strip()
	if( len(arguments) == 0 or arguments.count(" ") > 1 ):
		socket.sysmessage( "Usage: tilemove [z0] x" )
		socket.sysmessage( "Usage: tilemove [z0] x[,y]" )
		socket.sysmessage( "Usage: tilemove [z0] x[,y][,z]" )
		socket.sysmessage( "Usage: tilemove [z0] x[,y][,z][,map]" )
		return False

	mode = MODE_NONE
	z0 = 0

	if arguments.count(' ') >= 1:
		(z0, arguments) = arguments.split(" ")
		try:
			if z0.startswith('<='):
				mode = MODE_LESSEREQUAL
				z0 = int(z0[2:])
			elif z0.startswith('>='):
				mode = MODE_GREATEREQUAL
				z0 = int(z0[2:])
			elif z0.startswith('>'):
				mode = MODE_GREATER
				z0 = int(z0[1:])
			elif z0.startswith('<'):
				mode = MODE_LESSER
				z0 = int(z0[1:])
			elif z0.startswith('!='):
				mode = MODE_NOTEQUAL
				z0 = int(z0[2:])
			else:
				mode = MODE_EQUAL
				z0 = int(z0)
		except:
			socket.sysmessage( "'%s' must be a number." % z0 )
			return True

	socket.sysmessage('MODE: %u' % mode)
	socket.sysmessage('Z0: %u' % z0)

	arguments = arguments.split( "," )
	for i in arguments:
		try:
			i = int( i )
		except:
			socket.sysmessage( "'%s' must be a number." % i )
			return True

	if( len(arguments) < 1 or len(arguments) > 4 ):
		socket.sysmessage( "Usage: tilemove [z0] x" )
		socket.sysmessage( "Usage: tilemove [z0] x[,y]" )
		socket.sysmessage( "Usage: tilemove [z0] x[,y][,z]" )
		socket.sysmessage( "Usage: tilemove [z0] x[,y][,z][,map]" )
		return False

	if len( arguments ) == 4:
		xmod = int( arguments[0] )
		ymod = int( arguments[1] )
		zmod = int( arguments[2] )
		newmap = int( arguments[3] )
		if not wolfpack.hasmap( newmap ):
			newmap = None
	elif len( arguments ) == 3:
		xmod = int( arguments[0] )
		ymod = int( arguments[1] )
		zmod = int( arguments[2] )
		newmap = None
	elif len( arguments ) == 2:
		xmod = int( arguments[0] )
		ymod = int( arguments[1] )
		zmod = 0
		newmap = None
	elif len( arguments ) == 1:
		xmod = int( arguments[0] )
		ymod = 0
		zmod = 0
		newmap = None
	if newmap:
		socket.sysmessage( "Please select the first corner. [Move: %i,%i,%i,%i]" % ( xmod, ymod, zmod, newmap ) )
	else:
		socket.sysmessage( "Please select the first corner. [Move: %i,%i,%i]" % ( xmod, ymod, zmod ) )

	socket.attachtarget( "commands.tilemove.tileResponse", [ xmod, ymod, zmod, newmap, mode, z0 ] )
	return True
Example #14
0
def commandMove(socket, cmd, args):
    moveself = cmd.upper() == 'SMOVE'

    char = socket.player
    args = args.strip()
    if len(args) == 0:
        socket.sysmessage("Moves an object relative to its current position.")
        socket.sysmessage("Usage: move [x]")
        socket.sysmessage("Usage: move [x],[y]")
        socket.sysmessage("Usage: move [x],[y],[z]")
        socket.sysmessage("Usage: move [x],[y],[z],[map]")
        return False
    else:
        args = args.split(",")
        for i in args:
            try:
                i = int(i)
            except:
                socket.sysmessage("'%s' must be a number." % i)
                return True

        if len(args) >= 1 and len(args) <= 4:
            if len(args) == 4:
                xmod = int(args[0])
                ymod = int(args[1])
                zmod = int(args[2])
                newmap = int(args[3])
                if not wolfpack.hasmap(newmap):
                    newmap = None
            elif len(args) == 3:
                xmod = int(args[0])
                ymod = int(args[1])
                zmod = int(args[2])
                newmap = None
            elif len(args) == 2:
                xmod = int(args[0])
                ymod = int(args[1])
                zmod = 0
                newmap = None
            elif len(args) == 1:
                xmod = int(args[0])
                ymod = 0
                zmod = 0
                newmap = None

            if moveself:
                pos = char.pos
                if newmap != None:
                    newposition = wolfpack.coord(
                        (pos.x + xmod), (pos.y + ymod), (pos.z + zmod), newmap)
                else:
                    newposition = wolfpack.coord(
                        (pos.x + xmod), (pos.y + ymod), (pos.z + zmod),
                        pos.map)

                if not (utilities.isValidPosition(newposition)):
                    char.socket.sysmessage("Error: Destination invalid!")
                    return False

                char.removefromview()
                char.moveto(newposition)
                char.update()
                if char.socket:
                    char.socket.resendworld()
                return True
            else:
                if newmap != None:
                    socket.sysmessage(
                        "Please select a target to move %i,%i,%i,%i" %
                        (xmod, ymod, zmod, newmap))
                else:
                    socket.sysmessage(
                        "Please select a target to move %i,%i,%i" %
                        (xmod, ymod, zmod))
                socket.attachtarget(
                    "commands.move.response",
                    [int(xmod), int(ymod),
                     int(zmod), newmap])
                return True
        else:
            socket.sysmessage(
                "Moves an object relative to its current position.")
            socket.sysmessage("Usage: move [x]")
            socket.sysmessage("Usage: move [x],[y]")
            socket.sysmessage("Usage: move [x],[y],[z]")
            socket.sysmessage("Usage: move [x],[y],[z],[map]")
            return False