コード例 #1
0
class TunableTestedGreetingGroup(TunableTestedGreeting):
    INSTANCE_TUNABLES = {
        'tests_or_greeting':
        TunableVariant(
            description=
            "\n            Either play a greeting if the tests pass, or reference another\n            TunableTestedGreetingGroup that will perform it's behavior if the\n            tests pass.\n            ",
            tests=TunableTuple(
                description=
                '\n                Child TunableTestedGreetingGroup nodes that run if the tests pass.\n                ',
                child_nodes=TunableList(
                    description=
                    '\n                    A list of children to run through as children of this branch.\n                    If any one passes, it will not process any more children.\n                    ',
                    tunable=TunableReference(
                        description=
                        '\n                        A child node that represents a set of tests to run as\n                        well as child nodes or a greeting.\n                        ',
                        manager=services.get_instance_manager(
                            sims4.resources.Types.SNIPPET),
                        class_restrictions=('TunableTestedGreetingGroup', ),
                        pack_safe=True)),
                locked_args={'leaf_or_branch': BRANCH}),
            greeting=TunableTuple(
                description=
                '\n                A mixer reaction greeting.\n                ',
                mixer=TunableReactionMixer(
                    description=
                    '\n                    Mixer reactions that Sims can play before socializing. This\n                    particular reaction works well with Social Mixers because we\n                    can guarantee that the Sim will greet the target within social\n                    constraints. Just remember to override the super affordance to\n                    a social super interaction.\n                    ',
                    get_affordance={'pack_safe': True}),
                locked_args={'leaf_or_branch': LEAF}))
    }

    @classmethod
    def _run_greeting(cls, sim, resolver, source_interaction=None, **kwargs):
        return cls.tests_or_greeting.mixer(sim, resolver, **kwargs)
コード例 #2
0
class CollectionInteractionData:
    COLLECTION_COMBINING_TUNING = TunableMapping(
        description=
        '\n        Mapping of collectible id, to states that we allow for collectible\n        combining.\n        ',
        key_type=TunableEnumEntry(
            description=
            '\n            ID of the collectible that can be combined.\n            ',
            tunable_type=CollectionIdentifier,
            default=CollectionIdentifier.Unindentified),
        value_type=TunableTuple(
            description=
            '\n            Possible states that can be combined on a collectible.\n            Mapping of state values that can be combined to get a new state\n            ',
            states_to_combine=TunableList(
                description=
                '\n                Any states tuned here will be transfered from the combine \n                collectibles to the resulting object.\n                For example: Frogs will transfer their color and pattern \n                states.\n                ',
                tunable=ObjectState.TunableReference(
                    description=
                    '\n                    State that can be inherited by the new collectible.\n                    '
                )),
            combination_mapping=TunableList(
                description=
                '\n                Mapping of possible father-mother states to which new\n                state can they generate on the newly created collectible.\n                e.g.  If collectible A has green color state, and collectible\n                B has blue color states the resulting state can be a Green \n                color state.  This means the outcome of the interaction will\n                look for a collectible that has this resulting state value.\n                ',
                tunable=TunableTuple(
                    description=
                    '\n                    State combinations to create a new state on the \n                    result collectible.\n                    ',
                    father_state=ObjectStateValue.TunableReference(),
                    mother_state=ObjectStateValue.TunableReference(),
                    resulting_state=ObjectStateValue.TunableReference()))))
コード例 #3
0
class LaundryTuning:
    GENERATE_CLOTHING_PILE = TunableTuple(description='\n        The tunable to generate clothing pile on the lot. This will be called\n        when we find laundry hero objects on the lot and there is no hamper\n        available.\n        ', loot_to_apply=TunableReference(description='\n            Loot to apply for generating clothing pile.\n            ', manager=services.get_instance_manager(sims4.resources.Types.ACTION), class_restrictions=('LootActions',), pack_safe=True), naked_outfit_category=TunableSet(description="\n            Set of outfits categories which is considered naked.\n            When Sim switches FROM these outfits, it won't generate the pile.\n            When Sim switches TO these outfits, it won't apply laundry reward\n            or punishment.\n            ", tunable=TunableEnumEntry(tunable_type=OutfitCategory, default=OutfitCategory.EVERYDAY, invalid_enums=(OutfitCategory.CURRENT_OUTFIT,))), no_pile_outfit_category=TunableSet(description="\n            Set of outfits categories which will never generate the pile.\n            When Sim switches FROM or TO these outfits, it won't generate the\n            pile.\n            \n            Laundry reward or punishment will still be applied to the Sim when \n            switching FROM or TO these outfits.\n            ", tunable=TunableEnumEntry(tunable_type=OutfitCategory, default=OutfitCategory.EVERYDAY, invalid_enums=(OutfitCategory.CURRENT_OUTFIT,))), no_pile_interaction_tag=TunableEnumWithFilter(description='\n            If interaction does spin clothing change and has this tag, it will\n            generate no clothing pile.\n            ', tunable_type=Tag, default=Tag.INVALID, filter_prefixes=('interaction',)))
    HAMPER_OBJECT_TAGS = TunableTags(description='\n        Tags that considered hamper objects.\n        ', filter_prefixes=('func',))
    LAUNDRY_HERO_OBJECT_TAGS = TunableTags(description='\n        Tags of laundry hero objects. Placing any of these objects on the lot\n        will cause the service to generate clothing pile for each Sims on the\n        household after spin clothing change.\n        ', filter_prefixes=('func',))
    NOT_DOING_LAUNDRY_PUNISHMENT = TunableTuple(description='\n        If no Sim in the household unload completed laundry in specific\n        amount of time, the negative loot will be applied to Sim household \n        on spin clothing change to engage them doing laundry.\n        ', timeout=TunableSimMinute(description="\n            The amount of time in Sim minutes, since the last time they're \n            finishing laundry, before applying the loot.\n            ", default=2880, minimum=1), loot_to_apply=TunableReference(description='\n            Loot defined here will be applied to the Sim in the household\n            on spin clothing change if they are not doing laundry for \n            a while.\n            ', manager=services.get_instance_manager(sims4.resources.Types.ACTION), class_restrictions=('LootActions',), pack_safe=True))
    PUT_AWAY_FINISHED_LAUNDRY = TunableTuple(description='\n        The tunable to update laundry service on Put Away finished laundry\n        interaction.\n        ', interaction_tag=TunableEnumWithFilter(description='\n            Tag that represent the put away finished laundry interaction which \n            will update Laundry Service data.\n            ', tunable_type=Tag, default=Tag.INVALID, filter_prefixes=('interaction',)), laundry_condition_states=TunableTuple(description='\n            This is the state type of completed laundry object condition \n            which will aggregate the data to the laundry service.\n            ', condition_states=TunableList(description='\n                A list of state types to be stored on laundry service.\n                ', tunable=TunableStateTypeReference(pack_safe=True), unique_entries=True), excluded_states=TunableList(description='\n                A list of state values of Condition States which will not \n                be added to the laundry service.\n                ', tunable=TunableStateValueReference(pack_safe=True), unique_entries=True)), laundry_condition_timeout=TunableSimMinute(description='\n            The amount of time in Sim minutes that the individual laundry\n            finished conditions will be kept in the laundry conditions \n            aggregate data.\n            ', default=1440, minimum=0), conditions_and_rewards_map=TunableMapping(description='\n            Mapping of laundry conditions and loot rewards.\n            ', key_type=TunableReference(manager=services.get_instance_manager(sims4.resources.Types.OBJECT_STATE), pack_safe=True), value_type=TunableReference(manager=services.get_instance_manager(sims4.resources.Types.ACTION), class_restrictions=('LootActions',), pack_safe=True)))
    PUT_CLOTHING_PILE_ON_HAMPER = TunableTuple(description='\n        The Tunable to directly put generated clothing pile in the hamper.\n        ', chance=TunablePercent(description='\n            The chance that a clothing pile will be put directly in the hamper. \n            Tune the value in case putting clothing pile in hamper every \n            spin-outfit-change feeling excessive.\n            ', default=100), clothing_pile=TunableTuple(description="\n            Clothing pile object that will be created and put into the hamper \n            automatically. \n            \n            You won't see the object on the lot since it will go directly to \n            the hamper. We create it because we need to transfer all of the \n            commodities data and average the values into the hamper precisely.\n            ", definition=TunablePackSafeReference(description='\n                Reference to clothing pile object definition.\n                ', manager=services.definition_manager()), initial_states=TunableList(description='\n                A list of states to apply to the clothing pile as soon as it \n                is created.\n                ', tunable=TunableTuple(description='\n                    The state to apply and optional to decide if the state \n                    should be applied.\n                    ', state=TunableStateValueReference(pack_safe=True), tests=TunableTestSet()))), full_hamper_state=TunableStateValueReference(description='\n            The state of full hamper which make the hamper is unavailable to \n            add new clothing pile in it.\n            ', pack_safe=True), loots_to_apply=TunableList(description='\n            Loots to apply to the hamper when clothing pile is being put.\n            ', tunable=TunableReference(manager=services.get_instance_manager(sims4.resources.Types.ACTION), class_restrictions=('LootActions',), pack_safe=True)), tests=TunableTestSet(description='\n            The test to run on the Sim that must pass in order for putting\n            clothing pile automatically to the hamper. These tests will only \n            be run when we have available hamper on the lot.\n            '))
コード例 #4
0
 def get_create_params(user_facing=False):
     create_params = {}
     create_params_locked = {}
     if user_facing:
         create_params['user_facing'] = Tunable(
             description=
             "\n                                                   If enabled, we will start the situation as user facing.\n                                                   Note: We can only have one user facing situation at a time,\n                                                   so make sure you aren't tuning multiple user facing\n                                                   situations to occur at once.\n                                                   ",
             tunable_type=bool,
             default=False)
     else:
         create_params_locked['user_facing'] = False
     return {
         'weighted_situations':
         TunableList(
             description=
             '\n            A weighted list of situations to be used while fulfilling the\n            desired Sim count.\n            ',
             tunable=TunableTuple(
                 situation=Situation.TunableReference(pack_safe=True),
                 params=TunableTuple(
                     description=
                     '\n                    Situation creation parameters.\n                    ',
                     locked_args=create_params_locked,
                     **create_params),
                 weight=Tunable(tunable_type=int, default=1),
                 weight_multipliers=TunableMultiplier.TunableFactory(
                     description=
                     "\n                    Tunable tested multiplier to apply to weight.\n                    \n                    *IMPORTANT* The only participants that work are ones\n                    available globally, such as Lot and ActiveHousehold. Only\n                    use these participant types or use tests that don't rely\n                    on any, such as testing all objects via Object Criteria\n                    test or testing active zone with the Zone test.\n                    ",
                     locked_args={'base_value': 1}),
                 tests=TunableTestSet(
                     description=
                     "\n                    A set of tests that must pass for the situation and weight\n                    pair to be available for selection.\n                    \n                    *IMPORTANT* The only participants that work are ones\n                    available globally, such as Lot and ActiveHousehold. Only\n                    use these participant types or use tests that don't rely\n                    on any, such as testing all objects via Object Criteria\n                    test or testing active zone with the Zone test.\n                    "
                 )))
     }
コード例 #5
0
class FishingData(HasTunableSingletonFactory, AutoFactoryInit):
    FACTORY_TUNABLES = {
        'weight_fish':
        TunableMultiplier.TunableFactory(
            description=
            '\n            A tunable list of tests and multipliers to apply to the weight \n            used to determine if the Sim will catch a fish instead of treasure \n            or junk. This will be used in conjunction with the Weight Junk and \n            Weight Treasure.\n            '
        ),
        'weight_junk':
        TunableMultiplier.TunableFactory(
            description=
            '\n            A tunable list of tests and multipliers to apply to the weight\n            used to determine if the Sim will catch junk instead of a fish or \n            treasure. This will be used in conjunction with the Weight Fish and \n            Weight Treasure.\n            '
        ),
        'weight_treasure':
        TunableMultiplier.TunableFactory(
            description=
            '\n            A tunable list of tests and multipliers to apply to the weight\n            used to determine if the Sim will catch a treasure instead of fish \n            or junk. This will be used in conjunction with the Weight Fish and \n            Weight Junk.\n            '
        ),
        'possible_treasures':
        TunableList(
            description=
            "\n            If the Sim catches a treasure, we'll pick one of these based on their weights.\n            Higher weighted treasures have a higher chance of being caught.\n            ",
            tunable=TunableTuple(treasure=TunableReference(
                manager=services.definition_manager(), pack_safe=True),
                                 weight=TunableMultiplier.TunableFactory())),
        'possible_fish':
        TunableList(
            description=
            "\n            If the Sim catches a fish, we'll pick one of these based on their weights.\n            Higher weighted fish have a higher chance of being caught.\n            ",
            tunable=TunableTuple(fish=TunableReference(
                manager=services.definition_manager(), pack_safe=True),
                                 weight=TunableMultiplier.TunableFactory()),
            minlength=1)
    }

    def _verify_tuning_callback(self):
        import fishing.fish_object
        for fish in self.possible_fish:
            if not issubclass(fish.fish.cls, fishing.fish_object.Fish):
                logger.error(
                    "Possible Fish on Fishing Data has been tuned but there either isn't a definition tuned for the fish, or the definition currently tuned is not a Fish.\n{}",
                    self)

    def get_possible_fish_gen(self):
        yield from self.possible_fish

    def choose_fish(self, resolver, require_bait=True):
        weighted_fish = [
            (f.weight.get_multiplier(resolver), f.fish)
            for f in self.possible_fish
            if f.fish.cls.can_catch(resolver, require_bait=require_bait)
        ]
        if weighted_fish:
            return sims4.random.weighted_random_item(weighted_fish)

    def choose_treasure(self, resolver):
        weighted_treasures = [(t.weight.get_multiplier(resolver), t.treasure)
                              for t in self.possible_treasures]
        if weighted_treasures:
            return sims4.random.weighted_random_item(weighted_treasures)
コード例 #6
0
class DefaultRelationshipInHousehold:
    RelationshipSetupMap = TunableMapping(
        description=
        '\n        A mapping of the possible genealogy links in a family to the default \n        relationship values that we want to start our household members. \n        ',
        key_name='Family Link',
        key_type=TunableEnumEntry(
            description=
            '\n            A genealogy link between the two Sims in the household.\n            ',
            tunable_type=DefaultGenealogyLink,
            default=DefaultGenealogyLink.Roommate),
        value_name='Default Relationship Setup',
        value_type=TunableTestedList(
            description=
            '\n            A list of relationship actions to apply.\n            ',
            tunable_type=DefaultRelationship.TunableFactory()))
    SPECIES_TO_ROOMATE_LINK = TunableList(
        description=
        '\n        Define what the "roommate" relationship, i.e. two Sims unrelated by\n        blood or marriage within the same household translates to. For instance,\n        two humans would use the regular "Roommate" link, but a human and a dog\n        would use an "owner/pet" link.\n        ',
        tunable=TunableTuple(
            description=
            '\n            An entry that defines the "roommate" mapping for two Sims.\n            ',
            species_actor=TunableEnumEntry(
                description=
                '\n                The species of the actor Sim, i.e. the Sim that is going to own\n                any applied bits.\n                ',
                tunable_type=Species,
                default=Species.HUMAN,
                invalid_enums=(Species.INVALID, )),
            species_target=TunableEnumEntry(
                description=
                '\n                The species of the target Sim, i.e. the Sim that is going to be\n                the target of any bit applied to the actor.\n                ',
                tunable_type=Species,
                default=Species.HUMAN,
                invalid_enums=(Species.INVALID, )),
            genealogy_link=TunableEnumEntry(
                description=
                '\n                The default genealogy link to create between two Sims of the\n                specified species.\n                ',
                tunable_type=DefaultGenealogyLink,
                default=DefaultGenealogyLink.Roommate)))
    SPECIES_TO_FAMILY_MEMBER_LINK = TunableList(
        description=
        '\n        Define what the "family member" relationship, i.e. two Sims related by\n        blood or marriage within the same household translates to. For instance,\n        humans would use the regular "FamilyMember" link, but dogs would use a\n        dog specific link.\n        \n        It\'s assumed that the two sims involved are the same species.\n        ',
        tunable=TunableTuple(
            description=
            '\n            An entry that defines the "family member" mapping for two Sims.\n            ',
            species=TunableEnumEntry(
                description=
                '\n                The species of the family members.\n                ',
                tunable_type=Species,
                default=Species.HUMAN,
                invalid_enums=(Species.INVALID, )),
            genealogy_link=TunableEnumEntry(
                description=
                '\n                The default genealogy link to create between two Sims of the\n                specified species.\n                ',
                tunable_type=DefaultGenealogyLink,
                default=DefaultGenealogyLink.FamilyMember)))
コード例 #7
0
ファイル: cas_tuning.py プロジェクト: NeonOcean/Environment
class CASStoriesTuning:
    CAS_STORIES = TunableTuple(
        description=
        '\n            Tuning for the CAS Stories sim-creation flow.\n            ',
        questions_per_pack=TunableMapping(
            description=
            '\n                Mapping between the number of packs available and the number of\n                base game questions and questions per pack that should be asked.\n                ',
            key_type=Tunable(
                description=
                '\n                    The number of available packs.\n                    ',
                tunable_type=int,
                default=0),
            value_type=TunableTuple(
                description=
                '\n                    The number of questions that should be asked.\n                    ',
                base_game_questions=Tunable(
                    description=
                    '\n                        The number of base game questions to ask.\n                        ',
                    tunable_type=int,
                    default=0),
                per_pack_questions=Tunable(
                    description=
                    '\n                        The number of pack questions to ask per pack.\n                        ',
                    tunable_type=int,
                    default=0),
                export_class_name='CasStoriesQuestionCountTuple'),
            tuple_name='CasStoriesQuestionsPerPackKeyValue'),
        funds_traits=TunableMapping(
            description=
            '\n                Mapping between specific traits and the amount of starting\n                household funds to give to a sim with that trait.\n                ',
            key_type=TunableReference(
                description=
                '\n                    Reference to the trait.\n                    ',
                manager=services.get_instance_manager(Types.TRAIT)),
            value_type=Tunable(
                description=
                '\n                    The household starting funds.\n                    ',
                tunable_type=int,
                default=0),
            tuple_name='CasStoriesFundsPerTraitKeyValue'),
        additional_sims_funds_percentage=TunableRange(
            description=
            '\n                If additional CAS Stories sims are added to a household, this is\n                the percentage of their normal funding to add to the household\n                funds as additonal funding. For instance, if we have 1 sim with\n                a 10,000 simoleon trait and a second sim with a 5,000 simoleon\n                trait and this is tuned to .5, the resulting household income\n                would be 10,000 + .5 * 5,000 = 12,500.\n                ',
            tunable_type=float,
            default=0.75,
            minimum=0,
            maximum=1),
        silouetted_sim_info=TunableResourceKey(
            description=
            '\n                The SimInfo file to use for the silouetted sim in CAS Stories.\n                ',
            default=None,
            resource_types=(sims4.resources.Types.SIMINFO, )),
        export_modes=ExportModes.ClientBinary,
        export_class_name='CasStoriesTuning')
コード例 #8
0
class SpellbookTuning:
    FRONT_PAGE_DATA = TunableTuple(description='\n        UI-specific data used to display front page.\n        ', title=TunableLocalizedStringFactory(description='\n            The title to use on the front page of the spellbook.\n            '), icon=OptionalTunable(description='\n            Image displayed on front page of spellbook.\n            If unset, image is not shown.\n            ', tunable=TunableIconAllPacks()), page_description=OptionalTunable(description='\n            Description used for this page in the spellbook.\n            If unset, description is not shown.\n            ', tunable=TunableLocalizedString()))
    CATEGORY_LIST_DATA = TunableTuple(description='\n        UI-specific data used to display second page of the spellbook.\n        ', title=TunableLocalizedStringFactory(description='\n            The title to use on the category list of the spellbook.\n            '), icon=OptionalTunable(description='\n            Icon used on the category list page of the spellbook.\n            ', tunable=TunableIconAllPacks()), page_description=OptionalTunable(description='\n            Description used for this page in the spellbook.\n            If unset, description is not shown.\n            ', tunable=TunableLocalizedString()))
    CATEGORY_DATAS = TunableList(description='\n        A list of a spellbook category data.\n        ', tunable=SpellbookCategoryData.TunableFactory(), tuning_group=GroupNames.UI)
    POTION_DISPLAY_DATA = TunableMapping(description="\n        A mapping of a potion's recipe to it's spellbook display data. \n        ", key_type=TunableReference(description="\n            The potion's recipe.\n            ", manager=services.get_instance_manager(Types.RECIPE), class_restrictions=('Recipe',), pack_safe=True), value_type=SpellbookRecipeData.TunableFactory(), tuning_group=GroupNames.UI)
    INGREDIENTS_LABEL = TunableLocalizedString(description='\n        Text used to display ingredients label for a spell or potion.\n        \n        e.g. "Ingredients:"\n        ', tuning_group=GroupNames.UI)
    PROGRESS_LABEL = TunableLocalizedString(description='\n        Text used to display field name for progress into a specific\n        category.\n        \n        e.g. "Learned:"\n        ', tuning_group=GroupNames.UI)
    PROGRESS_TEXT_FORMAT = TunableLocalizedStringFactory(description='\n        Text used to display the progress towards completing a specific\n        category.  Takes current items learned and and total available.\n\n        e.g. "{0.Number}/{1.Number}"\n        ', tuning_group=GroupNames.UI)
    CATEGORY_FRONT_PAGE_ENTRY_COUNT = TunableRange(description=',\n        Number of entries allotted for the front page of a category section.\n        ', tunable_type=int, minimum=0, tuning_group=GroupNames.UI, default=2)
    CATEGORY_ENTRY_COUNT = TunableRange(description=',\n        Number of entries allotted for the subsequent pages of a category section.\n        ', tunable_type=int, minimum=1, tuning_group=GroupNames.UI, default=4)
    INGREDIENT_FORMAT = TunableLocalizedStringFactory(description='\n        The format used for ingredients in the spellbook.\n        First parameter will be name of ingredient, second will be quantity required.\n        e.g. {0.String}({1.Number}) = "Frog(1)"\n        ', tuning_group=GroupNames.UI)
コード例 #9
0
ファイル: cas_tuning.py プロジェクト: NeonOcean/Environment
class CASMenu(HasTunableReference,
              metaclass=HashedTunedInstanceMetaclass,
              manager=services.get_instance_manager(Types.CAS_MENU)):
    INSTANCE_TUNABLES = {
        'cas_mode':
        TunableEnumEntry(
            description=
            '\n            The CAS mode for which this menu should be used.\n            ',
            tunable_type=CASMode,
            default=CASMode.BODY,
            export_modes=ExportModes.ClientBinary),
        'criteria':
        CASContextCriteria(
            description=
            '\n            List of criteria to determine when this menu should be used.\n            If more than one menu has its criteria met, the menu with the larger\n            number of criteria will be used.\n            ',
            export_modes=ExportModes.ClientBinary),
        'items':
        TunableList(
            description='\n            List of menu items.\n            ',
            tunable=TunableTuple(
                description=
                '\n                A menu item and its inclusion (and/or exclusion) criteria.\n                ',
                criteria=CASContextCriteria(
                    description=
                    '\n                    Include this item in the list of available menu items when all specified\n                    criteria are met.  If no criteria are defined, this item is always included.\n                    '
                ),
                item=TunablePackSafeReference(
                    description=
                    '\n                    Reference to a menu item for inclusion in this list.\n                    ',
                    manager=services.get_instance_manager(
                        Types.CAS_MENU_ITEM)),
                sub_items=TunableList(
                    description=
                    '\n                    Show the sub-menu, including this list of items.\n                    ',
                    tunable=TunableTuple(
                        description=
                        '\n                        A sub-menu item and its inclusion (and/or exclusion) criteria.\n                        ',
                        criteria=CASContextCriteria(
                            description=
                            '\n                            Include this item in the list of available menu items when all specified\n                            criteria are met.  If no criteria are defined, this item is always included.\n                            '
                        ),
                        item=TunablePackSafeReference(
                            description=
                            '\n                            Reference to a menu item for inclusion in this list.\n                            ',
                            manager=services.get_instance_manager(
                                Types.CAS_MENU_ITEM)),
                        export_class_name='CASSubMenuEntry')),
                export_class_name='CASMenuEntry'),
            export_modes=ExportModes.ClientBinary)
    }
コード例 #10
0
ファイル: ui_dialog.py プロジェクト: NeonOcean/Environment
class _UiResponseCommand(HasTunableSingletonFactory, AutoFactoryInit):
	FACTORY_TUNABLES = {
		'command': Tunable(description = 'The command.', tunable_type = str, default = ''),
		'arguments': TunableList(description = '\n            The arguments for this command. Arguments will be added after the\n            command.\n            ', tunable = TunableVariant(description = '\n                An argument being passed to the command.\n                ', boolean = TunableTuple(description = '\n                    A boolean value.\n                    ', arg_value = Tunable(tunable_type = bool, default = False), locked_args = {
			'arg_type': CommandArgType.ARG_TYPE_BOOL
		}), string = TunableTuple(description = '\n                    A string.\n                    ', arg_value = Tunable(tunable_type = str, default = ''), locked_args = {
			'arg_type': CommandArgType.ARG_TYPE_STRING
		}), floating_point = TunableTuple(description = '\n                    A floating point number.\n                    ', arg_value = Tunable(tunable_type = float, default = 0.0), locked_args = {
			'arg_type': CommandArgType.ARG_TYPE_FLOAT
		}), integer = TunableTuple(description = '\n                    An integer number.\n                    ', arg_value = Tunable(tunable_type = int, default = 0), locked_args = {
			'arg_type': CommandArgType.ARG_TYPE_INT
		}), participant_id = UiResponseParticipantId.TunableFactory(), special_command_data = TunableTuple(description = '\n                    This will use the data passed into the show_dialog()\n                    function. This must be supported with GPE work, so\n                    only use this if you have talked to a GPE.\n                    ', locked_args = {
			'arg_type': CommandArgType.ARG_TYPE_SPECIAL
		})))
	}
コード例 #11
0
class BillReduction(GlobalPolicyEffect, HasTunableSingletonFactory,
                    HasTunableFactory, AutoFactoryInit):
    FACTORY_TUNABLES = {
        'percent_reduction':
        TunableTuple(
            description=
            '\n            A mapping of bill reduction reason to percent reduction. Reasons for bill\n            reduction can be added to sims.bills tuning.\n            ',
            reduction_reason=TunableEnumEntry(
                description=
                '\n                Reason for bill reduction.\n                ',
                tunable_type=BillReductionEnum,
                default=BillReductionEnum.GlobalPolicy_ControlInvasiveSpecies),
            reduction_amount=TunablePercent(
                description=
                '\n                Percent by which all household bills are reduced.\n                ',
                default=50))
    }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def turn_on(self, _, from_load=False):
        services.global_policy_service().add_bill_reduction(
            self.percent_reduction.reduction_reason,
            self.percent_reduction.reduction_amount)

    def turn_off(self, _):
        services.global_policy_service().remove_bill_reduction(
            self.percent_reduction.reduction_reason)
コード例 #12
0
class TelemetryTuning:
    __qualname__ = 'TelemetryTuning'
    BUFF_ALARM_TIME = TunableRange(
        description=
        "\n        Integer value in sim minutes in which the buff alarm will trigger to \n        send a telemetry report of current active buff's on the household sims.\n        ",
        tunable_type=int,
        minimum=1,
        default=60)
    EMOTION_REL_ALARM_TIME = TunableRange(
        description=
        '\n        Integer value in sim minutes in which the emotion and relationship \n        alarm will trigger to send a telemetry report of the emotion and \n        relationship status of the household sims.\n        ',
        tunable_type=int,
        minimum=1,
        default=60)
    HOOK_ACTIONS = TunableList(
        description=
        '\n        List of hook actions that we want to drop or collect to create rules \n        to disable them from triggering.\n        ',
        tunable=TunableTuple(
            description='\n            Hook actions.\n            ',
            module_tag=Tunable(
                description=
                "\n                Module identifier of the hook where the action should be \n                applied.\n                Can be empty if we want to apply an action by only group or \n                hook tag. \n                e.g. 'GAME'.  \n                ",
                tunable_type=str,
                default=''),
            group_tag=Tunable(
                description=
                "\n                Group identifier of the hook where the action should be \n                applied.\n                Can be empty if we want to apply an action by only module or \n                hook tag.\n                e.g. 'WHIM'\n                ",
                tunable_type=str,
                default=''),
            hook_tag=Tunable(
                description=
                "\n                Tag identifier of the hook where the action should be \n                applied.\n                Can be empty if we want to apply an action by only module or \n                group tag.\n                e.g. 'WADD'\n                ",
                tunable_type=str,
                default=''),
            priority=Tunable(
                description=
                "\n                Priority for this rule to apply.  The rules are sorted in \n                priority order (lowest priority first).  The the first rule \n                that matches a hook causes the hook to be blocked or collected, \n                depending on the value of action. \n                e.g. We can have an action to COLLECT hook {GAME, WHIM, WADD} \n                with priority 0, and an action to DROP hooks with module 'GAME'\n                {GAME, '', ''} with priority 1, this means the collected hook\n                action will have more importance than the rule to drop all \n                GAME hooks.                \n                ",
                tunable_type=int,
                default=0),
            action=TunableEnumEntry(
                description=
                '\n                Action to take for the specified tags. \n                COLLECT to enable the hook.\n                DROP to disable the hook.\n                ',
                tunable_type=RuleAction,
                default=RuleAction.DROP)))

    @classmethod
    def filter_tunable_hooks(cls):
        for hook in TelemetryTuning.HOOK_ACTIONS:
            module_tag = hook.module_tag
            group_tag = hook.group_tag
            hook_tag = hook.hook_tag
            if module_tag == '':
                module_tag = None
            if group_tag == '':
                group_tag = None
            if hook_tag == '':
                hook_tag = None
            sims4.telemetry.add_filter_rule(hook.priority, module_tag,
                                            group_tag, hook_tag, None,
                                            hook.action)
コード例 #13
0
    class _DirectionalGoalMixin:
        FACTORY_TUNABLES = {
            'limit_direction':
            OptionalTunable(
                TunableTuple(description='\n                ',
                             direction=TunableOperator(
                                 tunable_type=InequalityOperator,
                                 default=Operator.LESS_OR_EQUAL),
                             tooltip=event_testing.test_base.BaseTest.
                             FACTORY_TUNABLES['tooltip']))
        }

        def get_threshold_value(self, stat):
            return self.get_goal_value()

        def get_additional_tests_gen(self, subject):
            yield from super().get_additional_tests_gen(subject)
            if self.limit_direction is not None:
                threshold = sims4.math.Threshold(
                    self.get_threshold_value(), self.limit_direction.direction)
                test = StatThresholdTest(tooltip=self.limit_direction.tooltip,
                                         who=subject,
                                         stat=self.stat,
                                         threshold=threshold)
                yield test
class CommonUiObjectCategoryPicker(UiObjectPicker):
    """An ObjectPicker with categories listed in a drop down.

    """
    FACTORY_TUNABLES = {
        'object_categories':
        TunableList(
            description=
            '\n            The categories to display in the drop down for this picker.\n            ',
            tunable=TunableTuple(object_category=Tunable(tunable_type=str,
                                                         default='ALL'),
                                 icon=TunableIconFactory(),
                                 category_name=TunableLocalizedString()))
    }

    def _build_customize_picker(self, picker_data) -> None:
        for category in self.object_categories:
            with ProtocolBufferRollback(
                    picker_data.filter_data) as category_data:
                category_data.tag_type = abs(hash(
                    category.object_category)) % (10**8)
                build_icon_info_msg(category.icon(None), None,
                                    category_data.icon_info)
                category_data.description = category.category_name
        super()._build_customize_picker(picker_data)
コード例 #15
0
class _TextInputLengthFixed(HasTunableSingletonFactory, AutoFactoryInit):
    FACTORY_TUNABLES = {
        'min_length':
        OptionalTunable(
            description=
            "\n             If enabled, specify the minimum length of input text the player has\n             to enter before he/she can hit the 'OK' button.\n             ",
            tunable=TunableTuple(
                length=TunableRange(
                    description=
                    '\n                     Minimum amount of characters the user must enter in to the\n                     text box before he/she can click on the OK button.\n                     ',
                    tunable_type=int,
                    minimum=1,
                    default=1),
                tooltip=OptionalTunable(
                    description=
                    '\n                     If enabled, allows specification of a tooltip to display if\n                     the user has entered text length less than min_length.\n                     ',
                    tunable=TunableLocalizedStringFactory()))),
        'max_length':
        Tunable(
            description=
            '\n             Max amount of characters the user can enter into the text box.\n             ',
            tunable_type=int,
            default=20)
    }

    def build_msg(self, dialog, msg, *additional_tokens):
        msg.max_length = self.max_length
        if self.min_length is not None:
            msg.min_length = self.min_length.length
            if self.min_length.tooltip is not None:
                msg.input_too_short_tooltip = dialog._build_localized_string_msg(
                    self.min_length.tooltip, *additional_tokens)
コード例 #16
0
class PackSpecificTuning:
    VENUE_PACK_TUNING = TunableMapping(
        description=
        "\n        Venue tuning that is needed by UI when that venue's pack is not installed.\n        ",
        key_name='venue_id',
        key_type=TunableReference(
            description=
            '\n            Reference to the venue that this data represents\n            ',
            manager=services.get_instance_manager(sims4.resources.Types.VENUE),
            pack_safe=True),
        value_name='data',
        value_type=TunableTuple(
            description=
            "\n            Venue data that is shown in the UI when this venue's pack is not installed.\n            ",
            gallery_download_venue=OptionalTunable(
                description=
                '\n                If tuned, the tuned venue tuning will be substituted if this\n                venue is downloaded from the gallery by a player who is not\n                entitled to it. The default behavior is to substitute the\n                generic venue. This tuned venue will also determine download\n                compatibility (for instance, only residential venues can be \n                downloaded to owned residential venues).\n                ',
                tunable=TunableReference(manager=services.get_instance_manager(
                    sims4.resources.Types.VENUE))),
            venue_name=TunableLocalizedStringFactory(
                description=
                '\n                Name that will be displayed for the venue when the pack containing \n                that venue is not installed\n                '
            ),
            venue_flags=TunableEnumFlags(
                description=
                '\n                Venue flags used to mark a venue with specific properties.\n                ',
                enum_type=VenueFlags,
                allow_no_flags=True,
                default=VenueFlags.NONE),
            export_class_name='VenueDataTuple'),
        tuple_name='VenuePackTuning',
        export_modes=ExportModes.All,
        verify_tunable_callback=verify_venue_tuning)
コード例 #17
0
class TestableDisplayName(HasTunableSingletonFactory, AutoFactoryInit):
    __qualname__ = 'TestableDisplayName'

    @staticmethod
    def _verify_tunable_callback(instance_class, tunable_name, source, value):
        for (index, override_data) in enumerate(value.overrides):
            while not override_data.new_display_name:
                logger.error(
                    'name override not set for display name override in {} at index:{}',
                    instance_class, index)

    FACTORY_TUNABLES = {
        'overrides':
        TunableList(
            description=
            '\n            Potential name overrides for this interaction. The first test in\n            this list which passes will be the new display name show to the\n            player. If none pass the tuned display_name will be used.\n            ',
            tunable=TunableTuple(
                description=
                '\n                A tuple of a test and the name that would be chosen if the test\n                passes.\n                ',
                test=event_testing.tests.TunableTestSet(
                    description=
                    '\n                    The test to run to see if the display_name should be\n                    overridden.\n                    '
                ),
                new_display_name=TunableLocalizedStringFactory(
                    description=
                    '\n                    The localized name of this interaction. it takes two tokens,\n                    the actor (0) and target object (1) of the interaction.\n                    '
                ),
                new_pie_menu_icon=TunableResourceKey(
                    description=
                    '\n                    If this display name overrides the default display name,\n                    this will be the icon that is shown. If this is not tuned\n                    then the default pie menu icon for this interaction will be\n                    used.\n                    ',
                    default=None,
                    resource_types=sims4.resources.CompoundTypes.IMAGE),
                new_display_tooltip=OptionalTunable(
                    description=
                    '\n                    Tooltip to show on this pie menu option.\n                    ',
                    tunable=sims4.localization.TunableLocalizedStringFactory(
                    )),
                new_pie_menu_category=TunableReference(
                    description=
                    '\n                    Pie menu category to put interaction under.\n                    ',
                    manager=services.get_instance_manager(
                        sims4.resources.Types.PIE_MENU_CATEGORY)))),
        'verify_tunable_callback':
        _verify_tunable_callback
    }

    def get_display_names_gen(self):
        for override in self.overrides:
            yield override.new_display_name

    def get_display_name_and_result(self,
                                    interaction,
                                    target=DEFAULT,
                                    context=DEFAULT):
        resolver = interaction.get_resolver(target=target, context=context)
        for override in self.overrides:
            result = override.test.run_tests(resolver)
            while result:
                return (override, result)
        return (None, TestResult.NONE)
コード例 #18
0
class ScholarshipTuning:
    APPLICATION_RESPONSE_TUNING = TunableTuple(
        description=
        '\n        Loot actions to be run on scholarship acceptance or rejection.\n        \n        Reward object(s) given through the loot actions must have the\n        Scholarship Letter Component enabled in order to store information about\n        the resolved scholarship and sim applicant on the object.\n        ',
        value_threshold=Tunable(
            description=
            "\n            A value threshold that when exceeds runs the 'accepted_beyond_value_\n            threshold' loot action.\n            ",
            tunable_type=int,
            default=1),
        accepted_beyond_value_threshold=LootActions.TunablePackSafeReference(
            description=
            '\n            Loot action to be called when a Sim is accepted to\n            a scholarship and the value earned exceeds the tuned value threshold.\n            '
        ),
        accepted_below_value_threshold=LootActions.TunablePackSafeReference(
            description=
            '\n            Loot action to be called when a Sim is accepted to a scholarship and\n            the value does not exceed the tuned value threshold.\n            '
        ),
        rejected=LootActions.TunablePackSafeReference(
            description=
            '\n            Loot action to be called when a Sim is rejected from a scholarship.\n            '
        ))
    FULL_RIDE_LOOT = LootActions.TunablePackSafeReference(
        description=
        '\n        Loot to run if a sim has applied for scholarships and successfully\n        earned a full ride to attend university.\n        '
    )
    MERIT_SCHOLARSHIP = TunablePackSafeReference(
        description=
        '\n        The merit scholarship to evaluate on enrollment. One Merit Scholarship\n        is earned at enrollment if any prestige degrees are earned.\n        ',
        manager=services.get_instance_manager(sims4.resources.Types.SNIPPET),
        class_restrictions='Scholarship')
コード例 #19
0
 def __init__(self,
              target_default=ParticipantType.Object,
              locked_args={},
              carry_target_default=ParticipantType.Object,
              **kwargs):
     super().__init__(
         TunableTuple(
             affordance=TunableReference(
                 services.affordance_manager(),
                 description=
                 'The affordance to push as a continuation on the actor for this SI.'
             ),
             si_affordance_override=TunableReference(
                 services.affordance_manager(),
                 description=
                 "When the tuned affordance is a mixer for a different SI, use this to specify the mixer's appropriate SI. This is useful for pushing socials."
             ),
             actor=TunableEnumEntry(
                 ParticipantType,
                 ParticipantType.Actor,
                 description='The Sim on which the affordance is pushed.'),
             target=TunableEnumEntry(
                 ParticipantType,
                 target_default,
                 description='The participant the affordance will target.'),
             carry_target=OptionalTunable(
                 TunableEnumEntry(
                     ParticipantType,
                     carry_target_default,
                     description=
                     'The participant the affordance will set as a carry target.'
                 )),
             locked_args=locked_args), **kwargs)
コード例 #20
0
ファイル: tunable.py プロジェクト: johndpope/sims4-ai-engine
 def __init__(self, **kwargs):
     super().__init__(
         job_list=TunableMapping(
             description='A list of roles associated with the situation.',
             key_type=TunableReference(services.situation_job_manager(),
                                       description='Job reference'),
             value_type=TunableReference(
                 services.get_instance_manager(
                     sims4.resources.Types.ROLE_STATE),
                 description='Role the job will perform'),
             key_name='job',
             value_name='role'),
         exit_conditions=TunableList(
             TunableTuple(conditions=TunableList(
                 TunableSituationCondition(
                     description=
                     'A condition for a situation or single phase.'),
                 description=
                 'A list of conditions that all must be satisfied for the group to be considered satisfied.'
             )),
             description=
             'A list of condition groups of which if any are satisfied, the group is satisfied.'
         ),
         duration=TunableSimMinute(
             description=
             '\n                                                    How long the phase will last in sim minutes.\n                                                    0 means forever, which should be used on the last phase of the situation.\n                                                    ',
             default=60),
         **kwargs)
コード例 #21
0
class PushInteractionOnAllGreetedSimsInteraction(
        interactions.base.super_interaction.SuperInteraction):
    __qualname__ = 'PushInteractionOnAllGreetedSimsInteraction'
    INSTANCE_TUNABLES = {
        '_pushed_interaction_tunables':
        TunableTuple(
            affordance_to_push=sims4.tuning.tunable.TunableReference(
                description=
                '\n                Affordance to push on all sims in the household and all greeted\n                sims.\n                ',
                manager=services.affordance_manager()),
            push_on_actor=sims4.tuning.tunable.Tunable(
                description=
                '\n               Whether Afforance To Push should be pushed on the actor.\n               ',
                tunable_type=bool,
                default=False),
            target_override_for_pushed_affordance=OptionalTunable(
                TunableEnumEntry(
                    description=
                    '\n                ParticipantType for the target to be set on the pushed\n                affordance.\n                ',
                    tunable_type=ParticipantType,
                    default=ParticipantType.Actor))),
        '_required_appropriateness_tags':
        TunableSet(
            description=
            '\n            A list of tags that a Sim must have to be eligible for this\n            interaction.\n            ',
            tunable=TunableEnumEntry(tunable_type=tag.Tag,
                                     default=tag.Tag.INVALID))
    }

    @classmethod
    def _test(cls, target, context, **interaction_parameters):
        sim = next(cls._target_sim_gen(context.sim), None)
        if sim is None:
            return event_testing.results.TestResult(False,
                                                    'No valid sims to call.')
        return super()._test(target, context, **interaction_parameters)

    def _run_interaction_gen(self, timeline):
        if self._pushed_interaction_tunables.target_override_for_pushed_affordance is not None:
            new_target = self.get_participant(
                self._pushed_interaction_tunables.
                target_override_for_pushed_affordance)
        else:
            new_target = self.target
        for target_sim in self._target_sim_gen(self.sim):
            target_context = self.context.clone_for_sim(target_sim)
            target_sim.push_super_affordance(
                self._pushed_interaction_tunables.affordance_to_push,
                new_target, target_context)
        return event_testing.results.ExecuteResult.NONE

    @classmethod
    def _target_sim_gen(cls, sim):
        for target_sim in services.sim_info_manager(
        ).instanced_sims_on_active_lot_gen():
            while target_sim.Buffs.is_appropriate(
                    cls._required_appropriateness_tags):
                if not cls._pushed_interaction_tunables.push_on_actor and target_sim is sim:
                    pass
                yield target_sim
コード例 #22
0
class TunableTemplateChooser(metaclass=TunedInstanceMetaclass,
                             manager=services.get_instance_manager(
                                 sims4.resources.Types.TEMPLATE_CHOOSER)):
    INSTANCE_TUNABLES = {
        '_templates':
        TunableList(
            description=
            '\n            A list of templates that can be chosen from this template chooser.\n            ',
            tunable=TunableTuple(
                description=
                '\n                The template and weights that can be chosen.\n                ',
                template=TunableSimTemplate.TunableReference(
                    description=
                    '\n                    A template that can be chosen.\n                    ',
                    pack_safe=True),
                weight=Tunable(
                    description=
                    '\n                    Weight of this template being chosen.\n                    ',
                    tunable_type=int,
                    default=1)))
    }

    @classmethod
    def choose_template(cls):
        possible_templates = [(template_weight_pair.weight,
                               template_weight_pair.template)
                              for template_weight_pair in cls._templates]
        return sims4.random.pop_weighted(possible_templates)
コード例 #23
0
ファイル: display_name.py プロジェクト: NeonOcean/Environment
class TunableDisplayNameWrapper(HasTunableSingletonFactory, AutoFactoryInit):
    FACTORY_TUNABLES = {
        'wrappers':
        TunableList(
            description=
            '\n            Each wrapper is a localized string matched with a test set. The \n            wrapper that tests in first is applied to the display name.\n            \n            NOTE: The wrapper is override independent, and if enabled will be \n            applied to all display name variants. Anything that depends on override\n            context should not be tuned here, but instead be tuned manually under\n            Display Name Overrides.\n            \n            NOTE: The format of the wrapper will take in the original string\n            and should be written in this form: "[0.String] Wrapper" .\n            ',
            tunable=TunableTuple(
                description=
                '\n                A tuple of test sets and the wrapper.\n                ',
                test=event_testing.tests.TunableTestSet(
                    description=
                    '\n                    The tests that control the condition of when the wrapper is\n                    displayed.\n                    '
                ),
                wrapper=TunableLocalizedStringFactory(
                    description=
                    '\n                    The localized wrapper.\n                    '
                )))
    }

    def get_first_passing_wrapper(self,
                                  interaction,
                                  target=DEFAULT,
                                  context=DEFAULT,
                                  **interaction_parameters):
        resolver = interaction.get_resolver(target=target,
                                            context=context,
                                            **interaction_parameters)
        for wrapper in self.wrappers:
            result = wrapper.test.run_tests(resolver)
            if result:
                return wrapper
コード例 #24
0
 def __init__(self,
              start_description=None,
              end_description=None,
              **kwargs):
     super().__init__(
         key_type=TunableEnumEntry(
             description=
             '\n                    The weather type we are interested in.\n                    ',
             tunable_type=WeatherType,
             default=WeatherType.UNDEFINED),
         value_type=TunableTuple(
             start_loot=TunableList(
                 description=start_description,
                 tunable=LootActions.TunableReference(
                     description=
                     '\n                            The loot action applied.\n                            ',
                     pack_safe=True)),
             end_loot=TunableList(
                 description=end_description,
                 tunable=LootActions.
                 TunableReference(
                     description=
                     '\n                            The loot action applied.\n                            ',
                     pack_safe=True))),
         **kwargs)
     self.cache_key = 'TunableWeatherAwareMapping'
コード例 #25
0
ファイル: season.py プロジェクト: NeonOcean/Environment
class SeasonalContent(HasTunableSingletonFactory, AutoFactoryInit):
    FACTORY_TUNABLES = {
        'holidays':
        TunableMapping(key_type=TunableReference(
            description=
            '\n                Drama node to be scheduled for this holiday.\n                ',
            manager=services.get_instance_manager(
                sims4.resources.Types.HOLIDAY_DEFINITION),
            pack_safe=True),
                       value_type=TunableList(
                           tunable=DayOfSeason.TunableFactory())),
        'segments':
        TunableTuple(
            early_season_length=TunableTimeSpan(
                description=
                '\n                Early season length, in days.\n                ',
                default_days=2,
                locked_args={
                    'hours': 0,
                    'minutes': 0
                }),
            late_season_length=TunableTimeSpan(
                description=
                '\n                Late season length, in days.\n                ',
                default_days=2,
                locked_args={
                    'hours': 0,
                    'minutes': 0
                }))
    }
コード例 #26
0
class SingleJobSituation(SituationComplexCommon):
    INSTANCE_TUNABLES = {
        'job':
        TunableTuple(
            description=
            '\n            The job and role which the career Sim is placed into.\n            ',
            situation_job=SituationJob.TunableReference(
                description=
                '\n                A reference to a SituationJob that can be performed at this Situation.\n                '
            ),
            role_state=RoleState.TunableReference(
                description=
                '\n                A role state the Sim assigned to the job will perform.\n                '
            ))
    }
    REMOVE_INSTANCE_TUNABLES = Situation.NON_USER_FACING_REMOVE_INSTANCE_TUNABLES

    @classmethod
    def _states(cls):
        return (SituationStateData(1, SingleJobSituationState), )

    @classmethod
    def _get_tuned_job_and_default_role_state_tuples(cls):
        return [(cls.job.situation_job, cls.job.role_state)]

    @classmethod
    def default_job(cls):
        return cls.job.situation_job

    def start_situation(self):
        super().start_situation()
        self._change_state(SingleJobSituationState())
コード例 #27
0
class TunableMultiplier(HasTunableSingletonFactory, AutoFactoryInit):
    __qualname__ = 'TunableMultiplier'
    FACTORY_TUNABLES = {
        'base_value':
        Tunable(
            description=
            '\n            The basic value to return if no modifications are applied.\n            ',
            default=1,
            tunable_type=float),
        'multipliers':
        TunableList(
            description=
            '\n            A list of multipliers to apply to base_value.\n            ',
            tunable=TunableTuple(
                multiplier=TunableRange(
                    description=
                    '\n                    The multiplier to apply to base_value if the associated\n                    tests pass.\n                    ',
                    tunable_type=float,
                    default=1,
                    minimum=0),
                tests=TunableTestSet(
                    description=
                    '\n                    A series of tests that must pass in order for multiplier to\n                    be applied.\n                    '
                )))
    }

    def get_multiplier(self, participant_resolver):
        multiplier = self.base_value
        for multiplier_data in self.multipliers:
            while multiplier_data.tests.run_tests(participant_resolver):
                multiplier *= multiplier_data.multiplier
        return multiplier
コード例 #28
0
ファイル: loot.py プロジェクト: NeonOcean/Environment
class WeightedSingleSimLootActions(HasTunableReference,
                                   HasTunableSingletonFactory,
                                   AutoFactoryInit,
                                   metaclass=HashedTunedInstanceMetaclass,
                                   manager=services.get_instance_manager(
                                       sims4.resources.Types.ACTION)):
    INSTANCE_TUNABLES = {
        'loot_actions':
        TunableList(
            description=
            '\n            A list of weighted Loot Actions that operate only on one Sim.\n            ',
            tunable=TunableTuple(
                buff_loot=DynamicBuffLootOp.TunableFactory(),
                weight=Tunable(
                    description=
                    '\n                    Accompanying weight of the loot.\n                    ',
                    tunable_type=int,
                    default=1)))
    }

    def __iter__(self):
        return iter(self.loot_actions)

    @classmethod
    def pick_loot_op(cls):
        weighted_loots = [(loot.weight, loot.buff_loot)
                          for loot in cls.loot_actions]
        loot_op = sims4.random.weighted_random_item(weighted_loots)
        return loot_op
コード例 #29
0
class PlayVisualEffectMixin:
    FACTORY_TUNABLES = {
        'vfx':
        PlayEffect.TunableFactory(
            description='\n            The effect to play.\n            '),
        'vfx_target':
        OptionalTunable(
            description=
            '\n            If enabled, the visual effect is set to target a specific joint on\n            another object or Sim.\n            ',
            tunable=TunableTuple(
                participant=TunableEnumEntry(
                    description=
                    '\n                    The participant this visual effect targets.\n                    ',
                    tunable_type=ParticipantTypeSingle,
                    default=ParticipantTypeSingle.TargetSim),
                joint_name=TunableStringHash32(
                    description=
                    '\n                    The name of the slot this effect is targeted to.\n                    ',
                    default='_FX_')))
    }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def _start_vfx(self, participant, target_participant):
        vfx_params = {}
        if target_participant is not None:
            vfx_params['target_actor_id'] = target_participant.id
            vfx_params['target_joint_name_hash'] = self.vfx_target.joint_name
        running_vfx = self.vfx(participant, **vfx_params)
        self.vfx_lifetime.start_visual_effect(running_vfx)
        return running_vfx
コード例 #30
0
class PhoneTuning:
    DISABLE_PHONE_TESTS = TunableList(
        description=
        '\n        List of tests and tooltip that when passed will disable opening the\n        phone.\n        ',
        tunable=TunableTuple(
            description=
            '\n            Test that should pass for the phone to be disabled and its tooltip\n            to display to the player when he clicks on the phone.\n            ',
            test=TunableTestVariant(),
            tooltip=TunableLocalizedStringFactory()))

    class TunablePhoneColorTuple(TunableTuple):
        def __init__(self, *args, **kwargs):
            super().__init__(
                *args,
                bg_image=TunableIcon(
                    description=
                    '\n                Image resource to display as UI phone panel background.\n                '
                ),
                icon=TunableIcon(
                    description=
                    '\n                Icon to display for phone color selector swatch.\n                '
                ),
                phone_trait=TunableReference(
                    description=
                    '\n                Trait associated with cell phone color.\n                ',
                    allow_none=True,
                    manager=services.get_instance_manager(
                        sims4.resources.Types.TRAIT)),
                **kwargs)

    PHONE_COLOR_VARIATION_TUNING = TunableList(
        description=
        '\n        A list of all of the different colors you can set the cell phone cover to be.\n        ',
        tunable=TunablePhoneColorTuple(),
        export_modes=(ExportModes.ClientBinary, ))