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)
def parseMulti( file, pos ):
	warnings = ''
	count = 0
	for line in file:
		# Replace \r and \n's
		line = line.replace( "\r", "" )
		line = line.replace( "\n", "" )


		if len(line.split(' ')) != 5:
			continue

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

		if not int(show):
			continue

		id = hex2dec( id )
		x = int( x )
		y = int( y )
		z = int( z )
		newitem = wolfpack.newitem(1) # Generate a new serial for us

		newitem.decay = 0
		newitem.id = id

		newitem.moveto( pos.x + x, pos.y + y, pos.z + z, pos.map, 1 )
		newitem.update()
		count += 1

	return ( count, warnings )
	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)
Beispiel #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)

        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)
    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)
	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)
Beispiel #7
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)
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.newitem(1)
                item.decay = 0
                item.movable = 2
                item.id = itemid
                item.color = color
                item.moveto(x, y, z, map)
                item.update()
                count += 1

            itemid = -1
            props = {}

    return (count, warnings)
	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)
Beispiel #10
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)
def bulletinboard(socket, packet):
	char = socket.player

	try:
		subcommand = packet.getbyte(3)
		board = wolfpack.finditem(packet.getint(4))

		if not board or not char.canreach(board, 3):
			char.socket.clilocmessage(1019045)
			return True

		# Post a new message
		if subcommand == 5:
			replyto = packet.getint(8)
			subjectlen = packet.getbyte(12)
			subject = ""
			for i in range(0, subjectlen):
				byte = packet.getbyte(13+i)
				if byte != 0:
					subject += chr(byte)
			subject = subject.decode('utf-8')

			lines = []
			offset = 13 + subjectlen

			numlines = packet.getbyte(offset)
			offset += 1

			for i in range(0,numlines):
				linelen = packet.getbyte(offset)
				offset += 1

				line = ""
				for i in range(0, linelen):
					byte = packet.getbyte(offset+i)
					if byte != 0:
						line += chr(byte)
				lines.append(line.decode('utf-8'))
				offset += linelen

			if replyto != 0:
				replyto = wolfpack.finditem(replyto)

				if replyto and replyto.getoutmostitem() != board:
					replyto = board
			else:
				replyto = board

			if len(subject) > 0 and len(lines) > 0:
				message = wolfpack.newitem(1)
				message.id = 0xeb0 # Deed
				message.container = replyto

				# Set all necessary tags
				message.settag('poster_name', char.name)
				message.settag('poster_serial', char.serial)
				message.settag('poster_hue', char.skin)
				message.settag('poster_body', char.id)

				# Store Equipment
				equipmentcount = 0

				for i in range(1, LAYER_NPCRESTOCK):
					item = char.itemonlayer(i)
					if item:
						message.settag('equipment%uid' % equipmentcount, item.id)
						message.settag('equipment%uhue' % equipmentcount, item.color)
						equipmentcount += 1

				message.settag('equipmentcount', equipmentcount)

				message.settag('time', time.time())
				message.settag('subject', subject)
				message.settag('lines', len(lines))
				for i in range(0, len(lines)):
					message.settag('line%u' % i, lines[i])

				message.update()

		# Request the whole message
		elif subcommand == 3:
			message = wolfpack.finditem(packet.getint(8))
			if message and message.getoutmostitem() == board:
				subject = ''
				subjectlen = len(subject)+1
				poster = ''
				posterlen = len(poster)+1
				timestr = ''
				timestrlen = len(timestr)+1
				lineslen = 1 # Byte value of how many lines are there = 1 byte
				lines = []

				if message.hastag('subject'):
					subject = message.gettag('subject')
					subjectlen = len(subject.encode('utf-8')) + 1

				if message.hastag('poster_name'):
					poster = message.gettag('poster_name')
					posterlen = len(poster.encode('utf-8')) + 1

				if message.hastag('time'):
					message_time = int(message.gettag('time'))
					current_time = time.time()

					# Calculate the difference and print out in days + minutes
					diff = current_time - message_time
					if diff < 0:
						diff = 0

					days = 0

					if diff >= 86400:
						days = floor(diff/86400)
						diff %= 86400

					hours = floor(diff / 1440)
					minutes = floor(diff % 1440 / 60)

					if (days != 0):
						timestr = tr('%u Days %02u:%02u') % (days, hours, minutes)
					else:
						timestr = '%02u:%02u' % (hours, minutes)

					timestrlen = 2 + len(timestr.encode('utf-8'))

				if message.hastag('lines'):
					linecount = int(message.gettag('lines'))

					for i in range(0, linecount):
						if message.hastag('line%u' % i):
							line = message.gettag('line%u' % i)
							lines.append(line)
							lineslen += 2 + len(line.encode('utf-8'))

				equipment = []

				if message.hastag('equipmentcount'):
					equipmentcount = int(message.gettag('equipmentcount'))

					for i in range(0,equipmentcount):
						id = int(message.gettag('equipment%uid'%i))
						hue = int(message.gettag('equipment%uhue'%i))
						equipment.append([id, hue])

				packet_len = 15 + posterlen + subjectlen + timestrlen
				# Whole Message mode
				packet_len += lineslen + 5 + len(equipment) * 4

				packet = wolfpack.packet(0x71, packet_len)
				packet.setshort(1, packet_len)
				packet.setbyte(3, 2) # Whole message
				packet.setint(4, board.serial)
				packet.setint(8, message.serial)
				packet.setbyte(12, posterlen)
				packet.setascii(13, poster.encode('utf-8'))
				packet.setbyte(13 + posterlen, subjectlen)
				packet.setascii(14 + posterlen, subject.encode('utf-8'))
				packet.setbyte(14 + posterlen + subjectlen, timestrlen)
				packet.setascii(15 + posterlen + subjectlen, timestr)

				# Skip 5 byte (character data???)
				offset = 15 + posterlen + subjectlen + timestrlen

				packet.setshort(offset, 0x191) # Poster Body
				packet.setshort(offset + 2, 0x840a) # Poster Hue
				packet.setbyte(offset + 4, len(equipment)) # Count of Equipment (Short Id, Short Hue)
				offset += 5

				for data in equipment:
					packet.setshort(offset, data[0])
					packet.setshort(offset+2, data[1])
					offset += 4

				packet.setbyte(offset, len(lines))
				offset += 1

				for line in lines:
					linelen = len(line.encode('utf-8')) + 1

					packet.setbyte(offset, linelen)
					packet.setascii(offset + 1, line.encode('utf-8'))
					offset += linelen + 1
				packet.send(char.socket)

			else:
				char.socket.sysmessage( tr("You can't read this message.") )

		# Request message summary
		elif subcommand == 4:
			message = wolfpack.finditem(packet.getint(8))

			if message and message.getoutmostitem() == board:
				subject = ''
				subjectlen = len(subject)+1
				poster = ''
				posterlen = len(poster)+1
				timestr = tr('Unknown')
				timestrlen = len(timestr)+1

				if message.hastag('subject'):
					subject = message.gettag('subject')
					subjectlen = len(subject.encode('utf-8')) + 1

				if message.hastag('poster_name'):
					poster = message.gettag('poster_name')
					posterlen = len(poster.encode('utf-8')) + 1

				if message.hastag('time'):
					message_time = int(message.gettag('time'))
					current_time = time.time()

					# Calculate the difference and print out in days + minutes
					diff = current_time - message_time
					if diff < 0:
						diff = 0

					days = 0

					if diff >= 86400:
						days = floor(diff/86400)
						diff %= 86400

					hours = floor(diff / 1440)
					minutes = floor(diff % 1440 / 60)

					if days == 1:
						timestr = tr('%u day %02u:%02u') % (days, hours, minutes)
					elif days > 1:
						timestr = tr('%u days %02u:%02u') % (days, hours, minutes)
					else:
						timestr = '%02u:%02u' % (hours, minutes)

					timestrlen = 1 + len(timestr.encode('utf-8'))

				packet_len = 19 + posterlen + subjectlen + timestrlen

				packet = wolfpack.packet(0x71, packet_len)
				packet.setshort(1, packet_len)
				packet.setbyte(3, 1) # Message summary
				packet.setint(4, board.serial)
				packet.setint(8, message.serial)

				if message.container != board:
					packet.setint(12, message.container.serial) # parent

				packet.setbyte(16, posterlen)
				packet.setascii(17, poster.encode('utf-8'))
				packet.setbyte(17 + posterlen, subjectlen)
				packet.setascii(18 + posterlen, subject.encode('utf-8'))
				packet.setbyte(18 + posterlen + subjectlen, timestrlen)
				packet.setascii(19 + posterlen + subjectlen, timestr)
				packet.send(char.socket)

			else:
				socket.sysmessage( tr("You can't read this message.") )

	except:
		socket.sysmessage( tr('Invalid bulletin board packet.') )
		raise

	return True
Beispiel #12
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)
	def target(self, char, mode, targettype, target, args, item):
		char.turnto(target)

		# We can only recall from recall runes
		if not target.hasscript( 'magic.rune' ):
			char.message(502357)
			return

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

		if not target.hastag('marked') or target.gettag('marked') != 1:
			char.message(502354)
			fizzle(char)
			return

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

		if region.nogate:
			char.message(501802)
			fizzle(char)
			return

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

		region = wolfpack.region(location.x, location.y, location.map)

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

		if region.nogate:
			char.message(1019004)
			fizzle(char)
			return

		if char.socket:
			char.socket.clilocmessage(501024)

		serials = []

		# Create the two gates
		gate = wolfpack.newitem(1)
		gate.id = 0xf6c
		gate.moveto(char.pos)
		gate.settag('dispellable_field', 1)
		gate.addscript( 'magic.gate' )
		gate.settag('target', target.gettag('location'))
		gate.direction = 9
		gate.update()
		gate.soundeffect(0x20e)
		serials.append(gate.serial)

		gate = wolfpack.newitem(1)
		gate.id = 0xf6c
		gate.moveto(location)
		gate.settag('target', '%u,%u,%d,%u' % (char.pos.x, char.pos.y, char.pos.z, char.pos.map))
		gate.settag('dispellable_field', 1)
		gate.addscript( 'magic.gate' )
		gate.direction = 9
		gate.update()
		gate.soundeffect(0x20e)
		serials.append(gate.serial)

		wolfpack.addtimer(30000, "magic.utilities.field_expire", serials, 1)
Beispiel #14
0
def bulletinboard(socket, packet):
    char = socket.player

    try:
        subcommand = packet.getbyte(3)
        board = wolfpack.finditem(packet.getint(4))

        if not board or not char.canreach(board, 3):
            char.socket.clilocmessage(1019045)
            return True

        # Post a new message
        if subcommand == 5:
            replyto = packet.getint(8)
            subjectlen = packet.getbyte(12)
            subject = ""
            for i in range(0, subjectlen):
                byte = packet.getbyte(13 + i)
                if byte != 0:
                    subject += chr(byte)
            subject = subject.decode('utf-8')

            lines = []
            offset = 13 + subjectlen

            numlines = packet.getbyte(offset)
            offset += 1

            for i in range(0, numlines):
                linelen = packet.getbyte(offset)
                offset += 1

                line = ""
                for i in range(0, linelen):
                    byte = packet.getbyte(offset + i)
                    if byte != 0:
                        line += chr(byte)
                lines.append(line.decode('utf-8'))
                offset += linelen

            if replyto != 0:
                replyto = wolfpack.finditem(replyto)

                if replyto and replyto.getoutmostitem() != board:
                    replyto = board
            else:
                replyto = board

            if len(subject) > 0 and len(lines) > 0:
                message = wolfpack.newitem(1)
                message.id = 0xeb0  # Deed
                message.container = replyto

                # Set all necessary tags
                message.settag('poster_name', char.name)
                message.settag('poster_serial', char.serial)
                message.settag('poster_hue', char.skin)
                message.settag('poster_body', char.id)

                # Store Equipment
                equipmentcount = 0

                for i in range(1, LAYER_NPCRESTOCK):
                    item = char.itemonlayer(i)
                    if item:
                        message.settag('equipment%uid' % equipmentcount,
                                       item.id)
                        message.settag('equipment%uhue' % equipmentcount,
                                       item.color)
                        equipmentcount += 1

                message.settag('equipmentcount', equipmentcount)

                message.settag('time', time.time())
                message.settag('subject', subject)
                message.settag('lines', len(lines))
                for i in range(0, len(lines)):
                    message.settag('line%u' % i, lines[i])

                message.update()

        # Request the whole message
        elif subcommand == 3:
            message = wolfpack.finditem(packet.getint(8))
            if message and message.getoutmostitem() == board:
                subject = ''
                subjectlen = len(subject) + 1
                poster = ''
                posterlen = len(poster) + 1
                timestr = ''
                timestrlen = len(timestr) + 1
                lineslen = 1  # Byte value of how many lines are there = 1 byte
                lines = []

                if message.hastag('subject'):
                    subject = message.gettag('subject')
                    subjectlen = len(subject.encode('utf-8')) + 1

                if message.hastag('poster_name'):
                    poster = message.gettag('poster_name')
                    posterlen = len(poster.encode('utf-8')) + 1

                if message.hastag('time'):
                    message_time = int(message.gettag('time'))
                    current_time = time.time()

                    # Calculate the difference and print out in days + minutes
                    diff = current_time - message_time
                    if diff < 0:
                        diff = 0

                    days = 0

                    if diff >= 86400:
                        days = floor(diff / 86400)
                        diff %= 86400

                    hours = floor(diff / 1440)
                    minutes = floor(diff % 1440 / 60)

                    if (days != 0):
                        timestr = tr('%u Days %02u:%02u') % (days, hours,
                                                             minutes)
                    else:
                        timestr = '%02u:%02u' % (hours, minutes)

                    timestrlen = 2 + len(timestr.encode('utf-8'))

                if message.hastag('lines'):
                    linecount = int(message.gettag('lines'))

                    for i in range(0, linecount):
                        if message.hastag('line%u' % i):
                            line = message.gettag('line%u' % i)
                            lines.append(line)
                            lineslen += 2 + len(line.encode('utf-8'))

                equipment = []

                if message.hastag('equipmentcount'):
                    equipmentcount = int(message.gettag('equipmentcount'))

                    for i in range(0, equipmentcount):
                        id = int(message.gettag('equipment%uid' % i))
                        hue = int(message.gettag('equipment%uhue' % i))
                        equipment.append([id, hue])

                packet_len = 15 + posterlen + subjectlen + timestrlen
                # Whole Message mode
                packet_len += lineslen + 5 + len(equipment) * 4

                packet = wolfpack.packet(0x71, packet_len)
                packet.setshort(1, packet_len)
                packet.setbyte(3, 2)  # Whole message
                packet.setint(4, board.serial)
                packet.setint(8, message.serial)
                packet.setbyte(12, posterlen)
                packet.setascii(13, poster.encode('utf-8'))
                packet.setbyte(13 + posterlen, subjectlen)
                packet.setascii(14 + posterlen, subject.encode('utf-8'))
                packet.setbyte(14 + posterlen + subjectlen, timestrlen)
                packet.setascii(15 + posterlen + subjectlen, timestr)

                # Skip 5 byte (character data???)
                offset = 15 + posterlen + subjectlen + timestrlen

                packet.setshort(offset, 0x191)  # Poster Body
                packet.setshort(offset + 2, 0x840a)  # Poster Hue
                packet.setbyte(
                    offset + 4,
                    len(equipment))  # Count of Equipment (Short Id, Short Hue)
                offset += 5

                for data in equipment:
                    packet.setshort(offset, data[0])
                    packet.setshort(offset + 2, data[1])
                    offset += 4

                packet.setbyte(offset, len(lines))
                offset += 1

                for line in lines:
                    linelen = len(line.encode('utf-8')) + 1

                    packet.setbyte(offset, linelen)
                    packet.setascii(offset + 1, line.encode('utf-8'))
                    offset += linelen + 1
                packet.send(char.socket)

            else:
                char.socket.sysmessage(tr("You can't read this message."))

        # Request message summary
        elif subcommand == 4:
            message = wolfpack.finditem(packet.getint(8))

            if message and message.getoutmostitem() == board:
                subject = ''
                subjectlen = len(subject) + 1
                poster = ''
                posterlen = len(poster) + 1
                timestr = tr('Unknown')
                timestrlen = len(timestr) + 1

                if message.hastag('subject'):
                    subject = message.gettag('subject')
                    subjectlen = len(subject.encode('utf-8')) + 1

                if message.hastag('poster_name'):
                    poster = message.gettag('poster_name')
                    posterlen = len(poster.encode('utf-8')) + 1

                if message.hastag('time'):
                    message_time = int(message.gettag('time'))
                    current_time = time.time()

                    # Calculate the difference and print out in days + minutes
                    diff = current_time - message_time
                    if diff < 0:
                        diff = 0

                    days = 0

                    if diff >= 86400:
                        days = floor(diff / 86400)
                        diff %= 86400

                    hours = floor(diff / 1440)
                    minutes = floor(diff % 1440 / 60)

                    if days == 1:
                        timestr = tr('%u day %02u:%02u') % (days, hours,
                                                            minutes)
                    elif days > 1:
                        timestr = tr('%u days %02u:%02u') % (days, hours,
                                                             minutes)
                    else:
                        timestr = '%02u:%02u' % (hours, minutes)

                    timestrlen = 1 + len(timestr.encode('utf-8'))

                packet_len = 19 + posterlen + subjectlen + timestrlen

                packet = wolfpack.packet(0x71, packet_len)
                packet.setshort(1, packet_len)
                packet.setbyte(3, 1)  # Message summary
                packet.setint(4, board.serial)
                packet.setint(8, message.serial)

                if message.container != board:
                    packet.setint(12, message.container.serial)  # parent

                packet.setbyte(16, posterlen)
                packet.setascii(17, poster.encode('utf-8'))
                packet.setbyte(17 + posterlen, subjectlen)
                packet.setascii(18 + posterlen, subject.encode('utf-8'))
                packet.setbyte(18 + posterlen + subjectlen, timestrlen)
                packet.setascii(19 + posterlen + subjectlen, timestr)
                packet.send(char.socket)

            else:
                socket.sysmessage(tr("You can't read this message."))

    except:
        socket.sysmessage(tr('Invalid bulletin board packet.'))
        raise

    return True