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 24th Mar 2016 at 11:08 PM
First attempt at a core mod crashing at load
Hi, I am a brand-new modder on TS3 and first-time poster on MTS (but longtime fan). I have some experience coding but not a lot with these tools. My head is bursting with ideas, but unfortunately, I feel like my hands are a little clumsy.

I'm a fan of the NRaas mods and have had a lot of fun with Woohooer. One of the things it does is enable romantic interactions between closely-related Sims. I thought, that's pretty fun; but one of the things I noticed is that though the interactions are available, the rest of the game, such as the Dreams and Promises system, doesn't treat the Sims as any other romantic couple. Though Woohooer allows some autonomous interactions, they don't "want" each other; they don't have dreams to kiss each other, etc.

Hacking through the core, I find what I think is the culprit: IsSufficientlyRelatedToRuleOutRomance in Sims3.Gameplay.Socializing.Genealogy. The game submits budding romantic dreams, among other things, to this function, and kills them before they happen. It's a simple boolean function, so I thought, hey, it shouldn't be hard to make this always return false. Hence, my first attempt at a core mod. (Yes, it's an incest mod. Don't judge, yo.)

Following BailaBaila99's core modding tutorial, I decompiled the core to IL and did some tweaking. I edited the return values of the function, reassembled the IL to a DLL with Ilasm, repackaged it using S3PE, stuck it in my mods directory -- and then nothing. It loaded the loader; it went through the intro video and got to the end of the main game loader (to bring up the main menu where my saved games are listed) -- and then it crashed. Finding the xcpt[...].txt file, it shows this exception:

Code:
[Exception info]
date: 2016-03-24
time: 16.17.35
type: ACCESS_VIOLATION reading address 0x00000014
address: 0x00e51f25 "C:\Program Files (x86)\Steam\steamapps\common\The Sims 3\Game\Bin\TS3W.exe":0x0001:0x00a50f25


Oh, yeah, I'm running this under Steam; forgot to mention that. Under Windows 10. And FWIW, the only other core mod I am running is one which this ought not to conflict, NRaas's ErrorTrap, which only mods ScriptCore.

So, did I screw something up? Where did I go wrong? With my editing? Assembling? Packaging? So much can go wrong, and I'm not experienced enough to see what it might be. So I would appreciate your help.

Below is the code I was working with:

The code of the original function, for reference (this acquired using ILSpy):

Code:
namespace Sims3.Gameplay.Socializing.Genealogy {
	public bool IsSufficientlyRelatedToRuleOutRomance(Genealogy other)
	{
		return (other.SimDescription == null || !other.SimDescription.IsEP11Bot) && (this.mSim == null || !this.mSim.IsEP11Bot)
			&& (this.IsBloodRelated(other) || this.IsStepRelated(other) || this.IsFutureBloodRelated(other));
	}
}


The original IL:

Code:
.method public hidebysig instance bool 
          IsSufficientlyRelatedToRuleOutRomance(class Sims3.Gameplay.Socializing.Genealogy other) cil managed
  {
    // Code size       79 (0x4f)
    .maxstack  2
    IL_0000:  ldarg.1
    IL_0001:  callvirt   instance class Sims3.Gameplay.CAS.SimDescription Sims3.Gameplay.Socializing.Genealogy::get_SimDescription()
    IL_0006:  brfalse.s  IL_0015

    IL_0008:  ldarg.1
    IL_0009:  callvirt   instance class Sims3.Gameplay.CAS.SimDescription Sims3.Gameplay.Socializing.Genealogy::get_SimDescription()
    IL_000e:  callvirt   instance bool Sims3.Gameplay.CAS.SimDescription::get_IsEP11Bot()
    IL_0013:  brtrue.s   IL_002a

    IL_0015:  ldarg.0
    IL_0016:  ldfld      class Sims3.Gameplay.CAS.SimDescription Sims3.Gameplay.Socializing.Genealogy::mSim
    IL_001b:  brfalse.s  IL_002c

    IL_001d:  ldarg.0
    IL_001e:  ldfld      class Sims3.Gameplay.CAS.SimDescription Sims3.Gameplay.Socializing.Genealogy::mSim
    IL_0023:  callvirt   instance bool Sims3.Gameplay.CAS.SimDescription::get_IsEP11Bot()
    IL_0028:  brfalse.s  IL_002c

    IL_002a:  ldc.i4.0
    IL_002b:  ret

    IL_002c:  ldarg.0
    IL_002d:  ldarg.1
    IL_002e:  call       instance bool Sims3.Gameplay.Socializing.Genealogy::IsBloodRelated(class Sims3.Gameplay.Socializing.Genealogy)
    IL_0033:  brfalse.s  IL_0037

    IL_0035:  ldc.i4.1
    IL_0036:  ret

    IL_0037:  ldarg.0
    IL_0038:  ldarg.1
    IL_0039:  call       instance bool Sims3.Gameplay.Socializing.Genealogy::IsStepRelated(class Sims3.Gameplay.Socializing.Genealogy)
    IL_003e:  brfalse.s  IL_0042

    IL_0040:  ldc.i4.1
    IL_0041:  ret

    IL_0042:  ldarg.0
    IL_0043:  ldarg.1
    IL_0044:  call       instance bool Sims3.Gameplay.Socializing.Genealogy::IsFutureBloodRelated(class Sims3.Gameplay.Socializing.Genealogy)
    IL_0049:  brfalse.s  IL_004d

    IL_004b:  ldc.i4.1
    IL_004c:  ret

    IL_004d:  ldc.i4.0
    IL_004e:  ret
  } // end of method Genealogy::IsSufficientlyRelatedToRuleOutRomance


My modded version alters the following:

Code:
IL_0035:  ldc.i4.0  // Modded to return false
...
IL_0040:  ldc.i4.0  // Modded to return false
...
IL_004b:  ldc.i4.0  // Modded to return false


ILSpying on my reassembled DLL, I get this:

Code:
public bool IsSufficientlyRelatedToRuleOutRomance(Genealogy other)
{
	return (other.SimDescription == null || !other.SimDescription.IsEP11Bot) && (this.mSim == null || !this.mSim.IsEP11Bot)
		&& !this.IsBloodRelated(other) && !this.IsStepRelated(other) && this.IsFutureBloodRelated(other) && false;
}


Kind of clumsy and not really what I wanted, but it ought always to return false. So what went wrong?

Help?

[P.S. In the preview it's showing added line breaks in my code sections. How can I stop that?]
Back to top