def _csf_reset_slider(slider_name: str, opt_sim: OptionalSimInfoParam = None, _connection: int = None): output = CheatOutput(_connection) output('Resetting slider \'{}\'.'.format(slider_name)) sim_info = get_optional_target(opt_sim, target_type=OptionalSimInfoParam, _connection=_connection) if sim_info is None: output('Failed, No Sim found!') return False output('Resetting slider for \'{}\'.'.format( CommonSimNameUtils.get_full_name(sim_info))) from cncustomsliderframework.sliders.query.slider_query_utils import CSFSliderQueryUtils custom_sliders = CSFSliderQueryUtils().get_sliders_by_name( sim_info, slider_name) if not custom_sliders: output('Invalid Slider! \'{}\''.format(slider_name)) output('Available Sliders:') for custom_slider in CSFSliderQueryUtils().get_sliders_for_sim( sim_info): output('>{}'.format(custom_slider.raw_display_name)) return False custom_slider = next(iter(custom_sliders)) if custom_slider is not None: output('Slider found.') else: output('Invalid Slider! \'{}\''.format(slider_name)) output('Available Sliders:') for custom_slider in CSFSliderQueryUtils().get_sliders_for_sim( sim_info): output('>{}'.format(custom_slider.raw_display_name)) return False CSFCustomSliderApplicationService().reset_slider(sim_info, custom_slider) output('Success, Sliders reset.')
def _csf_command_log_slider_tags(_connection: int = None): output = CheatOutput(_connection) output( 'Logging Slider tags, this will take awhile and your game may freeze. Be Patient!' ) try: log.enable() slider_results = [] for slider_tag_value in CSFSliderQueryRegistry()._slider_library.keys( ): sliders = CSFSliderQueryRegistry( )._slider_library[slider_tag_value] count = len(sliders) slider_result = { 'tag_type': str(slider_tag_value), 'count': count, } slider_results.append(slider_result) sorted_sliders = sorted(slider_results, key=lambda res: res['tag_type']) log.debug('<Slider Tag>: <Count>') for slider in sorted_sliders: log.debug('{}: {}'.format(slider['tag_type'], slider['count'])) log.disable() output('Slider Tags logged') except Exception as ex: log.error('Something happened', exception=ex) output('Failed to log Slider tags.')
def _cm_max_motive(motive_name: str, opt_sim: OptionalSimInfoParam = None, _connection: int = None): output = CheatOutput(_connection) sim_info = get_optional_target(opt_sim, target_type=OptionalSimInfoParam, _connection=_connection) if sim_info is None: output('Failed, No Sim found!') return False if not CMMotiveUtils().can_translate_motive(sim_info, motive_name): output( 'Invalid motive: Valid motives for \'{}\' are as follows:'.format( CommonSimNameUtils.get_full_name(sim_info))) for motive in CMMotiveUtils().get_valid_motives(sim_info): output('- {}'.format(motive)) return False output('Setting motive \'{}\' to \'{}\' for \'{}\''.format( motive_name, 100.0, CommonSimNameUtils.get_full_name(sim_info))) result = CMMotiveUtils().change_motive_level(sim_info, motive_name, 100.0) if not result: output('Failed to set motive level.') else: output('Success!') output('Done')
def _cm_help(opt_sim: OptionalSimInfoParam = None, _connection: int = None): output = CheatOutput(_connection) output( 'Motive values range from -100.0 to 100.0. With 0.0 being 50% of the Motive bar.' ) sim_info = get_optional_target(opt_sim, target_type=OptionalSimInfoParam, _connection=_connection) if sim_info is not None: output('Available Motives for the current Sim:') output('Hygiene is the same as Hydration for Mermaids.') output('Social is the same as Affection for Pets.') for motive in CMMotiveUtils().get_valid_motives(sim_info): output('- {}'.format(motive)) output('Available Commands:') output('cm.set <motive_name> <level>') output( ' | Set the motive level of a Sim. "level" can be -100.0 to 100.0') output('cm.max <motive_name>') output(' | Set the motive level of a Sim to its maximum 100.0.') output('cm.min <motive_name>') output(' | Set the motive level of a Sim to its minimum -100.0.') output('cm.min_all') output(' | Set all motives of a Sim to their minimum -100.0.') output('cm.max_all') output(' | Set all motives of a Sim to their maximum 100.0.')
def _common_testing_spawn_object_on_lot(object_id: str = '20359', _connection: Any = None): output = CheatOutput(_connection) # noinspection PyBroadException try: object_id = int(object_id) except Exception: output('object_id must be an number.') output( 'Attempting to spawn object on the current lot with id \'{}\'.'.format( object_id)) from sims4communitylib.utils.sims.common_sim_location_utils import CommonSimLocationUtils from sims4communitylib.utils.sims.common_sim_utils import CommonSimUtils from sims4communitylib.utils.objects.common_object_utils import CommonObjectUtils active_sim_info = CommonSimUtils.get_active_sim_info() location = CommonSimLocationUtils.get_location(active_sim_info) try: game_object = CommonObjectSpawnUtils.spawn_object_on_lot( object_id, location) if game_object is None: output('Failed to spawn object.') else: output( 'Object spawned successfully. Can you see it? Object Id: {}'. format(CommonObjectUtils.get_object_id(game_object))) except Exception as ex: CommonExceptionHandler.log_exception( ModInfo.get_identity(), 'Error occurred trying to spawn object.', exception=ex) output('Done spawning object.')
def _csf_show_sliders(_connection: int = None): output = CheatOutput(_connection) output('Showing loaded Sliders') CSFSliderRegistry().log.enable() for (unique_id, slider) in CSFSliderRegistry().sliders.items(): CSFSliderRegistry().log.debug(repr(slider)) CSFSliderRegistry().log.disable() output('Done showing loaded Sliders.')
def _cgs_command_clear_global_settings(_connection: int = None): output = CheatOutput(_connection) output('Clearing CGS Mod Data.') CGSDataManagerUtils().reset(prevent_save=True) output('!!! PLEASE READ !!!') output( 'Settings reset to default. Please restart your game without saving.') output('!!!!!!!!!!!!!!!!!!!')
def _oc_show_cas_parts(_connection: int = None): output = CheatOutput(_connection) output('Showing loaded CAS Parts') OCCASPartRegistry().log.enable() for cas_part in OCCASPartRegistry().cas_part_collection: OCCASPartRegistry().log.debug(repr(cas_part)) OCCASPartRegistry().log.disable() output('Done showing loaded CAS Parts.')
def _cgs_command_print_sim_data(_connection: int = None): output = CheatOutput(_connection) sim_info = CommonSimUtils.get_active_sim_info() output('Sim Data for Sim: Name: \'{}\' Id: \'{}\''.format( CommonSimNameUtils.get_full_name(sim_info), CommonSimUtils.get_sim_id(sim_info))) sim_storage = CGSSimData(sim_info) for (key, value) in sim_storage._data.items(): output(' > {}: {}'.format(pformat(key), pformat(value)))
def _cgs_command_print_mod_data(_connection: int = None): output = CheatOutput(_connection) output( 'Printing CGS Mod Data to Messages.txt file. This may take a little bit, be patient.' ) log.enable() log.format(data_store_data=CGSDataManagerUtils().get_all_data()) log.disable() output('Done')
def _oc_is_cas_part_loaded(part_id: int = None, _connection: int = None): output = CheatOutput(_connection) if part_id is None: output('No CAS Part specified!') return output('Checking if CAS Part {} is loaded.'.format(part_id)) if CommonCASUtils.is_cas_part_loaded(part_id): output('CAS Part is loaded.') else: output('CAS Part is not loaded.')
def _s4asm_perform_autosave(_connection: int=None): try: output = CheatOutput(_connection) output('Attempting to perform autosave.') if _AutosaveHandler._time_to_save(): output('Done doing autosave.') else: output('ERROR: Failed to autosave.') except Exception as ex: CommonExceptionHandler.log_exception(ModInfo.get_identity(), 'An exception occurred while autosaving.', exception=ex)
def _csf_command_reload_sliders(_connection: int = None): output = CheatOutput(_connection) output('Reloading Sliders.') if CSFSliderQueryRegistry()._collecting: output('Failed, Sliders are already being reloaded.') return CSFSliderQueryRegistry().trigger_collection() output( 'Finished triggering a reload. Now you must wait for the Sliders to finish loading. A notification will appear in the top right of your screen when they are done loading.' )
def set_friendship_decay(new_friendship_decay: int=None, _connection: int=None): output = CheatOutput(_connection) if new_friendship_decay is None: output("Usage: friendship.decay [positive number 1-100]") return if new_friendship_decay < 0: output("You have typed in a negative value! Don't type negative values or I'll personally send ninjas after you.") return NRDSettingUtils().set_setting(NRDSettings.FRIENDSHIP_DECAY, new_friendship_decay) _NRDRelationshipUtils().update_relationship_decay() output("Done! You have modified friendship decay for all sims to {} percent of the normal rate.".format(new_friendship_decay))
def _oc_print(_connection: int = None): output = CheatOutput(_connection) try: log.enable() output('Printing') log.format(things=dir(Dialog_pb2.UiDialogMessage)) log.disable() except Exception as ex: CommonExceptionHandler.log_exception(ModInfo.get_identity(), 'Problem.', exception=ex) output('Done.')
def _csf_reset_sliders(opt_sim: OptionalSimInfoParam = None, _connection: int = None): output = CheatOutput(_connection) output('Resetting all sliders.') sim_info = get_optional_target(opt_sim, target_type=OptionalSimInfoParam, _connection=_connection) if sim_info is None: output('Failed, No Sim found!') return False output('Resetting all sliders for \'{}\'.'.format( CommonSimNameUtils.get_full_name(sim_info))) CSFCustomSliderApplicationService().reset_all_sliders(sim_info) output('Success, Sliders reset.')
def _cm_max_all_motives(opt_sim: OptionalSimInfoParam = None, _connection: int = None): output = CheatOutput(_connection) sim_info = get_optional_target(opt_sim, target_type=OptionalSimInfoParam, _connection=_connection) if sim_info is None: output('Failed, No Sim found!') return False output('Setting all motives to maximum for \'{}\''.format( CommonSimNameUtils.get_full_name(sim_info))) result = CMMotiveUtils().max_all_motives(sim_info) if not result: output('Failed to set motive level.') else: output('Success!') output('Done')
def _csf_apply_slider(slider_name: str, amount: float, opt_sim: OptionalSimInfoParam = None, _connection: int = None): output = CheatOutput(_connection) output('Applying slider \'{}\' with amount \'{}\''.format( slider_name, amount)) sim_info = get_optional_target(opt_sim, target_type=OptionalSimInfoParam, _connection=_connection) if sim_info is None: output('Failed, No Sim found!') return False output('Applying slider to \'{}\'.'.format( CommonSimNameUtils.get_full_name(sim_info))) facial_attributes = PersistenceBlobs_pb2.BlobSimFacialCustomizationData() facial_attributes.MergeFromString(sim_info.facial_attributes) from cncustomsliderframework.sliders.query.slider_query_utils import CSFSliderQueryUtils custom_sliders = CSFSliderQueryUtils().get_sliders_by_name( sim_info, slider_name) if not custom_sliders: output('Invalid Slider! \'{}\''.format(slider_name)) output('Available Sliders:') for custom_slider in CSFSliderQueryUtils().get_sliders_for_sim( sim_info): output('>{}'.format(custom_slider.raw_display_name)) return False custom_slider = next(iter(custom_sliders)) if custom_slider is not None: output('Slider found.') else: output('Invalid Slider! \'{}\''.format(slider_name)) output('Available Sliders:') for custom_slider in CSFSliderQueryUtils().get_sliders_for_sim( sim_info): output('>{}'.format(custom_slider.raw_display_name)) return False # noinspection PyBroadException try: amount = float(amount) except: output('Amount must be a number! \'{}\''.format(amount)) return False output('Applying Sim Attributes!') return CSFCustomSliderApplicationService().apply_slider( sim_info, custom_slider, amount)
def _common_testing_show_ui_response_dialog(_connection: int = None): output = CheatOutput(_connection) output('Showing test ui response dialog.') def _on_chosen(_: CommonUiResponseDialog): response_value = _.get_response_value() output('Chosen value {}'.format(response_value if response_value is not None else 'No value chosen.')) try: responses: Tuple[CommonUiDialogResponse] = (CommonUiDialogResponse( 0, 'one', text='Button one'), CommonUiDialogResponse( 1, 'two', text='Button two')) title = CommonLocalizationUtils.create_localized_string( CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN, tokens=(CommonLocalizationUtils.create_localized_string( CommonStringId.TESTING_SOME_TEXT_FOR_TESTING, text_color=CommonLocalizedStringColor.GREEN), )) description = CommonLocalizationUtils.create_localized_string( CommonStringId.TESTING_TEST_TEXT_WITH_STRING_TOKEN, tokens=(CommonLocalizationUtils.create_localized_string( CommonStringId.TESTING_TEST_TEXT_WITH_SIM_FIRST_AND_LAST_NAME, tokens=(CommonSimUtils.get_active_sim_info(), ), text_color=CommonLocalizedStringColor.BLUE), )) active_sim_info = CommonSimUtils.get_active_sim_info() dialog = CommonUiResponseDialog.TunableFactory().default( active_sim_info, responses, # Having a value of 0 means that we want to display the Close button with no other dialog options. dialog_options=0, text=lambda *_, **__: description, title=lambda *_, **__: title) dialog.add_listener(_on_chosen) dialog.show_dialog() except Exception as ex: CommonExceptionHandler.log_exception(ModInfo.get_identity(), 'Failed to show button dialog.', exception=ex) output('Done')
def _csf_command_log_sliders_for_author(author: str = None, _connection: int = None): output = CheatOutput(_connection) output( 'Logging Sliders, this will take awhile and your game may freeze. Be Patient!' ) if author is None: output('Please specify an author to locate Sliders for.') return output( 'Will print pretty printed Sliders when the author is the one specified {} (It wont work for authors with spaces in their names).' .format(author)) try: log.enable() sliders_to_log: Dict[str, Any] = {} for slider_tag_value in CSFSliderQueryRegistry()._slider_library.keys( ): sliders: Set[CSFSlider] = CSFSliderQueryRegistry( )._slider_library[slider_tag_value] for slider in sliders: if str(author).lower() != str(slider.author).lower(): continue slider_identifier = str(slider.unique_identifier) if slider_identifier in sliders_to_log: if slider_tag_value in sliders_to_log[slider_identifier][ 'filter_keys']: continue sliders_to_log[slider_identifier]['filter_keys'].append( slider_tag_value) continue sliders_to_log[slider_identifier] = { 'slider': slider, 'filter_keys': [slider_tag_value] } log.debug('Logging Sliders for author {}:'.format(author)) for (key, val) in sliders_to_log.items(): log.format(slider=val['slider'], filter_keys=val['filter_keys']) log.disable() output('Sliders logged') except Exception as ex: log.error('Something happened', exception=ex) output('Failed to log.')
def _common_remove_trait(trait_id: int=None, target_sim_id: int=None, _connection: int=None): output = CheatOutput(_connection) if trait_id is None: output('Missing trait_id') return if target_sim_id is None: output('No Target specified, using the Active Sim.') target_sim_info = CommonSimUtils.get_active_sim_info() else: target_sim_info = CommonSimUtils.get_sim_info(target_sim_id) if target_sim_info is None: output('No target Sim found with id {}'.format(target_sim_id)) return try: output('Attempting to remove trait {} from Sim {}'.format(trait_id, CommonSimNameUtils.get_full_name(target_sim_info))) if CommonTraitUtils.remove_trait(target_sim_info, trait_id): output('Successfully removed trait.') else: output('Failed to remove trait.') except Exception as ex: CommonExceptionHandler.log_exception(ModInfo.get_identity(), 'Failed to remove trait {} from Sim {}'.format(trait_id, CommonSimNameUtils.get_full_name(target_sim_info)), exception=ex) output('Done')
def _csf_help(opt_sim: OptionalSimInfoParam = None, _connection: int = None): output = CheatOutput(_connection) sim_info = get_optional_target(opt_sim, target_type=OptionalSimInfoParam, _connection=_connection) if sim_info is None: output('Failed, No Sim found!') return output('Available Sliders:') from cncustomsliderframework.sliders.query.slider_query_utils import CSFSliderQueryUtils for custom_slider in sorted( CSFSliderQueryUtils().get_sliders_for_sim(sim_info), key=lambda sl: sl.raw_display_name): output('>{}'.format(custom_slider.raw_display_name)) output('Available Commands:') output('csf.apply_slider <slider_name> <amount>') output( ' >|apply the slider with <slider_name> in the amount of <amount>') output('csf.reset_slider <slider_name>') output(' >|reset the slider with name <slider_name> to 0.0') output('csf.reset_sliders') output(' >|reset all sliders to 0.0')
def _oc_load_vanilla_cas_parts(_connection: int = None): output = CheatOutput(_connection) try: output('Loading') # noinspection PyUnresolvedReferences cas_part_resource_keys = list(sims4.resources.list(type=Types.CASPART)) for key in cas_part_resource_keys: cas_part_id = key.instance body_type = CommonCASUtils.get_body_type_of_cas_part(cas_part_id) if body_type not in BodyType: continue log.format_with_message('Loading cas part into OC.', cas_part_id=cas_part_id) available_for_genders: Tuple[Gender] = (Gender.MALE, Gender.FEMALE) available_for_ages: Tuple[Age] = (Age.TEEN, Age.YOUNGADULT, Age.ADULT, Age.ELDER) available_for_species: Tuple[CommonSpecies] = ( CommonSpecies.HUMAN, ) available_for = OCOutfitPartAvailableFor(available_for_genders, available_for_ages, available_for_species) OCOutfitPartsLoader.get().add_outfit_part_with_id( CommonLocalizationUtils.create_localized_string( str(cas_part_id)), str(cas_part_id), 'Maxis', key, cas_part_id, available_for, tuple(), icon_key=key) except Exception as ex: CommonExceptionHandler.log_exception(ModInfo.get_identity(), 'Problem.', exception=ex) output('Done.')
def _common_show_known_traits(target_sim_id: int=None, _connection: int=None): output = CheatOutput(_connection) output('Doing') active_sim_info = CommonSimUtils.get_active_sim_info() active_sim_id = CommonSimUtils.get_sim_id(active_sim_info) output('Active sim id: {}'.format(active_sim_id)) if target_sim_id is None: output('No target specified.') return target_sim_info = CommonSimUtils.get_sim_info(target_sim_id) if target_sim_info is None: output('Target with id not found: {}'.format(target_sim_id)) return output('Getting relationship {}'.format(CommonSimNameUtils.get_full_name(target_sim_info))) relationship_tracker: RelationshipTracker = active_sim_info.relationship_tracker output('Getting knowledge') knowledge: SimKnowledge = relationship_tracker.get_knowledge(target_sim_id, initialize=False) output('Printing knowledge') if knowledge.known_traits is None: output('No known traits.') return output('Known Traits:') output(pformat(knowledge.known_traits)) output('Done')
def _csf_command_log_slider_counts(sliders_count: int = 5, _connection: int = None): output = CheatOutput(_connection) output( 'Logging Sliders, this will take awhile and your game may freeze. Be Patient!' ) output( 'Will print pretty printed Sliders when the total count of them in a filter is less than {}' .format(sliders_count)) try: log.enable() slider_results = [] for slider_tag_value in CSFSliderQueryRegistry()._slider_library.keys( ): sliders: Set[CSFSlider] = CSFSliderQueryRegistry( )._slider_library[slider_tag_value] count = len(sliders) slider_result = { 'filter_key': slider_tag_value, 'count': count, 'sliders': tuple() } if count < sliders_count: slider_result['sliders'] = sliders slider_results.append(slider_result) sorted_sliders = sorted(slider_results, key=lambda res: res['filter_key']) for slider in sorted_sliders: log.format(filter_key=slider['filter_key'], count=slider['count'], sliders=slider['sliders']) log.disable() output('Sliders logged') except Exception as ex: log.error('Something happened', exception=ex) output('Failed to log.')
def _spawn_human_sims(count: int = 100, gender_str: str = 'male', age_str: str = 'adult', _connection: int = None): output = CheatOutput(_connection) gender: Gender = CommonResourceUtils.get_enum_by_name(gender_str.upper(), Gender, default_value=None) if gender is None: output('{} is not a valid gender'.format(gender_str)) return age: Age = CommonResourceUtils.get_enum_by_name(age_str.upper(), Age, default_value=None) if age is None: output('{} is not a valid age'.format(age_str)) return if count <= 0: output('Please enter a count above zero.') return output('Spawning {} Sims of Gender: {} and Age: {}.'.format( count, gender.name, age.name)) try: active_sim_info = CommonSimUtils.get_active_sim_info() active_sim_location = CommonSimLocationUtils.get_location( active_sim_info) for x in range(count): created_sim_info = CommonSimSpawnUtils.create_human_sim_info( gender=gender, age=age, first_name=str(x), last_name=str(x)) CommonSimSpawnUtils.spawn_sim(created_sim_info, location=active_sim_location) except Exception as ex: CommonExceptionHandler.log_exception(ModInfo.get_identity(), 'Error spawning Sims.', exception=ex) output('Done spawning Sims.')
def _nrd_testing_show_relationship_decay(_connection: int=None): output = CheatOutput(_connection) output('Showing Relationship Decay Values.') _NRDRelationshipUtils().show_relationships(CommonSimUtils.get_sim_info_for_all_sims_generator()) output('Done')
def _common_disable_vanilla_logs(_connection: int = None): output = CheatOutput(_connection) output('Disabling vanilla logs.') _CommonVanillaLogOverride().disable_logs() output('Done')
def _nrd_testing_get_decay_values(_connection: int=None): output = CheatOutput(_connection) output('Showing Friendship and Romance decay settings.') friendship = NRDSettingUtils().get_setting(NRDSettings.FRIENDSHIP_DECAY, int) romance = NRDSettingUtils().get_setting(NRDSettings.ROMANCE_DECAY, int) output('Decay Constants for this mod are: GL_FRIENDSHIP_DECAY = {} | GL_ROMANCE_DECAY = {}'.format(friendship, romance))
def _cntei_generate_error_report(_connection=None): output = CheatOutput(_connection) output('Generating tuning error report.') TuningWatcher.get().generate_report() output('Finished generating tuning error report.')