Forum Discussion

MR_TURBODRIVER's avatar
MR_TURBODRIVER
Seasoned Veteran
7 years ago

Injecting Satisfaction Store Rewards

Hey! This is a simple way of injecting new rewards to the satisfaction store. I haven't tested it with anything else than traits, but it should work with everything as long as you include all of the details in the 'SimReward' tunable file.
A way of injecting rewards was requested by @Triplis and I hope it can be helpful for others too. It took me a while to figure it all out.

This instruction is strictly explaining how to add new reward traits. Adding money, moodlet, object, and CAS rewards is possible too, but wasn't tested.

1. Create a SimReward tunable file. In that file, you need to include your reward. For more details, you should check out the TDESC documentation. The example below is for a trait.


2F7D0004:00000000:ABABABABABABABAB
0x00000000
0x00000000




1234567890






2. Create a Python file. In that file, place the code below and change/add your own reward at the end just like the example is showing. The first variable is the ID of the SimReward tunable file, the second variable is the cost of the reward, and the third is the type (MONEY, BUFF, OBJECT, TRAIT, CASPART).

import services
from sims4 import resources, collections
from sims4.collections import FrozenAttributeDict
from whims.whims_tracker import WhimsTracker


def register_satisfaction_store_reward(reward_id, cost, award_type=WhimsTracker.WhimAwardTypes.TRAIT):
"""
Register satisfaction store reward of given type.
This method retains the original classes state and won't conflict when adding multiple of different rewards.
The 'award_type' keyword is set to 'TRAIT' as an example of what award types are available.
:param reward_id: int -> id of the reward instance
:param cost: int -> amount of satisfaction points this reward will cost
:param award_type: WhimAwardTypes -> award type enum
"""

reward_instance = services.get_instance_manager(resources.Types.REWARD).get(reward_id)

if reward_instance is not None:
immutable_slots_class = collections.make_immutable_slots_class()
reward_immutable_slots = immutable_slots_class(dict(cost=cost, award_type=award_type))

satisfaction_store_items = dict(WhimsTracker.SATISFACTION_STORE_ITEMS)
satisfaction_store_items = reward_immutable_slots

WhimsTracker.SATISFACTION_STORE_ITEMS = FrozenAttributeDict(satisfaction_store_items)


# Example of injecting a new reward trait
register_satisfaction_store_reward(1234567890, 100, WhimsTracker.WhimAwardTypes.TRAIT)


And you're done. Save and compile. The reward should now be available in the satisfaction store.

1 Reply

Replies have been turned off for this discussion
  • Thanks so much for sharing this, Turbodriver. :)

    I tried it with a custom simreward trait and it wasn't showing up in game, and then I realized it needed to be loaded somehow, so I used a standard injector and added the lines:


    from sims4.tuning.instance_manager import InstanceManager
    import injector


    And added to:


    # Example of injecting a new reward trait
    register_satisfaction_store_reward(1234567890, 100, WhimsTracker.WhimAwardTypes.TRAIT)


    with:


    @injector.inject_to(InstanceManager, 'load_data_into_class_instances')
    def _load_satisfaction_store_rewards(original, self):
    original(self)

    register_satisfaction_store_reward(1234567890, 100, WhimsTracker.WhimAwardTypes.TRAIT)


    Now it's showing up in-game. Yay. :)

    Also, for anyone else wanting to make use of it, it looks like the forums censored parts with the first four letters of dictionary into "plum". I changed that part in my code as well to account for it.

About The Sims 4 Mods & Custom Content

Find expert tips, troubleshooting help, tutorials for mods and custom content, and The Sims 4 patch files in our forum.14,403 PostsLatest Activity: 12 minutes ago