Ejemplo n.º 1
0
def go(socket, command, arguments):
    player = socket.player

    if len(arguments) == 0:
        global generated
        if not generated:
            socket.sysmessage('Generating go menu.')
            socket.sysmessage('Please wait...')
            generateGoMenu()
            generated = 1

        menu = findmenu('GOMENU')
        if menu:
            socket.sysmessage('Bringing up the travel gump.')
            menu.send(player)
        else:
            socket.sysmessage("Didn't find the GOMENU menu.")
        return
    elif arguments.count(',') >= 1:
        parts = arguments.split(',')
        pos = player.pos

        try:
            pos.x = int(parts[0])
            pos.y = int(parts[1])
            if len(parts) >= 3:
                pos.z = int(parts[2])

            if len(parts) >= 4:
                pos.map = int(parts[3])

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

            player.removefromview()
            player.moveto(pos)
            player.update()
            player.socket.resendworld()
            return
        except:
            pass

    # If we reach this point it was no valid coordinate
    # See if we can get a def
    location = wolfpack.getdefinition(WPDT_LOCATION, arguments)

    if location:
        (x, y, z, map) = location.text.split(',')
        pos = wolfpack.coord(int(x), int(y), int(z), int(map))
        if not isValidPosition(pos):
            socket.sysmessage("Error: Destination invalid!")
            return False
        player.removefromview()
        player.moveto(pos)
        player.update()
        player.socket.resendworld()
    else:
        socket.sysmessage('Usage: <x, y, z, map>|<location>')
    return
Ejemplo n.º 2
0
def go(socket, command, arguments):
    player = socket.player

    if len(arguments) == 0:
        global generated
        if not generated:
            socket.sysmessage("Generating go menu.")
            socket.sysmessage("Please wait...")
            generateGoMenu()
            generated = 1

        menu = findmenu("GOMENU")
        if menu:
            socket.sysmessage("Bringing up the travel gump.")
            menu.send(player)
        else:
            socket.sysmessage("Didn't find the GOMENU menu.")
        return
    elif arguments.count(",") >= 1:
        parts = arguments.split(",")
        pos = player.pos

        try:
            pos.x = int(parts[0])
            pos.y = int(parts[1])
            if len(parts) >= 3:
                pos.z = int(parts[2])

            if len(parts) >= 4:
                pos.map = int(parts[3])

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

            player.removefromview()
            player.moveto(pos)
            player.update()
            player.socket.resendworld()
            return
        except:
            pass

            # If we reach this point it was no valid coordinate
            # See if we can get a def
    location = wolfpack.getdefinition(WPDT_LOCATION, arguments)

    if location:
        (x, y, z, map) = location.text.split(",")
        pos = wolfpack.coord(int(x), int(y), int(z), int(map))
        if not isValidPosition(pos):
            socket.sysmessage("Error: Destination invalid!")
            return False
        player.removefromview()
        player.moveto(pos)
        player.update()
        player.socket.resendworld()
    else:
        socket.sysmessage("Usage: <x, y, z, map>|<location>")
    return
Ejemplo n.º 3
0
def teleport( char, args, target ):
	source = char.pos
	# Keeps you from teleporting to weird places.
	if target.item and target.item.container:
		target = char.pos
	else:
		target = target.pos

	if not( utilities.isValidPosition(target) ):
		char.socket.sysmessage( 'Invalid target.' )
		return False

	char.removefromview()
	char.moveto( target )
	char.update()
	if char.socket:
		char.socket.resendworld()
	utilities.smokepuff(char, source)
	utilities.smokepuff(char, target)

	if args[0]:
		char.socket.sysmessage( 'Select your teleport destination.' )
		char.socket.attachtarget( "commands.tele.teleport", [True] )

	return True
Ejemplo n.º 4
0
def teleport(char, args, target):
    source = char.pos
    # Keeps you from teleporting to weird places.
    if target.item and target.item.container:
        target = char.pos
    else:
        target = target.pos

    if not (utilities.isValidPosition(target)):
        char.socket.sysmessage('Invalid target.')
        return False

    char.removefromview()
    char.moveto(target)
    char.update()
    if char.socket:
        char.socket.resendworld()
    utilities.smokepuff(char, source)
    utilities.smokepuff(char, target)

    if args[0]:
        char.socket.sysmessage('Select your teleport destination.')
        char.socket.attachtarget("commands.tele.teleport", [True])

    return True
Ejemplo n.º 5
0
def response(char, args, target):
    socket = char.socket
    xmod = int(args[0])
    ymod = int(args[1])
    zmod = int(args[2])
    if (args[3] == None):
        newmap = None
    else:
        newmap = int(args[3])

    if target.item:
        item = target.item
        pos = item.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

        item.moveto(newposition)
        item.update()
        return True
    elif target.char:
        char = target.char
        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)):
            return False

        char.removefromview()
        char.moveto(newposition)
        char.update()
        if char.socket:
            char.socket.resendworld()
        return True
    return True
Ejemplo n.º 6
0
def parseTxt( file, map ):
	warnings = ''
	count = 0

	parseTickCount = 0
	createTickCount = 0
	propTickCount = 0
	moveTickCount = 0

	for line in file:
		step1 = wolfpack.tickcount()

		# Replace \r and \n's
		line = line.replace( "\r", "" )
		line = line.replace( "\n", "" )

		( id, x, y, z, color ) = line.split( ' ' )

		id = hex2dec( id )
		baseid = '%x' % id
		color = hex2dec( color )
		x = int( x )
		y = int( y )
		z = int( z )

		step2 = wolfpack.tickcount()
		newitem = wolfpack.additem( '%s' % baseid ) # Generate a new serial for us
		step3 = wolfpack.tickcount()

		newitem.decay = 0
		newitem.color = color
		newitem.id = id

		step4 = wolfpack.tickcount()

		newposition = wolfpack.coord( x, y, z, map )
		if not isValidPosition( newposition ):
			newitem.delete()
			continue
		newitem.moveto( newposition )

		step5 = wolfpack.tickcount()

		parseTickCount += step2 - step1
		createTickCount += step3 - step2
		propTickCount += step4 - step3
		moveTickCount += step5 - step4

		newitem.update()

		count += 1

	print "Parsing: %i ticks" % parseTickCount
	print "Creating: %i ticks" % createTickCount
	print "Prop: %i ticks" % propTickCount
	print "Move: %i ticks" % moveTickCount

	return ( count, warnings )
Ejemplo n.º 7
0
def response( char, args, target ):
	socket = char.socket
	xmod = int( args[0] )
	ymod = int( args[1] )
	zmod = int( args[2] )
	if( args[3] == None ):
		newmap = None
	else:
		newmap = int( args[3] )

	if target.item:
		item = target.item
		pos = item.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

		item.moveto( newposition )
		item.update()
		return True
	elif target.char:
		char = target.char
		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) ):
			return False
		
		char.removefromview()
		char.moveto( newposition )
		char.update()
		if char.socket:
			char.socket.resendworld()
		return True
	return True
Ejemplo n.º 8
0
def onCollide(player, item):
	if item.hastag('playersonly') and player.npc:
		return False

	if not item.hastag('target'):
		if player.socket:
			player.socket.sysmessage( tr('This gate leads nowhere...') )
		else:
			console.log(LOG_ERROR, tr("NPC [%x] using gate [%x] without target.\n") % (player.serial, item.serial))
		return False

	target = item.gettag('target').split(',')

	# Convert the target of the gate.
	try:
		target = map(int, target)
	except:
		player.socket.sysmessage( tr('This gate leads nowhere...') )
		return False

	# Validate the coord
	try:
		m = target[3]
	except:
		m = player.pos.map
	pos = wolfpack.coord( target[0], target[1], target[2], m )

	if not utilities.isValidPosition( pos ):
		player.socket.sysmessage( tr('This gate leads nowhere...') )
		return False

	if not utilities.isMapAvailableTo( player, pos.map ):
		return False

	# Move his pets if he has any
	if player.player:
		for follower in player.followers:
			if follower.wandertype == 4 and follower.distanceto(player) < 5:
				follower.removefromview()
				follower.moveto(pos)
				follower.update()

	player.removefromview()
	player.moveto(pos)
	player.update()
	if player.socket:
		player.socket.resendworld()

	# show some nice effects
	if not item.hastag('silent'):
		item.soundeffect(0x1fe)
		utilities.smokepuff(player, pos)
		utilities.smokepuff(player, item.pos)

	return True
Ejemplo n.º 9
0
def parseSphere51a(file, map):
	itemid = -1
	props = {}
	count = 0
	warnings = ''

	while 1:
		line = file.readline()
		if not line:
			break
		line = line.strip()

		if line.startswith('[WORLDITEM ') and line.endswith(']'):
			itemid = int(line[11:len(line)-1], 16)
		elif itemid != -1 and "=" in line:
			(key, value) = line.split('=', 1)
			props[key.lower()] = value
		elif itemid != -1 and len(line) == 0:
			if props.has_key('p'):
				(x, y, z) = props['p'].split(',')
				x = int(x)
				y = int(y)
				z = int(z)
				if props.has_key('color'):
			 		color = int(props['color'], 16)
			 	else:
			 		color = 0

				item = wolfpack.additem('%x' % itemid)

				if item:
					item.decay = 0
					item.movable = 3
					item.color = color
					newposition = wolfpack.coord( x, y, z, map )
					if not isValidPosition( newposition ):
						item.delete()
						continue
					item.moveto( newposition )
					item.update()
				else:
					warnings += "Found an invalid item id '%x' at %u,%u,%d,%u<br>" % (itemid, x, y, z, map)
				count += 1

			itemid = -1
			props = {}

	return (count, warnings)
Ejemplo n.º 10
0
def check(char):
    target_serial = char.gettag("target")
    target = wolfpack.findchar(target_serial)
    if not target or target.dead:
        char.kill()
        return False
    elif (char.pos.map != target.pos.map) or char.distanceto(target) > 15:
        for i in range(0, 5):
            loc = wolfpack.coord(
                target.pos.x - 4 + random.randint(0, 9),
                target.pos.y - 4 + random.randint(0, 9),
                target.pos.z,
                target.pos.map,
            )
            if isValidPosition(loc):
                break

        char.pos.effect(0x3728, 1, 13, 37, 7)
        char.moveto(loc)
        char.removefromview()
        char.update()
        char.effect(0x3728, 1, 13, 37, 7)
        char.soundeffect(0x37D)
    return True
Ejemplo n.º 11
0
def parseWsc( file, map ):
	warnings = ''
	count = 0

	while 1:
		line = file.readline()

		if not line:
			break

		# Replace \r and \n's
		line = line.replace( "\r", "" )
		line = line.replace( "\n", "" )

		# SECTION WORLDITEM : 17 byte
		if line[:17] == 'SECTION WORLDITEM':
			item = {}

			while 1:
				line = file.readline()

				if not line or len( line ) == 0 or line[0] == '}':
					break

				if line[0] == '{':
					continue

				line = line.replace( "\r", "" )
				line = line.replace( "\n", "" )

				if line.find( ' ' ) == -1:
					continue

				# Space has to be in there
				( key, value ) = line.split( ' ', 1 )

				item[ key ] = value

			# Check if we can import this item
			serial = 'Unset'
			if item.has_key( 'SERIAL' ):
				serial = hex( int( item[ 'SERIAL' ] ) )

			if item.has_key( 'BASEID' ):
				baseid = item[ 'BASEID' ]
			else:
				baseid = ''

			if not item.has_key( 'ID' ):
				warnings += 'Item (%s) has no ID property. Skipping.<br>' % ( serial )
				continue

			id = int( item['ID'] )

			if not item.has_key( 'X' ) or not item.has_key( 'Y' ):
				warnings += 'Item (Serial: %s, ID: %x) has no X or Y property. Skipping.<br>' % ( serial, id )
				continue

			if item.has_key('X'):
				x = int( item['X'] )
			else:
				x = 0
			if item.has_key('Y'):
				y = int( item['Y'] )
			else:
				y = 0
			if item.has_key('Z'):
				z = int( item['Z'] )
			else:
				z = 0
			if item.has_key('MAP'):
				map = int( item['MAP'] )

			color = 0
			if item.has_key( 'COLOR' ):
				color = int( item[ 'COLOR' ] )

			if item.has_key( 'CONT' ) and item[ 'CONT' ] != '-1':
				# warnings += 'Item (Serial: %s, ID: %x) is contained in container %s. Skipping' % ( serial, id, item[ 'CONT' ] )
				continue

			amount = 1
			if item.has_key( 'AMOUNT' ):
				amount = int( item[ 'AMOUNT' ] )

			name = '#'
			if item.has_key( 'NAME' ):
				name = item[ 'NAME' ]

			if item.has_key( 'TYPE' ):
				type = item[ 'TYPE' ]

			#print 'Item %x, Color %x, Pos %i,%i,%i<br>' % ( id, color, x, y, z )

			# REMEMBER: Set them to nodecay!!!
			if baseid != '':
				newitem = wolfpack.additem( "%s" % baseid ) # Generate a new serial for us
			else:
				baseid = lstrip( str( hex( id ) ), "0x" )

				# Multi ?
				if id >= 0x4000:
					newitem = wolfpack.addmulti( "%s" % baseid ) # Generate a new serial for us
				else:
					newitem = wolfpack.additem( "%s" % baseid ) # Generate a new serial for us

			if not newitem:
				warnings += "Found an invalid item id '%s' at %s<br>" % (baseid, str(newposition))
				continue

			newitem.decay = 0
			newitem.movable = 3 # Make everything gm movable by default
			newitem.color = color
			newitem.id = id
			newitem.amount = amount
			if name != "#":
				newitem.name = name
			newposition = wolfpack.coord( x, y, z, map )
			if not isValidPosition( newposition ):
				newitem.delete()
				continue
			newitem.moveto( newposition )
			#newitem.moveto( x, y, z, map )
			newitem.update()

			count += 1

		elif line[:17] == 'SECTION WORLDCHAR':
			warnings += "Found character in import file. Importing characters is not allowed.<br>"

	return ( count, warnings )
Ejemplo n.º 12
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
Ejemplo n.º 13
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
Ejemplo n.º 14
0
def gateCallback( char, args, target ):
	if( len( args ) < 1 ):
		char.socket.sysmessage( "script error 1. contact GM." )
		return 1
	item = args[0]
	if not item and not char.gm :
		char.socket.sysmessage( "script error 2. contact GM." )
		return 1
	if not char.gm and ( char.distanceto( item ) > 3):
		char.socket.clilocmessage( 500295 ) # You are too far away to do that.
		return 1

	if( target.button != 1 ):
		char.socket.sysmessage( tr("Canceled.") )
		return 1
	if( len( target.switches ) == 0 ):
		return 1

	button = int( target.switches[0] )

	# set world number
	numWorld = 0
	if( ( button > 9 ) and ( button < 19 ) ):
		numWorld = 1
	elif ( ( button > 18 ) and ( button < 28 ) ):
		numWorld = 0
	elif( ( button > 27 ) and ( button < 37 ) ):
		numWorld = 2
	elif( ( button > 36 ) and ( button < 45 ) ):
		numWorld = 3
	elif( ( button > 44 ) and ( button < 48 ) ):
		numWorld = 3
	else:
		char.socket.sysmessage( "script error 4. contact GM." )
		char.socket.sysmessage( "button = %i" % button )
		return 1

	# teleport
	coord = []
	oldcoord = [ char.pos.x, char.pos.y, char.pos.z ]
	if( ( button == 10 ) or ( button == 19 ) ):
		coord = [ 1336, 1998, 5, numWorld ]
	elif( ( button == 11 ) or ( button == 20 ) ):
		coord = [ 3564, 2141, 33, numWorld ]
	elif( ( button == 12 ) or ( button == 21 ) ):
		coord = [ 4467, 1284, 5, numWorld ]
	elif( ( button == 13 ) or ( button == 22 ) ):
		coord = [ 643, 2068, 5, numWorld ]
	elif( ( button == 14 ) or ( button == 23 ) ):
		coord = [ 1828, 2949, -20, numWorld ]
	elif( ( button == 15 ) or ( button == 24 ) ):
		coord = [ 2701, 694, 4, numWorld ]
	elif( ( button == 16 ) or ( button == 25 ) ):
		coord = [ 771, 754, 4, numWorld ]
	elif( ( button == 17 ) or ( button == 26 ) ):
		coord = [ 1499, 3772, 5, numWorld ]
	elif( button == 18 ):
		coord = [ 3763, 2771, 50, 1 ]
	elif( button == 27 ):
		coord = [ 2712, 2234,  0, 0 ]
	elif( button == 28 ):
		coord = [ 1216, 468, -13, 2 ]
	elif( button == 29 ):
		coord = [ 722, 1364, -60, 2 ]
	elif( button == 30 ):
		coord = [ 750, 724, -28, 2 ]
	elif( button == 31 ):
		coord = [ 282, 1015, 0, 2 ]
	elif( button == 32 ):
		coord = [ 987, 1010, -32, 2 ]
	elif( button == 32 ):
		coord = [ 1174, 1286, -30, 2 ]
	elif( button == 34 ):
		coord = [1532, 1340, -4, 2 ]
	elif( button == 35 ):
		coord = [ 528, 219, -42, 2 ]
	elif( button == 36 ):
		coord = [ 1721, 218, 96, 2 ]
	elif( button == 37 ):
		coord = [ 1015, 527, -65, 3 ]
	elif( button == 38 ):
		coord = [ 991, 519, -50, 3 ]
	elif( button == 39 ):
		coord = [ 1023, 503, -70, 3 ]
	elif( button == 40 ):
		coord = [ 989, 595, -90, 3 ]
	elif( button == 41 ):
		coord = [ 961, 638, -90, 3 ]
	elif( button == 42 ):
		coord = [ 1997, 1386, -85, 3 ]
	elif( button == 43 ):
		coord = [ 1941, 1321, -88, 3 ]
	elif( button == 44 ):
		coord = [ 1992, 1326, -90, 3 ]
	elif( button == 45 ):
		coord = [ 718, 1159, 25, 4 ]
	elif( button == 46 ):
		coord = [ 1169, 998, 41, 4 ]
	elif( button == 47 ):
		coord = [ 270, 628, 15, 4 ]
	char.soundeffect( 0x1fc )
	char.removefromview()
	pos = wolfpack.coord( coord[0], coord[1], coord[2], coord[3] )
	if not isValidPosition( pos ):
		char.socket.sysmessage( tr("Destination Invalid!") )
		return False
	char.moveto( pos )
	char.update()
	char.soundeffect( 0x1fc )
	char.effect( 0x372a )
	# move followers
	followers = char.followers
	if( len( followers ) > 0 ):
		for i in range( 0, len( char.followers ) ):
			follower = char.followers[i]
			# only transport follower which is within 5 tile from the character
			if( char.distanceto( follower ) < 5 ):
				follower.removefromview()
				follower.moveto( pos )
				follower.update()
				follower.effect( 0x372a )
			# else it will not follow him/her
			else:
				char.removefollower( follower )

	char.socket.resendplayer()
	char.socket.resendworld()
	return 1
Ejemplo n.º 15
0
def sendresponse(player, arguments, target):
    if target.item:
        object = target.item
    elif target.char:
        if target.char.rank > player.rank and player != target.char:
            player.socket.sysmessage("You've burnt your fingers!")
            return

        object = target.char
    else:
        player.socket.sysmessage('You need to target a character or an item.')
        return

    # Maybe we need to choose a location
    if len(arguments) == 0:
        player.socket.sysmessage(
            'Where do you want to send the targetted object?')
        player.socket.attachtarget('commands.go.sendresponse2',
                                   [object.serial])
    else:
        # Try to parse a target location for the object.
        parts = arguments[0].split(',')
        pos = player.pos
        try:
            if len(parts) >= 3:
                pos.z = int(parts[2])
            if len(parts) >= 4:
                pos.map = int(parts[3])

            pos.x = int(parts[0])
            pos.y = int(parts[1])

            if not isValidPosition(pos):
                player.socket.sysmessage("Error: Destination invalid!")
                return False

            object.removefromview()
            object.moveto(pos)
            object.update()
            if not object.ischar() or not object.socket:
                return
            object.socket.resendworld()
            return
        except:
            pass

        # If we reach this point it was no valid coordinate
        # See if we can get a def
        location = wolfpack.getdefinition(WPDT_LOCATION, arguments[0])

        if location:
            (x, y, z, map) = location.text.split(',')
            pos = wolfpack.coord(int(x), int(y), int(z), int(map))
            if not isValidPosition(pos):
                player.socket.sysmessage("Error: Destination invalid!")
                return False
            object.removefromview()
            object.moveto(pos)
            object.update()

            if object.ischar() and object.socket:
                object.socket.resendworld()
        else:
            player.socket.sysmessage('Usage: send <x, y, z, map>|<location>')
    return
Ejemplo n.º 16
0
def gateCallback(char, args, target):
    if (len(args) < 1):
        char.socket.sysmessage("script error 1. contact GM.")
        return 1
    item = args[0]
    if not item and not char.gm:
        char.socket.sysmessage("script error 2. contact GM.")
        return 1
    if not char.gm and (char.distanceto(item) > 3):
        char.socket.clilocmessage(500295)  # You are too far away to do that.
        return 1

    if (target.button != 1):
        char.socket.sysmessage(tr("Canceled."))
        return 1
    if (len(target.switches) == 0):
        return 1

    button = int(target.switches[0])

    # set world number
    numWorld = 0
    if ((button > 9) and (button < 19)):
        numWorld = 1
    elif ((button > 18) and (button < 28)):
        numWorld = 0
    elif ((button > 27) and (button < 37)):
        numWorld = 2
    elif ((button > 36) and (button < 45)):
        numWorld = 3
    elif ((button > 44) and (button < 48)):
        numWorld = 3
    else:
        char.socket.sysmessage("script error 4. contact GM.")
        char.socket.sysmessage("button = %i" % button)
        return 1

    # teleport
    coord = []
    oldcoord = [char.pos.x, char.pos.y, char.pos.z]
    if ((button == 10) or (button == 19)):
        coord = [1336, 1998, 5, numWorld]
    elif ((button == 11) or (button == 20)):
        coord = [3564, 2141, 33, numWorld]
    elif ((button == 12) or (button == 21)):
        coord = [4467, 1284, 5, numWorld]
    elif ((button == 13) or (button == 22)):
        coord = [643, 2068, 5, numWorld]
    elif ((button == 14) or (button == 23)):
        coord = [1828, 2949, -20, numWorld]
    elif ((button == 15) or (button == 24)):
        coord = [2701, 694, 4, numWorld]
    elif ((button == 16) or (button == 25)):
        coord = [771, 754, 4, numWorld]
    elif ((button == 17) or (button == 26)):
        coord = [1499, 3772, 5, numWorld]
    elif (button == 18):
        coord = [3763, 2771, 50, 1]
    elif (button == 27):
        coord = [2712, 2234, 0, 0]
    elif (button == 28):
        coord = [1216, 468, -13, 2]
    elif (button == 29):
        coord = [722, 1364, -60, 2]
    elif (button == 30):
        coord = [750, 724, -28, 2]
    elif (button == 31):
        coord = [282, 1015, 0, 2]
    elif (button == 32):
        coord = [987, 1010, -32, 2]
    elif (button == 32):
        coord = [1174, 1286, -30, 2]
    elif (button == 34):
        coord = [1532, 1340, -4, 2]
    elif (button == 35):
        coord = [528, 219, -42, 2]
    elif (button == 36):
        coord = [1721, 218, 96, 2]
    elif (button == 37):
        coord = [1015, 527, -65, 3]
    elif (button == 38):
        coord = [991, 519, -50, 3]
    elif (button == 39):
        coord = [1023, 503, -70, 3]
    elif (button == 40):
        coord = [989, 595, -90, 3]
    elif (button == 41):
        coord = [961, 638, -90, 3]
    elif (button == 42):
        coord = [1997, 1386, -85, 3]
    elif (button == 43):
        coord = [1941, 1321, -88, 3]
    elif (button == 44):
        coord = [1992, 1326, -90, 3]
    elif (button == 45):
        coord = [718, 1159, 25, 4]
    elif (button == 46):
        coord = [1169, 998, 41, 4]
    elif (button == 47):
        coord = [270, 628, 15, 4]
    char.soundeffect(0x1fc)
    char.removefromview()
    pos = wolfpack.coord(coord[0], coord[1], coord[2], coord[3])
    if not isValidPosition(pos):
        char.socket.sysmessage(tr("Destination Invalid!"))
        return False
    char.moveto(pos)
    char.update()
    char.soundeffect(0x1fc)
    char.effect(0x372a)
    # move followers
    followers = char.followers
    if (len(followers) > 0):
        for i in range(0, len(char.followers)):
            follower = char.followers[i]
            # only transport follower which is within 5 tile from the character
            if (char.distanceto(follower) < 5):
                follower.removefromview()
                follower.moveto(pos)
                follower.update()
                follower.effect(0x372a)
            # else it will not follow him/her
            else:
                char.removefollower(follower)

    char.socket.resendplayer()
    char.socket.resendworld()
    return 1
Ejemplo n.º 17
0
def sendresponse(player, arguments, target):
    if target.item:
        object = target.item
    elif target.char:
        if target.char.rank > player.rank and player != target.char:
            player.socket.sysmessage("You've burnt your fingers!")
            return

        object = target.char
    else:
        player.socket.sysmessage("You need to target a character or an item.")
        return

        # Maybe we need to choose a location
    if len(arguments) == 0:
        player.socket.sysmessage("Where do you want to send the targetted object?")
        player.socket.attachtarget("commands.go.sendresponse2", [object.serial])
    else:
        # Try to parse a target location for the object.
        parts = arguments[0].split(",")
        pos = player.pos
        try:
            if len(parts) >= 3:
                pos.z = int(parts[2])
            if len(parts) >= 4:
                pos.map = int(parts[3])

            pos.x = int(parts[0])
            pos.y = int(parts[1])

            if not isValidPosition(pos):
                player.socket.sysmessage("Error: Destination invalid!")
                return False

            object.removefromview()
            object.moveto(pos)
            object.update()
            if not object.ischar() or not object.socket:
                return
            object.socket.resendworld()
            return
        except:
            pass

            # If we reach this point it was no valid coordinate
            # See if we can get a def
        location = wolfpack.getdefinition(WPDT_LOCATION, arguments[0])

        if location:
            (x, y, z, map) = location.text.split(",")
            pos = wolfpack.coord(int(x), int(y), int(z), int(map))
            if not isValidPosition(pos):
                player.socket.sysmessage("Error: Destination invalid!")
                return False
            object.removefromview()
            object.moveto(pos)
            object.update()

            if object.ischar() and object.socket:
                object.socket.resendworld()
        else:
            player.socket.sysmessage("Usage: send <x, y, z, map>|<location>")
    return