TUTORIAL - Commodities 2 (Patreon)
Content
In answer to the question:
This is an interesting question. There are a lot of times Maxis does this in different ways, and I can think not one, but at least 4 ways to do this, depending on what we want to achieve.
So, let's look at a couple of times Maxis does this, so you can see the logic behind. This will not be a step by step tutorial. We'll only be looking at Maxis xmls. If you have my XMLs folder you can follow me through.
Let's start from the way a vampire gets burned by the sun. The commodity controlling this is this one:
We can see by giving a look to it that this one is... weird:
It goes up to 100
On failure ( when the commodity reaches the min_value_tuning, comparison LESS_OR_EQUAL ) the sim burns... also the interaction repeats at an interval of 5 sims minutes, to be sure that this interaction runs.
It decays at a rate of 1
When it's given (the initial tuning) it starts at 100, so at the convergence value
the minimum it can get to is -100
there is another option: remove_on_convergence FALSE. It means that the commodity will not be removed once it reaches it's convergence value.
Now, careful... if you do not specify this, it defaults to true:
So the commodity is always removed on convergence.
Wait... our commodity here has something happening at -100 but... it goes up to 100?!
When the fuck is this commodity supposed to go down, and make that something happens?!
Let's first see where this commodity comes from...
To investigate this I just... take the instance number of the commodity and do a Windows search inside the XMLs folder:
It found some buffs, the commodity themselves, and...
The trait occult vampire!
This commodity is tuned in the vampire trait, along with Vampire Power and Thirst. You see both Power and Thirst in the UI, but not this one... yet she's there, at her maximum convergence value, watching and waiting all the time, waiting for...
The sim to get this buff (or another one of the sunlight buffs, depending on if they have sunlight resistance and at what level, what changes is the value in the modifier). This buff, as long as the sim has it (under the sun for too long), brings down that commodity 3.33333 points per sims minute, to the minimum of -100 where the sim will die.
Once the sim stops having this buff, the commodity will stop going down, and start going up to its convergence value, will reach 100 and sit there, waiting for the vampire to go under the sun again. So, this is a commodity that resets themselves, first way to do what SweetLilja asked.
Another way to do this:
This goes down to 0, at a decaying rate of 1, the max value is 120, but when it gets given it starts somewhere between 30 and 90, it's not removed on convergence, I highlighted another option:
_add_if_not_in_tracker this means that, when trying to update the commodity (in any way, via buff, action, interaction, whatever adds or removes points from this commodity) if the sim doesn't already have this on, it should not be given.
This is another option that defaults to true:
If you tell nothing to the game, the game assumes you want to give a commodity to the sim when you try to update it.
Let's say you want to make a interaction that affects a commodity you made, this interaction can be performed by any sim, but you want to only update the commodity if the sim already has it on... unless you tell the game to not add the commodity if not in tracker, the game will assume that when you try to add 1 point to it, you also want to give the commodity to a sim who doesn't have it already.
Our commodity here is associated to a buff that is given to NPCs only, when a specific policy is active
When this commodity goes to 1, an action runs:
This action does two things:
Forces the NPC to run an interaction, and resets the commodity to its max value (120)
When the Policy Buff is removed, the commodity is removed as well.
To go back to our initial question:
Can I have a commodity that activates only in certain situations? Sure you can...
- You can use the method maxis used with the Vampire Sun Exposure;
- You can have a commodity that gets added if not in tracker, removed on convergence, starts from the max value tuning, goes down to minimum, has the convergence value to the minimum, and make an interaction that will update that commodity. A sim performing said interaction will get the commodity, the commodity will start going down to 0, will do its job, and go away. When the sim will perform that interaction again, the commodity will be given again.
- You can have a commodity associated to a Buff, that only a sim with that buff will have, and use the reset method with loots
- You can have a commodity that goes to the convergence value, doesn't get removed, but sits there until you update it again somehow...
These are only 4 ways to do it, and ultimately depends on what you want to achieve.