Exemplo n.º 1
0
def cow(char, player, amount):
	# List with id of empty pitcher
	pitcher_list = [0x9a7, 0xff6, 0xff7]
	found = 0
	for pitcher in pitcher_list:
		foundn = player.countresource(pitcher)
		found += foundn
	if not found:
		player.socket.sysmessage(tr("You need something you can fill the milk in."))
		return False
	player.soundeffect(0x30)
	if found < amount:
		amount = found
	amount_down = amount
	for pitcher in pitcher_list:
		# consume as many pitchers as needed
		if amount_down > 0:
			if player.useresource(amount, pitcher):
				amount_down -= 1
		else:
			break
	# add as many pitchers as consumed (item.amount not possible, because not generic)
	for i in range(0, amount):
		milk = wolfpack.additem("9ad")
		if not wolfpack.utilities.tobackpack( milk, player ):
			milk.update()
	char.settag( "resourcecount", char.gettag("resourcecount") - amount)
	player.socket.sysmessage(tr("You melk the cow and fill the milk in an empty pitcher."))
	return
Exemplo n.º 2
0
def onWalk(char, dir, sequence):
	# Find the spiderweb
	items = wolfpack.items(char.pos.x, char.pos.y, char.pos.map, 0)

	spiderweb = None

	for item in items:
		if item.hasscript( 'spiderweb' ):
			spiderweb = item
			break

	if spiderweb:
		# Damage the web until it disappears
		spiderweb.health = max(0, spiderweb.health - ceil(char.strength / 2.0))

		if spiderweb.health == 0:
			spiderweb.delete()
		else:
			if char.socket:
				if random.random() <= 0.25:
					char.socket.sysmessage( tr('You damage the spiderweb.') )
				packet = wolfpack.packet(0x21, 8)
				packet.setbyte(1, sequence)
				packet.setshort(2, char.pos.x)
				packet.setshort(4, char.pos.y)
				packet.setbyte(6, char.direction)
				packet.setbyte(7, char.pos.z)
				packet.send(char.socket)
				char.socket.walksequence = 0
			return True

	char.removescript( 'spiderweb' )
	if char.socket:
		char.socket.sysmessage( tr('You manage to break free of the spiderweb.') )
	return False
Exemplo n.º 3
0
def onDamage(char, type, amount, source):	
	# 5% chance to talk
	if random.random() >= 0.05:
		return amount

	if char.health - amount > 0:	
		if amount < 5:
			sentence = random.choice([ tr("Ouch!"), tr("Me not hurt bad!"), tr("Thou fight bad."), tr("Thy blows soft!"), tr("You bad with weapon!") ])				
		else:
			sentence = random.choice([ tr("Ouch! Me hurt!"), tr("No, kill me not!"), tr("Me hurt!"), tr("Away with thee!"), tr("Oof! That hurt!"), tr("Aaah! That hurt..."), tr("Good blow!") ])
	else:
		sentence = random.choice([ tr("Revenge!"), tr("NOOooo!"), tr("I... I..."), tr("Me no die!"), tr("Me die!"), tr("Must... not die..."), tr("Oooh, me hurt..."), tr("Me dying?")])

	speech = char.getstrproperty('monsterspeech', '')
	global speechbuilders
	if not speech in speechbuilders:
		return amount
	speechbuilder = speechbuilders[speech]

	# Say english sentence after constructed one
	char.say( speechbuilder.buildsentence( random.randint(2, 3) ), speechbuilder.saycolor )
	char.soundeffect( speechbuilder.saysound )
	char.say( sentence, speechbuilder.saycolor )

	return amount
Exemplo n.º 4
0
def shrinktarget( char, args, target ):
	if not target.char:
		char.socket.sysmessage(tr('You can only shrink characters.'))
		return
	if target.char.player:
		char.socket.sysmessage(tr('You cannot shrink other players.'))
		return
		
	bodyinfo = wolfpack.bodyinfo(target.char.id)
		
	if bodyinfo['figurine'] <= 0 or bodyinfo['figurine'] >= 0x4000:
		char.socket.sysmessage(tr('You cannot shrink that.'))
		return
			
	target.char.sound(SND_IDLE)

	# Create a new figurine and make it newbie
	figurine = wolfpack.additem('%x' % bodyinfo['figurine'])
	figurine.newbie = True
	figurine.addscript('figurine')
	figurine.settag('pet', target.char.serial)
	figurine.color = target.char.skin
	figurine.name = target.char.name
	figurine.update()
	figurine.moveto(target.char.pos)
	figurine.update()

	target.char.removefromview()
	target.char.owner = None
	target.char.stablemaster = figurine.serial
	target.char.addscript('figurine') # This is a figurined NPC
Exemplo n.º 5
0
def attack_target(char, arguments, target):
    if not target.char or target.char == char:
        char.socket.sysmessage(tr("Your pets cannot attack that."))
        return

    (pet, all) = arguments
    if all:
        if char.gm:
            pos = char.pos
            pets = wolfpack.chars(pos.x, pos.y, pos.map, 18, False)
            for follower in pets:
                if follower.npc and not follower.frozen:
                    attack_target(char, [follower.serial, False], target)
        else:
            for follower in char.followers:
                attack_target(char, [follower.serial, False], target)
    else:
        pet = wolfpack.findchar(pet)
        if target.char == pet:
            char.socket.sysmessage(tr("Your pet refuses to kill itself."))
            return
        if pet and (pet.owner == char or char.gm) and pet.distanceto(char) < 18:
            startfight(pet, target.char)
            pet.fight(target.char)

            # right here we need to not interrupt the target, but i can't register a fight unless i do, right? not sure.
            target.char.fight(pet)
            target.char.follow(pet)

            go_target(char, arguments, target)
            follow_target(char, arguments, target)
            pet.sound(SND_ATTACK)
Exemplo n.º 6
0
def nuke(socket, command, argstring):
    argstring = argstring.strip()  # Remove trailing and leading whitespaces
    if len(argstring) > 0:
        if argstring.lower() == "all":
            gump = WarningGump(
                1060635, 30720,
                tr("Wiping <i>all</i> items in the world.<br>Do you wish to proceed?"
                   ), 0xFFC000, 420, 400, wipeAllWorld, [])
            gump.send(socket)
            return
        elif argstring.lower() == "map":
            gump = WarningGump(
                1060635, 30720,
                tr("Wiping <i>all</i> items in this map.<br>Do you wish to proceed?"
                   ), 0xFFC000, 420, 400, wipeMap, [])
            gump.send(socket)
            return
        else:
            if argstring.lower() == "nomulti":
                socket.sysmessage(
                    tr("You choose to nuke anything except items in multis"))
                baseid = argstring
            else:
                if argstring.lower() == "onlymulti":
                    socket.sysmessage(
                        tr("You choose to nuke just items in multis"))
                    baseid = argstring
                else:
                    baseid = argstring
    else:
        baseid = None

    socket.sysmessage(tr("Select the area to remove"))
    getBoundingBox(socket, wipeBoundingBox, baseid)
    return True
Exemplo n.º 7
0
def removescript_response( player, arguments, target ):
	script = arguments[0]
	object = None

	if target.item:
		object = target.item
	elif target.char:
		if target.char.rank > player.rank and player != target.char:
			player.socket.sysmessage( tr("You've burnt your fingers!") )
			return False

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

	if object.hasscript( str( script ) ):
		player.log( LOG_MESSAGE, tr("Removes script '%s' from object 0x%x.\n" % ( script, object.serial )) )
		object.removescript( str( script ) )
		object.resendtooltip()
		player.socket.sysmessage( tr('You remove the script from your target.') )
		return True
	else:
		player.socket.sysmessage( tr('Your target does not have the given script.') )
		return False
Exemplo n.º 8
0
def onContextEntry(char, target, tag):
	if tag == 1:
		if char.dead:
			target.say(500895) # That sounded spooky.
			return True

		if char.iscriminal():
			target.say(500378) # Thou art a criminal and cannot access thy bank box.
			return True

		bank = char.getbankbox()
		target.turnto(char)
		# Check for invisible GMs
		if not char.invisible:
			target.say(tr("Here is your bank box, %s.") % char.name)
		char.socket.sendcontainer(bank)

	elif tag == 2:
		target.turnto(char)
		bank = char.getbankbox()
		amount = bank.countresource(0xEED, 0x0)
		# Check for invisible GMs
		if not char.invisible:
			if not amount:
				target.say(tr("Alas you don't have any money in your bank."))
			else:
				target.say(tr("You have %i gold in your bank.") % amount)
		else:
			if not amount:
				char.socket.sysmessage(tr("Alas you don't have any money in your bank."))
			else:
				char.socket.sysmessage(tr("You have %i gold in your bank.") % amount)


	return True
Exemplo n.º 9
0
def response(player, arguments, target):
    if not target.char or not target.char.player:
        player.socket.sysmessage(tr('You have to target a player character.'))
        return

    if target.char.rank >= player.rank:
        player.socket.sysmessage(tr('You burn your fingers.'))
        return

    target.char.squelched = arguments[0]

    if arguments[0]:
        player.log(
            LOG_MESSAGE, 'Muted player %s (0x%x).\n' %
            (target.char.orgname, target.char.serial))
        player.socket.sysmessage(
            tr('The targetted player can no longer talk.'))
    else:
        player.log(
            LOG_MESSAGE, 'Unmuted player %s (0x%x).\n' %
            (target.char.orgname, target.char.serial))
        player.socket.sysmessage(
            tr('The targetted player can now talk again.'))
        target.char.message(500006)
    return
Exemplo n.º 10
0
def cow(char, player, amount):
    # List with id of empty pitcher
    pitcher_list = [0x9A7, 0xFF6, 0xFF7]
    found = 0
    for pitcher in pitcher_list:
        foundn = player.countresource(pitcher)
        found += foundn
    if not found:
        player.socket.sysmessage(tr("You need something you can fill the milk in."))
        return False
    player.soundeffect(0x30)
    if found < amount:
        amount = found
    amount_down = amount
    for pitcher in pitcher_list:
        # consume as many pitchers as needed
        if amount_down > 0:
            if player.useresource(amount, pitcher):
                amount_down -= 1
        else:
            break
            # add as many pitchers as consumed (item.amount not possible, because not generic)
    for i in range(0, amount):
        milk = wolfpack.additem("9ad")
        if not wolfpack.utilities.tobackpack(milk, player):
            milk.update()
    char.settag("resourcecount", char.gettag("resourcecount") - amount)
    player.socket.sysmessage(tr("You melk the cow and fill the milk in an empty pitcher."))
    return
Exemplo n.º 11
0
def pressbutton( player, partner, box1, box2 ):
	#Switch buttons on trade gump
	button1 = player.gettag( 'trade_button' )
	button2 = partner.gettag( 'trade_button' )
	sendtradepacket( player.socket, 2, box1.serial, button1, button2, "" )
	sendtradepacket( partner.socket, 2, box2.serial, button2, button1, "" )

	#To far away for trading ?
	if player.distanceto( partner ) > 3:
		player.socket.clilocmessage( 500295 ) # You are too far away to do that.
		partner.socket.clilocmessage( 500295 ) # You are too far away to do that.
		closetrade( player, partner, box1, box2 )
		return True

	if button1 == 1 and button2 == 1:
		back1 = player.getbackpack()
		back2 = partner.getbackpack()

		for item in box1.content:
			# Player is giving this item to partner
			player.log(LOG_TRACE, tr("Trading item 0x%x ('%s', %u) to player '%s' (0x%x, %s)\n") % (item.serial, item.baseid, item.amount, partner.orgname, partner.serial, partner.account.name))
			if not tocontainer( item, back2 ):
				item.update()

		for item in box2.content:
			# Partner is giving this item to partner
			partner.log(LOG_TRACE, tr("Trading item 0x%x ('%s', %u) to player '%s' (0x%x, %s)\n") % (item.serial, item.baseid, item.amount, player.orgname, player.serial, player.account.name))
			if not tocontainer( item, back1 ):
				item.update()

		closetrade( player, partner, box1, box2 )

	return True
Exemplo n.º 12
0
def nuke( socket, command, argstring ):
	argstring = argstring.strip() # Remove trailing and leading whitespaces
	if len( argstring ) > 0:
		if argstring.lower() == "all":
			gump = WarningGump( 1060635, 30720, tr("Wiping <i>all</i> items in the world.<br>Do you wish to proceed?"), 0xFFC000, 420, 400, wipeAllWorld, [] )
			gump.send( socket )
			return
		elif argstring.lower() == "map":
			gump = WarningGump( 1060635, 30720, tr("Wiping <i>all</i> items in this map.<br>Do you wish to proceed?"), 0xFFC000, 420, 400, wipeMap, [] )
			gump.send( socket )
			return
		else:
			if argstring.lower() == "nomulti":
				socket.sysmessage(tr("You choose to nuke anything except items in multis"))
				baseid = argstring
			else:
				if argstring.lower() == "onlymulti":
					socket.sysmessage(tr("You choose to nuke just items in multis"))
					baseid = argstring
				else:
					baseid = argstring
	else:
		baseid = None

	socket.sysmessage(tr("Select the area to remove"))
	getBoundingBox( socket, wipeBoundingBox, baseid )
	return True
Exemplo n.º 13
0
def findlock(socket, command, arguments):
	if len(arguments) == 0:
		socket.sysmessage( tr('Usage: findlock <lock>') )
		return

	lock = arguments.strip().lower()
	items = wolfpack.itemiterator()
	item = items.first

	while item:
		if item.hasscript( "lock" ):
			if item.hastag( "lock" ) and item.gettag( "lock" ).lower() == lock:
				container = item.getoutmostitem()

				if container.container:
					container = container.container

				socket.sysmessage( tr("Going to item '%s' [Serial: 0x%x; Top: 0x%x]." % (item.getname(), item.serial, container.serial)) )
				pos = container.pos
				socket.player.removefromview()
				socket.player.moveto(pos)
				socket.player.update()
				socket.resendworld()

				if item.container:
					socket.sendobject(item.container)
					if item.container.isitem():
						socket.sendcontainer(item.container)
				return True

		item = items.next

	socket.sysmessage( "A matching lock with the id '%s' was not found." % lock )
Exemplo n.º 14
0
def decoration( socket, command, arguments ):
	if len(arguments) > 0:
		args = str(arguments)
		if args == 'save':
			saveObject = DecorationSaveHandler(socket)
			socket.sysmessage(tr("Sorting items, please wait..."))
			saveObject.sort()
			socket.sysmessage(tr("Writting file..."))
			saveObject.save()
			return
		
	parser = xml.sax.make_parser()
	handler = DecorationHandler()
	parser.setContentHandler(handler)
	maps = []
	try:
		maponly = int(arguments)
		maps.append(maponly)
	except ValueError:
                maps = [0, 1, 2, 3]
		pass

	for map in maps:
            if wolfpack.hasmap(map):
                socket.sysmessage(tr("Decorating map %i, please wait...") % map)
                parser.parse("definitions/decoration/decoration.%i.xml" % map)
Exemplo n.º 15
0
def onWorldSave():
    if ENABLEDFANCYSTATUS:
        # Creating Dialog
        dialog = cGump(nomove=1, nodispose=1, x=150, y=150)

        dialog.setType(
            0x98FA2C10
        )  # NEVER change this Type or Gump will not be closed in the end of save

        dialog.addResizeGump(0, 0, 9200, 291, 90)
        dialog.addCheckerTrans(0, 0, 291, 90)
        dialog.addText(47, 19, tr("WORLDSAVE IN PROGRESS"), 2122)
        dialog.addText(47, 37,
                       tr("Saving %i items.") % (wolfpack.itemcount()), 2100)
        dialog.addText(47, 55,
                       tr("Saving %i characters.") % (wolfpack.charcount()),
                       2100)
        dialog.addTilePic(3, 25, 4167)

        # Sending to players

        worldsocket = wolfpack.sockets.first()
        while worldsocket:
            dialog.send(worldsocket)
            worldsocket = wolfpack.sockets.next()
Exemplo n.º 16
0
def sextant_parts( char, item ):
	if not char.checkskill( TINKERING, 0, 500 ):
		if random.randint( 1, 100 ) <= 25:
			additional = tr(" and break the parts.")

			if item.amount > 1:
				item.amount -= 1
				item.update()
			else:
				item.delete()
		else:
			additional = "."

		char.message( "%s%s" % ( tr("You fail to create the sextant"), additional ) )
	else:
		if item.amount > 1:
			item.amount -= 1
			item.update()
		else:
			item.delete()

		if item.id == 0x1059:
			item = wolfpack.additem( '1057' )
		else:
			item = wolfpack.additem( '1058' )

		char.getbackpack().additem( item, 1, 1, 0 )
		item.update()
		char.message( tr("You put the sextant into your backpack") )

	return 1
Exemplo n.º 17
0
def onUse( char, item ):
	# We only can rename marked runes
	if item.gettag( 'marked' ) != 1:
		char.socket.sysmessage( tr("This rune is not marked.") )
		return True

	# We are only handling runes
	if not isrune( item ):
		return 0

	# It needs to be on our body
	if item.getoutmostchar() != char:
		char.socket.sysmessage( tr("The rune needs to be in your posession to rename it.") )
		return True

	gump = cGump( 0, 0, 0, 50, 50 )
	# Header
	gump.addBackground( 0x24a4, 300, 200 )
	gump.addTilePic( 80, 33, 0x1F14 )
	gump.addHtmlGump( 10, 30, 300, 20, tr('<basefont size="7" color="#336699"><center>Rename rune</center></basefont>') )

	# Rename Field
	gump.addHtmlGump( 40, 60, 300, 20, tr('How do you like to name the rune?') )
	gump.addResizeGump( 40, 80, 0x2486, 206, 26 )
	gump.addInputField( 43, 83, 200, 20, 0x539, 1, item.name )

	gump.addButton( 43, 125, 2128, 2129, 1000 ) # Ok
	gump.addButton( 110, 125, 2119, 2120, 0 ) # Cancel

	gump.setCallback( rename_callback )
	gump.setArgs( [ item ] )
	gump.send( char )

	return True
Exemplo n.º 18
0
def attack_target(char, arguments, target):
    if not target.char or target.char == char:
        char.socket.sysmessage(tr('Your pets cannot attack that.'))
        return

    (pet, all) = arguments
    if all:
        if char.gm:
            pos = char.pos
            pets = wolfpack.chars(pos.x, pos.y, pos.map, 18, False)
            for follower in pets:
                if follower.npc and not follower.frozen:
                    attack_target(char, [follower.serial, False], target)
        else:
            for follower in char.followers:
                attack_target(char, [follower.serial, False], target)
    else:
        pet = wolfpack.findchar(pet)
        if target.char == pet:
            char.socket.sysmessage(tr('Your pet refuses to kill itself.'))
            return
        if pet and (pet.owner == char
                    or char.gm) and pet.distanceto(char) < 18:
            startfight(pet, target.char)
            pet.fight(target.char)

            # right here we need to not interrupt the target, but i can't register a fight unless i do, right? not sure.
            target.char.fight(pet)
            target.char.follow(pet)

            go_target(char, arguments, target)
            follow_target(char, arguments, target)
            pet.sound(SND_ATTACK)
Exemplo n.º 19
0
	def add(self, page, notify = True):
		updated = False
		if page in self.pages:
			updated = True
			self.pages.remove(page)
		self.pages.append(page)
		self.save()

		if notify:
			char = wolfpack.findchar(page.serial)
			if char:
				if updated:
					char.log(LOG_MESSAGE, tr("%s (%s) updates his gm page [%s]:\n%s\n") % (char.name, page.account, page.category, page.getmessage()))					
				else:					
					char.log(LOG_MESSAGE, tr("%s (%s) makes a gm page [%s]:\n%s\n") % (char.name, page.account, page.category, page.getmessage()))
		
			notification = page.notification(updated)
			socket = wolfpack.sockets.first()
			while socket:
				player = socket.player
				
				# If the pagenotify flag is on and it is a staff account,
				# send a notification about the new or updated page.
				if player and player.rank > 1 and player.account.flags & 0x10 != 0:				
					# Send the notification to the socket
					socket.sysmessage(notification, 0x846)
					
					for line in page.message:
						if len(line) > 0:
							socket.sysmessage(line, 0x843)

				socket = wolfpack.sockets.next()
Exemplo n.º 20
0
def follow(char, pet, all=False):
    if all:
        char.socket.sysmessage(tr('Who do you want your pets to follow?'))
    else:
        char.socket.sysmessage(tr('Who do you want your pet to follow?'))

    char.socket.attachtarget("speech.pets.follow_target", [pet.serial, all])
Exemplo n.º 21
0
def showWhoGump(player, page):
	current_page = page

	# Collect the current list of sockets first
	wholist = []

	worldsocket = wolfpack.sockets.first()
	while worldsocket:
		char = worldsocket.player
		if char.invisible and char.rank > player.rank:
			worldsocket = wolfpack.sockets.next()
			continue
		if not char.account:
			wolfpack.sockets.next()
			continue	
		wholist.append(char)
		worldsocket = wolfpack.sockets.next()
		
	count = len(wholist)
		
	# Skip page * 10 users
	newwholist = wholist[page * 10:]

	while len(newwholist) == 0 and page > 0:
		page -= 1
		newwholist = wholist[page * 10:]

	wholist = newwholist
	
	# Player list increases by 22 pixels
	pages = (count + 9) / 10 # 10 per page
		
	gump = cGump( 0, 0, 0, 50, 50 )
	gump.addBackground( 0xE10, 380, 360 )
	gump.addCheckerTrans( 15, 15, 350, 330 );
	gump.addGump( 130, 18, 0xFA8 )
	gump.addText( 165, 20, tr("Who Menu"), 0x530 )
	gump.addButton( 30, 320, 0xFB1, 0xFB3, 0 ) 	# Close Button
	gump.addText( 70, 320, tr("Close"), 0x834 )
	gump.addText( 145, 320, tr("Players: %u") % count, 0x834 )

	gump.addText( 280, 320, tr( "Page %i of %i" % ( page + 1, pages ) ), 0x834 )

	if page + 1 < pages:
		gump.addButton( 260, 320, 0x0FA, 0x0FA, 1 ) # Next Page
		
	if page > 0:
		gump.addButton( 240, 320, 0x0FC, 0x0FC, 2 ) # Previous Page
		
	offset = 22
	wholist = wholist[:10]
	for char in wholist:
		gump.addButton( 20, 40 + offset, 0xFA5, 0xFA7, 2 + char.serial )
		gump.addText( 54, 40 + offset, tr("%s [%s]") % ( char.name, char.account.name ), 0x834 )
		gump.addText( 257, 40 + offset, unicode(char.socket.address), 0x834 )
		offset += 24
	
	gump.setArgs( [ current_page ] )
	gump.setCallback( "commands.who.callbackWho" )
	gump.send( player.socket )
Exemplo n.º 22
0
def shrinktarget(char, args, target):
    if not target.char:
        char.socket.sysmessage(tr('You can only shrink characters.'))
        return
    if target.char.player:
        char.socket.sysmessage(tr('You cannot shrink other players.'))
        return

    bodyinfo = wolfpack.bodyinfo(target.char.id)

    if bodyinfo['figurine'] <= 0 or bodyinfo['figurine'] >= 0x4000:
        char.socket.sysmessage(tr('You cannot shrink that.'))
        return

    target.char.sound(SND_IDLE)

    # Create a new figurine and make it newbie
    figurine = wolfpack.additem('%x' % bodyinfo['figurine'])
    figurine.newbie = True
    figurine.addscript('figurine')
    figurine.settag('pet', target.char.serial)
    figurine.color = target.char.skin
    figurine.name = target.char.name
    figurine.update()
    figurine.moveto(target.char.pos)
    figurine.update()

    target.char.removefromview()
    target.char.owner = None
    target.char.stablemaster = figurine.serial
    target.char.addscript('figurine')  # This is a figurined NPC
Exemplo n.º 23
0
def follow(char, pet, all=False):
    if all:
        char.socket.sysmessage(tr("Who do you want your pets to follow?"))
    else:
        char.socket.sysmessage(tr("Who do you want your pet to follow?"))

    char.socket.attachtarget("speech.pets.follow_target", [pet.serial, all])
Exemplo n.º 24
0
def gump_response(char, args, response):
	if len(args) < 1 or response.button != 1:
		return

	key = wolfpack.finditem(args[0])

	if not char.canreach(key, 5):
		char.socket.clilocmessage(501661)
		return

	# Rename
	new_name = response.text[1][:30] # 30 Chars max.
	key.name = new_name
	char.socket.sysmessage(tr("You renamed the key to '%s'") % new_name)

	# Rekey
	if char.gm:
		new_lock = response.text[2]
		old_lock = ''
		if key.hastag('lock'):
			old_lock = str(key.gettag('lock'))

		if old_lock != new_lock:
			char.log(LOG_TRACE, tr("Changing lock of key 0x%x from '%s' to '%s'.\n") % (key.serial, old_lock, new_lock))
			if len(new_lock) != 0:
				key.settag('lock', new_lock)
				char.socket.sysmessage(tr('This key now unlocks: ') + new_lock)								
			else:
				key.deltag('lock')
				char.socket.sysmessage(tr('You erase the lock information from the key.'))

	key.resendtooltip()
Exemplo n.º 25
0
def onUse(char, item):
    # If we've already learned all we can > cancel.
    if (char.skill[STEALING] >= 600):
        char.message(
            501830
        )  # Your ability to steal cannot improve any further by simply practicing on a dummy.
        return True

    # Either the dummy is swinging or we aren't assigned to a dummy
    if (item.id != 0x1ec0 and item.id != 0x1ec3):
        return True

    # Distance & Direction checks
    if (char.distanceto(item) > 1):
        char.message(
            tr('You must be standing in front of or behind the dummy to use it.'
               ))
        return True

    # Calculates the direction we'll have to look
    # to focus the dummy
    direction = char.directionto(item)

    # We only have E/W facing Pickpocket dips
    if (direction != 2 and direction != 6):
        char.message(
            tr('You must be standing in front of or behind the dummy to use it.'
               ))
        return True

    # Turn to the correct direction if not already
    if (char.direction != direction):
        char.direction = direction
        char.update()

    # Only swing the dip if the check failed
    if (char.checkskill(STEALING, 0, 1000)):
        char.message(tr("You succeed in your try to pickpocket the dip."))
        return True

    if (item.id == 0x1ec0):
        item.id = 0x1ec1
    elif (item.id == 0x1ec3):
        item.id = 0x1ec4

    # Resend the item to surrounding clients after
    # changing the id and play the soundeffect
    # originating from the dummy
    item.update()
    item.soundeffect(0x41)

    # Display the char-action
    # (combat swing 1handed)
    char.action(0x09)

    # Add a timer to reset the id
    item.addtimer(3000, resetid, [item.serial])

    return True
Exemplo n.º 26
0
def response(char, args, target):
    if not char:
        return False

    if skills.skilltable[ITEMID][skills.UNHIDE] and char.hidden:
        char.reveal()

    socket = char.socket
    socket.settag('skill_delay',
                  int(wolfpack.time.currenttime() + ITEMID_DELAY))

    # Identify an item and send the buy and sellprice.
    if target.item:
        item = target.item
        if not item.getoutmostchar() == char:
            top = item.getoutmostitem()
            if top.container and top.container.ischar():
                top = top.container
            if not char.canreach(top, 4):
                socket.clilocmessage(0x7A27F, "", 0x3b2, 3)
                return False

        if not char.checkskill(ITEMID, 0, 1000):
            socket.clilocmessage(500353)
            return

        # Identify the item
        if target.item.hastag('unidentified'):
            socket.sysmessage(
                tr('You are able to identify the use of this item!'))
            target.item.deltag('unidentified')
            target.item.resendtooltip()

        # Display the buyprice
        if target.item.buyprice != 0:
            socket.sysmessage(
                tr("You could probably buy this for %u gold.") %
                target.item.buyprice)
        else:
            socket.sysmessage(
                tr("You don't think that anyone would sell this."))

        # Display the sellprice
        if target.item.sellprice != 0:
            socket.sysmessage(
                tr("You could probably sell this for %u gold.") %
                target.item.sellprice)
        else:
            socket.sysmessage(tr("You don't think anyone would buy this."))

    elif target.char:
        if not char.canreach(target.char, 4):
            socket.clilocmessage(500344)
            return

        target.char.showname(socket)

    else:
        socket.clilocmessage(500353)
Exemplo n.º 27
0
def checkpay(char, vendor, count):
	if char.countresource( 0xeed, 0 ) < count:
		vendor.say( tr("You don't have enough gold!"), 5 )
		return False
	char.useresource( count, 0xeed, 0 )
	char.soundeffect( 0x37, 0 )
	vendor.say( tr("That is %i gold.") % count, 5 )
	return True
Exemplo n.º 28
0
	def type(self):
		if self.category == tr('BUG'):
			return 0
		elif self.category == tr('STUCK'):
			return 1
		elif self.category == tr('GAMEPLAY'):
			return 2
		else:
			return 3
Exemplo n.º 29
0
	def __init__(self, parent):
		CraftItemAction.__init__(self, parent, tr('Runebook'), 0x22c5, '22c5')
		self.markable = True
		self.runes = 8
		
		# Add the other requirements
		self.materials.append([['1f60'], 1, tr('Gate Travel Scrolls')])
		self.materials.append([['1f4c'], 1, tr('Recall Scrolls')])
		self.skills[INSCRIPTION] = [450, 1250, 250]
Exemplo n.º 30
0
    def getmaterialshtml(self, player, arguments):
        materialshtml = CraftItemAction.getmaterialshtml(self, player, arguments)

        if self.water:
            materialshtml += tr("Water: 1<br>")
        if self.flour:
            materialshtml += tr("Flour: %i<br>" % self.flouramount)

        return materialshtml
Exemplo n.º 31
0
 def type(self):
     if self.category == tr('BUG'):
         return 0
     elif self.category == tr('STUCK'):
         return 1
     elif self.category == tr('GAMEPLAY'):
         return 2
     else:
         return 3
Exemplo n.º 32
0
def potion(char, potion, manatype):
    socket = char.socket
    if not canUsePotion(char, potion):
        return False

    if char.mana >= char.maxmana:
        socket.sysmessage(tr('You are already at full mana.'))
        if char.mana > char.maxmana:
            char.mana = char.maxmana
            char.updatemana()
        return False

    # Compare
    if socket.hastag('mana_pot_timer'):
        elapsed = int(socket.gettag('mana_pot_timer'))
        if elapsed > time.time():
            # Broken Timer
            if time.time() - elapsed > MANA_POT_DELAY:
                socket.deltag('mana_pot_timer')
            else:
                socket.sysmessage(
                    tr('You must wait a few seconds before using another mana potion.'
                       ))
                return False

    socket.settag('mana_pot_timer', time.time() + MANA_POT_DELAY)
    amount = 0

    # Lesser Mana
    if manatype == 22:
        amount = randint(POTION_LESSERMANA_RANGE[0],
                         POTION_LESSERMANA_RANGE[1])
    # Mana
    elif manatype == 23:
        amount = randint(POTION_MANA_RANGE[0], POTION_MANA_RANGE[1])
    # Greater Mana
    elif manatype == 24:
        amount = randint(POTION_GREATERMANA_RANGE[0],
                         POTION_GREATERMANA_RANGE[1])

    # Apply Enhancepotions Bonus
    enhancepotions = properties.fromchar(char, ENHANCEPOTIONS)
    if enhancepotions > 0:
        amount += (enhancepotions * amount) / 100

    char.mana = min(char.mana + amount,
                    char.maxmana)  # We don't add mana over our maximum mana

    # Resend Mana
    char.updatemana()

    char.action(ANIM_FIDGET3)
    char.soundeffect(SOUND_DRINK1)
    consumePotion(char, potion, POTIONS[manatype][POT_RETURN_BOTTLE])

    return True
Exemplo n.º 33
0
def sendmap(player, item, maptype):
    if maptype == 'preset' and item.hastag('preset'):
        preset = item.gettag('preset')
        if not preset in MAP_PRESETS:
            player.socket.sysmessage(tr('Unknown map preset: %s.') % preset)
            return
        (width, height, xtop, ytop, xbottom, ybottom) = MAP_PRESETS[preset]
    elif maptype == 'world':
        (width, height, xtop, ytop, xbottom, ybottom) = (400, 400, 0, 0, 5119,
                                                         4095)
    elif maptype == 'custom':
        (width, height, xtop, ytop, xbottom, ybottom) = (200, 200, 0, 0, 5119,
                                                         4095)
        if item.hastag('width'):
            width = int(item.gettag('width'))
        if item.hastag('height'):
            height = int(item.gettag('height'))
        if item.hastag('xtop'):
            xtop = int(item.gettag('xtop'))
        if item.hastag('xbottom'):
            xbottom = int(item.gettag('xbottom'))
        if item.hastag('ytop'):
            ytop = int(item.gettag('ytop'))
        if item.hastag('ybottom'):
            ybottom = int(item.gettag('ybottom'))
    else:
        player.socket.sysmessage(tr('Unknown map type: %s.') % maptype)
        return

    # Send a map detail packet
    details = wolfpack.packet(0x90, 19)
    details.setint(1, item.serial)
    details.setshort(5, 0x139d)
    details.setshort(7, xtop)  # Upper Left X
    details.setshort(9, ytop)  # Upper Left Y
    details.setshort(11, xbottom)  # Lower Right X
    details.setshort(13, ybottom)  # Lower Right Y
    details.setshort(15, width)  # Gump Width
    details.setshort(17, height)  # Gump Height
    details.send(player.socket)

    # Remove all pins
    sendmapcommand(player.socket, item, 5)

    # Send all pins anew
    pins = []
    if item.hastag('pins'):
        pins = item.gettag('pins').strip().split(';')

    for pin in pins:
        (x, y) = pin.split(',')
        sendmapcommand(player.socket, item, 1, x=int(x), y=int(y))

    protected = item.hastag('protected')
    editable = item.hastag('editable')
    sendmapcommand(player.socket, item, 7, not protected and editable)
Exemplo n.º 34
0
def onShowTooltip(viewer, object, tooltip):
    marked = 0
    if object.hastag('marked'):
        marked = int(object.gettag('marked'))
    tooltip.reset()

    if marked:
        tooltip.add(1042971, tr("a recall rune for %s") % object.name)
    else:
        tooltip.add(1042971, tr("an unmarked recall rune"))
Exemplo n.º 35
0
    def getmaterialshtml(self, player, arguments):
        materialshtml = CraftItemAction.getmaterialshtml(
            self, player, arguments)

        if self.water:
            materialshtml += tr("Water: 1<br>")
        if self.flour:
            materialshtml += tr("Flour: %i<br>" % self.flouramount)

        return materialshtml
Exemplo n.º 36
0
def follow(socket, command, arguments):
	socket.player.dispel(None, True, 'FOLLOW_TIMER')
	if socket.hastag('follow_target'):
		message = tr('Stopped following 0x%x.') % socket.gettag('follow_target')
		socket.sysmessage(message)
		socket.log(LOG_MESSAGE, message + "\n")
		socket.deltag('follow_target')
	socket.sysmessage(tr('Choose a new character to follow.'))
	socket.attachtarget('commands.follow.target', [])
	return
Exemplo n.º 37
0
def poison_command(socket, command, arguments):
	try:
		level = int(arguments)
		if level < 0 or level > 4:
			socket.sysmessage(tr('Allowed levels: 0 to 4.'))
		else:
			socket.sysmessage(tr('Select the character you want to poison.'))
			socket.attachtarget("system.poison.poison_target", [level])
	except:
		socket.sysmessage(tr('Usage: poison <level>'))
Exemplo n.º 38
0
def poison_command(socket, command, arguments):
    try:
        level = int(arguments)
        if level < 0 or level > 4:
            socket.sysmessage(tr('Allowed levels: 0 to 4.'))
        else:
            socket.sysmessage(tr('Select the character you want to poison.'))
            socket.attachtarget("system.poison.poison_target", [level])
    except:
        socket.sysmessage(tr('Usage: poison <level>'))
Exemplo n.º 39
0
def onShowTooltip(viewer, object, tooltip):
	marked = 0
	if object.hastag('marked'):
		marked = int(object.gettag('marked'))
	tooltip.reset()

	if marked:
		tooltip.add(1042971, tr("a recall rune for %s") % object.name)
	else:
		tooltip.add(1042971, tr("an unmarked recall rune"))
Exemplo n.º 40
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.º 41
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.º 42
0
def onLogin( player ):
	socket = player.socket
	socket.sysmessage( tr("Welcome to %s") % ( wolfpack.serverversion() )  )
	socket.sysmessage( tr("Report Bugs: http://bugs.wpdev.org/") )
	player.hidden = False

	# send to jail if account is jailed
	if player.account.flags & 0x80:
		if not player.jailed:
			jailPlayer( player, player )
	return False
Exemplo n.º 43
0
	def notification(self, updated = False):
		char = wolfpack.findchar(self.serial)
		if not char:
			return None
				
		if not updated:
			result = tr("New %s page from '%s' on account '%s':") % (self.category, char.name, self.account)
		else:
			result = tr("Updated %s page from '%s' on account '%s':") % (self.category, char.name, self.account)

		return result
Exemplo n.º 44
0
def response(player, arguments, target):
    if not target.char or not target.char.player:
        player.socket.sysmessage(tr('You have to target a player character.'))
        return

    if target.char.rank >= player.rank:
        player.socket.sysmessage(tr('You burn your fingers.'))
        return

    jailPlayer(player, target.char, arguments[0])
    return
Exemplo n.º 45
0
def sendmap(player, item, maptype):
    if maptype == "preset" and item.hastag("preset"):
        preset = item.gettag("preset")
        if not preset in MAP_PRESETS:
            player.socket.sysmessage(tr("Unknown map preset: %s.") % preset)
            return
        (width, height, xtop, ytop, xbottom, ybottom) = MAP_PRESETS[preset]
    elif maptype == "world":
        (width, height, xtop, ytop, xbottom, ybottom) = (400, 400, 0, 0, 5119, 4095)
    elif maptype == "custom":
        (width, height, xtop, ytop, xbottom, ybottom) = (200, 200, 0, 0, 5119, 4095)
        if item.hastag("width"):
            width = int(item.gettag("width"))
        if item.hastag("height"):
            height = int(item.gettag("height"))
        if item.hastag("xtop"):
            xtop = int(item.gettag("xtop"))
        if item.hastag("xbottom"):
            xbottom = int(item.gettag("xbottom"))
        if item.hastag("ytop"):
            ytop = int(item.gettag("ytop"))
        if item.hastag("ybottom"):
            ybottom = int(item.gettag("ybottom"))
    else:
        player.socket.sysmessage(tr("Unknown map type: %s.") % maptype)
        return

        # Send a map detail packet
    details = wolfpack.packet(0x90, 19)
    details.setint(1, item.serial)
    details.setshort(5, 0x139D)
    details.setshort(7, xtop)  # Upper Left X
    details.setshort(9, ytop)  # Upper Left Y
    details.setshort(11, xbottom)  # Lower Right X
    details.setshort(13, ybottom)  # Lower Right Y
    details.setshort(15, width)  # Gump Width
    details.setshort(17, height)  # Gump Height
    details.send(player.socket)

    # Remove all pins
    sendmapcommand(player.socket, item, 5)

    # Send all pins anew
    pins = []
    if item.hastag("pins"):
        pins = item.gettag("pins").strip().split(";")

    for pin in pins:
        (x, y) = pin.split(",")
        sendmapcommand(player.socket, item, 1, x=int(x), y=int(y))

    protected = item.hastag("protected")
    editable = item.hastag("editable")
    sendmapcommand(player.socket, item, 7, not protected and editable)
Exemplo n.º 46
0
	def onItemsSold(self, vendor, player, count = 0, totalgold = 0, tobank = False):
		text = None
		
		if count > 0 and totalgold > 0:
			if tobank:
				text = tr('I bought %u items from you. I sent a check for %u gold to your bank account.' % (count, totalgold))
			else:
				text = tr('I bought %u items from you. Here are your %u gold.' % (count, totalgold))
		
		if text:
			player.socket.showspeech(vendor, text, vendor.saycolor)
Exemplo n.º 47
0
def response(player, arguments, target):
	if not target.char or not target.char.player:
		player.socket.sysmessage(tr('You have to target a player character.'))
		return

	if target.char.rank >= player.rank:
		player.socket.sysmessage(tr('You burn your fingers.'))
		return

	jailPlayer(player, target.char, arguments[0])
	return
Exemplo n.º 48
0
def doLinkDoors(char, args, target):
	if not target.item or not target.item.hasscript("door"):
		char.socket.sysmessage(tr("That's not a door!"))
		return True
	if not args[0]:
		char.socket.sysmessage(tr("Now the second door."))
		char.socket.attachtarget("door.doLinkDoors", [target.item])
		return True
	else:
		args[0].settag("link",target.item.serial)
		target.item.settag("link",args[0].serial)
		char.socket.sysmessage(tr("Doors linked successfully."))
Exemplo n.º 49
0
def tileResponse(player, arguments, target):
    if len(arguments) < 3:
        player.socket.sysmessage(tr('Please select the second corner.'))
        player.socket.attachtarget("commands.tile.tileResponse",
                                   list(arguments) + [target.pos])
        return

    x1 = min(arguments[2].x, target.pos.x)
    x2 = max(arguments[2].x, target.pos.x)
    y1 = min(arguments[2].y, target.pos.y)
    y2 = max(arguments[2].y, target.pos.y)
    z = arguments[0]
    ids = arguments[1]

    unlimited = player.account.authorized('Misc', 'Unlimited Tile')
    count = ((x2 - x1) + 1) * ((y2 - y1) + 1)

    # Cap at 500 items if not an admin is using it
    if not unlimited and count > 250:
        player.socket.sysmessage(
            tr('You are not allowed to tile more than 250 items at once.'))
        return

    pos = player.pos
    pos.z = z

    count = 0
    for x in range(x1, x2 + 1):
        for y in range(y1, y2 + 1):
            pos.x = x
            pos.y = y
            id = random.choice(ids)
            item = wolfpack.additem(id)
            # if there's no item created, remove the id from the list and restart the loop
            if not item:
                player.socket.sysmessage(
                    tr("No Item definition by the name '%s' found.") % id)
                ids.remove(id)
                continue
            item.moveto(pos)
            item.decay = 0
            item.movable = 2  # Not Movable
            item.update()
            count += 1

    player.log(
        LOG_MESSAGE, "Tiling %u items (%s) from %u,%u to %u,%u at z=%d.\n" %
        (count, ", ".join(ids), x1, y1, x2, y2, z))
    player.socket.sysmessage('Creating %u items from %u,%u to %u,%u at z=%d.' %
                             (count, x1, y1, x2, y2, z))

    return
Exemplo n.º 50
0
def doUnlinkDoors(char, args, target):
	if not target.item or not target.item.hasscript("door"):
		char.socket.sysmessage(tr("That's not a door!"))
		return True

	otherItem = wolfpack.finditem(target.item.gettag("link"))
	if not otherItem:
		char.socket.sysmessage( tr("This door seems not to be linked.") )
		return True

	if otherItem.hastag("link"):
		otherItem.deltag("link")
	target.item.deltag("link")
Exemplo n.º 51
0
def onUse(char, item):
    # Out of reach?
    if not char.canreach(item, 2):
        char.socket.clilocmessage(500295)
        return True

    char.turnto(item)
    number1 = randrange(1, 7)
    number2 = randrange(1, 7)

    char.emote(
        tr("rolls a ") + unicode(number1) + tr(" and a ") + unicode(number2))
    return True