Example #1
0
	def get_targets(self):
		monsters = []
		
		for unit_id in self.monsters:
			monster = craw.get_unit(unit_id, 1)
			#missing town NPC check?
			if monster == None:
				print 'Failed to receive monster data for ID %08x' % unit_id
				continue
				
			#location hack
			x, y = self.monsters[unit_id]
			monster.x = x
			monster.y = y
				
			if monster.mode in [0, 12]:
				#monster is dead
				self.attack_print('Dead monster: %08x' % unit_id)
				continue
				
			distance = utility.get_d2_distance(self.i, monster)
			if distance > configuration.follower_attack_radius:
				self.attack_print('Distance to %08x too great: %.1f (%s)' % (monster.id, distance, repr((monster.x, monster.y))))
				continue
			monsters.append((distance, unit_id))
			
		monsters.sort(cmp = utility.sort_units)
		
		return monsters
Example #2
0
	def process_message(self, name, message):
		tokens = message.split(' ')
		if len(tokens) < 2:
			return
		trigger = tokens[0]
		try:
			value = float(tokens[1])
		except ValueError:
			return
			
		difference = self.get_ms(value, self.start_of_attack)
			
		if trigger == chat_trigger_hostile:
			print 'Delay between the start of the attack and the declaration of hostility: %d ms' % difference
			self.hostile_time = value
		elif trigger == chat_trigger_damage:
			euclidean_distance = utility.get_euclidean_distance(self.i, self.target)
			d2_distance = utility.get_d2_distance(self.i, self.target)
			print 'Delay between the declaration of hostility and the damage: %d ms' % self.get_ms(value, self.hostile_time)
			print 'Delay between the start of the attack and the damage: %d ms' % difference
			print 'Initial euclidean distance between the attacker and the victim: %.1f' % euclidean_distance
			print 'Initial Diablo II distance between the attacker and the victim: %.1f' % d2_distance
			if len(tokens) >= 3:
				try:
					damage = int(tokens[2])
					print 'Damage taken by the victim: %d' % damage
				except	ValueError:
					pass
Example #3
0
	def get_target(self):
		players = craw.get_players()
		my_player = utility.get_my_player()
		players = filter(lambda x: x.level >= 9 and x.x != 0 and x.id != my_player.id and not self.is_a_friend(x), players)
		players = map(lambda x: (utility.get_d2_distance(my_player, x), x), players)
		players = filter(lambda x: x[0] <= configuration.maximal_attack_distance, players)
		players.sort(cmp = utility.sort_units)
		
		if len(players) == 0:
			print 'There are no suitable targets in range.'
			return None
		
		print 'List of targets:'
		counter = 1
		for distance, player in players:
			print '%d. %s: %.2f (%d, %d)' % (counter, player.name, distance, player.x, player.y)
			counter += 1
			
		target = players[0][1]
		return target
Example #4
0
	def attack(self):
		if utility.town_check():
			print 'You cannot attack other players in town.'
			return
			
		self.i = utility.get_my_player()
		
		target = self.get_target()
		if target == None:
			return
		self.target = target
		
		print 'Picked target %s' % target.name
		
		if target.id in self.movement:
			x, y = self.movement[target.id]
			print 'It is a moving target: %d, %d' % (x, y)
		
		bone_spirit_attack = self.left_skill == bone_spirit_skill and self.skill_check([bone_prison_skill, teleport_skill], attack_mode_bone_prison_bone_spirit_tppk)
		bone_spear_attack = self.left_skill == bone_spear_skill and self.skill_check([bone_prison_skill], attack_mode_bone_prison_bone_spear_tppk)
		foh_attack = self.left_skill == fist_of_heavens_skill and self.skill_check([fist_of_heavens_skill], attack_mode_fist_of_heavens_tppk)
		
		self.start_of_attack = time.time()
		
		if bone_spirit_attack or bone_spear_attack:
			self.debug('Setting the right skill to Bone Prison')
			packets.set_right_skill(bone_prison_skill)
		elif foh_attack:
			if craw.get_skill_level(teleport_skill) > 0:
				self.debug('Setting the right skill to teleport')
				packets.set_right_skill(teleport_skill)
			else:
				if utility.get_d2_distance(utility.get_my_player(), target) > configuration.fist_of_heavens_distance:
					print 'You are not in range for a Fist of Heavens attack'
					return
				self.debug('Casting Fist of Heavens at the target')
				packets.cast_left_skill_at_target(0, self.target.id)
				nil.thread.create_thread(lambda: self.town_portal(configuration.fist_of_heavens_delay))
		else:
			print 'Performing default attack "%s"' % attack_mode_cast_left_skill
			packets.cast_left_skill_at_target(0, self.target.id)