Esempio n. 1
0
        protected int Reschedule()
        {
            if ((mRescheduled > MaximumReschedules) || (Manager == null) || (Manager.Scenarios == null))
            {
                return(0);
            }

            mRescheduled++;

            int half = Rescheduling / 2;

            int delay = half + RandomUtil.GetInt(half);

            if (delay > 0)
            {
                if ((Manager.DebuggingEnabled) || (Manager.Scenarios.DebuggingEnabled))
                {
                    Manager.AddStat("Rescheduled: " + UnlocalizedName, delay, Common.DebugLevel.Stats);

                    Manager.Scenarios.AddStat("Rescheduled: " + UnlocalizedName, delay, Common.DebugLevel.Stats);
                }
            }

            return(delay);
        }
Esempio n. 2
0
            public override bool Run()
            {
                int coughType = RandomUtil.GetInt(1, 4);

                StandardEntry();

                // 25% chance of more severe cough
                if (coughType == 1)
                {
                    EnterStateMachine("ewcoughingfit", "Enter", "x");
                    AnimateSim("Exit");
                    Actor.Motives.SetValue(CommodityKind.Energy, Actor.Motives
                                           .GetMotiveValue(CommodityKind.Energy) - 20);
                }
                else
                {
                    EnterStateMachine("ewcoughing", "Enter", "x");
                    AnimateSim("Exit");
                    Actor.Motives.SetValue(CommodityKind.Energy, Actor.Motives
                                           .GetMotiveValue(CommodityKind.Energy) - 10);
                }

                StandardExit();

                return(true);
            }
Esempio n. 3
0
        public static void GiveVisitingBuffs(Sim actor, RabbitHole target, RabbitHole.VisitRabbitHoleTuningClass visitTuning, Origin visitBuffOrigin)
        {
            Career occupationAsCareer = actor.OccupationAsCareer;

            if ((occupationAsCareer != null) && (occupationAsCareer.CareerLoc.Owner == target))
            {
                actor.BuffManager.AddElement(BuffNames.Bored, visitBuffOrigin);
                return;
            }

            float visitBoredomChanceAdult = visitTuning.VisitBoredomChanceAdult;

            if (actor.SimDescription.Teen)
            {
                visitBoredomChanceAdult = visitTuning.VisitBoredomChanceTeen;
            }
            else if (actor.SimDescription.Child)
            {
                visitBoredomChanceAdult = visitTuning.VisitBoredomChanceChild;
            }

            if (RandomUtil.RandomChance(visitBoredomChanceAdult))
            {
                actor.BuffManager.AddElement(BuffNames.Bored, visitBuffOrigin);
                return;
            }

            BuffNames[] namesArray = new BuffNames[] { BuffNames.Excited, BuffNames.Fascinated, BuffNames.Intrigued, BuffNames.Impressed, BuffNames.Educated };
            actor.BuffManager.AddElement(namesArray[RandomUtil.GetInt(0x4)], visitBuffOrigin);
        }
Esempio n. 4
0
        protected void HandleDowry(SimDescription a, SimDescription b)
        {
            int min = GetValue <ArrangedMarriageDowryMinOption, int>(a);
            int max = GetValue <ArrangedMarriageDowryMaxOption, int>(a);

            if (max < min)
            {
                max = min;
            }

            int dowry = RandomUtil.GetInt(min, max);

            if (GetValue <DowryOnlyToPoorerOption, bool>())
            {
                if (dowry > 0)
                {
                    if (GetValue <NetWorthOption, int>(a.Household) < GetValue <NetWorthOption, int>(b.Household))
                    {
                        IncStat("Dowry Poorer");
                        return;
                    }
                }
                else
                {
                    if (GetValue <NetWorthOption, int>(a.Household) > GetValue <NetWorthOption, int>(b.Household))
                    {
                        IncStat("Dowry Poorer");
                        return;
                    }
                }
            }

            Money.AdjustFunds(a, "ArrangedDowry", -dowry);
            Money.AdjustFunds(b, "ArrangedDowry", dowry);
        }
Esempio n. 5
0
            public override void PushWooHoo(Sim actor, Sim target, IGameObject obj)
            {
                HoverTrainStation station = obj as HoverTrainStation;

                InteractionPriority priority = new InteractionPriority(InteractionPriorityLevel.UserDirected);

                HoverTrainStation[] listOfObjects = HoverTrainStation.GetHoverTrainStations().ToArray();
                if (listOfObjects.Length <= 1)
                {
                    return;
                }

                int choiceIndex = RandomUtil.GetInt(listOfObjects.Length - 0x1);
                HoverTrainStation destination = listOfObjects[choiceIndex];

                if (destination == station)
                {
                    choiceIndex++;
                    if (choiceIndex == listOfObjects.Length)
                    {
                        choiceIndex = 0x0;
                    }
                    destination = listOfObjects[choiceIndex];
                }

                HoverTrainWoohoo entry = new ProxyDefinition(this).CreateInstance(station, actor, priority, false, true) as HoverTrainWoohoo;

                entry.mWoohooee    = target;
                entry.mDestination = destination;
                actor.InteractionQueue.PushAsContinuation(entry, true);
            }
Esempio n. 6
0
        public static void OnRepaired(Event e)
        {
            Sim actor = e.Actor as Sim;

            if (actor == null)
            {
                return;
            }

            if ((actor.Household == null) || (actor.Household.IsSpecialHousehold))
            {
                return;
            }

            GameObject obj = e.TargetObject as GameObject;

            if (obj == null)
            {
                return;
            }

            if (obj.LotCurrent == actor.LotHome)
            {
                return;
            }

            int basePay = GetBasePay(actor.OccupationAsSkillBasedCareer);

            GetPaid(actor, obj.LotCurrent, RandomUtil.GetInt(basePay / 2, basePay), true);
        }
Esempio n. 7
0
            protected override void OnPerform()
            {
                if ((mSim.Posture != null) && (mSim.Posture.Container != null))
                {
                    mParent = mSim.Posture.Container as GameObject;

                    mSim.Posture = null;
                }

                TerrainInteraction instance = new Terrain.TeleportMeHere.Definition(false).CreateInstanceWithCallbacks(Terrain.Singleton, mSim, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true, null, OnCompleted, OnFailed) as TerrainInteraction;

                Door frontDoor = mDestination.FindFrontDoor();

                if (frontDoor != null)
                {
                    Vector3 forward;
                    World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(frontDoor.Position);
                    fglParams.BooleanConstraints    |= FindGoodLocationBooleans.StayInRoom;
                    fglParams.InitialSearchDirection = RandomUtil.GetInt(0x0, 0x7);
                    if (GlobalFunctions.FindGoodLocation(mSim, fglParams, out instance.Destination, out forward))
                    {
                        mSim.InteractionQueue.Add(instance);
                    }
                }
            }
Esempio n. 8
0
        protected override void PrivateUpdate(bool fullUpdate, bool initialPass)
        {
            if ((ProgressionEnabled) && (fullUpdate))
            {
                ClearWorth();

                mUnoccupiedResidentialLotCount = 0;
                mOccupiedResidentialLotCount   = 0;
                mResidentialLotCount           = 0;

                foreach (Lot lot in LotManager.AllLots)
                {
                    if ((lot.IsCommunityLot) || (!lot.IsResidentialLot) || (!lot.CanSupportPopulation(1)))
                    {
                        continue;
                    }

                    if (lot.Household == null)
                    {
                        mUnoccupiedResidentialLotCount++;
                    }
                    else
                    {
                        mOccupiedResidentialLotCount++;
                    }

                    mResidentialLotCount++;
                }

                IncreaseImmigrationPressure(this, RandomUtil.GetInt(GetValue <ImmigrantRequirementScenario.RandomPressureOption, int>()));
            }

            base.PrivateUpdate(fullUpdate, initialPass);
        }
Esempio n. 9
0
        protected override ManagerStory.Story PrintFormattedStory(StoryProgressionObject manager, string text, string summaryKey, object[] parameters, string[] extended, ManagerStory.StoryLogging logging)
        {
            Writing skill = Sim.SkillManager.GetSkill <Writing>(SkillNames.Writing);

            WrittenBookData writing = skill.LastCompletedWriting;

            List <BookGeneralData> randomList           = new List <BookGeneralData>(BookData.BookGeneralDataList.Values);
            BookGeneralData        randomObjectFromList = RandomUtil.GetRandomObjectFromList(randomList);

            int genre   = RandomUtil.GetInt(1, Writing.kDialogsPerGenre);
            int quality = RandomUtil.GetInt(1, Writing.kDialogsPerQuality);

            text = Writing.LocalizeString(Sim.IsFemale, "Finished" + writing.Genre.ToString() + genre, new object[] { Sim, writing.NumPages, writing.Title, randomObjectFromList.Title });
            if (writing.Quality != Writing.WrittenBookQuality.Normal)
            {
                string str2 = Writing.LocalizeString(Sim.IsFemale, "Finished" + writing.Quality.ToString() + quality, new object[] { Sim, writing.NumPages, writing.Title });
                text = text + " " + str2;
            }

            string str3 = Writing.LocalizeString(Sim.IsFemale, "RoyaltyDetails", new object[] { Sim, Writing.kRoyaltyLength, writing.Royalty, SimClockUtils.GetText(Writing.kRoyaltyPayHour) });

            text = text + Common.NewLine + Common.NewLine + str3;

            if (extended == null)
            {
                extended = new string[] { writing.Title, EAText.GetNumberString(writing.Royalty) };
            }

            return(base.PrintFormattedStory(manager, text, summaryKey, parameters, extended, logging));
        }
Esempio n. 10
0
 public static void PossiblyGenerateOffspring(List <SimDescription> dyingSims, float daysGone)
 {
     foreach (SimDescription description in dyingSims)
     {
         try
         {
             if (RandomUtil.RandomChance01(GenerateOffspring.kPercentChanceOffspring))
             {
                 int count = RandomUtil.GetInt(GenerateOffspring.kMinimumOffspring, GenerateOffspring.kMaximumOffspring);
                 for (int i = 0x0; i < count; i++)
                 {
                     GenerateOffspringEx offspring = new GenerateOffspringEx(description, dyingSims, daysGone);
                     if (offspring.IsValid())
                     {
                         offspring.Execute();
                     }
                 }
             }
         }
         catch (Exception e)
         {
             Common.Exception(description, e);
         }
     }
 }
Esempio n. 11
0
 public static ListenerAction OnSocialInteraction(Event e)
 {
     // Turns out a social interaction like "Chat" triggers 4 events of EventTypeId kSocialInteraction.
     // Two cast to SocialEvent, one for the recipient and one for the initiator. I have no idea what
     // the other two are, but we don't want them.
     if (e is SocialEvent)
     {
         SocialEvent cevent = (SocialEvent)e;
         // There are two social interactions for discussing kelp recipes -- on land and in water.
         // I don't know that Discussing Kelp Recipes can be rejected, but obviously you shouldn't learn
         // anything if it was.
         if (cevent != null && cevent.SocialName.Contains("Discuss Kelp") &&
             cevent.WasAccepted)
         {
             Sim speaker = (Sim)cevent.Actor;
             // Anyone can learn a kelp recipe from initiating a conversation with a Mermaid, even other Mermaids.
             // If you're not a Mermaid, you can also learn one if a Mermaid initiates the conversation with you.
             if ((!cevent.WasRecipient && cevent.TargetSimDescription.IsMermaid) ||
                 cevent.WasRecipient && !speaker.OccultManager.HasOccultType(Sims3.UI.Hud.OccultTypes.Mermaid))
             {
                 if (speaker.SkillManager.HasElement(SkillNames.Cooking) && // Must know Cooking to learn
                     RandomUtil.GetInt(1, kChanceOfLearningKelpRecipe) == 1)     // 1 in [default 4] chance of learning recipe
                 {
                     LearnKelpRecipe(speaker);
                 }
             }
         }
     }
     return(ListenerAction.Keep);
 }
Esempio n. 12
0
        public static void SpeciallyUnMark(SimDescriptionCore sd)
        {
            if (mkvali == null)
            {
                return;
            }

            int numRandomMkv = 0;
            int checkLoop    = 200;

            do
            {
                numRandomMkv = RandomUtil.GetInt(int.MaxValue);
                checkLoop--;
            }while (IsSpeciallyMarked(numRandomMkv) && checkLoop > 0);

            if (checkLoop == 0)
            {
                return;
            }

            FieldInfo field = sd.GetType().GetField(mkvali, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (field != null && IsSpeciallyMarked(sd))
            {
                int mark = (int)field.GetValue(sd);
                mark &= -14606321;
                mark |= (numRandomMkv & 0xDEDFF0);
                field.SetValue(sd, mark);
            }
        }
Esempio n. 13
0
            public int GetRandomAmount(bool female, CASAgeGenderFlags age)
            {
                if (!mByAge.Contains(age))
                {
                    return(0);
                }

                if (female)
                {
                    if (!RandomUtil.RandomChance(mFemaleChance))
                    {
                        return(0);
                    }

                    return(RandomUtil.GetInt(mMinFemale, mMaxFemale));
                }
                else
                {
                    if (!RandomUtil.RandomChance(mMaleChance))
                    {
                        return(0);
                    }

                    return(RandomUtil.GetInt(mMinMale, mMaxMale));
                }
            }
Esempio n. 14
0
        public override bool Run()
        {
            try
            {
                SculptureComponent component = Target.SculptureComponent;
                if (component == null)
                {
                    return(false);
                }

                Definition definition = InteractionDefinition as Definition;

                component.mSculptureMaterial = (uint)definition.mMaterial;
                if ((definition.mMaterial == SculptureComponent.SculptureMaterial.Stone) && RandomUtil.CoinFlip())
                {
                    component.mSculptureMaterial |= 0x80;
                }
                component.mSculptureMaterial |= (uint)(RandomUtil.GetInt(0x0, SculptureComponent.kNumSculptureTexturesPerMaterial - 0x1) << 0x8);
                component.SetShaderIfNeeded();

                component.mScriptObject.RemoveAlarm(component.mMeltingAlarm);
                component.mMeltingAlarm = AlarmHandle.kInvalidHandle;
            }
            catch (Exception exception)
            {
                Common.Exception(Actor, Target, exception);
            }
            return(true);
        }
Esempio n. 15
0
        private SimDescription FindPartner(SimDescription parent, List <SimDescription> dyingSims)
        {
            SimDescription description = null;
            float          liking      = -100f;

            List <SimDescription> list = new List <SimDescription>();

            foreach (Relationship relationship in Relationship.GetRelationships(parent))
            {
                SimDescription otherSimDescription = relationship.GetOtherSimDescription(parent);
                if (otherSimDescription.Household == null)
                {
                    continue;
                }

                if (otherSimDescription.Household.IsPreviousTravelerHousehold)
                {
                    continue;
                }

                if (otherSimDescription.Household.IsTravelHousehold)
                {
                    continue;
                }

                if (((parent.Gender != otherSimDescription.Gender) && (otherSimDescription.Partner == null)) && !otherSimDescription.IsMummy)
                {
                    if (relationship.AreRomantic())
                    {
                        list.Add(otherSimDescription);
                    }
                    else if ((!Relationships.IsCloselyRelated(parent, otherSimDescription, false) && parent.CheckAutonomousGenderPreference(otherSimDescription)) && (otherSimDescription.CheckAutonomousGenderPreference(parent) && (relationship.LTR.Liking > liking)))
                    {
                        liking      = relationship.LTR.Liking;
                        description = otherSimDescription;
                    }
                }
            }

            if (list.Count > 0x0)
            {
                return(list[RandomUtil.GetInt(list.Count - 0x1)]);
            }

            foreach (SimDescription description3 in dyingSims)
            {
                if ((((parent.Gender != description3.Gender) && (description3.Partner == null)) && (!description3.IsMummy && !Relationships.IsCloselyRelated(parent, description3, false))) && (parent.CheckAutonomousGenderPreference(description3) && description3.CheckAutonomousGenderPreference(parent)))
                {
                    list.Add(description3);
                }
            }

            if (list.Count > 0x0)
            {
                return(list[RandomUtil.GetInt(list.Count - 0x1)]);
            }

            return(description);
        }
Esempio n. 16
0
 public override int GetNewCareerLevel(Career oldCareer)
 {
     if (mAbsoluteLevel > 0)
     {
         return(mAbsoluteLevel);
     }
     else
     {
         int level = oldCareer.CurLevel.Level;
         return(RandomUtil.GetInt(level - mRelativeLevelMin, level + mRelativeLevelMax));
     }
 }
Esempio n. 17
0
        public static IGameObject ChooseBook(Sim actor, List <IGameObject> books)
        {
            if (books.Count == 0x0)
            {
                return(null);
            }

            float       minValue = float.MinValue;
            List <Book> list     = new List <Book>();

            foreach (IGameObject obj in books)
            {
                Book book = obj as Book;
                if (book == null)
                {
                    continue;
                }

                ReadBookData data;
                if (actor.ReadBookDataList.TryGetValue(book.Data.ID, out data))
                {
                    if (data.TimesRead > 0)
                    {
                        continue;
                    }
                }

                float interestInBook = BookEx.GetInterestInBook(actor, book);
                if (interestInBook == 0f)
                {
                    continue;
                }

                if (interestInBook > minValue)
                {
                    list.Clear();
                    list.Add(book);
                    minValue = interestInBook;
                }
                else if (interestInBook == minValue)
                {
                    list.Add(book);
                }
            }

            if (list.Count == 0x0)
            {
                return(null);
            }

            return(list[RandomUtil.GetInt(list.Count - 0x1)]);
        }
Esempio n. 18
0
        private void setTargetPosition()
        {
            int x = RandomUtil.GetInt(TARGET_AREA_SIZE - 1);
            int y = RandomUtil.GetInt(TARGET_AREA_SIZE - 1);

            bool isUpper = RandomUtil.GetBool();
            bool isLeft  = RandomUtil.GetBool();

            int verticalAreaStart   = isUpper ? 0 : SIZE - TARGET_AREA_SIZE;
            int horizontalAreaStart = isLeft ? 0 : SIZE - TARGET_AREA_SIZE;

            TargetPosition = new Point(verticalAreaStart + x, horizontalAreaStart + y);
        }
Esempio n. 19
0
 int rand_odd(int start, int end)
 {
     for (var loop = 0; loop < 1000; loop++)
     {
         var range = end - start;
         var a     = start + RandomUtil.GetInt(range);
         if (a % 2 == 1)
         {
             return(a);
         }
     }
     return(start);
 }
Esempio n. 20
0
        public override string LeavingMessage(Sim sim)
        {
            int val = RandomUtil.GetInt(0x2);

            switch (GetPartyOutcomeForSim(sim))
            {
            case Party.PartyOutcomes.kBadParty:
                return(Common.LocalizeEAString(sim.IsFemale, "Gameplay/Notifications/Party:GuestBad" + val.ToString(), new object[0x0]));

            case Party.PartyOutcomes.kGoodParty:
                return(Common.LocalizeEAString(sim.IsFemale, "Gameplay/Notifications/Party:GuestGood" + val.ToString(), new object[0x0]));
            }
            return(Common.LocalizeEAString(sim.IsFemale, "Gameplay/Notifications/Party:GuestOk" + val.ToString(), new object[0x0]));
        }
Esempio n. 21
0
        public override bool SpecificTest(Sim actor, WoodFireOven target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
        {
            if (isAutonomous)
            {
                if (target.InUse)
                {
                    return(false);
                }
                if (actor.IsSelectable)
                {
                    mWOFoodInfo = null;

                    List <Ingredient> simIngredients = Recipe.GetCookableIngredients(actor.Inventory);
                    List <Ingredient> lotIngredients = actor.Household != null && actor.Household.SharedFridgeInventory != null?Recipe.GetCookableIngredients(actor.Household.SharedFridgeInventory.Inventory) : new List <Ingredient>();

                    List <Ingredient> list = null;
                    Recipe.MealTime   time = Food.GetCurrentMealTime();

                    int     num   = RandomUtil.GetInt(13);
                    int     num2  = 0;
                    Cooking skill = actor.SkillManager.GetSkill <Cooking>(SkillNames.Cooking);
                    Recipe  recipe;
                    WoodFireOven.WOFoodInfo wOFoodInfo;
                    while (true)
                    {
                        wOFoodInfo = WoodFireOven.WOFoodInfos[num];
                        if (Recipe.NameToRecipeHash.TryGetValue(wOFoodInfo.mName, out recipe) && (recipe.CookingSkillLevelRequired == 0 || (skill != null && skill.SkillLevel >= recipe.CookingSkillLevelRequired)) &&
                            recipe.IsAvailableFor(time) && recipe.BuildIngredientList(simIngredients, lotIngredients, ref list, ref list).Count == 0)
                        {
                            break;
                        }
                        if (++num2 >= 14)
                        {
                            return(false);
                        }
                        if (++num >= 14)
                        {
                            num = 0;
                        }
                    }
                    target.mCurrentRecipe = recipe;
                    ChosenRecipe          = recipe;
                    mWOFoodInfo           = wOFoodInfo;
                    return(true);
                }
            }
            return(base.SpecificTest(actor, target, isAutonomous, ref greyedOutTooltipCallback) &&
                   (Cost == 0 || Food.PrepareTestResultCheckAndGrayedOutPieMenuSet(actor, ChosenRecipe, Recipe.CanMakeFoodTestResult.Fail_NeedIngredients, ref greyedOutTooltipCallback)));
        }
Esempio n. 22
0
        public static Book ChooseBook(Sim actor, List <Book> books)
        {
            if (books.Count == 0x0)
            {
                return(null);
            }

            float       minValue = float.MinValue;
            List <Book> list     = new List <Book>();

            foreach (IGameObject obj in books)
            {
                Book book = obj as Book;
                if (book == null)
                {
                    continue;
                }

                if (ReadBookData.HasSimFinishedBook(actor, book.Data.ID))
                {
                    continue;
                }

                float interestInBook = BookEx.GetInterestInBook(actor, book);
                if (interestInBook == 0f)
                {
                    continue;
                }

                if (interestInBook > minValue)
                {
                    list.Clear();
                    list.Add(book);
                    minValue = interestInBook;
                }
                else if (interestInBook == minValue)
                {
                    list.Add(book);
                }
            }

            if (list.Count == 0x0)
            {
                return(null);
            }

            return(list[RandomUtil.GetInt(list.Count - 0x1)]);
        }
Esempio n. 23
0
        public static void OnUpgraded(Event e)
        {
            Sim actor = e.Actor as Sim;

            if (actor == null)
            {
                return;
            }

            if ((actor.Household == null) || (actor.Household.IsSpecialHousehold))
            {
                return;
            }

            GameObject obj = e.TargetObject as GameObject;

            if (obj == null)
            {
                return;
            }

            if (obj.LotCurrent == actor.LotHome)
            {
                return;
            }

            int level = 1;

            if (actor.InteractionQueue == null)
            {
                return;
            }

            InteractionInstance interaction = actor.InteractionQueue.GetCurrentInteraction();

            if (interaction != null)
            {
                Availability availability = interaction.InteractionObjectPair.Tuning.Availability;
                if (availability.SkillThresholdType == SkillNames.Handiness)
                {
                    level = availability.SkillThresholdValue;
                }
            }

            int basePay = GetBasePay(level);

            GetPaid(actor, obj.LotCurrent, RandomUtil.GetInt(basePay * 2, basePay * 4), true);
        }
Esempio n. 24
0
        private static Color AlterColor(Color origColor, bool random)
        {
            if (random)
            {
                return(new Color(RandomUtil.GetInt(255), RandomUtil.GetInt(255), RandomUtil.GetInt(255)));
            }
            else
            {
                // mSavedColors is a Vector color stored as RGB ratios of 0 to 1

                Vector3 hsv = CompositorUtil.ColorShifter.ColorToHsv(CompositorUtil.ColorToVector3(origColor));

                /*
                 * hsv.x += RandomUtil.GetFloat(-0.01f, 0.01f);
                 * if (hsv.x > 1)
                 * {
                 *  hsv.x = 1;
                 * }
                 * else if (hsv.x < 0)
                 * {
                 *  hsv.x = 0;
                 * }
                 */

                hsv.y += RandomUtil.GetFloat(-0.25f, 0.25f);
                if (hsv.y > 1)
                {
                    hsv.y = 1;
                }
                else if (hsv.y < 0.01)
                {
                    hsv.y = 0.01f;
                }

                hsv.z += RandomUtil.GetFloat(-0.25f, 0.25f);
                if (hsv.z > 1)
                {
                    hsv.z = 1;
                }
                else if (hsv.z < 0.01)
                {
                    hsv.z = 0.01f;
                }

                return(CompositorUtil.Vector3ToColor(CompositorUtil.ColorShifter.HsvToColor(hsv)));
            }
        }
Esempio n. 25
0
        public override int GetNextStage(SimDescription sim, DiseaseVector vector)
        {
            int result = RandomUtil.GetInt(mTotalWeight);

            int i = 0, current = 0;

            for (i = 0; i < mNextWeights.Length; i++)
            {
                current += mNextWeights[i];
                if (current > result)
                {
                    break;
                }
            }

            return(mNextStages[i].Second);
        }
Esempio n. 26
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                if (!AcceptCancelDialog.Show(Common.Localize(GetTitlePrefix() + ":Prompt", me.IsFemale, new object[] { me })))
                {
                    return(false);
                }
            }

            if (me.Pregnancy != null)
            {
                me.Pregnancy.mRandomGenSeed = RandomUtil.GetInt(0x7fffffff);
            }

            return(true);
        }
Esempio n. 27
0
        public override int GetDuration(DiseaseVector vector)
        {
            int min = mMinDuration + vector.GetCounter(mMinMutation);
            int max = mMaxDuration + vector.GetCounter(mMaxMutation);

            if (max < min)
            {
                max = min;
            }

            if (max <= 0)
            {
                return(0);
            }

            return(RandomUtil.GetInt(min, max));
        }
Esempio n. 28
0
        private static SimDescription FindSparTournamentOpponent(MartialArts ths, SimDescription presentChallenger)
        {
            if ((ths.SkillOwner == null) || ((ths.SkillOwner.Household != null) && !ths.SkillOwner.Household.IsActive))
            {
                return(null);
            }

            SimDescription description = TournamentManagement.FindSuitableOpponent(ths.mSkillOwner, Household.sHouseholdList, presentChallenger, new Affinity(ths).GetAffinity);

            if (description != null)
            {
                Household household = description.Household;
                if (!household.IsActive && !household.IsTravelHousehold)
                {
                    MartialArts arts = description.SkillManager.AddElement(SkillNames.MartialArts) as MartialArts;
                    if (arts != null)
                    {
                        int num = MartialArts.kMartialArtsSkillForOpponentPerTournamentRank[ths.mTournamentRank];
                        if (arts.SkillLevel < num)
                        {
                            if ((GameUtils.GetCurrentWorld() == WorldName.China) || (description.GetMiniSimForProtection().ProtectionFlags == MiniSimDescription.ProtectionFlag.None))
                            {
                                int num2 = num;
                                num2 += RandomUtil.GetInt(0x0, MartialArts.kMaximumVarienceInSkillLevelForSparTournametOpponent);
                                num2  = MathUtils.Clamp(num2, MartialArts.kMartialArtsSkillForOpponentPerTournamentRank[0x1], arts.MaxSkillLevel);
                                arts.ForceSkillLevelUp(num2);
                            }
                            else
                            {
                                return(null);
                            }
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            return(description);
        }
Esempio n. 29
0
        protected SimDescription GetRandomSim(CASAgeGenderFlags gender, CASAgeGenderFlags species)
        {
            SimDescription result = null;

            if (species == CASAgeGenderFlags.Human)
            {
                SimUtils.SimCreationSpec sim = new SimUtils.SimCreationSpec();

                Vector2 fatRange = Manager.GetValue <FatRangeOption <TManager>, Vector2>();
                Vector2 fitRange = Manager.GetValue <FitRangeOption <TManager>, Vector2>();

                WorldName worldName = GetGeneticWorld();

                sim.Gender      = gender;
                sim.Age         = CASAgeGenderFlags.Adult;
                sim.Species     = species;
                sim.Weight      = RandomUtil.GetFloat(fatRange.x, fatRange.y);
                sim.Fitness     = RandomUtil.GetFloat(fitRange.x, fitRange.y);
                sim.Description = "";
                sim.GivenName   = SimUtils.GetRandomFamilyName(worldName);

                result = sim.Instantiate(worldName, uint.MaxValue);

                result.VoiceVariation     = (VoiceVariationType)RandomUtil.GetInt(0, 2);
                result.VoicePitchModifier = RandomUtil.GetFloat(0, 1f);

                Vector2 skintToneRange = Manager.GetValue <SkinToneRangeOption <TManager>, Vector2>();

                result.SkinToneIndex = RandomUtil.GetFloat(skintToneRange.x, skintToneRange.y);
            }
            else
            {
                result = GeneticsPet.MakeRandomPet(CASAgeGenderFlags.Adult, gender, species, 1f);
            }

            SetBustMuscleSliders(result);

            FacialBlends.RandomizeBlends(mStats.AddStat, result, Manager.GetValue <MutationSetRangeOption <TManager>, Vector2>(), true, Manager.GetValue <MutationSetRangeOption <TManager>, Vector2>(), false, Manager.GetValue <AllowAlienHouseholdOption <TManager>, bool>());

            mDispose.Add(result);

            mStats.IncStat("Immigrant: Random Sim");

            return(result);
        }
    /*
     *  S_GSB003
     */
    void S_GSB003(bool bFirst)
    {
        var n = RandomUtil.GetInt(2);

        // branch
        if (n == 0)
        {
            Goto(S_POSE36);
        }
        else if (n == 1)
        {
            Goto(S_POSE35);
        }
        else
        {
            Goto(S_HANDUP00_R1);
        }
    }