Quick Reply
Search this Thread
Senior Moderator
staff: senior moderator
Original Poster
#1 Old 11th Mar 2025 at 3:40 PM Last edited by zoe22 : 11th Mar 2025 at 4:54 PM.
Default Skill gain through ITUN for custom skills
Please Note: This tutorial is aimed at anyone who has successfully made a custom skill and an interaction to increase it. It won't tell you how to load a custom skill, or make an interaction.

EA interactions that cause skill gain usually do so through the ITUN like so:

Code:
<Change type="SkillLogic" advertised="400" locked="True" actual="400" updateType="ContinuousFlow" timeDependsOn="False" updateEvenOnFailure="False" updateAboveAndBelowZero="Either" />

But it doesn't work for custom skills, even the EA store skills (e.g Violin) where instead the skill has to be added in the interaction's c# code. But actually that's not true, and there's just two things you need to do to allow your custom skill to be used in ITUNs!

1. Add your skill's CommodityKind to the CommodityKind enum:

So first, here is the generic AddEnumValue function: (not sure where this came from originally, but it's used for adding custom lifetime wishes as well as in other mods)
Code:
private static void AddEnumValue<T>(string key, object value) where T : struct
        {
            Type typeFromHandle = typeof(T);
            if (!ParserFunctions.sCaseInsensitiveEnumParsers.TryGetValue(typeFromHandle, out EnumParser value2))
            {
                value2 = new EnumParser(typeFromHandle, ignoreCase: true);
                ParserFunctions.sCaseInsensitiveEnumParsers.Add(typeFromHandle, value2);
            }
            if (!ParserFunctions.sCaseSensitiveEnumParsers.TryGetValue(typeFromHandle, out EnumParser value3))
            {
                value3 = new EnumParser(typeFromHandle, ignoreCase: false);
                ParserFunctions.sCaseSensitiveEnumParsers.Add(typeFromHandle, value3);
            }
            if (!value2.mLookup.ContainsKey(key.ToLowerInvariant()) && !value3.mLookup.ContainsKey(key))
            {
                value2.mLookup.Add(key.ToLowerInvariant(), value);
                value3.mLookup.Add(key, value);
            }
        }

To add your CommodityKind...
In your SKIL resource, you should have chosen a commodityKind value here
Code:
<Commodity>SkillZoeoePottery=0x234A5EEF</Commodity>

You need to add the enum values immediately when your mod is loaded, so in the static constructor - NOT in OnStartupApp etc, which is too late.
Code:
AddEnumValue<CommodityKind>("SkillZoeoePottery", (CommodityKind)0x234A5EEF);

You also want to add the skill to SkillNames if you haven't already. This is also needed for having custom skills as career metrics and in dream trees.
Code:
AddEnumValue<SkillNames>("zoeoePottery", (SkillNames)0x0B65BEF8);

Note that the values used here are from the SKIL resource:
Code:
<Hex>zoeoePottery=0x0B65BEF8</Hex>


2. You need to make sure that the skill's CommodityKind value is between the decimal numbers 536870912 and 804999999.
You can use this website to convert hex to decimal numbers https://www.rapidtables.com/convert...to-decimal.html
The reason is because of this check
Code:
public static bool IsSkill(CommodityKind k)
{
	return (int)k >> 28 == 2;
}

And unless I'm confused, the numbers I gave above will return true to the above check because the binary value has to start with 0010 in order to = 2 when shifted right 28 times...
And I think the range is the full set that start with that in binary :p
You can always check the value in binary yourself to make sure!

So now, you should be able to add the skill's commodity kind into the ITUN as an output, and it will work in game!

A final note, this isn't enough for autonomy. Your ITUN can encourage sims to do the interaction with something else like Fun, but in order to have a custom commodity kind work for autonomy, you need to load it as a motive and add the motive to sims... I've not done this so I can't give more info but it's what douglasveiga's Gardener Service mod does, so check that out if you want to explore custom autonomy further.
Back to top