示例#1
0
	def process_bytes(self, bytes):
		if bytes[0] == 0x01:
			self.new_game = True
			return
			
		assignment = packets.parse_assignment(bytes)
		if assignment != None:
			player_id, character_class, player_name, x, y = assignment
			if self.new_game:
				self.new_game = False
				self.my_id = player_id
			else:
				if configuration.auto_loot_permission_to_friends and privileges.is_friend(player_name):
					print 'Granting loot permission to friend %s' % player_name
					packets.grant_loot_permission(player_id)
				
		
		message = packets.parse_message(bytes)
		if message != None:
			name, message = message
			my_name = utility.get_my_name()
			if name != my_name:
				self.process_command(name, message)
			
		player_id = packets.parse_invitiation(bytes)
		if player_id != None:
			player = utility.get_player_by_id(player_id)
			if configuration.auto_accept_invitations_by_friends and privileges.is_friend(player.name):
				print 'Accepting the invitation of friend %s' % player.name
				packets.accept_invitation(player_id)
				
		"""
示例#2
0
	def process_bytes(self, bytes):
		self.lock.acquire()
		running = self.running
		self.lock.release()
		
		if running:
			return
			
		my_name = utility.get_my_name()
		if my_name not in configuration.battle_orders_barbarians:
			return
			
		message = packets.parse_message(bytes)
		if message != None:
			name, message = message
			if privileges.has_remote_privileges(name):
				self.process_command(name, message)
示例#3
0
	def process_bytes(self, bytes):
		self.lock.acquire()
		running = self.running
		self.lock.release()
		
		if running:
			return
		
		my_name = utility.get_my_name()
		if my_name not in configuration.enchanters:
			return
			
		self.mana = craw.get_mana()
		if self.mana == None:
			print 'Unable to retrieve the mana values'
			return
			
		message = packets.parse_message(bytes)
		if message != None:
			name, message = message
			if privileges.has_remote_privileges(name):
				self.process_command(name, message)
示例#4
0
	def process_bytes(self, bytes):
		if packets.entering_game(bytes):
			self.initialise()
			
		message = packets.parse_message(bytes)
		if message != None:
			name, message = message
			
			my_name = utility.get_my_name()
			self.my_name = my_name
			
			if name not in configuration.follow_leaders:
				return
				
			if name != my_name and self.command_match(message, configuration.leave_command):
				print '%s ordered us to leave the game' % name
				craw.leave_game()
			
			if my_name != None and my_name in configuration.followers:
				self.process_command(name, message)
		
		move = packets.parse_move(bytes)
		if move != None:
			player_id, x, y = move
			if self.following and player_id == self.leader_id:
				#print 'Following %s to (%d, %d)' % (self.leader, x, y)
				craw.move_click(x, y)
				
		assignment = packets.town_portal_assignment(bytes)
		if assignment != None:
			object_id, x, y = assignment
			self.current_portal = town_portal_entry(object_id, x, y)
			#print 'Portal assignment: %08x (%d, %d)' % (object_id, x, y)
			
		portal_ownership = packets.portal_ownership(bytes)
		if portal_ownership != None:
			player_id, portal_id = portal_ownership
			if self.current_portal == None:
				print 'Received portal ownership information without a previous object assignment'
			else:
				self.town_portal_map[player_id] = self.current_portal
				x, y = self.current_portal.location
				#print 'Portal ownership detected: Portal %08x (%d, %d) belongs to player %08x' % (portal_id, x, y, player_id)
				
		object_removal = packets.object_removal(bytes)
		if object_removal != None:
			type, id = object_removal
			for player_id in self.town_portal_map:
				if self.town_portal_map[player_id].id == id:
					del self.town_portal_map[player_id]
					#print 'Removed portal %08x by player %08x' % (id, player_id)
					break
					
			try:
				if type == 1:
					del self.monsters[id]
					#print 'Removed unit %08x' % id
			except KeyError:
				pass
					
		add_unit = packets.parse_add_unit(bytes)
		if add_unit != None:
			unit_type, unit_id = add_unit
			if unit_type == 1:
				try:
					location = self.assignments[unit_id]
					self.monsters[unit_id] = location
					#print 'Added unit %08x: %s' % (unit_id, repr(location))
				except KeyError:
					#print 'Unit was added without prior assignment: %08x' % unit_id
					pass
				
		npc_move = packets.parse_npc_move(bytes)
		if npc_move != None:
			unit_id, running, x, y = npc_move
			if unit_id in self.monsters:
				target = (x, y)
				if unit_id in self.monsters:
					self.monsters[unit_id] = target
					#print 'Monster %08x is moving to %s' % (unit_id, repr(target))
				
		npc_assignment = packets.parse_npc_assignment(bytes)
		if npc_assignment != None:
			unit_id, unit_code, x, y, life = npc_assignment
			if unit_code in npc.npcs:
				#print 'Detected an NPC: %08x' % unit_id
				pass
			else:
				location = (x, y)
				self.assignments[unit_id] = location
示例#5
0
def has_remote_privileges(name):
    my_name = utility.get_my_name()
    if name == my_name:
        return False

    return configuration.remote_command_privilege_users == None or name in configuration.remote_command_privilege_users
示例#6
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)