Quick Reply
Search this Thread
Test Subject
Original Poster
#1 Old 26th May 2024 at 3:22 AM
Default Buff not loading into game
I have been trying to load Buffs into the game, but every attempt that I have made seems to have failed. Is there something that I could be doing wrong?.


Code:
namespace Sims3.game.est_MoodletLoader
{
    internal class BuffBooter
    {
        public void LoadBuffData()
        {
            AddBuffs(null);
            UIManager.NewHotInstallStoreBuffData = (UIManager.NewHotInstallStoreBuffCallback)Delegate.Combine(UIManager.NewHotInstallStoreBuffData, new UIManager.NewHotInstallStoreBuffCallback(AddBuffs));
        }
        public void AddBuffs(ResourceKey[] resourceKey)
        {
            XmlDbData xmldbdata = XmlDbData.ReadData(new ResourceKey(ResourceUtils.HashString64("BuffList_BuffTestMoodlet"), 53690476u, 0u), false);
            if(xmldbdata!=null)
            {
                BuffManager.ParseBuffData(xmldbdata, true);
            }
        }
    }

    public static class Instantiator
    {
        [Tunable]
        internal static bool kinstantiator2 = false;

        static Instantiator()
        {
            LoadSaveManager.ObjectGroupsPreLoad += OnPreLoad;
        }

        public static void OnPreLoad()
        {
            new BuffBooter().LoadBuffData();
        }
    }
}

namespace Sims3.game.est_Moodlet
{
    public class BuffTestMoodlet : Buff
    {
        private const ulong kTestMoodletBuff = 0x16E200B42A4DBF48;

        public static ulong staticGuid
        {
            get
            {
                return 0x16E200B42A4DBF48;
            }
        }

        public BuffTestMoodlet(BuffData info) : base(info)
        {

        }
    }
}



and then the xml-

Code:
<?xml version="1.0"?>
<buffs_BuffTest>
<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>
 <BuffList>
  <Hex>TestMoodletBuff=0x16E200B42A4DBF48</Hex>
  <BuffName>BuffTestMoodlet</BuffName>
  <BuffDescription>BuffTestMoodlet_BuffDescription</BuffDescription>
  <SKU>EP6</SKU>
  <ThumbFilename>moodlet_ensorcelled</ThumbFilename>
  <AxisEffected>None</AxisEffected>
  <EffectValue>0</EffectValue>
  <TimeoutLength>180</TimeoutLength>
  <CustomClassName>Sims3.game.est_Moodlet.BuffTestMoodlet, Sims3.game.est</CustomClassName>
 </BuffList>
</buffs_BuffTest>
Advertisement
Field Researcher
#2 Old 28th May 2024 at 2:53 PM
I looked in some old code and it was like this,

Code:
using Sims3.Gameplay.ActorSystems;
using Sims3.Gameplay.Utilities;
using Sims3.SimIFace;


                ResourceKey key = new ResourceKey(ResourceUtils.HashString64("MyBuffs"), 0x0333406C, 0x00000000);
                XmlDbData xmlDbData = XmlDbData.ReadData(key, false);
                if (xmlDbData != null)
                {
                                BuffManager.ParseBuffData(xmlDbData, true);
                }


Hope it can help.
Test Subject
Original Poster
#3 Old 28th May 2024 at 8:24 PM
Quote: Originally posted by denton47
I looked in some old code and it was like this,

Code:
using Sims3.Gameplay.ActorSystems;
using Sims3.Gameplay.Utilities;
using Sims3.SimIFace;


                ResourceKey key = new ResourceKey(ResourceUtils.HashString64("MyBuffs"), 0x0333406C, 0x00000000);
                XmlDbData xmlDbData = XmlDbData.ReadData(key, false);
                if (xmlDbData != null)
                {
                                BuffManager.ParseBuffData(xmlDbData, true);
                }


Hope it can help.



@denton47 Thank you so much for responding, I gave it a try and I was getting errors in visual studio. I try every buff code I could find I'm not sure if I had made an error with a spelling or anything. I am not sure if you would like to look at it, Thank you in advance again.
Attached files:
File Type: zip  TestingBuff.zip (3.8 KB, 5 downloads)
Trainee Moderator
staff: trainee moderator
#4 Old 31st May 2024 at 12:13 PM Last edited by Eca : 31st May 2024 at 12:48 PM.
It's probably because in the assembly, the variable is named "kinstantiator2", whereas in the XML, it's named "kInstantiator2"; case-sensitive.

So it's not that the buff is not loading, but the script isn't running at all.
Test Subject
Original Poster
#5 Old 3rd Jun 2024 at 8:54 PM
Quote: Originally posted by Eca
It's probably because in the assembly, the variable is named "kinstantiator2", whereas in the XML, it's named "kInstantiator2"; case-sensitive.

So it's not that the buff is not loading, but the script isn't running at all.


Thank you @Eca, Though I tried and it seems as if nothing is working. I'm not sure if it is because of the namespace, but nothing will show up.
Trainee Moderator
staff: trainee moderator
#6 Old 6th Jun 2024 at 8:47 AM
Quote: Originally posted by SimShady19
Thank you @Eca, Though I tried and it seems as if nothing is working. I'm not sure if it is because of the namespace, but nothing will show up.

I don't think so. It seems OK to me.

Perhaps you can add "SimpleMessageDialog.Show()" to produce a popup message as a reporter to many places in your code to see where it gets fired and where it does not. You may start with your constructor "static Instantiator()".
Test Subject
Original Poster
#7 Old 9th Jun 2024 at 6:56 PM
Quote: Originally posted by Eca
I don't think so. It seems OK to me.

Perhaps you can add "SimpleMessageDialog.Show()" to produce a popup message as a reporter to many places in your code to see where it gets fired and where it does not. You may start with your constructor "static Instantiator()".


Thanks @Eca, I put debug messages and it seems like the only place that it seems not to work in is the Instantiator. I am not sure If I should use an OnWorldLoad, since it seems as if the Instantiator is not going through.
Code:
public static class Instantiator
    {
        [Tunable]
        internal static bool kInstantiator = false;

        static Instantiator()
        {
            try
            {
                SimpleMessageDialog.Show("Debug", "Instantiator Constructor Called");
                LoadSaveManager.ObjectGroupsPreLoad += OnPreLoad;
                SimpleMessageDialog.Show("Debug", "Event Handler Registered");
            }
            catch (Exception ex)
            {
                SimpleMessageDialog.Show("Error", "Error in Instantiator constructor: " + ex.Message);
            }
        }
        public static void OnPreLoad()
        {
            try
            {
                SimpleMessageDialog.Show("Debug", "OnPreLoad Called");
                (new BuffBooter()).LoadBuffData();
                SimpleMessageDialog.Show("Debug", "Buff Data Loaded in OnPreLoad");
            }
            catch (Exception ex)
            {
                SimpleMessageDialog.Show("Error", "Error in OnPreLoad: " + ex.Message);
            }
        }
    }
}
Trainee Moderator
staff: trainee moderator
#8 Old 9th Jun 2024 at 9:58 PM
That means your script is not being run at all. So, "static Instantiator()" is also not being run.
Your XML should be like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<base>
  <Current_Tuning>
    <kInstantiator value="True" />
  </Current_Tuning>
</base>
The variable is case-sensitive and its value must be either "True" or "False".
"OnPreLoad" should be enough.
Test Subject
Original Poster
#9 Old 11th Jun 2024 at 5:17 PM Last edited by SimShady19 : 11th Jun 2024 at 5:58 PM.
Quote: Originally posted by Eca
That means your script is not being run at all. So, "static Instantiator()" is also not being run.
Your XML should be like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<base>
  <Current_Tuning>
    <kInstantiator value="True" />
  </Current_Tuning>
</base>
The variable is case-sensitive and its value must be either "True" or "False".
"OnPreLoad" should be enough.


@Eca that doesnt seem to be the problem, because I got my debug to produce what might be the issue, I'm not sure how to fix it though. It said "Error in Instantiator constructor: Attempting to yield in a non-yielding context!".
Trainee Moderator
staff: trainee moderator
#10 Old 12th Jun 2024 at 1:02 PM
May I test your file?
Test Subject
Original Poster
#11 Old 12th Jun 2024 at 6:18 PM
Quote: Originally posted by SimShady19
@Eca that doesnt seem to be the problem, because I got my debug to produce what might be the issue, I'm not sure how to fix it though. It said "Error in Instantiator constructor: Attempting to yield in a non-yielding context!".


@Eca, Thank you.
Attached files:
File Type: zip  TestingBuff2.zip (4.5 KB, 2 downloads)
Trainee Moderator
staff: trainee moderator
#12 Old 14th Jun 2024 at 9:33 AM
It throws the exception when trying to subscribe to ObjectGroupsPreLoad. This shouldn't happen. Maybe you used assemblies from older versions, targeted the wrong framework, or forgot to reference the game's mscorlib.dll... Can you send the project folder as well?
Test Subject
Original Poster
#13 Old 14th Jun 2024 at 2:36 PM
Quote: Originally posted by Eca
It throws the exception when trying to subscribe to ObjectGroupsPreLoad. This shouldn't happen. Maybe you used assemblies from older versions, targeted the wrong framework, or forgot to reference the game's mscorlib.dll... Can you send the project folder as well?



@Eca now that I think about it that could definitely be the case.
Attached files:
File Type: zip  Sims3.game.est.zip (171.0 KB, 4 downloads)
Trainee Moderator
staff: trainee moderator
#14 Old 20th Jun 2024 at 11:00 PM
Sorry I couldn't respond sooner. Turns out removing "SimpleMessageDialog"s from the constructor solves the yielding error. But your buff is still not loaded and that gives another error. I don't know why. I think you need to go through the custom moodlet tutorial and compare it to your work again.
Back to top