Exemple #1
0
	def auto_cast_thread(self):
		for name, skill in auto_cast_skills:
			level = craw.get_skill_level(skill)
			if level == None or level == 0:
				continue
				
			print 'Casting %s level %d' % (name, level)
			packets.perform_cast(skill, configuration.auto_cast_switch_delay, configuration.auto_cast_cast_delay)
	def skill_check(self, skills, attack_mode):
		for skill in skills:
			if craw.get_skill_level(skill) == 0:
				print 'You lack a skill to perform the following attack: %s' % attack_mode
				return False
		print 'Performing attack "%s"' % attack_mode
		self.attack_mode = attack_mode
		return True
	def cast_battle_orders(self):
		if utility.town_check():
			packets.send_chat(configuration.battle_orders_town_error)
			return
			
		current_mana, maximum_mana = craw.get_mana()
		mana_usage = 6 + 7 + 11
		if current_mana < mana_usage:
			packets.send_chat(configuration.mana_error % (current_mana, maximum_mana))
			return
			
		for skill_name, skill in battle_orders_skills:
			level = craw.get_skill_level(skill)
			if level == 0:
				print 'This character lacks the following skill: %s' % skill_name
				return
			
		self.launch_function(self.battle_orders_thread)
	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)
Exemple #5
0
	def process_command(self, name, message):
		self.player = utility.get_player_data_by_name(name)
		self.my_player = utility.get_my_player()
		
		if self.player.id == self.my_player.id:
			return
		
		if self.player == None or self.my_player == None:
			return
		
		enchant_level = craw.get_skill_level(enchant_handler_class.enchant_skill)
		if enchant_level == None:
			print 'Unable to retrieve the enchant skill level'
			return
			
		if enchant_level == 0:
			print 'Unable to enchant - this character does not even have this skill!'
			return
		
		self.enchant_level = enchant_level
		
		self.mana = craw.get_mana()
		if self.mana == None:
			print 'Unable to retrieve mana'
			return
	
		if message == configuration.enchant_command:
			self.launch_function(self.enchant_player)
				
		elif message == configuration.enchant_minions_command:
			self.launch_function(self.enchant_minions)
				
		elif message == configuration.enchant_all_command:
			self.launch_function(self.enchant_all)
			
		elif message == configuration.enchant_players_command:
			self.launch_function(self.enchant_players)