Esempio n. 1
0
        protected override bool TargetAllow(SimDescription target)
        {
            if (Target.TeenOrBelow)
            {
                IncStat("Too Young");
                return(false);
            }
            else if (Target.OccultManager == null)
            {
                IncStat("No Manager");
                return(false);
            }
            else if (OccultTypeHelper.CreateList(target, true).Count == 0)
            {
                IncStat("Not Occult");
                return(false);
            }
            else if (!GetValue <AllowPersonalityOccultOption, bool>(target))
            {
                IncStat("Occult Denied");
                return(false);
            }

            return(base.TargetAllow(target));
        }
Esempio n. 2
0
        protected override ManagerStory.Story PrintStory(StoryProgressionObject manager, string name, object[] parameters, string[] extended, ManagerStory.StoryLogging logging)
        {
            List <OccultTypes> occults = OccultTypeHelper.CreateList(Sim);

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

            OccultTypes occult = occults[occults.Count - 1];

            switch (occult)
            {
            case OccultTypes.Vampire:
            case OccultTypes.Werewolf:
            case OccultTypes.Fairy:
            case OccultTypes.Witch:
            case OccultTypes.Genie:
                //case OccultTypes.Mummy:
                name = "Became" + occult;
                break;

            default:
                if (!Manager.DebuggingEnabled)
                {
                    return(null);
                }
                break;
            }

            return(base.PrintStory(manager, name, parameters, extended, logging));
        }
Esempio n. 3
0
        protected static OccultTypes FirstOccult(SimDescription sim)
        {
            List <OccultTypes> types = OccultTypeHelper.CreateList(sim);

            if (types.Count == 0)
            {
                return(OccultTypes.None);
            }

            return(types[0]);
        }
Esempio n. 4
0
        public override bool InRabbitHole()
        {
            try
            {
                SimDescription oldSim = Actor.SimDescription;
                SimDescription newSim = Genetics.MakeDescendant(oldSim, oldSim, CASAgeGenderFlags.Child, oldSim.Gender, 100f, new Random(), false, true, true);
                newSim.WasCasCreated = false;

                /*
                 * if (!Household.ActiveHousehold.CanAddSpeciesToHousehold(Actor.SimDescription.Species))
                 * {
                 *  newSim.Dispose();
                 *  return false;
                 * }
                 */

                oldSim.Household.Add(newSim);
                newSim.FirstName = StringInputDialog.Show(Localization.LocalizeString("Gameplay/Objects/RabbitHoles/ScienceLab:NameCloneTitle", new object[0x0]), Localization.LocalizeString("Gameplay/Objects/RabbitHoles/ScienceLab:NameCloneDesc", new object[0x0]), string.Empty, 256, StringInputDialog.Validation.SimNameText);
                Target.SetupNewClone(oldSim, newSim, "ep4CloneTransitionChild");

                // Custom
                foreach (OccultTypes type in OccultTypeHelper.CreateList(oldSim))
                {
                    OccultTypeHelper.Add(newSim, type, false, false);
                }

                IGameObject voucher = Actor.Inventory.Find <IVoucherCloneMe>();
                if (voucher != null)
                {
                    Actor.Inventory.RemoveByForce(voucher);
                    voucher.Destroy();
                    voucher = null;
                }

                EventTracker.SendEvent(EventTypeId.kNewOffspring, Actor, newSim.CreatedSim);
                EventTracker.SendEvent(EventTypeId.kParentAdded, newSim.CreatedSim, Actor);
                EventTracker.SendEvent(EventTypeId.kChildBornOrAdopted, null, newSim.CreatedSim);
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Esempio n. 5
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (!base.PrivateUpdate(frame))
            {
                return(false);
            }

            if ((!mFail) && (GetValue <AllowRevertOption, bool>()))
            {
                foreach (OccultTypes type in OccultTypeHelper.CreateList(Target, true))
                {
                    OccultTypeHelper.Remove(Target, type, true);
                }
            }

            return(true);
        }
Esempio n. 6
0
            public void OnSwitchWorlds(ICollection <SimDescription> travelers)
            {
                mPerformTravelActions = Traveler.Settings.mPerformTravelActions;

                StoreHouseholds(travelers);

                transitionedSettings.Clear();
                transitionedOccults.Clear();

                if (GameStates.sTravelData.mDestWorld == WorldName.FutureWorld)
                {
                    // need to figure out the issue with ITransition and expand this into a deriative search
                    // but I don't see a big use beyond this
                    transitionedSettings["DisableDescendants"]     = Traveler.Settings.mDisableDescendants;
                    transitionedSettings["ChanceOfOccultMutation"] = Traveler.Settings.mChanceOfOccultMutation;
                    transitionedSettings["ChanceOfOccultHybrid"]   = Traveler.Settings.mChanceOfOccultHybrid;
                    transitionedSettings["MaxOccult"] = Traveler.Settings.mMaxOccult;

                    // can't use the transtioned household because progenitors could be outside of the active household
                    foreach (FutureDescendantService.FutureDescendantHouseholdInfo info in FutureDescendantService.sPersistableData.ActiveDescendantHouseholdsInfo)
                    {
                        if (info.HasAncestorFromHousehold(Household.ActiveHousehold) && info.mProgenitorSimIds.Count > 0)
                        {
                            foreach (ulong num in info.mProgenitorSimIds)
                            {
                                SimDescription sim = SimDescription.Find(num);
                                if (sim != null)
                                {
                                    if (sim.OccultManager != null)
                                    {
                                        if (sim.OccultManager.HasAnyOccultType() && !transitionedOccults.ContainsKey(num))
                                        {
                                            transitionedOccults.Add(num, new List <OccultTypes>());
                                            transitionedOccults[num].AddRange(OccultTypeHelper.CreateList(sim.OccultManager.CurrentOccultTypes, true));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
Esempio n. 7
0
        public static string GetStatus(SimDescription sim)
        {
            string str = sim.FullName;

            bool serviceOrRole = false;

            if (sim.AssignedRole != null)
            {
                serviceOrRole = true;
                ShoppingRegister register = sim.AssignedRole.RoleGivingObject as ShoppingRegister;
                if (register != null)
                {
                    str += ", " + register.RegisterRoleName(sim.IsFemale);
                }
                else
                {
                    string roleName;
                    if (Localization.GetLocalizedString(sim.AssignedRole.CareerTitleKey, out roleName))
                    {
                        str += ", " + roleName;
                    }
                }

                string hours = GetRoleHours(sim);
                if (!string.IsNullOrEmpty(hours))
                {
                    str += Common.NewLine + hours;
                }
            }
            else if (SimTypes.InServicePool(sim))
            {
                serviceOrRole = true;

                string serviceName;
                if (Localization.GetLocalizedString("Ui/Caption/Services/Service:" + sim.CreatedByService.ServiceType.ToString(), out serviceName))
                {
                    str += ", " + serviceName;
                }
            }

            if ((serviceOrRole) || (Tagger.Settings.mTagDataSettings[TagDataType.Orientation] && Tagger.Settings.mTagDataSettings[TagDataType.LifeStage] && (Tagger.Settings.mTagDataSettings[TagDataType.AgeInDays] || (Tagger.Settings.mTagDataSettings[TagDataType.DaysTillNextStage] && sim.AgingEnabled))))
            {
                str += Common.NewLine;
            }
            else
            {
                str += " - ";
            }

            if (sim.TeenOrAbove && !sim.IsPet && Tagger.Settings.mTagDataSettings[TagDataType.Orientation])
            {
                str += Common.Localize("SimType:" + TagDataHelper.GetOrientation(sim).ToString());
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.LifeStage])
            {
                if (Tagger.Settings.mTagDataSettings[TagDataType.Orientation])
                {
                    str += " ";
                }

                str += sim.AgeLocalizedText;
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.AgeInDays] || Tagger.Settings.mTagDataSettings[TagDataType.DaysTillNextStage])
            {
                str += " (";
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.AgeInDays])
            {
                str += Common.Localize("TagData:Age", sim.IsFemale, new object[] { Math.Round(Aging.GetCurrentAgeInDays(sim as IMiniSimDescription)) });
            }

            if (sim.AgingEnabled)
            {
                if (Tagger.Settings.mTagDataSettings[TagDataType.DaysTillNextStage])
                {
                    str += ", " + Common.Localize("TagData:Birthday", sim.IsFemale, new object[] { (int)(AgingManager.Singleton.AgingYearsToSimDays(AgingManager.GetMaximumAgingStageLength(sim)) - AgingManager.Singleton.AgingYearsToSimDays(sim.AgingYearsSinceLastAgeTransition)) });
                }
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.AgeInDays] || Tagger.Settings.mTagDataSettings[TagDataType.DaysTillNextStage])
            {
                str += ")";
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.Occult] && sim.OccultManager != null)
            {
                List <OccultTypes> types = OccultTypeHelper.CreateList(sim, false);

                if (types.Count > 0)
                {
                    str += Common.NewLine;

                    string occultString = "";
                    foreach (OccultTypes type in types)
                    {
                        occultString += ", " + OccultTypeHelper.GetLocalizedName(type);
                    }

                    str += Common.Localize("TagData:OccultTag", sim.IsFemale, new object[] { occultString.Remove(0, 2) });
                }
            }

            Sim createdSim = sim.CreatedSim;

            if (Tagger.Settings.Debugging)
            {
                if (createdSim != null)
                {
                    str += Common.NewLine + "Autonomy: ";
                    if (createdSim.Autonomy == null)
                    {
                        str += "None";
                    }
                    else
                    {
                        if (createdSim.Autonomy.AutonomyDisabled)
                        {
                            str += "Disabled";
                        }
                        else if (!AutonomyRestrictions.IsAnyAutonomyEnabled(createdSim))
                        {
                            str += "User Disabled";
                        }
                        else if (createdSim.Autonomy.IsRunningHighLODSimulation)
                        {
                            str += "High";
                        }
                        else
                        {
                            str += "Low";
                        }

                        if (createdSim.Autonomy.ShouldRunLocalAutonomy)
                        {
                            str += " Local";
                        }

                        if (createdSim.CanRunAutonomyImmediately())
                        {
                            str += " Ready";
                        }
                        else if (!createdSim.mLastInteractionWasAutonomous)
                        {
                            str += " Push";
                        }
                        else if (!createdSim.mLastInteractionSucceeded)
                        {
                            str += " Fail";
                        }

                        if (createdSim.Autonomy.InAutonomyManagerQueue)
                        {
                            str += " Queued";
                        }
                    }
                }
            }

            if (createdSim != null)
            {
                if (Tagger.Settings.mTagDataSettings[TagDataType.Mood])
                {
                    str += Common.NewLine;
                    int flavour = (int)createdSim.MoodManager.MoodFlavor;

                    str += Common.Localize("TagData:MoodTag", sim.IsFemale, new object[] { Common.LocalizeEAString(false, "Ui/Tooltip/HUD/SimDisplay:MoodFlavor" + flavour.ToString()) }) + " ";
                }

                if (Tagger.Settings.mTagDataSettings[TagDataType.MotiveInfo])
                {
                    if (!Tagger.Settings.mTagDataSettings[TagDataType.Mood])
                    {
                        str += Common.NewLine;
                    }

                    string motives = ", ";
                    int    num     = 0;
                    foreach (CommodityKind kind in (Sims3.UI.Responder.Instance.HudModel as HudModel).GetMotives(sim.CreatedSim))
                    {
                        if (sim.CreatedSim.Motives.HasMotive(kind))
                        {
                            if (num >= 6)
                            {
                                break;
                            }

                            motives += FetchMotiveLocalization(sim.Species, kind) + ": " + "(" + sim.CreatedSim.Motives.GetValue(kind).ToString("0.") + ") ";
                        }

                        num++;
                    }

                    str += Common.Localize("TagData:Motives", sim.IsFemale, new object[] { motives.Remove(0, 2) });
                }

                if (Tagger.Settings.mTagDataSettings[TagDataType.CurrentInteraction] && createdSim.CurrentInteraction != null)
                {
                    str += Common.NewLine;

                    try
                    {
                        str += createdSim.CurrentInteraction.ToString();
                    }
                    catch (Exception e)
                    {
                        Common.DebugException(createdSim, e);

                        str += createdSim.CurrentInteraction.GetType();
                    }

                    Tone tone = createdSim.CurrentInteraction.CurrentTone;
                    if (tone != null)
                    {
                        str += Common.NewLine + tone.ToString();
                    }

                    SocialInteractionBase social = createdSim.CurrentInteraction as SocialInteractionBase;
                    if ((social != null) && (social.Target != null))
                    {
                        str += " " + Common.Localize("TagData:With", sim.IsFemale, new object[] { social.Target.Name });
                    }

                    if (createdSim.CurrentInteraction is Terrain.GoHereWith)
                    {
                        InviteToLotSituation situtation = InviteToLotSituation.FindInviteToLotSituationInvolving(createdSim);
                        if (situtation != null)
                        {
                            if (situtation.SimA != createdSim)
                            {
                                str += " " + situtation.SimA.Name;
                            }
                            else if (situtation.SimB != createdSim)
                            {
                                str += situtation.SimB.Name;
                            }
                        }
                    }
                }
            }

            if (!SimTypes.IsSpecial(sim))
            {
                str += Common.NewLine + Common.Localize("TagData:CashTag", sim.IsFemale, new object[] { sim.FamilyFunds });

                if ((Tagger.Settings.mTagDataSettings[TagDataType.Debt] || Tagger.Settings.mTagDataSettings[TagDataType.NetWorth]) && sGetDebtAndNetworth.Valid)
                {
                    int bit = 0;
                    if (Tagger.Settings.mTagDataSettings[TagDataType.Debt])
                    {
                        bit = bit + 1;
                    }
                    if (Tagger.Settings.mTagDataSettings[TagDataType.NetWorth])
                    {
                        bit = bit + 4;
                    }

                    str += sGetDebtAndNetworth.Invoke <string>(new object[] { sim, bit });
                }

                if (Tagger.Settings.mTagDataSettings[TagDataType.Job])
                {
                    if (sim.Occupation != null)
                    {
                        str += Common.NewLine;
                        if (sim.Occupation.OfficeLocation != null)
                        {
                            str += Common.Localize("TagData:JobAt", sim.IsFemale, new object[] { sim.Occupation.CurLevelJobTitle, sim.Occupation.OfficeLocation.GetLocalizedName() });
                        }
                        else
                        {
                            str += Common.Localize("TagData:JobTag", sim.IsFemale, new object[] { sim.Occupation.CurLevelJobTitle });
                        }
                    }
                }

                if (Tagger.Settings.mTagDataSettings[TagDataType.PartnerInfo])
                {
                    if (sim.Partner != null)
                    {
                        Relationship rel    = sim.GetRelationship(sim.Partner, false);
                        string       status = "Happily";
                        if (rel != null)
                        {
                            if (rel.CurrentLTRLiking < -15)
                            {
                                status = "Unhappily";
                            }
                        }

                        str += Common.NewLine;

                        if (sim.IsMarried)
                        {
                            str += Common.Localize("TagData:Spouse", sim.IsFemale, new object[] { Common.Localize("TagData:" + status), sim.Partner });
                        }
                        else
                        {
                            str += Common.Localize("TagData:Partner", sim.IsFemale, new object[] { sim.Partner });
                        }
                    }
                }
            }

            if (sim.IsPregnant && Tagger.Settings.mTagDataSettings[TagDataType.PregnancyInfo])
            {
                IMiniSimDescription father = SimDescription.Find(sim.Pregnancy.DadDescriptionId);
                if (father == null)
                {
                    father = MiniSimDescription.Find(sim.Pregnancy.DadDescriptionId);
                }

                str += Common.NewLine;

                if (father != null)
                {
                    if (sim.Partner != null && father != sim.Partner && !sim.IsPet)
                    {
                        string uhoh = Common.Localize("TagData:Uhoh");
                        str += Common.Localize("TagData:Pregnancy", sim.IsFemale, new object[] { father, uhoh });
                    }
                    else
                    {
                        str += Common.Localize("TagData:Pregnancy", sim.IsFemale, new object[] { father });
                    }
                }
                else
                {
                    str += Common.Localize("TagData:PregnancyUnknown", sim.IsFemale);
                }
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.PersonalityInfo] && sGetClanInfo.Valid)
            {
                List <string> info = sGetClanInfo.Invoke <List <string> >(new object [] { sim });
                foreach (string personality in info)
                {
                    str += Common.NewLine + personality;
                }
            }

            return(str);
        }
Esempio n. 8
0
        public static void CalculateAttractionScore(Relationship ths, bool displayNotice)
        {
            if (ths == null)
            {
                return;
            }

            ths.AttractionScore = 0;

            //if (ths.AttractionScore == float.PositiveInfinity)
            {
                SimDescription simA = ths.SimDescriptionA;
                SimDescription simB = ths.SimDescriptionB;
                if ((simA != null) && (simB != null) && (simA.IsHuman) && (simB.IsHuman))
                {
                    string reason;
                    GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                    if (CommonSocials.CanGetRomantic(simA, simB, true, false, true, ref greyedOutTooltipCallback, out reason))
                    {
                        float score = RandomUtil.GetFloat(Relationship.kBaseRandomAttraction[0x0], Relationship.kBaseRandomAttraction[0x1]);

                        score += Woohooer.Settings.mAttractionBaseChanceScoringV3[PersistedSettings.GetSpeciesIndex(simA)];

                        float origScore = score;
                        float highScore = 0f;
                        float newScore  = 0f;

                        switch (ths.LTR.CurrentLTR)
                        {
                        case LongTermRelationshipTypes.Spouse:
                        case LongTermRelationshipTypes.Fiancee:
                            if (score > 0)
                            {
                                score *= 2;
                            }
                            else
                            {
                                score = 0;
                            }
                            break;
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        Relationship.AttractionType attractionType = Relationship.AttractionType.None;
                        foreach (Trait traitA in simA.TraitManager.List)
                        {
                            if (traitA.IsReward)
                            {
                                continue;
                            }

                            foreach (Trait traitB in simB.TraitManager.List)
                            {
                                if (traitB.IsReward)
                                {
                                    continue;
                                }

                                if (traitA.TraitGuid == traitB.TraitGuid)
                                {
                                    score += Relationship.kTraitModifier;
                                }
                                else if (TraitManager.DoTraitsConflict(traitA.Guid, traitB.Guid))
                                {
                                    score -= Relationship.kTraitModifier;
                                }
                            }
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Trait, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Trait;
                        }

                        Occupation occupation = simA.Occupation;
                        if (occupation != null)
                        {
                            score += occupation.CareerLevel * Relationship.kCareerBonusPerLevel;
                        }

                        Occupation occupation2 = simB.Occupation;
                        if (occupation2 != null)
                        {
                            score += occupation2.CareerLevel * Relationship.kCareerBonusPerLevel;
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Career, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Career;
                        }

                        foreach (Skill skill in simA.SkillManager.List)
                        {
                            score += skill.SkillLevel * Relationship.kSkillBonusPerLevel;
                        }

                        foreach (Skill skill2 in simB.SkillManager.List)
                        {
                            score += skill2.SkillLevel * Relationship.kSkillBonusPerLevel;
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Skill, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Skill;
                        }

                        List <OccultTypes> listA = OccultTypeHelper.CreateList(simA);
                        List <OccultTypes> listB = OccultTypeHelper.CreateList(simB);

                        foreach (OccultTypes typeA in listA)
                        {
                            if (listB.Contains(typeA))
                            {
                                score += Relationship.kBonusForMatchingOccult;
                            }
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Occult, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Occult;
                        }

                        CelebrityManager celebrityManagerA = simA.CelebrityManager;
                        if (celebrityManagerA != null)
                        {
                            score += celebrityManagerA.Level * Relationship.kCelebrityBonusPerLevel;
                        }

                        CelebrityManager celebrityManagerB = simB.CelebrityManager;
                        if (celebrityManagerB != null)
                        {
                            score += celebrityManagerB.Level * Relationship.kCelebrityBonusPerLevel;
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Celebrity, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Celebrity;
                        }

                        if (simA.Zodiac == simB.Zodiac)
                        {
                            score += Relationship.kMatchingSignsBonus;
                        }

                        if (simA.FavoriteColor == simB.FavoriteColor)
                        {
                            score += Relationship.kMatchingSignsBonus / 2;
                        }

                        if (simA.FavoriteFood == simB.FavoriteFood)
                        {
                            score += Relationship.kMatchingSignsBonus / 2;
                        }

                        if (simA.FavoriteMusic == simB.FavoriteMusic)
                        {
                            score += Relationship.kMatchingSignsBonus / 2;
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Astro, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Astro;
                        }

                        int familyFundsA = 0;

                        Household house = simA.Household;
                        if (house != null)
                        {
                            familyFundsA = house.FamilyFunds;
                        }

                        if (familyFundsA >= Relationship.kAttractedMoneyAmounts[0x2])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x2];
                        }
                        else if (familyFundsA >= Relationship.kAttractedMoneyAmounts[0x1])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x1];
                        }
                        else if (familyFundsA >= Relationship.kAttractedMoneyAmounts[0x0])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x0];
                        }

                        int familyFundsB = 0;

                        house = simB.Household;
                        if (house != null)
                        {
                            familyFundsB = house.FamilyFunds;
                        }
                        if (familyFundsB >= Relationship.kAttractedMoneyAmounts[0x2])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x2];
                        }
                        else if (familyFundsB >= Relationship.kAttractedMoneyAmounts[0x1])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x1];
                        }
                        else if (familyFundsB >= Relationship.kAttractedMoneyAmounts[0x0])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x0];
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Money, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Money;
                        }

                        foreach (TraitNames trait in sAttractionTraits)
                        {
                            if (simA.HasTrait(trait))
                            {
                                score += Relationship.kAttractionLifetimeRewardBonus;
                            }

                            if (simB.HasTrait(trait))
                            {
                                score += Relationship.kAttractionLifetimeRewardBonus;
                            }
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Attractive, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Attractive;
                        }

                        BuffManager buffManagerA = null;
                        if (simA.CreatedSim != null)
                        {
                            buffManagerA = simA.CreatedSim.BuffManager;
                        }

                        BuffManager buffManagerB = null;
                        if (simB.CreatedSim != null)
                        {
                            buffManagerB = simB.CreatedSim.BuffManager;
                        }

                        foreach (BuffNames posBuff in Relationship.kPositiveBuffList)
                        {
                            if ((buffManagerA != null) && (buffManagerA.HasElement(posBuff)))
                            {
                                score += Relationship.kPerBuffModifier;
                            }
                            if ((buffManagerB != null) && (buffManagerB.HasElement(posBuff)))
                            {
                                score += Relationship.kPerBuffModifier;
                            }
                        }

                        foreach (BuffNames negBuff in Relationship.kNegativeBuffList)
                        {
                            if ((buffManagerA != null) && (buffManagerA.HasElement(negBuff)))
                            {
                                score -= Relationship.kPerBuffModifier;
                            }
                            if ((buffManagerB != null) && (buffManagerB.HasElement(negBuff)))
                            {
                                score -= Relationship.kPerBuffModifier;
                            }
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Buffs, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Buffs;
                        }

                        score += simA.Fitness * 25;
                        score += simB.Fitness * 25;

                        if (simA.Weight < 0)
                        {
                            score += 25 - simA.Weight * -25;
                        }
                        else
                        {
                            score += 25 - simA.Weight * 25;
                        }

                        if (simB.Weight < 0)
                        {
                            score += 25 - simB.Weight * -25;
                        }
                        else
                        {
                            score += 25 - simB.Weight * 25;
                        }

                        int ageA = 0;
                        switch (simA.Age)
                        {
                        case CASAgeGenderFlags.Teen:
                            ageA = 1;
                            break;

                        case CASAgeGenderFlags.YoungAdult:
                            ageA = 2;
                            break;

                        case CASAgeGenderFlags.Adult:
                            ageA = 3;
                            break;

                        case CASAgeGenderFlags.Elder:
                            ageA = 4;
                            break;
                        }

                        int ageB = 0;
                        switch (simB.Age)
                        {
                        case CASAgeGenderFlags.Teen:
                            ageB = 1;
                            break;

                        case CASAgeGenderFlags.YoungAdult:
                            ageB = 2;
                            break;

                        case CASAgeGenderFlags.Adult:
                            ageB = 3;
                            break;

                        case CASAgeGenderFlags.Elder:
                            ageB = 4;
                            break;
                        }

                        score -= Math.Abs(ageA - ageB) * 25;

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Physical, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Physical;
                        }

                        ths.AttractionScore = score;

                        if (Common.kDebugging)
                        {
                            Common.DebugNotify(simA.FullName + Common.NewLine + simB.FullName + Common.NewLine + "Attraction: " + score + Common.NewLine + attractionType);
                        }

                        if ((ths.AreAttracted) && ((SimTypes.IsSelectable(simA)) || (SimTypes.IsSelectable(simB))))
                        {
                            if (AttractionHelper.TestEnableAttractionNPCController(ths))
                            {
                                if (ths.AttractionNPCController == null)
                                {
                                    ths.AttractionNPCController = new AttractionNPCBehaviorController(ths);
                                }
                            }
                            else
                            {
                                if (ths.AttractionNPCController != null)
                                {
                                    ths.AttractionNPCController.Dispose();
                                }
                            }

                            switch (ths.LTR.CurrentLTR)
                            {
                            case LongTermRelationshipTypes.Spouse:
                            case LongTermRelationshipTypes.Fiancee:
                            case LongTermRelationshipTypes.Ex:
                            case LongTermRelationshipTypes.ExSpouse:
                            case LongTermRelationshipTypes.Partner:
                            case LongTermRelationshipTypes.RomanticInterest:
                                break;

                            default:
                                if (displayNotice)
                                {
                                    Sim createdSimA = simA.CreatedSim;
                                    Sim createdSimB = simB.CreatedSim;
                                    if ((createdSimA != null) && (createdSimB != null))
                                    {
                                        if ((createdSimA.LotCurrent == createdSimB.LotCurrent) && (createdSimA.RoomId == createdSimB.RoomId))
                                        {
                                            VisualEffect effect = VisualEffect.Create("ep8AttractionSystem");
                                            createdSimB.ParentHeadlineFx(effect);
                                            effect.SubmitOneShotEffect(VisualEffect.TransitionType.SoftTransition);

                                            VisualEffect effect2 = VisualEffect.Create("ep8AttractionSystem");
                                            createdSimA.ParentHeadlineFx(effect2);
                                            effect2.SubmitOneShotEffect(VisualEffect.TransitionType.SoftTransition);

                                            ThoughtBalloonManager.BalloonData bd = new ThoughtBalloonManager.BalloonData(createdSimA.GetThumbnailKey());
                                            bd.BalloonType = ThoughtBalloonTypes.kSpeechBalloon;
                                            createdSimB.ThoughtBalloonManager.ShowBalloon(bd);

                                            ThoughtBalloonManager.BalloonData data2 = new ThoughtBalloonManager.BalloonData(createdSimB.GetThumbnailKey());
                                            data2.BalloonType = ThoughtBalloonTypes.kSpeechBalloon;
                                            createdSimA.ThoughtBalloonManager.ShowBalloon(data2);

                                            TNSNames reasonTNS = ths.GetReasonTNS(attractionType);
                                            if (reasonTNS != TNSNames.None)
                                            {
                                                Sim target = createdSimB.IsSelectable ? createdSimB : createdSimA;
                                                Sim actor  = (createdSimB == target) ? createdSimA : createdSimB;
                                                target.ShowTNSIfSelectable(reasonTNS, actor, target, new object[] { actor, target });
                                            }

                                            EventTracker.SendEvent(EventTypeId.kMeetAttractiveSim, createdSimB);
                                            EventTracker.SendEvent(EventTypeId.kMeetAttractiveSim, createdSimA);
                                            Audio.StartObjectSound(createdSimB.IsSelectable ? createdSimB.ObjectId : createdSimA.ObjectId, "sting_attraction", false);
                                        }
                                    }
                                }
                                break;
                            }
                        }
                        else if (ths.AttractionNPCController != null)
                        {
                            ths.AttractionNPCController.Dispose();
                        }
                    }
                    else
                    {
                        if (greyedOutTooltipCallback != null)
                        {
                            Common.DebugNotify(simA.FullName + Common.NewLine + simB.FullName + Common.NewLine + greyedOutTooltipCallback());
                        }
                    }
                }
            }

            if (ths.AttractionNPCController != null)
            {
                ths.AttractionNPCController.Dispose();
            }
        }
Esempio n. 9
0
        protected override bool Push()
        {
            List <OccultTypes> occults = OccultTypeHelper.CreateList(Sim);

            if (occults.Count == 0)
            {
                return(false);
            }

            OccultTypes occult = RandomUtil.GetRandomObjectFromList(occults);

            List <CommercialLotSubType> types = new List <CommercialLotSubType>();

            switch (occult)
            {
            case OccultTypes.Vampire:
                types.Add(CommercialLotSubType.kEP3_CocktailLoungeVampire);
                types.Add(CommercialLotSubType.kGraveyard);
                types.Add(CommercialLotSubType.kEP7_Mausoleum);
                break;

            case OccultTypes.Werewolf:
                types.Add(CommercialLotSubType.kEP7_WerewolfBar);
                types.Add(CommercialLotSubType.kBigPark);
                types.Add(CommercialLotSubType.kSmallPark);
                break;

            case OccultTypes.Witch:
                types.Add(CommercialLotSubType.kEP7_PotionShopConsignmentStore);
                types.Add(CommercialLotSubType.kEP7_VaultOfAntiquity);
                break;

            case OccultTypes.Fairy:
                types.Add(CommercialLotSubType.kEP7_Arboretum);
                types.Add(CommercialLotSubType.kBigPark);
                types.Add(CommercialLotSubType.kSmallPark);
                break;

            case OccultTypes.Mummy:
                types.Add(CommercialLotSubType.kEP1_ChineseGarden);
                types.Add(CommercialLotSubType.kEP1_LandmarkTomb);
                types.Add(CommercialLotSubType.kEP1_HiddenTomb);
                break;

            case OccultTypes.ImaginaryFriend:
                types.Add(CommercialLotSubType.kHangout);
                types.Add(CommercialLotSubType.kBigPark);
                types.Add(CommercialLotSubType.kSmallPark);
                break;
            }

            if (types.Count == 0)
            {
                return(false);
            }

            Lot lot = Lots.GetCommunityLot(Sim.CreatedSim, types, false);

            if (lot == null)
            {
                return(false);
            }

            return(Situations.PushVisit(this, Sim, lot));
        }
Esempio n. 10
0
        public static bool ApplyOccultChance(SimDescription sim, List <OccultTypes> validTypes, int chanceOfOccult, int chanceOfMutation, int maximumOccultPerSim)
        {
            if (sim == null)
            {
                return(false);
            }

            if (FutureDescendantServiceEx.OccultProcessed.Contains(sim.SimDescriptionId))
            {
                return(false);
            }

            List <OccultTypes> possibleOccults = OccultTypeHelper.CreateListOfAllOccults(true);

            int occultsAdded = -1;

            if (OccultTypeHelper.CreateList(sim).Count > 0) // this handles the possible occult added by EA when the Sim was generated
            {
                occultsAdded = 0;
            }

            foreach (OccultTypes type in validTypes)
            {
                if (occultsAdded >= maximumOccultPerSim)
                {
                    break;
                }

                if (!RandomUtil.RandomChance(chanceOfOccult))
                {
                    continue;
                }

                if (RandomUtil.RandomChance(chanceOfMutation) && possibleOccults.Count > 0)
                {
                    while (possibleOccults.Count > 0)
                    {
                        OccultTypes mutationType = RandomUtil.GetRandomObjectFromList <OccultTypes>(possibleOccults);

                        if (OccultTypeHelper.Add(sim, mutationType, false, false))
                        {
                            possibleOccults.Remove(mutationType);
                            occultsAdded++;
                            break;
                        }

                        possibleOccults.Remove(mutationType);
                    }
                }

                if (OccultTypeHelper.Add(sim, type, false, false))
                {
                    occultsAdded++;
                }
            }

            OccultTypeHelper.ValidateOccult(sim, null);
            FutureDescendantServiceEx.OccultProcessed.Add(sim.SimDescriptionId);

            if (occultsAdded > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 11
0
        public static SimDescription MakeAlienBaby(SimDescription alien, SimDescription abductee, CASAgeGenderFlags gender, float averageMood, Random pregoRandom, bool interactive)
        {
            SimBuilder sb = new SimBuilder();

            sb.Age            = CASAgeGenderFlags.Baby;
            sb.Gender         = gender;
            sb.Species        = CASAgeGenderFlags.Human;
            sb.SkinTone       = alien.SkinToneKey;
            sb.SkinToneIndex  = alien.SkinToneIndex;
            sb.TextureSize    = 1024u;
            sb.UseCompression = true;
            ApplyAlienFaceBlend(gender, ref sb);
            float hue = (sb.SkinToneIndex + 0.5f) % 1f;

            Color[] colors = new Color[]
            {
                HSLToRGB(hue, 0.71f, 0.5f),
                HSLToRGB(hue, 0.72f, 0.5f),
                HSLToRGB(hue, 0.73f, 0.5f),
                HSLToRGB(hue, 0.74f, 0.5f),
                HSLToRGB(hue, 0.75f, 0.5f),
                HSLToRGB(hue, 0.76f, 0.5f),
                HSLToRGB(hue, 0.77f, 0.5f),
                HSLToRGB(hue, 0.78f, 0.5f),
                HSLToRGB(hue, 0.79f, 0.5f),
                HSLToRGB(hue, 0.80f, 0.5f)
            };
            SimDescription baby = Genetics.MakeSim(sb, CASAgeGenderFlags.Baby, gender, alien.SkinToneKey, alien.SkinToneIndex, colors,
                                                   GameUtils.GetCurrentWorld(), 4294967295u, true);

            if (baby != null)
            {
                if (interactive)
                {
                    baby.FirstName = string.Empty;
                }
                else
                {
                    baby.FirstName = SimUtils.GetRandomAlienGivenName(baby.IsMale);
                }

                baby.LastName = abductee.LastName;
                Genetics.AssignTraits(baby, null, abductee, interactive, averageMood, pregoRandom);

                if (Aliens.Settings.mFutureSim)
                {
                    baby.TraitManager.AddHiddenElement(TraitNames.FutureSim);
                }

                if (Aliens.Settings.mAllowOccultBabies)
                {
                    List <OccultTypes> toInherit = OccultsToInherit(OccultTypeHelper.CreateList(abductee), OccultTypeHelper.CreateList(alien));

                    if (toInherit != null && toInherit.Count > 0)
                    {
                        for (int i = 0; i < toInherit.Count; i++)
                        {
                            if (toInherit[i] != OccultTypes.Ghost)
                            {
                                OccultTypeHelper.Add(baby, toInherit[i], false, false);
                            }
                            else
                            {
                                SimDescription.DeathType deathType = GetGhostBabyType(abductee, alien);
                                Urnstones.SimToPlayableGhost(baby, deathType);
                            }
                        }

                        if (OccultTypeHelper.HasType(baby, OccultTypes.Fairy))
                        {
                            CASFairyData casFairyData = baby.SupernaturalData as CASFairyData;

                            if (casFairyData != null)
                            {
                                Vector3   wingColor;
                                WingTypes wingType;
                                Genetics.InheritWings(baby, abductee, alien, pregoRandom, out wingColor, out wingType);
                                casFairyData.WingType  = wingType;
                                casFairyData.WingColor = wingColor;
                            }
                        }
                    }
                    else if (RandomUtil.RandomChance01(abductee.Pregnancy.mChanceOfRandomOccultMutation))
                    {
                        OccultTypeHelper.Add(baby, Pregnancy.ChooseARandomOccultMutation(), false, false);
                    }
                }

                baby.CelebrityManager.SetBabyLevel(Genetics.AssignBabyCelebrityLevel(null, abductee));
                abductee.Genealogy.AddChild(baby.Genealogy);

                if (alien != null)
                {
                    alien.Genealogy.AddChild(baby.Genealogy);
                }
            }

            return(baby);
        }
Esempio n. 12
0
        public SimDescription CreateNewSim(SimDescription mom, SimDescription dad, CASAgeGenderFlags ages, CASAgeGenderFlags genders, CASAgeGenderFlags species, bool updateGenealogy)
        {
            if (dad == null)
            {
                dad = GetSim(CASAgeGenderFlags.Male, species, mom);
                if (dad == null)
                {
                    dad = GetSim(CASAgeGenderFlags.Female, species, mom);
                    if (dad == null)
                    {
                        return(null);
                    }
                }
            }

            CASAgeGenderFlags gender = (CASAgeGenderFlags)RandomUtil.SelectOneRandomBit((uint)(genders));
            CASAgeGenderFlags age    = (CASAgeGenderFlags)RandomUtil.SelectOneRandomBit((uint)(ages));

            if (dad.CelebrityManager == null)
            {
                dad.Fixup();
            }

            if (mom.CelebrityManager == null)
            {
                mom.Fixup();
            }

            SimDescription newSim = null;

            try
            {
                if (mom.Species == CASAgeGenderFlags.Human)
                {
                    newSim = Genetics.MakeDescendant(dad, mom, age, gender, 100, new Random(), false, updateGenealogy, true, GetGeneticWorld(), false);

                    newSim.HomeWorld = GameUtils.GetCurrentWorld();
                }
                else
                {
                    newSim = GeneticsPet.MakePetDescendant(dad, mom, age, gender, mom.Species, new Random(), updateGenealogy, GeneticsPet.SetName.SetNameNonInteractive, 0, OccultTypes.None);
                }
            }
            catch (Exception e)
            {
                Common.Exception(dad, mom, e);
            }

            if (newSim == null)
            {
                return(null);
            }

            if (!updateGenealogy)
            {
                FacialBlends.RandomizeBlends(mStats.AddStat, newSim, new Vector2(0f, 0f), true, Manager.GetValue <MutationUnsetRangeOption <TManager>, Vector2>(), true, Manager.GetValue <AllowAlienHouseholdOption <TManager>, bool>());
            }

            List <OccultTypes> occults = new List <OccultTypes>();

            occults.AddRange(OccultTypeHelper.CreateList(mom.OccultManager.CurrentOccultTypes, true));
            occults.AddRange(OccultTypeHelper.CreateList(dad.OccultManager.CurrentOccultTypes, true));

            if (updateGenealogy)
            {
                Manager.Sims.ApplyOccultChance(Manager, newSim, occults, Manager.GetValue <ChanceOfHybridOption <TManager>, int>(), Manager.GetValue <MaximumOccultOption <TManager>, int>());
            }
            else if (species == CASAgeGenderFlags.Human)
            {
                int maxCelebrityLevel = Manager.GetValue <MaxCelebrityLevelOption <TManager>, int>();

                if (maxCelebrityLevel >= 0)
                {
                    newSim.CelebrityManager.mOwner = newSim;

                    Skill scienceSkill = SkillManager.GetStaticSkill(SkillNames.Science);
                    if (scienceSkill != null)
                    {
                        scienceSkill.mNonPersistableData.SkillCategory |= SkillCategory.Hidden;
                    }

                    try
                    {
                        newSim.CelebrityManager.ForceSetLevel((uint)RandomUtil.GetInt(maxCelebrityLevel));
                    }
                    finally
                    {
                        if (scienceSkill != null)
                        {
                            scienceSkill.mNonPersistableData.SkillCategory &= ~SkillCategory.Hidden;
                        }
                    }
                }

                occults.AddRange(Manager.GetValue <ImmigrantOccultOption <TManager>, List <OccultTypes> >());
                if (occults.Count > 0)
                {
                    if (RandomUtil.RandomChance(Manager.GetValue <ChanceOfOccultOption <TManager>, int>()))
                    {
                        OccultTypeHelper.Add(newSim, RandomUtil.GetRandomObjectFromList(occults), false, false);
                    }
                }
            }

            Manager.Sims.ApplyOccultChance(Manager, newSim, occults, Manager.GetValue <ChanceOfHybridOption <TManager>, int>(), Manager.GetValue <MaximumOccultOption <TManager>, int>());

            OccultTypeHelper.ValidateOccult(newSim, null);

            OccultTypeHelper.TestAndRebuildWerewolfOutfit(newSim);

            newSim.FirstName = Manager.Sims.EnsureUniqueName(newSim);

            List <Trait> traits = new List <Trait>(newSim.TraitManager.List);

            foreach (Trait trait in traits)
            {
                if (trait.IsHidden)
                {
                    newSim.TraitManager.RemoveElement(trait.Guid);
                }
            }

            List <Trait> choices = AgingManager.GetValidTraits(newSim, true, true, true);

            if (choices.Count > 0)
            {
                while (!newSim.TraitManager.TraitsMaxed())
                {
                    Trait choice = RandomUtil.GetRandomObjectFromList <Trait>(choices);
                    if (!newSim.TraitManager.AddElement(choice.Guid))
                    {
                        break;
                    }
                }
            }

            if (SimFromBinEvents.OnGeneticSkinBlend != null)
            {
                SimFromBinEvents.OnGeneticSkinBlend(mStats, newSim, mom, dad, Manager);
            }

            FixInvisibleTask.Perform(newSim, true);

            if (SimFromBinEvents.OnSimFromBinUpdate != null)
            {
                SimFromBinEvents.OnSimFromBinUpdate(mStats, newSim, mom, dad, Manager);
            }

            INameTakeOption nameTake = Manager.GetOption <NameTakeOption <TManager> >();

            if ((!updateGenealogy) && (nameTake != null))
            {
                bool wasEither;
                newSim.LastName = Manager.Sims.HandleName(nameTake, mom, dad, out wasEither);
            }
            else if (mom != null)
            {
                newSim.LastName = mom.LastName;
            }
            else if (dad != null)
            {
                newSim.LastName = dad.LastName;
            }

            if (!updateGenealogy && Manager.GetValue <CustomNamesOnlyOption <TManager>, bool>())
            {
                newSim.LastName = LastNameListBooter.GetRandomName(!Manager.GetValue <CustomNamesOnlyOption <TManager>, bool>(), newSim.Species, newSim.IsFemale);
            }

            return(newSim);
        }
Esempio n. 13
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Common.StringBuilder msg = new Common.StringBuilder("PrivateUpdate");

            try
            {
                bool fullList = !GetValue <CustomNamesOnlyOption <ManagerLot>, bool>();

                foreach (SimDescription baby in mBabies)
                {
                    msg += Common.NewLine + baby.FullName;

                    if (!SimTypes.IsSelectable(baby))
                    {
                        baby.FirstName = Sims.EnsureUniqueName(baby);
                    }

                    List <SimDescription> parents = Relationships.GetParents(baby);

                    parents.Remove(Sim);
                    if ((mDad == null) && (parents.Count > 0))
                    {
                        mDad = parents[0];
                    }

                    msg += Common.NewLine + "A";

                    List <OccultTypes> choices = OccultTypeHelper.CreateList(Sim.OccultManager.CurrentOccultTypes, true);

                    // Grandparent occult inheritance
                    foreach (SimDescription parent in Relationships.GetParents(Sim))
                    {
                        if (parent.OccultManager == null)
                        {
                            continue;
                        }

                        choices.AddRange(OccultTypeHelper.CreateList(parent.OccultManager.CurrentOccultTypes, true));
                    }

                    msg += Common.NewLine + "B";

                    if ((mDad != null) && (mDad.OccultManager != null))
                    {
                        choices.AddRange(OccultTypeHelper.CreateList(mDad.OccultManager.CurrentOccultTypes, true));

                        // Grandparent occult inheritance
                        foreach (SimDescription parent in Relationships.GetParents(mDad))
                        {
                            if (parent.OccultManager == null)
                            {
                                continue;
                            }

                            choices.AddRange(OccultTypeHelper.CreateList(parent.OccultManager.CurrentOccultTypes, true));
                        }
                    }

                    msg += Common.NewLine + "C";

                    Sims.ApplyOccultChance(this, baby, choices, GetValue <ChanceOfOccultBabyOptionV2, int>(), GetValue <MaximumNewbornOccultOption, int>());

                    msg += Common.NewLine + "D";

                    if ((SimTypes.IsServiceAlien(mDad)) || (SimTypes.IsServiceAlien(Sim)))
                    {
                        baby.SetAlienDNAPercentage(1f);
                    }
                    else
                    {
                        baby.SetAlienDNAPercentage(SimDescription.GetAlienDNAPercentage(mDad, Sim, true));
                    }
                }

                msg += Common.NewLine + "E";

                if (OnRenameNewbornsScenario != null)
                {
                    OnRenameNewbornsScenario(this, frame);
                }

                if (!SimTypes.IsSelectable(Sim))
                {
                    ManagerSim.IncrementLifetimeHappiness(Sim, Sims3.Gameplay.Rewards.LifeEventRewards.kLifetimeHappinessRewardForBaby);
                }

                SetElapsedTime <DayOfLastBabyOption>(Sim);

                msg += Common.NewLine + "F";

                if (mDad != null)
                {
                    if (!SimTypes.IsSelectable(mDad))
                    {
                        ManagerSim.IncrementLifetimeHappiness(mDad, Sims3.Gameplay.Rewards.LifeEventRewards.kLifetimeHappinessRewardForBaby);
                    }

                    SetElapsedTime <DayOfLastBabyOption>(mDad);
                }

                msg += Common.NewLine + "G";

                foreach (SimDescription baby in mBabies)
                {
                    Manager.AddAlarm(new NormalBabyAgingScenario(baby));
                }

                msg += Common.NewLine + "H";

                if (OnBirthScenario != null)
                {
                    OnBirthScenario(this, frame);
                }

                msg += Common.NewLine + "I";

                // Do this at the end once everything else has done its thing
                foreach (SimDescription baby in mBabies)
                {
                    msg += Common.NewLine + baby.FullName;

                    HouseholdOptions houseData = GetHouseOptions(baby.Household);
                    if (houseData != null)
                    {
                        int netWorth = houseData.GetValue <NetWorthOption, int>();

                        foreach (SimDescription parent in Relationships.GetParents(baby))
                        {
                            SimData parentData = GetData(parent);
                            if (parentData != null)
                            {
                                foreach (CasteOptions caste in parentData.Castes)
                                {
                                    if (!caste.GetValue <CasteInheritedOption, bool>())
                                    {
                                        continue;
                                    }

                                    if (!caste.Matches(baby, netWorth))
                                    {
                                        continue;
                                    }

                                    SimData babyData = GetData(baby);
                                    if (babyData != null)
                                    {
                                        babyData.AddValue <ManualCasteOption, CasteOptions>(caste);
                                    }
                                }
                            }
                        }
                    }
                }

                msg += Common.NewLine + "J";

                Add(frame, new SuccessScenario(), ScenarioResult.Start);
            }
            catch (Exception e)
            {
                Common.Exception(ToString() + Common.NewLine + msg.ToString(), e);
            }
            return(false);
        }
Esempio n. 14
0
        public static void FixupOccults(FutureDescendantService ths, FutureDescendantService.FutureDescendantHouseholdInfo descendantHouseholdInfo)
        {
            Common.StringBuilder msg = new Common.StringBuilder("FixupOccults");

            if (descendantHouseholdInfo == null)
            {
                msg += Common.NewLine + "descendantHouseholdInfo null";
            }

            if (descendantHouseholdInfo.DescendantHousehold == null)
            {
                msg += Common.NewLine + "descendantHouseholdInfo.DescendantHousehold null";
            }

            if (!descendantHouseholdInfo.mFutureDescendantHouseholdInfoDirty)
            {
                msg += Common.NewLine + "mFutureDescendantHosueholdInfoDirty is false";
            }

            if (Traveler.Settings.mChanceOfOccultHybrid == 0)
            {
                msg += Common.NewLine + "Hybrid 0, returning";
                Common.DebugWriteLog(msg);
                ths.FixupOccults(descendantHouseholdInfo);
                return;
            }

            try
            {
                if (((descendantHouseholdInfo != null) && descendantHouseholdInfo.mFutureDescendantHouseholdInfoDirty) && (descendantHouseholdInfo.DescendantHousehold != null))
                {
                    descendantHouseholdInfo.mFutureDescendantHouseholdInfoDirty = false;
                    List <OccultTypes> list  = null;
                    float minAlienPercentage = 0f;
                    float maxAlienPercentage = 0f;
                    if (descendantHouseholdInfo.mProgenitorSimIds != null)
                    {
                        foreach (ulong num in descendantHouseholdInfo.mProgenitorSimIds)
                        {
                            SimDescription item     = null;
                            bool           unpacked = false;
                            msg += Common.NewLine + "Num: " + num;
                            item = FutureDescendantHouseholdInfoEx.CreateProgenitor(num, out unpacked);

                            if (CrossWorldControl.sRetention.transitionedOccults.ContainsKey(num))
                            {
                                list = CrossWorldControl.sRetention.transitionedOccults[num];
                            }
                            else
                            {
                                msg += Common.NewLine + "Couldn't find Sim in transitionedOccults (Maybe they had none?)";
                            }

                            if (item != null)
                            {
                                // EA appears to transition this... I hope :)
                                msg += Common.NewLine + "Working on " + item.FullName;
                                if (SimTypes.IsServiceAlien(item))
                                {
                                    msg += Common.NewLine + "Is full blood Alien";
                                    maxAlienPercentage = 1f;
                                }
                                else
                                {
                                    msg += Common.NewLine + "Died (2)";
                                    if (item.AlienDNAPercentage == 0 && item.IsAlien)
                                    {
                                        msg += Common.NewLine + "IsAlien";
                                        minAlienPercentage = 0;
                                        maxAlienPercentage = 1;
                                    }
                                    else
                                    {
                                        if (item.AlienDNAPercentage > maxAlienPercentage)
                                        {
                                            maxAlienPercentage = item.mAlienDNAPercentage;
                                        }
                                        else if (item.AlienDNAPercentage > minAlienPercentage)
                                        {
                                            minAlienPercentage = item.mAlienDNAPercentage;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                msg += Common.NewLine + "Failed to find SimDesc";
                            }
                        }
                    }

                    if (descendantHouseholdInfo.mHouseholdMembers != null)
                    {
                        foreach (ulong num3 in descendantHouseholdInfo.mHouseholdMembers)
                        {
                            SimDescription newSim = SimDescription.Find(num3);
                            if (newSim != null && !newSim.IsDead)
                            {
                                msg += Common.NewLine + "Processing: " + newSim.FullName;
                                if (Traveler.Settings.mChanceOfOccultMutation == 0)
                                {
                                    msg += Common.NewLine + "Occult Mutation 0";
                                    List <OccultTypes> descendantOccults = OccultTypeHelper.CreateList(newSim, true);
                                    foreach (OccultTypes type in descendantOccults)
                                    {
                                        if (list == null || !list.Contains(type))
                                        {
                                            OccultTypeHelper.Remove(newSim, type, true);
                                        }
                                    }
                                }

                                if (list != null && list.Count > 0)
                                {
                                    msg += Common.NewLine + "Applying Occult Chance to " + newSim.FullName;
                                    bool success = FutureDescendantHouseholdInfoEx.ApplyOccultChance(newSim, list, Traveler.Settings.mChanceOfOccultHybrid, Traveler.Settings.mChanceOfOccultMutation, Traveler.Settings.mMaxOccult);
                                    if (success)
                                    {
                                        msg += Common.NewLine + "Added occults";
                                    }
                                }
                                else
                                {
                                    msg += Common.NewLine + "No occults found...";
                                }

                                if (minAlienPercentage > 0 || maxAlienPercentage > 0 && RandomUtil.CoinFlip())
                                {
                                    float percent = (minAlienPercentage + maxAlienPercentage) / 2f;
                                    float jitter  = SimDescription.kAlienDNAJitterPercent * 2; // 2 generations have passed considering Travelers approach to descendants
                                    percent = RandomUtil.GetFloat(-jitter, jitter);
                                    newSim.SetAlienDNAPercentage(MathUtils.Clamp(percent, 0f, 1f));

                                    msg += Common.NewLine + "Made alien. Percent: " + newSim.mAlienDNAPercentage;
                                }
                            }
                            else
                            {
                                msg += Common.NewLine + "New Sim was null.";
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception("", e);
            }
            finally
            {
                Common.DebugWriteLog(msg);
            }
        }
Esempio n. 15
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            SimDescription newSim = null;

            using (SimFromBin <ManagerSim> bin = new SimFromBin <ManagerSim>(this, Sims))
            {
                CASAgeGenderFlags gender = Sim.Gender;

                switch (GetValue <GenderOption, BabyGenderScenario.FirstBornGender>())
                {
                case BabyGenderScenario.FirstBornGender.Male:
                    gender = CASAgeGenderFlags.Male;
                    break;

                case BabyGenderScenario.FirstBornGender.Female:
                    gender = CASAgeGenderFlags.Female;
                    break;
                }

                newSim = bin.CreateNewSim(Sim.Age, gender, CASAgeGenderFlags.Human);
                if (newSim == null)
                {
                    IncStat("Creation Fail");
                    return(false);
                }
            }

            bool genderChanged = (Sim.Gender != newSim.Gender);

            bool result = FacialBlends.CopyGenetics(newSim, Sim, false, false);

            Sim.VoiceVariation     = newSim.VoiceVariation;
            Sim.VoicePitchModifier = newSim.VoicePitchModifier;

            Sim.FirstName = newSim.FirstName;

            if (genderChanged)
            {
                Sim.Gender = newSim.Gender;

                SavedOutfit.Cache cache = new SavedOutfit.Cache(newSim);

                Dictionary <OutfitCategories, bool> replaced = new Dictionary <OutfitCategories, bool>();

                Sim.RemoveOutfits(OutfitCategories.Career, true);

                SimOutfit geneOutfit = CASParts.GetOutfit(Sim, CASParts.sPrimary, false);

                foreach (SavedOutfit.Cache.Key outfit in cache.Outfits)
                {
                    using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(Sim, outfit.mKey, geneOutfit))
                    {
                        builder.Builder.Gender = Sim.Gender;

                        outfit.Apply(builder, false, null, null);

                        if (!replaced.ContainsKey(outfit.Category))
                        {
                            replaced.Add(outfit.Category, true);

                            CASParts.RemoveOutfits(Sim, outfit.Category, false);
                        }
                    }
                }

                if (Sim.CreatedSim != null)
                {
                    Sim.CreatedSim.UpdateOutfitInfo();

                    Sim.CreatedSim.RefreshCurrentOutfit(true);

                    SwitchOutfits.SwitchNoSpin(Sim.CreatedSim, new CASParts.Key(OutfitCategories.Everyday, 0));
                }
            }
            else
            {
                new SavedOutfit.Cache(Sim).PropagateGenetics(Sim, CASParts.sPrimary);
            }

            if (newSim.OccultManager.CurrentOccultTypes != OccultTypes.None)
            {
                if (Instantiation.PerformOffLot(Sim, Household.ActiveHousehold.LotHome, null) != null)
                {
                    List <OccultTypes> occults = OccultTypeHelper.CreateList(newSim, true);

                    foreach (OccultTypes occult in occults)
                    {
                        switch (occult)
                        {
                        case OccultTypes.Frankenstein:
                            Sim.TraitManager.AddElement(TraitNames.Brave);
                            Sim.TraitManager.AddElement(TraitNames.Hydrophobic);
                            break;
                        }
                    }

                    Sims.ApplyOccultChance(this, Sim, occults, 100, int.MaxValue);
                }

                if (Sim.GetOutfitCount(OutfitCategories.Everyday) > 1)
                {
                    Sim.RemoveOutfit(OutfitCategories.Everyday, 1, true);
                }

                SimOutfit currentOutfit = Sim.GetOutfit(OutfitCategories.Everyday, 0);
                if (currentOutfit != null)
                {
                    try
                    {
                        ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, Sim.AgeGenderSpecies);
                    }
                    catch (Exception e)
                    {
                        Common.Exception(Sim, e);
                    }
                }
            }

            Deaths.CleansingKill(newSim, true);

            if (!result)
            {
                return(false);
            }

            if (Common.kDebugging)
            {
                Common.DebugNotify(GetTitlePrefix(PrefixType.Pure) + ": " + Sim.FullName, Sim.CreatedSim);
            }

            SpeedTrap.Sleep();

            return(true);
        }
Esempio n. 16
0
        public static void OnTrickOrTreatAccept(Sim actor, Sim target, string interaction, ActiveTopic topic, InteractionInstance i)
        {
            IGameObject trickOrTreatItem = null;

            if (actor.OccultManager != null)
            {
                if ((actor.OccultManager.HasAnyOccultType() || actor.SimDescription.IsAlien) && RandomUtil.RandomChance(Tempest.Settings.mChanceOccultItemTrickOrTreat))
                {
                    List <OccultTypes> types = OccultTypeHelper.CreateList(actor.SimDescription);
                    OccultTypes        pick  = OccultTypes.None;
                    bool useAlien            = true;
                    if (types.Count > 0)
                    {
                        pick     = RandomUtil.GetRandomObjectFromList <OccultTypes>(types);
                        useAlien = actor.SimDescription.IsAlien && RandomUtil.CoinFlip();
                    }
                    trickOrTreatItem = FetchRandomOccultTreat(pick, useAlien);

                    if (trickOrTreatItem is FailureObject)
                    {
                        trickOrTreatItem = null;
                    }
                    else
                    {
                        if (RandomUtil.CoinFlip())
                        {
                            if (actor.OccultManager.HasOccultType(OccultTypes.PlantSim) && GameUtils.IsInstalled(ProductVersion.EP10) && Sim.MosquitoBeBitten.kChanceToKillMosquito != 100 && !target.BuffManager.HasAnyElement(new BuffNames[] { BuffNames.MosquitoBiteLow, BuffNames.MosquitoBiteMid, BuffNames.MosquitoBiteHigh }))
                            {
                                target.BuffManager.AddElement(BuffNames.MosquitoBiteLow, Origin.FromFallHoliday);
                            }
                            else if (actor.OccultManager.HasOccultType(OccultTypes.Werewolf) && GameUtils.IsInstalled(ProductVersion.EP5) && BuffGotFleasHuman.kPetToHumanSpreadFleasChance != 0 && !target.BuffManager.HasElement(BuffNames.GotFleasHuman))
                            {
                                target.BuffManager.AddElement(BuffNames.GotFleasHuman, Origin.FromFallHoliday);
                            }
                        }
                    }
                }
            }

            if (trickOrTreatItem == null)
            {
                trickOrTreatItem = TrickOrTreatSituation.GetTrickOrTreatItem();
            }

            if (trickOrTreatItem != null)
            {
                if (!target.Inventory.TryToAdd(trickOrTreatItem))
                {
                    trickOrTreatItem.Destroy();
                }
                else if (!(trickOrTreatItem is Candy))
                {
                    target.ShowTNSIfSelectable(Localization.LocalizeString(target.IsFemale, "Gameplay/Situation/TrickorTreat:SpecialObjectTNS", new object[] { trickOrTreatItem }), StyledNotification.NotificationStyle.kSimTalking, target.ObjectId, trickOrTreatItem.ObjectId);
                    if (trickOrTreatItem is IMagicGnomeFall)
                    {
                        EventTracker.SendEvent(EventTypeId.kReceivedSeasonalGnome);
                    }
                }
            }
            EventTracker.SendEvent(EventTypeId.kWentTrickOrTreating, target);
        }