Maeldor
9th Jun 2011, 02:41 PM
Edit: Resolved! Thanks to Buzzler for informing me of what I needed to know. It seems this was a lot easier than I thought: it was just a missing ITUN!
Hi everyone,
So, I've become interested in script modding (not core!) and I find it fantastic (I'm a C# coder so I'm comfortable!), and I've decided I want to try replacing the sleep interaction on beds (specifically, I'm wanting to alter how it picks the outfit to be used). But I've hit a problem and really could do with some insight from those who might know what I'm doing wrong.
I understand (at least I think! Thanks especially to Buzzler's code (you're awesome!)) how interactions are replaced. You simply alter their Singleton to your own definition during Preload (LoadSaveManager.ObjectGroupsPreLoad). But, for the life of me, I can't seem to replace EnterSleeping without totally breaking the bed's sleep interaction!
From what I can tell, Beds have a BedSleep interaction (the actual interaction you click on in the pie menu), and an EnterSleeping interaction which figures out the route and determines what happens before the sim actually gets into the bed. These two interactions are of the type InteractionPart (the name makes sense), but I'm not entirely sure how they work together. I've been looking through the code for literally 3 days straight and cannot see where BedSleep and EnterSleeping call each other - there seems to be absolutely no reference to each other.
Now, the really strange thing... No matter what I seem to do to EnterSleeping, it breaks the sleep routine. The moment I click the interaction on the bed, the sleep interaction gets added to the queue and immediately removed again, so nothing happens.
I'm lost as to what's causing this. I've even tried replacing the EnterSleeping's Singleton with an identical definition (at least, as identical as my decompiler gave me):
private sealed class Definition : InteractionDefinition<Sim, Bed, Sims3.Gameplay.Objects.Beds.EnterSleeping>
{
public override InteractionTestResult Test(ref InteractionInstanceParameters parameters, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
Sim sim = parameters.Actor as Sim;
if ( parameters.EffectivelyAutonomous && sim.SimDescription.IsMummy )
return InteractionTestResult.GenericFail;
else
return base.Test(ref parameters, ref greyedOutTooltipCallback);
}
public override bool Test(Sim a, Bed target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
if ( !target.CanBeUsedAsBed || !isAutonomous && !(a.InteractionQueue.RunningInteraction is BedSleep) || a.Posture.GetType() == typeof(SleepingPosture) )
{
return false;
}
else
{
if ( isAutonomous && !target.CanShareBed(a, CommodityKind.Sleeping) )
{
InteractionInstance headInteraction = a.InteractionQueue.GetHeadInteraction();
if ( headInteraction == null || headInteraction.Autonomous )
return false;
}
if ( Posture.TestForRunningDuplicateInteraction((InteractionDefinition)this, a, (IGameObject)target) || a.InteractionQueue.TransitionInteraction is Sims3.Gameplay.Objects.Beds.EnterSleeping )
return false;
else
return true;
}
}Please take notice of the Sims3.Gameplay.Objects.Beds.EnterSleeping in the InteractionDefinition constructor: the definition is even linking to the original interaction, yet it still doesn't work! (this is just for testing, obviously; when it comes to getting this working, I'd use my own actual interaction). I was beginning to think perhaps there was a problem with the decompiled code—I've even tried about 5 different decompilers, and nothing works—but the fact I'm replacing it with a definition that targets the original interaction (and even disregarding the code entirely by forcing the definition to return true) makes me think there's something else going on here that I'm unaware of. Have I got this idea wrong or something? This is where the interaction is chosen, right? I assume the game instantiates a new interaction, when it's run, from the definition's—uh...—definition (the last parameter!), lol.
I've even tried inheriting the Sims3.Gameplay.Objects.Beds.EnterSleeping interaction itself (I reassembled the DLLs into public and non-sealed form to achieve this in the compiler), but nothing there either.
I'm really lost as to why this just breaks. Am I totally missing something? I'm new to this so that's very likely, but I just can't see it.
I know it's a long shot—perhaps this is just one of those interactions you can't replace with a scripting mod and it needs to be core, for some bizarre reason or another—but I'm hoping perhaps someone can shed some light on it. I've been at it for days (I've almost been losing sleep over this!) and just can't understand why it's refusing to work.
The only actual thing I can do without it breaking is to replace its Singleton with a new instance of its own definition (fat lot of use that does, obviously, lol).
Thanks so much! I'll greatly appreciate any assistance! :)
(and sorry for the long post!)http://www.modthesims.info/static/images/icons/icon11.gif
Hi everyone,
So, I've become interested in script modding (not core!) and I find it fantastic (I'm a C# coder so I'm comfortable!), and I've decided I want to try replacing the sleep interaction on beds (specifically, I'm wanting to alter how it picks the outfit to be used). But I've hit a problem and really could do with some insight from those who might know what I'm doing wrong.
I understand (at least I think! Thanks especially to Buzzler's code (you're awesome!)) how interactions are replaced. You simply alter their Singleton to your own definition during Preload (LoadSaveManager.ObjectGroupsPreLoad). But, for the life of me, I can't seem to replace EnterSleeping without totally breaking the bed's sleep interaction!
From what I can tell, Beds have a BedSleep interaction (the actual interaction you click on in the pie menu), and an EnterSleeping interaction which figures out the route and determines what happens before the sim actually gets into the bed. These two interactions are of the type InteractionPart (the name makes sense), but I'm not entirely sure how they work together. I've been looking through the code for literally 3 days straight and cannot see where BedSleep and EnterSleeping call each other - there seems to be absolutely no reference to each other.
Now, the really strange thing... No matter what I seem to do to EnterSleeping, it breaks the sleep routine. The moment I click the interaction on the bed, the sleep interaction gets added to the queue and immediately removed again, so nothing happens.
I'm lost as to what's causing this. I've even tried replacing the EnterSleeping's Singleton with an identical definition (at least, as identical as my decompiler gave me):
private sealed class Definition : InteractionDefinition<Sim, Bed, Sims3.Gameplay.Objects.Beds.EnterSleeping>
{
public override InteractionTestResult Test(ref InteractionInstanceParameters parameters, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
Sim sim = parameters.Actor as Sim;
if ( parameters.EffectivelyAutonomous && sim.SimDescription.IsMummy )
return InteractionTestResult.GenericFail;
else
return base.Test(ref parameters, ref greyedOutTooltipCallback);
}
public override bool Test(Sim a, Bed target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
if ( !target.CanBeUsedAsBed || !isAutonomous && !(a.InteractionQueue.RunningInteraction is BedSleep) || a.Posture.GetType() == typeof(SleepingPosture) )
{
return false;
}
else
{
if ( isAutonomous && !target.CanShareBed(a, CommodityKind.Sleeping) )
{
InteractionInstance headInteraction = a.InteractionQueue.GetHeadInteraction();
if ( headInteraction == null || headInteraction.Autonomous )
return false;
}
if ( Posture.TestForRunningDuplicateInteraction((InteractionDefinition)this, a, (IGameObject)target) || a.InteractionQueue.TransitionInteraction is Sims3.Gameplay.Objects.Beds.EnterSleeping )
return false;
else
return true;
}
}Please take notice of the Sims3.Gameplay.Objects.Beds.EnterSleeping in the InteractionDefinition constructor: the definition is even linking to the original interaction, yet it still doesn't work! (this is just for testing, obviously; when it comes to getting this working, I'd use my own actual interaction). I was beginning to think perhaps there was a problem with the decompiled code—I've even tried about 5 different decompilers, and nothing works—but the fact I'm replacing it with a definition that targets the original interaction (and even disregarding the code entirely by forcing the definition to return true) makes me think there's something else going on here that I'm unaware of. Have I got this idea wrong or something? This is where the interaction is chosen, right? I assume the game instantiates a new interaction, when it's run, from the definition's—uh...—definition (the last parameter!), lol.
I've even tried inheriting the Sims3.Gameplay.Objects.Beds.EnterSleeping interaction itself (I reassembled the DLLs into public and non-sealed form to achieve this in the compiler), but nothing there either.
I'm really lost as to why this just breaks. Am I totally missing something? I'm new to this so that's very likely, but I just can't see it.
I know it's a long shot—perhaps this is just one of those interactions you can't replace with a scripting mod and it needs to be core, for some bizarre reason or another—but I'm hoping perhaps someone can shed some light on it. I've been at it for days (I've almost been losing sleep over this!) and just can't understand why it's refusing to work.
The only actual thing I can do without it breaking is to replace its Singleton with a new instance of its own definition (fat lot of use that does, obviously, lol).
Thanks so much! I'll greatly appreciate any assistance! :)
(and sorry for the long post!)http://www.modthesims.info/static/images/icons/icon11.gif