def placement(player, arguments, target):
	deed = wolfpack.finditem(arguments[0])
	(dispid, xoffset, yoffset, zoffset) = arguments[1:] # Get the rest of the arguments
	
	if not checkDeed(player, deed):
		return	

	if not player.canreach(target.pos, 20):
		player.socket.sysmessage('You can\'t reach that.')
		return
		
	(canplace, moveout) = wolfpack.canplace(target.pos, dispid - 0x4000, 4)
	
	if not canplace:
		player.socket.sysmessage('CANT PLACE THERE')
		return
	
	house = wolfpack.addmulti(str(deed.gettag('section')))
	house.owner = player
	house.moveto(target.pos)
	house.update()
	housing.registerHouse(house)

	for obj in moveout:
		obj.removefromview()
		obj.moveto(player.pos)
		obj.update()
		if obj.ischar() and obj.socket:
			obj.socket.resendworld()
Exemple #2
0
def placement(player, arguments, target):
	deed = wolfpack.finditem(arguments[0])
	(dispid, xoffset, yoffset, zoffset) = arguments[1:] # Get the rest of the arguments

	if not checkDeed(player, deed):
		return	

	if not player.canreach(target.pos, 20):
		player.socket.sysmessage('You can\'t reach that.')
		return

	(canplace, moveout) = wolfpack.canplace(target.pos, dispid - 0x4000, 4)

	if not canplace:
		player.socket.sysmessage('CAN\'T PLACE THERE')
		return

	house = wolfpack.addmulti(str(deed.gettag('section')))
	house.owner = player
	house.moveto(target.pos)
	house.update()
	housing.registerHouse(house)

	for obj in moveout:
		obj.removefromview()
		obj.moveto(player.pos)
		obj.update()
		if obj.ischar() and obj.socket:
			obj.socket.resendworld()
	deed.delete()
	return
Exemple #3
0
def addmulti(player, arguments, target):
	if target.item and target.item.container:
		player.socket.sysmessage("You can't add the multi there.")
		return

	multi = wolfpack.addmulti(str(arguments[0]))
	multi.moveto(target.pos)
	multi.update()
Exemple #4
0
    def startElement(self, name, atts):
        if name == "item":
            self.itemid = str(atts.getValue("id"))
            if "hue" in atts:
                self.hue = int(hex2dec(str(atts.getValue("hue"))))
            else:
                self.hue = 0
            if "amount" in atts:
                self.amount = int(atts.getValue("amount"))
            else:
                self.amount = 0
            self.statements = []
        elif name == "attribute":
            type = "str"
            if "type" in atts:
                type = str(atts.getValue("type"))
            if "value" in atts and "key" in atts:
                self.statements.append(
                    str(atts.getValue("key")) + "," + type + "," +
                    str(atts.getValue("value")))
        elif name == "pos":
            if int(hex2dec(self.itemid)) >= 0x4000:
                item = wolfpack.addmulti("%x" % hex2dec(self.itemid))
            else:
                item = wolfpack.additem("%x" % hex2dec(self.itemid))

            if not item or item == None:
                return
            if self.hue > 0:
                item.color = self.hue
            if self.amount > 0:
                item.amount = self.amount
            for p in self.statements:
                parts = p.split(",")
                if hasattr(item, parts[0]):
                    if parts[1] == "str":
                        value = parts[2]
                    elif parts[1] == "int":
                        value = int(parts[2])
                    setattr(item, parts[0], value)

            x = int(atts.getValue("x"))
            y = int(atts.getValue("y"))
            z = int(atts.getValue("z"))
            map = int(atts.getValue("map"))
            item.moveto(x, y, z, map)
            item.movable = 3  # not movable
            item.decay = 0  # no decay
            item.update()
        elif name == "include":
            path = atts.getValue("file")
            if not os.path.isfile(path):
                console.log(LOG_ERROR, tr("File '%s' not found.\n") % (path))
                return
            parser = xml.sax.make_parser()
            handler = DecorationHandler()
            parser.setContentHandler(handler)
            parser.parse(path)
	def startElement( self, name, atts ):
		if name == "item":
			self.itemid = str(atts.getValue("id"));
			if "hue" in atts:
				self.hue = int(hex2dec(str(atts.getValue("hue"))));
			else:
				self.hue = 0
			if "amount" in atts:
				self.amount = int(atts.getValue("amount"));
			else:
				self.amount = 0
			self.statements = []
		elif name == "attribute":
			type = "str"
			if "type" in atts:
				type = str(atts.getValue("type"))
			if "value" in atts and "key" in atts:
				self.statements.append( str(atts.getValue("key")) + "," + type + ","+ str(atts.getValue("value")) )
		elif name == "pos":
			if int(hex2dec( self.itemid )) >= 0x4000:
				item = wolfpack.addmulti( "%x" %  hex2dec( self.itemid ) )
			else:
				item = wolfpack.additem( "%x" %  hex2dec( self.itemid ) )

			if not item or item == None:
				return
			if self.hue > 0:
				item.color = self.hue
			if self.amount > 0:
				item.amount = self.amount
			for p in self.statements:
				parts = p.split(",")
				if hasattr(item, parts[0]):
					if parts[1] == "str":
						value = parts[2]
					elif parts[1] == "int":
						value = int(parts[2])
					setattr(item, parts[0], value)

			x = int( atts.getValue("x") )
			y = int( atts.getValue("y") )
			z = int( atts.getValue("z") )
			map = int( atts.getValue("map") )
			item.moveto( x, y, z, map )
			item.movable = 3 # not movable
			item.decay = 0 # no decay
			item.update()
		elif name == "include":
			path = atts.getValue("file")
			if not os.path.isfile(path):
				console.log(LOG_ERROR, tr("File '%s' not found.\n") % (path))
				return
			parser = xml.sax.make_parser()
			handler = DecorationHandler()
			parser.setContentHandler(handler)
			parser.parse(path)
Exemple #6
0
def createBoat(player, deed, pos):
    boat = wolfpack.addmulti(str(deed.gettag('multisection')))
    if boat == None:
        player.socket.sysmessage(
            tr('This deed is broken. Failed to create boat'))

    boat.owner = player
    boat.settag('boat_anchored', 1)
    boat.settag('boat_facing', 0)  # boat is facing north
    boat.settag('deedid', deed.baseid)  # For DryDock
    boat.moveto(pos)
    boat.update()
    boat.decay = 0

    if deed.hastag('hasname'):
        boat.name = deed.name

    splank = None
    pplank = None

    # Create special items
    node = wolfpack.getdefinition(WPDT_MULTI, str(deed.gettag('multisection')))
    count = node.childcount
    for i in range(0, count):
        subnode = node.getchild(i)
        if subnode.name == 'ids':
            boat.settag('boat_id_north',
                        hex2dec(subnode.getattribute('north', '0')))
            boat.settag('boat_id_east',
                        hex2dec(subnode.getattribute('east', '0')))
            boat.settag('boat_id_south',
                        hex2dec(subnode.getattribute('south', '0')))
            boat.settag('boat_id_west',
                        hex2dec(subnode.getattribute('west', '0')))
        elif subnode.name == 'special_items':  # Found section
            subsubnode = subnode.findchild('tillerman')
            if subsubnode != None:
                tillerman = createBoatSpecialItem('3e4e', subsubnode, boat)
                boat.settag('boat_tillerman', tillerman.serial)
                if deed.hastag('hasname'):
                    tillerman.name = 'Tillerman of ' + boat.name
            subsubnode = subnode.findchild('hold')
            if subsubnode != None:
                hold = createBoatSpecialItem('3eae', subsubnode, boat)
            subsubnode = subnode.findchild('planks')
            if subsubnode != None:
                portclosed = subsubnode.findchild('port_closed')
                pplank = createBoatSpecialItem('3eb1', portclosed, boat)
                starclosed = subsubnode.findchild('star_closed')
                splank = createBoatSpecialItem('3eb2', starclosed, boat)
                splank.settag('plank_starboard', 1)

    if not deed.hastag('lock'):
        createKeys(splank, pplank, hold, boat, player)
    else:
        applyKeys(splank, pplank, hold, deed)
def createBoat( player, deed, pos ):
	boat = wolfpack.addmulti(str(deed.gettag('multisection')))
        if boat == None:
                player.socket.sysmessage(tr('This deed is broken. Failed to create boat'))

	boat.owner = player
	boat.settag( 'boat_anchored', 1 )
	boat.settag( 'boat_facing', 0 ) # boat is facing north
	boat.settag( 'deedid', deed.baseid ) # For DryDock
	boat.moveto(pos)
	boat.update()
	boat.decay = 0

	if deed.hastag('hasname'):
		boat.name = deed.name

	splank = None
	pplank = None

        # Create special items
        node = wolfpack.getdefinition(WPDT_MULTI, str(deed.gettag('multisection')) )
	count = node.childcount
	for i in range(0, count):
		subnode = node.getchild(i)
		if subnode.name == 'ids':
                    boat.settag('boat_id_north', hex2dec( subnode.getattribute( 'north', '0' ) ) )
                    boat.settag('boat_id_east', hex2dec( subnode.getattribute( 'east', '0' ) ) )                               
                    boat.settag('boat_id_south', hex2dec( subnode.getattribute( 'south', '0' ) ) )                               
                    boat.settag('boat_id_west', hex2dec( subnode.getattribute( 'west', '0' ) ) )                               
		elif subnode.name == 'special_items': # Found section
                        subsubnode = subnode.findchild('tillerman')
                        if subsubnode != None:
                                tillerman = createBoatSpecialItem( '3e4e', subsubnode, boat )
                                boat.settag('boat_tillerman', tillerman.serial)
				if deed.hastag('hasname'):
					tillerman.name = 'Tillerman of ' + boat.name
                        subsubnode = subnode.findchild('hold')
                        if subsubnode != None:
                                hold = createBoatSpecialItem( '3eae', subsubnode, boat )
                        subsubnode = subnode.findchild('planks')
                        if subsubnode != None:
                                portclosed = subsubnode.findchild('port_closed')
                                pplank = createBoatSpecialItem( '3eb1', portclosed, boat )
                                starclosed = subsubnode.findchild('star_closed')
                                splank = createBoatSpecialItem( '3eb2', starclosed, boat )
                                splank.settag('plank_starboard', 1)

	if not deed.hastag('lock'):
		createKeys( splank, pplank, hold, boat, player )
	else:
		applyKeys( splank, pplank, hold, deed )
Exemple #8
0
def addmulti(player, arguments, target):
	if target.item and target.item.container:
		player.socket.sysmessage("You can't add the multi there.")
		return

	multi = wolfpack.addmulti(str(arguments[0]))

	# If arguments[1] is true, make the item
	# static
	if arguments[1]:
		multi.decay = False
		multi.movable = 3

	multi.moveto(target.pos)
	multi.update()
Exemple #9
0
def addmulti(player, arguments, target):
    if target.item and target.item.container:
        player.socket.sysmessage(tr("You can't add the multi there."))
        return

    multi = wolfpack.addmulti(str(arguments[0]))

    # If arguments[1] is true, make the item
    # static
    if arguments[1]:
        multi.decay = False
        multi.movable = 3

    multi.moveto(target.pos)
    multi.update()

    player.log(LOG_MESSAGE, tr("Adds multi %s (0x%x) at %s.\n") % (str(arguments[0]), multi.serial, target.pos))
Exemple #10
0
def addmulti(player, arguments, target):
    if target.item and target.item.container:
        player.socket.sysmessage(tr("You can't add the multi there."))
        return

    multi = wolfpack.addmulti(str(arguments[0]))

    # If arguments[1] is true, make the item
    # static
    if arguments[1]:
        multi.decay = False
        multi.movable = 3

    multi.moveto(target.pos)
    multi.update()

    player.log(
        LOG_MESSAGE,
        tr("Adds multi %s (0x%x) at %s.\n") %
        (str(arguments[0]), multi.serial, target.pos))
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 )