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!
I'm almost done with my yoga mod, but I want to make some of the values in the code tunable. However, despite my best efforts, I can't get the game to recognize the tuning changes. The variables I want to change both govern the length of time it takes for a certain moodlet to be added to the sim using the yoga mat and are implemented through alarms under the Run() section. I have also correctly modified the AssemblyInfo.cs. The code is in the spoiler:
Code:
namespace Sims3.Gameplay.Objects.Alunn
{
public class YogaMat : GameObject
{
public class PracticeYoga : Interaction<Sim, YogaMat>
{
[Tunable]
public static float kMinsToAddFatigued = 240f;
[Tunable]
public static float kMinsToAddTranquil = 120f;
public class Definition : InteractionDefinition<Sim, YogaMat, PracticeYoga>
{
public override string GetInteractionName(Sim actor, YogaMat target, InteractionObjectPair interaction)
{
return "Practice Yoga";
}
public override bool Test(Sim actor, YogaMat target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
if (!RolePaparazzi.IsSimPaparazzi(actor))
{
if (actor.BuffManager.HasElement(BuffNames.Fatigued))
{
greyedOutTooltipCallback = new GreyedOutTooltipCallback(CouchPotatoTraitGreyedTooltip);
return false;
}
if (!actor.TraitManager.HasElement(TraitNames.CouchPotato) || (float)actor.MoodManager.MoodValue >= TraitTuning.CouchPotatoMoodForWorkOut)
{
return true;
}
}
return false;
}
private string CouchPotatoTraitGreyedTooltip()
{
return "You are too tired to keep practicing yoga!";
}
}
public static InteractionDefinition Singleton = new Definition();
public Athletic mAthleticSkill;
public void AddTranquil()
{
int skillLevel = Actor.SkillManager.GetSkillLevel(SkillNames.Athletic);
if (skillLevel >= 0)
{
Actor.BuffManager.AddElementPaused(BuffNames.Tranquil, Origin.FromExercise);
}
}
public void AddFatigued()
{
int skillLevel = Actor.SkillManager.GetSkillLevel(SkillNames.Athletic);
if (skillLevel >= 0)
{
Actor.BuffManager.AddElementPaused(BuffNames.Fatigued, Origin.FromExercise);
}
}
public override bool Run()
{
if (!Actor.RouteToSlot(Target, (Slot)0x31229A4C))
{
Actor.PlayRouteFailure();
return false;
}
// We ask the game to give/initiate the skill on the actor that's currently using the object. Even if they're level 10 or don't know the skill yet, this will be added.
Athletic athleticSkill = base.Actor.SkillManager.AddElement(SkillNames.Athletic) as Athletic;
if (athleticSkill == null)
{
// For good practise on a first run, make sure to add an in-game notification here to debug whether the skill has been loaded or not
return false;
}
// Starts skill gaining. The Skilling bar will appear above the sim's head now.
athleticSkill.StartSkillGain(2);
base.StandardEntry();
base.EnterStateMachine("YogaMatAnim", "Enter", "x");
base.Actor.SwitchToOutfitWithSpin(Sim.ClothesChangeReason.GoingToWorkOut, OutfitCategories.Athletic);
base.SetActor("YogaMat_object", base.Target);
base.Actor.RouteToSlot(this.Target, (Slot)0x31229A4C);
base.EnterState("x", "Enter");
base.SetParameter("skill", (object)Actor.SkillManager.GetSkillLevelParameterForJazzGraph(SkillNames.Athletic));
base.BeginCommodityUpdates();
base.AnimateSim("Loop");
AlarmManager.Global.AddAlarm(kMinsToAddTranquil, TimeUnit.Minutes, AddTranquil, "Tranquil", AlarmType.DeleteOnReset, Actor);
AlarmManager.Global.AddAlarm(kMinsToAddFatigued, TimeUnit.Minutes, AddFatigued, "Fatigued", AlarmType.DeleteOnReset, Actor);
// EA uses the 'Flag' variable for this. But when looping, it's important on each loop to return either 'true' or 'false'. An exit reason can return a false or true
bool GainSkillOnLoop = DoLoop(ExitReason.Default, LoopInfinite, null);
base.AnimateSim("Exit");
base.EndCommodityUpdates(true);
Actor.BuffManager.UnpauseBuff(BuffNames.Tranquil);
Actor.BuffManager.UnpauseBuff(BuffNames.Fatigued);
// Because we're exiting, we're also stopping skillgaining here.
athleticSkill.StopSkillGain();
base.StandardExit();
// This is the only instance in a run() function to return a variable like this. Merely because of the 'DoLoop' function.
return GainSkillOnLoop;
}
And I set up the XML file like this (Instance is Sims3.Gameplay.Objects.Alunn.PracticeYoga):
<?xml version="1.0" encoding="utf-8"?>
<base>
<Current_Tuning>
<kMinsToAddFatigued value="240">
<!--Minutes to add the Fatigued moodlet-->
<kMinsToAddFatigued>
<kMinsToAddTranquil value="30">
<!--Minutes to add the Tranquil moodlet-->
<kMinsToAddTranquil>
</Current_Tuning>
</base>
I'm stumped on where to go from here
Additionally, is there a tutorial on how to make an object interaction autonomous? I'd like for non-playable sims to use the yoga mat on their own.
Note: I made this thread separate from my yoga mod thread because while these questions do relate to that mod, the answers will help me create other mods in the future.
The instance name of your tuning XML should be "Sims3.Gameplay.Objects.Alunn.YogaMat+PracticeYoga" (minus the quotes, of course).
Fully-qualified type names (which the XML instance must follow in order for the game to find and instantiate the tuning variables) follow the format "[Namespace].[OutermostClass]+[NestedClass]+[NestedNestedClass]..."
As far as making interactions autonomous goes, that's done through ITUNs. Basically, you mark the interaction as valid for autonomous use and then set up "advertisements" encouraging Sims to automatically perform the interaction in order to fulfill specific "commodities." Take a look here and here for more info.
"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt
The instance name of your tuning XML should be "Sims3.Gameplay.Objects.Alunn.YogaMat+PracticeYoga" (minus the quotes, of course).
Fully-qualified type names (which the XML instance must follow in order for the game to find and instantiate the tuning variables) follow the format "[Namespace].[OutermostClass]+[NestedClass]+[NestedNestedClass]..."
As far as making interactions autonomous goes, that's done through ITUNs. Basically, you mark the interaction as valid for autonomous use and then set up "advertisements" encouraging Sims to automatically perform the interaction in order to fulfill specific "commodities." Take a look here and here for more info.
Thanks for the breakdown on tuning XML names, that was a huge help. Happy to report my tunings are working now! And thanks for the links on ITUNs as well. I think I've got those set up properly, but I had no idea there were so many different commodity kinds to choose from.
This site is not endorsed by or affiliated with Electronic Arts, or its licensors. Trademarks are the property of their respective owners. Game content and materials copyright Electronic Arts Inc. and its licensors. All Rights Reserved.