Example #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)
Example #2
0
	def enchant(self, target, type):
		packets.set_right_skill(enchant_handler_class.enchant_skill)
		packets.cast_right_skill_at_target(type, target)
		current_mana, maximum_mana = self.mana
		current_mana -= self.mana_per_cast
		self.mana = (current_mana, maximum_mana)
		time.sleep(configuration.enchant_delay)
		return current_mana >= self.mana_per_cast
Example #3
0
	def process_bytes(self, bytes):
		set_skill = packets.parse_set_skill(bytes)
		if set_skill != None:
			unit_type, unit_id, side, skill = set_skill
			#if unit_id == my_player.id:
			if side == 0x01:
				self.left_skill = skill
				#print 'Left skill is set to %02x' % skill
	
		my_player = utility.get_my_player()
		if my_player == None:
			return
		
		move = packets.parse_move(bytes)
		if move != None:
			player_id, x, y = move
			self.movement[player_id] = (x, y)
			
		stop = packets.parse_player_stop(bytes)
		if stop != None:
			unit_type, unit_id, x, y, life = stop
			try:
				del self.movement[unit_id]
			except KeyError:
				pass
				
		if set_skill != None:
			if self.attack_mode == attack_mode_bone_prison_bone_spirit_tppk and skill == teleport_skill:
				self.debug('Right skill has been changed, casting teleport for Bone Spirit attack')
				teleport_x = self.target.x + configuration.bone_spirit_teleport_offset[0]
				teleport_y = self.target.y + configuration.bone_spirit_teleport_offset[1]
				packets.cast_right_skill_at_location(teleport_x, teleport_y)
			elif self.attack_mode == attack_mode_fist_of_heavens_tppk and skill == teleport_skill:
				self.debug('Right skill has been changed, casting teleport for Fist of Heavens attack')
				packets.cast_right_skill_at_target(0, self.target.id)
			elif self.attack_mode == attack_mode_bone_prison_bone_spirit_tppk and skill == bone_prison_skill:
				self.debug('Right skill has been changed, casting Bone Prison for the Bone Spirit attack')
				packets.cast_right_skill_at_target(0, self.target.id)
				nil.thread.create_thread(self.bone_prison_teleport)
			elif self.attack_mode == attack_mode_bone_prison_bone_spear_tppk and skill == bone_prison_skill:
				self.debug('Right skill has been changed, casting Bone Prison for the Bone Spear attack')
				packets.cast_right_skill_at_target(0, self.target.id)
				nil.thread.create_thread(self.bone_prison_bone_spear)
				
		reassignment = packets.parse_reassignment(bytes)
		if reassignment != None:
			unit_type, unit_id, x, y, boolean = reassignment
			if self.attack_mode in [attack_mode_bone_prison_bone_spirit_tppk, attack_mode_fist_of_heavens_tppk] and my_player.id == unit_id:
				self.debug('Detected reassignment, performing attack')
				
				if not self.is_in_range(self.target.id):
					print 'The player is no longer in range - unable to cast Bone Spirit'
					self.reset_attack()
					return
					
				packets.cast_left_skill_at_target(0, self.target.id)
				if self.attack_mode == attack_mode_fist_of_heavens_tppk:
					nil.thread.create_thread(lambda: self.town_portal(configuration.fist_of_heavens_delay))
				else:
					nil.thread.create_thread(self.town_portal)
				
		message = packets.parse_message(bytes)
		if self.start_of_attack != None and message != None:
			name, message = message
			if name != utility.get_my_name():
				self.process_message(name, message)