def poisonit( char, args ):
	potion = wolfpack.finditem(args[ 0 ])
	item = wolfpack.finditem(args[ 1 ])
	if not potion or not item:
		return

	skill = char.skill[ POISONING ]

	# poison strength : lesser(0), normal, greater, deadly(3)
	strength = int( potion.getintproperty( 'potiontype' ) ) - 14

	# consume the potion / add a blank bottle
	potions.consumePotion(char, potion, True)

	if not char.checkskill( POISONING, MINSKILLS[strength], MAXSKILLS[strength] ):
		char.socket.clilocmessage( 1010518 )
		return 1

	char.socket.clilocmessage(1010517)

	# decrease karma / fame

	# set poisoning infos as tags
	item.settag( 'poisoning_char', char.serial )
	item.settag( 'poisoning_strength', strength )
	item.settag( 'poisoning_skill', skill )
	# weapon : poison chance when hit % = char.skill[ POISONING ] / 4
	# 	number of uses before the poison wears off
	if item.hasscript( 'blades' ):
		item.settag( 'poisoning_uses', 18 - strength * 2 )
	return 1
def chainpotiontimer( cserial, iserial, bserial, outradius ):
	char = wolfpack.findchar( cserial )
	item = wolfpack.finditem( iserial )
	bomb = wolfpack.finditem( bserial )

	if not item or not bomb:
		return False

	if bomb.hastag( 'exploding' ):
		return False

	# Doing error checks first, makes it faster
	if not checkLoS( item, bomb, outradius ):
		return False

	potiontype = getPotionType( bomb )

	if not potiontype in [11, 12, 13]:
		return False

	bomb.settag( 'exploding', cserial )

	if isPotionkeg( bomb ) and int( bomb.gettag( 'kegfill' ) ) >= 1:
		bomb.addtimer( randint( 1000, 2250 ), "potions.explosion.potioncountdown", [ char.serial, 10, int( bomb.gettag( 'kegfill' ) ) ] )
	else:
		bomb.addtimer( randint( 1000, 2250 ), "potions.explosion.potioncountdown", [ char.serial, 0, bomb.amount ] )
	return True
def create_leaves(serial, fruittype="apple"):
    object = wolfpack.finditem(serial)
    # Lets figure out what kind of leaves we need
    if object.id == 0xD94:
        leaves = wolfpack.additem("d95")
    elif object.id == 0xD98:
        leaves = wolfpack.additem("d99")

    if leaves:
        object.settag("leaf_serial", leaves.serial)
        leaves = None
        leaves = wolfpack.finditem(object.gettag("leaf_serial"))
        leaves.pos = "%i,%i,%i,%i" % (object.pos.x, object.pos.y, object.pos.z, object.pos.map)
        if leaves.pos != object.pos:
            leaves.moveto(object.pos)
            # leaves.visible = 0
        object.update()
        # 2 - 15 minutes
        leaves.addtimer(int(60000 * random.randint(2, 15)), leaves_progress, [])
        leaves.update()
        leaves.settag("fruit_count", 0)
        leaves.settag("fruit_type", str(fruittype))
        leaves.settag("stage", 0)
        return True
    else:
        object.update()
        return False
Example #4
0
def response( char, args, target ):

	direction = char.directionto( target.pos )
	if not char.direction == direction:
		char.direction = direction
		char.update()
	item = wolfpack.finditem( args[0] )

	if ( ( char.pos.x-target.pos.x )**2 + ( char.pos.y-target.pos.y )**2 > 4):
		char.socket.clilocmessage( 502648, '', GRAY) # You are too far away to do that.
		return True

	if abs( char.pos.z - target.pos.z ) > 5:
		char.socket.clilocmessage( 502648, '', GRAY) # You are too far away to do that.
		return True

	# Check target (only item targets valid)
	if not target.item:
		char.socket.clilocmessage( 502658, '', GRAY ) # Use that on a spinning wheel.
		return True

	if target.item.id in ids:
		color = item.color
		if ( item.amount > 1 ):
			item.amount = item.amount -1
			item.update()
		else:
			item.delete()

		# Spinning Wheel Animations
		if target.item.id == ids[0]:
			target.item.id = animids[0]
			target.item.update()
		elif target.item.id == ids[1]:
			target.item.id = animids[1]
			target.item.update()
		elif target.item.id == ids[2]:
			target.item.id = animids[2]
			target.item.update()
		elif target.item.id == ids[3]:
			target.item.id = animids[3]
			target.item.update()

		wheel = wolfpack.finditem( target.item.serial )
		processtime = 5000 # 5 Seconds
		char.addtimer( processtime, ProcessTimer, [wheel.serial, color] )

	elif target.item.id in animids:
		# That spinning wheel is being used.
		char.socket.clilocmessage( 502656, '', GRAY )
		return True

	else:
		# Use that on a spinning wheel.
		char.socket.clilocmessage( 502658, '', GRAY )
		return True
	def smelt(self, player, arguments, target):
		if not self.checktool(player, wolfpack.finditem(arguments[0])):
			return False

		tool = wolfpack.finditem(arguments[0])
		if tool == target.item:
			player.socket.clilocmessage(1044271)
			return

		# Smelt a weapon
		item = target.item
		weapon = itemcheck(item, ITEM_WEAPON)
		shield = itemcheck(item, ITEM_SHIELD)
		armor = itemcheck(item, ITEM_ARMOR)

		# See if it's in our ore list.
		if weapon or shield or armor:
			if item.container != player.getbackpack():
				player.socket.clilocmessage(1044274)
				return

			if item.hastag('resname'):
				resname = str(item.gettag('resname'))
			else:
				resname = None

			for metal in METALS:
				if metal[5] == resname:
					# Try to find out how many ingots this item would need
					action = self.topmostmenu().findcraftitem(item.baseid)
					returned = 0.25 + min(1000, player.skill[MINING]) / 2000

					if action and action.submaterial1 > 0:
						amount = int(math.floor(action.submaterial1 * returned))
					else:
						amount = 1

					if amount > 0:
						# Randomly select one of the resources required by that metal
						item.delete()
						ingots = wolfpack.additem(random.choice(metal[3]))
						ingots.amount = amount
						if not tobackpack(ingots, player):
							ingots.update()

						player.soundeffect(0x2a)
						player.soundeffect(0x240)

						player.socket.clilocmessage(1044270)
						self.send(player, arguments)
						return

		player.socket.clilocmessage(1044272)
		self.send(player, arguments)
def selecttarget( char, args, target ):
	# you cannot use skill while dead
	if char.dead:
		char.socket.clilocmessage( 502796 )
		return

	potion = wolfpack.finditem(args[ 0 ])
	if not potion:
		return

	if not target.item:
		char.socket.clilocmessage( 502145 )
		return

	global ALLOWED
	if not target.item.id in ALLOWED and not target.item.hasscript('food') and not target.item.hasscript('beverage'):
		char.socket.clilocmessage(1060204)
		return

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

	# sound / effect
	char.soundeffect( 0x4F )
	# apply poison to the item
	char.addtimer( POISONING_DELAY, poisonit, [ potion.serial, target.item.serial ] )
	return 1
Example #7
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()
def response(player, arguments, response):
	if response.button == 0:
		return

	item = wolfpack.finditem(arguments[0])
	if not item:
		return

	# Validate parameters
	if not 0 in response.switches and not 1 in response.switches:
		player.socket.sysmessage('You have to choose a spawntype.')
		return

	spawntype = response.switches[0]

	try:
		definition = response.text[0]
		area = int(response.text[1])
		mininterval = int(response.text[2])
		maxinterval = int(response.text[3])
	except:
		player.socket.sysmessage('You entered an invalid value.')
		return

	item.settag('spawntype', spawntype)
	item.settag('spawndef', definition)
	item.settag('area', area)
	item.settag('mininterval', mininterval)
	item.settag('maxinterval', maxinterval)

	item.resendtooltip()
  def applyproperties(self, player, arguments, item, exceptional):
    # Use all available resources if the item we make is
    # flagged as "stackable".
    if self.stackable:
      backpack = player.getbackpack()
      count = -1
      for (materials, amount, name) in self.materials:
        items = backpack.countitems(materials)
        if count == -1:
          count = items / amount
        else:
          count = min(count, items / amount)
      for (materials, amount, name) in self.materials:
        backpack.removeitems( materials, count )
      if count != -1:
        item.amount += count
      else:
        item.amount = 1 + count
      item.update()


    # Distribute another 6 points randomly between the resistances an armor alread
    # has. There are no tailored weapons.
    if exceptional:
      pass

    # Reduce the uses remain count
    checktool(player, wolfpack.finditem(arguments[0]), 1)
Example #10
0
def response(player, arguments, response):
	if response.button == 0:
		return

	command = (response.button >> 28) & 0xC
	item = wolfpack.finditem((response.button & 0x3FFFFFFF) | 0x40000000)
	target = item.container
	
	# Delete Item
	if command == 0x04:
		player.log(LOG_MESSAGE, 'Deleting item 0x%x from character 0x%x.\n' % (item.serial, item.container.serial))
		item.delete()
		
		showEditGump(player, target)

	# Bounce Item
	elif command == 0x08:
		player.log(LOG_MESSAGE, 'Bouncing item 0x%x from character 0x%x.\n' % (item.serial, item.container.serial))
		
		if not tobackpack(item, player):			
			item.update()
			
		showEditGump(player, target)

	# Show Info For Item
	elif command == 0x0C:
		player.log(LOG_MESSAGE, 'Showing info gump for item 0x%x from character 0x%x.\n' % (item.serial, item.container.serial))
		iteminfo(player.socket, item)

	else:
		player.socket.sysmessage('Unknown command.')
def response(char, args, target):
    kit = wolfpack.finditem(args[0])
    if not kit:
        return False
    if not char.canreach(target.pos, 3):
        char.socket.clilocmessage(500295)  # You are too far away to do that.
        return False
    if not target.item and not target.item.corpse and not baseid == "big_fish":
        char.socket.clilocmessage(1042600)  # That is not a corpse!
    elif target.item.corpse and VisitedByTaxidermist(target.item):
        char.socket.clilocmessage(1042596)  # That corpse seems to have been visited by a taxidermist already.
    else:
        if target.item.baseid == "big_fish":
            createTrophyDeed(char, "big_fish", target.item)
            target.item.delete()
            kit.delete()

        elif getname(target.item.bodyid) in corpses.keys():
            corpse = corpses[getname(target.item.bodyid)]
            if not wolfpack.utilities.checkresources(char.getbackpack(), "1bdd", 10):

                createTrophyDeed(char, getname(target.item.bodyid), target.item)

                target.item.settag("VisitedByTaxidermist", 0)
                kit.delete()
            else:
                char.socket.clilocmessage(1042598)  # You do not have enough boards.
        else:
            char.socket.clilocmessage(1042599)  # That does not look like something you want hanging on a wall.
        return
def target(player, arguments, target):
	dyetub = wolfpack.finditem(arguments[0])

	if not dyetub or not player.canreach(dyetub, 1):
		player.socket.clilocmessage(500446)
		return
		
	if not target.item:
		player.socket.clilocmessage(1042418) # You can only dye leather with this tub.
		return

	if target.item.getoutmostchar() != player:
		player.socket.clilocmessage(500446) # Too far away
		return
		
	if target.item.container == player:
		player.socket.clilocmessage(500861) # Can't Dye clothing that is being worn.
		return
		
	global ARMORLIST
	if not properties.itemcheck(target.item, ITEM_ARMOR) or target.item.baseid not in ARMORLIST:
		player.socket.clilocmessage(1042418) # Can only dye leaether
		return	
	
	target.item.color = dyetub.color
	target.item.update()
	player.log( LOG_MESSAGE, "Dying item (%x,%x) using tub (%x,%x)\n" % ( target.item.serial, target.item.color, dyetub.serial, dyetub.color ) )
	player.soundeffect(0x23e)
def pickHueCallback(player, arguments, response):
	dyetub = wolfpack.finditem(arguments[0])
	
	if not player.canreach(dyetub, 1):
		player.socket.clilocmessage(500446) # You can't reach that
		return
		
	if response.button == 1:
		if len(response.switches) == 0:
			return
			
		switch = response.switches[0]
		
		(i, j) = (switch / 15, switch % 15)

		if i >= len(HUES) or j + 1 >= len(HUES[i]):
			return
			
		dyetub.color = HUES[i][j + 1] # Special Hue
		dyetub.update()
		player.soundeffect(0x023e)

	elif response.button == 2:
		dyetub.color = 0 # Default Hue
		dyetub.update()
		player.soundeffect(0x023e)
	def make(self, player, arguments, nodelay=0):
		assert(len(arguments) > 0, 'Arguments has to contain a tool reference.')

		if not checktool(player, wolfpack.finditem(arguments[0])):
			return False

		return CraftItemAction.make(self, player, arguments, nodelay)
Example #15
0
def responseHandler(socket, packet):
	if packet.size < 16:
		return True
	
	item = wolfpack.finditem(packet.getint(3))
	
	if not item:
		socket.sysmessage(tr('Unexpected input response.'))
		return True # Item went out of scope
					
	if packet.getint(11) != 1:
		args = (socket.player, item, packet.getint(7))
		callEvent(item, 'onTextInputCancel', args)
		return True # Cancelled

	# Last byte has to be nullbyte
	if packet.getbyte(packet.size - 1) != 0:
		socket.log(LOG_ERROR, "Received invalid input response packet. String is not null terminated.")
		return True
		
	text = packet.getascii(15, packet.size - 15)
	
	# Build argument string for onTextInput event
	args = (socket.player, item, packet.getint(7), text)
	callEvent(item, 'onTextInput', args)

	return True
def provocation( char, skill ):
	socket = char.socket

	if not char.socket:
		return False
	# Only handle provocation
	if skill != PROVOCATION:
		return False

	if not socket.hastag( 'instrument' ):
		socket.clilocmessage( 0x7A74E, '', 0x3b2, 3 ) # What instrument shall I play music on?
		socket.attachtarget( "skills.provocation.findinstrument" )
		return True

	instserial = socket.gettag( 'instrument' )
	instrument = wolfpack.finditem( instserial )
	backpack = char.getbackpack()

	if not instrument or not instrument.getoutmostitem() == backpack:
		socket.clilocmessage( 0x7A74E, "", 0x3b2, 3 ) # What instrument shall I play music on?
		socket.attachtarget( "skills.provocation.findinstrument" )
		return True

	socket.clilocmessage( 0x7A74D, "", 0x3b2, 3 ) # What do you wish to incite?
	socket.attachtarget( "skills.provocation.response1", [instrument] )
	return True
Example #17
0
def response( char, args, target ):
	# 2440: Scissors can not be used on that to produce anything
	# 2437: The item you wish to cut must be in your backpack

	item = wolfpack.finditem( args[0] )

	if not item:
		char.socket.clilocmessage( 500312, '', GRAY ) # You cannot reach that.
		return

	if not ( item.getoutmostchar() == char):
		char.socket.clilocmessage( 500312, '', GRAY ) # You cannot reach that.
		return

	# Check target (only item targets valid)
	if not target.item:
		char.socket.clilocmessage( 502440, "", GRAY ) # Scissors can not be used on that to produce anything
		return

	if not target.item.getoutmostchar() == char:
		char.socket.clilocmessage( 502440 ) # Scissors cannot be used on that to produce anything.
		return

	if not cutItem(char, target.item):
		char.socket.clilocmessage( 502440, "", GRAY ) # Scissors can not be used on that to produce anything
Example #18
0
def lock_response(char, args, target):
  if len(args) != 1:
    return

  key = wolfpack.finditem(args[0])
  if not key or not char.canreach(key,5):
    char.socket.clilocmessage(501661)
    return

  # Check for an item target.
  if not target.item or not char.canreach(target.item,5):
    char.socket.clilocmessage(501666)
    return

  if target.item == key:
    rename_key(char,key)

  elif target.item.hasscript( 'lock' ):
    if target.item.hastag('locked') and int(target.item.gettag('locked')) == 1:
      target.item.deltag('locked')
    else:
      target.item.settag('locked',1)
    char.soundeffect(0x241)

  else:
    char.socket.clilocmessage(501666)

  return
def response_receiver( char, args, target ):
	item = wolfpack.finditem( args[0] )
	if not item:
		return False
	if not item.getoutmostchar() == char and not char.canreach( target.pos, 2 ):
		char.socket.clilocmessage( 1019045 ) # I can't reach that.
		return False

	if target.item and target.item.serial == item.serial:
		if active(item):
			deactivate( item )
			char.socket.clilocmessage( 500672 ) # You turn the crystal off.
		else:
			activate_receiver( item )
			char.socket.clilocmessage( 500673 ) # You turn the crystal on.

	elif target.char:
		if item.hastag( "sender" ):
			deltags_sender( item )
			item.deltag( "sender" )
			char.socket.clilocmessage( 1010044 ) # You unlink the receiver crystal.
		else:
			char.socket.clilocmessage( 1010045 ) # That receiver crystal is not linked.

	else:
		if getname(target.item.baseid) in recharges.keys():
			char.socket.clilocmessage( 500677 ) # This crystal cannot be recharged.
			return True
		char.socket.clilocmessage( 1010045 ) # That receiver crystal is not linked.
	return True
def deltags_receiver( item ):
	for i in item.tags:
		if i.startswith( "receiver_" ):
			item.deltag(i)
			receiver = wolfpack.finditem( int(i.split("_")[1]) )
			receiver.deltag( "sender" )
	return
def dyingtub_response( char, args, target ):
	dyetub = wolfpack.finditem( args[0] )

	if not dyetub or not char.canreach( dyetub, 2 ):
		char.message( localemsg( 6 ) )
		return

	if not target.item:
		char.message( localemsg( 8 ) )
		return

	# Valid Target?
	if not char.gm:
		if target.item.getoutmostchar() != char:
			char.socket.sysmessage( localemsg( 10 ) )
			return

		if not target.item.dye:
			char.socket.sysmessage( localemsg( 11 ) )
			return

	char.log( LOG_MESSAGE, "Dying item (%x,%x) using tub (%x,%x)\n" % ( target.item.serial, target.item.color, dyetub.serial, dyetub.color ) )
	target.item.color = dyetub.color
	target.item.update()
	char.soundeffect(0x023e)
Example #22
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('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()
Example #23
0
def target(player, arguments, target):
	# Check the target
	if not target.item or target.item.baseid not in ['fab', 'leatherdye', 'specialdye', 'runedye']:
		player.socket.clilocmessage(500857)
		return
		
	# Needs to in our belongings
	if target.item.getoutmostchar() != player:
		player.socket.clilocmessage(500364)
		return		

	# Wear out the tools
	dyes = wolfpack.finditem(arguments[0])
	if not checkdyes(player, dyes):
		return

	checkdyes(player, dyes, 1) # Wear out

	if target.item.baseid == 'leatherdye':
		leatherdye.pickHue(player, target.item) # Use special dye gump
		return
	elif target.item.baseid == 'specialdye':
		specialdye.pickHue(player, target.item) # Use special dye gump
		return
	elif target.item.baseid == 'runedye':
		runedye.pickHue(player, target.item) # Use special dye gump
		return

	# Send the dye dialog
	packet = wolfpack.packet(0x95, 9)
	packet.setint(1, target.item.serial)
	packet.setshort(7, 0xfab)
	packet.send(player.socket)
def target(player, arguments, target):
	leaves = wolfpack.finditem(arguments[0])
	
	# The leaves have to be in the backpack
	if not leaves or leaves.getoutmostitem() != player.getbackpack():
		player.socket.clilocmessage(1042664) # You must have the object in your backpack to use it.
		return
	
	# The book has to be in the backpack	
	if not target.item or target.item.getoutmostitem() != player.getbackpack():
		player.socket.clilocmessage(1042664) # You must have the object in your backpack to use it.
		return
	
	# Only works on books	
	if not target.item.hasscript('book'):
		target.item.say(1061911, '', '', False, 0x3b2, player.socket) # You can only use red leaves to seal the ink into book pages!
		return
	
	# Only on unprotected books
	if target.item.hastag('protected'):
		target.item.say(1061909, '', '', False, 0x3b2, player.socket) # The ink in this book has already been sealed.
		return
		
	# Seal the book
	target.item.settag('protected', 1)
	target.item.say(1061910, '', '', False, 0x3b2, player.socket) # You seal the ink to the page using wax from the red leaf.
	
	if leaves.amount <= 1:
		leaves.delete()
	else:
		leaves.amount -= 1
		leaves.update()
	def applyproperties(self, player, arguments, item, exceptional):
		item.decay = 1

		# See if this item
		if self.retaincolor and self.submaterial1 > 0:
			material = self.parent.getsubmaterial1used(player, arguments)
			material = self.parent.submaterials1[material]
			item.color = material[4]
			item.settag('resname', material[5])
			
		# Apply properties of secondary material
		if self.submaterial2 > 0:
			material = self.parent.getsubmaterial2used(player, arguments)
			material = self.parent.submaterials2[material]
			item.color = material[4]
			item.settag('resname2', material[5])


		# Apply one-time boni
		healthbonus = fromitem(item, DURABILITYBONUS)
		if healthbonus != 0:
			bonus = int(math.ceil(item.maxhealth * (healthbonus / 100.0)))
			item.maxhealth = max(1, item.maxhealth + bonus)
			item.health = item.maxhealth

		# Reduce the uses remain count
		checktool(player, wolfpack.finditem(arguments[0]), 1)
Example #26
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	

        region = wolfpack.region( target.pos.x, target.pos.y, target.map )
        if region.cave:
		player.socket.clilocmessage( 502488 ) # You can not place a ship inside a dungeon.
		return
                
	(canplace, moveout) = wolfpack.canplaceboat(target.pos, dispid - 0x4000)

	if not canplace or player.pos.distance( target.pos ) > 30:
		player.socket.clilocmessage( 1043284 ) # A ship can not be created here.
		return

        createBoat( player, deed, target.pos )
	deed.delete()

	for obj in moveout:
		obj.removefromview()
		obj.moveto(player.pos)
		obj.update()
		if obj.ischar() and obj.socket:
			obj.socket.resendworld()
	return
Example #27
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("You renamed the key to '%s'" % new_name)

  # Rekey
  if char.gm:
    new_lock = response.text[2]

  if len(new_lock) != 0:
    key.settag('lock', new_lock)
    char.socket.sysmessage('This key now unlocks: ' + new_lock)
  else:
    key.deltag('lock')
    char.socket.sysmessage('You erase the lock information from the key.')

  key.resendtooltip()
	def consumematerial(self, player, arguments, half = 0):
		result = CraftItemAction.consumematerial(self, player, arguments, half)
		
		if result and self.cloth > 0:			
			if half:
				needed = int(math.ceil(self.cloth / 2))
			else:
				needed = self.cloth
		
			assert(len(arguments) >= 2)
			cloth = wolfpack.finditem(arguments[1])
			if not player.canreach(cloth, -1):
				player.socket.clilocmessage(1044456) # You don't have any ready cloth...
				return False
			elif cloth.amount < needed:
				player.socket.clilocmessage(1044287) # You don't have enough...
				return False

			# Replace the second argument with the color of the cloth
			arguments[1] = cloth.color

			if needed == cloth.amount:
				cloth.delete()
			else:
				cloth.amount -= needed
				cloth.update()

		return result
	def applyproperties(self, player, arguments, item, exceptional):
		# All tailoring items crafted out of leather gain the special color
		if self.submaterial1 > 0:
			material = self.parent.getsubmaterial1used(player, arguments)
			material = self.parent.submaterials1[material]
			item.color = material[4]
			item.settag('resname', material[5])

		# Distribute another 6 points randomly between the resistances an armor alread
		# has. There are no tailored weapons.
		if exceptional:
			if itemcheck(item, ITEM_ARMOR) or itemcheck(item, ITEM_SHIELD):
				# Copy all the values to tags
				boni = [0, 0, 0, 0, 0]

				for i in range(0, 6):
					boni[random.randint(0,4)] += 1

				item.settag('res_physical', fromitem(item, RESISTANCE_PHYSICAL) + boni[0])
				item.settag('res_fire', fromitem(item, RESISTANCE_FIRE) + boni[1])
				item.settag('res_cold', fromitem(item, RESISTANCE_COLD) + boni[2])
				item.settag('res_energy', fromitem(item, RESISTANCE_ENERGY) + boni[3])
				item.settag('res_poison', fromitem(item, RESISTANCE_POISON) + boni[4])

		# Reduce the uses remain count
		checktool(player, wolfpack.finditem(arguments[0]), 1)
Example #30
0
	def target(self, char, mode, targettype, target, args, item):
		char.turnto(target)

		# Gates need special handling
		if target.hasscript('magic.gate'):
			other_gate = target.gettag('other_gate')
			if other_gate != None:
				item = wolfpack.finditem(other_gate)

		# Dispellable?
		if not target.hastag('dispellable_field'):
			if char.socket:
				char.socket.clilocmessage(1005049)
			return

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

		wolfpack.effect(0x376a, target.pos, 9, 20)
		# remove other gate
		if item and item.hastag('dispellable_field'):
			wolfpack.effect(0x376a, item.pos, 9, 20)
			target.soundeffect(0x201)
			item.delete()
		target.soundeffect(0x201)
		target.delete()
Example #31
0
def onUse(char, item, norange=0):
	# Using doors doesnt count against the object-delay
	char.objectdelay = 0

	# In Range?
	if not char.cansee( item ):
		char.socket.sysmessage( tr("You cannot see the door from here.") )
		return True
	elif not norange and not char.canreach(item, 2):
		char.socket.sysmessage( tr("You cannot reach the handle from here.") )
		return True

	# Do we have a linked door, is this door not open?
	if item.hastag('link') and not item.hastag('opened'):
		doubledoor = wolfpack.finditem( int(item.gettag('link')) )
		if doubledoor:
			# Double check to make sure either door isn't open.
			if not item.hastag('opened') and not doubledoor.hastag('opened'):
				opendoor( char, doubledoor )
	return opendoor( char, item )
Example #32
0
def response(player, arguments, response):
    if response.button == 0:
        return

    command = (response.button >> 28) & 0xC
    item = wolfpack.finditem((response.button & 0x3FFFFFFF) | 0x40000000)
    if not item:
        return

    target = arguments[0]

    # Delete Item
    if command == 0x04:
        player.log(
            LOG_MESSAGE, 'Deleting item 0x%x from character 0x%x.\n' %
            (item.serial, item.container.serial))
        item.delete()

        showEditGump(player, target)

    # Bounce Item
    elif command == 0x08:
        player.log(
            LOG_MESSAGE, 'Bouncing item 0x%x from character 0x%x.\n' %
            (item.serial, item.container.serial))

        if not tobackpack(item, player):
            item.update()

        showEditGump(player, target)

    # Show Info For Item
    elif command == 0x0C:
        player.log(
            LOG_MESSAGE,
            'Showing info gump for item 0x%x from character 0x%x.\n' %
            (item.serial, item.container.serial))
        iteminfo(player.socket, item)

    else:
        player.socket.sysmessage('Unknown command.')
Example #33
0
def onDelete(object):
    if object.isitem():
        item = object
        if item.hastag('pet'):
            try:
                pet = wolfpack.findchar(int(item.gettag('pet')))
                if pet and pet.stablemaster != -1:
                    item.free = 1
                    pet.delete()
            except:
                pass
        return

    char = object
    if not char.npc:
        return

    figurine = wolfpack.finditem(char.stablemaster)
    if figurine:
        char.free = 1
        figurine.delete()
Example #34
0
def dyeresponse(socket, packet):
	serial = packet.getint(1)
	color = packet.getshort(7)

	# See if the color is invalid.
	if color < 2 or color > 0x3e9:
		socket.sysmessage( tr("You selected an invalid color.") )
		return 1

	# See if the serial is pointing to a valid object.
	item = wolfpack.finditem(serial)
	
	# Check if it's a dyetub and if its in our belongings
	if not item or item.baseid != 'fab' or item.getoutmostchar() != socket.player:
		socket.clilocmessage(500857)
		return 1

	item.color = color
	item.update()
	socket.player.soundeffect(0x023e)
	return 1
Example #35
0
def target(player, arguments, target):
    leaves = wolfpack.finditem(arguments[0])

    # The leaves have to be in the backpack
    if not leaves or leaves.getoutmostitem() != player.getbackpack():
        player.socket.clilocmessage(
            1042664)  # You must have the object in your backpack to use it.
        return

    # The book has to be in the backpack
    if not target.item or target.item.getoutmostitem() != player.getbackpack():
        player.socket.clilocmessage(
            1042664)  # You must have the object in your backpack to use it.
        return

    # Only works on books
    if not target.item.hasscript('book'):
        target.item.say(
            1061911, '', '', False, 0x3b2, player.socket
        )  # You can only use red leaves to seal the ink into book pages!
        return

    # Only on unprotected books
    if target.item.hastag('protected'):
        target.item.say(
            1061909, '', '', False, 0x3b2,
            player.socket)  # The ink in this book has already been sealed.
        return

    # Seal the book
    target.item.settag('protected', 1)
    target.item.say(
        1061910, '', '', False, 0x3b2, player.socket
    )  # You seal the ink to the page using wax from the red leaf.

    if leaves.amount <= 1:
        leaves.delete()
    else:
        leaves.amount -= 1
        leaves.update()
Example #36
0
def targetitem( char, args, target ):
	socket = char.socket

	if target.item:
		# Find the target item.
		finditem = wolfpack.finditem( target.item.serial )
		# Safety Checks
		if not finditem:
			socket.sysmessage(tr("You must target an item!"))
			return True
		if not canturn( char, finditem ):
			socket.sysmessage(tr("This object is not movable by you!"))
			return True

		# Turnable Furniture
		if finditem.id in TURNABLES:
			finditem.id = utilities.hex2dec(TURNABLES[finditem.id][0])
			finditem.update()
			socket.sysmessage(tr("You rotate the object."))
		# Turnable Deeds
		elif int(finditem.id) == utilities.hex2dec(0x14ef) and str(finditem.baseid) in TURNDEEDS:
			if finditem.container != char.getbackpack():
				socket.sysmessage(tr("This deed needs to be in your backpack to turn it!"))
				return True
			else:
				finditem.settag( 'carpentry_type', str(TURNDEEDS[finditem.baseid][1]) )
				finditem.name = str(TURNDEEDS[str(finditem.baseid)][2])
				# Update BaseID Last
				finditem.baseid = str(TURNDEEDS[finditem.baseid][0])
				finditem.update()
				socket.sysmessage(tr("You rotate the deed's placement direction."))
			return
		# Error
		else:
			socket.sysmessage(tr("This item is not turnable."))
			return True
	# Error
	else:
		socket.sysmessage(tr("This item is not turnable."))
		return True
Example #37
0
def response(player, args, target):
	if player.guild:
		player.socket.sysmessage(tr('You have to leave your guild before founding a new one.'))
		return

	deed = wolfpack.finditem(args[0])

	if deed:
		if deed.getoutmostchar() != player:
			player.socket.clilocmessage(500364)
		elif not player.cansee(deed) or not player.canpickup(deed):
			player.socket.clilocmessage(500312)
		#elif not player.cansee(target.pos, 1) or not target.pos.validspawnspot():
		#	player.socket.clilocmessage(500312)
		else:
			if not player.canreach(target, 3):
				player.socket.clilocmessage(500312)
			elif not target.pos.validspawnspot():
				player.socket.clilocmessage(502749)
			else:
				# Create a guild
				guild = wolfpack.newguild()
				guild.name = tr("%s's Guild") % (player.name)
				guild.addmember(player)
				guild.leader = player

				player.addscript( 'guilds.member' )

				# Create a guildstone at the given location
				guildstone = wolfpack.additem("guildstone")
				guildstone.settag('guild', guild.serial)
				guildstone.decay = 0
				guildstone.moveto(target.pos)
				guild.guildstone = guildstone
				guildstone.update()

				deed.delete()
				player.socket.sysmessage(tr('You place the guildstone and your deed vanishes.'))
				player.resendtooltip()
	return True
Example #38
0
def DryDock( item, player ):

	boat = wolfpack.finditem(item.gettag('boat_serial'))

	socket = player.socket

	dialog = cGump( nomove=1, x=100, y=150 )

	dialog.addResizeGump(0, 0, 9200, 240, 159)
	dialog.addText(60, 10, "DryDock System", 0)
	dialog.addResizeGump(18, 39, 9350, 200, 70)
	dialog.addText(35, 50, "Do you really want to dock", 0)
	dialog.addText(35, 75, "your ship?", 0)
	dialog.addButton(40, 120, 247, 248, 1)
	dialog.addButton(130, 120, 241, 242, 0)

	dialog.setArgs( [boat] )
	dialog.setCallback( drydockresponse )

	dialog.send( player.socket )

	return True
Example #39
0
def onDelete(object):
    if not object.hastag('spawner'):
        return 0

    try:
        spawner = wolfpack.finditem(int(object.gettag('spawner')))
        if spawner and spawner.hastag('current'):
            current = int(spawner.gettag('current'))
            current -= 1

            if current <= 0:
                spawner.deltag('current')
            else:
                spawner.settag('current', current)

            spawner.resendtooltip()
    except:
        return 0

    object.removescript('system.spawns')
    object.deltag('spawner')
    return 0
Example #40
0
def BoatRename( item, player ):

	boat = wolfpack.finditem(item.gettag('boat_serial'))

	socket = player.socket

	dialog = cGump( nomove=1, x=100, y=150 )

	dialog.addResizeGump(0, 0, 9200, 240, 159)
	dialog.addText(60, 10, "Rename your Boat", 0)
	dialog.addResizeGump(18, 39, 9350, 200, 70)
	dialog.addText(25, 45, "New Boat name:", 0)
	dialog.addInputField(28, 75, 176, 20, 0, 1, boat.name)
	dialog.addButton(40, 120, 247, 248, 1)
	dialog.addButton(130, 120, 241, 242, 0)

	dialog.setArgs( [boat, item] )
	dialog.setCallback( renameresponse )

	dialog.send( player.socket )

	return True
Example #41
0
def target(player, arguments, target):
	dyetub = wolfpack.finditem(arguments[0])

	if not dyetub or not player.canreach(dyetub, 1):
		player.socket.clilocmessage(500446)
		return

	if not target.item or not target.item.dye:
		player.socket.clilocmessage(1042083) # You can not dye that.
		return

	if target.item.getoutmostchar() != player:
		player.socket.clilocmessage(500446) # Too far away
		return

	if target.item.container == player:
		player.socket.clilocmessage(500861) # Can't Dye clothing that is being worn.
		return

	target.item.color = dyetub.color
	target.item.update()
	player.log( LOG_MESSAGE, "Dying item (%x,%x) using tub (%x,%x)\n" % ( target.item.serial, target.item.color, dyetub.serial, dyetub.color ) )
	player.soundeffect(0x23e)
Example #42
0
def transport_timer(object, args):
	char = wolfpack.findchar(args[0])
	item = wolfpack.finditem(args[1])
	bound = args[2]
	char.frozen = False
	if not item:
		return False

	item.deltag('timer')
	if CheckUse(char, item, False):
		boundRoot = bound.getoutmostchar().socket
		if boundRoot:
			item.settag('charges', charges(item) - 1)
			item.resendtooltip()

			#
			# ToDo: TeleportPets
			#

			char.soundeffect(0x1fc)
			char.moveto(boundRoot.player.pos)
			char.soundeffect(0x1fc)
			char.update()
Example #43
0
def response(player, arguments, response):
	plant = wolfpack.finditem(arguments[0])

	if response.button == 0 or not plant or plants.plant.getStatus(plant) != STATUS_STAGE9 or not player.canreach(plant, 3):
		return # Cancel

	if not plants.plant.checkAccess(player, plant):
		plant.say(1061856, '', '', False, 0x3b2, player.socket)
		return

	# Cancel	
	if response.button == 1:
		plants.reproductiongump.send(player, plant)

	# Help
	elif response.button == 2:
		send(player, plant)
		plants.sendCodexOfWisdom(player.socket, 70)

	# Turn into a decorative plant
	elif response.button == 3:
		plants.plant.setStatus(plant, STATUS_DECORATIVE)
		plant.say(1053077, '', '', False, 0x3b2, player.socket) # You prune the plant. This plant will no longer produce resources or seeds, but will require no upkeep.
Example #44
0
def hairdye_callback( char, args, response ):
	if response.button != 1:
		return

	# Check the item first
	item = wolfpack.finditem( args[0] )

	if not item or item.container != char.getbackpack():
		char.message( 1042001 ) # That must be in your pack for you to use it.
		return

	# Check if it's a valid color
	if len( response.switches ) != 1:
		char.message( tr("You have to choose a hair color.") )
		return

	color = response.switches[0]

	# Find the color
	for dye_group in hairdye_groups:
		if color >= dye_group[0] and color < dye_group[0] + dye_group[1]:
			item.delete()

			hair = char.itemonlayer( LAYER_HAIR )
			beard = char.itemonlayer( LAYER_BEARD )

			if beard:
				beard.color = color
				beard.update()

			if hair:
				hair.color = color
				hair.update()

			return

	char.message( tr("That is an invalid color.") )
Example #45
0
def response(char, args, target):
    kit = wolfpack.finditem(args[0])
    if not kit:
        return False
    if not char.canreach(target.pos, 3):
        char.socket.clilocmessage(500295)  # You are too far away to do that.
        return False
    if not target.item and not target.item.corpse and not baseid == "big_fish":
        char.socket.clilocmessage(1042600)  # That is not a corpse!
    elif target.item.corpse and VisitedByTaxidermist(target.item):
        char.socket.clilocmessage(
            1042596
        )  # That corpse seems to have been visited by a taxidermist already.
    else:
        if target.item.baseid == "big_fish":
            createTrophyDeed(char, 'big_fish', target.item)
            target.item.delete()
            kit.delete()

        elif getname(target.item.bodyid) in corpses.keys():
            corpse = corpses[getname(target.item.bodyid)]
            if not wolfpack.utilities.checkresources(char.getbackpack(),
                                                     '1bdd', 10):

                createTrophyDeed(char, getname(target.item.bodyid),
                                 target.item)

                target.item.settag('VisitedByTaxidermist', 0)
                kit.delete()
            else:
                char.socket.clilocmessage(
                    1042598)  # You do not have enough boards.
        else:
            char.socket.clilocmessage(
                1042599
            )  # That does not look like something you want hanging on a wall.
        return
Example #46
0
def potion( cserial, iserial, clicked=False, counter=4, bonus=0 ):
	item = wolfpack.finditem( iserial )
	amount = item.amount
	if not item:
		return False

	if not item.baseid in explodables:
		return False

	if not clicked:
		if not item.hastag( 'exploding' ):
			item.settag( 'exploding', cserial )
		potion( cserial, iserial, True, counter, bonus )
		return True
	# Triggered
	if clicked:
		if counter > 0:
			item.addtimer( 1000, potioncountdown, [cserial, counter, bonus] )
		else:
			item.soundeffect( 0x307 ) # Boom!
			item.effect( explosions[randint( 0, 2 )], 20, 10 )
			potionregion( cserial, iserial, bonus )
			item.delete()
		return True
Example #47
0
def copy_response(char, args, target):
    if len(args) != 1:
        return

    key = wolfpack.finditem(args[0])
    if not key or not char.canreach(key, 5):
        char.socket.clilocmessage(501661)
        return

    # Check if the targetted item is a key
    if not target.item or not target.item.hasscript('key'):
        char.socket.clilocmessage(501679)
        return

    # Also a blank key?
    if not target.item.hastag('lock'):
        char.socket.clilocmessage(501675)
        return

    # Check if the player can reach the item
    if not char.canreach(target.item, 5):
        char.socket.clilocmessage(501661)
        return

    # Tinkering check (15%-30%, 25% chance of loosing the key on failure)
    if char.checkskill(TINKERING, 150, 300):
        key.settag('lock', target.item.gettag('lock'))
        key.resendtooltip()
        char.socket.clilocmessage(501676)
    else:
        char.socket.clilocmessage(501677)

        # 25% chance of destroying the blank key
        if random.randint(1, 4) == 1:
            char.socket.clilocmessage(501678)
            key.delete()
Example #48
0
def target(player, arguments, target):
    dyetub = wolfpack.finditem(arguments[0])

    if not dyetub or not player.canreach(dyetub, 1):
        player.socket.clilocmessage(500446)
        return

    if not target.item or (
            not magic.runebook.isRunebook(target.item)
            and not target.item.baseid in ['1f14', '1f15', '1f16', '1f17']):
        player.socket.clilocmessage(
            1049775)  # You can only dye runestones or runebooks with this tub.
        return

    if target.item.getoutmostchar() != player:
        player.socket.clilocmessage(500446)  # Too far away
        return

    target.item.color = dyetub.color
    target.item.update()
    player.log(
        LOG_MESSAGE, "Dying item (%x,%x) using tub (%x,%x)\n" %
        (target.item.serial, target.item.color, dyetub.serial, dyetub.color))
    player.soundeffect(0x23e)
Example #49
0
def response(player, arguments, response):
    if response.button == 0:
        return

    item = wolfpack.finditem(arguments[0])
    if not item:
        return

    if response.button == 2:
        openadvancedoptions(player, item)

    # Validate parameters
    if not 0 in response.switches and not 1 in response.switches:
        player.socket.sysmessage(tr('You have to choose a spawntype.'))
        return

    spawntype = response.switches[0]

    try:
        definition = response.text[0]
        area = int(response.text[1])
        mininterval = int(response.text[2])
        maxinterval = int(response.text[3])
        maximum = int(response.text[4])
    except:
        player.socket.sysmessage(tr('You entered an invalid value.'))
        return

    item.settag('spawntype', spawntype)
    item.settag('spawndef', definition)
    item.settag('area', area)
    item.settag('mininterval', mininterval)
    item.settag('maxinterval', maxinterval)
    item.settag('maximum', maximum)

    item.resendtooltip()
Example #50
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()
Example #51
0
def successlumberjacking(char, args):
    if not char:
        return False

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

    socket = char.socket
    pos = args[0]  # Target POS
    resource = wolfpack.finditem(args[1])
    amount = args[2]
    tool = wolfpack.finditem(args[3])
    resname = args[4]
    table = args[5]
    if not resource or not tool:
        return False

    # Lets make sure we stayed next to the tree
    # Player can reach that ?
    if char.pos.map != pos.map or char.pos.distance(pos) > chopdistance:
        socket.sysmessage(
            tr("You have moved too far away to gather any wood."))
        socket.deltag('is_lumberjacking')
        return False

    if not resource.hastag('resourcecount'):
        return False

    if int(resource.gettag('resourcecount')) <= 0:
        char.socket.clilocmessage(500488)
        return False

    reqskill = table[resname][REQSKILL]
    chance = int((char.skill[LUMBERJACKING] - table[resname][MINSKILL]) / 10)

    if char.skill[LUMBERJACKING] < reqskill:
        socket.sysmessage(
            tr("You are not skilled enough to gather wood from this tree."))
        return False
    else:
        char.checkskill(LUMBERJACKING, reqskill, 1200)
        # Skill Check against LUMBERJACKING
        if chance >= randint(1, 100):
            char.socket.clilocmessage(
                500498)  # You put some logs into your backpack
            checktool(char, tool, True)
            char.socket.deltag('is_lumberjacking')
            success = True
        else:
            char.socket.clilocmessage(
                500495
            )  # You hack at the tree for a while but fail to produce...
            success = False
            return False

    if success:
        # Check for a backpack
        backpack = char.getbackpack()
        if not backpack:
            return False
        # Create an item in my pack
        resourceitem = wolfpack.additem(table[resname][LOGBASEID])
        resourceitem.amount = randint(3, 10)
        if not wolfpack.utilities.tobackpack(resourceitem, char):
            resourceitem.update()

        # Resend weight
        char.socket.resendstatus()

        if resource.gettag('resourcecount') >= 1:
            resource.settag('resourcecount', int(amount - 1))

        return True
Example #52
0
def pollinate_target(player, arguments, target):
    plant = wolfpack.finditem(arguments[0])

    if not plant or plants.plant.getStatus(plant) >= STATUS_DECORATIVE:
        return  # Cancel

    if not plants.plant.checkAccess(player, plant):
        plant.say(1061856, '', '', False, 0x3b2, player.socket)
        return

    genus = plants.plant.getGenus(plant)
    hue = plants.plant.getHue(plant)
    status = plants.plant.getStatus(plant)

    # Not crossable -> no pollen
    if not genus.crossable or not hue.crossable:
        plant.say(
            1053050, '', '', False, 0x3b2,
            player.socket)  # You cannot gather pollen from a mutated plant!

    # Too early to gather pollen
    elif status < STATUS_FULLGROWN:
        plant.say(
            1053051, '', '', False, 0x3b2, player.socket
        )  # You cannot gather pollen from a plant in this stage of development!

    # Not healthy enough
    elif plants.plant.getHealthStatus(plant) in [HEALTH_WILTED, HEALTH_DYING]:
        plant.say(
            1053052, '', '', False, 0x3b2,
            player.socket)  # You cannot gather pollen from an unhealthy plant!

    # Check the target item now
    elif not target.item or not target.item.hasscript('plants.plant'):
        plant.say(1053070, '', '', False, 0x3b2, player.socket
                  )  # You can only pollinate other specially grown plants!

    else:
        # Get the neccesary information for the target
        tgenus = plants.plant.getGenus(target.item)
        thue = plants.plant.getHue(target.item)
        tstatus = plants.plant.getStatus(target.item)

        # It's not really a plant
        if tstatus >= STATUS_DECORATIVE or tstatus <= STATUS_DIRT:
            plant.say(1053070, '', '', False, 0x3b2, player.socket
                      )  # You can only pollinate other specially grown plants!

        # It's not reachable
        elif not plants.plant.checkAccess(player, target.item):
            target.item.say(
                1061856, '', '', False, 0x3b2, player.socket
            )  # You must have the item in your backpack or locked down in order to use it.

        # It's not crossable
        elif not tgenus.crossable or not thue.crossable:
            target.item.say(
                1053073, '', '', False, 0x3b2, player.socket
            )  # You cannot cross-pollinate with a mutated plant!

        # It's not producing pollen
        elif tstatus < STATUS_FULLGROWN:
            target.item.say(
                1053074, '', '', False, 0x3b2, player.socket
            )  # This plant is not in the flowering stage. You cannot pollinate it!

        # Not healthy enough
        elif plants.plant.getHealthStatus(
                target.item) in [HEALTH_WILTED, HEALTH_DYING]:
            target.item.say(
                1053075, '', '', False, 0x3b2,
                player.socket)  # You cannot pollinate an unhealthy plant!

        # Already pollinated
        elif plants.plant.getPollinated(target.item):
            target.item.say(
                1053072, '', '', False, 0x3b2,
                player.socket)  # This plant has already been pollinated!

        # Self Pollination
        elif target.item == plant:
            plants.plant.setPollinated(target.item, True)
            plants.plant.setSeedGenus(target.item, genus)
            plants.plant.setSeedHue(target.item, hue)
            target.item.say(
                1053071, '', '', False, 0x3b2,
                player.socket)  # You pollinate the plant with its own pollen.

        # Cross Pollination
        else:
            plants.plant.setPollinated(target.item, True)
            plants.plant.setSeedGenus(target.item, genus.cross(tgenus))
            plants.plant.setSeedHue(target.item, hue.cross(thue))
            target.item.say(
                1053076, '', '', False, 0x3b2,
                player.socket)  # You successfully cross-pollinate the plant.

    send(player, plant)  # In the end always resend the gump
Example #53
0
def response(player, arguments, response):
    plant = wolfpack.finditem(arguments[0])

    if response.button == 0 or not plant or plants.plant.getStatus(
            plant) >= STATUS_DECORATIVE or not player.canreach(plant, 3):
        return  # Cancel

    if not plants.plant.checkAccess(player, plant):
        plant.say(1061856, '', '', False, 0x3b2, player.socket)
        return

    # Back to maingump
    if response.button == 1:
        plants.maingump.send(player, plant)

    # Set to decorative mode
    elif response.button == 2:
        status = plants.plant.getStatus(plant)
        if status == STATUS_STAGE9:
            plants.makedecorativegump.send(player, plant)

    # Pollination Help
    elif response.button == 3:
        send(player, plant)
        plants.sendCodexOfWisdom(player.socket, 67)

    # Resources Help
    elif response.button == 4:
        send(player, plant)
        plants.sendCodexOfWisdom(player.socket, 69)

    # Seed Help
    elif response.button == 5:
        send(player, plant)
        plants.sendCodexOfWisdom(player.socket, 68)

    # Gather Pollen
    elif response.button == 6:
        genus = plants.plant.getGenus(plant)
        hue = plants.plant.getHue(plant)
        status = plants.plant.getStatus(plant)

        # Not crossable -> no pollen
        if not genus.crossable or not hue.crossable:
            plant.say(1053050, '', '', False, 0x3b2, player.socket
                      )  # You cannot gather pollen from a mutated plant!

        # Too early to gather pollen
        elif status < STATUS_FULLGROWN:
            plant.say(
                1053051, '', '', False, 0x3b2, player.socket
            )  # You cannot gather pollen from a plant in this stage of development!

        # Not healthy enough
        elif plants.plant.getHealthStatus(plant) in [
                HEALTH_WILTED, HEALTH_DYING
        ]:
            plant.say(1053052, '', '', False, 0x3b2, player.socket
                      )  # You cannot gather pollen from an unhealthy plant!

        # Show a target to pollinate another plant
        else:
            plant.say(1053054, '', '', False, 0x3b2, player.socket
                      )  # Target the plant you wish to cross-pollinate to.
            player.socket.attachtarget(
                'plants.reproductiongump.pollinate_target', [plant.serial])

        send(player, plant)  # Resend our gump

    # Gather resources
    elif response.button == 7:
        available = plants.plant.getAvailableResources(plant)
        genus = plants.plant.getGenus(plant)
        hue = plants.plant.getHue(plant)

        # The plant doesn't produce resources
        if not plants.resources.canProduce(genus, hue):
            if not genus.crossable or not hue.crossable:
                plant.say(
                    1053055, '', '', False, 0x3b2,
                    player.socket)  # Mutated plants do not produce resources!
            else:
                plant.say(
                    1053056, '', '', False, 0x3b2,
                    player.socket)  # This plant has no resources to gather!

        # Nothing available at the moment
        elif available == 0:
            plant.say(1053056, '', '', False, 0x3b2,
                      player.socket)  # This plant has no resources to gather!

        # Create resources
        else:
            res = plants.resources.create(genus, hue)
            if not wolfpack.utilities.tobackpack(res, player):
                res.update()

            plants.plant.setAvailableResources(plant, available -
                                               1)  # Reduce available resources
            plant.say(1053059, '', '', False, 0x3b2,
                      player.socket)  # You gather resources from the plant.

        send(player, plant)

    # Gather Seeds
    elif response.button == 8:
        available = plants.plant.getAvailableSeeds(plant)
        genus = plants.plant.getGenus(plant)
        hue = plants.plant.getHue(plant)

        # The plant doesn't produce seeds
        if not genus.crossable or not hue.crossable:
            plant.say(1053060, '', '', False, 0x3b2,
                      player.socket)  # Mutated plants do not produce seeds!

        # Nothing available at the moment
        elif available == 0:
            plant.say(1053061, '', '', False, 0x3b2,
                      player.socket)  # This plant has no seeds to gather!

        # Create seeds
        else:
            seed = plants.seed.create(plants.plant.getSeedGenus(plant),
                                      plants.plant.getSeedHue(plant), True)
            if not wolfpack.utilities.tobackpack(seed, player):
                seed.update()

            plants.plant.setAvailableSeeds(plant, available -
                                           1)  # Reduce available seeds.
            plant.say(1053063, '', '', False, 0x3b2,
                      player.socket)  # You gather seeds from the plant.

        send(player, plant)
Example #54
0
def response_sender(char, args, target):
    item = wolfpack.finditem(args[0])
    if not item:
        return False
    if not item.getoutmostchar() == char and not char.canreach(target.pos, 2):
        char.socket.clilocmessage(1019045)  # I can't reach that.
        return False

    if target.item and target.item.serial == item.serial:
        if active(item):
            deactivate(item)
            char.socket.clilocmessage(500672)  # You turn the crystal off.
        else:
            if int(charges(item)) > 0:
                activate_sender(item)
                char.socket.clilocmessage(500673)  # You turn the crystal on.
            else:
                char.socket.clilocmessage(
                    500676)  # This crystal is out of charges.

    elif target.item and target.item.baseid == "comcrystal_receiver":
        if len(receivers(item)) >= 10:
            char.socket.cliloc(
                1010042
            )  # This broadcast crystal is already linked to 10 receivers.
            return False
        elif target.item.gettag("sender") == item.serial:
            char.socket.clilocmessage(
                500674)  # This crystal is already linked with that crystal.
        elif target.item.hastag("sender"):
            char.socket.clilocmessage(
                1010043
            )  # That receiver crystal is already linked to another broadcast crystal.
        else:
            item.settag("receiver_%s" % target.item.serial, 0)
            target.item.settag("sender", item.serial)
            char.socket.clilocmessage(
                500675)  # That crystal has been linked to this crystal.
            item.resendtooltip()

    elif target.char:
        deltags_receiver(item)
        char.socket.clilocmessage(
            1010046
        )  # You unlink the broadcast crystal from all of its receivers.
        item.resendtooltip()

    else:
        if getname(target.item.baseid) in recharges.keys():
            if charges(item) >= MaxCharges:
                char.socket.clilocmessage(
                    500678)  # This crystal is already fully charged.
            else:
                char.socket.sysmessage("baseid: " +
                                       str(getname(target.item.baseid)))
                gem = getname(target.item.baseid)
                new_charges = getrechargeinfo(gem)
                target.item.delete()
                if (charges(item) + new_charges) >= MaxCharges:
                    item.settag("charges", MaxCharges)
                    char.socket.clilocmessage(
                        500679)  # You completely recharge the crystal.
                else:
                    item.settag("charges", charges(item) + new_charges)
                    char.socket.clilocmessage(
                        500680)  # You recharge the crystal.
        char.socket.clilocmessage(
            500681)  # You cannot use this crystal on that.
    return True
Example #55
0
def deltags_sender(item):
    if item.hastag("sender"):
        sender = wolfpack.finditem(int(item.gettag("sender")))
        sender.deltag("receiver_%s" % item.serial)
        sender.resendtooltip()
    return
Example #56
0
def findHouse(player):
    serial = player.serial
    if serial in HOUSES:
        return wolfpack.finditem(HOUSES[serial])
    else:
        return None
Example #57
0
def update_light(serial):
	item = wolfpack.finditem(serial)
	if item:
		item.update()
Example #58
0
def domining(char, args):
    char.soundeffect(random.choice([0x125, 0x126]))
    tool = wolfpack.finditem(args[0])
    pos = args[1]
    socket = char.socket
    if socket.hastag('is_mining'):
        socket.deltag('is_mining')

    if not tool:
        return False

    # Recheck distance
    #if not char.canreach(pos, MINING_MAX_DISTANCE):
    #	socket.clilocmessage(501867)
    #	return False

    # Finding the Default Ore table for this Region
    region = char.region
    Oretable = FindOreTable(region)

    veingem = getvein(Oretable, pos, char)

    if not veingem or not veingem.hastag('resourcecount'):
        return False

    # 50% chance to dig up primary resource,
    # even if the vein has something else.
    if veingem.hastag('resname2') and random.random() >= 0.50:
        resname = veingem.gettag('resname2')
    else:
        resname = veingem.gettag('resname')

    resourcecount = veingem.gettag('resourcecount')
    reqskill = Oretable[resname][REQSKILL]

    # Refill the resource gem.
    if resourcecount == 0:
        socket.sysmessage(tr("There is no ore here to mine."))

        if not veingem.hastag('resource_empty'):
            # Picking the next amount
            nextamount = random.randint(Oretable[resname][MINAMOUNT],
                                        Oretable[resname][MAXAMOUNT])
            duration = random.randint(MINING_REFILLTIME[0],
                                      MINING_REFILLTIME[1])
            veingem.addtimer(duration, respawnvein, [nextamount], True)
            veingem.settag('resource_empty', 1)
        return False

    # You loosen some rocks but fail to find any usable ore.
    if char.skill[MINING] < reqskill:
        socket.clilocmessage(501869)
        return False

    chance = max(0, char.skill[MINING] - Oretable[resname][MINSKILL]) / 1000.0
    success = 0

    if not skills.checkskill(char, MINING, chance):
        socket.clilocmessage(501869)
        return False

    # Digs up the large ore.
    if resourcecount >= 5:
        successmining(Oretable, char, veingem, resname, 3)

    # Picks one of the smaller ore types
    elif resourcecount == 3 or resourcecount == 4:
        successmining(Oretable, char, veingem, resname, 2)

    # Smallest ore only
    elif resourcecount == 1 or resourcecount == 2:
        successmining(Oretable, char, veingem, resname, 1)
    wearout(char, tool)
Example #59
0
def response(char, args, target):
    socket = char.socket
    if not socket:
        return False

    pos = target.pos

    # Player can reach that ?
    if char.pos.map != pos.map or char.pos.distance(pos) > MINING_MAX_DISTANCE:
        # That is too far away
        socket.clilocmessage(500446, "", GRAY)
        return True

    tool = wolfpack.finditem(args[0])

    #Player also can't mine when riding, polymorphed and dead.
    #Mine char ?!
    if target.char:
        # You can't mine that.
        socket.clilocmessage(501863, "", GRAY)
        return True

    #Find tile by it's position if we haven't model
    elif target.model == 0:
        map = wolfpack.map(target.pos.x, target.pos.y, target.pos.map)
        ###########################
        # Searching for a Treasure
        ###########################
        bag = char.getbackpack()
        if bag.countresource(0x14eb) > 0:
            # Assign a variable to stop or not process
            foundtreas = 0
            # Loop content in player's Backpack
            for cmap in bag.content:
                if cmap.id == 0x14eb and cmap.hastag(
                        'level') and not cmap.hastag('founded'):
                    foundtreas = checktreaspoint(target.pos.x, target.pos.y,
                                                 target.pos.z, target.pos.map,
                                                 cmap, char)
                    if foundtreas == 1:
                        break
            # Stop Action
            if foundtreas == 1:
                return True

        if ismountainorcave(map['id']):
            mining(char, target.pos, tool, sand=False)
        elif issand(map['id']) and canminesand(char):
            mining(char, target.pos, tool, sand=True)
        else:
            # You can't mine there.
            socket.clilocmessage(501862, "", GRAY)
        return True

    #Find tile by it's model
    elif target.model != 0:
        ###########################
        # Searching for a Treasure
        ###########################
        bag = char.getbackpack()
        if bag.countresource(0x14eb) > 0:
            # Assign a variable to stop or not process
            foundtreas = 0
            # Loop content in player's Backpack
            for cmap in bag.content:
                if cmap.id == 0x14eb and cmap.hastag('level'):
                    foundtreas = checktreaspoint(target.pos.x, target.pos.y,
                                                 target.pos.z, target.pos.map,
                                                 cmap, char)
                    if foundtreas == 1:
                        break
            # Stop Action
            if foundtreas == 1:
                return True

        if ismountainorcave(target.model):
            #add new ore gem here and mine
            mining(char, target.pos, tool)
        else:
            socket.clilocmessage(501862, "", GRAY)  # You can't mine there.
        return True

    else:
        return False
Example #60
0
def response(player, arguments, response):
    plant = wolfpack.finditem(arguments[0])

    if response.button == 0 or not plant or plants.plant.getStatus(
            plant) >= STATUS_DECORATIVE or not player.canreach(plant, 3):
        return  # Cancel

    if not plants.plant.checkAccess(player, plant):
        plant.say(1061856, '', '', False, 0x3b2, player.socket)
        return

    # Reproduction Menu
    if response.button == 1:
        if plants.plant.getStatus(plant) > STATUS_DIRT:
            plants.reproductiongump.send(player, plant)
            pass
        else:
            player.socket.clilocmessage(
                1061885)  # You need to plant a seed in the bowl first.
            send(player, plant)

    # Infestation
    elif response.button == 2:
        send(player, plant)
        plants.sendCodexOfWisdom(player.socket, 54)

    # Fungus
    elif response.button == 3:
        send(player, plant)
        plants.sendCodexOfWisdom(player.socket, 56)

    # Poison
    elif response.button == 4:
        send(player, plant)
        plants.sendCodexOfWisdom(player.socket, 58)

    # Disease
    elif response.button == 5:
        send(player, plant)
        plants.sendCodexOfWisdom(player.socket, 60)

    # Water
    elif response.button == 6:
        addWater(player, plant)

    # Poison Potion
    elif response.button == 7:
        addPotion(player, plant, [16, 17])

    # Cure Potion
    elif response.button == 8:
        addPotion(player, plant, [6])

    # Heal Potion
    elif response.button == 9:
        addPotion(player, plant, [3])

    # Strength Potion
    elif response.button == 10:
        addPotion(player, plant, [10])

    # Help
    elif response.button == 11:
        send(player, plant)
        plants.sendCodexOfWisdom(player.socket, 48)

    # Empty the Bowl
    elif response.button == 12:
        plants.emptybowlgump.send(player, plant)
        pass