def _get_return_to_spawn_points(self) -> tuple: # [waypoints], z_locked bool # No points, return just spawn point. if len(self.evading_waypoints) == 0: return [self.spawn_position], False # Reverse the combat waypoints, so they point back to spawn location. waypoints = [wp for wp in reversed(self.evading_waypoints)] # Set self location to the latest known point. self.location = waypoints[0].copy() last_waypoint = self.location # Distance we want between each waypoint. d_factor = 4 # Try to use waypoints only for units that have invalid z calculations. z_locked = False distance_sum = 0 # Filter the waypoints by distance, remove those that are too close to each other. for waypoint in list(waypoints): # Check for protected z. if not z_locked: z, z_locked = MapManager.calculate_z(self.map_, waypoint.x, waypoint.y, waypoint.z) distance_sum += last_waypoint.distance(waypoint) if distance_sum < d_factor: waypoints.remove(waypoint) else: distance_sum = 0 last_waypoint = waypoint if z_locked: # Make sure the last waypoints its self spawn position. waypoints.append(self.spawn_position.copy()) else: # This unit is probably outside a cave, do not use waypoints. waypoints.clear() waypoints.append(self.spawn_position) return waypoints, z_locked
def calculate_z( x, y, map_id, default_z=0.0 ) -> tuple: # float, z_locked (Could not use map files Z) if map_id == -1 or not config.Server.Settings.use_map_tiles: return default_z, False else: # Calculate destination Z, default Z if not possible. return MapManager.calculate_z(map_id, x, y, default_z)
def calculate_z(x, y, map_id, default_z=0.0): if map_id == -1 or not config.Server.Settings.use_map_tiles: return default_z else: # Calculate destination Z, default Z if not possible. return MapManager.calculate_z(map_id, x, y, default_z)