コード例 #1
0
def filter_create_many_infos(*filter_names, _connection=None):
    def callback(results, callback_event_data):
        sims4.commands.output('Filter: {}'.format(callback_event_data),
                              _connection)
        for result in results:
            sims4.commands.output(
                '   Sim ID:{}, score: {}'.format(result.sim_info.id,
                                                 result.score), _connection)

    def get_sim_filter_gsi_name():
        return 'Sim Filter Command: Create Many Sim Infos'

    for filter_name in filter_names:
        filter_type = get_tunable_instance(sims4.resources.Types.SIM_FILTER,
                                           filter_name)
        if filter_type is not None:
            services.sim_filter_service().submit_matching_filter(
                number_of_sims_to_find=1,
                sim_filter=filter_type,
                callback=callback,
                callback_event_data=filter_name,
                gsi_source_fn=get_sim_filter_gsi_name)
            sims4.commands.output('Processing filter: {}'.format(filter_name),
                                  _connection)
        else:
            sims4.commands.output('Unknown filter: {}'.format(filter_name),
                                  _connection)
コード例 #2
0
def complete_current_milestone(opt_sim: OptionalTargetParam = None,
                               _connection=None):
    sim = get_optional_target(opt_sim, _connection)
    if sim is not None:
        track_id = sim.sim_info.primary_aspiration.guid64 if sim.sim_info.primary_aspiration is not None else 0
        if track_id == 0:
            sims4.commands.output(
                "{} doesn't have a primary aspiration.".format(sim),
                _connection)
            return
        track = get_tunable_instance(sims4.resources.Types.ASPIRATION_TRACK,
                                     track_id)
        for (_, track_aspriation) in track.get_aspirations():
            if not sim.sim_info.aspiration_tracker.milestone_completed(
                    track_aspriation):
                for objective_type in track_aspriation.objectives:
                    if not sim.sim_info.aspiration_tracker.objective_completed(
                            objective_type):
                        sim.sim_info.aspiration_tracker.complete_objective(
                            objective_type)
                sim.sim_info.aspiration_tracker.complete_milestone(
                    track_aspriation, sim.sim_info)
                sims4.commands.output(
                    'Complete {} on {}'.format(track_aspriation, sim),
                    _connection)
                sim.sim_info.aspiration_tracker.send_if_dirty()
                return
        sims4.commands.output(
            '{} has completed all milestones in {}.'.format(sim, track),
            _connection)
コード例 #3
0
def set_constrained_goal_list(*goal_names, _connection=None):
    constrained_goals = set()
    for goal_name in goal_names:
        goal_type = get_tunable_instance(sims4.resources.Types.SITUATION_GOAL, goal_name)
        if goal_type is None:
            sims4.commands.output('Invalid goal name: {} skipping.'.format(goal_name), _connection)
        constrained_goals.add(goal_type)
    situations.situation_goal_tracker.SituationGoalTracker.constrained_goals = constrained_goals
コード例 #4
0
def set_constrained_goal_list(*goal_names, _connection=None):
    constrained_goals = set()
    for goal_name in goal_names:
        goal_type = get_tunable_instance(sims4.resources.Types.SITUATION_GOAL,
                                         goal_name)
        if goal_type is None:
            sims4.commands.output(
                'Invalid goal name: {} skipping.'.format(goal_name),
                _connection)
        constrained_goals.add(goal_type)
    situations.situation_goal_tracker.SituationGoalTracker.constrained_goals = constrained_goals
コード例 #5
0
def volcanic_eruption(eruption_size, _connection=None):
    size_to_schedule_entry_dict = {'large': '0', 'small': '1'}
    zone_modifier = get_tunable_instance(
        sims4.resources.Types.ZONE_MODIFIER,
        'zoneModifier_lotTrait_VolcanicActivity')
    if zone_modifier is None:
        return
    schedule_entry_index = size_to_schedule_entry_dict.get(
        eruption_size.lower())
    if schedule_entry_index is None:
        return
    run_zone_modifier_entry(zone_modifier, schedule_entry_index, _connection)
コード例 #6
0
def filter_create_many_infos(*filter_names, _connection=None):

    def callback(results, callback_event_data):
        sims4.commands.output('Filter: {}'.format(callback_event_data), _connection)
        for result in results:
            sims4.commands.output('   Sim ID:{}, score: {}'.format(result.sim_info.id, result.score), _connection)

    for filter_name in filter_names:
        filter_type = get_tunable_instance(sims4.resources.Types.SIM_FILTER, filter_name)
        if filter_type is not None:
            services.sim_filter_service().submit_filter(filter_type, callback, callback_event_data=filter_name, create_if_needed=True)
            sims4.commands.output('Processing filter: {}'.format(filter_name), _connection)
        else:
            sims4.commands.output('Unknown filter: {}'.format(filter_name), _connection)
コード例 #7
0
def archive_sim_motives():
    sim_info_manager = services.sim_info_manager()
    if sim_info_manager is None:
        logger.error('Archiving sim motives when the sim_info_manager is absent.')
        return
    all_motives = ['motive_fun', 'motive_social', 'motive_hygiene', 'motive_hunger', 'motive_energy', 'motive_bladder']
    sim_infos = list(sim_info_manager.values())
    for sim_info in sim_infos:
        sim = sim_info.get_sim_instance()
        while sim is not None:
            archive_data = {}
            for motive in all_motives:
                cur_stat = get_tunable_instance(sims4.resources.Types.STATISTIC, motive, exact_match=True)
                tracker = sim.get_tracker(cur_stat)
                cur_value = tracker.get_value(cur_stat)
                archive_data[motive] = cur_value
            archive_data['sim_id'] = str(sim.sim_id)
            sim_motive_archiver.archive(object_id=sim.id, data=archive_data)
コード例 #8
0
def complete_objective(objective_type, opt_sim:OptionalTargetParam=None, _connection=None):
    sim = get_optional_target(opt_sim, _connection)
    if sim is not None and objective_type is not None:
        sim.sim_info.aspiration_tracker.complete_objective(objective_type)
        track_id = sim.sim_info.primary_aspiration
        if track_id != 0:
            track = get_tunable_instance(sims4.resources.Types.ASPIRATION_TRACK, track_id)
            for (_, track_aspriation) in track.get_aspirations():
                while objective_type in track_aspriation.objectives:
                    count_completed = 0
                    for obj in track_aspriation.objectives:
                        while sim.sim_info.aspiration_tracker.objective_completed(obj.guid64):
                            count_completed += 1
                    if count_completed == len(track_aspriation.objectives):
                        sim.sim_info.aspiration_tracker.complete_milestone(track_aspriation, sim.sim_info)
                    break
        sim.sim_info.aspiration_tracker.send_if_dirty()
        sims4.commands.output('Complete {} on {}'.format(objective_type, sim), _connection)
コード例 #9
0
def create_sim_info_from_templates(*sim_template_names, _connection=None):
    sims4.commands.output('Processing sim_templates: {}'.format(sim_template_names), _connection)
    sim_creators = []
    sim_templates = []
    for sim_template_name in sim_template_names:
        sim_template = get_tunable_instance(sims4.resources.Types.SIM_TEMPLATE, sim_template_name)
        sim_templates.append(sim_template)
        sim_creators.append(sim_template.sim_creator)
    (household_template_type, insertion_indexes_to_sim_creators) = filters.tunable.TunableSimFilter.find_household_template_that_contains_sim_filter(sim_creators)
    if household_template_type is not None:
        sims4.commands.output('Household template for creation: {}'.format(household_template_type), _connection)
        created_sim_infos = household_template_type.get_sim_infos_from_household(0, insertion_indexes_to_sim_creators, creation_source='template: {}'.foramt(household_template_type.__name__))
        for (index, index_to_sim_creator) in enumerate(insertion_indexes_to_sim_creators.items()):
            created_sim_info = created_sim_infos[index]
            sim_template = sim_templates[sim_creators.index(index_to_sim_creator[1])]
            sims4.commands.output('Applying:{} to  {}'.format(sim_template, created_sim_info), _connection)
            sim_template.add_template_data_to_sim(created_sim_info)
        sims4.commands.output('Finished template creation: {}'.format(created_sim_infos[0].household), _connection)
    else:
        sims4.commands.output('Failed find template for creation', _connection)
コード例 #10
0
def filter_create_many_infos(*filter_names, _connection=None):
    def callback(results, callback_event_data):
        sims4.commands.output('Filter: {}'.format(callback_event_data),
                              _connection)
        for result in results:
            sims4.commands.output(
                '   Sim ID:{}, score: {}'.format(result.sim_info.id,
                                                 result.score), _connection)

    for filter_name in filter_names:
        filter_type = get_tunable_instance(sims4.resources.Types.SIM_FILTER,
                                           filter_name)
        if filter_type is not None:
            services.sim_filter_service().submit_filter(
                filter_type,
                callback,
                callback_event_data=filter_name,
                create_if_needed=True)
            sims4.commands.output('Processing filter: {}'.format(filter_name),
                                  _connection)
        else:
            sims4.commands.output('Unknown filter: {}'.format(filter_name),
                                  _connection)
コード例 #11
0
def create_sim_info_from_templates(*sim_template_names, _connection=None):
    sims4.commands.output(
        'Processing sim_templates: {}'.format(sim_template_names), _connection)
    sim_creators = []
    sim_templates = []
    for sim_template_name in sim_template_names:
        sim_template = get_tunable_instance(sims4.resources.Types.SIM_TEMPLATE,
                                            sim_template_name)
        sim_templates.append(sim_template)
        sim_creators.append(sim_template.sim_creator)
    (
        household_template_type, insertion_indexes_to_sim_creators
    ) = filters.tunable.TunableSimFilter.find_household_template_that_contains_sim_filter(
        sim_creators)
    if household_template_type is not None:
        sims4.commands.output(
            'Household template for creation: {}'.format(
                household_template_type), _connection)
        created_sim_infos = household_template_type.get_sim_infos_from_household(
            0,
            insertion_indexes_to_sim_creators,
            creation_source='template: {}'.foramt(
                household_template_type.__name__))
        for (index, index_to_sim_creator) in enumerate(
                insertion_indexes_to_sim_creators.items()):
            created_sim_info = created_sim_infos[index]
            sim_template = sim_templates[sim_creators.index(
                index_to_sim_creator[1])]
            sims4.commands.output(
                'Applying:{} to  {}'.format(sim_template, created_sim_info),
                _connection)
            sim_template.add_template_data_to_sim(created_sim_info)
        sims4.commands.output(
            'Finished template creation: {}'.format(
                created_sim_infos[0].household), _connection)
    else:
        sims4.commands.output('Failed find template for creation', _connection)