Ejemplo n.º 1
0
	def summoner_thread(self):
		while True:
			player = utility.get_my_player()
			if player == None:
				#print 'No summoner unit'
				time.sleep(configuration.summoner_check_delay)
				continue
			break
				
		if player.name not in configuration.summoners:
			#print 'This is not a summoner'
			return
			
		while True:
			my_unit = utility.get_my_unit()
			if my_unit == None:
				print 'Unable to retrieve summoner unit'
				return
				
			standing_still = my_unit.mode == 1
			if standing_still and not utility.town_check():
				targets = self.get_targets()
				if len(targets) == 0:
					craw.print_text('There are no nearby corpses')
				else:
					target = random.choice(targets)
					description, skill = random.choice(skills)
					craw.print_text('%s: %08x' % (description, target))
					packets.set_right_skill(skill)
					time.sleep(configuration.summoner_switch_delay)
					packets.cast_right_skill_at_target(1, target)
					time.sleep(configuration.summoner_cast_delay)
					continue
				
			time.sleep(configuration.summoner_check_delay)
Ejemplo n.º 2
0
	def life_check(self, bytes):
		if len(bytes) < 3:
			return
			
		configuration.chicken_data = craw.get_life()
		if configuration.chicken_data == None:
			return
			
		current_life, maximal_life = configuration.chicken_data
		
		if maximal_life > 0 and maximal_life < self.last_maximal_life and self.last_maximal_life != None:
			craw.print_text('Warning: Maximal life decreased to %d' % maximal_life)
			
		self.last_maximal_life = maximal_life
			
		if bytes[0] not in [0x18, 0x95]:
			return
			
		new_life = utility.read_bytes(bytes, 1, 2) & 0x7fff
		if new_life >= current_life:
			return
			
		damage = current_life - new_life
		ratio = float(new_life) / maximal_life
		percent = '%.2f%%' % (ratio * 100)
		
		if new_life == maximal_life:
			#hack for a strange bug
			return
		
		#print time.time()
		print '%d damage, %d/%d left (%s)' % (damage, new_life, maximal_life, percent)
		for damage_handler in self.damage_handlers:
			damage_handler(damage, (new_life, maximal_life))
		
		if new_life <= 0:
			print 'I am dead.'
			return
		
		in_town = utility.town_check()
		
		if in_town == None:
			return
		
		if not in_town and configuration.chicken and ratio <= configuration.chicken_ratio:
			print 'Leaving the game because the chicken life ratio has been reached'
			craw.leave_game()
Ejemplo n.º 3
0
	def print_item(self, item):
		quality_string = item_handler_class.get_quality_string(item.quality)
		description = '%s %s' % (quality_string, item.type)
		if item.ethereal:
			description = 'Ethereal %s' % description
			
		additional_information = []
		if item.level > 1:
			additional_information.append('Level %d' % item.level)
			
		if item.sockets == 1:
			additional_information.append('1 socket')
			
		elif item.sockets > 1:
			additional_information.append('%d sockets' % item.sockets)
			
		if len(additional_information) > 0:
			description = '%s (%s)' % (description, string.join(additional_information, ', '))
			
		print description
		craw.print_text(description)