Beispiel #1
0
	def enter_tp(self, player):
		try:
			tp_entry = self.town_portal_map[player.id]
		except KeyError:
			packets.send_chat(configuration.tp_error % player.name)
			return
			
		packets.send_chat(configuration.enter_tp_confirmation % player.name)
		town_portal_timer(tp_entry)
Beispiel #2
0
def say_file(file):
	lines = nil.file.read_lines(file)
	if lines == None:
		print 'Unable to read %s'
	elif len(lines) >= 25:
		print '%s has too many lies' % file
	else:
		print 'Reading %s and sending it to the chat' % file
		for line in lines:
			packets.send_chat(line)
Beispiel #3
0
	def distance_check(self):
		my_coordinates = (self.my_player.x, self.my_player.y)
		player_coordinates = (self.player.x, self.player.y)
		
		distance = utility.distance(my_coordinates, player_coordinates)
		
		is_in_range = self.player.x != 0 and distance <= configuration.maximal_enchant_distance
		if not is_in_range:
			packets.send_chat(configuration.enchant_range_error)
		return is_in_range
Beispiel #4
0
	def enchant_minions(self):
		if not self.perform_pre_cast_check():
			return False
			
		minions = self.get_minions()
		minions_enchanted = self.process_targets(minions)
		if minions_enchanted == None:
			return False
			
		current_mana, maximum_mana = self.mana
		packets.send_chat(configuration.enchant_minions_confirmation % (minions_enchanted, current_mana, maximum_mana))
		return True
Beispiel #5
0
	def perform_mana_check(self, cast_count):
		self.mana_per_cast = self.enchant_level + 24
		mana_usage = cast_count * self.mana_per_cast
		current_mana, maximum_mana = self.mana
		output = mana_usage <= current_mana
		if self.mana_per_cast > current_mana:
			packets.send_chat(configuration.mana_error % self.mana)
			return False
		elif mana_usage > current_mana:
			packets.send_chat(configuration.enchant_mana_lack_warning % self.mana)
			return True
		else:
			return True
Beispiel #6
0
	def enchant_all(self):
		if not self.perform_pre_cast_check():
			return False
			
		targets = self.get_minions()
		if targets == None:
			print 'Unable to retrieve minions!'
			targets = []
		targets = [(0, self.player.id)] + targets
		targets_enchanted = self.process_targets(targets)
		if targets_enchanted == None:
			return False
			
		minions_enchanted = targets_enchanted - 1
			
		current_mana, maximum_mana = self.mana
		packets.send_chat(configuration.enchant_all_confirmation % (minions_enchanted, current_mana, maximum_mana))
		return True
Beispiel #7
0
	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)
Beispiel #8
0
def say(message):
	packets.send_chat(message)
Beispiel #9
0
	def process_command(self, name, message):
		player = utility.get_player_by_name(name)
		
		if self.my_name == name:
			return
		
		if player == None:
			print 'Unable to retrieve player data of player %s' % player
			return
			
		#print 'Processing <%s> "%s"' % (name, message)
			
		if self.command_match(message, configuration.follow_command):
			self.following = True
			self.leader = player.name
			self.leader_id = player.id
			print 'Following %s' % self.leader
			packets.send_chat(configuration.follow_confirmation % self.leader)
			
		elif self.command_match(message, configuration.stop_command):
			if self.following:
				self.following = False
				print 'No longer following %s' % self.leader
				packets.send_chat(configuration.stop_confirmation % self.leader)
			else:
				print '%s asked us to stop following the leader but we are currently not following anybody' % name
				packets.send_chat(configuration.stop_error)
				
		elif self.command_match(message, configuration.enter_tp_command) and not utility.town_check():
			self.enter_tp(player)
			
		elif self.command_match(message, configuration.enter_town_tp_command) and utility.town_check():
			self.enter_tp(player)
				
		elif self.command_match(message, configuration.go_to_town_command):
			print 'Casting a town portal to go to town'
			self.town_portal_handler.town_tp()
			
		elif self.command_match(message, configuration.attack_command):
			if self.attacking:
				packets.send_chat(configuration.attack_error)
			else:
				packets.send_chat(configuration.attack_confirmation)
				self.attacking = True
				nil.thread.create_thread(self.attack_thread)
				
		elif self.command_match(message, configuration.stop_attacking_command):
			if self.attacking:
				packets.send_chat(configuration.stop_attacking_confirmation)
				self.attacking = False
			else:
				packets.send_chat(configuration.stop_attacking_error)
Beispiel #10
0
	def perform_party_check(self):
		is_in_party = utility.same_party(self.player, self.my_player)
		if not is_in_party:
			packets.send_chat(configuration.party_error)
		return is_in_party
Beispiel #11
0
	def enchant_player(self):
		if not self.perform_pre_cast_check() or not self.perform_mana_check(1):
			return False
		self.enchant(self.player.id, 0)
		packets.send_chat(configuration.enchant_confirmation % self.mana)
		return True
Beispiel #12
0
	def battle_orders_thread(self):
		packets.send_chat(configuration.battle_orders_confirmation)
		for skill_name, skill in battle_orders_skills:
			packets.perform_cast(skill, configuration.battle_orders_switch_delay, configuration.battle_orders_cast_delay)
Beispiel #13
0
	def process_hostility(self):
		if self.research_mode:
			packets.send_chat('%s %.3f' % (chat_trigger_hostile, time.time()))
Beispiel #14
0
	def process_damage(self, damage, life):
		if self.research_mode:
			packets.send_chat('%s %.3f %d' % (chat_trigger_damage, time.time(), damage))