Example #1
0
 def start(self):
     if self.dialog_on_activation is not None:
         resolver = GlobalResolver()
         if self.dialog_on_activation.tests.run_tests(resolver):
             dialog = self.dialog_on_activation.dialog(None,
                                                       resolver=resolver)
             dialog.show_dialog()
     if self.audio_sting is not None:
         play_tunable_audio(self.audio_sting)
     if self.sim_info_loots is not None:
         services.narrative_service().add_sliced_sim_info_loots(
             self.sim_info_loots.loots,
             self.sim_info_loots.save_lock_tooltip)
Example #2
0
 def test(self, tooltip):
     if self.narratives.test_collection(
             services.narrative_service().completed_narratives):
         return TestResult.TRUE
     return TestResult(False,
                       'Failed to pass narrative white/black list.',
                       tooltip=tooltip)
def has_narrative(narrative_id: int, _connection=None):
    found_narrative = False
    for active_narrative in services.narrative_service().active_narratives:
        if active_narrative.guid64 == narrative_id:
            found_narrative = True
            break
    sims4.commands.automation_output(
        'NarrativeInfo; NarrativeIsActive:{}'.format(found_narrative),
        _connection)
    return True
def restart_conservation_narrative(_connection=None):
    if services.narrative_service().is_narrative_locked(
            EP07NarrativeCommands.CONSERVATION_NARRATIVE_START_STAGE):
        sims4.commands.output(
            'Island Conservation Narrative stage locked. Please unlock to set.',
            _connection)
    resolver = SingleSimResolver(services.active_sim_info())
    loot = EP07NarrativeCommands.CONSERVATION_START_STAGE_LOOT
    if loot is None:
        return
    loot.apply_to_resolver(resolver)
 def _handle_narratives_updated(self, from_startup=False):
     required_layers = set()
     active_narratives = services.narrative_service().active_narratives
     for narrative in (n for n in self.narrative_object_layers if n in active_narratives):
         required_layers.update(self.narrative_object_layers[narrative])
     current_layers = set(self._narrative_layers)
     shut_down_layers = current_layers - required_layers
     start_up_layers = required_layers - current_layers
     load_layer_func = self.load_layer_immediately if from_startup else self.load_layer_gradually
     for layer in shut_down_layers:
         self.remove_layer_objects(layer)
     self._narrative_layers.update(start_up_layers)
     for layer in start_up_layers:
         load_layer_func(layer)
def toggle_island_conservation_narrative_lock(_connection=None):
    narrative_service = services.narrative_service()
    did_lock = False
    for narrative in (
            EP07NarrativeCommands.CONSERVATION_NARRATIVE_START_STAGE,
            EP07NarrativeCommands.CONSERVATION_NARRATIVE_INTERMEDIATE_STAGE,
            EP07NarrativeCommands.CONSERVATION_NARRATIVE_FINAL_STAGE):
        if narrative_service.is_narrative_locked(narrative):
            narrative_service.unlock_narrative(narrative)
        else:
            narrative_service.lock_narrative(narrative)
            did_lock = True
    if did_lock:
        sims4.commands.output('Island Conservation Narrative locked',
                              _connection)
    else:
        sims4.commands.output('Island Conservation Narrative unlocked',
                              _connection)
Example #7
0
def generate_narrative_view():
    narratives = []
    narrative_service = services.narrative_service()
    narrative_tuning_manager = services.get_instance_manager(Types.NARRATIVE)
    for narrative in narrative_tuning_manager.types.values():
        narratives.append({
            'narrative':
            str(narrative.__name__),
            'groups':
            ', '.join(group.name for group in narrative.narrative_groups),
            'active':
            narrative in narrative_service.active_narratives,
            'previously_completed':
            narrative in narrative_service.completed_narratives,
            'Linked Narratives':
            list({
                'event': str(event.name),
                'narrative': str(link.__name__)
            } for (event, link) in narrative.narrative_links.items())
        })
    return sorted(narratives, key=operator.itemgetter('narrative'))
 def on_spawn_sims_for_zone_spin_up(self, client):
     traveled_sim_infos = []
     for sim_id in tuple(self._sims_traveled_to_zone):
         if sim_id == 0:
             self._sims_traveled_to_zone.remove(sim_id)
         else:
             sim_info = self.get(sim_id)
             if sim_info is None:
                 logger.error('sim id {} for traveling did not spawn because sim info does not exist.', sim_id, owner='msantander')
             else:
                 traveled_sim_infos.append(sim_info)
     narrative_service = services.narrative_service()
     if not narrative_service.should_suppress_travel_sting():
         lot_tuning = world.lot_tuning.LotTuningMaps.get_lot_tuning()
         if lot_tuning is not None and lot_tuning.audio_sting is not None:
             sting = lot_tuning.audio_sting(None)
             sting.start()
         elif traveled_sim_infos:
             play_tunable_audio(TravelTuning.TRAVEL_SUCCESS_AUDIO_STING)
         else:
             play_tunable_audio(TravelTuning.NEW_GAME_AUDIO_STING)
     services.current_zone().venue_service.process_traveled_and_persisted_and_resident_sims_during_zone_spin_up(traveled_sim_infos, self._sim_infos_saved_in_zone, self._sim_infos_saved_in_plex_group, self._sim_infos_saved_in_open_street, self._sim_infos_injected_into_zone)
 def _start_welcome_wagon(self, _):
     situation_manager = services.get_zone_situation_manager()
     if situation_manager.is_user_facing_situation_running():
         self._schedule_welcome_wagon()
         return
     active_household = services.active_household()
     for sim_info in active_household.can_live_alone_info_gen():
         if sim_info.is_instanced():
             break
     else:
         self._schedule_welcome_wagon()
         return
     resolver = GlobalResolver()
     if not NPCHostedSituationService.WELCOME_WAGON_TUNING.welcome_wagon_start_tests.run_tests(
             resolver):
         active_household.needs_welcome_wagon = False
         return
     narrative_service = services.narrative_service()
     welcome_wagon_situation = narrative_service.get_possible_replacement_situation(
         NPCHostedSituationService.WELCOME_WAGON_TUNING.situation)
     if welcome_wagon_situation is NPCHostedSituationService.WELCOME_WAGON_TUNING.situation:
         region = services.current_region()
         if region.welcome_wagon_replacement is not None:
             welcome_wagon_situation = region.welcome_wagon_replacement
     guest_list = welcome_wagon_situation.get_predefined_guest_list()
     if guest_list is None:
         active_household.needs_welcome_wagon = False
         return
     game_clock_services = services.game_clock_service()
     if game_clock_services.clock_speed == ClockSpeedMode.SUPER_SPEED3:
         game_clock_services.set_clock_speed(ClockSpeedMode.NORMAL)
     situation_id = situation_manager.create_situation(
         welcome_wagon_situation,
         guest_list=guest_list,
         user_facing=False,
         scoring_enabled=False)
     if not (situation_id is None
             or not welcome_wagon_situation.sets_welcome_wagon_flag):
         active_household.needs_welcome_wagon = False
Example #10
0
def generate_narrative_links_view():
    narrative_links = []
    narrative_service = services.narrative_service()
    for (narrative_cls, narrative_instance
         ) in narrative_service.get_active_narrative_instances():
        for (event, linked_narrative) in narrative_cls.narrative_links.items():
            narrative_links.append({
                'event':
                str(event.name),
                'narrative':
                str(narrative_cls.__name__),
                'narrative_link':
                str(linked_narrative.__name__)
            })
        for (event, progression_value
             ) in narrative_instance._narrative_progression.items():
            narrative_threshold_link = narrative_instance.narrative_threshold_links[
                event]
            narrative_links.append({
                'event':
                str(event.name),
                'progression_value':
                str(progression_value),
                'above_link':
                None if narrative_threshold_link.above_link is None else str(
                    narrative_threshold_link.above_link.__name__),
                'above_threshold':
                None if narrative_threshold_link.above_link is None else str(
                    narrative_threshold_link.interval.upper_bound),
                'below_link':
                None if narrative_threshold_link.below_link is None else str(
                    narrative_threshold_link.below_link.__name__),
                'below_threshold':
                None if narrative_threshold_link.below_link is None else str(
                    narrative_threshold_link.interval.lower_bound)
            })
    return sorted(narrative_links, key=operator.itemgetter('event'))
def trigger_narrative_event(event: NarrativeEvent, _connection=None):
    services.narrative_service().handle_narrative_event(event)
Example #12
0
 def _apply_to_subject_and_target(self, subject, target, resolver):
     services.narrative_service().handle_narrative_event_progression(
         self.event, self.amount)
Example #13
0
 def perform(self, *_, **__):
     services.narrative_service().reset_completion(self.narrative)
def reset_narrative_completion(
        narrative: TunableInstanceParam(sims4.resources.Types.NARRATIVE),
        _connection=None):
    services.narrative_service().reset_completion(narrative)
 def on_add(self):
     self.on_narratives_set(services.narrative_service().active_narratives)
def end_narrative(
        narrative: TunableInstanceParam(sims4.resources.Types.NARRATIVE),
        _connection=None):
    services.narrative_service().end_narrative(narrative)
 def on_finalize_load(self):
     self.on_narratives_set(services.narrative_service().active_narratives)
def get_active_narratives(_connection=None):
    for active_narrative in services.narrative_service().active_narratives:
        sims4.commands.cheat_output('{}'.format(active_narrative.guid64),
                                    _connection)
    return True
Example #19
0
 def perform(self, *_, **__):
     services.narrative_service().handle_narrative_event(self.event)
Example #20
0
 def perform(self, *_, **__):
     services.narrative_service().end_narrative(self.narrative)
Example #21
0
 def create_situation(self,
                      situation_type,
                      guest_list=None,
                      user_facing=True,
                      duration_override=None,
                      custom_init_writer=None,
                      zone_id=0,
                      scoring_enabled=True,
                      spawn_sims_during_zone_spin_up=False,
                      creation_source=None,
                      travel_request_kwargs=frozendict(),
                      linked_sim_id=GLOBAL_SITUATION_LINKED_SIM_ID,
                      scheduled_time=None,
                      **extra_kwargs):
     zone = services.current_zone()
     if zone.is_zone_shutting_down:
         return
     current_zone_id = services.current_zone_id()
     situation_type = services.narrative_service(
     ).get_possible_replacement_situation(situation_type)
     if services.get_zone_modifier_service().is_situation_prohibited(
             zone_id if zone_id else current_zone_id, situation_type):
         return
     if guest_list is None:
         guest_list = SituationGuestList()
     hire_cost = guest_list.get_hire_cost()
     host_sim_info = guest_list.host_sim_info
     if host_sim_info is not None and not host_sim_info.household.funds.try_remove(
             situation_type.cost() + hire_cost,
             Consts_pb2.TELEMETRY_EVENT_COST, host_sim_info):
         return
     situation_id = id_generator.generate_object_id()
     self._send_create_situation_telemetry(situation_type, situation_id,
                                           guest_list, hire_cost, zone_id)
     if zone_id and zone_id != current_zone_id and scheduled_time is None:
         return self._create_situation_and_travel(
             situation_type,
             situation_id,
             guest_list,
             user_facing,
             duration_override,
             custom_init_writer,
             zone_id,
             scoring_enabled=scoring_enabled,
             creation_source=creation_source,
             linked_sim_id=linked_sim_id,
             travel_request_kwargs=travel_request_kwargs)
     situation_seed = SituationSeed(
         situation_type,
         SeedPurpose.NORMAL,
         situation_id,
         guest_list,
         user_facing=user_facing,
         duration_override=duration_override,
         zone_id=zone_id,
         scoring_enabled=scoring_enabled,
         spawn_sims_during_zone_spin_up=spawn_sims_during_zone_spin_up,
         creation_source=creation_source,
         linked_sim_id=linked_sim_id,
         **extra_kwargs)
     if custom_init_writer is not None:
         situation_seed.setup_for_custom_init_params(custom_init_writer)
     return_id = None
     if scheduled_time is not None:
         uid = services.drama_scheduler_service().schedule_node(
             self.DEFAULT_PLAYER_PLANNED_DRAMA_NODE,
             SingleSimResolver(guest_list.host_sim.sim_info),
             specific_time=scheduled_time,
             situation_seed=situation_seed)
         return_id = situation_id if uid is not None else None
     else:
         return_id = self.create_situation_from_seed(situation_seed)
     return return_id