Exemplo n.º 1
0
def onUse( player, item ):

    if ( player.distanceto( item ) > 8 ):
        return False

    boat_serial = item.gettag( 'boat_serial' )

    if ( player.multi != None and player.multi.serial == boat_serial ):
        if ( item.hastag('plank_open') ):
            closePlank( item )
        else:
            openPlank( item )
    else:
        if not item.hastag('plank_open'):
            if not item.hastag('plank_locked'):
                openPlank( item )
            elif player.gm:
                player.say( 502502 ); # That is locked but your godly powers allow access
            else:
                player.say( 502503 ); # That is locked.
        elif not item.hastag('plank_locked'):
            newpos = wolfpack.coord( item.pos.x, item.pos.y, item.pos.z + 5, item.pos.map )
            player.moveto( newpos )
            player.update()
        elif player.gm:
            player.say( 502502 ); # That is locked but your godly powers allow access
            newpos = wolfpack.coord( item.pos.x, item.pos.y, item.pos.z + 5, item.pos.map )
            player.moveto( newpos )
            player.update()
        else:
            player.say( 502503 ); # That is locked.
    return True
Exemplo n.º 2
0
    def target(self, char, mode, targettype, target, args, item):
        char.turnto(target)

        # Only containers are trappable
        if target.type != 1:
            char.message('You can' 't trap that.')
            return

        if not self.consumerequirements(char, mode, args, target, item):
            return

        pos = target.pos
        wolfpack.effect(0x376a, wolfpack.coord(pos.x + 1, pos.y, pos.z,
                                               pos.map), 9, 10)
        wolfpack.effect(0x376a, wolfpack.coord(pos.x, pos.y - 1, pos.z,
                                               pos.map), 9, 10)
        wolfpack.effect(0x376a, wolfpack.coord(pos.x - 1, pos.y, pos.z,
                                               pos.map), 9, 10)
        wolfpack.effect(0x376a, wolfpack.coord(pos.x, pos.y + 1, pos.z,
                                               pos.map), 9, 10)
        target.soundeffect(0x1ef)

        # Add the Trap Properties to the Item
        target.settag('trap_owner', char.serial)
        target.settag('trap_damage', random.randint(10, 50))
        target.settag('trap_type', 'magic')
        target.addscript('magic.trap')
Exemplo n.º 3
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 = "%i,%i,%i,%i" % ( (pos.x + xmod) , (pos.y + ymod ), (pos.z + zmod), newmap )
		else:
			newposition = "%i,%i,%i,%i" % ( (pos.x + xmod) , (pos.y + ymod ), (pos.z + zmod), pos.map )
		item.pos = 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 )
		char.removefromview()
		char.moveto( newposition )
		char.update()
		if char.socket:
			char.socket.resendworld()
		return True
	return True
Exemplo n.º 4
0
	def target(self, char, mode, targettype, target, args, item):
		char.turnto(target)

		if not self.consumerequirements(char, mode, args, target, item):
			return

		xdiff = abs(target.x - char.pos.x)
		ydiff = abs(target.y - char.pos.y)

		if xdiff > ydiff:
			positions = [ wolfpack.coord(target.x, target.y - 1, target.z, target.map), wolfpack.coord(target.x, target.y, target.z, target.map), wolfpack.coord(target.x, target.y + 1, target.z, target.map) ]
		else:
			positions = [ wolfpack.coord(target.x - 1, target.y, target.z, target.map), wolfpack.coord(target.x, target.y, target.z, target.map), wolfpack.coord(target.x + 1, target.y, target.z, target.map) ]

		# At least one spell should look fancy
		# Calculate the Angle here
		serials = []

		char.soundeffect(0x1f6)

		for pos in positions:
			newitem = wolfpack.newitem(1)
			newitem.id = 0x80
			newitem.moveto(pos)
			newitem.decay = 0 # Dont decay. TempEffect will take care of them
			newitem.update()
			newitem.settag('dispellable_field', 1)
			serials.append(newitem.serial)
			wolfpack.effect(0x376a, pos, 9, 10)

		wolfpack.addtimer(10000, field_expire, serials, 1)
Exemplo n.º 5
0
	def target(self, char, mode, targettype, target, args, item):
		char.turnto(target)

		if not self.consumerequirements(char, mode, args, target, item):
			return

		xdiff = abs(target.x - char.pos.x)
		ydiff = abs(target.y - char.pos.y)

		positions = []

		# North/South
		if xdiff > ydiff:
			itemid = 0x3922
			for i in range(-2, 3):
				positions.append(wolfpack.coord(target.x, target.y + i, target.z, target.map))

		# West/East
		else:
			itemid = 0x3915
			for i in range(-2, 3):
				positions.append(wolfpack.coord(target.x + i, target.y, target.z, target.map))

		serials = []
		char.soundeffect(0x20c)

		total = (char.skill[MAGERY] + char.skill[POISONING]) / 2.0
		if total >= 1000:
			level = 3
		elif total > 850:
			level = 2
		elif total > 650:
			level = 1
		else:
			level = 0

		for pos in positions:
			newitem = wolfpack.newitem(1)
			newitem.id = itemid
			#newitem.direction = 29
			newitem.moveto(pos)
			newitem.decay = 0 # Dont decay. TempEffect will take care of them
			newitem.settag('dispellable_field', 1)
			newitem.settag('level', level)
			newitem.addscript( 'magic.poisonfield' )
			newitem.update()
			serials.append(newitem.serial)

			# Affect chars who are occupying the field cells
			chars = wolfpack.chars( newitem.pos.x, newitem.pos.y, newitem.pos.map, 0 )
			for affected in chars:
				if affected.pos.z >= newitem.pos.z - 10 and affected.pos.z <= newitem.pos.z + 10:
					newitem.callevent(EVENT_COLLIDE, (affected, newitem))

		duration = int((3 + char.skill[MAGERY] / 25.0) * 1000)
		wolfpack.addtimer(duration, field_expire, serials, 1)
Exemplo n.º 6
0
    def target(self, char, mode, targettype, target, args, item):
        char.turnto(target)

        if not self.consumerequirements(char, mode, args, target, item):
            return

        xdiff = abs(target.x - char.pos.x)
        ydiff = abs(target.y - char.pos.y)

        positions = []

        # West / East
        if xdiff > ydiff:
            itemid = 0x3996
            for i in range(-2, 3):
                positions.append(
                    wolfpack.coord(target.x, target.y + i, target.z,
                                   target.map))

        # North South
        else:
            itemid = 0x398c
            for i in range(-2, 3):
                positions.append(
                    wolfpack.coord(target.x + i, target.y, target.z,
                                   target.map))

        serials = []

        char.soundeffect(0x20c)

        for pos in positions:
            newitem = wolfpack.newitem(1)
            newitem.id = itemid
            #newitem.direction = 29
            newitem.moveto(pos)
            newitem.decay = 0  # Dont decay. TempEffect will take care of them
            newitem.settag('dispellable_field', 1)
            newitem.settag('source', char.serial)
            newitem.addscript('magic.firefield')
            newitem.update()
            serials.append(newitem.serial)

            # Affect chars who are occupying the field cells
            chars = wolfpack.chars(newitem.pos.x, newitem.pos.y,
                                   newitem.pos.map, 0)
            if len(chars) > 0:
                for affected in chars:
                    if affected.pos.z >= newitem.pos.z - 10 and affected.pos.z <= newitem.pos.z + 10:
                        newitem.callevent(EVENT_COLLIDE, (affected, newitem))

        duration = int((4 + char.skill[MAGERY] * 0.05) * 1000)
        wolfpack.addtimer(duration, field_expire, serials, 1)
Exemplo n.º 7
0
    def target(self, char, mode, targettype, target, args, item):
        char.turnto(target)

        if not char.canreach(target, 10):
            char.message(500237)
            return

        if not self.consumerequirements(char, mode, args, target, item):
            return

        xdiff = abs(target.x - char.pos.x)
        ydiff = abs(target.y - char.pos.y)

        positions = []

        # West / East
        if xdiff > ydiff:
            itemid = 0x3996
            for i in range(-2, 3):
                positions.append(wolfpack.coord(target.x, target.y + i, target.z, target.map))

                # North South
        else:
            itemid = 0x398C
            for i in range(-2, 3):
                positions.append(wolfpack.coord(target.x + i, target.y, target.z, target.map))

        serials = []

        char.soundeffect(0x20C)

        for pos in positions:
            newitem = wolfpack.newitem(1)
            newitem.id = itemid
            # newitem.direction = 29
            newitem.moveto(pos)
            newitem.decay = 0  # Dont decay. TempEffect will take care of them
            newitem.settag("dispellable_field", 1)
            newitem.settag("source", char.serial)
            newitem.addscript("magic.firefield")
            newitem.update()
            serials.append(newitem.serial)

            # Affect chars who are occupying the field cells
            chars = wolfpack.chars(newitem.pos.x, newitem.pos.y, newitem.pos.map, 0)
            if len(chars) > 0:
                for affected in chars:
                    if affected.pos.z >= newitem.pos.z - 10 and affected.pos.z <= newitem.pos.z + 10:
                        newitem.callevent(EVENT_COLLIDE, (affected, newitem))

        duration = int((4 + char.skill[MAGERY] * 0.05) * 1000)
        wolfpack.addtimer(duration, "magic.utilities.field_expire", serials, 1)
Exemplo n.º 8
0
def onCHLevelChange( char, level ):
	if not char.hastag( 'customizing' ):
		return
	multi = wolfpack.findmulti( int( char.gettag( 'customizing' ) ) )

	char.socket.sysmessage( 'multi at: ' + str( multi.pos.z ) )
	char.socket.sysmessage( 'char at: ' + str( char.pos.z ) )
	alt = (level-1) * 49
	if level == 3:
		char.moveto( wolfpack.coord( multi.pos.x, multi.pos.y, char.pos.z+1, multi.pos.map ) )
	if level == 2:
		char.moveto( wolfpack.coord( multi.pos.x+4, multi.pos.y+4, multi.pos.z+alt, multi.pos.map ) )
	if level == 1:
		char.moveto( wolfpack.coord( multi.pos.x, multi.pos.y, char.pos.z-1, multi.pos.map ) )
	char.update()
	return 1
Exemplo n.º 9
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
Exemplo n.º 10
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
Exemplo n.º 11
0
def onDropOnItem(runebook, item):
    if not isRunebook(runebook):
        return False  # Only handle for dropping something on the runebook

    if not item.container or not item.container.ischar():
        return False  # Some internal error or script before us

    player = item.container

    if runebook.getoutmostchar() != player:
        player.socket.sysmessage(
            tr('The runebook has to be in your belongings to modify it.'))
    else:
        if isRune(item):
            location = None
            if item.hastag('marked') and item.hastag('location'):
                try:
                    (x, y, z, map) = item.gettag('location').split(',')
                    location = wolfpack.coord(int(x), int(y), int(z), int(map))
                except:
                    pass

            if location:
                index = getFreeIndex(runebook)

                if index != -1:
                    tagname = 'entry%u' % index
                    name = item.name.strip()
                    if len(name) != 0:
                        runebook.settag(tagname + 'name', name)
                    else:
                        runebook.deltag(
                            tagname + 'name')  # Make sure there is no old name
                    runebook.settag(tagname, str(location))
                    player.soundeffect(0x42)
                    item.delete()
                    return True

                else:
                    player.socket.clilocmessage(
                        502401)  # This runebook is full.
            else:
                player.socket.clilocmessage(502409)

        elif isRecallScroll(item):
            # Recharge if possible
            (charges, maxcharges) = getCharges(runebook)
            if charges < maxcharges:
                consume = min(item.amount, maxcharges - charges)
                runebook.settag('charges', charges + consume)
                player.soundeffect(0x249)

                if consume == item.amount:
                    item.delete()
                    return True  # The item has been removed
                else:
                    item.amount -= consume
            else:
                player.socket.clilocmessage(502410)
    return False
Exemplo n.º 12
0
	def __init__(self, char):
		if type(char) == str:
			values = char.split(';')
			self.account = unquote( values[0] )
			self.serial = int(values[1])
			self.name = unquote(values[2])
			(x, y, z, m) = values[3].split(',')
			self.pos = wolfpack.coord(int(x), int(y), int(z), int(m))
			self.category = unquote(values[4])
			self.message = ['', '', '', '']
			self.message[0] = unicode(unquote(values[5]))
			self.message[1] = unicode(unquote(values[6]))
			self.message[2] = unicode(unquote(values[7]))
			self.message[3] = unicode(unquote(values[8]))
			self.created = float(values[9])		
		else:
			self.account = char.account.name
			self.serial = char.serial
			self.name = char.name
			self.pos = char.pos
			self.category = ''
			self.message = ['', '', '', '']
			self.created = 0

		self.assigned = None
Exemplo n.º 13
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
Exemplo n.º 14
0
	def target(self, char, mode, targettype, target, args, item):
		char.turnto(target)

		if not self.consumerequirements(char, mode, args, target, item):
			return

		xdiff = abs(target.x - char.pos.x)
		ydiff = abs(target.y - char.pos.y)

		positions = []

		# West / East
		if xdiff > ydiff:
			itemid = 0x3967
			for i in range(-2, 3):
				positions.append(wolfpack.coord(target.x, target.y + i, target.z, target.map))

		# North South
		else:
			itemid = 0x3979
			for i in range(-2, 3):
				positions.append(wolfpack.coord(target.x + i, target.y, target.z, target.map))

		serials = []

		char.soundeffect(0x20b)

		for pos in positions:
			newitem = wolfpack.newitem(1)
			newitem.id = itemid
			newitem.moveto(pos)
			newitem.decay = 0 # Dont decay. TempEffect will take care of them
			newitem.settag('dispellable_field', 1)
			newitem.settag('strength', char.skill[self.damageskill])
			newitem.addscript( 'magic.paralyzefield' )
			newitem.update()
			serials.append(newitem.serial)
			wolfpack.effect(0x376A, newitem.pos, 9, 10)

			# Affect chars who are occupying the field cells
			chars = wolfpack.chars( newitem.pos.x, newitem.pos.y, newitem.pos.map, 0 )
			for affected in chars:
				if affected.pos.z >= newitem.pos.z - 10 and affected.pos.z <= newitem.pos.z + 10:
					newitem.callevent(EVENT_COLLIDE, (affected, newitem))

		duration = int((3 + char.skill[MAGERY] / 30.0) * 1000)
		wolfpack.addtimer(duration, field_expire, serials, 1)
Exemplo n.º 15
0
def foundation( char, target, width, height, multiid ):
	multi = wolfpack.multi( CUSTOMHOUSE )
	char.socket.sysmessage( str( multi.serial ) )
	multi.id = multiid + 0x4000
	multi.decay = FALSE
	multi.moveto( target.pos )

	left = width/2
	right = left - ( width-1 )
	bottom = height/2
	top = bottom - ( height-1 )

	#Draw floor
	for y in xrange( top+1,bottom+1 ):
		for x in xrange( right+1,left+1 ):
			if x == 0 and y == 0:
				multi.addchtile( 0x1, 0, 0, 0 )
			multi.addchtile( 0x31f4, x, y, 7 )

	#Draw corners
	multi.addchtile( 0x66, right, top, 0 )
	multi.addchtile( 0x65, left, bottom, 0 )

	#Draw sides
	for x in xrange( right+1,left+1 ):
		multi.addchtile( 0x63, x, top, 0 )
		if x < left:
			multi.addchtile( 0x63, x, bottom, 0 )

	for y in xrange( top+1, bottom+1 ):
		multi.addchtile( 0x64, right, y, 0 )
		multi.addchtile( 0x64, left, y, 0 )

	#Draw stairs
	for x in xrange( right+1,left+1 ):
		multi.addchtile( 0x0751, x, bottom+1, 0 )


	multi.sendcustomhouse( char )
	#woodenpost = wolfpack.additem( "9" )
	signpost = wolfpack.additem( "b98" )
	sign = wolfpack.additem( "bd2" )
	#woodenpost.decay = FALSE
	signpost.decay = FALSE
	sign.decay = FALSE
	x = multi.pos.x + right
	y = multi.pos.y + bottom
	z = multi.pos.z + 7
	map = multi.pos.map
	newpos = wolfpack.coord( x, y, z, map )
	#woodenpost.moveto( newpos )
	newpos.y += 1
	signpost.moveto( newpos )
	sign.moveto( newpos )
	sign.settag( 'house', multi.serial )
	sign.addscript( 'signpost' )
	#woodenpost.update()
	signpost.update()
	sign.update()
Exemplo n.º 16
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 )
Exemplo n.º 17
0
def onDropOnItem(runebook, item):
	if not isRunebook(runebook):
		return False # Only handle for dropping something on the runebook

	if not item.container or not item.container.ischar():
		return False # Some internal error or script before us

	player = item.container

	if runebook.getoutmostchar() != player:
		player.socket.sysmessage(tr('The runebook has to be in your belongings to modify it.'))
	else:
		if isRune(item):
			location = None
			if item.hastag('marked') and item.hastag('location'):
				try:
					(x, y, z, map) = item.gettag('location').split(',')
					location = wolfpack.coord(int(x), int(y), int(z), int(map))
				except:
					pass

			if location:
				index = getFreeIndex(runebook)
				
				if index != -1:
					tagname = 'entry%u' % index
					name = item.name.strip()
					if len(name) != 0:
						runebook.settag(tagname + 'name', name)
					else:
						runebook.deltag(tagname + 'name') # Make sure there is no old name
					runebook.settag(tagname, str(location))
					player.soundeffect(0x42)
					item.delete()
					return True

				else:
					player.socket.clilocmessage(502401) # This runebook is full.
			else:
				player.socket.clilocmessage(502409)

		elif isRecallScroll(item):
			# Recharge if possible
			(charges, maxcharges) = getCharges(runebook)
			if charges < maxcharges:
				consume = min(item.amount, maxcharges - charges)
				runebook.settag('charges', charges + consume)
				player.soundeffect(0x249)

				if consume == item.amount:
					item.delete()
					return True # The item has been removed
				else:
					item.amount -= consume
			else:
				player.socket.clilocmessage(502410)
	return False
Exemplo n.º 18
0
def Rotate( boat, coord, count ):
    rx = coord.x - boat.pos.x
    ry = coord.y - boat.pos.y

    for i in range( 0, count ):
        temp = rx
        rx = -ry
        ry = temp
    return wolfpack.coord( boat.pos.x + rx, boat.pos.y + ry, coord.z, coord.map )
Exemplo n.º 19
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
Exemplo n.º 20
0
def onCHLevelChange( char, level ):
	if not char.hastag( 'customizing' ):
		return
	multi = wolfpack.findobject( char.gettag( 'customizing' ) )

	char.socket.sysmessage( 'Level selected: ' + str( level ) )
	char.socket.sysmessage( 'multi at: ' + str( multi.pos.z ) )
	char.socket.sysmessage( 'char at: ' + str( char.pos.z ) )
	
	#alt = (level-1) * 49

	if level == 3:
		char.moveto( wolfpack.coord( multi.pos.x, multi.pos.y, multi.pos.z+47, multi.pos.map ) )
	if level == 2:
		char.moveto( wolfpack.coord( multi.pos.x, multi.pos.y, multi.pos.z+27, multi.pos.map ) )
	if level == 1:
		char.moveto( wolfpack.coord( multi.pos.x, multi.pos.y, multi.pos.z+7, multi.pos.map ) )
	char.update()
	return 1
Exemplo n.º 21
0
def onCHLevelChange(char, level):
    if not char.hastag("customizing"):
        return
    multi = wolfpack.findobject(char.gettag("customizing"))

    char.socket.sysmessage("Level selected: " + str(level))
    char.socket.sysmessage("multi at: " + str(multi.pos.z))
    char.socket.sysmessage("char at: " + str(char.pos.z))

    # alt = (level-1) * 49

    if level == 3:
        char.moveto(wolfpack.coord(multi.pos.x, multi.pos.y, multi.pos.z + 47, multi.pos.map))
    if level == 2:
        char.moveto(wolfpack.coord(multi.pos.x, multi.pos.y, multi.pos.z + 27, multi.pos.map))
    if level == 1:
        char.moveto(wolfpack.coord(multi.pos.x, multi.pos.y, multi.pos.z + 7, multi.pos.map))
    char.update()
    return 1
Exemplo n.º 22
0
    def target(self, char, mode, targettype, target, args, item):
        char.turnto(target)

        if not self.consumerequirements(char, mode, args, target, item):
            return

        xdiff = abs(target.x - char.pos.x)
        ydiff = abs(target.y - char.pos.y)

        positions = []

        # West / East
        if xdiff > ydiff:
            itemid = 0x3956
            for i in range(-2, 3):
                positions.append(
                    wolfpack.coord(target.x, target.y + i, target.z,
                                   target.map))

        # North South
        else:
            itemid = 0x3946
            for i in range(-2, 3):
                positions.append(
                    wolfpack.coord(target.x + i, target.y, target.z,
                                   target.map))

        serials = []

        char.soundeffect(0x20b)

        for pos in positions:
            newitem = wolfpack.newitem(1)
            newitem.id = itemid
            newitem.moveto(pos)
            newitem.decay = 0
            #newitem.direction = 29
            newitem.settag('dispellable_field', 1)
            newitem.update()
            serials.append(newitem.serial)

        duration = int((15 + (char.skill[MAGERY] / 5)) / 0.007)
        wolfpack.addtimer(duration, field_expire, serials, 1)
Exemplo n.º 23
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:
			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])

			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))
			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>')
Exemplo n.º 24
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
Exemplo n.º 25
0
def jailPlayer(player, target, tojail=True):
    if target.jailed == tojail:
        if not target.jailed:
            player.socket.sysmessage(
                tr('That player has been released from jail already.'))
        else:
            player.socket.sysmessage(tr('That player is in jail already.'))
        return

    if tojail:
        target.jailed = True
        target.account.jail()
        target.settag('unjail_pos', str(target.pos))

        target.removefromview()
        target.moveto(JAIL_POS)
        target.update()
        if target.socket:
            target.socket.resendworld()

        if player != target:
            player.log(
                LOG_MESSAGE, 'Jailed player %s (0x%x). Account: %s \n' %
                (target.orgname, target.serial, target.account.name))
            player.socket.sysmessage(
                tr('The targetted player has been jailed.'))
        target.message(503268)  # You've been jailed
    else:
        target.account.forgive()
        player.log(
            LOG_MESSAGE, 'Unjailed player %s (0x%x). Account: %s \n' %
            (target.orgname, target.serial, target.account.name))
        player.socket.sysmessage(tr('The targetted player has been unjailed.'))

        for char in target.account.characters:
            if char.jailed:
                # Send back to original position
                unjail_pos = char.gettag('unjail_pos')
                if unjail_pos and unjail_pos.count(',') == 3:
                    (x, y, z, map) = unjail_pos.split(',')

                    if map != 0xFF:
                        char.removefromview()
                        char.moveto(
                            wolfpack.coord(int(x), int(y), int(z), int(map)))
                        char.update()
                        if char.socket:
                            char.socket.resendworld()

                char.jailed = False
                char.deltag('unjail_pos')

        target.message(503267)  # You've been unjailed

    return
Exemplo n.º 26
0
def onUse(char, item):
    try:
        type = item.gettag('trap_type')
        damage = item.gettag('trap_damage')
        owner = wolfpack.findchar(int(item.gettag('trap_owner')))
    except:
        item.removescript('magic.trap')
        item.deltag('trap_type')
        item.deltag('trap_damage')
        item.deltag('trap_owner')
        return 0

    item.removescript('magic.trap')
    item.deltag('trap_type')
    item.deltag('trap_damage')
    item.deltag('trap_owner')

    char.message(502999)

    if not item.container:
        pos = item.pos
    else:
        item = item.getoutmostitem()
        if item.container:
            item = item.container
    pos = item.pos

    wolfpack.effect(0x36bd, wolfpack.coord(pos.x + 1, pos.y, pos.z, pos.map),
                    15, 15)
    wolfpack.effect(0x36bd, wolfpack.coord(pos.x, pos.y - 1, pos.z, pos.map),
                    15, 15)
    wolfpack.effect(0x36bd, wolfpack.coord(pos.x - 1, pos.y, pos.z, pos.map),
                    15, 15)
    wolfpack.effect(0x36bd, wolfpack.coord(pos.x, pos.y + 1, pos.z, pos.map),
                    15, 15)
    char.soundeffect(0x307)

    # Now Damage the Character
    if char.distanceto(item) <= 2:
        energydamage(char, owner, damage, fire=100)

    return 1
Exemplo n.º 27
0
def Move( boat, direction, speed, message ):
    if boat.hastag('boat_anchored'):
        return False

    rx, ry = MovementOffset( ( direction + int( boat.gettag('boat_facing') ) & 0x07 ) )

    xOffset = speed * rx;
    yOffset = speed * ry;

    # Move the boat
    newCoord = wolfpack.coord( boat.pos.x + xOffset, boat.pos.y + yOffset, boat.pos.z, boat.pos.map )

    # Check collision here
    if not wolfpack.canboatmoveto( boat, newCoord ):
        if message:
            tillerman = wolfpack.finditem( int( boat.gettag('boat_tillerman') ) )
            if tillerman != None:
                tillerman.say( 501424 ) # Ar, we've stopped sir.
        return False;        

    
    boat.moveto( newCoord )
    boat.update()

    # Move boat subparts
    for i in range( 1, int( boat.gettag('boat_part_count') ) + 1 ):
        item = wolfpack.finditem( int( boat.gettag('boat_part%i' % i) ) )
        if item != None:
            newCoord = wolfpack.coord( item.pos.x + xOffset, item.pos.y + yOffset, item.pos.z, item.pos.map )
            item.moveto( newCoord )
            item.update()

    # Move other items/chars inside the boat
    listitems = boat.objects
    for item in listitems:
	if not item.hastag('boat_serial'):
		newCoord = wolfpack.coord( item.pos.x + xOffset, item.pos.y + yOffset, item.pos.z, item.pos.map )
		item.moveto( newCoord )
		item.update()
    return True
Exemplo n.º 28
0
def placeItem(x, y, z, mapid, itemid):
    if itemid == None:
        return
    elif type(itemid) == tuple:
        itemid = random.choice(itemid)
    elif type(itemid) == list:
        itemid = random.choice(itemid)

    item = wolfpack.additem(itemid)
    item.moveto(wolfpack.coord(x, y, z, mapid))
    item.movable = 2
    item.decay = False
    item.update()
Exemplo n.º 29
0
	def target(self, char, mode, targettype, target, args, item):
		char.turnto(target)

		if not self.consumerequirements(char, mode, args, target, item):
			return

		xdiff = abs(target.x - char.pos.x)
		ydiff = abs(target.y - char.pos.y)

		positions = []

		# West / East
		if xdiff > ydiff:
			itemid = 0x3956
			for i in range(-2, 3):
				positions.append(wolfpack.coord(target.x, target.y + i, target.z, target.map))

		# North South
		else:
			itemid = 0x3946
			for i in range(-2, 3):
				positions.append(wolfpack.coord(target.x + i, target.y, target.z, target.map))

		serials = []

		char.soundeffect(0x20b)

		for pos in positions:
			newitem = wolfpack.newitem(1)
			newitem.id = itemid
			newitem.moveto(pos)
			newitem.decay = 0
			#newitem.direction = 29
			newitem.settag('dispellable_field', 1)
			newitem.update()
			serials.append(newitem.serial)

		duration = int((15 + (char.skill[MAGERY] / 5)) / 0.007)
		wolfpack.addtimer(duration, field_expire, serials, 1)
Exemplo n.º 30
0
def placeItem(x, y, z, mapid, itemid):
	if itemid == None:
		return
	elif type(itemid) == tuple:
		itemid = random.choice(itemid)
	elif type(itemid) == list:
		itemid = random.choice(itemid)

	item = wolfpack.additem(itemid)
	item.moveto(wolfpack.coord(x, y, z, mapid))
	item.movable = 2
	item.decay = False
	item.update()
Exemplo n.º 31
0
def response( char, args, target ):
	socket = char.socket
	xmod = args[0]
	ymod = args[1]
	zmod = args[2]
	newmap = args[3]
	if not newmap:
		newmap = False

	if newmap:
		newmap = int(newmap)
	xmod = int( xmod )
	ymod = int( ymod )
	zmod = int( zmod )

	if target.item:
		item = target.item
		pos = item.pos
		if type(newmap) == int:
			newposition = "%i,%i,%i,%i" % ( (pos.x + xmod) , (pos.y + ymod ), (pos.z + zmod), newmap )
		else:
			newposition = "%i,%i,%i,%i" % ( (pos.x + xmod) , (pos.y + ymod ), (pos.z + zmod), pos.map )
		item.pos = newposition
		item.update()
		return True
	elif target.char:
		char = target.char
		pos = char.pos
		if type(newmap) == int:
			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 )
		char.removefromview()
		char.moveto( newposition )
		char.update()
		if char.socket:
			char.socket.resendworld()
		return True
	return True
Exemplo n.º 32
0
    def __init__(self, char):
        if type(char) == str:
            values = char.split(';')
            self.account = unquote(values[0]).decode('utf-8')
            self.serial = int(values[1])
            self.name = unquote(values[2]).decode('utf-8')
            (x, y, z, m) = values[3].split(',')
            self.pos = wolfpack.coord(int(x), int(y), int(z), int(m))
            self.category = unquote(values[4]).decode('utf-8')
            self.message = ['', '', '', '']
            self.message[0] = unquote(values[5]).decode('utf-8')
            self.message[1] = unquote(values[6]).decode('utf-8')
            self.message[2] = unquote(values[7]).decode('utf-8')
            self.message[3] = unquote(values[8]).decode('utf-8')
            self.created = float(values[9])
        elif type(char) == unicode:
            values = char.split(';')
            self.account = unquote(values[0])
            self.serial = int(values[1])
            self.name = unquote(values[2])
            (x, y, z, m) = values[3].split(',')
            self.pos = wolfpack.coord(int(x), int(y), int(z), int(m))
            self.category = unquote(values[4])
            self.message = ['', '', '', '']
            self.message[0] = unquote(values[5])
            self.message[1] = unquote(values[6])
            self.message[2] = unquote(values[7])
            self.message[3] = unquote(values[8])
            self.created = float(values[9])
        else:
            self.account = char.account.name
            self.serial = char.serial
            self.name = char.name
            self.pos = char.pos
            self.category = ''
            self.message = [u'', u'', u'', u'']
            self.created = 0

        self.assigned = None
Exemplo n.º 33
0
def onUse(player, item):

    if (player.distanceto(item) > 8):
        return False

    boat_serial = item.gettag('boat_serial')

    if (player.multi != None and player.multi.serial == boat_serial):
        if (item.hastag('plank_open')):
            closePlank(item)
        else:
            openPlank(item)
    else:
        if not item.hastag('plank_open'):
            if not item.hastag('plank_locked'):
                openPlank(item)
            elif player.gm:
                player.say(502502)
                # That is locked but your godly powers allow access
            else:
                player.say(502503)
                # That is locked.
        elif not item.hastag('plank_locked'):
            newpos = wolfpack.coord(item.pos.x, item.pos.y, item.pos.z + 5,
                                    item.pos.map)
            player.moveto(newpos)
            player.update()
        elif player.gm:
            player.say(502502)
            # That is locked but your godly powers allow access
            newpos = wolfpack.coord(item.pos.x, item.pos.y, item.pos.z + 5,
                                    item.pos.map)
            player.moveto(newpos)
            player.update()
        else:
            player.say(502503)
            # That is locked.
    return True
Exemplo n.º 34
0
	def target(self, char, mode, targettype, target, args, item):
		char.turnto(target)

		# Only containers are trappable
		if target.type != 1:
			char.message('You can''t trap that.')
			return

		if not self.consumerequirements(char, mode, args, target, item):
			return

		pos = target.pos
		wolfpack.effect(0x376a, wolfpack.coord(pos.x + 1, pos.y, pos.z, pos.map), 9, 10)
		wolfpack.effect(0x376a, wolfpack.coord(pos.x, pos.y - 1, pos.z, pos.map), 9, 10)
		wolfpack.effect(0x376a, wolfpack.coord(pos.x - 1, pos.y, pos.z, pos.map), 9, 10)
		wolfpack.effect(0x376a, wolfpack.coord(pos.x, pos.y + 1, pos.z, pos.map), 9, 10)
		target.soundeffect(0x1ef)

		# Add the Trap Properties to the Item
		target.settag('trap_owner', char.serial)
		target.settag('trap_damage', random.randint(10, 50))
		target.settag('trap_type', 'magic')
		target.addscript( 'magic.trap' )
Exemplo n.º 35
0
def generateGoMenu():
    locations = wolfpack.getdefinitions(WPDT_LOCATION)

    gomenu = MakeMenu('GOMENU', None, 'Go Menu')
    submenus = {}

    for location in locations:
        if not location.hasattribute('category'):
            continue
        categories = location.getattribute('category').split('\\')
        description = categories[len(categories) - 1]  # Name of the action
        categories = categories[:len(categories) - 1]

        # Iterate trough the categories and see if they're all there
        category = ''
        if len(categories) > 0 and not submenus.has_key('\\'.join(categories) +
                                                        '\\'):
            for subcategory in categories:
                if not submenus.has_key(category + subcategory + '\\'):
                    # Category is our parent category
                    parent = None
                    if len(category) == 0:
                        parent = gomenu
                    elif category in submenus:
                        parent = submenus[category]

                    category += subcategory + '\\'
                    menu = MakeMenu('GOMENU_' + category, parent, subcategory)
                    submenus[category] = menu
                else:
                    category += subcategory + '\\'

        # Parse the position of this makemenu entry
        if location.text.count(',') != 3:
            raise RuntimeError, "Wrong position information for location %s." % location.getattribute(
                'id')

        (x, y, z, map) = location.text.split(',')
        pos = wolfpack.coord(int(x), int(y), int(z), int(map))

        if len(categories) == 0:
            GoAction(gomenu, description, pos)
        else:
            GoAction(submenus['\\'.join(categories) + '\\'], description, pos)

    for menu in submenus.values():
        menu.sort()

    gomenu.sort()
    return
Exemplo n.º 36
0
def jailPlayer(player, target, tojail = True):
	if target.jailed == tojail:
		if not target.jailed:
			player.socket.sysmessage(tr('That player has been released from jail already.'))
		else:
			player.socket.sysmessage(tr('That player is in jail already.'))
		return


	if tojail:
		target.jailed = True
		target.account.jail()
		target.settag('unjail_pos', str(target.pos))

		target.removefromview()
		target.moveto(JAIL_POS)
		target.update()
		if target.socket:
			target.socket.resendworld()

		if player != target:
			player.log(LOG_MESSAGE, 'Jailed player %s (0x%x). Account: %s \n' % (target.orgname, target.serial, target.account.name))
			player.socket.sysmessage(tr('The targetted player has been jailed.'))
		target.message(503268) # You've been jailed
	else:
		target.account.forgive()
		player.log(LOG_MESSAGE,'Unjailed player %s (0x%x). Account: %s \n' % (target.orgname, target.serial, target.account.name))
		player.socket.sysmessage(tr('The targetted player has been unjailed.'))

		for char in target.account.characters:
			if char.jailed:
				# Send back to original position
				unjail_pos = char.gettag('unjail_pos')
				if unjail_pos and unjail_pos.count(',') == 3:
					(x, y, z, map) = unjail_pos.split(',')

					if map != 0xFF:
						char.removefromview()
						char.moveto(wolfpack.coord(int(x), int(y), int(z), int(map)))
						char.update()
						if char.socket:
							char.socket.resendworld()

				char.jailed = False
				char.deltag('unjail_pos')
				
		target.message(503267) # You've been unjailed

	return
Exemplo n.º 37
0
def recall1( self, args ):
	if( len( args ) < 2 ):
		return 1
	char = wolfpack.findchar( args[ 0 ] )
	rune = wolfpack.finditem( args[ 1 ] )

	if not char:
		return False
	if not rune:
		char.socket.sysmessage( "runebook script error." )
		return False
	# Check for Recall
	if not magic.utilities.hasSpell(char, 32):
		return False

	location = rune.gettag( 'location' )
	location = location.split(",")
	location = wolfpack.coord(int(location[0]), int(location[1]), int(location[2]), int(location[3]))

	region = None
	region = wolfpack.region(char.pos.x, char.pos.y, char.pos.map)

	if region and region.norecallout:
		char.message(501802)
		fizzle(char)
		return False
		region = None
		region = wolfpack.region(location.x, location.y, location.map)

	if not location.validspawnspot():
			char.message(501942)
			fizzle(char)
			return False

	if region and region.norecallin:
			char.message(1019004)
			fizzle(char)
			return False

	# cast spell
	if( char.mana < 11 ):
		char.socket.sysmessage( "You lack the mana to recall." )
		return False

	# Insert link to Recall Spell!
	char.socket.sysmessage( "not implemented yet" )

	return True
Exemplo n.º 38
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)
Exemplo n.º 39
0
def generateGoMenu():
    locations = wolfpack.getdefinitions(WPDT_LOCATION)

    gomenu = MakeMenu("GOMENU", None, "Go Menu")
    submenus = {}

    for location in locations:
        if not location.hasattribute("category"):
            continue
        categories = location.getattribute("category").split("\\")
        description = categories[len(categories) - 1]  # Name of the action
        categories = categories[: len(categories) - 1]

        # Iterate trough the categories and see if they're all there
        category = ""
        if len(categories) > 0 and not submenus.has_key("\\".join(categories) + "\\"):
            for subcategory in categories:
                if not submenus.has_key(category + subcategory + "\\"):
                    # Category is our parent category
                    parent = None
                    if len(category) == 0:
                        parent = gomenu
                    elif category in submenus:
                        parent = submenus[category]

                    category += subcategory + "\\"
                    menu = MakeMenu("GOMENU_" + category, parent, subcategory)
                    submenus[category] = menu
                else:
                    category += subcategory + "\\"

                    # Parse the position of this makemenu entry
        if location.text.count(",") != 3:
            raise RuntimeError, "Wrong position information for location %s." % location.getattribute("id")

        (x, y, z, map) = location.text.split(",")
        pos = wolfpack.coord(int(x), int(y), int(z), int(map))

        if len(categories) == 0:
            GoAction(gomenu, description, pos)
        else:
            GoAction(submenus["\\".join(categories) + "\\"], description, pos)

    for menu in submenus.values():
        menu.sort()

    gomenu.sort()
    return
Exemplo n.º 40
0
def spawnNpc(pos, npc):
    # Try it 5 times
    for i in range(0, 5):
        x = pos.x + random.randint(-1, 1)
        y = pos.y + random.randint(-1, 1)
        npcpos = wolfpack.coord(x, y, pos.z, pos.map)

        if not npcpos.validspawnspot():
            npcpos.z = 127
            if not npcpos.validspawnspot():
                continue

        npc.moveto(npcpos)
        return True

    return False
Exemplo n.º 41
0
def spawnItem(pos, item):
	# Try it 5 times
	for i in range(0, 5):
		x = pos.x + random.randint(-1, 1)
		y = pos.y + random.randint(-1, 1)
		itempos = wolfpack.coord(x, y, pos.z, pos.map)
		
		if not itempos.validspawnspot():
			itempos.z = 127
			if not itempos.validspawnspot():
				continue
			
		item.moveto(itempos)
		return True
		
	return False
Exemplo n.º 42
0
def spawnNpc(pos, npc):
	# Try it 5 times
	for i in range(0, 5):
		x = pos.x + random.randint(-1, 1)
		y = pos.y + random.randint(-1, 1)
		npcpos = wolfpack.coord(x, y, pos.z, pos.map)
		
		if not npcpos.validspawnspot():
			npcpos.z = 127
			if not npcpos.validspawnspot():
				continue
			
		npc.moveto(npcpos)
		return True
		
	return False	
Exemplo n.º 43
0
def spawnItem(pos, item):
    # Try it 5 times
    for i in range(0, 5):
        x = pos.x + random.randint(-1, 1)
        y = pos.y + random.randint(-1, 1)
        itempos = wolfpack.coord(x, y, pos.z, pos.map)

        if not itempos.validspawnspot():
            itempos.z = 127
            if not itempos.validspawnspot():
                continue

        item.moveto(itempos)
        return True

    return False
Exemplo n.º 44
0
def customize( char, item ):
	if not item.hastag( 'house' ):
		return

	multi = wolfpack.findmulti( int( item.gettag( 'house' ) ) )
	multi.sendcustomhouse( char )
	char.socket.sysmessage( str( multi.serial ) )
	#char.socket.sysmessage( "Multi serial : %i" % multi.serial )
	char.moveto( wolfpack.coord( multi.pos.x, multi.pos.y, multi.pos.z+7, multi.pos.map ) )
	char.update()
	#woodenpost = wolfpack.finditem( item.morez )
	#woodenpost.delete()
	char.socket.customize( item )
	char.settag( 'customizing', multi.serial )

	return 1
Exemplo n.º 45
0
def getEntry(runebook, index):
    if index < 0 or index > 15:
        return None

    tagname = "entry%u" % index

    if not runebook.hastag(tagname):
        return None

    try:
        (x, y, z, map) = runebook.gettag(tagname).split(",")
        pos = wolfpack.coord(int(x), int(y), int(z), int(map))
    except:
        return None

    return pos
Exemplo n.º 46
0
def getEntry(runebook, index):
    if index < 0 or index > 15:
        return None

    tagname = 'entry%u' % index

    if not runebook.hastag(tagname):
        return None

    try:
        (x, y, z, map) = runebook.gettag(tagname).split(',')
        pos = wolfpack.coord(int(x), int(y), int(z), int(map))
    except:
        return None

    return pos
Exemplo n.º 47
0
def onCollide(char, item):

    if not item.hastag('plank_open'):
        return False

    boat_serial = item.gettag('boat_serial')
    if char.multi != None and char.multi.serial != boat_serial:
        return True

    rx = 0
    ry = 0

    if item.id == 0x3ed4:
        rx = 1
    elif item.id == 0x3ed5:
        rx = -1
    elif item.id == 0x3e84:
        ry = 1
    elif item.id == 0x3e89:
        ry = -1

    for i in range(1, 6):
        x = item.pos.x + (i * rx)
        y = item.pos.y + (i * ry)
        z = 0

        for j in range(-8, 8):
            z = char.pos.z + j
            pos = wolfpack.coord(x, y, z, item.pos.map)
            if pos.validspawnspot():
                if i == 1 and j >= -2 and j <= 2:
                    return True
                char.moveto(pos)
                char.update()
                return True

        #z = wolfpack.getaveragez( x, y, item.pos.map )
        #pos = wolfpack.coord( x, y, z, item.pos.map )
        #if  pos.validspawnspot():
        #    if i == 1:
        #        return True
        #    char.moveto( pos )
        #    char.update()
        #    return True
    return True
Exemplo n.º 48
0
def customize( char, item ):
	if not checkAccess(char, item.multi, ACCESS_OWNER):
		char.socket.sysmessage('You are not the owner of this house.')
		return
	
	if not item.hastag( 'house' ):
		return

	multi = wolfpack.findobject( item.gettag( 'house' ) )
	# I Commented the last line... it servers for what exactly? no references for this
	#multi.sendcustomhouse( char )
	char.socket.sysmessage( str( multi.serial ) )
	#char.socket.sysmessage( "Multi serial : %i" % multi.serial )
	char.moveto( wolfpack.coord( multi.pos.x, multi.pos.y, multi.pos.z+7, multi.pos.map ) )
	char.update()
	#woodenpost = wolfpack.finditem( item.morez )
	#woodenpost.delete()
	char.socket.customize( item )
	char.settag( 'customizing', multi.serial )

	return 1
Exemplo n.º 49
0
def createBoatSpecialItem(definition, parentTag, boat):
    offsets = parentTag.findchild('offsets')
    xoffset = int(offsets.getattribute('x', '0'))
    yoffset = int(offsets.getattribute('y', '0'))
    item = wolfpack.additem(definition)
    itempos = wolfpack.coord(boat.pos.x + xoffset, boat.pos.y + yoffset,
                             boat.pos.z, boat.pos.map)
    item.moveto(itempos)
    item.update()
    item.decay = 0
    item.settag('boat_serial', boat.serial)
    if not boat.hastag('boat_part_count'):
        boat.settag('boat_part_count', 1)
        boat.settag('boat_part1', item.serial)
    else:
        i = int(boat.gettag('boat_part_count'))
        i = i + 1
        boat.settag('boat_part_count', i)
        boat.settag('boat_part%i' % i, item.serial)

    return item
Exemplo n.º 50
0
def getEntries(runebook):
    entries = []

    for i in range(0, 16):
        tagname = 'entry%u' % i
        if runebook.hastag(tagname):
            try:
                (x, y, z, map) = runebook.gettag(tagname).split(',')
                pos = wolfpack.coord(int(x), int(y), int(z), int(map))

                if runebook.hastag(tagname + 'name'):
                    name = runebook.gettag(tagname + 'name')
                else:
                    name = tr('(indescript)')

                entries.append([i, name, pos])
            except:
                raise
                runebook.deltag(tagname)
                runebook.deltag(tagname + 'name')

    return entries
Exemplo n.º 51
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)
Exemplo n.º 52
0
    def target(self, char, mode, targettype, target, args, item):
        char.turnto(target)

        if not self.consumerequirements(char, mode, args, target, item):
            return

        xdiff = abs(target.x - char.pos.x)
        ydiff = abs(target.y - char.pos.y)

        if xdiff > ydiff:
            positions = [
                wolfpack.coord(target.x, target.y - 1, target.z, target.map),
                wolfpack.coord(target.x, target.y, target.z, target.map),
                wolfpack.coord(target.x, target.y + 1, target.z, target.map)
            ]
        else:
            positions = [
                wolfpack.coord(target.x - 1, target.y, target.z, target.map),
                wolfpack.coord(target.x, target.y, target.z, target.map),
                wolfpack.coord(target.x + 1, target.y, target.z, target.map)
            ]

        # At least one spell should look fancy
        # Calculate the Angle here
        serials = []

        char.soundeffect(0x1f6)

        for pos in positions:
            newitem = wolfpack.newitem(1)
            newitem.id = 0x80
            newitem.moveto(pos)
            newitem.decay = 0  # Dont decay. TempEffect will take care of them
            newitem.update()
            newitem.settag('dispellable_field', 1)
            serials.append(newitem.serial)
            wolfpack.effect(0x376a, pos, 9, 10)

        wolfpack.addtimer(10000, field_expire, serials, 1)
Exemplo n.º 53
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
Exemplo n.º 54
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
Exemplo n.º 55
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
Exemplo n.º 56
0
import wolfpack
from wolfpack import tr
from wolfpack.consts import *
"""
	\command jail
	\description Sends the targetted player to jail after saving his current position. The jailed flag is set for the player too.
	If you want to release the player from jail, you have to use the forgive command.
"""
"""
	\command forgive
	\description Releases the targetted player from jail and sends him back where he was before being jailed.
"""

# Set this to the position of your jail
JAIL_POS = wolfpack.coord(5275, 1163, 0, 1)


def jailPlayer(player, target, tojail=True):
    if target.jailed == tojail:
        if not target.jailed:
            player.socket.sysmessage(
                tr('That player has been released from jail already.'))
        else:
            player.socket.sysmessage(tr('That player is in jail already.'))
        return

    if tojail:
        target.jailed = True
        target.account.jail()
        target.settag('unjail_pos', str(target.pos))
Exemplo n.º 57
0
def SetFacing( boat, direction ):

    # Checking collision
    newboatid = boat.id
    if direction == Forward:
        newboatid = int( boat.gettag('boat_id_north') )
    elif direction == Backward:
        newboatid = int( boat.gettag('boat_id_south') )
    elif direction == Left:
        newboatid = int( boat.gettag('boat_id_west') )
    elif direction == Right:
        newboatid = int( boat.gettag('boat_id_east') )

    oldboatid = boat.id
    boat.id = newboatid
    if not wolfpack.canboatmoveto( boat, boat.pos ):
        boat.id = oldboatid
        return False;        

    old = int( boat.gettag('boat_facing') )
    boat.settag( 'boat_facing', direction )
    rx, ry = MovementOffset( direction )

    count = ( direction - old ) & 0x07
    count = count / 2

    # Move boat subparts
    for i in range( 1, int( boat.gettag('boat_part_count') ) + 1 ):
        item = wolfpack.finditem( int( boat.gettag('boat_part%i' % i) ) )
        if item != None:
            #wolfpack.console.send('direction = %i\n' % direction )
            if item.id in [ 0x3e4b, 0x3e4e, 0x3e50, 0x3e53 ]: # Tillerman
                distance = max( abs( boat.pos.y - item.pos.y ), abs( boat.pos.x - item.pos.x ) )
                p = wolfpack.coord( boat.pos.x + ( rx * -distance ), boat.pos.y + ( ry * -distance ), item.pos.z, item.pos.map )
                if direction == Forward:
                    p.x = p.x + 1
                    item.id = 0x3e4e
                elif direction == Backward:
                    item.id = 0x3e4b
                elif direction == Left:
                    item.id = 0x3e50
                elif direction == Right:
                    item.id = 0x3e53
                item.moveto( p )
            elif item.id in [ 0x3e65, 0x3e93, 0x3eae, 0x3eb9 ]: # Hold
                distance = max( abs( boat.pos.y - item.pos.y ), abs( boat.pos.x - item.pos.x ) )
                p = wolfpack.coord( boat.pos.x + ( rx * distance ), boat.pos.y + ( ry * distance ), item.pos.z, item.pos.map )
                if direction == Forward:
                    #p.x = p.x + 1
                    item.id = 0x3eae
                elif direction == Backward:
                    item.id = 0x3eb9
                elif direction == Left:
                    item.id = 0x3e93
                elif direction == Right:
                    item.id = 0x3e65
                item.moveto( p )
            elif item.id in [ 0x3ed4, 0x3ed5, 0x3e84, 0x3e89, 0x3eb2, 0x3eb1, 0x3e85, 0x3e8a ]: # gang planks
                if item.hastag('plank_open'):
                    if item.hastag('plank_starboard'):
                        if direction == Forward:
                            item.id = 0x3ed4
                        elif direction == Backward:
                            item.id = 0x3ed5
                        elif direction == Left:
                            item.id = 0x3e89
                        elif direction == Right:
                            item.id = 0x3e84
                    else:
                        if direction == Forward:
                            item.id = 0x3ed5
                        elif direction == Backward:
                            item.id = 0x3ed4
                        elif direction == Left:
                            item.id = 0x3e84
                        elif direction == Right:
                            item.id = 0x3e89
                else:
                    if item.hastag('plank_starboard'):
                        if direction == Forward:
                            item.id = 0x3eb2
                        elif direction == Backward:
                            item.id = 0x3eb1
                        elif direction == Left:
                            item.id = 0x3e8a
                        elif direction == Right:
                            item.id = 0x3e85
                    else:
                        if direction == Forward:
                            item.id = 0x3eb1
                        elif direction == Backward:
                            item.id = 0x3eb2
                        elif direction == Left:
                            item.id = 0x3e85
                        elif direction == Right:
                            item.id = 0x3e8a
                item.moveto( Rotate( boat, item.pos, count ) )
            item.update()

    # Rotate other items/chars inside the boat
    listitems = boat.objects
    for item in listitems:
	if not item.hastag('boat_serial'):
		item.moveto( Rotate( boat, item.pos, count ) )
		try:
			item.direction += int( direction ) - int( old )
			item.update()
		except:
			item.update()
			continue

            
    boat.update()

    return True
Exemplo n.º 58
0
    def target(self, char, mode, targettype, target, args, item):
        char.turnto(target)

        if not self.consumerequirements(char, mode, args, target, item):
            return

        xdiff = abs(target.x - char.pos.x)
        ydiff = abs(target.y - char.pos.y)

        positions = []

        # North/South
        if xdiff > ydiff:
            itemid = 0x3922
            for i in range(-2, 3):
                positions.append(
                    wolfpack.coord(target.x, target.y + i, target.z,
                                   target.map))

        # West/East
        else:
            itemid = 0x3915
            for i in range(-2, 3):
                positions.append(
                    wolfpack.coord(target.x + i, target.y, target.z,
                                   target.map))

        serials = []
        char.soundeffect(0x20c)

        total = (char.skill[MAGERY] + char.skill[POISONING]) / 2.0
        if total >= 1000:
            level = 3
        elif total > 850:
            level = 2
        elif total > 650:
            level = 1
        else:
            level = 0

        for pos in positions:
            newitem = wolfpack.newitem(1)
            newitem.id = itemid
            #newitem.direction = 29
            newitem.moveto(pos)
            newitem.decay = 0  # Dont decay. TempEffect will take care of them
            newitem.settag('dispellable_field', 1)
            newitem.settag('level', level)
            newitem.addscript('magic.poisonfield')
            newitem.update()
            serials.append(newitem.serial)

            # Affect chars who are occupying the field cells
            chars = wolfpack.chars(newitem.pos.x, newitem.pos.y,
                                   newitem.pos.map, 0)
            for affected in chars:
                if affected.pos.z >= newitem.pos.z - 10 and affected.pos.z <= newitem.pos.z + 10:
                    newitem.callevent(EVENT_COLLIDE, (affected, newitem))

        duration = int((3 + char.skill[MAGERY] / 25.0) * 1000)
        wolfpack.addtimer(duration, field_expire, serials, 1)