Example #1
0
	def check(self):
		toremove = []
		for page in self.pages:
			char = wolfpack.findchar(page.serial)
			if not char:
				toremove.append(page)
				continue
			if page.assigned:
				char = wolfpack.findchar(page.assigned)
				if not char or not char.socket:
					page.assigned = None
					continue
		for page in toremove:
			self.remove(page)
Example #2
0
 def check(self):
     toremove = []
     for page in self.pages:
         char = wolfpack.findchar(page.serial)
         if not char:
             toremove.append(page)
             continue
         if page.assigned:
             char = wolfpack.findchar(page.assigned)
             if not char or not char.socket:
                 page.assigned = None
                 continue
     for page in toremove:
         self.remove(page)
Example #3
0
def gump_response(char, arguments, response):
	vendor = wolfpack.findchar(arguments[0])
	if not vendor or vendor.distanceto(char) > 4:
		return

	if response.button == 0:
		return

	if response.button > len(sellList):		
		return

	item = sellList[response.button - 1]

	female = ( char.id in PLAYER_BODIES_ALIVE_FEMALE )
	gold = char.getbackpack().countitems(['eed'])
	gold += char.getbankbox().countitems(['eed'])
		
	# Check if we can afford it
	if female and item[2]:
		vendor.say(1010639, "", "", False, vendor.saycolor, char.socket)
		return

	if item[1] > gold and not char.gm:
		vendor.say(1042293, "", "", False, vendor.saycolor, char.socket)
		return

	item[3](vendor, char, item, item[4])
Example #4
0
def onTrade( player, type, buttonstate, itemserial ):
	#Receiving button state, close request etc...
	#itemserial == tradecontainer.serial of player
	#buttonstate == 1 : user confirm deal
	#buttonstate == 0 : user reject deal
	#type == 1 : user want to close trade
	#type == 2 : button pressed
	handler = { 1 : closetrade, 2 : pressbutton }

	#Check if we have a partner
	if player.hastag( 'trade_partner' ):
		partner = wolfpack.findchar( player.gettag( 'trade_partner' ) )
		if not partner:
			return True
	else:
		return True

	#Get tradecontainers
	box2 = partner.itemonlayer( LAYER_TRADING )
	box1 = player.itemonlayer( LAYER_TRADING )

	#Something lost ?
	if not box1 or not box2:
		closetrade( player, partner, box1, box2 )

	#Button pressed ?
	if buttonstate == 1:
		player.settag( 'trade_button', 1 )

	#Execute handler of specified type
	handler[type]( player, partner, box1, box2 )


	return True
Example #5
0
def attack_target(char, arguments, target):
	if not target.char or target.char == char:
		char.socket.sysmessage('Your pets cannot attack that.')
		return

	(pet, all) = arguments
	if all:
		for follower in char.followers:
			attack_target(char, [follower.serial, 0], target)
	else:
		pet = wolfpack.findchar(pet)
		if target.char == pet:
			char.socket.sysmessage('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 cant 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)
Example #6
0
def onPickup(player1, item):
	box1 = player1.itemonlayer(LAYER_TRADING)
	if not box1:
		return False

	if item.container != box1:
		return False

	if not player1.hastag('trade_partner'):
		return False

	player2 = wolfpack.findchar(int(player1.gettag('trade_partner')))
	if not player2:
		return False
	box2 = player2.itemonlayer(LAYER_TRADING)

	if not box2:
		return False

	player1.settag( 'trade_button', 0 )
	player2.settag( 'trade_button', 0 )

	# Reset the trading status and resend it
	# To me
	sendtradepacket( player1.socket, 2, box1.serial, 0, 0, "" )

	# To partner
	sendtradepacket( player2.socket, 2, box2.serial, 0, 0, "" )

	item.removefromview(True)

	return False
Example #7
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)
Example #8
0
def onLogin(player):
  if player.hastag('guildmessages'):
    count = int(player.gettag('guildmessages'))

    for i in range(0, count):
      name = 'guildmessage' + str(i)
      text = unicode(player.gettag(name))
      player.socket.sysmessage(text, 0x3A)
      player.deltag(name)
    player.deltag('guildmessages')

  # Make sure that this event is removed as soon as we don't are in a guild anymore
  if not player.guild:
    # Clean voting and or permissions
    tags = player.tags
    for tag in tags:
      if tag.startswith('vote_'):
        player.deltag(tag)
      elif tag.startswith('permissions_'):
        player.deltag(tag)

    player.removescript( 'guilds.member' )
  else:
    # Remove voting tags just in case
    if player.guild.leader:
      player.deltag('vote_%u' % player.guild.serial)

    members = player.guild.members
    online = []

    for member in members:
      if member != player and member.socket:
        online.append(member)

    if len(online) > 1:
      player.socket.sysmessage('There are %u other members of your guild logged on.' % len(online), 0x30)
    elif len(online) == 1:
      player.socket.sysmessage('There is one other member of your guild logged on.', 0x30)
    else:
      player.socket.sysmessage('There is no other member of your guild logged on.', 0x30)

    # Private messaging
    tags = player.tags

    for tag in tags:
      if tag.startswith('privmsg'):
        serial = int(tag[7:])
        char = wolfpack.findchar(serial)
        if char:
          chunks = getPrivateMessage(player, char)
          time_now = localtime()
          time_message = localtime(chunks[0])

          # Hide the date if it's from the same day
          if time_now[0] != time_message[0] or time_now[1] != time_message[1] or time_now[2] != time_message[2]:
            player.socket.sysmessage('[%s] %s: %s' % (strftime(FORMAT_DATETIME, time_message), char.name, chunks[2]), chunks[1])
          else:
            player.socket.sysmessage('[%s] %s: %s' % (strftime(FORMAT_TIME, time_message), char.name, chunks[2]), chunks[1])

        player.deltag(tag)
def response(player, arguments, response):
	if response.button == 0:
		return

	target = wolfpack.findchar(arguments[0])

	if not target:
		return False

	# Iterate trough all skills and see what changed
	for skill in range( 0, ALLSKILLS ):
		try:
			newvalue = int(floor(float(response.text[0x1000 | skill]) * 10))
			newcap = int(floor(float(response.text[0x2000 | skill]) * 10))
		except:
			player.socket.sysmessage('You have entered invalid values for %s.' % SKILLNAMES[skill])
			return False

		oldvalue = target.skill[skill]
		oldcap = target.skillcap[skill]

		if oldvalue != newvalue or oldcap != newcap:
			message = "Changed %s for character 0x%x to value %u [%d] and cap %u [%d].\n"
			message = message % (SKILLNAMES[skill], target.serial, newvalue, newvalue - oldvalue, newcap, newcap - oldcap)
			player.log(LOG_MESSAGE, message)
			player.socket.sysmessage(message)

			target.skill[skill] = newvalue
			target.skillcap[skill] = newcap
def onShowTooltip( viewer, object, tooltip ):
	if extended_carpentry:
		# Reinsert the name if we need a wood prefix
		prefix1 = None
		if object.hastag('resname'):
			resname = str(object.gettag('resname'))
			if resname in RESNAME_BONI:
				resinfo = RESNAME_BONI[resname]
				if MATERIALPREFIX in resinfo:
					prefix1 = resinfo[MATERIALPREFIX]
		elif object.hasstrproperty( 'resname' ):
			resname = str( object.getstrproperty( 'resname' ) )
			if resname in RESNAME_BONI:
				resinfo = RESNAME_BONI[resname]
				if MATERIALPREFIX in resinfo:
					prefix1 = resinfo[MATERIALPREFIX]

		prefix2 = None
		if object.hastag('resname2'):
			resname = str(object.gettag('resname2'))
			if resname in RESNAME_BONI:
				resinfo = RESNAME_BONI[resname]
				if MATERIALPREFIX in resinfo:
					prefix2 = resinfo[MATERIALPREFIX]
		elif object.hasstrproperty( 'resname2' ):
			resname = str( object.getstrproperty( 'resname2' ) )
			if resname in RESNAME_BONI:
				resinfo = RESNAME_BONI[resname]
				if MATERIALPREFIX in resinfo:
					prefix2 = resinfo[MATERIALPREFIX]

		if len(object.name) == 0:
			itemname = '#' + str(1020000 + object.id)
		else:
			itemname = object.name

		if prefix1 and prefix2:
			tooltip.reset()
			tooltip.add(1053099, "%s %s\t%s" % (prefix1, prefix2, itemname))
		elif prefix1 and not prefix2:
			tooltip.reset()
			tooltip.add(1053099, "%s\t%s" % (prefix1, itemname))
		elif not prefix1 and prefix2:
			tooltip.reset()
			tooltip.add(1053099, "%s\t%s" % (prefix2, itemname))
		# For containers (hardcoded type), add count of items and total weight
		if object.type == 1:
			tooltip.add(1050044, "%i\t%i" % (object.countitem(), object.totalweight))
		if object.lockeddown:
			tooltip.add(501643, "")

	# Exceptional item?
	if object.hastag('exceptional'):
		tooltip.add(1060636, '')

		# 1050043: Crafted by ~param~
		serial = int(object.gettag('exceptional'))
		crafter = wolfpack.findchar(serial)
		if crafter:
			tooltip.add(1050043, crafter.orgname)
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
Example #12
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, "%s (%s) updates his gm page [%s]:\n%s\n" % (char.name, page.account, page.category, "\n".join(page.message)))					
				else:					
					char.log(LOG_MESSAGE, "%s (%s) makes a gm page [%s]:\n%s\n" % (char.name, page.account, page.category, "\n".join(page.message)))
		
			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()
Example #13
0
def sendresponse2(player, arguments, target):
    if target.item:
        if target.item.container:
            return
        else:
            pos = target.item.pos
    elif target.char:
        pos = target.char.pos
    else:
        pos = target.pos

    if arguments[0] >= 0x40000000:
        object = wolfpack.finditem(arguments[0])
    else:
        object = wolfpack.findchar(arguments[0])

    if not object:
        return
    object.removefromview()
    object.moveto(pos)
    object.update()
    if not object.ischar() or not object.socket:
        return
    object.socket.resendworld()
    return
Example #14
0
def pages_gump(player):
	global pages
	pages.check() # Make sure all pages are valid
	
	gump = wolfpack.gumps.cGump()
	
	gump.startPage(0)
	
	# Gump Background
	gump.addBackground( 0xE10, 480, 360 ) # Background
	gump.addCheckerTrans( 15, 15, 450, 330 )
	
	# Gump Header
	gump.addGump( 180, 18, 0xFA8 )
	gump.addText( 215, 20, "Page Queue", 0x530 )

	# Close Button
	gump.addText( 70, 320, "Close", 0x834 )
	gump.addButton( 30, 320, 0xFB1, 0xFB3, 0 )

	count = (pages.count() + 9) / 10

	# Iterate this loop once for every page	
	for i in range(0, count):
		gump.startPage(i + 1)
		offset = 0

		for j in range(i * 10, i * 10 + 10):
			if j < pages.count():
				page = pages.pages[j]
				pagetype = page.type()

				if not page.assigned:
					gump.addButton( 20, 60 + offset, 0xFA5, 0xFA7, 1 + j )

				char = wolfpack.findchar(page.serial)

				if char.socket:
					gump.addText( 55, 60 + offset, "%s (%s)" % (char.name, page.account), 0x844 + 5 * pagetype )
					gump.addText( 200, 60 + offset, page.category, 0x844 + 5 * pagetype )
					gump.addText( 280, 60 + offset, time.strftime(FORMAT_DATETIME, time.localtime(page.created)), 0x844 + 5 * pagetype )
				else:
					gump.addText( 55, 60 + offset, "%s (%s)" % (char.name, page.account), 2100 )
					gump.addText( 200, 60 + offset, page.category, 2100 )
					gump.addText( 280, 60 + offset, time.strftime(FORMAT_DATETIME, time.localtime(page.created)), 21000 )
					
				offset += 20
				
		gump.addText( 280, 320, "Page %u of %u" % ( i + 1, count ), 0x834 )

		# Are we on the first page
		if i > 0:
			gump.addPageButton( 240, 320, 0x0FC, 0x0FC, i - 1 )

		# Would the next page be valid?
		if i + 1 < count:
			gump.addPageButton( 260, 320, 0x0FA, 0x0FA, i + 2 )

	gump.setCallback("system.pages.pages_gump_response")
	gump.send(player.socket)
Example #15
0
def endheal(char, arguments):
	socket = char.socket

	if not socket:
		return # Cancel healing if the player disconnected

	if char.dead:
		socket.clilocmessage(500962) # Died before finishing his work
		socket.deltag('bandage_slipped')
		return

	if socket.hastag('bandage_slipped'):
		slipped = int(socket.gettag('bandage_slipped')) # How many times the fingers slipped
	else:
		slipped = 0
	socket.deltag('bandage_slipped')

	# Retrieve arguments
	(primary, secondary, target) = arguments
	target = wolfpack.findchar(target)

	# Sanity checks again
	if not target or not char.canreach(target, 2):
		socket.clilocmessage(500963) # You did not stay close enough
		return

	if target.dead:
		resurrectTarget(char, target, primary, secondary, slipped) # Resurrection attempt
	elif target.poison != -1:
		cureTarget(char, target, primary, secondary, slipped) # Cure attempt
	elif system.bleeding.isbleeding(target):
		system.bleeding.end(target)
	else:
		healTarget(char, target, primary, secondary, slipped) # Heal attempt
Example #16
0
def onUse(player, item):
	if not item.getoutmostchar() == player:
		player.socket.sysmessage('The figurine needs to be in your posession to use it.')
		return 1

	if not item.hastag('pet'):
		item.delete()
		return 1

	try:
		pet = wolfpack.findchar(int(item.gettag('pet')))

		if not pet:
			item.deltag('pet')
			item.delete()
			return 1
	except:
		item.deltag('pet')
		item.delete()
		return 1

	# Remove pet reference and then delete
	item.deltag('pet')
	item.delete()

	pet.stablemaster = -1
	pet.moveto(player.pos)
	pet.update()
	pet.sound(SND_IDLE)
	pet.action(ANIM_CASTDIRECTED)
	return 1
Example #17
0
def stroke(player, arguments):
	(source, count) = arguments

	if player.dead or player.pos.map == 0xff:
		end(player, False) # End bleeding if dead, but dont message
	else:
		amount = random.randint(count, count * 2)
		if player.npc:
			amount *= 2

		player.soundeffect(0x133)
		player.damage(DAMAGE_GODLY, amount, wolfpack.findchar(source)) 

		if player.pos.map != 0xff:
			blood = wolfpack.additem(random.choice(BLOOD))
			blood.movable = 3 # Not movable
			blood.decay = True # Make it decay
			blood.moveto(player.pos)
			blood.update()

	# There are still strokes left	
	if count > 1 and not player.dead and player.pos.map != 0xff:
		player.addtimer(TIMERINTERVAL, stroke, [source, count - 1], False, False, TIMERID)
	else:
		end(player)
Example #18
0
def stroke(player, arguments):
	(source, count) = arguments

	if player.dead or player.pos.map == 0xff:
		end(player, False) # End bleeding if dead, but dont message
	else:
		amount = random.randint(count, count * 2)
		if player.npc:
			amount *= 2

		player.soundeffect(0x133)
		player.damage(DAMAGE_GODLY, amount, wolfpack.findchar(source)) 

		if player.pos.map != 0xff:
			blood = wolfpack.additem(random.choice(BLOOD))
			blood.movable = 3 # Not movable
			blood.decay = True # Make it decay
			blood.moveto(player.pos)
			blood.update()

	# There are still strokes left	
	if count > 1 and not player.dead and player.pos.map != 0xff:
		player.addtimer(TIMERINTERVAL, stroke, [source, count - 1], False, False, TIMERID)
	else:
		end(player)
Example #19
0
def gump11(char, callback, item):
    # security remove a co owner
    gump_params = ["a house", "sign"]

    mygump = cGump()
    mygump.addRawLayout("{page 0}")
    mygump.addRawLayout("{resizepic 0 0 5054 420 440}")
    mygump.addRawLayout("{gumppictiled 10 10 400 100 2624}")
    mygump.addRawLayout("{checkertrans 10 10 400 100}")
    mygump.addRawLayout("{gumppictiled 10 120 400 260 2624}")
    mygump.addRawLayout("{checkertrans 10 120 400 260}")
    mygump.addRawLayout("{gumppictiled 10 390 400 40 2624}")
    mygump.addRawLayout("{checkertrans 10 390 400 40}")
    mygump.addRawLayout("{button 250 410 4005 4007 1 0 0}")
    mygump.addRawLayout("{xmfhtmlgumpcolor 285 410 240 20 1060675 0 0 32767}")
    mygump.addRawLayout("{gumppic 10 10 100}")
    mygump.addRawLayout("{text 62 43 0 0}")
    mygump.addRawLayout("{text 74 57 0 1}")
    # remove button cause change of callback
    # ~ mygump.addRawLayout( "{button 10 390 4005 4007 1 0 31}" )
    mygump.addRawLayout("{xmfhtmlgumpcolor 45 390 240 20 1060676 0 0 32767}")
    # ~ mygump.addRawLayout( "{button 10 410 4005 4007 1 0 46}" )
    mygump.addRawLayout("{xmfhtmlgumpcolor 45 410 240 20 1060677 0 0 32767}")
    # ~ mygump.addRawLayout( "{button 150 10 4005 4007 1 0 2}" )
    mygump.addRawLayout("{xmfhtmlgumpcolor 195 10 200 20 1060668 0 0 32767}")
    # ~ mygump.addRawLayout( "{button 150 30 4006 4007 1 0 17}" )
    mygump.addRawLayout("{xmfhtmlgumpcolor 195 30 200 20 1060669 0 0 16927}")
    # ~ mygump.addRawLayout( "{button 150 50 4005 4007 1 0 32}" )
    mygump.addRawLayout("{xmfhtmlgumpcolor 195 50 200 20 1060670 0 0 32767}")
    # ~ mygump.addRawLayout( "{button 150 70 4005 4007 1 0 47}" )
    mygump.addRawLayout("{xmfhtmlgumpcolor 195 70 200 20 1060671 0 0 32767}")
    # ~ mygump.addRawLayout( "{button 150 90 4005 4007 1 0 62}" )
    mygump.addRawLayout("{xmfhtmlgumpcolor 195 90 200 20 1060672 0 0 32767}")  # end of common part with gump0
    # mygump.addRawLayout( "{button 10 130 4005 4007 1 0 4}" ) # button see title next line
    mygump.addRawLayout("{xmfhtmlgumpcolor 45 130 240 20 1011274 0 0 32767}")  # View Remove a co-owner from the house
    # ~ mygump.addRawLayout( "{text 45 170 1152 2}" )#~ mygump.addRawLayout( "{text 45 150 1152 2}" ) #ecrit le parametre 2 en blanc

    offsetx = 0
    offsety = 0
    members = getCoOwners(item.multi)
    # ~ char.socket.sysmessage('liste %s'%members)
    for memberserial in members:
        try:
            member = wolfpack.findchar(int(memberserial))
            mygump.addButton(15 + offsety, 150 + offsetx, 0xFA5, 0xFA7, member.serial)
            # ~ mygump.addText( 15 +offsety, 150+offsetx, unicode(' *'), 1152)
            mygump.addText(49 + offsety, 150 + offsetx, unicode(member.name), 1152)
            if offsetx == 192:
                offsetx = 0
                offsety += 200
            else:
                offsetx += 24
        except:
            pass
    mygump.setCallback(callbackremovecoowner)
    mygump.setArgs([item])
    # Add params
    for line in gump_params:
        mygump.addRawText(line)
    mygump.send(char)
Example #20
0
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 ), potioncountdown, [ char.serial, 10, int( bomb.gettag( 'kegfill' ) ) ] )
	else:
		bomb.addtimer( randint( 1000, 2250 ), potioncountdown, [ char.serial, 0, bomb.amount ] )
	return True
Example #21
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)
Example #22
0
def onUse(player, item):
	if not item.getoutmostchar() == player:
		player.socket.sysmessage(tr('The figurine needs to be in your posession to use it.'))
		return 1

	if not item.hastag('pet'):
		item.delete()
		return 1

	try:
		pet = wolfpack.findchar(int(item.gettag('pet')))

		if not pet:
			item.deltag('pet')
			item.delete()
			return 1
	except:
		item.deltag('pet')
		item.delete()
		return 1

	# Remove pet reference and then delete
	item.deltag('pet')
	item.delete()

	pet.removescript('figurine')
	pet.owner = player
	pet.stablemaster = 0
	pet.wandertype = 0 # Stay where you are...
	pet.direction = player.direction
	pet.moveto(player.pos)
	pet.update()
	pet.sound(SND_IDLE)
	pet.action(ANIM_CASTDIRECTED)
	return 1
Example #23
0
def sendresponse2(player, arguments, target):
    if target.item:
        if target.item.container:
            return
        else:
            pos = target.item.pos
    elif target.char:
        pos = target.char.pos
    else:
        pos = target.pos

    if arguments[0] >= 0x40000000:
        object = wolfpack.finditem(arguments[0])
    else:
        object = wolfpack.findchar(arguments[0])

    if not object:
        return
    object.removefromview()
    object.moveto(pos)
    object.update()
    if not object.ischar() or not object.socket:
        return
    object.socket.resendworld()
    return
Example #24
0
def gump12( char, callback, item ):
	#security view friends list
	gump_params = [
	"a house",
	"sign"]

	mygump = cGump()
	mygump.addRawLayout( "{page 0}" )
	mygump.addRawLayout( "{resizepic 0 0 5054 420 440}" )
	mygump.addRawLayout( "{gumppictiled 10 10 400 100 2624}" )
	mygump.addRawLayout( "{checkertrans 10 10 400 100}" )
	mygump.addRawLayout( "{gumppictiled 10 120 400 260 2624}" )
	mygump.addRawLayout( "{checkertrans 10 120 400 260}" )
	mygump.addRawLayout( "{gumppictiled 10 390 400 40 2624}" )
	mygump.addRawLayout( "{checkertrans 10 390 400 40}" )
	mygump.addRawLayout( "{button 250 410 4005 4007 1 0 0}" )
	mygump.addRawLayout( "{xmfhtmlgumpcolor 285 410 240 20 1060675 0 0 32767}" )
	mygump.addRawLayout( "{gumppic 10 10 100}" )
	mygump.addRawLayout( "{text 62 43 0 0}" )
	mygump.addRawLayout( "{text 74 57 0 1}" )
	mygump.addRawLayout( "{button 10 390 4005 4007 1 0 31}" )
	mygump.addRawLayout( "{xmfhtmlgumpcolor 45 390 240 20 1060676 0 0 32767}" )
	mygump.addRawLayout( "{button 10 410 4005 4007 1 0 46}" )
	mygump.addRawLayout( "{xmfhtmlgumpcolor 45 410 240 20 1060677 0 0 32767}" )
	mygump.addRawLayout( "{button 150 10 4005 4007 1 0 2}" )
	mygump.addRawLayout( "{xmfhtmlgumpcolor 195 10 200 20 1060668 0 0 32767}" )
	mygump.addRawLayout( "{button 150 30 4006 4007 1 0 17}" )
	mygump.addRawLayout( "{xmfhtmlgumpcolor 195 30 200 20 1060669 0 0 16927}" )
	mygump.addRawLayout( "{button 150 50 4005 4007 1 0 32}" )
	mygump.addRawLayout( "{xmfhtmlgumpcolor 195 50 200 20 1060670 0 0 32767}" )
	mygump.addRawLayout( "{button 150 70 4005 4007 1 0 47}" )
	mygump.addRawLayout( "{xmfhtmlgumpcolor 195 70 200 20 1060671 0 0 32767}" )
	mygump.addRawLayout( "{button 150 90 4005 4007 1 0 62}" )
	mygump.addRawLayout( "{xmfhtmlgumpcolor 195 90 200 20 1060672 0 0 32767}" ) #end of common part with gump0
	#mygump.addRawLayout( "{button 10 130 4005 4007 1 0 4}" ) # button see title next line
	mygump.addRawLayout( "{xmfhtmlgumpcolor 45 130 240 20 1011243 0 0 32767}" ) #View friend List
	
	offsetx = 0
	offsety= 0
	members = getFriends(item.multi)
	for memberserial in members:
		try :
			member = wolfpack.findchar(int(memberserial))
			#~ mygump.addButton( 15 +offsety, 150+offsetx, 0xFA5, 0xFA7, member.serial )
			mygump.addText( 15 +offsety, 150+offsetx, unicode(' *'), 1152)
			mygump.addText(49 +offsety, 150+offsetx, unicode(member.name), 1152)
			if offsetx == 192:
				offsetx = 0
				offsety += 200
			else:
				offsetx += 24			
		except:
			pass
	mygump.setCallback( callback )
	mygump.setArgs( [item] )
	#Add params
	for line in gump_params:
		mygump.addRawText( line )
	mygump.send( char )
Example #25
0
def getmoney(char, args):
    npc = wolfpack.findchar(args[0])
    if not npc:
        return False

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

    theirPack = npc.getbackpack()
    badKarmaChance = 0.5 - float(char.karma / 8570)

    if not theirPack:
        char.socket.clilocmessage(
            500404)  # They seem unwilling to give you any money.
    elif char.karma < 0 and badKarmaChance > random.random():
        npc.say(
            500406,
            "")  # Thou dost not look trustworthy... no gold for thee today!
    elif char.checkskill(BEGGING, 0, 1000):
        toConsume = npc.countresource(wolfpack.utilities.hex2dec(0xeed)) / 10
        max = 10 + (char.fame / 2500)
        if max > 14:
            max = 14
        elif max < 10:
            max = 10

        if toConsume > max:
            toConsume = max
        if toConsume > 0:
            consumed = npc.useresource(toConsume, 0x0eed)
            if consumed > 0:
                npc.say(500405)  # I feel sorry for thee...
                coins = wolfpack.additem(GOLD_COIN1)
                coins.amount = toConsume
                if not tobackpack(coins, char):
                    coins.update()
                coins.update()
                sound = 0
                if toConsume <= 1:
                    sound = 0x2e4
                elif toConsume <= 5:
                    sound = 0x2e5
                else:
                    sound = 0x2e6
                char.soundeffect(sound)
                if char.karma > -3000:
                    toLose = char.karma + 3000

                    if toLose > 40:
                        toLose = 40
                    char.awardkarma(-toLose)
            else:
                npc.say(500407)  # I have not enough money to give thee any!
        else:
            npc.say(500407)  # I have not enough money to give thee any!
    else:
        npc.say(500404)  # They seem unwilling to give you any money.

    return True
Example #26
0
def onLogout( player ):
	if player.hastag( 'trade_partner' ):
		partner = wolfpack.findchar( player.gettag( 'trade_partner' ) )
		box2 = partner.itemonlayer( LAYER_TRADING )
		box1 = player.itemonlayer( LAYER_TRADING )
		closetrade( player, partner, box1, box2 )

	return True
def onShowTooltip(player, object, tooltip):
	if object.hastag('animalweight') and object.gettag('animalweight') >= 20:
		if object.hastag('hunter'):
			serial = int(object.gettag('hunter'))
			hunter = wolfpack.findchar(serial)
			if hunter:
				tooltip.add( 1070857, hunter.orgname ) # Caught by ~1_fisherman~
		tooltip.add( 1070858, str(object.gettag('animalweight')) ) # ~1_weight~ stones
Example #28
0
def response(player, args, choice):
	pet = wolfpack.findchar(args[0])
	if not pet:
		return False
	if choice.button == 0:
		return False
	if choice.button == 1:
		release(pet)
	return True
Example #29
0
def onShowTooltip(player, object, tooltip):
    if object.hastag('animalweight') and object.gettag('animalweight') >= 20:
        if object.hastag('hunter'):
            serial = int(object.gettag('hunter'))
            hunter = wolfpack.findchar(serial)
            if hunter:
                tooltip.add(1070857, hunter.orgname)  # Caught by ~1_fisherman~
        tooltip.add(1070858,
                    str(object.gettag('animalweight')))  # ~1_weight~ stones
Example #30
0
def gump12(char, callback, item):
    # security view friends list
    gump_params = ["a house", "sign"]

    mygump = cGump()
    mygump.addRawLayout("{page 0}")
    mygump.addRawLayout("{resizepic 0 0 5054 420 440}")
    mygump.addRawLayout("{gumppictiled 10 10 400 100 2624}")
    mygump.addRawLayout("{checkertrans 10 10 400 100}")
    mygump.addRawLayout("{gumppictiled 10 120 400 260 2624}")
    mygump.addRawLayout("{checkertrans 10 120 400 260}")
    mygump.addRawLayout("{gumppictiled 10 390 400 40 2624}")
    mygump.addRawLayout("{checkertrans 10 390 400 40}")
    mygump.addRawLayout("{button 250 410 4005 4007 1 0 0}")
    mygump.addRawLayout("{xmfhtmlgumpcolor 285 410 240 20 1060675 0 0 32767}")
    mygump.addRawLayout("{gumppic 10 10 100}")
    mygump.addRawLayout("{text 62 43 0 0}")
    mygump.addRawLayout("{text 74 57 0 1}")
    mygump.addRawLayout("{button 10 390 4005 4007 1 0 31}")
    mygump.addRawLayout("{xmfhtmlgumpcolor 45 390 240 20 1060676 0 0 32767}")
    mygump.addRawLayout("{button 10 410 4005 4007 1 0 46}")
    mygump.addRawLayout("{xmfhtmlgumpcolor 45 410 240 20 1060677 0 0 32767}")
    mygump.addRawLayout("{button 150 10 4005 4007 1 0 2}")
    mygump.addRawLayout("{xmfhtmlgumpcolor 195 10 200 20 1060668 0 0 32767}")
    mygump.addRawLayout("{button 150 30 4006 4007 1 0 17}")
    mygump.addRawLayout("{xmfhtmlgumpcolor 195 30 200 20 1060669 0 0 16927}")
    mygump.addRawLayout("{button 150 50 4005 4007 1 0 32}")
    mygump.addRawLayout("{xmfhtmlgumpcolor 195 50 200 20 1060670 0 0 32767}")
    mygump.addRawLayout("{button 150 70 4005 4007 1 0 47}")
    mygump.addRawLayout("{xmfhtmlgumpcolor 195 70 200 20 1060671 0 0 32767}")
    mygump.addRawLayout("{button 150 90 4005 4007 1 0 62}")
    mygump.addRawLayout("{xmfhtmlgumpcolor 195 90 200 20 1060672 0 0 32767}")  # end of common part with gump0
    # mygump.addRawLayout( "{button 10 130 4005 4007 1 0 4}" ) # button see title next line
    mygump.addRawLayout("{xmfhtmlgumpcolor 45 130 240 20 1011243 0 0 32767}")  # View friend List

    offsetx = 0
    offsety = 0
    members = getFriends(item.multi)
    for memberserial in members:
        try:
            member = wolfpack.findchar(int(memberserial))
            # ~ mygump.addButton( 15 +offsety, 150+offsetx, 0xFA5, 0xFA7, member.serial )
            mygump.addText(15 + offsety, 150 + offsetx, unicode(" *"), 1152)
            mygump.addText(49 + offsety, 150 + offsetx, unicode(member.name), 1152)
            if offsetx == 192:
                offsetx = 0
                offsety += 200
            else:
                offsetx += 24
        except:
            pass
    mygump.setCallback(callback)
    mygump.setArgs([item])
    # Add params
    for line in gump_params:
        mygump.addRawText(line)
    mygump.send(char)
Example #31
0
def checkLoS( object1, object2, rangecheck=10 ):
	# Char -> Char Check
	if ( object1.ischar() and object2.ischar() ):
		char1 = wolfpack.findchar(object1.serial)
		char2 = wolfpack.findchar(object2.serial)
		if not char1.cansee(char2):
			return False
		if char1.distanceto(char2) > rangecheck:
			return False
		if not char1.canreach(char2, rangecheck):
			return False
		return True
	# Item -> Item Check
	elif ( object1.isitem() and object2.isitem() ):
		item1 = wolfpack.finditem(object1.serial)
		item2 = wolfpack.finditem(object2.serial)
		if item1.distanceto(item2) > rangecheck:
			return False
		return True
	# Char -> Item Check
	elif ( object1.ischar() and object2.isitem() ):
		char = wolfpack.findchar(object1.serial)
		item = wolfpack.finditem(object2.serial)
		if not char.cansee(item):
			return False
		if (char.distanceto(item) > rangecheck) or (item.distanceto(char) > rangecheck):
			return False
		if not char.canreach(item, rangecheck):
			return False
		return True
	# Item -> Char Check
	elif ( object1.isitem() and object2.ischar() ):
		item = wolfpack.finditem(object1.serial)
		char = wolfpack.findchar(object2.serial)
		if not char.cansee(item):
			return False
		if (item.distanceto(char) > rangecheck) or (char.distanceto(item) > rangecheck):
			return False
		if not char.canreach(item, rangecheck):
			return False
		return True
	# Failed Object Check
	else:
		return False
def checkLoS( object1, object2, rangecheck=10 ):
	# Char -> Char Check
	if ( object1.ischar() and object2.ischar() ):
		char1 = wolfpack.findchar(object1.serial)
		char2 = wolfpack.findchar(object2.serial)
		if not char1.cansee(char2):
			return 0
		if char1.distanceto(char2) > rangecheck:
			return 0
		if not char1.canreach(char2, rangecheck):
			return 0
		return 1
	# Item -> Item Check
	elif ( object1.isitem() and object2.isitem() ):
		item1 = wolfpack.finditem(object1.serial)
		item2 = wolfpack.finditem(object2.serial)
		if item1.distanceto(item2) > rangecheck:
			return 0
		return 1
	# Char -> Item Check
	elif ( object1.ischar() and object2.isitem() ):
		char = wolfpack.findchar(object1.serial)
		item = wolfpack.finditem(object2.serial)
		if not char.cansee(item):
			return 0
		if (char.distanceto(item) > rangecheck) or (item.distanceto(char) > rangecheck):
			return 0
		if not char.canreach(item, rangecheck):
			return 0
		return 1
	# Item -> Char Check
	elif ( object1.isitem() and object2.ischar() ):
		item = wolfpack.finditem(object1.serial)
		char = wolfpack.findchar(object2.serial)
		if not char.cansee(item):
			return 0
		if (item.distanceto(char) > rangecheck) or (char.distanceto(item) > rangecheck):
			return 0
		if not char.canreach(item, rangecheck):
			return 0
		return 1
	# Failed Object Check
	else:
		return 0
def furniture_tooltip(viewer, object, tooltip):
    	# Exceptional item?
	if object.hastag('exceptional'):
		tooltip.add(1060636, '')

		# 1050043: Crafted by ~param~
		serial = int(object.gettag('exceptional'))
		crafter = wolfpack.findchar(serial)
		if crafter:
			tooltip.add(1050043, crafter.name)
Example #34
0
def friends(pet):
    friend = []
    for tag in pet.tags:
        if tag.startswith("friend_"):
            char = wolfpack.findchar(int(tag.split("_")[1]))
            # always check on deleted chars every time friends(pet) is called
            if not char:
                pet.deltag(tag)
            friend.append(char)
    return friend
Example #35
0
def callbackWho( char, args, choice ):
	wholist = args[0]
	if choice.button == 0:
		return False
	elif wholist[ choice.button - 10 ]:
		player = wolfpack.findchar( wholist[ choice.button - 10 ] )
		details(char, player)
		return True
	else:
		return False
Example #36
0
def friends(pet):
    friend = []
    for tag in pet.tags:
        if tag.startswith("friend_"):
            char = wolfpack.findchar(int(tag.split("_")[1]))
            # always check on deleted chars every time friends(pet) is called
            if not char:
                pet.deltag(tag)
            friend.append(char)
    return friend
Example #37
0
def getmoney( char, args ):
	npc = wolfpack.findchar( args[0] )
	if not npc:
		return False

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

	theirPack = npc.getbackpack()
	badKarmaChance = 0.5 - float(char.karma / 8570)

	if not theirPack:
		char.socket.clilocmessage( 500404 ) # They seem unwilling to give you any money.
	elif char.karma < 0 and badKarmaChance > random.random():
		npc.say( 500406, "" ) # Thou dost not look trustworthy... no gold for thee today!
	elif char.checkskill( BEGGING, 0, 1000 ):
		toConsume = npc.countresource( wolfpack.utilities.hex2dec( 0xeed ) ) / 10
		max = 10 + (char.fame / 2500)
		if max > 14:
			max = 14
		elif max < 10:
			max = 10

		if toConsume > max:
			toConsume = max
		if toConsume > 0:
			consumed = npc.useresource( toConsume, 0x0eed )
			if consumed > 0:
				npc.say( 500405 ) # I feel sorry for thee...
				coins = wolfpack.additem( GOLD_COIN1 )
				coins.amount = toConsume
				if not tobackpack(coins, char):
					coins.update()
				coins.update()
				sound = 0
				if toConsume <= 1:
					sound = 0x2e4
				elif toConsume <= 5:
					sound = 0x2e5
				else:
					sound = 0x2e6
				char.soundeffect(sound)
				if char.karma > -3000:
					toLose = char.karma + 3000

					if toLose > 40:
						toLose = 40
					char.awardkarma( -toLose )
			else:
				npc.say( 500407 ) # I have not enough money to give thee any!
		else: 
			npc.say( 500407 ) # I have not enough money to give thee any!
	else:
		npc.say( 500404 ) # They seem unwilling to give you any money.

	return True
Example #38
0
def callbackSocket( char, args, choice ):
	socket = char.socket
	player = wolfpack.findchar( args[0] )
	textentries = choice.text
	keys = textentries.keys()
	# Cancel
	if choice.button == 0:
		return False
	# Follow
	elif choice.button == 8:
		commands.follow.who_target( char, args, args[0] )
		return True
	# Disconnect
	elif choice.button == 7:
		player.socket.disconnect()
		return True
	# Send Message
	elif choice.button == 6:
		if 1 in keys:
			if player.socket:
				player.socket.sysmessage( tr('A private message from %s: %s') % (char.name, textentries[ 1 ]), char.saycolor )
				socket.sysmessage( 'You sent the following message: %s' % textentries[ 1 ], char.saycolor )
			else:
				socket.sysmessage( "The Player has left. Message not sent." )
		return True
	# Char Info
	elif choice.button == 5:
		commands.info.charinfo( socket, player )
		return True
	# Forgive player
	elif choice.button == 4:
		commands.jail.jailPlayer(char, player, False)
		return True
	# Jail player
	elif choice.button == 3:
		commands.jail.jailPlayer(char, player, True)
		return True
	# Bring player
	elif choice.button == 2:
		if player.serial != char.serial:
			player.removefromview()
			player.moveto(char.pos)
			player.update()
			player.socket.resendworld()
		return True
	# Go to player
	elif choice.button == 1:
		if player.serial != char.serial:
			char.removefromview()
			char.moveto(player.pos)
			char.update()
			char.socket.resendworld()
		return True

	return True
Example #39
0
	def load(self):
		count = int(wolfpack.getoption('pages', '0'))
		for i in range(1, count+1):
			pagestr = wolfpack.getoption('page_%u' % i, '')
			if pagestr == '':
				continue
			page = Page(pagestr)
			
			char = wolfpack.findchar(page.serial)
			if char:			
				self.add(page, False)
Example #40
0
    def load(self):
        count = int(wolfpack.getoption('pages', '0'))
        for i in range(1, count + 1):
            pagestr = wolfpack.getoption('page_%u' % i, '')
            if pagestr == '':
                continue
            page = Page(pagestr)

            char = wolfpack.findchar(page.serial)
            if char:
                self.add(page, False)
	def get(self):
		if self.serial > 0 and self.serial < 0x40000000:
			char = wolfpack.findchar(self.serial)
			if not char.free:
				return char
		elif serial > 0x40000000:
			item = wolfpack.finditem(self.serial)
			if not item.free:
				return item

		return None
Example #42
0
	def get(self):
		if self.serial > 0 and self.serial < 0x40000000:
			char = wolfpack.findchar(self.serial)
			if not char.free:
				return char
		elif serial > 0x40000000:
			item = wolfpack.finditem(self.serial)
			if not item.free:
				return item

		return None
Example #43
0
def callbackremovefriend( char,args , choice):
	item = args[0]
	#~ elif choice.button > 2:
	serial = choice.button
	if serial ==0:
		return
	player = wolfpack.findchar(serial)
	#~ details(char, player)
	removeFriend(item.multi, player)
	char.socket.sysmessage('You have just remove %s from the friends list'%player.name)
	return
Example #44
0
def trackWhoResponse(char, args, response):
    # Button is 0?
    if response.button == 0:
        return True

    # Retrieve List and npc
    list = args[0]
    ran = args[1]
    npc = wolfpack.findchar(response.button)
    # Send the Arrow
    sendQuestArrow(char, npc, ran)
Example #45
0
	def notification(self, updated = False):
		char = wolfpack.findchar(self.serial)
		if not char:
			return None
				
		if not updated:
			result = "New %s page from '%s' on account '%s':" % (self.category, char.name, self.account)
		else:
			result = "Updated %s page from '%s' on account '%s':" % (self.category, char.name, self.account)

		return result
Example #46
0
def changehairhue_response(char, arguments, response):
	(vendor, entries, layers, price) = arguments
	vendor = wolfpack.findchar(vendor)

	if not vendor:
		return

	if response.button == 0 or len(response.switches) == 0:
		vendor.say(1013009, "", "", False, vendor.saycolor, char.socket)		
		return	

	# Get the hair color
	index = int(response.switches[0] % len(entries))
	offset = int(response.switches[0] / len(entries))

	if index >= len(entries):
		vendor.say(1013009, "", "", False, vendor.saycolor, char.socket)		
		return

	if offset >= entries[index][2]:
		vendor.say(1013009, "", "", False, vendor.saycolor, char.socket)
		return

	hue = entries[index][1] + offset

	gold = char.getbackpack().countitems(['eed'])
	gold += char.getbankbox().countitems(['eed'])

	if price > gold and not char.gm:
		vendor.say(1042293, "", "", False, vendor.saycolor, char.socket)
		return

	found = False
	items = []
	for layer in layers:
		item = char.itemonlayer(layer)
		if item:
			found = True
			items.append(item)

	if not found:
		vendor.say(502623, "", "", False, vendor.saycolor, char.socket)
		return

	if not char.gm:
		rest = char.getbackpack().removeitems(['eed'], arguments[3])
		if rest != 0:
			char.getbankbox().removeitems(['eed'], rest)

	for item in items:
		item.color = hue
		item.update()
Example #47
0
def potiondamage( cserial, target, iserial, dmgbonus, potiontype ):
	char = wolfpack.findchar( cserial )
	item = wolfpack.finditem( iserial )

	if not item or not char:
		return False

	# Damage Range
	if potiontype == 11:
		damage = randint( POTION_LESSEREXPLOSION_RANGE[0], POTION_LESSEREXPLOSION_RANGE[1] )
	elif potiontype == 12:
		damage = randint( POTION_EXPLOSION_RANGE[0], POTION_EXPLOSION_RANGE[1] )
	elif potiontype == 13:
		damage = randint( POTION_GREATEREXPLOSION_RANGE[0], POTION_GREATEREXPLOSION_RANGE[1] )
	else:
		damage = randint( POTION_LESSEREXPLOSION_RANGE[0], POTION_GREATEREXPLOSION_RANGE[1] )

	# Bonuses
	if char.skill[ALCHEMY] == 1200:
		bonus = 10
	elif char.skill[ALCHEMY] >= 1100:
		bonus = randint(8,9)
	elif char.skill[ALCHEMY] >= 1000:
		bonus = randint(6,7)
	else:
		bonus = randint(0,5)
	if item.amount > 1:
		damage = damage * item.amount
	if dmgbonus > 1:
		damage *= dmgbonus
	damage += bonus

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

	if not item.container:
		if target.distanceto( item ) > 1:
			damage = ( damage / target.distanceto( item ) )

	# Flamestrike effect
	if damage >= ( target.maxhitpoints / 2 ):
		target.effect(0x3709, 10, 30)
	target.effect( explosions[randint(0,2)], 20, 10)

	# Let the target defend himself if he isn't fighting yet
	if not target.attacktarget:
		target.fight(char)

	energydamage(target, char, damage, fire=100 )
	return
Example #48
0
def onCollide(char, item):
    if char.dead or char.invulnerable or char.region.safe:
        return

    if not char.hastag('in_firefield'):
        source = None
        if item.hastag('source'):
            source = wolfpack.findchar(int(item.gettag('source')))

        char.settag('in_firefield', 1)
        energydamage(char, source, 2, fire=100)
        char.addtimer(350, expire, [])
    return 0
Example #49
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
Example #50
0
def dofollow(player, target):
	char = wolfpack.findchar(target)
	if char.rank > player.rank:
		player.socket.sysmessage(tr('You better don''t do that.'))
		return

	message = tr('Started following 0x%x.') % char.serial
	player.socket.sysmessage(message)
	player.socket.log(LOG_MESSAGE, message + "\n")
	player.socket.settag('follow_target', char.serial)
	player.dispel(None, True, 'FOLLOW_TIMER')
	player.addtimer(1500, timer, [], False, False, 'FOLLOW_TIMER')
	return
Example #51
0
def delay(char, args):
    target = wolfpack.findchar(args[0])
    if not target:
        return False
    new_bola = wolfpack.additem("26ac")
    new_bola.moveto(target.pos)
    new_bola.update()

    target.damage(1, 1, char)
    target.unmount()
    if target.socket:
        target.socket.clilocmessage(
            1040023)  # You have been knocked off of your mount!
    return True
Example #52
0
def addvendor(player, arguments, target):
	if target.item and target.item.container:
		player.socket.sysmessage("You can't add the npc there.")
		return

	owner = wolfpack.findchar(arguments[1])
	if not owner:
		player.socket.sysmessage(u'Ooops. Da ist was schief gelaufen. Oder der Owner wurde gerade gelöscht. So kann ich nicht Arbeiten!')
		return
	npc = wolfpack.addnpc(str(arguments[0]), target.pos)
	npc.owner = owner
	npc.invulnerable = True
	npc.update()
	
	player.log(LOG_MESSAGE, "Adds %s's Playervendor (0x%x) at %s.\n" % (owner.orgname, npc.serial, str(target.pos)))
Example #53
0
def callbackWho( char, args, choice ):
	page = args[0]

	# Next page
	if choice.button == 1:
		showWhoGump(char, page + 1)

	elif choice.button == 2 and page > 0:
		showWhoGump(char, page - 1)

	elif choice.button > 2:
		serial = choice.button - 2
		player = wolfpack.findchar(serial)
		details(char, player)
	return
Example #54
0
def gothere(char, args, target):
    pet = wolfpack.findchar(args[0])
    if not pet:
        return False
    if not char.canreach(target.pos, 10):
        return False
    if not char.checkskill(HERDING, 0, 1000):
        char.socket.clilocmessage(
            502472)  # You don't seem to be able to persuade that to move.
        return False

    char.socket.clilocmessage(
        502479)  # The animal walks where it was instructed to.
    pet.goto(target.pos)
    pet.sound(SND_ATTACK)
    return
Example #55
0
def checkPayment(serials):	
	partition = serials[:50] # Process 50 vendors
	rest = serials[50:]
		
	# Queue up the rest of the serials
	if len(rest) > 0:
		wolfpack.queuecode(checkPayment, (rest,))
	else:
		# Finished processing
		global paymentthread
		paymentthread.mutex.acquire()
		paymentthread.processed = True
		paymentthread.mutex.release()
	
	for serial in partition:
		vendor = wolfpack.findchar(serial)
		if vendor:
			npc.playervendor.checkPayment(vendor)
Example #56
0
def incomingSellPacket(socket, packet):
    player = socket.player
    size = packet.getshort(1)

    if size < 9:
        return True  # Bogous packet

    vendor = wolfpack.findchar(packet.getint(3))  # Find the vendor

    if not vendor or vendor == player:
        closeBuyGump(vendor, player)
        return True  # Invalid sell packet

    count = packet.getshort(7)  # Number of items following

    if count == 0:
        closeBuyGump(vendor, player)
        return True  # No Items sold

    # Validate packet size
    if size != 9 + count * 6:
        socket.sysmessage('You sent an invalid vendor sell packet.')
        return True  # invalid packet

    offset = 9
    sold = []  # List of tuples (item, amount)

    for i in range(0, count):
        item = wolfpack.finditem(packet.getint(offset))
        amount = packet.getshort(offset + 4)
        offset += 6

        # Check if the item can really be sold by the player
        if item and item.getoutmostchar() == player:
            sold.append((item, amount))

    # We collected the list of sold items here.
    # Forward it to the vendor.
    vclass = npc.vendor.getClassFromVendor(vendor)

    if vclass and vclass.onSellItems(vendor, player, sold):
        closeBuyGump(vendor, player)

    return True