Quick Reply
Search this Thread
Test Subject
Original Poster
#1 Old 5th Apr 2025 at 3:14 AM
Default Where am I Going wrong in my Moodlet Creation
Hi! I need help creating custom moodlets. I've watched videos, looked at templates, went through the tutorials but I'm still stuck. Do you have any idea Where I am going wrong?

Code:
 namespace Simception.RoyaltyMod.BuffLoader
{
    // The BuffBooter class is responsible for loading buff data.
    internal class BuffBooter
    {
        public void LoadBuffData()
        {
            // Calls the AddBuffs method and subscribes to the NewHotInstallStoreBuffData event.
            this.AddBuffs(null);
            UIManager.NewHotInstallStoreBuffData = (UIManager.NewHotInstallStoreBuffCallback)Delegate.Combine(UIManager.NewHotInstallStoreBuffData, new UIManager.NewHotInstallStoreBuffCallback(this.AddBuffs));
        }

        // This method is called to add buffs, reading data from XML files.
        public void AddBuffs(ResourceKey[] resourcekey)
        {
            // Reads XML data to load buffs using a specific resource key (hashes used here).
            XmlDbData xmlDbData = XmlDbData.ReadData(new ResourceKey(
                ResourceUtils.HashString64("Bufflist_RoyaltyMod"),  // Placeholder for actual XML file name.
                53690476U,  // Example hash value
                0U), false); // Reads the data from the XML

            bool flag = xmlDbData != null;
            if (flag)
            {
                // Parses and loads the buff data into the game.
                BuffManager.ParseBuffData(xmlDbData, true);
            }
        }
    }

    // Instantiator class is responsible for loading buff data when the game is preloaded.
    public static class Instantiator
    {
        [Tunable]  // This attribute allows the value to be externally configured.
        internal static bool kInstantiator2 = false;

        // Static constructor for the Instantiator class, called when the class is first accessed.
        static Instantiator()
        {
            // Registers the OnPreLoad method to be called before the object groups are loaded.
            LoadSaveManager.ObjectGroupsPreLoad += new ObjectGroupsPreLoadHandler(Instantiator.OnPreLoad);
        }

        // Method called before object groups are loaded. It triggers the loading of buff data.
        public static void OnPreLoad()
        {
            new BuffBooter().LoadBuffData();  // Load the buff data before the game loads.
        }
    }
}

namespace Simception.RoyaltyMod.Buffs
{
    // The BuffRulingMonarch class defines a custom buff for a ruling monarch.
    public class BuffRulingMonarch : Buff
    {
        // The unique GUID for this buff (used to identify the buff in the system).
        private const ulong kRulingMonarchGuid = 0x89E915AEBC17B7D0L;

        // Static property to retrieve the GUID for this buff.
        public static ulong StaticGuid
        {
            get
            {
                return 0x89E915AEBC17B7D0;
            }
        }

        // Constructor for the BuffRulingMonarch class, which takes buff data.
        public BuffRulingMonarch(Buff.BuffData info) : base(info) { }
    }
}


Moodlet String XML:
Quote:
<?xml version="1.0" encoding="UTF-8" ?>
<TEXT>

<!-- Name of the buff in the game -->
<KEY>Gameplay/Excel/buffs/BuffList:RulingMonarch_Buff</KEY>
<STR>A Ruling Monarch</STR>

<!-- Description of the buff in the game -->
<KEY>Gameplay/Excel/buffs/BuffList:Rulingmonarch_BuffDescription</KEY>
<STR>Any sim likes to be under test. They feel important.</STR>

</TEXT>


Moodlet Buff List: Bufflist_RoyaltyMod
Quote:
<?xml version="1.0" encoding="UTF-8" ?>
<RoyalBuffs>
<!-- You MUST leave the following entry as it is. This is the template. -->
<BuffList>
<BuffName></BuffName>
<BuffDescription></BuffDescription>
<BuffHelpText></BuffHelpText>
<FirstPersonDescription></FirstPersonDescription>
<Category></Category>
<PermaMoodlet>False</PermaMoodlet>
<PermaMoodletColor></PermaMoodletColor>
<AxisEffected></AxisEffected>
<PolarityOverride>NoOverride</PolarityOverride>
<EffectValue></EffectValue>
<DelayTimer>0</DelayTimer>
<TimeoutLength></TimeoutLength>
<SKU>BaseGame</SKU>
<SolveCommodity></SolveCommodity>
<AttemptAutoSolve>False</AttemptAutoSolve>
<SolveTime></SolveTime>
<Stackable></Stackable>
<IsExtreme>False</IsExtreme>
<FacialIdle></FacialIdle>
<IncreasedEffectiveness></IncreasedEffectiveness>
<ReducedEffectiveness></ReducedEffectiveness>
<Hex></Hex>
<CustomClassName></CustomClassName>
<ThumbFilename></ThumbFilename>
<Topic></Topic>
<ShowBallon>True</ShowBallon>
<Travel>False</Travel>
<DisallowedOccults></DisallowedOccults>
<JazzStateSuffix></JazzStateSuffix>
<Version>0.1</Version>
<SpeciesAvailability>All</SpeciesAvailability>
</BuffList>
<!-- Here starts the definition of your Buffs -->
<BuffList>
<BuffName>RulingMonarch_Buff>
<BuffDescription>Rulingmonarch_BuffDescription>
<Hex>RulingMonarchGuid = 0x89E915AEBC17B7D0L</Hex>
<CustomClassName>Simception.RoyaltyMod.Buffs.BuffRulingMonarch,Royalliving</CustomClassName>
<ThumbFilename>moodlet_Hungry</ThumbFilename>
<!-- Effects of your custom moodlet -->
<Category>Physical</Category>
<AxisEffected>Happy</AxisEffected>
<EffectValue>20</EffectValue>
<TimeoutLength>240</TimeoutLength>
<SKU>BaseGame</SKU>
<Stackable>False</Stackable>
<Version>0.1</Version>
</BuffList>
</RoyalBuffs>
Back to top