Пример #1
0
class SkillDynamicallyReferencedTest(HasTunableSingletonFactory,
                                     AutoFactoryInit,
                                     event_testing.test_base.BaseTest):
    FACTORY_TUNABLES = {
        'subject':
        TunableEnumEntry(
            description='\n            The subject of this test.\n            ',
            tunable_type=ParticipantType,
            default=ParticipantType.Actor),
        'referenced_skill':
        TunableVariant(
            description=
            '\n            Where to obtain the skill to test against. \n            \n            Should the Sim not have the specified skill, or should the skill not\n            be available because of pack restrictions, this Sim will be\n            considered at level 0.\n            ',
            from_career=_CareerSkillLootData.TunableFactory(),
            default='from_career'),
        'skill_range':
        TunableVariant(
            description=
            '\n            A skill range defined by either an interval or a threshold.\n            ',
            interval=SkillInterval.TunableFactory(),
            threshold=SkillThreshold.TunableFactory(),
            default='interval'),
        'use_effective_skill_level':
        Tunable(
            description=
            "\n            If checked, then instead of using the skill's actual level, the test\n            will use the skill's effective level for the purpose of satisfying\n            the specified criteria.\n            ",
            tunable_type=bool,
            needs_tuning=True,
            default=False)
    }
    __slots__ = ('subject', 'referenced_skill', 'skill_range',
                 'use_effective_skill_level')

    def get_expected_args(self):
        return {'test_targets': self.subject}

    @cached_test
    def __call__(self, test_targets=()):
        target = next(iter(test_targets), None)
        if target is None:
            return TestResult(False, 'Target is None.', tooltip=self.tooltip)
        referenced_skill = self.referenced_skill(target)
        if referenced_skill is None:
            skill_value = 0
        else:
            skill_or_skill_type = target.get_statistic(
                referenced_skill, add=False) or referenced_skill
            if self.use_effective_skill_level and target.is_instanced():
                skill_value = target.get_sim_instance(
                    allow_hidden_flags=ALL_HIDDEN_REASONS
                ).get_effective_skill_level(skill_or_skill_type)
            else:
                skill_value = skill_or_skill_type.get_user_value()
        if not self.skill_range(skill_value):
            return TestResult(False,
                              'Skill {} level not in desired range.',
                              referenced_skill,
                              tooltip=self.tooltip)
        return TestResult.TRUE
Пример #2
0
class InventoryTransfer(XevtTriggeredElement, HasTunableFactory,
                        AutoFactoryInit):
    FACTORY_TUNABLES = {
        'description':
        '\n            Transfer all objects with a specified inventory type from the\n            specified inventory to the inventory of a specified participant.\n            ',
        'source':
        TunableVariant(
            description=
            '\n            The source of the inventory objects being transferred.\n            ',
            lot_inventory_type=TunableEnumEntry(
                description=
                '\n                The inventory from which the objects will be transferred.\n                ',
                tunable_type=InventoryType,
                default=InventoryType.UNDEFINED,
                invalid_enums=(InventoryType.UNDEFINED, )),
            participant=TunableEnumEntry(
                description=
                '\n                The participant of the interaction whose inventory objects will\n                be transferred to the specified inventory.\n                ',
                tunable_type=ParticipantType,
                default=ParticipantType.Object,
                invalid_enums=(ParticipantType.Invalid, ))),
        'recipient':
        TunableVariant(
            description=
            '\n            The inventory that will receive the objects being transferred.\n            ',
            lot_inventory_type=TunableEnumEntry(
                description=
                '\n                The inventory into which the objects will be transferred.\n                ',
                tunable_type=InventoryType,
                default=InventoryType.UNDEFINED,
                invalid_enums=(InventoryType.UNDEFINED, )),
            participant=TunableEnumEntry(
                description=
                '\n                The participant of the interaction who will receive the objects \n                being transferred.\n                ',
                tunable_type=ParticipantType,
                default=ParticipantType.Object,
                invalid_enums=(ParticipantType.Invalid, ))),
        'object_tests':
        TunableTestSet(
            description=
            '\n            Tests that will run on each object, and will transfer the object\n            only if all the tests pass.\n            \n            The object will be the PickedObject participant type, so we can\n            preserve the interaction resolver.\n            '
        )
    }

    def _do_behavior(self):
        if isinstance(self.source, ParticipantType):
            source = self.interaction.get_participant(self.source)
        else:
            source = self.source
        if isinstance(self.recipient, ParticipantType):
            recipient = self.interaction.get_participant(self.recipient)
        else:
            recipient = self.recipient
        transfer_entire_inventory(source,
                                  recipient,
                                  interaction=self.interaction,
                                  object_tests=self.object_tests)
Пример #3
0
 def participant_type_data(*, participant_type, participant_default):
     return {
         'participant':
         TunableEnumEntry(
             description=
             '\n                The participant determining which objects are to be generated.\n                ',
             tunable_type=participant_type,
             default=participant_default),
         'in_slot':
         TunableVariant(
             description=
             '\n                slots of the participant object from which the target objects should be pulled.\n                ',
             by_name=Tunable(
                 description=
                 '\n                    The exact name of a slot on the parent object in which the object should be.  \n                    ',
                 tunable_type=str,
                 default='_ctnm_'),
             by_reference=TunableReference(
                 description=
                 '\n                    A particular slot type in which the object should be.\n                    ',
                 manager=services.get_instance_manager(
                     sims4.resources.Types.SLOT_TYPE)),
             locked_args={'use_participant': None},
             default='use_participant')
     }
Пример #4
0
class TunableStatisticModifierCurve(HasTunableSingletonFactory, AutoFactoryInit):

	@TunableFactory.factory_option
	def axis_name_overrides (x_axis_name = None, y_axis_name = None):
		return {
			'multiplier': TunableVariant(description = '\n                Define how the multiplier will be applied.\n                ', value_curve = TunableCurve(description = '\n                    The multiplier will be determined by interpolating against a\n                    curve. The user-value is used. This means that a curve for\n                    skills should have levels as its x-axis.\n                    ', x_axis_name = x_axis_name, y_axis_name = y_axis_name), locked_args = {
				'raw_value': None
			}, default = 'raw_value')
		}

	FACTORY_TUNABLES = {
		'statistic': TunablePackSafeReference(description = "\n            The payout amount will be multiplied by this statistic's value.\n            ", manager = services.get_instance_manager(sims4.resources.Types.STATISTIC)),
		'subject': TunableEnumEntry(description = '\n            The participant to look for the specified statistic on.\n            ', tunable_type = ParticipantType, default = ParticipantType.Actor),
		'multiplier': TunableVariant(description = '\n            Define how the multiplier will be applied.\n            ', value_curve = TunableCurve(description = '\n                The multiplier will be determined by interpolating against a\n                curve. The user-value is used. This means that a curve for\n                skills should have levels as its x-axis.\n                '), locked_args = {
			'raw_value': None
		}, default = 'raw_value')
	}

	def get_value (self, stat, sim):
		return stat.convert_to_user_value(stat.get_value())

	def get_multiplier (self, resolver, sim):
		subject = resolver.get_participant(participant_type = self.subject, sim = sim)
		if subject is not None:
			stat = subject.get_stat_instance(self.statistic)
			if stat is not None:
				value = self.get_value(stat, sim)
				if self.multiplier is not None:
					return self.multiplier.get(value)
				else:
					return value
		return 1.0
Пример #5
0
class SituationGoalLootActions(HasTunableReference,
                               metaclass=TunedInstanceMetaclass,
                               manager=services.get_instance_manager(
                                   sims4.resources.Types.ACTION)):
    __qualname__ = 'SituationGoalLootActions'
    INSTANCE_TUNABLES = {
        'goal_loot_actions':
        TunableList(
            TunableVariant(statistics=TunableStatisticChange(
                locked_args={
                    'subject': ParticipantType.Actor,
                    'advertise': False,
                    'chance': 1,
                    'tests': None
                }),
                           money_loot=MoneyChange.TunableFactory(
                               locked_args={
                                   'subject': ParticipantType.Actor,
                                   'chance': 1,
                                   'tests': None,
                                   'display_to_user': None,
                                   'statistic_multipliers': None
                               }),
                           buff=buffs.buff_ops.BuffOp.TunableFactory(
                               locked_args={
                                   'subject': ParticipantType.Actor,
                                   'chance': 1,
                                   'tests': None
                               })))
    }

    def __iter__(self):
        return iter(self.goal_loot_actions)
Пример #6
0
class CasStoriesAnswer(HasTunableReference,
                       metaclass=HashedTunedInstanceMetaclass,
                       manager=services.get_instance_manager(
                           sims4.resources.Types.CAS_STORIES_ANSWER)):
    INSTANCE_TUNABLES = {
        'text':
        TunableLocalizedStringFactory(
            description='\n            The text of this answer.\n            ',
            export_modes=ExportModes.ClientBinary,
            tuning_group=GroupNames.UI),
        'weightings':
        TunableList(
            description=
            '\n            A list of objects to apply weightings to if this answer is \n            selected. Weight is the weight that shoudld be added to the chance \n            to receive this object.  In the latter case a trait will be \n            selected from the trait chooser based on its cumulative weighting \n            throughout the CAS Stories survey.\n            ',
            tunable=TunableTuple(weighted_object=TunableVariant(
                trait=Trait.TunableReference(),
                trait_chooser=CasStoriesTraitChooser.TunableReference(),
                aspiration_track=TunableReference(
                    manager=services.get_instance_manager(
                        sims4.resources.Types.ASPIRATION_TRACK)),
                default='trait'),
                                 weight=Tunable(tunable_type=float,
                                                default=0.0),
                                 export_class_name='CASAnswerWeightings'),
            export_modes=ExportModes.ClientBinary)
    }
Пример #7
0
class SetFavoriteLootOp(BaseTargetedLootOperation):
    FACTORY_TUNABLES = {'favorite_type': TunableVariant(description="\n            The type of favorite action to apply.\n            \n            Preferred Object: Sets the object as a sim's preferred object\n            to use for a specific func tag.\n            Favorite Stack: Sets the object's stack of the sim's favorites\n            in their inventory.\n            ", preferred_object=TunableTuple(description='\n                Data for setting this item as preferred.\n                ', tag=TunableTag(description='\n                    The tag that represents this type of favorite.\n                    ', filter_prefixes=('Func',))), locked_args={'favorite_stack': None}, default='preferred_object'), 'unset': Tunable(description='\n            If checked, this will unset the target as the favorite instead of setting\n            it.\n            ', tunable_type=bool, default=False)}

    def __init__(self, favorite_type, unset, **kwargs):
        super().__init__(**kwargs)
        self._favorite_type = favorite_type
        self._unset = unset

    def _apply_to_subject_and_target(self, subject, target, resolver):
        if subject is None or target is None:
            logger.error('Trying to run a SetFavorite loot without a valid Subject or Target')
            return
        if target.is_sim:
            logger.error("Trying to set a Sim {} as a Favorite of another Sim {}. This isn't possible.", target, subject)
            return
        favorites_tracker = subject.sim_info.favorites_tracker
        if favorites_tracker is None:
            logger.error('Trying to set a favorite for Sim {} but they have no favorites tracker.', subject)
            return
        if self._favorite_type is not None:
            if self._unset:
                favorites_tracker.unset_favorite(self._favorite_type.tag, target.id, target.definition.id)
            else:
                favorites_tracker.set_favorite(self._favorite_type.tag, target.id, target.definition.id)
            return
        if self._unset:
            favorites_tracker.unset_favorite_stack(target)
        else:
            favorites_tracker.set_favorite_stack(target)
        target.inventoryitem_component.get_inventory().push_inventory_item_stack_update_msg(target)
Пример #8
0
 def __init__(self, **kwargs):
     super().__init__(
         distance=TunableInterval(
             description=
             '\n                The distance range relative to origin point that \n                the generated point should be in.\n                ',
             tunable_type=float,
             minimum=0,
             default_lower=1,
             default_upper=5),
         angle=TunableAngle(
             description=
             '\n                The slice of the donut/circle in degrees.\n                ',
             default=TWO_PI),
         offset=TunableAngle(
             description=
             '\n                An offset (rotation) in degrees, affecting where the start\n                of the angle is.  This has no effect if angle is 360 degrees.\n                ',
             default=0),
         axis=TunableVariant(
             description=
             '\n                Around which axis the position will be located.\n                ',
             default='y',
             locked_args={
                 'x': Vector3.X_AXIS(),
                 'y': Vector3.Y_AXIS(),
                 'z': Vector3.Z_AXIS()
             }),
         **kwargs)
Пример #9
0
class ChangePaintingState(HasTunableFactory, AutoFactoryInit):
    FACTORY_TUNABLES = {'texture_id': TunableVariant(description='\n            Modify the texture id in some way.\n            ', set_texture=_SetTexture(), clear_texture=_ClearTexture()), 'reveal_level': OptionalTunable(description='\n            If enabled then we will change the reveal level of the painting\n            state.\n            ', tunable=TunableRange(description='\n                The reveal level that we will change the painting state to.\n                ', tunable_type=int, default=PaintingState.REVEAL_LEVEL_MIN, minimum=PaintingState.REVEAL_LEVEL_MIN, maximum=PaintingState.REVEAL_LEVEL_MAX)), 'state_texture_id': TunableVariant(description='\n            Change the state texture id in some way.  This is the\n            texture that will be revealed when being revealed as a mural.\n            ', set_texture=_SetTexture(), clear_texture=_ClearTexture(), dont_use=_DontUsePaintingTextureField()), 'overlay_texture_id': TunableVariant(description='\n            Change the overlay texture id in some way.  This is the\n            texture that we want to use as the overlay on this picture\n            ', set_texture=_SetTexture(), clear_texture=_ClearTexture(), dont_use=_DontUsePaintingTextureField()), 'reveal_texture_id': TunableVariant(description='\n            Change the reveal texture id in some way.  This is the\n            texture that we will use as a map to reveal the painting being\n            created.\n            ', set_texture=_SetTexture(), clear_texture=_ClearTexture(), dont_use=_DontUsePaintingTextureField())}

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

    def start(self, *_, **__):
        painting_state = self.target.canvas_component.painting_state
        if painting_state is None:
            painting_state = PaintingState(0)
        if self.texture_id is not None:
            painting_state = self.texture_id(painting_state.set_painting_texture_id)
        if self.reveal_level is not None:
            painting_state = painting_state.get_at_level(self.reveal_level)
        if self.state_texture_id is not None:
            painting_state = self.state_texture_id(painting_state.set_stage_texture_id)
        if self.overlay_texture_id is not None:
            painting_state = self.overlay_texture_id(painting_state.set_overlay_texture_id)
        if self.reveal_texture_id is not None:
            painting_state = self.reveal_texture_id(painting_state.set_reveal_texture_id)
        self.target.canvas_component.painting_state = painting_state

    def stop(self, *_, **__):
        pass
Пример #10
0
class _TargetActionRules(HasTunableFactory, AutoFactoryInit):
    FACTORY_TUNABLES = {
        'chance':
        TunablePercent(
            description=
            '\n            A random chance of this action getting applied (default 100%).\n            ',
            default=100),
        'test':
        TunableTestSet(
            description=
            '\n            A test to decide whether or not to apply this particular set of actions to the target object.\n            ',
            tuning_group=GroupNames.TESTS),
        'actions':
        TunableList(
            description=
            '\n            A list of one or more ObjectRoutingBehaviorActions to run on the\n            target object after routing to it. These are applied in sequence.\n            ',
            tunable=TunableVariant(
                play_animation=ObjectRoutingBehaviorActionAnimation.
                TunableFactory(),
                destroy_objects=ObjectRoutingBehaviorActionDestroyObjects.
                TunableFactory(),
                apply_loot=ObjectRoutingBehaviorActionApplyLoot.TunableFactory(
                ),
                default='play_animation')),
        'abort_if_applied':
        Tunable(
            description=
            "\n            Don't run any further actions from this list of action rules if \n            conditions are met and this action is executed.\n            ",
            tunable_type=bool,
            default=False)
    }
Пример #11
0
class VenueCivicPolicyTest(BaseCivicPolicyTest):
    FACTORY_TUNABLES = {
        'venue':
        TunableVariant(
            description=
            "\n            Select the zone's venue to test by specifying a Zone Source.\n            ",
            use_current_zone=ActiveZone.TunableFactory(),
            use_pick_info=PickInfoZone.TunableFactory(),
            use_picked_zone_ids=PickedZoneIds.TunableFactory(),
            use_participant_home_zone=ParticipantHomeZone.TunableFactory(),
            default='use_current_zone')
    }

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

    def _get_zone_id(self, **kwargs):
        return self.venue.get_zone_id(**kwargs)

    def get_expected_args(self):
        return self.venue.get_expected_args()

    def _get_civic_policy_provider(self, *args, **kwargs):
        zone_id = self._get_zone_id(**kwargs)
        if zone_id is None:
            return
        venue_game_service = services.venue_game_service()
        if venue_game_service is None:
            return
        return venue_game_service.get_provider(zone_id)

    def get_custom_event_registration_keys(self):
        return ()
Пример #12
0
class DialogDramaNode(BaseDramaNode):
    INSTANCE_TUNABLES = {
        'dialog_and_loot':
        TunableVariant(
            description=
            '\n            The type of dialog and loot that will be applied.\n            ',
            notification=_notification_and_loot.TunableFactory(),
            dialog_ok=_dialog_ok_and_loot.TunableFactory(),
            dialog_ok_cancel=_dialog_ok_cancel_and_loot.TunableFactory(),
            dialog_multi_response=_dialog_multi_tested_response.TunableFactory(
            ),
            loot_only=_loot_only.TunableFactory(),
            default='notification')
    }

    @classproperty
    def drama_node_type(cls):
        return DramaNodeType.DIALOG

    def _run(self):
        self.dialog_and_loot.on_node_run(self)
        return DramaNodeRunOutcome.SUCCESS_NODE_COMPLETE

    @classmethod
    def apply_cooldown_on_response(cls, drama_node):
        if drama_node.cooldown is not None and drama_node.cooldown.cooldown_option == CooldownOption.ON_DIALOG_RESPONSE:
            services.drama_scheduler_service().start_cooldown(drama_node)
class BaseCivicPolicyTest(HasTunableSingletonFactory, AutoFactoryInit,
                          BaseTest):
    FACTORY_TUNABLES = {
        'civic_policy_tests':
        TunableList(
            description=
            '\n            The tests we wish to run on the civic policies in question, run in\n            order.  AND operation, all must pass, first to fail stops tests.\n            ',
            tunable=TunableVariant(
                description=
                '\n                Individual tests run on Civic Policy Provider.\n                ',
                default='voting_open',
                enacted=BaseCivicPolicyTestEnacted.TunableFactory(),
                balloted=BaseCivicPolicyTestBalloted.TunableFactory(),
                repealable=BaseCivicPolicyTestRepealable.TunableFactory(),
                dormant=BaseCivicPolicyTestDormant.TunableFactory(),
                available=BaseCivicPolicyTestAvailable.TunableFactory(),
                voting_open=BaseCivicPolicyTestVotingOpen.TunableFactory(),
                voting_time_until_change=
                BaseCivicPolicyTestVotingTimeUntilChange.TunableFactory()))
    }

    def _get_civic_policy_provider(self, *args, **kwargs):
        raise NotImplementedError

    def get_custom_event_registration_keys(self):
        raise NotImplementedError

    def __call__(self, *args, **kwargs):
        provider = self._get_civic_policy_provider(*args, **kwargs)
        for test in self.civic_policy_tests:
            result = test.run_test(provider, self.tooltip)
            if not result:
                return result
        return TestResult.TRUE
class ObjectMatchesDefinitionOrTagTest(event_testing.test_base.BaseTest):
    FACTORY_TUNABLES = {
        'description':
        'Check to see if the specified object matches either a static definition or a set of tags',
        'item':
        TunableVariant(
            actual_item=objects.object_tests.CraftActualItemFactory(),
            tagged_item=objects.object_tests.CraftTaggedItemFactory(),
            default='tagged_item',
            description=
            'Whether to test for a specific item or item that has a set of tags'
        )
    }

    def __init__(self, item, **kwargs):
        super().__init__(**kwargs)
        self.item = item

    def get_expected_args(self):
        return {'objects': ParticipantType.Object}

    def __call__(self, objects=None):
        obj = next(iter(objects))
        match = self.item(obj, None)
        if not match:
            return event_testing.results.TestResult(
                False,
                'ObjectMatchesDefinitionOrTagTest: Object did not match specified checks.'
            )
        return event_testing.results.TestResult.TRUE
Пример #15
0
class CustomTrackerObjective(BaseObjective,
                             metaclass=HashedTunedInstanceMetaclass,
                             manager=services.get_instance_manager(
                                 sims4.resources.Types.OBJECTIVE)):
    INSTANCE_TUNABLES = {
        'tracking':
        TunableVariant(
            description=
            '\n            The method of tracking that we want to use.\n            ',
            commodity=TrackCommodity.TunableFactory(),
            default='commodity')
    }

    @classmethod
    def setup_objective(cls, event_data_tracker, milestone):
        tracker = cls.tracking(event_data_tracker, milestone, cls)
        event_data_tracker.add_event_tracker(cls, tracker)

    @classmethod
    def cleanup_objective(cls, event_data_tracker, milestone):
        event_data_tracker.remove_event_tracker(cls)

    @classmethod
    def goal_value(cls):
        return 1
Пример #16
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)
Пример #17
0
class SetAsHeadElement(XevtTriggeredElement, HasTunableFactory,
                       AutoFactoryInit):
    FACTORY_TUNABLES = {
        'participant_to_slot':
        TunableEnumEntry(
            description=
            '\n            The participant of the interaction that will be parented into the \n            target.\n            ',
            tunable_type=ParticipantTypeObject,
            default=ParticipantTypeObject.Object),
        'participant_target':
        TunableEnumEntry(
            description=
            '\n            The target where the object will be parented.\n            ',
            tunable_type=ParticipantTypeActorTargetSim,
            default=ParticipantTypeActorTargetSim.Actor),
        'set_head_operation':
        TunableVariant(
            description=
            '\n            Operation that should be done when the element is executed.\n            ',
            set_as_head=SetAsHead.TunableFactory(),
            unset_as_head=UnsetAsHead.TunableFactory(),
            default='set_as_head')
    }

    def _do_behavior(self):
        participant_to_parent = self.interaction.get_participant(
            self.participant_to_slot)
        if participant_to_parent is None:
            return False
        parent_target = self.interaction.get_participant(
            self.participant_target)
        if parent_target is None or not parent_target.is_sim:
            return False
        return self.set_head_operation.apply(participant_to_parent,
                                             parent_target)
Пример #18
0
class BusinessEmployeeAction(XevtTriggeredElement):
    FACTORY_TUNABLES = {
        'employee':
        TunableEnumEntry(
            description=
            '\n            The sim participant to hire/fire.\n            ',
            tunable_type=ParticipantTypeSingleSim,
            default=ParticipantTypeSingleSim.PickedSim),
        'action':
        TunableVariant(
            description=
            '\n            The action (hire or fire) to apply to the chosen employee.\n            ',
            hire=_BusinessEmployeeActionHire.TunableFactory(),
            fire=_BusinessEmployeeActionFire.TunableFactory(),
            default='hire')
    }

    def _do_behavior(self):
        employee_sim_info = self.interaction.get_participant(self.employee)
        if employee_sim_info is None:
            logger.error(
                'Got a None Sim trying to run the BusinessEmployeeAction element. {}, action: {}',
                self.interaction, self.action)
            return
        employee_sim_info = getattr(employee_sim_info, 'sim_info',
                                    employee_sim_info)
        business_manager = services.business_service(
        ).get_business_manager_for_zone()
        if business_manager is None:
            logger.error(
                'Got a None Business Manager trying to run a BusinessEmployeeAction element. {}, action: {}',
                self.interaction, self.action)
            return
        self.action.do_action(business_manager, employee_sim_info)
Пример #19
0
class HasTimedAspirationTest(HasTunableSingletonFactory, AutoFactoryInit,
                             BaseTest):
    FACTORY_TUNABLES = {
        'target':
        TunableEnumEntry(
            description=
            '\n            Who or what to apply this test to.\n            ',
            tunable_type=ParticipantTypeSingleSim,
            default=ParticipantTypeSingleSim.Actor),
        'test_behavior':
        TunableVariant(
            description='\n            The type of test to run.\n            ',
            has_any_timed_aspiration=HasAnyTimedAspirationTest.TunableFactory(
            ),
            has_specific_timed_aspiration=HasSpecificTimedAspirationTest.
            TunableFactory(),
            default='has_any_timed_aspiration')
    }

    def get_expected_args(self):
        return {'targets': self.target}

    @cached_test
    def __call__(self, targets):
        target_sim = next(iter(targets), None)
        if target_sim is None:
            return TestResult(False, 'Target is None.', tooltip=self.tooltip)
        return self.test_behavior._run_test(target_sim, tooltip=self.tooltip)
 def __init__(self, **kwargs):
     super().__init__(
         gender=TunableEnumEntry(
             description=
             "\n                The Sim's gender.\n                ",
             tunable_type=sim_info_types.Gender,
             needs_tuning=True,
             default=None),
         age_variant=TunableVariant(
             description=
             "\n                The sim's age for creation. Can be a literal age or random\n                between two ages.\n                ",
             literal=LiteralAge.TunableFactory(),
             random=RandomAge.TunableFactory(),
             needs_tuning=True),
         resource_key=OptionalTunable(
             description=
             '\n                If enabled, the Sim will be created using a saved SimInfo file.\n                ',
             tunable=TunableResourceKey(
                 description=
                 '\n                    The SimInfo file to use.\n                    ',
                 default=None,
                 resource_types=(sims4.resources.Types.SIMINFO, ))),
         full_name=OptionalTunable(
             description=
             "\n                If specified, then the Sim's name will be determined by this\n                localized string. Their first, last and full name will all be\n                set to this.\n                ",
             tunable=TunableLocalizedString()),
         tunable_tag_set=TunableReference(
             description=
             '\n                The set of tags that this template uses for CAS creation.\n                ',
             manager=services.get_instance_manager(
                 sims4.resources.Types.TAG_SET)),
         **kwargs)
Пример #21
0
 def __init__(self):
     return super().__init__(
         negate_tag=Tunable(
             bool,
             default=False,
             description=
             '\n                        Negate the tag below, meaning the affinity will apply for Sims running interactions that\n                        DO NOT have the given tag. Note: has no effect when paired with ALL.'
         ),
         running_interaction_tag=TunableEnumEntry(
             InteractionPostureAffinityTag,
             default=InteractionPostureAffinityTag.ALL,
             description=
             '\n                                                                    A list of tags of interactions where if a Sim is running\n                                                                    any interaction that matches any of these tags, they will\n                                                                    get the attached affinity scoring'
         ),
         affinity_strategy=TunableVariant(
             description=
             '\n                                        The type of strategy to use when scoring other Sims.\n                                        ',
             relationship_based=RelationshipSimAffinityStrategy(
                 description=
                 '\n                                                        Score objects near Sims based on their relationship. This\n                                                        strategy will make Sims more likely to be near their\n                                                        family members and lovers, etc.'
             ),
             attract=AttractSimAffinityStrategy(
                 description=
                 '\n                                                        Score objects near other Sims more highly. This will make\n                                                        Sims more likely to be nearby other Sims.'
             ),
             avoid=AvoidSimAffinityStrategy(
                 description=
                 '\n                                                        Apply penalties to objects near other Sims. This will make\n                                                        Sims avoid other Sims.'
             )),
         multiplier=Tunable(
             float,
             default=1,
             description=
             '\n                                        A scalar multiplier on the final score for each other Sim.'
         ))
Пример #22
0
class LiveDragLootActions(LootActions):
    __qualname__ = 'LiveDragLootActions'
    INSTANCE_TUNABLES = {
        'loot_actions':
        TunableList(
            TunableVariant(
                statistics=TunableStatisticChange(
                    locked_args={
                        'advertise': False,
                        'chance': 1,
                        'tests': None
                    },
                    include_relationship_ops=False),
                collectible_shelve_item=CollectibleShelveItem.TunableFactory(),
                inventory_loot=InventoryLoot.TunableFactory(
                    subject_participant_type_options={
                        'description':
                        '\n                            The participant type who has the inventory that the\n                            object goes into during this loot.\n                            ',
                        'optional': False
                    },
                    target_participant_type_options={
                        'description':
                        '\n                            The participant type of the object which gets to\n                            switch inventories in the loot.\n                            ',
                        'default_participant': ParticipantType.LiveDragActor
                    }),
                state_change=StateChangeLootOp.TunableFactory(),
                money_loot=MoneyChange.TunableFactory()))
    }

    def __iter__(self):
        return iter(self.loot_actions)
Пример #23
0
class BindFamiliarElement(XevtTriggeredElement, HasTunableFactory,
                          AutoFactoryInit):
    FACTORY_TUNABLES = {
        'participant':
        TunableEnumEntry(
            description=
            '\n            The Sim to bind the familiar to.\n            ',
            tunable_type=ParticipantTypeSingle,
            default=ParticipantTypeSingle.Actor),
        'bind_familiar_action':
        TunableVariant(
            description=
            '\n            The action that will be taken to bind the familiar.\n            ',
            object_familiar=BindObjectFamiliar.TunableFactory(),
            pet_familiar=BindPetFamiliar.TunableFactory(),
            default='object_familiar')
    }

    def _do_behavior(self):
        familiar_owner = self.interaction.get_participant(self.participant)
        familiar_tracker = familiar_owner.sim_info.familiar_tracker
        if familiar_tracker is None:
            logger.error(
                'Trying to bind a familiar to a Sim that does not have a familiar tracker.'
            )
            return
        self.bind_familiar_action.bind_familiar(self.interaction,
                                                familiar_owner,
                                                familiar_tracker)
Пример #24
0
 def __init__(self, **kwargs):
     super().__init__(
         additional_operations=TunableList(
             description=
             '\n                A list of additional statistic operations beyond that created\n                automatically for the goal commodity.  They also represent the\n                change in the worst-case scenario and will apply proportionally.\n                ',
             tunable=TunableProgressiveStatisticChange()),
         goal_completion_time=TunableVariant(
             description=
             '\n                Controls how to determine the number of Sim minutes it should\n                take the specified goal commodity to reach the specified goal\n                value in the worst case.  Assuming goal_exit_condition is\n                enabled, this is also the longest the interaction could possibly\n                take to complete.\n                \n                This will be used to determine the rate at which each operation\n                should increase.\n                ',
             default='fixed',
             fixed=self.FixedTime.TunableFactory(),
             skill_based_curve=self.SkillTimeCurve.TunableFactory(),
             skill_based_ramp=self.SkillTimeRamp.TunableFactory()),
         goal_value=TunableVariant(
             description=
             '\n                The target value for the goal commodity.  All generated\n                commodity changes will be based on how long it will take\n                this commodity to get to this target.\n                \n                Used in conjunction with the specified running_time tunable\n                to figure out the rate at which each operation should\n                increase.\n                ',
             default='maximum_value',
             maximum_value=self.MaximumValue.TunableFactory(),
             minimum_value=self.MinimumValue.TunableFactory(),
             convergence_value=self.ConvergenceValue.TunableFactory(),
             specific_value=self.SpecificValue.TunableFactory(),
             specific_change=self.SpecificChange.TunableFactory(),
             state_value=self.StateValue.TunableFactory()),
         subject=TunableEnumEntry(
             description=
             '\n                The participant of the interaction whose commodity will change.\n                ',
             tunable_type=ParticipantType,
             default=ParticipantType.Actor),
         goal_exit_condition=OptionalTunable(
             description=
             "\n                If enabled, the interaction will exit when the goal commodity\n                reaches the goal value.\n\n                Additionally, if either minimum/maximum running time is enabled,\n                the interaction will only exit due to reaching goal value if\n                it has run for some minimum amount of time. If only one of the\n                two running times is enabled, the required time is equal to the\n                the enabled option's time. If both are enabled, the minimum\n                time is a randomly generated time between the two options.\n                ",
             enabled_by_default=True,
             tunable=TunableTuple(
                 minimum_running_time=OptionalTunable(
                     Tunable(description=
                             '\n                        The minimum amount of time this interaction should run\n                        for.\n                        ',
                             tunable_type=int,
                             default=10)),
                 maximum_running_time=OptionalTunable(
                     Tunable(
                         description=
                         '\n                        The maximum amount of time this interaction should run\n                        for.\n                        ',
                         tunable_type=int,
                         default=10)))),
         locked_args={'advertise': False},
         callback=self._on_tunable_loaded_callback,
         **kwargs)
class ObjectRoutingBehaviorActionDestroyObjects(ObjectRoutingBehaviorAction):
    FACTORY_TUNABLES = {
        'animation_success':
        OptionalTunable(
            description=
            '\n            If enabled, the animation to play if there are objects to destroy.\n            ',
            tunable=_ObjectRoutingActionAnimation.TunableFactory()),
        'animation_failure':
        OptionalTunable(
            description=
            '\n            If enabled, the animation to play if there are no objects to destroy.\n            ',
            tunable=_ObjectRoutingActionAnimation.TunableFactory()),
        'loot_success':
        TunableList(
            description=
            '\n            For each destroyed object, apply this loot between the routing\n            object (Actor) and the destroyed object (Object).\n            ',
            tunable=LootActions.TunableReference()),
        'object_selection_method':
        TunableVariant(tags=_DestroyObjectSelectionRuleTags.TunableFactory(),
                       target_object=_DestroyObjectSelectionRuleTargetObject.
                       TunableFactory(),
                       default='tags')
    }

    def run_action_gen(self, timeline, obj, target):
        objects = self.object_selection_method.get_objects(obj, target)
        if not objects:
            if self.animation_failure is not None:
                result = yield from self.animation_failure(
                    timeline, obj, target)
                return result
                yield
            return True
            yield

        def _callback(_):
            for o in objects:
                resolver = DoubleObjectResolver(obj, o)
                for loot_action in self.loot_success:
                    loot_action.apply_to_resolver(resolver)
                o.remove_from_client(fade_duration=obj.FADE_DURATION)
                o.destroy(
                    source=self,
                    cause=
                    'Object being destroyed by ObjectRoutingBehaviorActionDestroyObjects'
                )

        if self.animation_success is not None:
            result = yield from self.animation_success(timeline,
                                                       obj,
                                                       target,
                                                       callback=_callback)
            if not result:
                return result
                yield
        else:
            _callback(timeline)
        return True
        yield
Пример #26
0
class LotDecorationTest(HasTunableSingletonFactory, AutoFactoryInit, BaseTest):
    FACTORY_TUNABLES = {'test': TunableVariant(description='\n            The test we want to run.\n            ', decorations_available=_LotDecorationHasDecorationsAvailableTest.TunableFactory(), holiday_decoratable=_LotDecorationDecoratableHolidayTest.TunableFactory(), custom_decorations=_LotDecorationHasCustomDecorationsTest.TunableFactory(), active_lot_decorated_for_occasion=_ActiveLotIsDecoratedForSomeOccasionTest.TunableFactory(), default='decorations_available')}

    def get_expected_args(self):
        return {}

    def __call__(self):
        return self.test().perform_test(self.tooltip)
 def __init__(self, **kwargs):
     super().__init__(key_name='name',
                      value_type=TunableVariant(
                          default='string',
                          boolean=Tunable(bool, False),
                          string=Tunable(str, 'value'),
                          integral=Tunable(int, 0)),
                      **kwargs)
Пример #28
0
 def __init__(self, **kwargs):
     super().__init__(
         valid_objects=TunableVariant(
             description=
             '\n            The items to which the rebate will be applied.\n            ',
             by_tag=TunableSet(
                 description=
                 '\n                The rebate will only be applied to objects purchased with the\n                tags in this list.\n                ',
                 tunable=TunableEnumEntry(tunable_type=tag.Tag,
                                          default=tag.Tag.INVALID,
                                          invalid_enums=(tag.Tag.INVALID, ))
             ),
             locked_args={'all_purchases': None},
             default='all_purchases'),
         rebate_payout_type=TunableVariant(
             percentage=TunablePercent(
                 description=
                 '\n                The percentage of the catalog price that the player will get\n                back in the rebate.\n                ',
                 default=10),
             per_item=TunableRange(
                 description=
                 '\n                The amount per valid object the player will get back in the\n                rebate\n                ',
                 tunable_type=int,
                 default=1,
                 minimum=1)),
         notification_text=TunableLocalizedStringFactory(
             description=
             '\n            A string representing the line item on the notification\n            explaining why Sims with this trait received a rebate.\n            \n            This string is provided one token: the percentage discount\n            obtained due to having this trait.\n            \n            e.g.:\n             {0.Number}% off for purchasing Art and leveraging Critical\n             Connections.\n            '
         ),
         tests_set=TunableTestSet(
             description=
             '\n            If these tests pass, then the object is scheduled for the next \n            scheduled rebate event.\n            '
         ),
         rebate_category=TunableVariant(
             description=
             '\n            Specify a rebate category for this rebate item.\n            \n            GAMEPLAY_OBJECT: A GAMEPLAY_OBJECT category rebate item has the option\n            of either being a one-time rebate or a cyclical rebate. If tests are\n            tuned, the object has two opportunities to get added to rebates\n            before the next scheduled rebate event: once on add and its tests\n            pass, the next when its tests pass.\n            \n            BUILD_BUY: A BUILD_BUY category rebate item will give a one-time rebate\n            of all the valid objects purchased through build-buy.\n            ',
             buildbuy=RebateCategory(
                 locked_args={
                     'rebate_category_enum': RebateCategoryEnum.BUILD_BUY,
                     'cyclical': False
                 }),
             gameplay_object=RebateCategory(locked_args={
                 'rebate_category_enum':
                 RebateCategoryEnum.GAMEPLAY_OBJECT
             }),
             default='buildbuy'))
Пример #29
0
class UtilityModifierOp(BaseLootOperation):
    class ShutOffUtility(AutoFactoryInit, HasTunableSingletonFactory):
        FACTORY_TUNABLES = {
            'shutoff_tooltip':
            TunableLocalizedStringFactory(
                description=
                '\n                A tooltip to show when an interaction cannot be run due to this\n                utility being shutoff.\n                '
            )
        }

        def __call__(self, utility_manager, utility, shutoff_reason):
            utility_manager.shut_off_utility(utility, shutoff_reason,
                                             self.shutoff_tooltip)

    class RestoreUtility(HasTunableSingletonFactory):
        def __call__(self, utility_manager, utility, shutoff_reason):
            utility_manager.restore_utility(utility, shutoff_reason)

    FACTORY_TUNABLES = {
        'utility':
        TunableEnumEntry(
            description=
            '\n            The utility we want to shut off.\n            ',
            tunable_type=Utilities,
            default=Utilities.POWER),
        'shutoff_reason':
        TunableEnumEntry(
            description=
            '\n            The priority of our shutoff reason. This determines how important\n            the shutoff tooltip is relative to other reasons the utility is\n            being shutoff.\n            ',
            tunable_type=UtilityShutoffReasonPriority,
            default=UtilityShutoffReasonPriority.NO_REASON),
        'action':
        TunableVariant(
            description='\n            Action to change utility.\n            ',
            restore=RestoreUtility.TunableFactory(),
            shut_off=ShutOffUtility.TunableFactory(),
            default='shut_off'),
        'locked_args': {
            'subject': ParticipantType.Lot
        }
    }

    def __init__(self, *args, utility, shutoff_reason, action, **kwargs):
        super().__init__(*args, **kwargs)
        self.utility = utility
        self.shutoff_reason = shutoff_reason
        self.action = action

    def _apply_to_subject_and_target(self, subject, target, resolver):
        household = subject.get_household()
        household_id = household.id if household is not None else None
        _manager = game_services.service_manager.utilities_manager
        if household_id:
            utilities_manager = _manager.get_manager_for_household(
                household_id)
        else:
            utilities_manager = _manager.get_manager_for_zone(subject.zone_id)
        self.action(utilities_manager, self.utility, self.shutoff_reason)
class StreetCivicPolicySelectorMixin(HasTunableSingletonFactory,
                                     AutoFactoryInit):
    FACTORY_TUNABLES = {
        'street':
        TunableVariant(
            description=
            '\n            Select what street to test.\n            ',
            literal=TunablePackSafeReference(
                description=
                '\n                Identify a specific Street.\n                ',
                manager=services.get_instance_manager(
                    sims4.resources.Types.STREET)),
            via_zone_source=TunableVariant(
                description=
                '\n                Select the street to use by specifying a Zone Source.\n                ',
                use_current_zone=ActiveZone.TunableFactory(),
                use_pick_info=PickInfoZone.TunableFactory(),
                use_picked_zone_ids=PickedZoneIds.TunableFactory(),
                use_participant_home_zone=ParticipantHomeZone.TunableFactory(),
                default='use_current_zone'),
            via_street_participant=StreetParticipant.TunableFactory(),
            default='literal')
    }

    def _get_street(self, **kwargs):
        if self.street is None or hasattr(self.street, 'civic_policy'):
            street = self.street
        else:
            if isinstance(self.street, (StreetParticipant, )):
                return self.street.get_street(**kwargs)
            zone_id = self.street.get_zone_id(**kwargs)
            if zone_id is None:
                return
            from world.street import get_street_instance_from_zone_id
            street = get_street_instance_from_zone_id(zone_id)
        return street

    def _get_civic_policy_provider(self, *args, **kwargs):
        street_service = services.street_service()
        if street_service is None:
            return
        else:
            street = self._get_street(**kwargs)
            if street is not None:
                return street_service.get_provider(street)