Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Quick Reply
Search this Thread
Test Subject
Original Poster
#1 Old 27th Nov 2019 at 8:14 PM
Default How would I create a wants/desires mod?
Hey guys!

Does anyone know what files I would need to access to create a wants mod for this game? It really bothers me how the sims don't really have true wants. All of the whims they have are short-term and don't really have consequences. Basically, I have compiled a massive list of scenarios that would have long-lasting effects on their lives and even the sims they are related to or know of.

What I know I will need:
- I'm going to need to make code for moodlets when sims complete their wish, or do not complete it.
- I'm going to need to make code to have their emotions affected depending on whether or not they complete their wish.
- I'm going to need to create code that will allow the mod to cycle through 8 different categories of wishes (Love, career, family, friends, etc...) Once the category is selected I will need another randomizer to select the wish through the number of wishes within the selected category.
- I think I want to have an object that the sims will have to use in order to trigger this wants system. They can use it multiple times if they want more than one wish to try and complete.
-There would need to be a fail safe option in the event that a wish rolled cannot be completed due to the sim's age or simply the player's discretion. In that case the wish would be cleared and no negative moodlets would persist.

For example a scenario would be: Click on the object and your sim rolls a wish to move to another town. The sim gets x amount of days to complete that wish. In the meantime they will get a tense/sad/angry/ moodlet each day they do not complete it. If the sim does not complete their wish within x amount of days they will be sad/angry for a few hours. If the sim completes their wish within x amount of days then they will receive a happy/confident/inspired/focused moodlet. The player can then choose to use the object again for another wish assignment.


So far between all 8 categories and their numbers of wishes I have a total of 169 scenarios compiled in a list so far. I really want to make this a mod instead of using a number generator app on my phone and playing these scenarios out for my sims. If anyone could help me figure out what files I need to access, I would greatly appreciate it! :D
Advertisement
Test Subject
#2 Old 1st Dec 2019 at 3:43 AM Last edited by Saa : 1st Dec 2019 at 3:55 AM.
Get The Sims 4 Mod Constructor, it's gonna help you a lot.
Add Element -> Subordinate Types -> Buffs. Create the moodlets you talked about. Click Add Component and put every detail you want, like duration, the emotion, etc.
Add Element -> Intermediate -> Aspiration Category. Then create your 8 categories. (I know, they're not aspirations, but did you know even carreer progression in TS4 is managed as an aspiration track?)
Add Element -> Intermediate -> Aspiration Track. Create each of your wishes:
- Only add an icon if you want to show icons when the wishes are selected
- In the category part, select Existing Element under Reference Type and select one of the categories you made
- If you want something to show up when the player completes a wish, write the Notification Text
- Try to add the wish's objective in the Objective Set. You might have to create a new set, and then search for what you want in the values. If you still can't find the objective you want, you can go to Subordinate Types-> Objective, then Add Component -> Objective Types, search for what you want, go back and select your new objective as a value in that new set you created. If you still can't find it, create a buff for it, but don't add any components to it. That'll make it a hidden buff. Then add it as an objective value (buff objective).
- In Reward on Completion, select the positive buff you created earlier. The negative ones will be added in a later step.
- Create another hidden buff named whatever. You only need one.
Make sure everything's to your liking, because Mod Contructor's main weakness is that it can't modify package files, just overwrite. So you're going to Export Package, and once you go to the next step, there'll be no going back!
If you have Sims4Studio, open it, click in My Projects, and select the package file you just exported. Search for the buff files (in S4S, they're "Buff Tuning" files) until you find the negative buff you created. Look at the second line, and search for something like s="14018653721593773271". You're gonna use these id numbers aaaaaall the time, so save them somewhere. If you created a buff for when the player cancels a wish, copy its number too.
Now open the text editor of your choice, and create a new file named something like "littlesims2chick_enums.py". Then write:
Code:
import enum

class LoveEnums(Enum.int):
    EXAMPLE = 12345


class CarreerEnums(Enum.int):
    EXAMPLE_2 = 6789

Etc, etc. Careful with those indentations, Python can be really picky about them. Use four spaces.
Anyway, instead of EXAMPLE, you're going to search for the id number of each Aspiration Tuning file. Populate your eight category classes with things like BUY_A_CAR = 45893567908436709354. If you added "negative aspirations", create classes for them, too (like NegativeCarreerEnums).
Now change the aspirations' files to look like the TimedAspirations_Resolutions XMLs. Put your buffs' id numbers in the "on_complete_loot_actions", "on_failure_loot_actions", and (way down in the file) "warning_buff" -> "buff_type". I don't know if you can delete the on_cancel or not; you can test it or you can just use that hidden buff named whatever. You can also edit the specified ages, etc to make sure a sim who gets the wish will always be able to complete it.
Make another Enum category, this time with the hidden buffs you had to create previously when making objectives.
Finally, make a last category with whatever name you have for misc enums. You'll add the id of that SuperAffordanceInstance you made, and the id of the object you made for the mod. Unless you're planning to use an EA object, then find its id in its XML file.

Add this code to a new .py file, then check back here because I don't know how to listen to affordances BUT my mod also needs it so I'll learn soon ~

By the way, you'll also need to inject code into the simulation.aspirations.timed_aspiration.TimedAspirationData, method 'schedule', to change the warning_duration part so the sims gets negative moodlets in more than one day. But check in your injection if the timed aspiration in question is yours or EA's.

Anyway, that's the behind-the-scenes code. I don't know how exactly you want the UI to be, other than the "Add Wish" interaction. Finding out how to make it so the player can cancel the wish depends on it.
Test Subject
Original Poster
#3 Old 1st Dec 2019 at 7:08 PM
Quote: Originally posted by Saa
Get The Sims 4 Mod Constructor, it's gonna help you a lot.
Add Element -> Subordinate Types -> Buffs. Create the moodlets you talked about. Click Add Component and put every detail you want, like duration, the emotion, etc.
Add Element -> Intermediate -> Aspiration Category. Then create your 8 categories. (I know, they're not aspirations, but did you know even carreer progression in TS4 is managed as an aspiration track?)
Add Element -> Intermediate -> Aspiration Track. Create each of your wishes:
- Only add an icon if you want to show icons when the wishes are selected
- In the category part, select Existing Element under Reference Type and select one of the categories you made
- If you want something to show up when the player completes a wish, write the Notification Text
- Try to add the wish's objective in the Objective Set. You might have to create a new set, and then search for what you want in the values. If you still can't find the objective you want, you can go to Subordinate Types-> Objective, then Add Component -> Objective Types, search for what you want, go back and select your new objective as a value in that new set you created. If you still can't find it, create a buff for it, but don't add any components to it. That'll make it a hidden buff. Then add it as an objective value (buff objective).
- In Reward on Completion, select the positive buff you created earlier. The negative ones will be added in a later step.
- Create another hidden buff named whatever. You only need one.
Make sure everything's to your liking, because Mod Contructor's main weakness is that it can't modify package files, just overwrite. So you're going to Export Package, and once you go to the next step, there'll be no going back!
If you have Sims4Studio, open it, click in My Projects, and select the package file you just exported. Search for the buff files (in S4S, they're "Buff Tuning" files) until you find the negative buff you created. Look at the second line, and search for something like s="14018653721593773271". You're gonna use these id numbers aaaaaall the time, so save them somewhere. If you created a buff for when the player cancels a wish, copy its number too.
Now open the text editor of your choice, and create a new file named something like "littlesims2chick_enums.py". Then write:
Code:
import enum

class LoveEnums(Enum.int):
    EXAMPLE = 12345


class CarreerEnums(Enum.int):
    EXAMPLE_2 = 6789

Etc, etc. Careful with those indentations, Python can be really picky about them. Use four spaces.
Anyway, instead of EXAMPLE, you're going to search for the id number of each Aspiration Tuning file. Populate your eight category classes with things like BUY_A_CAR = 45893567908436709354. If you added "negative aspirations", create classes for them, too (like NegativeCarreerEnums).
Now change the aspirations' files to look like the TimedAspirations_Resolutions XMLs. Put your buffs' id numbers in the "on_complete_loot_actions", "on_failure_loot_actions", and (way down in the file) "warning_buff" -> "buff_type". I don't know if you can delete the on_cancel or not; you can test it or you can just use that hidden buff named whatever. You can also edit the specified ages, etc to make sure a sim who gets the wish will always be able to complete it.
Make another Enum category, this time with the hidden buffs you had to create previously when making objectives.
Finally, make a last category with whatever name you have for misc enums. You'll add the id of that SuperAffordanceInstance you made, and the id of the object you made for the mod. Unless you're planning to use an EA object, then find its id in its XML file.

Add this code to a new .py file, then check back here because I don't know how to listen to affordances BUT my mod also needs it so I'll learn soon ~

By the way, you'll also need to inject code into the simulation.aspirations.timed_aspiration.TimedAspirationData, method 'schedule', to change the warning_duration part so the sims gets negative moodlets in more than one day. But check in your injection if the timed aspiration in question is yours or EA's.

Anyway, that's the behind-the-scenes code. I don't know how exactly you want the UI to be, other than the "Add Wish" interaction. Finding out how to make it so the player can cancel the wish depends on it.

TYSM!! I'm gonna work on this. It's 1 week before finals at my school but I'm hoping to get this done sometime early next year. TY!!!! <3
Test Subject
#4 Old 2nd Dec 2019 at 6:26 AM
Checking back! Forget about what I said after getting the object's ID. If you're going to create your own object, you can just edit its XML to add your interaction, by putting, at the end of its file:
Code:
  <L n="_super_affordances">
    <T>123456789</T>
  </L>

and instead of 123456789, you put your interaction's id there.
Then open your interaction's XML and add:
Code:
  <L n="basic_extras">
    <V t="do_command">
      <U n="do_command">
        <T n="command">littlesims2chick.getwish</T>
      </U>
    </V>
  </L>

Then you can create a script.py file and add something like this:
Code:
import random
import littlesims2chick_enums as cat
from server_commands.aspiration_commands import activate_timed_aspiration


@sims4.commands.Command('littlesims2chick.getwish', command_type=sims4.commands.CommandType.Live)
def get_a_wish(aspiration_type:TunableInstanceParam(_connection=None):
    sim = get_optional_target(None, _connection)
    if sim is None:
        return
    categories = [cat.LoveEnums, cat.CarreerEnums]
    category = random.choice(categories)
    wish = random.choice(list(category))
    activate_timed_aspiration(wish, sim)


There's one problem, though - it just occurred to me that timed aspirations were added with the Seasons pack. You'll have to ask someone with only the base game if they're supported - if there's a timed_aspiration.py file among the extracted Python files. I'm pretty sleepy so we'll cross that bridge when we get there.

Anyway, just now I thought of a way to add those tense/sad/angry moodlets without having to override anything. Just add each buff as the "loot on removal" of the other. Then create a hidden buff with the remainder (the first day the sim has the wish, and doesn't have any moodlets). Add the buff for the second day as "loot on removal" of the hidden buff, get that buff's id, add it to that hidden buff enum category, and then add these lines to the get_a_wish code, right before the activate_timed_aspiration line:
Code:
    sim.add_buff(cat.HiddenBuffEnum.HIDDEN_TIMEOUT_BUFF)
Back to top