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
Instructor
Original Poster
#1 Old 14th Feb 2023 at 6:48 AM Last edited by Twinsimming : 1st Mar 2023 at 1:39 PM.
Default [Solved] Help With Configuring Fatigue Stage
I'm trying to add a fatigue stage to my yoga mat mod, similar to how the treadmill and chip up bar have a "Workout Until Fatigued" option. I set up my code just like how it's set up for existing athletic objects, but the bar doesn't fill like its supposed to. I also set up a skill stage, but that one works like intended, so I'm really not sure where I went wrong with this one. This is what the code looks like right now. Any help is greatly appreciated!

Code:
using Sims3.SimIFace;
using Sims3.Gameplay.Objects.Miscellaneous;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.EventSystem;
using Sims3.Gameplay.Abstracts;
using Sims3.Gameplay.DreamsAndPromises;
using Sims3.Gameplay.ActorSystems;
using Sims3.Gameplay.Utilities;
using Sims3.Gameplay.TuningValues;
using Sims3.Gameplay.Autonomy;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Skills;
using Sims3.Gameplay.Core;
using Sims3.Gameplay.Roles;
using System.Collections.Generic;
using Sims3.SimIFace.CAS;
using Sims3.Gameplay.ObjectComponents;
using Sims3.Gameplay.Services;
using Sims3.Gameplay.CAS;
using Sims3.UI.Hud;

public class YogaMat : GameObject
    {
        [Tunable]
        public static float kMinsToAddFatiguedNovice = 240f;

        [Tunable]
        public static float kMinsToAddFatiguedNormal = 300f;

        [Tunable]
        public static float kMinsToAddFatiguedSkilled = 360f;

        [Tunable]
        public static float kMinsToAddFatiguedExpert = 420f;

        [Tunable]
        public static float kMinsToAddTranquil = 120f;

        [Tunable]
        public static float kMinsToAddFatiguedChild = 180f;

        [TunableComment("Range: 0.0f to 0.1f.  Description: As you use athletic game objects, your Sim has an increase in the Fatigue motive.  As your Sim gains Athletic skill, your Sim will be less fatigued.  This tunable is the fatigue gain percentage decrease per athletic skill level.")]
        public static float kDelayFatiguePercentagePerAthleticSkillLevel = 0.05f;

        [Tunable]
        public static Sims3.Gameplay.Abstracts.AthleticGameObject.Tuning kAthleticTuning = new Sims3.Gameplay.Abstracts.AthleticGameObject.Tuning();

        public Sims3.Gameplay.Abstracts.AthleticGameObject.Tuning AthleticTuning => kAthleticTuning;

        public class PracticeYoga : Interaction<Sim, YogaMat>
        {
            public class Definition : InteractionDefinition<Sim, YogaMat, PracticeYoga>
            {
                public override string GetInteractionName(Sim actor, YogaMat target, InteractionObjectPair interaction)
                {
                    return Localization.LocalizeString("Gameplay/Objects/AlunnTwinsimming/YogaMat:PracticeYoga", new object[0]);
                }
                public override bool Test(Sim actor, YogaMat target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
                {
                    if (!RolePaparazzi.IsSimPaparazzi(actor))
                    {
                        if (actor.BuffManager.HasElement(BuffNames.Fatigued))
                        {
                            greyedOutTooltipCallback = () => Localization.LocalizeString(actor.IsFemale, "Gameplay/Objects/AlunnTwinsimming/YogaMat:CouchPotato", new object[] { actor });
                            return false;
                        }
                        if (!actor.TraitManager.HasElement(TraitNames.CouchPotato) || (float)actor.MoodManager.MoodValue >= TraitTuning.CouchPotatoMoodForWorkOut)
                        {
                            return true;
                        }
                    }
                    return false;
                }
            }
            public static InteractionDefinition Singleton = new Definition();

            public Sim.SwitchOutfitHelper mSwitchOutfitHelper;

            public Athletic mAthleticSkill;

            private static string kSpecialOutfitName = "FirewalkBarefoot";

            public AlarmHandle mStagesAlarm;

            public Stage mFatigueStage;

            public SkillStage mSkillStage;

            public Stage FatigueStage => mFatigueStage;

            public Stage SkillStage => mSkillStage;

            public AthleticGameObject.Tuning AthleticTuning => AthleticTuning;

            public override void ConfigureInteraction()
            {
                if (mAthleticSkill == null)
                {
                    mAthleticSkill = (Actor.SkillManager.AddElement(SkillNames.Athletic) as Athletic);
                }
                if (Actor.SimDescription.TeenOrAbove)
                {
                    mSkillStage = new SkillStage(LocalizeString(Actor.IsFemale, "SkillStage"), SkillNames.Athletic, Actor, 1f, showCompletionTime: true, selectable: true);
                }
                if (!Actor.SimDescription.IsVampire)
                {
                    mFatigueStage = Target.ConfigureFatigueStage(Actor, mAthleticSkill, Target, this);
                }
                Sims3.UI.StyledNotification.Show(new Sims3.UI.StyledNotification.Format("NOTIF 1", StyledNotification.NotificationStyle.kGameMessageNegative));
                base.Stages = new List<Stage>(new Stage[2]
                {
                mFatigueStage,
                mSkillStage
                });
            }
            public float GetFatigueMultiplier()
            {
                float num = 1f;
                if (base.InteractionDefinition is StrengthDefinition)
                {
                    if (mAthleticSkill.IsBodyBuilder())
                    {
                        num = 0f;
                    }
                    else
                    {
                        num = 1f - Target.AthleticTuning.DelayFatiguePercentagePerAthleticSkillLevel * (float)mAthleticSkill.SkillLevel;
                        if (num <= 0f)
                        {
                            num = 0f;
                        }
                    }
                }
                else if (mAthleticSkill.IsFitnessNut())
                {
                    num = 0f;
                }
                else
                {
                    num = 1f - Target.AthleticTuning.DelayFatiguePercentagePerAthleticSkillLevel * (float)mAthleticSkill.SkillLevel;
                    if (num <= 0f)
                    {
                        num = 0f;
                    }
                }
                if (Actor.TraitManager.HasElement(TraitNames.Athletic))
                {
                    num *= TraitTuning.AthleticTraitSimFatigueMultiplier;
                }
                if (Actor.TraitManager.HasElement(TraitNames.LycanthropyHuman))
                {
                    num *= TraitTuning.LycanthropyHumanTraitSimFatigueMultiplier;
                }
                Sims3.UI.StyledNotification.Show(new Sims3.UI.StyledNotification.Format("NOTIF 2", StyledNotification.NotificationStyle.kGameMessageNegative));
                return num;
            }

            public static string LocalizeString(bool isFemale, string name, params object[] parameters)
            {
                return Localization.LocalizeString(isFemale, "Gameplay/Abstracts/AthleticGameObject/WorkOut:" + name, parameters);
            }

            public override void AddExcludedDreams(ICollection<DreamNames> excludedDreams)
            {
                base.AddExcludedDreams(excludedDreams);
                excludedDreams.Add(DreamNames.workout);
                excludedDreams.Add(DreamNames.workout_for_num_hours);
                excludedDreams.Add(DreamNames.workout_for_num_hours_straight);
                excludedDreams.Add(DreamNames.workout_until_fatigued);
            }

            public void AddTranquil()
            {
                int skillLevel = Actor.SkillManager.GetSkillLevel(SkillNames.Athletic);
                if (skillLevel >= 0)
                {
                    Actor.BuffManager.AddElementPaused(BuffNames.Tranquil, Origin.FromExercise);
                }
            }
            public void SetupOutfitSwapIfNeeded()
            {
                if (this.Actor.Service is GrimReaper || !this.IsWearingShoes())
                {
                    return;
                }
                SimDescription simDescription = this.Actor.SimDescription;
                simDescription.RemoveSpecialOutfit(FirewalkPit.Firewalk.kSpecialOutfitName);
                SimBuilder simBuilder = new SimBuilder();
                simBuilder.UseCompression = true;
                OutfitUtils.SetOutfit(simBuilder, this.Actor.CurrentOutfit, simDescription);
                foreach (CASPart part in this.Actor.CurrentOutfit.Parts)
                {
                    if (part.BodyType == BodyTypes.Shoes)
                    {
                        simBuilder.RemovePart(part);
                    }
                }
                string barefootCASPartName = this.GetBarefootCASPartName();
                ResourceKey resourceKey = new ResourceKey(ResourceUtils.HashString64(barefootCASPartName), 0x34AEECBU, ResourceUtils.ProductVersionToGroupId(ProductVersion.BaseGame));
                if (resourceKey != ResourceKey.kInvalidResourceKey)
                {
                    CASPart part2 = new CASPart(resourceKey);
                    simBuilder.AddPart(part2);
                    ResourceKey key = simBuilder.CacheOutfit("FirewalkPitBarefoot" + simDescription.SimDescriptionId);
                    SimOutfit outfit = new SimOutfit(key);
                    int num = simDescription.AddSpecialOutfit(outfit, FirewalkPit.Firewalk.kSpecialOutfitName);
                    if (num != -1)
                    {
                        this.mSwitchOutfitHelper = new Sim.SwitchOutfitHelper(this.Actor, OutfitCategories.Special, num);
                        this.mSwitchOutfitHelper.Start();
                        this.mSwitchOutfitHelper.Wait(true);
                        this.Actor.RefreshCurrentOutfit(false);
                        this.mSwitchOutfitHelper.ChangeOutfit();
                    }
                    return;
                }
            }

            private bool IsWearingShoes()
            {
                CASPart[] parts = Actor.CurrentOutfit.Parts;
                for (int i = 0; i < parts.Length; i++)
                {
                    CASPart cASPart = parts[i];
                    if (cASPart.BodyType == BodyTypes.Shoes)
                    {
                        return !StringUtil.ContainsAny(CASUtils.PartDataGetName(cASPart.Key), "ShoesNude");
                    }
                }
                return false;
            }

            private string GetBarefootCASPartName()
            {
                string text = "";
                SimDescription simDescription = Actor.SimDescription;
                text = (simDescription.YoungAdult ? "a" : OutfitUtils.GetAgePrefix(simDescription.Age));
                text += OutfitUtils.GetGenderPrefix(simDescription.Gender);
                return text + "ShoesNude";
            }

            public override bool Run()
            {
                if (!Actor.RouteToSlot(Target, (Slot)0x31229A4C))
                {
                    Actor.PlayRouteFailure();
                    return false;
                }
                Athletic athleticSkill = base.Actor.SkillManager.AddElement(SkillNames.Athletic) as Athletic;
                if (athleticSkill == null)
                {
                    return false;
                }
                athleticSkill.StartSkillGain(1);
                base.StandardEntry();
                base.EnterStateMachine("YogaMatAnim", "Enter", "x");
                base.Actor.SwitchToOutfitWithSpin(Sim.ClothesChangeReason.GoingToWorkOut, OutfitCategories.Athletic);
                SetupOutfitSwapIfNeeded();
                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));
                float fatigueMultiplier = GetFatigueMultiplier();
                float multiplier = 1f;
                if (Actor.TraitManager.HasElement(TraitNames.Athletic))
                {
                    multiplier = Target.AthleticTuning.AthleticTraitDestressMultiplier;
                    if (Target.AthleticTuning.CanTriggerAthleticTraitTip)
                    {
                        TraitTipsManager.ShowTraitTip(13271263770231521664uL, Actor);
                    }
                }
                BeginCommodityUpdate(CommodityKind.Fun, multiplier);
                BeginCommodityUpdate(CommodityKind.Fatigue, fatigueMultiplier);
                base.BeginCommodityUpdates();
                base.AnimateSim("Loop");
                StartStages();
                AlarmManager.Global.AddAlarm(kMinsToAddTranquil, TimeUnit.Minutes, AddTranquil, "Tranquil", AlarmType.DeleteOnReset, Actor);
                bool GainSkillOnLoop = DoLoop(ExitReason.Default, LoopInfinite, null);
                base.AnimateSim("Exit");
                RemoveBarefootOutfit();
                base.EndCommodityUpdates(true);
                Actor.BuffManager.UnpauseBuff(BuffNames.Tranquil);
                Actor.BuffManager.UnpauseBuff(BuffNames.Fatigued);
                athleticSkill.StopSkillGain();
                base.StandardExit();
                return GainSkillOnLoop;
            }

            public void LoopInfinite(StateMachineClient smc, LoopData loopData)
            { 
                if (Actor.HasExitReason(ExitReason.Default))
                {
                    base.Actor.AddExitReason(ExitReason.Default);
                }
                if (Actor.BuffManager.HasElement(BuffNames.Fatigued))
                {
                    Actor.AddExitReason(ExitReason.Finished);
                }
            }
            private void RemoveBarefootOutfit()
            {
                {
                    if (Actor.IsWearingSpecialOutfit(kSpecialOutfitName))
                    {
                        Actor.SwitchToPreviousOutfitWithoutSpin();
                        Actor.SimDescription.RemoveSpecialOutfit(kSpecialOutfitName);
                    }
                }
            }
            public override void Cleanup()
            {
                if (this.mSwitchOutfitHelper != null)
                {
                    this.mSwitchOutfitHelper.Dispose();
                    this.mSwitchOutfitHelper = null;
                }
                base.Cleanup();
            }
            public void RemoveOutfitCallback(StateMachineClient sender, IEvent evt)
            {
                RemoveBarefootOutfit();
            }
        }
        public virtual Stage ConfigureFatigueStage(Sim actor, Athletic athleticSkill, YogaMat target, InteractionInstance inst)
        {
            if (athleticSkill != null)
            {
                if (inst.InteractionDefinition is StrengthDefinition)
                {
                    if (athleticSkill.IsBodyBuilder())
                    {
                        return null;
                    }
                }
                else if (athleticSkill.IsFitnessNut())
                {
                    return null;
                }
            }
            float num = 1f;
            num = 1f - target.AthleticTuning.DelayFatiguePercentagePerAthleticSkillLevel * (float)athleticSkill.SkillLevel;
            if (num <= 0f)
            {
                num = 0f;
            }
            if (actor.TraitManager.HasElement(TraitNames.Athletic))
            {
                num *= TraitTuning.AthleticTraitSimFatigueMultiplier;
            }
            if (actor.TraitManager.HasElement(TraitNames.LycanthropyHuman))
            {
                num *= TraitTuning.LycanthropyHumanTraitSimFatigueMultiplier;
            }
            float expectedRateOfChange = inst.GetCommodityUpdate(CommodityKind.Fatigue) * num;
            Sims3.UI.StyledNotification.Show(new Sims3.UI.StyledNotification.Format("NOTIF 3", StyledNotification.NotificationStyle.kGameMessageNegative));
            return new BuffStage(GetFatigueStageName(actor.IsFemale), CommodityKind.Fatigue, BuffNames.Fatigued, DeltaStage.Direction.Negative, bHasBuff: true, actor, expectedRateOfChange, showCompletionTime: true, selectable: true);
        }
}
Advertisement
Senior Moderator
staff: senior moderator
#2 Old 25th Feb 2023 at 12:01 PM
It's hard to see what the problem could be but I would check the values related to the fatigue stage. That's if the stage is showing up correctly, but just not updating.
Specifically on line 263
Code:
float fatigueMultiplier = GetFatigueMultiplier();

If you put a notification there with the value to see what it is. Maybe it's 0, and then you'll want to have a closer look at the GetFatigueMultipler() function.

Personally I think it's easier to simple, hardcoded numbers when setting up something like this, as once you understand the parts of the stage and how it works together, you can then use functions to change values based on traits etc. Otherwise it's a bit tricky when something isn't working but there's a lot of calculations that get in the way of figuring out why :p
Instructor
Original Poster
#3 Old 25th Feb 2023 at 10:39 PM
Quote: Originally posted by zoe22
It's hard to see what the problem could be but I would check the values related to the fatigue stage. That's if the stage is showing up correctly, but just not updating.
Specifically on line 263
Code:
float fatigueMultiplier = GetFatigueMultiplier();

If you put a notification there with the value to see what it is. Maybe it's 0, and then you'll want to have a closer look at the GetFatigueMultipler() function.

Personally I think it's easier to simple, hardcoded numbers when setting up something like this, as once you understand the parts of the stage and how it works together, you can then use functions to change values based on traits etc. Otherwise it's a bit tricky when something isn't working but there's a lot of calculations that get in the way of figuring out why :p

I replaced the functions with hardcoded numbers and reshuffled the code a bit, but neither positive or negative numbers fix the stage not updating:

Code:
public class PracticeYoga : Interaction<Sim, YogaMat>
        {
            public class Definition : InteractionDefinition<Sim, YogaMat, PracticeYoga>
            {
                public override string GetInteractionName(Sim actor, YogaMat target, InteractionObjectPair interaction)
                {
                    return Localization.LocalizeString("Gameplay/Objects/AlunnTwinsimming/YogaMat:PracticeYoga", new object[0]);
                }
                public override bool Test(Sim actor, YogaMat target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
                {
                    if (!RolePaparazzi.IsSimPaparazzi(actor))
                    {
                        if (actor.BuffManager.HasElement(BuffNames.Fatigued))
                        {
                            greyedOutTooltipCallback = () => Localization.LocalizeString(actor.IsFemale, "Gameplay/Objects/AlunnTwinsimming/YogaMat:CouchPotato", new object[] { actor });
                            return false;
                        }
                        if (!actor.TraitManager.HasElement(TraitNames.CouchPotato) || (float)actor.MoodManager.MoodValue >= TraitTuning.CouchPotatoMoodForWorkOut)
                        {
                            return true;
                        }
                    }
                    return false;
                }
            }
            public static InteractionDefinition Singleton = new Definition();

            public Sim.SwitchOutfitHelper mSwitchOutfitHelper;

            public Athletic mAthleticSkill;

            private static string kSpecialOutfitName = "FirewalkBarefoot";

            public AlarmHandle mStagesAlarm;

            public DateAndTime mWorkoutStartTime;

            public Stage mFatigueStage;

            public SkillStage mSkillStage;

            public Stage FatigueStage => mFatigueStage;

            public Stage SkillStage => mSkillStage;

            public AthleticGameObject.Tuning AthleticTuning => AthleticTuning;

            public override void ConfigureInteraction()
            {
                if (mAthleticSkill == null)
                {
                    mAthleticSkill = (Actor.SkillManager.AddElement(SkillNames.Athletic) as Athletic);
                }
                if (Actor.SimDescription.TeenOrAbove)
                {
                    mSkillStage = new SkillStage(LocalizeString(Actor.IsFemale, "SkillStage"), SkillNames.Athletic, Actor, 1f, showCompletionTime: true, selectable: true);
                }
                if (!Actor.SimDescription.IsVampire)
                {
                    mFatigueStage = new BuffStage(GetFatigueStageName(Actor.IsFemale), CommodityKind.Fatigue, BuffNames.Fatigued, DeltaStage.Direction.Negative, bHasBuff: true, Actor, -1.5f, showCompletionTime: true, selectable: true);
                }
                Sims3.UI.StyledNotification.Show(new Sims3.UI.StyledNotification.Format("NOTIF 1", StyledNotification.NotificationStyle.kGameMessageNegative));
                base.Stages = new List<Stage>(new Stage[2]
                {
                mFatigueStage,
                mSkillStage
                });
            }
            public float GetFatigueMultiplier()
            {
                float num = 1f - Target.AthleticTuning.DelayFatiguePercentagePerAthleticSkillLevel * mAthleticSkill.SkillLevel;
                if (Actor.TraitManager.HasElement(TraitNames.Athletic))
                {
                    num *= TraitTuning.AthleticTraitSimFatigueMultiplier;
                }
                if (Actor.TraitManager.HasElement(TraitNames.LycanthropyHuman))
                {
                    num *= TraitTuning.LycanthropyHumanTraitSimFatigueMultiplier;
                }
                Sims3.UI.StyledNotification.Show(new Sims3.UI.StyledNotification.Format("NOTIF 2", StyledNotification.NotificationStyle.kGameMessageNegative));
                return num;
            }

            public float ConfigureFatigueStage()
            {
                float num = 1f - AthleticTuning.DelayFatiguePercentagePerAthleticSkillLevel * mAthleticSkill.SkillLevel;
                if (num <= 0f)
                {
                    num = 0f;
                }
                if (Actor.TraitManager.HasElement(TraitNames.Athletic))
                {
                    num *= TraitTuning.AthleticTraitSimFatigueMultiplier;
                }
                if (Actor.TraitManager.HasElement(TraitNames.LycanthropyHuman))
                {
                    num *= TraitTuning.LycanthropyHumanTraitSimFatigueMultiplier;
                }
                float expectedRateOfChange = GetCommodityUpdate(CommodityKind.Fatigue) * num;
                Sims3.UI.StyledNotification.Show(new Sims3.UI.StyledNotification.Format("NOTIF 3", StyledNotification.NotificationStyle.kGameMessageNegative));
                return expectedRateOfChange;
            }

            public static string LocalizeString(bool isFemale, string name, params object[] parameters)
            {
                return Localization.LocalizeString(isFemale, "Gameplay/Abstracts/AthleticGameObject/WorkOut:" + name, parameters);
            }

            public override void AddExcludedDreams(ICollection<DreamNames> excludedDreams)
            {
                base.AddExcludedDreams(excludedDreams);
                excludedDreams.Add(DreamNames.workout);
                excludedDreams.Add(DreamNames.workout_for_num_hours);
                excludedDreams.Add(DreamNames.workout_for_num_hours_straight);
                excludedDreams.Add(DreamNames.workout_until_fatigued);
            }

            public void AddTranquil()
            {
                int skillLevel = Actor.SkillManager.GetSkillLevel(SkillNames.Athletic);
                if (skillLevel >= 0)
                {
                    Actor.BuffManager.AddElementPaused(BuffNames.Tranquil, Origin.FromExercise);
                }
            }
            public void SetupOutfitSwapIfNeeded()
            {
                if (this.Actor.Service is GrimReaper || !this.IsWearingShoes())
                {
                    return;
                }
                SimDescription simDescription = this.Actor.SimDescription;
                simDescription.RemoveSpecialOutfit(FirewalkPit.Firewalk.kSpecialOutfitName);
                SimBuilder simBuilder = new SimBuilder();
                simBuilder.UseCompression = true;
                OutfitUtils.SetOutfit(simBuilder, this.Actor.CurrentOutfit, simDescription);
                foreach (CASPart part in this.Actor.CurrentOutfit.Parts)
                {
                    if (part.BodyType == BodyTypes.Shoes)
                    {
                        simBuilder.RemovePart(part);
                    }
                }
                string barefootCASPartName = this.GetBarefootCASPartName();
                ResourceKey resourceKey = new ResourceKey(ResourceUtils.HashString64(barefootCASPartName), 0x34AEECBU, ResourceUtils.ProductVersionToGroupId(ProductVersion.BaseGame));
                if (resourceKey != ResourceKey.kInvalidResourceKey)
                {
                    CASPart part2 = new CASPart(resourceKey);
                    simBuilder.AddPart(part2);
                    ResourceKey key = simBuilder.CacheOutfit("FirewalkPitBarefoot" + simDescription.SimDescriptionId);
                    SimOutfit outfit = new SimOutfit(key);
                    int num = simDescription.AddSpecialOutfit(outfit, FirewalkPit.Firewalk.kSpecialOutfitName);
                    if (num != -1)
                    {
                        this.mSwitchOutfitHelper = new Sim.SwitchOutfitHelper(this.Actor, OutfitCategories.Special, num);
                        this.mSwitchOutfitHelper.Start();
                        this.mSwitchOutfitHelper.Wait(true);
                        this.Actor.RefreshCurrentOutfit(false);
                        this.mSwitchOutfitHelper.ChangeOutfit();
                    }
                    return;
                }
            }

            private bool IsWearingShoes()
            {
                CASPart[] parts = Actor.CurrentOutfit.Parts;
                for (int i = 0; i < parts.Length; i++)
                {
                    CASPart cASPart = parts[i];
                    if (cASPart.BodyType == BodyTypes.Shoes)
                    {
                        return !StringUtil.ContainsAny(CASUtils.PartDataGetName(cASPart.Key), "ShoesNude");
                    }
                }
                return false;
            }

            private string GetBarefootCASPartName()
            {
                string text = "";
                SimDescription simDescription = Actor.SimDescription;
                text = (simDescription.YoungAdult ? "a" : OutfitUtils.GetAgePrefix(simDescription.Age));
                text += OutfitUtils.GetGenderPrefix(simDescription.Gender);
                return text + "ShoesNude";
            }

            public override bool Run()
            {
                if (!Actor.RouteToSlot(Target, (Slot)0x31229A4C))
                {
                    Actor.PlayRouteFailure();
                    return false;
                }
                Athletic athleticSkill = base.Actor.SkillManager.AddElement(SkillNames.Athletic) as Athletic;
                if (athleticSkill == null)
                {
                    return false;
                }
                athleticSkill.StartSkillGain(1);
                base.StandardEntry();
                base.EnterStateMachine("YogaMatAnim", "Enter", "x");
                base.Actor.SwitchToOutfitWithSpin(Sim.ClothesChangeReason.GoingToWorkOut, OutfitCategories.Athletic);
                SetupOutfitSwapIfNeeded();
                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));
                float fatigueMultiplier = -1.1f;
                float multiplier = 1f;
                if (Actor.TraitManager.HasElement(TraitNames.Athletic))
                {
                    multiplier = Target.AthleticTuning.AthleticTraitDestressMultiplier;
                    if (Target.AthleticTuning.CanTriggerAthleticTraitTip)
                    {
                        TraitTipsManager.ShowTraitTip(13271263770231521664uL, Actor);
                    }
                }
                BeginCommodityUpdate(CommodityKind.Fun, multiplier);
                BeginCommodityUpdate(CommodityKind.Fatigue, fatigueMultiplier);
                base.BeginCommodityUpdates();
                base.AnimateSim("Loop");
                StartStages();
                (mFatigueStage as BuffStage)?.ResetEstimatedRateOfChange(GetCommodityUpdate(CommodityKind.Fatigue), Actor);
                (mSkillStage as SkillStage)?.UpdateTimeOfCompletion(GetCommodityUpdate(CommodityKind.SkillAthletic), Actor);
                mWorkoutStartTime = SimClock.CurrentTime();
                AlarmManager.Global.AddAlarm(kMinsToAddTranquil, TimeUnit.Minutes, AddTranquil, "Tranquil", AlarmType.DeleteOnReset, Actor);
                bool GainSkillOnLoop = DoLoop(ExitReason.Default, LoopInfinite, null);
                base.AnimateSim("Exit");
                RemoveBarefootOutfit();
                base.EndCommodityUpdates(true);
                Actor.BuffManager.UnpauseBuff(BuffNames.Tranquil);
                Actor.BuffManager.UnpauseBuff(BuffNames.Fatigued);
                athleticSkill.StopSkillGain();
                base.StandardExit();
                return GainSkillOnLoop;
            }

            public void LoopInfinite(StateMachineClient smc, LoopData loopData)
            { 
                if (Actor.HasExitReason(ExitReason.Default))
                {
                    base.Actor.AddExitReason(ExitReason.Default);
                }
                if (Actor.BuffManager.HasElement(BuffNames.Fatigued))
                {
                    Actor.AddExitReason(ExitReason.Finished);
                }
            }
            private void RemoveBarefootOutfit()
            {
                {
                    if (Actor.IsWearingSpecialOutfit(kSpecialOutfitName))
                    {
                        Actor.SwitchToPreviousOutfitWithoutSpin();
                        Actor.SimDescription.RemoveSpecialOutfit(kSpecialOutfitName);
                    }
                }
            }
            public override void Cleanup()
            {
                if (this.mSwitchOutfitHelper != null)
                {
                    this.mSwitchOutfitHelper.Dispose();
                    this.mSwitchOutfitHelper = null;
                }
                base.Cleanup();
            }
            public void RemoveOutfitCallback(StateMachineClient sender, IEvent evt)
            {
                RemoveBarefootOutfit();
            }
        }
Instructor
Original Poster
#4 Old 1st Mar 2023 at 1:43 PM
I figured out what the problem was. The code itself is fine, but my ITUN file was not. My fatigue commodity “actual” value was still set to 0 instead of a positive or negative number, making the calculations the code was doing all equal 0 and thus no movement in the progression bar. Case closed!
Back to top