def process_bytes(self, bytes): if packets.entering_game(bytes): self.entering = True if self.entering and packets.load_complete(bytes): self.auto_cast() self.entering = False
def process_bytes(self, bytes): if not self.has_thread: #print 'Creating whois thread' nil.thread.create_thread(self.whois_thread) self.has_thread = True if packets.entering_game(bytes): self.entering_game = True assignment = packets.parse_assignment(bytes) if assignment != None and self.entering_game: player_id, character_class, player_name, x, y = assignment #print 'Assignment: %s' % player_name self.entering_game = False self.whois(player_name, None)
def process_bytes(self, bytes): if packets.entering_game(bytes): self.initialise() add_unit = packets.parse_add_unit(bytes) if add_unit != None: unit_type, unit_id = add_unit #print 'Added unit of type %d: %08x' % (unit_type, unit_id) if unit_type == 1: self.monsters.append(unit_id) object_removal = packets.object_removal(bytes) if object_removal != None: type, id = object_removal try: self.monsters.remove(id) except ValueError: pass
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