Example #1
0
 def stop_super_speed_three(self):
     for (sim_id,
          (speed,
           ss3_requested)) in tuple(self._sim_game_speed_requests.items()):
         while ss3_requested:
             self._sim_game_speed_requests[sim_id] = (speed, False)
     services.get_super_speed_three_service().update()
Example #2
0
 def unregister_game_speed_change_request(self, sim_id):
     if sim_id in self._sim_game_speed_requests:
         sim_info = services.sim_info_manager().get(sim_id)
         if sim_info is not None:
             for sim_in_household in sim_info.household.instanced_sims_gen(
                     allow_hidden_flags=ALL_HIDDEN_REASONS):
                 while sim_in_household.id not in self._sim_game_speed_requests:
                     break
             if self.clock_speed() > ClockSpeedMode.NORMAL:
                 self.set_clock_speed(ClockSpeedMode.NORMAL)
         del self._sim_game_speed_requests[sim_id]
         services.get_super_speed_three_service().update()
 def _update(self, force_create=False):
     if services.get_super_speed_three_service().in_or_has_requested_super_speed_three():
         gsi_handlers.ambient_handlers.archive_ambient_data('In super speed 3 mode')
         return
     if not self._sources:
         return
     if gsi_handlers.ambient_handlers.archiver.enabled:
         gsi_description = self.get_gsi_description()
     else:
         gsi_description = None
     sources_and_priorities = [(source, source.get_priority()) for source in self._sources]
     sources_and_priorities.sort(key=lambda source: source[1], reverse=True)
     situation_id = None
     source = sources_and_priorities[0][0]
     priority = sources_and_priorities[0][1]
     if priority > 0:
         situation_id = source.start_appropriate_situation()
     elif force_create:
         for (source, _) in sources_and_priorities:
             situation_id = source.start_appropriate_situation()
             while situation_id is not None:
                 break
     if gsi_handlers.ambient_handlers.archiver.enabled:
         if situation_id is not None:
             situation = services.current_zone().situation_manager.get(situation_id)
             gsi_description += '    Created {}'.format(situation)
         gsi_handlers.ambient_handlers.archive_ambient_data(gsi_description)
     return situation_id
 def start_situation(self):
     if services.get_super_speed_three_service(
     ).in_or_has_requested_super_speed_three():
         clock_service = services.game_clock_service()
         clock_service.stop_super_speed_three()
     super().start_situation()
     self._change_state(ArrivingOnLotSituationState())
Example #5
0
def clock_status(_connection=None):
    stats = []
    game_clock = services.game_clock_service()
    ss3_service = services.get_super_speed_three_service()
    clock_speed = None
    if ss3_service.in_super_speed_three_mode():
        clock_speed = 'Super Speed 3'
    else:
        clock_speed = ClockSpeedMode(game_clock.clock_speed())
    (deviance, threshold, current_duration,
     duration) = AdaptiveClockSpeed.get_debugging_metrics()
    output = sims4.commands.CheatOutput(_connection)
    stats.append(
        ('Clock Speed', clock_speed, '(Current player-facing clock speed)'))
    stats.append(
        ('Speed Multiplier Type',
         ClockSpeedMultiplierType(game_clock.clock_speed_multiplier_type),
         '(Decides the speed 2/3/SS3 multipliers for adaptive speed)'))
    stats.append(
        ('Clock Speed Multiplier', game_clock.current_clock_speed_scale(),
         '(Current Speed scaled with appropriate speed settings)'))
    stats.append(('Simulation Deviance', '{:>7} / {:<7}'.format(
        deviance, threshold
    ), '(Simulation clock deviance from time service clock / Tuning Threshold [units: ticks])'
                  ))
    stats.append(('Deviance Duration', '{:>7} / {:<7}'.format(
        current_duration, duration
    ), '(Current duration in multiplier phase / Tuning Duration [units: ticks])'
                  ))
    for (name, value, description) in stats:
        output('{:25} {!s:40} {}'.format(name, value, description))
 def _update(self, force_create=False):
     if services.get_super_speed_three_service(
     ).in_or_has_requested_super_speed_three():
         gsi_handlers.ambient_handlers.archive_ambient_data(
             'In super speed 3 mode')
         return
     if not self._sources:
         return
     if gsi_handlers.ambient_handlers.archiver.enabled:
         gsi_description = self.get_gsi_description()
     else:
         gsi_description = None
     sources_and_priorities = [(source, source.get_priority())
                               for source in self._sources]
     sources_and_priorities.sort(key=lambda source: source[1], reverse=True)
     situation_id = None
     source = sources_and_priorities[0][0]
     priority = sources_and_priorities[0][1]
     if priority > 0:
         situation_id = source.start_appropriate_situation()
     elif force_create:
         for (source, _) in sources_and_priorities:
             situation_id = source.start_appropriate_situation()
             while situation_id is not None:
                 break
     if gsi_handlers.ambient_handlers.archiver.enabled:
         if situation_id is not None:
             situation = services.current_zone().situation_manager.get(
                 situation_id)
             gsi_description += '    Created {}'.format(situation)
         gsi_handlers.ambient_handlers.archive_ambient_data(gsi_description)
     return situation_id
Example #7
0
 def register_game_speed_change_request(self, sim, game_speed_params):
     (game_speed, _) = game_speed_params
     if not sim.sim_info.is_npc:
         self._sim_game_speed_requests[sim.id] = game_speed_params
         lowest_requested_speed = game_speed
         for sim_in_household in sim.household.instanced_sims_gen(
                 allow_hidden_flags=ALL_HIDDEN_REASONS):
             speed_params = self._sim_game_speed_requests.get(
                 sim_in_household.id)
             if speed_params is not None:
                 (speed, _) = speed_params
                 if speed < lowest_requested_speed:
                     lowest_requested_speed = speed
                     return
             else:
                 return
         services.get_super_speed_three_service().update()
         self.set_clock_speed(lowest_requested_speed)
Example #8
0
def show_ss3_info(_connection=None):
    (ss3_state, alarm, sims_in_open_streets, target_state) = services.get_super_speed_three_service().get_debug_information()
    game_clock = services.game_clock_service()
    output = sims4.commands.Output(_connection)
    output('-=-=-=-=-=-=-=-=-\nSUPER SPEED THREE INFORMATION:')
    output('  State: {}\n  Alarm: {}\n  Sims in Open Streets: {}\n  Target State: {}'.format(ss3_state, alarm, sims_in_open_streets, target_state))
    output('  Game Speed: {}'.format(game_clock.clock_speed()))
    output('TIME REQUESTS:')
    for time_request in game_clock.game_speed_requests_gen():
        output('  {}\n'.format(time_request))
    output('-=-=-=-=-=-=-=-=-')
Example #9
0
 def _get_game_clock_sync_variables(self):
     server_time = services.server_clock_service().ticks()
     if self._interaction_loading:
         game_time = self._loading_monotonic_ticks
         monotonic_time = self._loading_monotonic_ticks
         game_speed = self._clock_speed_to_scale(
             ClockSpeedMode.INTERACTION_STARTUP_SPEED)
         clock_speed = ClockSpeedMode.INTERACTION_STARTUP_SPEED
         super_speed = False
     else:
         game_time = self._game_clock._ticks
         monotonic_time = game_time + self._loading_monotonic_ticks
         game_speed = self.current_clock_speed_scale()
         clock_speed = self.clock_speed()
         super_speed = services.get_super_speed_three_service(
         ).in_super_speed_three_mode()
     return (server_time, monotonic_time, game_time, game_speed,
             clock_speed, super_speed)
Example #10
0
 def _clock_speed_to_scale(self, clock_speed):
     if clock_speed == ClockSpeedMode.PAUSED:
         return self.PAUSED_SPEED_MULTIPLIER
     if clock_speed == ClockSpeedMode.NORMAL:
         return self.NORMAL_SPEED_MULTIPLIER
     if clock_speed == ClockSpeedMode.SPEED2:
         return ClockSpeedMultipliers.speed_two_multiplier(
             self.clock_speed_multiplier_type)
     if clock_speed == ClockSpeedMode.SPEED3:
         if services.get_super_speed_three_service(
         ).super_speed_three_active:
             return ClockSpeedMultipliers.super_speed_three_multiplier(
                 self.clock_speed_multiplier_type)
         return ClockSpeedMultipliers.speed_three_multiplier(
             self.clock_speed_multiplier_type)
     if clock_speed == ClockSpeedMode.INTERACTION_STARTUP_SPEED:
         return ClockSpeedMultipliers.get_interaction_startup_speed_multiplier(
         )
def clock_status(_connection=None):
    stats = []
    game_clock = services.game_clock_service()
    ss3_service = services.get_super_speed_three_service()
    clock_speed = None
    if ss3_service.in_super_speed_three_mode():
        clock_speed = 'Super Speed 3'
    else:
        clock_speed = ClockSpeedMode(game_clock.clock_speed())
    (deviance, threshold, current_duration, duration) = AdaptiveClockSpeed.get_debugging_metrics()
    output = sims4.commands.CheatOutput(_connection)
    stats.append(('Clock Speed', clock_speed, '(Current player-facing clock speed)'))
    stats.append(('Speed Multiplier Type', ClockSpeedMultiplierType(game_clock.clock_speed_multiplier_type), '(Decides the speed 2/3/SS3 multipliers for adaptive speed)'))
    stats.append(('Clock Speed Multiplier', game_clock.current_clock_speed_scale(), '(Current Speed scaled with appropriate speed settings)'))
    stats.append(('Simulation Deviance', '{:>7} / {:<7}'.format(deviance, threshold), '(Simulation clock deviance from time service clock / Tuning Threshold [units: ticks])'))
    stats.append(('Deviance Duration', '{:>7} / {:<7}'.format(current_duration, duration), '(Current duration in multiplier phase / Tuning Duration [units: ticks])'))
    for (name, value, description) in stats:
        output('{:25} {!s:40} {}'.format(name, value, description))
Example #12
0
 def set_clock_speed(self,
                     speed,
                     change_source=GameSpeedChangeSource.GAMEPLAY) -> bool:
     if speed is None or speed < 0 or speed > ClockSpeedMode.INTERACTION_STARTUP_SPEED:
         logger.error(
             'Attempting to set clock speed to something invalid: {}',
             speed)
         return False
     logger.debug(
         'set_clock_speed CALLED ...\n    speed: {}, change_source: {}',
         speed, change_source)
     if self._pause_requests:
         return False
     if change_source == GameSpeedChangeSource.USER and not services.current_zone(
     ).is_zone_running:
         logger.debug("set_clock_speed FAILED\n    zone isn't running")
         return False
     if change_source == GameSpeedChangeSource.GAMEPLAY and self._clock_speed == ClockSpeedMode.PAUSED and speed != ClockSpeedMode.PAUSED:
         if self._previous_non_pause_speed > speed:
             self._previous_non_pause_speed = speed
         logger.debug(
             'set_clock_speed SUCCEEDED\n    gameplay request to bring game out of PAUSED. caching for the unpause.')
         return True
     if speed != self._clock_speed:
         if self._clock_speed != ClockSpeedMode.INTERACTION_STARTUP_SPEED and self._clock_speed != ClockSpeedMode.PAUSED:
             self._previous_non_pause_speed = self._clock_speed
         self._update_time_spent_in_speed(self._clock_speed)
     if speed == ClockSpeedMode.NORMAL:
         self._set_clock_speed_multiplier_type(
             ClockSpeedMultiplierType.DEFAULT)
     (server_time, monotonic_time, game_time, _, _,
      _) = self._get_game_clock_sync_variables()
     self._clock_speed = speed
     ss3_service = services.get_super_speed_three_service()
     ss3_service.update()
     in_ss3 = ss3_service.in_super_speed_three_mode()
     game_speed = self.current_clock_speed_scale()
     self._broadcast_gameplay_clock_message(server_time, monotonic_time,
                                            game_time, game_speed,
                                            self._clock_speed, in_ss3)
     logger.debug('set_clock_speed SUCCEEDED. speed: {}, change_source: {}',
                  speed, change_source)
     return True
Example #13
0
 def _unrequest_super_speed_three_mode(self, game_speed):
     if services.get_super_speed_three_service().in_super_speed_three_mode():
         services.game_clock_service().set_clock_speed(game_speed)
 def _unrequest_super_speed_three_mode(self, game_speed):
     if services.get_super_speed_three_service().in_super_speed_three_mode(
     ):
         services.game_clock_service().set_clock_speed(game_speed)
 def start_situation(self):
     if services.get_super_speed_three_service().in_or_has_requested_super_speed_three():
         clock_service = services.game_clock_service()
         clock_service.stop_super_speed_three()
     super().start_situation()
     self._change_state(ArrivingOnLotSituationState())