Beispiel #1
0
 def start_situation(interaction, situation, user_facing):
     situation_manager = services.get_zone_situation_manager()
     guest_list = situation.get_predefined_guest_list()
     if guest_list is None:
         sim = interaction.sim
         guest_list = SituationGuestList(invite_only=True, host_sim_id=sim.id)
         if situation.targeted_situation is not None:
             target_sim = interaction.get_participant(ParticipantType.PickedSim)
             if target_sim is None:
                 target_sim = interaction.get_participant(ParticipantType.TargetSim)
             target_sim_id = target_sim.id if target_sim is not None else None
             job_assignments = situation.get_prepopulated_job_for_sims(sim, target_sim_id)
             for (sim_id, job_type_id) in job_assignments:
                 job_type = services.situation_job_manager().get(job_type_id)
                 guest_info = SituationGuestInfo.construct_from_purpose(sim_id, job_type, SituationInvitationPurpose.INVITED)
                 guest_list.add_guest_info(guest_info)
         else:
             default_job = situation.default_job()
             target_sims = interaction.get_participants(ParticipantType.PickedSim)
             if target_sims:
                 for sim_or_sim_info in target_sims:
                     guest_info = SituationGuestInfo.construct_from_purpose(sim_or_sim_info.sim_id, default_job, SituationInvitationPurpose.INVITED)
                     guest_list.add_guest_info(guest_info)
             else:
                 target_sim = interaction.get_participant(ParticipantType.TargetSim)
                 if target_sim is not None:
                     guest_info = SituationGuestInfo.construct_from_purpose(target_sim.sim_id, default_job, SituationInvitationPurpose.INVITED)
                     guest_list.add_guest_info(guest_info)
             guest_info = SituationGuestInfo.construct_from_purpose(sim.sim_id, default_job, SituationInvitationPurpose.INVITED)
             guest_list.add_guest_info(guest_info)
     zone_id = interaction.get_participant(ParticipantType.PickedZoneId) or 0
     situation_manager.create_situation(situation, guest_list=guest_list, user_facing=user_facing, zone_id=zone_id)
 def _create_situation(self, additional_sims_to_bring=()):
     guest_list = self._situation_to_run.get_predefined_guest_list()
     if guest_list is None:
         if self._require_predefined_guest_list:
             return
         host_sim_info = self._get_host(additional_sims_to_bring)
         if host_sim_info is None:
             return
         guest_list = SituationGuestList(invite_only=True, host_sim_id=host_sim_info.id)
     else:
         host_sim_info = self._get_host(additional_sims_to_bring)
         if host_sim_info is None:
             return
     if self._NPC_hosted_situation_player_job is not None:
         guest_list.add_guest_info(SituationGuestInfo.construct_from_purpose(self._receiver_sim_info.id, self._NPC_hosted_situation_player_job, SituationInvitationPurpose.INVITED))
     if self._NPC_host_job is not None:
         guest_list.add_guest_info(SituationGuestInfo.construct_from_purpose(host_sim_info.id, self._NPC_host_job, SituationInvitationPurpose.INVITED))
     if additional_sims_to_bring:
         additional_sims_job = self._chosen_dialog.bring_other_sims.situation_job
         for sim_info in additional_sims_to_bring:
             guest_list.add_guest_info(SituationGuestInfo.construct_from_purpose(sim_info.id, additional_sims_job, SituationInvitationPurpose.INVITED))
     if self._NPC_hosted_situation_use_player_sim_as_filter_requester:
         guest_list.filter_requesting_sim_id = self._receiver_sim_info.id
     services.get_zone_situation_manager().create_situation(self._situation_to_run, guest_list=guest_list, zone_id=self._get_zone_id(), scoring_enabled=self._NPC_hosted_situation_scoring_enabled, user_facing=self._user_facing)
     with telemetry_helper.begin_hook(telemetry_writer, TELEMETRY_HOOK_SITUATION_ACCEPTED, sim_info=self._receiver_sim_info) as hook:
         hook.write_guid(TELEMETRY_SITUATION_TYPE_ID, self._situation_to_run.guid64)
         hook.write_int(TELEMETRY_GUEST_COUNT, len(additional_sims_to_bring))
Beispiel #3
0
 def get_predefined_guest_list(cls):
     guest_list = SituationGuestList(invite_only=True)
     grabbed_members = []
     for (
             job, member_info
     ) in cls.member_job_and_role_states.org_member_jobs_and_roles.items():
         members_sim_ids = cls.get_members_sim_infos(
             job, member_info, blacklist_sims=grabbed_members)
         grabbed_members.extend(members_sim_ids)
         for member_sim_id in members_sim_ids:
             guest_list.add_guest_info(
                 SituationGuestInfo(member_sim_id, job,
                                    RequestSpawningOption.DONT_CARE,
                                    BouncerRequestPriority.BACKGROUND_HIGH))
     filter_service = services.sim_filter_service()
     grabbed_non_members = []
     for (job, role_info
          ) in cls.non_member_job_and_role_states.jobs_and_roles.items():
         non_member_ids = filter_service.submit_matching_filter(
             sim_filter=job.filter,
             number_of_sims_to_find=role_info.number_of_sims_to_find,
             allow_yielding=False,
             blacklist_sim_ids={
                 sim_info.sim_id
                 for sim_info in services.active_household()
             })
         grabbed_non_members.extend(non_member_ids)
         for non_member_result in non_member_ids:
             guest_list.add_guest_info(
                 SituationGuestInfo(non_member_result.sim_info.id, job,
                                    RequestSpawningOption.DONT_CARE,
                                    BouncerRequestPriority.BACKGROUND_HIGH))
     return guest_list
def travel_sims_to_zone(opt_sim_id:OptionalTargetParam, zone_id:int, *traveling_sim_ids, _connection=None):
    sim_or_sim_info = get_optional_target(opt_sim_id, _connection)
    if sim_or_sim_info is None:
        if opt_sim_id:
            sim_or_sim_info = services.sim_info_manager().get(opt_sim_id)
            if sim_or_sim_info is None:
                sims4.commands.output('Invalid Sim id: {} specified for travel.travel_sims_to_zone'.format(opt_sim_id), _connection)
                return False
        else:
            sims4.commands.output('No Sim id specified for travel.travel_sims_to_zone', _connection)
            return False
    zone_proto_buff = services.get_persistence_service().get_zone_proto_buff(zone_id)
    if zone_proto_buff is None:
        sims4.commands.output('Invalid Zone Id: {}. Zone does not exist.'.format(zone_id), _connection)
        return False
    situation_manager = services.get_zone_situation_manager()
    situation = situation_manager.DEFAULT_TRAVEL_SITUATION
    guest_list = situation.get_predefined_guest_list()
    if guest_list is None:
        guest_list = SituationGuestList(invite_only=True, host_sim_id=sim_or_sim_info.id)
        default_job = situation.default_job()
        sim_info_manager = services.sim_info_manager()
        roommate_service = services.get_roommate_service()
        if roommate_service is not None:
            traveling_sim_ids = tuple(itertools.chain(traveling_sim_ids, (sim_info.sim_id for sim_info in roommate_service.get_auto_invite_sim_infos(sim_or_sim_info, situation))))
        for sim_id in traveling_sim_ids:
            sim_id = int(sim_id)
            sim_info = sim_info_manager.get(sim_id)
            if sim_info is None:
                continue
            guest_info = SituationGuestInfo.construct_from_purpose(sim_id, default_job, SituationInvitationPurpose.INVITED)
            guest_list.add_guest_info(guest_info)
        guest_info = SituationGuestInfo.construct_from_purpose(sim_or_sim_info.id, default_job, SituationInvitationPurpose.INVITED)
        guest_list.add_guest_info(guest_info)
    situation_manager.create_situation(situation, guest_list=guest_list, user_facing=False, zone_id=zone_id)
 def _expand_guest_list_based_on_tuning(self):
     host_sim_id = self._guest_list.host_sim_id
     if self.resident_job(
     ) is not None and host_sim_id != 0 and self._guest_list.get_guest_info_for_sim_id(
             host_sim_id) is None:
         guest_info = SituationGuestInfo.construct_from_purpose(
             host_sim_id, self.resident_job(),
             SituationInvitationPurpose.HOSTING)
         self._guest_list.add_guest_info(guest_info)
     for job_type in self._jobs:
         if job_type is self.fan.job:
             celebrity_guest_info = next(
                 iter(
                     self._guest_list.get_guest_infos_for_job(
                         self.celebrity.job)))
             celebrity = services.sim_info_manager().get(
                 celebrity_guest_info.sim_id)
             fan_statistic = celebrity.get_statistic(
                 self.fan_count_statistic, add=False)
             if fan_statistic is None:
                 value = 0
             else:
                 value = fan_statistic.rank_level
             num_to_auto_fill = self.rank_to_fan_count.get(value, 0) - len(
                 self._guest_list.get_guest_infos_for_job(job_type))
         else:
             num_to_auto_fill = job_type.get_auto_invite() - len(
                 self._guest_list.get_guest_infos_for_job(job_type))
         for _ in range(num_to_auto_fill):
             guest_info = SituationGuestInfo.construct_from_purpose(
                 0, job_type, SituationInvitationPurpose.AUTO_FILL)
             self._guest_list.add_guest_info(guest_info)
Beispiel #6
0
 def get_predefined_guest_list(cls):
     active_sim_info = services.active_sim_info()
     door_knocker_results = services.sim_filter_service().submit_filter(cls._door_knocker_situation_job.filter, callback=None, requesting_sim_info=active_sim_info, allow_yielding=False, gsi_source_fn=cls.get_sim_filter_gsi_name)
     if not door_knocker_results:
         return
     door_knocker = random.choice(door_knocker_results)
     guest_list = SituationGuestList(invite_only=True, host_sim_id=door_knocker.sim_info.sim_id, filter_requesting_sim_id=active_sim_info.sim_id)
     guest_list.add_guest_info(SituationGuestInfo(door_knocker.sim_info.sim_id, cls._door_knocker_situation_job, RequestSpawningOption.DONT_CARE, BouncerRequestPriority.EVENT_VIP, expectation_preference=True))
     blacklist = set()
     blacklist.add(door_knocker.sim_info.sim_id)
     kava_carrier_results = services.sim_filter_service().submit_filter(cls._fruitcake_bearer_situation_job.filter, callback=None, requesting_sim_info=active_sim_info, allow_yielding=False, blacklist_sim_ids=blacklist, gsi_source_fn=cls.get_sim_filter_gsi_name)
     if not kava_carrier_results:
         return
     kava_carrier = random.choice(kava_carrier_results)
     guest_list.add_guest_info(SituationGuestInfo(kava_carrier.sim_info.sim_id, cls._fruitcake_bearer_situation_job, RequestSpawningOption.DONT_CARE, BouncerRequestPriority.EVENT_VIP, expectation_preference=True))
     blacklist.add(kava_carrier.sim_info.sim_id)
     lei_carrier_results = services.sim_filter_service().submit_filter(cls._lei_carrier_situation_job.filter, callback=None, requesting_sim_info=active_sim_info, allow_yielding=False, blacklist_sim_ids=blacklist, gsi_source_fn=cls.get_sim_filter_gsi_name)
     if not lei_carrier_results:
         return
     lei_carrier = random.choice(lei_carrier_results)
     guest_list.add_guest_info(SituationGuestInfo(lei_carrier.sim_info.sim_id, cls._lei_carrier_situation_job, RequestSpawningOption.DONT_CARE, BouncerRequestPriority.EVENT_VIP, expectation_preference=True))
     blacklist.add(lei_carrier.sim_info.sim_id)
     other_neighbors_results = services.sim_filter_service().submit_filter(cls._other_neighbors_job.filter, callback=None, requesting_sim_info=active_sim_info, allow_yielding=False, blacklist_sim_ids=blacklist, gsi_source_fn=cls.get_sim_filter_gsi_name)
     if not other_neighbors_results:
         return guest_list
     if len(other_neighbors_results) > cls._number_of_neighbors:
         neighbors = random.sample(other_neighbors_results, cls._number_of_neighbors)
     else:
         neighbors = other_neighbors_results
     for neighbor in neighbors:
         guest_list.add_guest_info(SituationGuestInfo(neighbor.sim_info.sim_id, cls._other_neighbors_job, RequestSpawningOption.DONT_CARE, BouncerRequestPriority.EVENT_VIP, expectation_preference=True))
     return guest_list
Beispiel #7
0
 def start_situation(interaction, situation, user_facing):
     situation_manager = services.get_zone_situation_manager()
     guest_list = situation.get_predefined_guest_list()
     if guest_list is None:
         sim = interaction.sim
         guest_list = SituationGuestList(invite_only=True,
                                         host_sim_id=sim.id)
         if situation.targeted_situation is not None:
             target_sim = interaction.get_participant(
                 ParticipantType.PickedSim)
             if target_sim is None:
                 target_sim = interaction.get_participant(
                     ParticipantType.TargetSim)
             target_sim_id = target_sim.id if target_sim is not None else None
             job_assignments = situation.get_prepopulated_job_for_sims(
                 sim, target_sim_id)
             for (sim_id, job_type_id) in job_assignments:
                 job_type = services.situation_job_manager().get(
                     job_type_id)
                 guest_info = SituationGuestInfo.construct_from_purpose(
                     sim_id, job_type,
                     SituationInvitationPurpose.INVITED)
                 guest_list.add_guest_info(guest_info)
         else:
             default_job = situation.default_job()
             target_sims = interaction.get_participants(
                 ParticipantType.PickedSim)
             if target_sims:
                 for sim_or_sim_info in target_sims:
                     guest_info = SituationGuestInfo.construct_from_purpose(
                         sim_or_sim_info.sim_id, default_job,
                         SituationInvitationPurpose.INVITED)
                     guest_list.add_guest_info(guest_info)
             else:
                 target_sim = interaction.get_participant(
                     ParticipantType.TargetSim)
                 if target_sim is not None:
                     guest_info = SituationGuestInfo.construct_from_purpose(
                         target_sim.sim_id, default_job,
                         SituationInvitationPurpose.INVITED)
                     guest_list.add_guest_info(guest_info)
             guest_info = SituationGuestInfo.construct_from_purpose(
                 sim.sim_id, default_job,
                 SituationInvitationPurpose.INVITED)
             guest_list.add_guest_info(guest_info)
     zone_id = interaction.get_participant(
         ParticipantType.PickedZoneId) or 0
     situation_manager.create_situation(situation,
                                        guest_list=guest_list,
                                        user_facing=user_facing,
                                        zone_id=zone_id)
 def _create_standard_ambient_guest_list(self, situation_type, *, sim_info):
     guest_list = SituationGuestList(invite_only=True)
     guest_list.add_guest_info(
         SituationGuestInfo(sim_info.sim_id, situation_type.default_job(),
                            RequestSpawningOption.MUST_SPAWN,
                            BouncerRequestPriority.BACKGROUND_LOW))
     return guest_list
Beispiel #9
0
 def submit_replace_request(self, sim, request, job_type):
     self._on_remove_sim_from_situation(sim)
     if not self.is_job_type_org_member(job_type):
         new_request = request.clone_for_replace()
         if new_request is not None:
             self.manager.bouncer.submit_request(new_request)
         return
     organization = self.member_job_and_role_states.org_member_jobs_and_roles.get(
         job_type).organization
     blacklist_sims = [sim.id]
     blacklist_sims.extend(
         sim_info.id for sim_info in services.sim_info_manager().get_all()
         if sim_info.is_player_sim)
     blacklist_sims.extend(sim.id for sim in self._situation_sims)
     additional_filter_terms = self.member_job_and_role_states.org_member_jobs_and_roles.get(
         job_type).additional_filters
     organization_member = services.organization_service(
     ).generate_organization_members(
         organization.guid64,
         amount=1,
         blacklist_sims=blacklist_sims,
         additional_filter_terms=additional_filter_terms)
     guest_info = SituationGuestInfo(organization_member[0], job_type,
                                     RequestSpawningOption.DONT_CARE,
                                     BouncerRequestPriority.BACKGROUND_HIGH)
     new_request = self._create_request_from_guest_info(guest_info)
     if new_request is not None:
         self.manager.bouncer.submit_request(new_request)
 def _on_set_sim_job(self, sim, job_type):
     super()._on_set_sim_job(sim, job_type)
     situation_manager = services.get_zone_situation_manager()
     guest_list = SituationGuestList(invite_only=True)
     guest_info = SituationGuestInfo(sim.sim_info.id, self.cafe_generic_customer_situation.default_job(), RequestSpawningOption.DONT_CARE, BouncerRequestPriority.BACKGROUND_MEDIUM)
     guest_list.add_guest_info(guest_info)
     situation_manager.create_situation(self.cafe_generic_customer_situation, guest_list=guest_list, user_facing=False)
 def get_predefined_guest_list(cls):
     guest_list = SituationGuestList(invite_only=True)
     situation_manager = services.get_zone_situation_manager()
     worker_filter = cls.group_filter if cls.group_filter is not None else cls.default_job(
     ).filter
     instanced_sim_ids = [
         sim.sim_info.id
         for sim in services.sim_info_manager().instanced_sims_gen()
     ]
     household_sim_ids = [
         sim_info.id
         for sim_info in services.active_household().sim_info_gen()
     ]
     auto_fill_blacklist = situation_manager.get_auto_fill_blacklist(
         sim_job=cls.blacklist_job)
     situation_sims = set()
     for situation in situation_manager.get_situations_by_tags(cls.tags):
         situation_sims.update(situation.invited_sim_ids)
     blacklist_sim_ids = set(
         itertools.chain(situation_sims, instanced_sim_ids,
                         household_sim_ids, auto_fill_blacklist))
     filter_results = services.sim_filter_service().submit_matching_filter(
         sim_filter=worker_filter,
         allow_yielding=False,
         blacklist_sim_ids=blacklist_sim_ids,
         gsi_source_fn=cls.get_sim_filter_gsi_name)
     if not filter_results:
         return
     for result in filter_results:
         job = cls.situation_job_mapping.get(result.tag, cls.default_job())
         guest_list.add_guest_info(
             SituationGuestInfo(result.sim_info.sim_id, job,
                                RequestSpawningOption.DONT_CARE,
                                BouncerRequestPriority.BACKGROUND_HIGH))
     return guest_list
Beispiel #12
0
 def _run_interaction_gen(self, timeline):
     logger.assert_raise(
         self.situation is not None,
         'No situation tuned on RunSituationSuperInteraction: {}'.format(
             self),
         owner='rez')
     situation_manager = services.get_zone_situation_manager()
     host_sim_id = 0
     if self.host_sim is not None:
         host_sim = self.get_participant(self.host_sim)
         if host_sim is not None:
             host_sim_id = host_sim.sim_id
     guest_list = SituationGuestList(invite_only=self.invite_only,
                                     host_sim_id=host_sim_id)
     if self.job_mapping:
         for (participant_type, job) in self.job_mapping.items():
             sim = self.get_participant(participant_type)
             if sim is not None:
                 if sim.is_sim:
                     guest_info = SituationGuestInfo.construct_from_purpose(
                         sim.sim_id, job,
                         SituationInvitationPurpose.INVITED)
                     guest_list.add_guest_info(guest_info)
     user_facing = False
     scoring_enabled = True
     if self.ui_options is not None:
         user_facing = True
         scoring_enabled = self.ui_options.scoring_enabled
     situation_manager.create_situation(self.situation,
                                        guest_list=guest_list,
                                        user_facing=user_facing,
                                        interaction=self,
                                        scoring_enabled=scoring_enabled)
     return event_testing.results.ExecuteResult.NONE
     yield
Beispiel #13
0
 def _start_scorable_situation_from_tuning(self):
     if self._scorable_situation_id is not None:
         return
     logger.assert_raise(
         self._career_events,
         'Spinning up career event manger with no career events. Manager: {}',
         self)
     career_event = self._career_events[0]
     if career_event.scorable_situation is None:
         return
     situation = career_event.scorable_situation.situation
     if situation is None:
         return
     guest_info = SituationGuestInfo.construct_from_purpose(
         self._career.sim_info.sim_id, situation.default_job(),
         SituationInvitationPurpose.CAREER)
     guest_list = SituationGuestList(
         invite_only=True,
         filter_requesting_sim_id=self._career.sim_info.sim_id)
     guest_list.add_guest_info(guest_info)
     situation_manager = services.get_zone_situation_manager()
     duration = self._career.time_until_end_of_work().in_minutes()
     self._scorable_situation_id = situation_manager.create_situation(
         situation, guest_list=guest_list, duration_override=duration)
     self._scorable_situation_setup()
 def _send_service_npc(self, scheduler, alarm_data, situation_creation_params):
     household = situation_creation_params.hiring_household
     service_npc_type = situation_creation_params.service_npc_type
     if not self._auto_scheduled_services_enabled and service_npc_type.auto_schedule_on_client_connect():
         return
     service_record = household.get_service_npc_record(service_npc_type.guid64)
     preferred_sim_id = service_record.get_preferred_sim_id()
     situation_type = service_npc_type.situation
     user_specified_data_id = situation_creation_params.user_specified_data_id
     now = services.time_service().sim_now
     if service_record.time_last_started_service is not None and alarm_data.start_time is not None:
         alarm_start_time_absolute = date_and_time_from_week_time(now.week(), alarm_data.start_time)
         if service_record.time_last_started_service >= alarm_start_time_absolute:
             return
     service_record.time_last_started_service = now
     service_record.time_last_finished_service = None
     duration = alarm_data.end_time - now.time_since_beginning_of_week()
     min_duration = service_npc_type.min_duration_left_for_arrival_on_lot()
     if duration < min_duration:
         service_npc_type.fake_perform(household)
         return
     min_duration = service_npc_type.min_work_duration()
     max_duration = service_npc_type.max_work_duration()
     duration = clamp(min_duration, duration.in_minutes(), max_duration)
     guest_list = SituationGuestList(True)
     if preferred_sim_id is not None:
         guest_list.add_guest_info(SituationGuestInfo.construct_from_purpose(preferred_sim_id, situation_type.default_job(), SituationInvitationPurpose.PREFERRED))
     situation_creation_params_writer = PropertyStreamWriter()
     situation_creation_params_writer.write_uint64('household_id', household.id)
     situation_creation_params_writer.write_uint64('service_npc_type_id', service_npc_type.guid64)
     if user_specified_data_id is not None:
         situation_creation_params_writer.write_uint64('user_specified_data_id', user_specified_data_id)
     situation_creation_params_writer.write_bool('is_recurring', situation_creation_params.is_recurring)
     self._situation_id = services.get_zone_situation_manager().create_situation(situation_type, guest_list, user_facing=False, duration_override=duration, custom_init_writer=situation_creation_params_writer)
 def _run_situation(self):
     host_sim_id = 0
     host_sim_info = None
     if self.host_sim_participant is not None:
         host_sim_info = self._get_resolver().get_participant(
             self.host_sim_participant)
         host_sim_id = host_sim_info.id
     guest_list = self.situation_to_run.get_predefined_guest_list()
     if guest_list is None:
         guest_list = SituationGuestList(invite_only=True,
                                         host_sim_id=host_sim_id)
     if self._sender_sim_info is not None and self.sender_sim_info_job is not None:
         guest_list.add_guest_info(
             SituationGuestInfo.construct_from_purpose(
                 self._sender_sim_info.id, self.sender_sim_info_job,
                 SituationInvitationPurpose.INVITED))
     if host_sim_info is not None and self.host_sim_info_job is not None:
         guest_list.add_guest_info(
             SituationGuestInfo.construct_from_purpose(
                 host_sim_info.id, self.host_sim_info_job,
                 SituationInvitationPurpose.HOSTING))
     zone_id = 0
     if self.lot is not None:
         lot_id = get_lot_id_from_instance_id(self.lot)
         zone_id = services.get_persistence_service(
         ).resolve_lot_id_into_zone_id(lot_id, ignore_neighborhood_id=True)
     situation_id = services.get_zone_situation_manager().create_situation(
         self.situation_to_run,
         guest_list=guest_list,
         spawn_sims_during_zone_spin_up=self.spawn_sims_during_zone_spin_up,
         user_facing=self.user_facing,
         zone_id=zone_id)
     if self.household_milestone and situation_id:
         active_household_milestone_tracker = services.active_household(
         ).household_milestone_tracker
         active_household_milestone_tracker.reset_milestone(
             self.household_milestone)
     if self.notification is not None:
         target_sim_id = self._sender_sim_info.id if self._sender_sim_info is not None else None
         dialog = self.notification(self._receiver_sim_info,
                                    DoubleSimResolver(
                                        self._sender_sim_info,
                                        self._receiver_sim_info),
                                    target_sim_id=target_sim_id)
         dialog.show_dialog()
     return True
Beispiel #16
0
 def get_predefined_guest_list(cls):
     if not cls.force_patient_on_active_career_sim:
         return
     career = services.get_career_service().get_career_in_career_event()
     if career is None:
         return
     guest_list = SituationGuestList(invite_only=True)
     guest_list.add_guest_info(SituationGuestInfo(career.sim_info.sim_id, cls.default_job(), RequestSpawningOption.CANNOT_SPAWN, BouncerRequestPriority.EVENT_VIP))
     return guest_list
Beispiel #17
0
 def get_predefined_guest_list(cls):
     active_sim_info = services.active_sim_info()
     fire_brigade_volunteers = services.sim_filter_service().submit_matching_filter(number_of_sims_to_find=cls.number_of_volunteers, sim_filter=cls.fire_brigade_job.filter, requesting_sim_info=active_sim_info, allow_yielding=False, blacklist_sim_ids={sim_info.sim_id for sim_info in services.active_household()}, gsi_source_fn=cls.get_sim_filter_gsi_name)
     if len(fire_brigade_volunteers) < cls.number_of_volunteers:
         return
     guest_list = SituationGuestList(invite_only=True, host_sim_id=fire_brigade_volunteers[0].sim_info.sim_id, filter_requesting_sim_id=active_sim_info.sim_id)
     for volunteer in fire_brigade_volunteers:
         guest_list.add_guest_info(SituationGuestInfo(volunteer.sim_info.sim_id, cls.fire_brigade_job, RequestSpawningOption.DONT_CARE, BouncerRequestPriority.EVENT_VIP, expectation_preference=True))
     return guest_list
Beispiel #18
0
 def get_predefined_guest_list(cls):
     guest_list = SituationGuestList(invite_only=True)
     members_sim_ids = cls.get_members_sim_infos()
     for member_sim_id in members_sim_ids:
         guest_list.add_guest_info(
             SituationGuestInfo(member_sim_id, cls.job_and_role_state.job,
                                RequestSpawningOption.DONT_CARE,
                                BouncerRequestPriority.BACKGROUND_HIGH))
     return guest_list
 def create_arrival_situation_for_sim(self, sim_info, situation_type=DEFAULT, during_spin_up=False):
     if situation_type is DEFAULT:
         situation_type = self.user_sim_arrival_situation
     situation_manager = services.get_zone_situation_manager()
     if during_spin_up and self._sim_info_already_in_arrival_situation(sim_info, situation_manager):
         return
     guest_list = SituationGuestList(invite_only=True)
     guest_info = SituationGuestInfo.construct_from_purpose(sim_info.id, situation_type.default_job(), SituationInvitationPurpose.INVITED)
     guest_list.add_guest_info(guest_info)
     self.create_arrival_situation(situation_type, guest_list, situation_manager)
 def _create_fire_situation_on_sim(self, sim, situation_manager=None):
     if sim.id in self._situation_ids:
         return
     if situation_manager is None:
         situation_manager = services.current_zone().situation_manager
     guest_list = SituationGuestList(invite_only=True)
     guest_info = SituationGuestInfo.construct_from_purpose(sim.sim_id, self.FIRE_JOB, SituationInvitationPurpose.INVITED)
     guest_list.add_guest_info(guest_info)
     situation_id = situation_manager.create_situation(self.FIRE_SITUATION, guest_list=guest_list, user_facing=False)
     self._situation_ids[sim.id] = situation_id
 def create_situations_during_zone_spin_up(self):
     sim_info = self._career_event.sim_info
     career = sim_info.careers.get(self.detective_career.guid64)
     if career is not None:
         situation_manager = services.get_zone_situation_manager()
         situation_manager.create_situation(self.apb_neutral_situation, user_facing=False, creation_source=self.instance_name)
         guest_list = SituationGuestList(invite_only=True, filter_requesting_sim_id=sim_info.sim_id)
         if not career.active_criminal_sim_id:
             career.create_criminal_fixup()
         guest_list.add_guest_info(SituationGuestInfo(career.active_criminal_sim_id, self.apb_situation_job_criminal, RequestSpawningOption.DONT_CARE, BouncerRequestPriority.EVENT_VIP))
         guest_list.add_guest_info(SituationGuestInfo(sim_info.sim_id, self.apb_situation_job_detective, RequestSpawningOption.DONT_CARE, BouncerRequestPriority.EVENT_VIP))
         decoy_sim_ids = career.get_decoy_sim_ids_for_apb(persisted_sim_ids=self._persisted_decoy_sim_ids)
         for decoy in decoy_sim_ids:
             guest_list.add_guest_info(SituationGuestInfo(decoy, self.apb_situation_job_decoy, RequestSpawningOption.DONT_CARE, BouncerRequestPriority.EVENT_VIP))
         self._persisted_decoy_sim_ids = None
         self._apb_situation_id = situation_manager.create_situation(self.apb_situation, guest_list=guest_list, spawn_sims_during_zone_spin_up=True, user_facing=False, creation_source=self.instance_name)
         with telemetry_helper.begin_hook(detective_apb_telemetry_writer, TELEMETRY_HOOK_APB_CALL, sim_info=sim_info) as hook:
             hook.write_int(TELEMETRY_CLUES_FOUND, len(career.get_discovered_clues()))
     return super().create_situations_during_zone_spin_up()
 def _generate_situation_guest_list(self, preferred_sim_id,
                                    service_npc_type, hiring_household):
     guest_list = SituationGuestList(invite_only=True)
     blacklist_sim_ids = hiring_household.get_all_fired_service_npc_ids()
     roommate_service = services.get_roommate_service()
     if roommate_service is not None:
         blacklist_sim_ids.update(roommate_service.get_roommate_ids())
     if preferred_sim_id is not None:
         guest_info = SituationGuestInfo.construct_from_purpose(
             preferred_sim_id, service_npc_type.situation.default_job(),
             SituationInvitationPurpose.PREFERRED)
         guest_info.expectation_preference = True
         guest_list.add_guest_info(guest_info)
         return guest_list
     if service_npc_type.exclusive_to_household:
         household_manager = services.household_manager()
         if household_manager is None:
             logger.error(
                 'Household manager is None when service npc is being scheduled for service type {}',
                 service_npc_type)
             return guest_list
         for household in household_manager.values():
             if household.id == hiring_household:
                 continue
             blacklist_sim_ids.update(
                 household.get_preferred_service_npcs())
     worker_filter = service_npc_type.situation.default_job().filter
     filter_results = services.sim_filter_service().submit_matching_filter(
         sim_filter=worker_filter,
         allow_yielding=False,
         blacklist_sim_ids=blacklist_sim_ids,
         gsi_source_fn=self.get_sim_filter_gsi_name)
     if not filter_results:
         return guest_list
     for result in filter_results:
         guest_info = SituationGuestInfo.construct_from_purpose(
             result.sim_info.sim_id,
             service_npc_type.situation.default_job(),
             SituationInvitationPurpose.PREFERRED)
         guest_info.expectation_preference = True
         guest_list.add_guest_info(guest_info)
     return guest_list
Beispiel #23
0
 def deserialize_from_proto(cls, seed_proto):
     situation_type = services.situation_manager().get(seed_proto.situation_type_id)
     if situation_type is None:
         return
     guest_list = SituationGuestList(seed_proto.invite_only, seed_proto.host_sim_id, seed_proto.filter_requesting_sim_id)
     for assignment in seed_proto.assignments:
         job_type = services.situation_job_manager().get(assignment.job_type_id)
         if job_type is None:
             continue
         role_state_type = services.role_state_manager().get(assignment.role_state_type_id)
         guest_info = SituationGuestInfo(assignment.sim_id, job_type, RequestSpawningOption(assignment.spawning_option), BouncerRequestPriority(assignment.request_priority), assignment.expectation_preference, assignment.accept_alternate_sim, SituationCommonBlacklistCategory(assignment.common_blacklist_categories), elevated_importance_override=assignment.elevated_importance_override, reservation=assignment.reservation)
         guest_info._set_persisted_role_state_type(role_state_type)
         guest_list.add_guest_info(guest_info)
     if seed_proto.HasField('duration'):
         duration = seed_proto.duration
     else:
         duration = None
     seed = SituationSeed(situation_type, seed_proto.seed_purpose, seed_proto.situation_id, guest_list, seed_proto.user_facing, duration, seed_proto.zone_id, date_and_time.DateAndTime(seed_proto.start_time), seed_proto.scoring_enabled, main_goal_visiblity=seed_proto.main_goal_visibility, linked_sim_id=seed_proto.linked_sim_id)
     seed._score = seed_proto.score
     if seed_proto.HasField('create_time'):
         seed._travel_time = DateAndTime(seed_proto.create_time)
     for job_data in seed_proto.jobs_and_role_states:
         job_type = services.situation_job_manager().get(job_data.job_type_id)
         if job_type is None:
             continue
         role_state_type = services.role_state_manager().get(job_data.role_state_type_id)
         if role_state_type is None:
             continue
         emotional_loot_actions_type = None
         if job_data.HasField('emotional_loot_actions_type_id'):
             emotional_loot_actions_type = services.action_manager().get(job_data.emotional_loot_actions_type_id)
         seed.add_job_data(job_type, role_state_type, emotional_loot_actions_type)
     if seed_proto.HasField('simple_data'):
         seed.add_situation_simple_data(seed_proto.simple_data.phase_index, seed_proto.simple_data.remaining_phase_time)
     elif seed_proto.HasField('complex_data'):
         complex_data = seed_proto.complex_data
         situation_custom_data = complex_data.situation_custom_data if complex_data.HasField('situation_custom_data') else None
         state_custom_data = complex_data.state_custom_data if complex_data.HasField('state_custom_data') else None
         seed.setup_for_complex_load(situation_custom_data, state_custom_data)
     if seed_proto.HasField('goal_tracker_data'):
         seed._goal_tracker = GoalTrackerSeedling.deserialize_from_proto(seed_proto.goal_tracker_data)
     return seed
Beispiel #24
0
 def __call__(self, interaction, picked_sim_ids):
     guest_list = SituationGuestList(invite_only=True)
     adoption_service = services.get_adoption_service()
     for sim_id in picked_sim_ids:
         replacement_sim_info = adoption_service.convert_base_sim_info_to_full(sim_id)
         if replacement_sim_info is None:
             sim_id_to_adopt = sim_id
         else:
             sim_id_to_adopt = replacement_sim_info.sim_id
         guest_list.add_guest_info(SituationGuestInfo(sim_id_to_adopt, self.adoptee_situation_job, RequestSpawningOption.DONT_CARE, BouncerRequestPriority.EVENT_VIP, reservation=True))
     services.get_zone_situation_manager().create_situation(self.situation_type, guest_list=guest_list, user_facing=False)
Beispiel #25
0
 def get_predefined_guest_list(cls):
     active_sim_info = services.active_sim_info()
     guest_list = SituationGuestList(invite_only=True, host_sim_id=active_sim_info.id)
     worker_filter = cls.group_filter if cls.group_filter is not None else cls.default_job().filter
     filter_results = services.sim_filter_service().submit_matching_filter(sim_filter=worker_filter, allow_yielding=False, gsi_source_fn=cls.get_sim_filter_gsi_name)
     if not filter_results:
         logger.error('Failed to find/create any sims for {}; using defaults in ambient service', cls, owner='rez')
         return guest_list
     for result in filter_results:
         guest_list.add_guest_info(SituationGuestInfo(result.sim_info.sim_id, cls.default_job(), RequestSpawningOption.MUST_SPAWN, BouncerRequestPriority.BACKGROUND_LOW))
     return guest_list
 def get_all_sim_arrival_guest_list(self, situation_manager, during_spin_up=False):
     sim_infos = [sim_info for sim_info in self.get_user_controlled_sim_infos()]
     if self.place_travel_companion_in_same_arrival_situation:
         sim_infos.extend(self._traveled_sim_infos)
     guest_list = SituationGuestList(invite_only=True)
     for sim_info in sim_infos:
         if during_spin_up and self._sim_info_already_in_arrival_situation(sim_info, situation_manager):
             continue
         guest_info = SituationGuestInfo.construct_from_purpose(sim_info.id, self.user_sim_arrival_situation.default_job(), SituationInvitationPurpose.INVITED)
         guest_list.add_guest_info(guest_info)
     return guest_list
 def _start_special_event(dialog):
     guest_list = None
     if dialog.accepted:
         start_user_facing = True
         guest_list = SituationGuestList()
         guest_info = SituationGuestInfo.construct_from_purpose(invited_sim.id, situation.venue_situation_player_job, SituationInvitationPurpose.INVITED)
         guest_list.add_guest_info(guest_info)
     else:
         start_user_facing = False
     situation_id = situation_manager.create_situation(situation, guest_list=guest_list, user_facing=start_user_facing)
     self._active_special_event_id = situation_id
 def _on_set_sim_job(self, sim, job_type):
     super()._on_set_sim_job(sim, job_type)
     situation_manager = services.get_zone_situation_manager()
     guest_list = SituationGuestList(invite_only=True)
     guest_info = SituationGuestInfo.construct_from_purpose(
         sim.sim_info.id, self.party_goer_situation.default_job(),
         SituationInvitationPurpose.INVITED)
     guest_list.add_guest_info(guest_info)
     situation_manager.create_situation(self.party_goer_situation,
                                        guest_list=guest_list,
                                        user_facing=False)
Beispiel #29
0
 def _expand_guest_list_based_on_tuning(self):
     super()._expand_guest_list_based_on_tuning()
     sim_info_manager = services.sim_info_manager()
     sim_info = sim_info_manager.get(self._guest_list.host_sim_id)
     if sim_info == None:
         logger.error('Host sim id {} is invalid while creating the island spirit visit situation', self._guest_list.host_sim_id)
     resolver = SingleSimResolver(sim_info)
     if not self.island_elemental.spawn_tests.run_tests(resolver):
         return
     guest_info = SituationGuestInfo(0, self.island_elemental.situation_job, spawning_option=RequestSpawningOption.DONT_CARE, request_priority=BouncerRequestPriority.EVENT_VIP, expectation_preference=True, accept_alternate_sim=True)
     self._guest_list.add_guest_info(guest_info)
 def start_career_situation(self):
     if self._career_situation is not None:
         guest_info = SituationGuestInfo.construct_from_purpose(self._sim_info.sim_id, self._career_situation.job, SituationInvitationPurpose.CAREER)
         guest_list = SituationGuestList()
         guest_list.add_guest_info(guest_info)
         situation_manager = services.get_zone_situation_manager()
         situation = self._career_situation.situation
         if not situation.has_venue_location():
             logger.error("Tried starting a career event, career:{}  level:{}, and couldn't find a valid venue. There should ALWAYS be a Maxis Lot tuned for every venue type. - trevorlindsey", self, self.level)
             return False
         zone_id = situation.get_venue_location()
         self._career_situation_id = situation_manager.create_situation(self._career_situation.situation, guest_list=guest_list, zone_id=zone_id)
Beispiel #31
0
 def _expand_guest_list_based_on_tuning(self):
     zone_data = services.get_persistence_service().get_zone_proto_buff(services.current_zone_id())
     lot_trait_manager = services.get_instance_manager(sims4.resources.Types.ZONE_MODIFIER)
     for lot_trait_id in zone_data.lot_traits:
         lot_trait = lot_trait_manager.get(lot_trait_id)
         if lot_trait in self.auto_invite_disabled_traits:
             return
     num_to_auto_fill = self.min_number_of_guests - len(self._guest_list.get_guest_infos_for_job(self.guest_job))
     if num_to_auto_fill > 0:
         for _ in range(num_to_auto_fill):
             guest_info = SituationGuestInfo.construct_from_purpose(0, self.island_guest_job, SituationInvitationPurpose.AUTO_FILL)
             self._guest_list.add_guest_info(guest_info)
 def get_predefined_guest_list(cls):
     guest_list = SituationGuestList(True)
     worker_filter = cls.default_job().filter
     sim_infos = services.sim_filter_service().submit_filter(
         worker_filter,
         None,
         allow_yielding=False,
         gsi_source_fn=cls.get_sim_filter_gsi_name)
     if sim_infos:
         guest_list.add_guest_info(
             SituationGuestInfo(sim_infos[0].sim_info.sim_id,
                                cls.default_job(),
                                RequestSpawningOption.DONT_CARE,
                                BouncerRequestPriority.GAME_BREAKER))
     else:
         guest_list.add_guest_info(
             SituationGuestInfo(0,
                                cls.default_job(),
                                RequestSpawningOption.DONT_CARE,
                                BouncerRequestPriority.GAME_BREAKER,
                                accept_alternate_sim=True))
     return guest_list
 def _create_NPC_hosted_situation(dialog):
     if not dialog.accepted:
         with telemetry_helper.begin_hook(writer, TELEMETRY_HOOK_SITUATION_REJECTED, sim=player_sim) as hook:
             hook.write_guid('type', chosen_situation.guid64)
         return
     guest_list = SituationGuestList(host_sim_id=NPC_sim_id)
     if chosen_situation.NPC_hosted_situation_use_player_sim_as_filter_requester:
         guest_list.filter_requesting_sim_id = player_sim.id
     guest_list.add_guest_info(SituationGuestInfo.construct_from_purpose(player_sim.id, chosen_situation.NPC_hosted_situation_player_job, SituationInvitationPurpose.INVITED))
     chosen_zone_id = chosen_situation.get_venue_location()
     services.get_zone_situation_manager().create_situation(chosen_situation, guest_list=guest_list, zone_id=chosen_zone_id)
     self.add_cooldown(self._cooldown)
     with telemetry_helper.begin_hook(writer, TELEMETRY_HOOK_SITUATION_ACCEPTED, sim=player_sim) as hook:
         hook.write_guid('type', chosen_situation.guid64)
def force_career_event(career_situation_type, opt_sim:OptionalTargetParam=None, _connection=None):
    sim = get_optional_target(opt_sim, _connection)
    if not sim:
        sims4.commands.output('Invalid Sim ID: {}'.format(opt_sim), _connection)
        return
    guest_info = SituationGuestInfo.construct_from_purpose(sim.id, career_situation_type.job, SituationInvitationPurpose.CAREER)
    guest_list = SituationGuestList()
    guest_list.add_guest_info(guest_info)
    situation_manager = services.get_zone_situation_manager()
    situation = career_situation_type.situation
    if not situation.has_venue_location():
        logger.error("Tried forcing a career event:{} and couldn't find a valid venue.", career_situation_type)
        return False
    zone_id = situation.get_venue_location()
    situation_manager.create_situation(situation, guest_list=guest_list, zone_id=zone_id)
 def _run_interaction_gen(self, timeline):
     logger.assert_raise(self.situation is not None, 'No situation tuned on RunSituationSuperInteraction: {}'.format(self), owner='rez')
     situation_manager = services.get_zone_situation_manager()
     host_sim_id = 0
     host_sim = self.get_participant(self.host_sim)
     if host_sim is not None:
         host_sim_id = host_sim.sim_id
     guest_list = SituationGuestList(host_sim_id=host_sim_id)
     if self.job_mapping:
         for (participant_type, job) in self.job_mapping.items():
             sim = self.get_participant(participant_type)
             while sim is not None and sim.is_sim:
                 guest_info = SituationGuestInfo.construct_from_purpose(sim.sim_id, job, SituationInvitationPurpose.INVITED)
                 guest_list.add_guest_info(guest_info)
     situation_manager.create_situation(self.situation, guest_list=guest_list, user_facing=False)
     return event_testing.results.ExecuteResult.NONE
def create_situation_with_guest_list(situation_type, scoring_enabled, zone_id:int=0, *args, _connection=None):
    if len(args) % 3 != 0:
        sims4.commands.output('Invalid guest list, its length must be a multiple of 3', _connection)
        return False
    situation_manager = services.get_zone_situation_manager()
    client = services.client_manager().get(_connection)
    if client.active_sim is not None:
        host_sim_id = client.active_sim.id
        client.active_sim.household.set_situation_scoring(scoring_enabled)
    else:
        host_sim_id = 0
    guest_list = SituationGuestList(situation_type.force_invite_only, host_sim_id)
    guest_list_is_good = True
    for (job_name_or_key, sim_id_or_name, purpose_name) in zip(args[0::3], args[1::3], args[2::3]):
        job_type = services.situation_job_manager().get(job_name_or_key)
        if job_type is None:
            sims4.commands.output('Invalid job name or key: {}'.format(job_name_or_key), _connection)
            guest_list_is_good = False
        try:
            purpose = SituationInvitationPurpose(purpose_name)
        except ValueError:
            sims4.commands.output('Invalid Purpose: {}. Use INVITED, HIRED, or PREFERRED'.format(purpose_name), _connection)
            guest_list_is_good = False
            continue
        try:
            sim_id = int(sim_id_or_name)
        except (ValueError, TypeError):
            sims4.commands.output('Incorrectly formatted sim_id {}'.format(sim_id_or_name), _connection)
            guest_list_is_good = False
            continue
        guest_info = SituationGuestInfo.construct_from_purpose(sim_id, job_type, purpose)
        guest_list.add_guest_info(guest_info)
    if not guest_list_is_good:
        sims4.commands.output('FAILURE: bad guest list {}.'.format(situation_type), _connection)
        return False
    situation_id = situation_manager.create_situation(situation_type, guest_list=guest_list, zone_id=zone_id, scoring_enabled=scoring_enabled)
    if situation_id is not None:
        sims4.commands.output('Successfully created situation: {}.'.format(situation_id), _connection)
    else:
        sims4.commands.output('Insufficient funds to create situation', _connection)
    return True