def add_parents(child, generation=0): if generation >= generations: return sim_creators = (SimCreator(gender=Gender.MALE, age=Age.ADULT, last_name=child.last_name), SimCreator(gender=Gender.FEMALE, age=Age.ADULT)) (sim_info_list, _) = SimSpawner.create_sim_infos( sim_creators, account=sim.account, zone_id=sim.zone_id, creation_source='cheat: genealogy.generate_dynasty') sim_info_list[0].death_tracker.set_death_type( DeathType.get_random_death_type()) sim_info_list[1].death_tracker.set_death_type( DeathType.get_random_death_type()) if set_to_min_lod: sim_info_list[0].request_lod(SimInfoLODLevel.MINIMUM) sim_info_list[1].request_lod(SimInfoLODLevel.MINIMUM) child.set_and_propagate_family_relation(FamilyRelationshipIndex.FATHER, sim_info_list[0]) child.set_and_propagate_family_relation(FamilyRelationshipIndex.MOTHER, sim_info_list[1]) add_parents(sim_info_list[0], generation=generation + 1) add_parents(sim_info_list[1], generation=generation + 1)
def create_pet_with_breed(breed: TunableInstanceParam( sims4.resources.Types.BREED), gender: Gender = Gender.FEMALE, age: Age = Age.ADULT, x: float = 0, y: float = 0, z: float = 0, _connection=None): if age not in (Age.CHILD, Age.ADULT, Age.ELDER): sims4.commands.output('Invalid age for pet: {}'.format(age), _connection) return client = services.client_manager().get(_connection) position = sims4.math.Vector3(x, y, z) if x and y and z else None sims4.commands.output('Creating pet with breed: {}'.format(breed.__name__), _connection) sim_creator = SimCreator(age=age, gender=gender, species=breed.breed_species, additional_tags=(breed.breed_tag, )) SimSpawner.create_sims((sim_creator, ), household=None, tgt_client=client, generate_deterministic_sim=True, sim_position=position, account=client.account, creation_source='cheat: pets.create_pet_with_breed')
def create_lod_sim_infos(quantity: int = 1, lod: SimInfoLODLevel = SimInfoLODLevel.MINIMUM, _connection=None): output = sims4.commands.CheatOutput(_connection) account = services.client_manager().get(_connection).account for _ in range(quantity): gender = random.choice(list(Gender)) age = random.choice([Age.TEEN, Age.YOUNGADULT, Age.ADULT, Age.ELDER]) first_name = SimSpawner.get_random_first_name(gender) last_name = 'CheatFamilyLOD{}'.format(lod) sc = SimCreator(gender=gender, age=age, first_name=first_name, last_name=last_name) household = services.household_manager().create_household(account) (si, _) = SimSpawner.create_sim_infos( (sc, ), household=household, zone_id=0, creation_source='cheat: LOD SimInfo') if not si[0].request_lod(lod): output('Failed to request {} lod for {}'.format(lod, si[0])) output('Created a SimInfo and requested {} LOD: {}.'.format( lod, si[0])) output('Created a total of {} SimInfos at {} LOD'.format(lod, quantity))
def create_sim_info(self, offspring_data): (parent_a, parent_b) = self.get_parents() sim_creator = SimCreator(gender=offspring_data.gender, age=Age.BABY, first_name=offspring_data.first_name, last_name=offspring_data.last_name) household = self._sim_info.household zone_id = household.home_zone_id (sim_info_list, _) = SimSpawner.create_sim_infos( (sim_creator, ), household=household, account=self.account, zone_id=zone_id, generate_deterministic_sim=True, creation_source='pregnancy') sim_info = sim_info_list[0] generate_offspring(parent_a._base, parent_b._base, sim_info._base, seed=offspring_data.genetics) sim_info.resend_physical_attributes() trait_tracker = sim_info.trait_tracker for trait in tuple(trait_tracker.personality_traits): trait_tracker.remove_trait(trait) for trait in offspring_data.traits: trait_tracker.add_trait(trait) self.initialize_sim_info(sim_info, parent_a, parent_b) self._sim_info.relationship_tracker.add_relationship_bit( sim_info.id, self.BIRTHPARENT_BIT) return sim_info
def create_adoption_sim_info(self, sim_info, household=None, account=None, zone_id=None): sim_creator = SimCreator(age=sim_info.age, gender=sim_info.gender, species=sim_info.extended_species, first_name=sim_info.first_name, last_name=sim_info.last_name) (sim_info_list, new_household) = SimSpawner.create_sim_infos((sim_creator,), household=household, account=account, zone_id=0, creation_source='adoption') SimInfoBaseWrapper.copy_physical_attributes(sim_info_list[0], sim_info) sim_info_list[0].pelt_layers = sim_info.pelt_layers sim_info_list[0].breed_name_key = sim_info.breed_name_key sim_info_list[0].load_outfits(sim_info.save_outfits()) sim_info_list[0].resend_physical_attributes() return (sim_info_list[0], new_household)
def create_human_sim_info(gender: Gender = None, age: Age = None, first_name: str = None, last_name: str = None, trait_ids: Tuple[int] = (), household: Household = None, source: str = 'testing') -> Union[SimInfo, None]: """create_human_sim_info(\ gender=None,\ age=None,\ species=None,\ first_name=None,\ last_name=None,\ trait_ids=(),\ household=None,\ source='testing'\ ) Create SimInfo for a Human Sim. :param gender: The Gender of the created Sim. :type gender: Gender, optional :param age: The Age of the created Sim. :type age: Age, optional :param first_name: The First Name of the created Sim. :type first_name: str, optional :param last_name: The Last Name of the created Sim. :type last_name: str, optional :param trait_ids: The decimal identifiers of the Traits to add to the created Sim. :type trait_ids: Tuple[int], optional :param household: The household to place the created Sim in. If None, the Sim will be placed in a hidden household. :type household: Household, optional :param source: The reason for the Sims creation. :type source: str, optional :return: The SimInfo of the created Sim or None if the Sim failed to be created. :rtype: SimInfo """ from sims4communitylib.utils.sims.common_household_utils import CommonHouseholdUtils household = household or CommonHouseholdUtils.create_empty_household( as_hidden_household=True) sim_creator = SimCreator( gender=gender, age=age, first_name=first_name or SimSpawner.get_random_first_name(gender, Species.HUMAN), last_name=last_name, traits=trait_ids) (sim_info_list, _) = SimSpawner.create_sim_infos( (sim_creator, ), household=household, generate_deterministic_sim=True, creation_source=source) if not sim_info_list: return None return sim_info_list[0]
def add_parents(child, generation=0): if generation >= generations: return sim_creators = (SimCreator(gender=Gender.MALE, age=Age.ADULT, last_name=child.last_name), SimCreator(gender=Gender.FEMALE, age=Age.ADULT)) (sim_info_list, _) = SimSpawner.create_sim_infos(sim_creators, household=sim.household, account=sim.account, zone_id=sim.zone_id, creation_source='cheat: genealogy.generate_dynasty') sim_info_list[0].death_tracker.set_death_type(1) sim_info_list[1].death_tracker.set_death_type(1) child.set_and_propagate_family_relation(FamilyRelationshipIndex.FATHER, sim_info_list[0]) child.set_and_propagate_family_relation(FamilyRelationshipIndex.MOTHER, sim_info_list[1]) add_parents(sim_info_list[0], generation=generation + 1) add_parents(sim_info_list[1], generation=generation + 1)
def get_menu_sim(): global MENU_SIM_ID if MENU_SIM_ID is None: household = Household(SimSpawner._get_default_account(), starting_funds=0) household.set_to_hidden() (sim_info_list, _) = SimSpawner.create_sim_infos((SimCreator(),), household=household, creation_source='WickedWhims Menu') if sim_info_list: sim_info = sim_info_list[0] MENU_SIM_ID = TurboManagerUtil.Sim.get_sim_id(sim_info) _prepare_sim_outfit(sim_info) if MENU_SIM_ID is not None: return TurboManagerUtil.Sim.get_sim_info(MENU_SIM_ID)
def create_sim_info(self, offspring_data): self.validate_partner() (parent_a, parent_b) = self.get_parents() sim_creator = SimCreator(age=offspring_data.age, gender=offspring_data.gender, species=offspring_data.species, first_name=offspring_data.first_name, last_name=offspring_data.last_name) household = self._sim_info.household zone_id = household.home_zone_id (sim_info_list, _) = SimSpawner.create_sim_infos( (sim_creator, ), household=household, account=self.account, zone_id=zone_id, generate_deterministic_sim=True, creation_source='pregnancy') sim_info = sim_info_list[0] sim_info.world_id = services.get_persistence_service( ).get_world_id_from_zone(zone_id) for trait in tuple(sim_info.trait_tracker.personality_traits): sim_info.remove_trait(trait) for trait in offspring_data.traits: sim_info.add_trait(trait) sim_info.apply_genetics(parent_a, parent_b, seed=offspring_data.genetics) sim_info.resend_extended_species() sim_info.resend_physical_attributes() default_track_overrides = {} mother = parent_a if parent_a.gender == Gender.FEMALE else parent_b father = parent_a if parent_a.gender == Gender.MALE else parent_b if self._origin in self.PREGNANCY_ORIGIN_MODIFIERS: father_override = self.PREGNANCY_ORIGIN_MODIFIERS[ self._origin].default_relationships.father_override if father_override is not None: default_track_overrides[father] = father_override mother_override = self.PREGNANCY_ORIGIN_MODIFIERS[ self._origin].default_relationships.mother_override if mother_override is not None: default_track_overrides[mother] = mother_override self.initialize_sim_info( sim_info, parent_a, parent_b, default_track_overrides=default_track_overrides) self._sim_info.relationship_tracker.add_relationship_bit( sim_info.id, self.BIRTHPARENT_BIT) return sim_info
def debug_create_baby(actor_sim, position, gender, routing_surface=None): baby = None try: actor_sim_info = actor_sim.sim_info account = actor_sim.sim_info.account sim_creator = SimCreator( gender=gender, age=Age.BABY, first_name=SimSpawner.get_random_first_name( account, gender == Gender.FEMALE), last_name=SimSpawner.get_family_name_for_gender( account, actor_sim.last_name, gender == Gender.FEMALE)) (sim_info_list, _) = SimSpawner.create_sim_infos( (sim_creator, ), household=actor_sim_info.household, account=account, zone_id=actor_sim_info.zone_id, creation_source='cheat: debug_create_baby') sim_info = sim_info_list[0] baby_def = Baby.get_default_baby_def() baby = create_object(baby_def, sim_info.sim_id) baby.set_sim_info(sim_info) fgl_context = placement.FindGoodLocationContext( starting_position=position, object_id=baby.id, search_flags=placement.FGLSearchFlagsDefault, object_footprints=(baby.get_footprint(), )) (trans, orient) = placement.find_good_location(fgl_context) if trans is not None: baby.location = sims4.math.Location( sims4.math.Transform(trans, orient), routing_surface) client = services.client_manager().get_client_by_household_id( sim_info.household_id) while client is not None: client.selectable_sims.add_selectable_sim_info(sim_info) except Exception as e: logger.exception('Create baby fail', e) if actor_sim_info.household.sim_in_household(sim_info.sim_id): actor_sim_info.household.remove_sim_info(sim_info) client = services.client_manager().get_client_by_household_id( sim_info.household_id) if client is not None: client.selectable_sims.remove_selectable_sim_info(sim_info) while baby is not None: baby.destroy(source=actor_sim, cause='Create baby fail')
def _create_clone_sim_info(self, source_sim_info, resolver, household): sim_creator = SimCreator( gender=source_sim_info.gender, age=source_sim_info.age, first_name=SimSpawner.get_random_first_name( source_sim_info.gender, source_sim_info.species), last_name=source_sim_info._base.last_name, traits=source_sim_info.trait_tracker.equipped_traits) (sim_info_list, _) = SimSpawner.create_sim_infos( (sim_creator, ), household=household, account=source_sim_info.account, generate_deterministic_sim=True, creation_source='cloning', skip_adding_to_household=True) clone_sim_info = sim_info_list[0] source_sim_proto = source_sim_info.save_sim(for_cloning=True) clone_sim_id = clone_sim_info.sim_id clone_first_name = clone_sim_info._base.first_name clone_last_name = clone_sim_info._base.last_name clone_breed_name = clone_sim_info._base.breed_name clone_first_name_key = clone_sim_info._base.first_name_key clone_last_name_key = clone_sim_info._base.last_name_key clone_full_name_key = clone_sim_info._base.full_name_key clone_breed_name_key = clone_sim_info._base.breed_name_key clone_sim_info.load_sim_info(source_sim_proto, is_clone=True, default_lod=SimInfoLODLevel.FULL) clone_sim_info.sim_id = clone_sim_id clone_sim_info._base.first_name = clone_first_name clone_sim_info._base.last_name = clone_last_name clone_sim_info._base.breed_name = clone_breed_name clone_sim_info._base.first_name_key = clone_first_name_key clone_sim_info._base.last_name_key = clone_last_name_key clone_sim_info._base.full_name_key = clone_full_name_key clone_sim_info._base.breed_name_key = clone_breed_name_key clone_sim_info._household_id = household.id if not self._try_add_sim_info_to_household( clone_sim_info, resolver, household, skip_household_check=True): return source_trait_tracker = source_sim_info.trait_tracker clone_trait_tracker = clone_sim_info.trait_tracker for trait in clone_trait_tracker.personality_traits: if not source_trait_tracker.has_trait(trait): clone_sim_info.remove_trait(trait) for trait in clone_trait_tracker.gender_option_traits: if not source_trait_tracker.has_trait(trait): clone_sim_info.remove_trait(trait) correct_aspiration_trait = clone_sim_info.primary_aspiration.primary_trait for trait in tuple(clone_trait_tracker.aspiration_traits): if trait is not correct_aspiration_trait: clone_sim_info.remove_trait(trait) source_sim_info.relationship_tracker.create_relationship( clone_sim_info.sim_id) source_sim_info.relationship_tracker.add_relationship_score( clone_sim_info.sim_id, 1) self._ensure_parental_lineage_exists(source_sim_info, clone_sim_info) services.sim_info_manager().set_default_genealogy( sim_infos=(clone_sim_info, )) clone_sim_info.set_default_data() clone_sim_info.save_sim() household.save_data() if not household.is_active_household: clone_sim_info.request_lod(SimInfoLODLevel.BASE) clone_sim_info.resend_physical_attributes() clone_sim_info.relationship_tracker.clean_and_send_remaining_relationship_info( ) return clone_sim_info