def update(self): if not super().update(): return False self.last_distance = utils.dist( h_utils.get_coords(h_utils.get_player_ped_id()), self.end_pos) pos = h_utils.get_coords(h_utils.get_player_ped_id()) x1, y1, z1 = pos.x, pos.y, pos.z x2, y2, z2 = self.end_pos.x, self.end_pos.y, self.end_pos.z self.last_distance_curve = h.Pathfind.calculate_travel_distance_between_points( x1, y1, z1, x2, y2, z1) return self.should_keep_running
def state(self): """ Dict of current scenario/player state. """ coord = h_utils.get_coords(h_utils.get_player_ped_id()) return dict(position=(coord.x, coord.y, coord.z), reward=0)
def __init__(self, ints=None, floats=None, **kwargs): super().__init__(**kwargs) if floats is None: floats = [0] * 7 floats[0] = h_utils.get_coords(h_utils.get_player_ped_id()).x floats[1] = h_utils.get_coords(h_utils.get_player_ped_id()).y floats[2] = h_utils.get_coords(h_utils.get_player_ped_id()).z floats[3] = 0.0 floats[4] = h_utils.random_point( h_utils.get_coords(h_utils.get_player_ped_id()).x, 1000) floats[5] = h_utils.random_point( h_utils.get_coords(h_utils.get_player_ped_id()).y, 1000) floats[6] = h_utils.random_point( h_utils.get_coords(h_utils.get_player_ped_id()).z, 1000) # Normal self.start_pos = h.Vector3(floats[0], floats[1], floats[2]) self.start_heading = floats[3] self.end_pos = h.Vector3(floats[4], floats[5], floats[6]) pos = h_utils.get_coords(h_utils.get_player_ped_id()) self.last_distance = utils.dist(pos, self.end_pos) self.last_distance_curve = h.Pathfind.calculate_travel_distance_between_points( pos.x, pos.y, pos.z, self.end_pos.x, self.end_pos.y, self.end_pos.z)
def _respawn(self): player_ped_id = h_utils.get_player_ped_id() if self.random_respawn: pos = h_utils.get_coord_near_road(self.x, self.y) heading = h_utils.get_road_heading(pos.x, pos.y) else: pos = h_utils.get_coords(player_ped_id) heading = player_ped_id.heading h_utils.set_ped_position(player_ped_id, pos) h_utils.set_ped_heading(player_ped_id, heading)
def setup(self, autopilot): coord = h_utils.get_coords(h_utils.get_player_ped_id()) h.Gameplay.clear_area(coord.x, coord.y, coord.z, 30.0, 0, 0, 0, 0) self._remove_all_vehicles() self._respawn() self._ready_vehicle() self.last_control = self.vehicle.control # Give autopilot information about vehicle, etc. autopilot.init(self)