def __init__(self, *args, reader=None, **kwargs): super().__init__(*args, reader=reader, **kwargs) self._current_count = 0 resolver = DataResolver(self._sim_info) test_result = resolver(self.object_criteria_test) if isinstance(test_result, TestResultNumeric): self._current_count = test_result.current_value
def _run_interaction_gen(self, timeline): services.sim_info_manager().set_default_genealogy() resolver = DataResolver(self.sim.sim_info) if not resolver(self.situation_blacklist): return True yield if not self.target.is_sim: return True yield if self.sim.household_id == self.target.household_id: return True yield def on_response(dialog): if not dialog.accepted: self.cancel_user( cancel_reason_msg= 'Move-In. Player canceled, or move in together dialog timed out from client.' ) return actor = self.get_participant(ParticipantType.Actor) src_household_id = actor.sim_info.household.id target = self.target tgt_household_id = target.sim_info.household.id if src_household_id is not None and tgt_household_id is not None: household_split(src_household_id, tgt_household_id) dialog = self.dialog(self.sim, self.get_resolver()) dialog.show_dialog(on_response=on_response) return True yield
def _should_handle_event(self, milestone, event, resolver: DataResolver): if not super()._should_handle_event(milestone, event, resolver): return False aspiration = milestone if aspiration.aspiration_type == AspriationType.FULL_ASPIRATION and aspiration.do_not_register_events_on_load: return self.aspiration_in_sequence(aspiration) if aspiration.aspiration_type == AspriationType.TIMED_ASPIRATION: return aspiration in self._timed_aspirations if aspiration.aspiration_type == AspriationType.CAREER: actor = resolver.get_participant(ParticipantType.Actor) if actor is None or not actor.is_sim: return False career_tracker = actor.sim_info.career_tracker if career_tracker is None: return False else: return milestone in career_tracker.get_all_career_aspirations() return True
def complete_objective( objective: TunableInstanceParam(sims4.resources.Types.OBJECTIVE), opt_sim: OptionalTargetParam = None, _connection=None): sim = get_optional_target(opt_sim, _connection) if sim is not None and objective is not None: aspiration_tracker = sim.sim_info.aspiration_tracker for aspiration in services.get_instance_manager( sims4.resources.Types.ASPIRATION).types.values(): if aspiration.aspiration_type == AspriationType.FULL_ASPIRATION and aspiration.do_not_register_events_on_load and not aspiration_tracker.aspiration_in_sequence( aspiration): continue for asp_objective in aspiration.objectives: if asp_objective == objective: aspiration_tracker.handle_event( aspiration, None, DataResolver(sim.sim_info), debug_objectives_to_force_complete=[objective]) sims4.commands.output('Complete {} on {}'.format(objective, sim), _connection)
def _schedule_all_holidays(self, holiday_ids_to_ignore=()): resolver = DataResolver(None) season_service = services.season_service() current_season_length = season_service.season_length_option drama_scheduler = services.drama_scheduler_service() season_data = defaultdict(list) for (season_type, season_content) in season_service.get_seasons_for_scheduling(): season_data[season_type].append(season_content) for (season, day, holiday_id) in self._holiday_times[ current_season_length].holidays_to_schedule_gen(): if holiday_id in holiday_ids_to_ignore: continue for season_content in season_data[season]: holiday_start_time = season_content.start_time + create_time_span( days=day) drama_scheduler.schedule_node( HolidayService.CUSTOM_HOLIDAY_DRAMA_NODE, resolver, specific_time=holiday_start_time, holiday_id=holiday_id)
def _schedule_venue_organization_event(self, org_drama_node, zone_id): drama_scheduler = services.drama_scheduler_service() resolver = DataResolver(None) org_start_time = self.verify_valid_time(org_drama_node) if org_start_time is None: return gsi_data = None if is_scoring_archive_enabled(): gsi_data = GSIDramaScoringData() gsi_data.bucket = 'Venue Organization Event' uid = drama_scheduler.schedule_node(org_drama_node, resolver, specific_time=org_start_time, setup_kwargs={ 'gsi_data': gsi_data, 'zone_id': zone_id }) if uid is not None: self._organization_venue_events[uid] = str(org_drama_node) drama_scheduler.add_complete_callback( uid, self._reschedule_venue_org_event)
def _run_interaction_gen(self, timeline): services.sim_info_manager()._set_default_genealogy() resolver = DataResolver(self.sim.sim_info) if not resolver(self.situation_blacklist): return True if not self.target.is_sim: return True if self.sim.household_id == self.target.household_id: return True def on_response(dialog): if not dialog.accepted: self.cancel_user( cancel_reason_msg= 'Move-In. Player canceled, or move in together dialog timed out from client.' ) return actor = self.get_participant(ParticipantType.Actor) src_household_id = actor.sim_info.household.id target = self.target tgt_household_id = target.sim_info.household.id client_manager = services.client_manager() if client_manager is not None: client = client_manager.get_first_client() if client is not None: active_sim_id = client.active_sim.id if src_household_id is not None and tgt_household_id is not None and active_sim_id is not None: transfer_info = InteractionOps_pb2.SimTransferRequest() transfer_info.source_household_id = src_household_id transfer_info.target_household_id = tgt_household_id transfer_info.active_sim_id = active_sim_id system_distributor = distributor.system.Distributor.instance() generic_pb_op = GenericProtocolBufferOp( DistributorOps_pb2.Operation.SIM_TRANSFER_REQUEST, transfer_info) system_distributor.add_op_with_no_owner(generic_pb_op) dialog = self.dialog(self.sim, self.get_resolver()) dialog.show_dialog(on_response=on_response) return True
def _schedule_holiday(self, holiday_id): resolver = DataResolver(None) season_service = services.season_service() current_season_length = season_service.season_length_option drama_scheduler = services.drama_scheduler_service() (season, day) = self._holiday_times[current_season_length].get_holiday_data( holiday_id) if season is None: logger.error( 'Trying to schedule holiday of id {} which is not actually scheduled to run at any time.' ) return for (season_type, season_content) in season_service.get_seasons_for_scheduling(): if season_type != season: continue holiday_start_time = season_content.start_time + create_time_span( days=day) drama_scheduler.schedule_node( HolidayService.CUSTOM_HOLIDAY_DRAMA_NODE, resolver, specific_time=holiday_start_time, holiday_id=holiday_id)
def schedule_org_events(self): resolver = DataResolver(None) drama_scheduler = services.drama_scheduler_service() scheduled_org_events = [ type(drama_node) for drama_node in drama_scheduler.scheduled_nodes_gen() if self._is_organization_event_type(drama_node) ] active_org_events = [ type(drama_node) for drama_node in drama_scheduler.active_nodes_gen() if self._is_organization_event_type(drama_node) ] for org_drama_node in self.ORGANIZATION_EVENTS: if not org_drama_node in scheduled_org_events: if org_drama_node in active_org_events: continue org_start_time = self.verify_valid_time(org_drama_node) if org_start_time is None: continue gsi_data = None if is_scoring_archive_enabled(): gsi_data = GSIDramaScoringData() gsi_data.bucket = 'Organization Event' uid = drama_scheduler.schedule_node( org_drama_node, resolver, gsi_data=gsi_data, specific_time=org_start_time, setup_kwargs={'gsi_data': gsi_data}) if uid is not None: self._organization_festival_events[uid] = str( org_drama_node) drama_scheduler.add_complete_callback( uid, self._reschedule_festival_org_event) venue_service = services.venue_service() for (event_venue_tuning, org_venue_event_info) in self.VENUE_ORG_EVENT_MAPPING.items(): if not org_venue_event_info.org_drama_node_events: continue org_drama_nodes = [ drama_node for drama_node in org_venue_event_info.org_drama_node_events if drama_node not in scheduled_org_events if drama_node not in active_org_events if drama_node.guid64 not in self._schedule_cancelled_venue_event_alarm.keys() ] if not org_drama_nodes: continue max_allowed = org_venue_event_info.org_zones_to_schedule if max_allowed == 0: continue try_zones_in_preferred_regions = True preferred_zone_ids_gen = self.get_preferred_zones_gen( org_venue_event_info.org_preferred_regions, event_venue_tuning) if preferred_zone_ids_gen is None: try_zones_in_preferred_regions = False def schedule_events(zone_ids, max_allowed, org_drama_nodes): for zone_id in zone_ids: for org_drama_node in org_drama_nodes: self._schedule_venue_organization_event( org_drama_node, zone_id) max_allowed -= 1 if max_allowed <= 0: break return max_allowed if try_zones_in_preferred_regions: max_allowed = schedule_events(preferred_zone_ids_gen, max_allowed, org_drama_nodes) if max_allowed <= 0: continue else: all_zones_with_venue_tuning_gen = venue_service.get_zones_for_venue_type_gen( event_venue_tuning, region_blacklist=org_venue_event_info. org_blacklisted_regions) schedule_events(all_zones_with_venue_tuning_gen, max_allowed, org_drama_nodes)