public Lot GetHomeLot(Sim a, Sim b, bool testPush) { Lot result = null; if (a.LotHome == null) { result = b.LotHome; } else if (b.LotHome == null) { result = a.LotHome; } if (result != null) { if ((testPush) && (!GetValue <AllowLotPushOption, bool>(result))) { return(null); } } if ((RandomUtil.CoinFlip()) && ((!testPush) || (GetValue <AllowLotPushOption, bool>(a.LotHome)))) { return(a.LotHome); } else if ((!testPush) || (GetValue <AllowLotPushOption, bool>(b.LotHome))) { return(b.LotHome); } else { return(null); } }
protected override bool Allow(MiniSimDescription me, IMiniSimDescription actor) { if (mFilter == null) { return(false); } foreach (SimSelection.ICriteria item in mFilter.mElements) { if (item.CanBeRandomCriteria && RandomUtil.CoinFlip()) { continue; } ITestableOption testable = item as ITestableOption; if (testable == null) { continue; } if (!testable.Test(me, false, actor)) { return(false); } } return(true); }
public static void PerformPostLoopChessClub(GoToSchoolInRabbitHole interaction, AfterschoolActivity activity) { try { Chess skill = interaction.Actor.SkillManager.GetSkill <Chess>(SkillNames.Chess); if (skill != null) { if (RandomUtil.CoinFlip()) { skill.NumberOfWins++; } else { skill.NumberOfLosses++; } } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(interaction.Actor, interaction.Target, e); } }
private static SimDescription.DeathType GetGhostBabyType(SimDescription abductee, SimDescription alien) { if (abductee.DeathStyle != SimDescription.DeathType.None && alien.DeathStyle != SimDescription.DeathType.None) { if (RandomUtil.CoinFlip()) { return(abductee.DeathStyle); } else { return(alien.DeathStyle); } } else if (abductee.DeathStyle != SimDescription.DeathType.None) { return(abductee.DeathStyle); } else if (alien.DeathStyle != SimDescription.DeathType.None) { return(alien.DeathStyle); } else { return(SimDescription.DeathType.None); } }
public void SetGenderPreference(SimDescription sim, bool allowGay) { if ((sim.mGenderPreferenceMale == 0) && (sim.mGenderPreferenceFemale == 0)) { if (sim.Partner != null) { if (sim.Partner.IsMale) { sim.InternalIncreaseGenderPreferenceMale(); } else { sim.InternalIncreaseGenderPreferenceFemale(); } } else if ((allowGay) && (RandomUtil.RandomChance(GetValue <ChanceOfGaySim, int>()))) { if (sim.IsMale) { sim.InternalIncreaseGenderPreferenceMale(); } else { sim.InternalIncreaseGenderPreferenceFemale(); } } else if ((allowGay) && (RandomUtil.RandomChance(GetValue <ChanceOfBisexualOption, int>()))) { if (RandomUtil.CoinFlip()) { sim.mGenderPreferenceMale += 100000; sim.mGenderPreferenceFemale += 50000; } else { sim.mGenderPreferenceMale += 50000; sim.mGenderPreferenceFemale += 100000; } if (sim.CreatedSim != null) { EventTracker.SendEvent(EventTypeId.kGenderPreferencesChanged, sim.CreatedSim); } } else { if (sim.IsMale) { sim.InternalIncreaseGenderPreferenceFemale(); } else { sim.InternalIncreaseGenderPreferenceMale(); } } } }
public override void GetNewBorns() { mNewborns = new List <Sim>(); Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/Pregnancy:DisableSave"); bool keepBaby = false; //if (Actor.Household.NumActorMembersCountingPregnancy < 0x8) { // Custom if (SimTypes.IsSelectable(Actor)) { keepBaby = TwoButtonDialog.Show(AlienUtils.LocalizeString("MalePregnancyConfirmationDialog", new object[] { Actor }), AlienUtils.LocalizeString("MalePregnancyConfirmationDialogAccept", new object[0x0]), AlienUtils.LocalizeString("MalePregnancyConfirmationDialogReject", new object[0x0])); } else { keepBaby = true; } } /*else * { * Actor.ShowTNSIfSelectable(AlienUtils.LocalizeString("MalePregnancyHouseholdFullTNS", new object[] { Actor }), StyledNotification.NotificationStyle.kGameMessagePositive, ObjectGuid.InvalidObjectGuid, Actor.ObjectId); * }*/ CASAgeGenderFlags gender = RandomUtil.CoinFlip() ? CASAgeGenderFlags.Male : CASAgeGenderFlags.Female; SimDescription description2 = SimDescription.Find(this.AlienParentID); SimDescription newSim = Genetics.MakeAlien(CASAgeGenderFlags.Baby, gender, GameUtils.GetCurrentWorld(), 1f, false); newSim.LastName = Actor.LastName; if ((keepBaby) && (SimTypes.IsSelectable(Actor))) { newSim.FirstName = string.Empty; } Genetics.AssignTraits(newSim, null, Actor.SimDescription, (keepBaby) && (SimTypes.IsSelectable(Actor)), (float)Actor.MoodManager.MoodValue, new Random()); Actor.Genealogy.AddChild(newSim.Genealogy); if (description2 != null) { description2.Genealogy.AddChild(newSim.Genealogy); } if (keepBaby) { Actor.Household.Add(newSim); } else { Household.AlienHousehold.Add(newSim); } Sim babyToHide = newSim.Instantiate(Vector3.Empty); babyToHide.GreetSimOnLot(Actor.LotCurrent); babyToHide.SetPosition(Actor.Position); Pregnancy.TotallyHideBaby(babyToHide); mNewborns.Add(babyToHide); }
protected static void AlterSkinBlend(Common.IStatGenerator stats, SimDescription sim, List <SimDescription> immediateParents) { List <SimDescription> choices = new List <SimDescription>(immediateParents); foreach (SimDescription parent in immediateParents) { if (parent.IsAlien) { return; } foreach (SimDescription grand in Relationships.GetParents(parent)) { if (!grand.IsAlien) { choices.Add(grand); } } } stats.AddStat("Blend Choices", choices.Count); if (choices.Count >= 2) { sim.SkinToneKey = FixInvisibleTask.ValidateSkinTone(RandomUtil.GetRandomObjectFromList(choices).SkinToneKey); RandomUtil.RandomizeListOfObjects(choices); float num4 = choices[0].SkinToneIndex; float num5 = choices[1].SkinToneIndex; if (num4 > num5) { float num6 = num5; num5 = num4; num4 = num6; } float num8 = num5 - num4; float newIndex = 0; float num7 = RandomUtil.GetFloat(Sims3.Gameplay.CAS.Genetics.kSkinColorMaxPercentTravel / 100f); if (RandomUtil.CoinFlip()) { newIndex = num4 + (num8 * num7); } else { newIndex = num5 - (num8 * num7); } sim.SkinToneIndex = newIndex; } }
public virtual bool Test(IMiniSimDescription me, bool fullFamily, IMiniSimDescription actor, bool testRandom) { Dictionary <TStoreType, TDataType> results = new Dictionary <TStoreType, TDataType>(); SimDescription trueSim = me as SimDescription; if (trueSim != null) { if ((fullFamily) && (trueSim.Household != null)) { foreach (SimDescription member in CommonSpace.Helpers.Households.All(trueSim.Household)) { Get(member, actor, results); } } else { if (!Get(trueSim, actor, results)) { return(false); } } } else { MiniSimDescription miniSim = me as MiniSimDescription; if (miniSim != null) { if (!Get(miniSim, actor, results)) { return(false); } } } if (testRandom && mCanBeRandomValue) { if (RandomUtil.CoinFlip()) { return(results.ContainsKey(Value)); } else { return(false); } // don't have to worry about new criteria being added to a filter... if it is we can flush Sims matching that filter // once filter with random criteria has been applied it won't be altered on the sim or removed unless the random criteria applied is no longer valid // if random criteria is applied, create new filter with it so it can be tested } return(results.ContainsKey(Value)); }
public KillTask(Sim target, SimDescription.DeathType deathType, GameObject obj) { if (target == null) { return; //throw new ArgumentNullException("target As Sim"); } mtarget = target; mdeathType = RandomUtil.CoinFlip() ? GetDGSDeathType(target) : GetDeathType(target); mobj = obj; mplayDeathAnim = true; msleepyes = true; }
public KillTask(Sim target) { if (target == null) { return; //throw new ArgumentNullException("target As Sim"); } mtarget = target; if (mdeathType == SimDescription.DeathType.None) { mdeathType = RandomUtil.CoinFlip() ? GetDGSDeathType(target) : GetDeathType(target); } mobj = null; mplayDeathAnim = true; msleepyes = true; }
public KillTask(Sim target, SimDescription.DeathType deathType, GameObject obj, bool playDeathAnim, bool sleepyes) { if (target == null) { return; //throw new ArgumentNullException("target As Sim"); } mtarget = target; if (mdeathType == SimDescription.DeathType.None) { mdeathType = RandomUtil.CoinFlip() ? GetDGSDeathType(target) : GetDeathType(target); } mobj = obj; mplayDeathAnim = playDeathAnim; msleepyes = sleepyes; }
private new void SongFinished(bool stopWatching, bool ableToTip) { try { mbIsWatchingRightNow = false; if (stopWatching) { base.SongFinished(stopWatching, ableToTip); } else { if (mTippingStatus == Tipping.NoTip) { if (RandomUtil.CoinFlip() || ((mPlayer.Occupation is Music) && (mPlayer.Occupation.Level >= Music.GuitarBonusLevel))) { AnimateSim("FinishHappy"); } else { AnimateSim("FinishSad"); } } else if (Actor.TraitManager.HasElement(TraitNames.Insane)) { AnimateSim("FinishSad"); } else { AnimateSim("FinishHappy"); } ExitAndTip(true); mTippingStatus = Tipping.NoTip; } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); } }
public static void OnPerform(Scenario scenario, ScenarioFrame frame) { DualSimScenario s = scenario as DualSimScenario; if (s == null) { return; } if (RandomUtil.CoinFlip()) { scenario.Add(frame, new EngagementGatheringScenario(s.Sim), ScenarioResult.Start); } else { scenario.Add(frame, new EngagementGatheringScenario(s.Target), ScenarioResult.Start); } }
public static CASAgeGenderFlags InterpretGender(CASAgeGenderFlags gender) { if (gender == CASAgeGenderFlags.GenderMask) { if (RandomUtil.CoinFlip()) { return(CASAgeGenderFlags.Male); } else { return(CASAgeGenderFlags.Female); } } else { return(gender); } }
public static CASAgeGenderFlags GetGenderByFirstBorn(StoryProgressionObject manager, FirstBornGender firstBorn, bool isPet) { if (firstBorn == FirstBornGender.Male) { return(CASAgeGenderFlags.Male); } else if (firstBorn == FirstBornGender.Female) { return(CASAgeGenderFlags.Female); } else if (firstBorn == FirstBornGender.Balanced) { return(CalculateGenderBalancer(manager, isPet)); } else if (RandomUtil.CoinFlip()) { return(CASAgeGenderFlags.Male); } else { return(CASAgeGenderFlags.Female); } }
public override bool Run() // Run { if (Autonomous || Actor.IsNPC) { return(false); } if (!AcceptCancelDialog.Show("Are You Sure All Kill Sim?")) { return(false); } List <Sim> list = new List <Sim>(); foreach (Sim sim in LotManager.Actors) { //if (sim.SimDescription.ToddlerOrAbove && !sim.IsInActiveHousehold && sim.LotCurrent != Household.ActiveHousehold.LotHome) //OK //if (!sim.IsInActiveHousehold || !(sim.Service is GrimReaper)) //Failed //if (sim.IsNPC && !sim.IsInActiveHousehold) //OK //if (sim.IsNPC && !sim.IsInActiveHousehold || !(sim.Service is GrimReaper)) // Failed All Sim Not If || if (!(sim.Service is GrimReaper)) // OK { //sim.InteractionQueue.AddNext(NotKillSimNPCOnly.Singleton.CreateInstance(sim, sim, new InteractionPriority((InteractionPriorityLevel)12, 1f), false, true)); //SpeedTrap.Sleep(1); //if (!AcceptCancelDialog.Show("Done?")) return false; //sim.InteractionQueue.Add(CCnlean.Singleton.CreateInstance(Actor, sim, new InteractionPriority((InteractionPriorityLevel)1, 0f), false, true)); list.Add(sim); } } if (list.Count > 0) { foreach (Sim nlist in list) { try { //Name is if (nlist.SimDescription.FirstName == "Death" && nlist.SimDescription.LastName == "Good System") { continue; } if (nlist.SimDescription.FirstName == "Good System" && nlist.SimDescription.LastName == "Death Helper") { continue; } if (nlist.SimDescription.FirstName == "Grim" && nlist.SimDescription.LastName == "Reaper") { continue; } } catch (NullReferenceException) { } //nlist.BuffManager.RemoveAllElements(); /* * List<SimDescription.DeathType> listr = new List<SimDescription.DeathType>(); * listr.Add(SimDescription.DeathType.Drown); * listr.Add(SimDescription.DeathType.Starve); * listr.Add(SimDescription.DeathType.Thirst); * listr.Add(SimDescription.DeathType.Burn); * listr.Add(SimDescription.DeathType.Freeze); * listr.Add(SimDescription.DeathType.ScubaDrown); * listr.Add(SimDescription.DeathType.Shark); * listr.Add(SimDescription.DeathType.Jetpack); * listr.Add(SimDescription.DeathType.Meteor); * listr.Add(SimDescription.DeathType.Causality); * listr.Add(SimDescription.DeathType.Electrocution); * if (Actor.SimDescription.Elder) * { * listr.Add(SimDescription.DeathType.OldAge); * } * listr.Add(SimDescription.DeathType.HauntingCurse); * SimDescription.DeathType randomObjectFromList = RandomUtil.GetRandomObjectFromList(listr); * //Urnstones.CreateGrave(nlist.SimDescription, randomObjectFromList, true, true); */ //KillTask kt = new KillTask(Target, RandomUtil.CoinFlip() ? KillTask.GetDGSDeathType(Target) : KillTask.GetDeathType(Target), null, false, false); //kt.AddToSimulator(); KillPro.FastKill(nlist, RandomUtil.CoinFlip() ? KillTask.GetDGSDeathType(Target) : KillTask.GetDeathType(Target), Actor, true, false); } //nlist.InteractionQueue.CancelAllInteractionsByType(NotKillSimNPCOnly.Singleton); } return(true); }
public static Sim CreateAnNPCPerformer(ShowStage ths) { Sim createdSim = null; Lot lotCurrent = null; OccupationNames[] randomList = new OccupationNames[] { OccupationNames.SingerCareer, OccupationNames.MagicianCareer, OccupationNames.PerformanceArtistCareer }; AcquireOccupationParameters occupationParameters = new AcquireOccupationParameters(RandomUtil.GetRandomObjectFromList(randomList), false, true); bool flag = RandomUtil.CoinFlip(); // Custom List <SimDescription> list = Household.AllTownieSimDescriptions(ValidPerformer); if (list.Count != 0) { SimDescription randomObjectFromList = RandomUtil.GetRandomObjectFromList(list); if (randomObjectFromList.CreatedSim == null) { lotCurrent = ths.LotCurrent; createdSim = randomObjectFromList.Instantiate(lotCurrent); } else { createdSim = randomObjectFromList.CreatedSim; } } else { Sim servicePerformer = CreateServicePerformer(ths); if (servicePerformer != null) { createdSim = servicePerformer; } } if (createdSim == null) { return(null); } GoToLot interaction = GoToLot.Singleton.CreateInstanceWithCallbacks(ths.LotCurrent, createdSim, new InteractionPriority(InteractionPriorityLevel.CriticalNPCBehavior), false, true, null, new Callback(GoToLotSuccess), new Callback(GoToLotFailure)) as GoToLot; if (createdSim.InteractionQueue != null) { Common.DebugNotify("Pushing GoToLot on " + createdSim.FullName); createdSim.InteractionQueue.Add(interaction); } if (createdSim.CareerManager == null) { return(null); } if (createdSim.CareerManager.OccupationAsPerformanceCareer == null) { try { if (createdSim.WasCreatedByAService) { switch (createdSim.Service.ServiceType) { case ServiceType.Magician: occupationParameters = new AcquireOccupationParameters(OccupationNames.MagicianCareer, false, true); break; case ServiceType.Singer: occupationParameters = new AcquireOccupationParameters(OccupationNames.SingerCareer, false, true); break; case ServiceType.PerformanceArtist: occupationParameters = new AcquireOccupationParameters(OccupationNames.PerformanceArtistCareer, false, true); break; default: break; } } createdSim.AcquireOccupation(occupationParameters); int num = flag ? RandomUtil.GetInt(0x0, 0x5) : RandomUtil.GetInt(0x5, createdSim.Occupation.HighestLevel); for (int i = 0x1; i < num; i++) { createdSim.CareerManager.Occupation.PromoteSim(); } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(createdSim, e); return(null); } } return(createdSim); }
static void RefreshCallback() { Logger.Append("Alien Household Refresh Alarm Triggered"); if (Household.AlienHousehold == null) { Logger.Append("Alien Refresh: Alien Household is Null"); return; } if (Household.AlienHousehold.NumMembers < AlienUtils.kAlienHouseholdNumMembers) { CASAgeGenderFlags age = RandomUtil.GetRandomObjectFromList <CASAgeGenderFlags>(AlienUtils.kAlienHouseholdValidAges); CASAgeGenderFlags gender = RandomUtil.CoinFlip() ? CASAgeGenderFlags.Male : CASAgeGenderFlags.Female; SimDescription description = AlienGenetics.MakeAlien(age, gender, GameUtils.GetCurrentWorld(), 1f, true); description.SkillManager.AddElement(SkillNames.Logic); description.SkillManager.AddElement(SkillNames.Handiness); Skill element = description.SkillManager.GetElement(SkillNames.Logic); if (element != null) { element.ForceSkillLevelUp(RandomUtil.GetInt(Abductor.Settings.mLogicSkill[0], Abductor.Settings.mLogicSkill[1])); } element = description.SkillManager.GetElement(SkillNames.Handiness); if (element != null) { element.ForceSkillLevelUp(RandomUtil.GetInt(Abductor.Settings.mHandinessSkill[0], Abductor.Settings.mHandinessSkill[1])); } if (age == CASAgeGenderFlags.Teen) { description.SkillManager.AddElement(SkillNames.LearnToDrive); element = description.SkillManager.GetElement(SkillNames.LearnToDrive); if (element != null) { element.ForceSkillLevelUp(SkillManager.GetMaximumSupportedSkillLevel(SkillNames.LearnToDrive)); } } if (GameUtils.IsInstalled(ProductVersion.EP11) && Abductor.Settings.mFutureSim) { description.TraitManager.AddHiddenElement(TraitNames.FutureSim); description.SkillManager.AddElement(SkillNames.Future); element = description.SkillManager.GetElement(SkillNames.Future); if (element != null) { element.ForceSkillLevelUp(RandomUtil.GetInt(Abductor.Settings.mAdvancedTechSkill[0], Abductor.Settings.mAdvancedTechSkill[1])); } } Household.AlienHousehold.AddSilent(description); description.OnHouseholdChanged(Household.AlienHousehold, false); } }
public static void GenerateChildTraits(Human child) { List <Settler> parents = new List <Settler>(); foreach (var relationship in child.Relationships) { if (relationship is ParentChildRelationship pcr && pcr.Role(child) == ParentChildRelationship.Child) { parents.Add(pcr.Other(child)); } } var badRelationshipParents = parents.Where(parent => child.Relationships .FirstOrDefault(rel => rel is ParentChildRelationship pcr && pcr.Other(parent) == child)?.Level <= RelationshipLevel.Dislike).ToList(); foreach (var trait in Trait.Traits) { var parentsTraitsArray = parents.ToArray().Select(parent => parent.Traits[trait].Value).ToArray(); if (badRelationshipParents.Count > 0 && RandomUtil.Chance(1, 3)) { var parent = RandomUtil.Get(badRelationshipParents); var level = parent.Traits[trait]; if (level == TraitLevel.Average) //Reaction goes extreme { child.Traits[trait] = RandomUtil.Get(new[] { TraitLevel.VeryLow, TraitLevel.Low, TraitLevel.High, TraitLevel.VeryHigh }); } else if (level == TraitLevel.AboveAverage) // Reaction goes extreme, more down { child.Traits[trait] = RandomUtil.Get(new[] { TraitLevel.VeryLow, TraitLevel.Low, TraitLevel.VeryHigh }); } else if (level == TraitLevel.BelowAverage) { child.Traits[trait] = RandomUtil.Get(new[] { TraitLevel.VeryLow, TraitLevel.High, TraitLevel.VeryHigh }); } else if (level >= TraitLevel.High) { child.Traits[trait] = RandomUtil.Get(new[] { TraitLevel.VeryLow, TraitLevel.Low, TraitLevel.BelowAverage }); } else { child.Traits[trait] = RandomUtil.Get(new[] { TraitLevel.AboveAverage, TraitLevel.High, TraitLevel.VeryHigh }); } } else { var baseLevel = TraitLevel.Average.Get(MathUtil.RoundTowardsZero(MathUtil.UnroundedAverage(parentsTraitsArray))); if (RandomUtil.CoinFlip()) //Drift { if (baseLevel == TraitLevel.VeryLow || baseLevel <= TraitLevel.High && RandomUtil.CoinFlip()) { baseLevel = baseLevel.Get(baseLevel.Value + 1); } else { baseLevel = baseLevel.Get(baseLevel.Value - 1); } } child.Traits[trait] = baseLevel as TraitLevel; } } TraitGenerator.EnsureMajorTrait(child); }
// Methods public override bool Run() // Run { Slot[] routingSlots = this.Target.GetRoutingSlots(); bool flag = false; Route route = this.Actor.CreateRoute(); if (route.PlanToSlot(this.Target, routingSlots).Succeeded()) { flag = this.Actor.DoRoute(route); } else if (this.Actor.RouteToObjectRadius(this.Target, 1f)) { flag = true; } base.StandardEntry(); base.BeginCommodityUpdates(); base.AcquireStateMachine("JellyBean"); base.SetActor("x", this.Actor); base.SetActor("magicjellybeanbush", this.Target); base.EnterState("x", "JellyBeanEnter"); if (RandomUtil.RandomChance01(100) && this.Actor.IsNPC) { base.AnimateSim("Poisoned"); this.Actor.Kill(SimDescription.DeathType.Shark); KillSimNiecX.MineKill(Actor, SimDescription.DeathType.Shark, true); } else { float @float = RandomUtil.GetFloat(1f); if (@float < JellyBeanBush.kChanceToCatchOnFire && this.Actor.IsNPC) { base.AnimateSim("NormalExit"); if (this.Actor.SimDescription.TeenOrAbove) { this.Actor.BuffManager.AddElement(BuffNames.OnFire, Origin.FromMagicJellyBean); this.Actor.PlayReaction(ReactionTypes.SmellSmoke, ReactionSpeed.NowOrLater); } } else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy && this.Actor.IsNPC) { base.AnimateSim("NormalExit"); this.Actor.BuffManager.AddElement(BuffNames.TooSpicy, Origin.FromMagicJellyBean); } else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff && this.Actor.IsNPC) { base.AnimateSim("NormalExit"); this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.NormalPositive); VisualEffect.FireOneShotEffect("ep7BuffJellyBeanPos_main", this.Actor, Sim.FXJoints.Pelvis, VisualEffect.TransitionType.SoftTransition); if (RandomUtil.CoinFlip()) { this.Actor.PlayReaction(ReactionTypes.Excited, ReactionSpeed.NowOrLater); } else { this.Actor.PlayReaction(ReactionTypes.Cheer, ReactionSpeed.NowOrLater); } } else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff + JellyBeanBush.kChanceToGetNegitiveBuff && this.Actor.IsNPC) { base.AnimateSim("NormalExit"); this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.NormalNegative); VisualEffect.FireOneShotEffect("ep7BuffJellyBeanNeg_main", this.Actor, Sim.FXJoints.Pelvis, VisualEffect.TransitionType.SoftTransition); if (RandomUtil.CoinFlip()) { this.Actor.PlayReaction(ReactionTypes.Shocked, ReactionSpeed.NowOrLater); } else { this.Actor.PlayReaction(ReactionTypes.HeadPain, ReactionSpeed.NowOrLater); } } else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff + JellyBeanBush.kChanceToGetNegitiveBuff + JellyBeanBush.kChanceToGetPosTransBuff && this.Actor.IsNPC) { base.AnimateSim("NormalExit"); OccultImaginaryFriend occultImaginaryFriend; if (!this.Actor.BuffManager.HasTransformBuff() && !this.Actor.IsWearingSpecialOutfit(UniversityMascot.MascotOutfitKey) && !OccultImaginaryFriend.TryGetOccultFromSim(this.Actor, out occultImaginaryFriend) && !this.Actor.IsSimBot) { this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.TransPositive); if (RandomUtil.CoinFlip()) { this.Actor.PlayReaction(ReactionTypes.Excited, ReactionSpeed.AfterInteraction); } else { this.Actor.PlayReaction(ReactionTypes.Cheer, ReactionSpeed.AfterInteraction); } } } else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff + JellyBeanBush.kChanceToGetNegitiveBuff + JellyBeanBush.kChanceToGetPosTransBuff + JellyBeanBush.kChanceToGetNegTransBuff && this.Actor.IsNPC) { base.AnimateSim("NormalExit"); OccultImaginaryFriend occultImaginaryFriend2; if (!this.Actor.BuffManager.HasTransformBuff() && !this.Actor.IsWearingSpecialOutfit(UniversityMascot.MascotOutfitKey) && !OccultImaginaryFriend.TryGetOccultFromSim(this.Actor, out occultImaginaryFriend2) && this.Actor.IsNPC) { this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.TransNegative); if (RandomUtil.CoinFlip()) { this.Actor.PlayReaction(ReactionTypes.Shocked, ReactionSpeed.AfterInteraction); } else { this.Actor.PlayReaction(ReactionTypes.HeadPain, ReactionSpeed.AfterInteraction); } } } else { base.AnimateSim("NormalExit"); } } base.EndCommodityUpdates(true); base.StandardExit(); EventTracker.SendEvent(EventTypeId.kEatMagicJellyBean, this.Actor); return(true); }
public override bool Run() { try { if (Target == null) { return(false); } if (!Target.RouteToWorkbench(Actor)) { return(false); } mInventSkill = Actor.SkillManager.AddElement(SkillNames.Inventing) as InventingSkill; bool flag = Target.mInventionProgress > 0f; Definition interactionDefinition = InteractionDefinition as Definition; mMakeMany = true; if (flag) { string mInventionKey = Target.mInventionKey; if (!InventingSkill.kInventionDataMap.TryGetValue(mInventionKey, out mCurData)) { return(false); } if (Target.mDummyModel == null) { Target.ScrapCurrentInvention(); return(false); } } else { if (Target.mDummyModel != null) { Target.CleanupDummyModel(); } List <string> choices = new List <string>(mInventSkill.KnownInventions); bool success = false; while (choices.Count > 0) { string choice = RandomUtil.GetRandomObjectFromList(choices); choices.Remove(choice); if (InventingSkill.kInventionDataMap.TryGetValue(choice, out mCurData)) { if (mCurData.InventType == InventionType.Toy) { mIsCheapToy = RandomUtil.CoinFlip(); } if (!Target.ReserveScrap(mCurData.GetScrapCost(Actor, mIsCheapToy), Actor, mScrapList)) { if (mIsCheapToy) { continue; } mIsCheapToy = true; if (!Target.ReserveScrap(mCurData.GetScrapCost(Actor, mIsCheapToy), Actor, mScrapList)) { continue; } } success = true; break; } } if (!success) { return(false); } Target.mInventionKey = mCurData.MedatorName; Target.mInventionProgress = 0f; Target.mIsMakingCheapToy = mIsCheapToy; if (!Target.ConsumeScrap(mScrapList)) { ShowOutOfScrapTNS(); return(false); } } if (Target.mWasFinishedByGnome) { ShowGnomeFinishedInventionTNS(); } StandardEntry(); StartStages(); mTimeUntilModelSwap = GetTimeForNextModelChange(); EnterStateMachine("WorkbenchInvention", "Enter", "x", "workstation"); if (Actor.SimDescription.Child) { mStool = GlobalFunctions.CreateObjectOutOfWorld("ChildStool") as GameObject; SetActor("stool", mStool); } SetParameter("shouldSwipe", !flag); SetParameter("skillLevel", InventionWorkbench.GetSkillLevelParam(mInventSkill)); if (!flag) { AddSynchronousOneShotScriptEventHandler(0x67, new SacsEventHandler(OnAnimationEvent)); } mTotalTime = GetTimeToCompletion(); AnimateSim("Loop Invent"); BeginCommodityUpdates(); bool succeeded = false; try { if (Actor.SimDescription.TeenOrAbove) { Actor.SkillManager.StartGainWithoutSkillMeter(SkillNames.Handiness, InventionWorkbench.kHandinessSkillGainRateDuringMake, true); } succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), new Interaction <Sim, InventionWorkbench> .InsideLoopFunction(MakeLoopCallback), mCurrentStateMachine); } finally { if (Actor.SimDescription.TeenOrAbove) { Actor.SkillManager.StopSkillGain(SkillNames.Handiness); } EndCommodityUpdates(succeeded); } if ((Target.mInventionProgress == 0f) && (Target.mDummyModel != null)) { Target.mDummyModel.FadeOut(false, true); Target.mDummyModel = null; } AnimateSim("Exit"); StandardExit(); return(succeeded); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
protected static Dictionary <int, SimDescription> GetPotentials(Sim actor) { CASAgeGenderFlags allow = CASAgeGenderFlags.None; if ((actor.SimDescription.Teen && Woohooer.Settings.AllowTeen(true)) || (actor.SimDescription.YoungAdultOrAbove && Woohooer.Settings.AllowTeenAdult(true))) { allow |= CASAgeGenderFlags.Teen; } if (actor.SimDescription.Teen && Woohooer.Settings.AllowTeen(true) && Woohooer.Settings.AllowTeenAdult(true)) { allow |= CASAgeGenderFlags.YoungAdult | CASAgeGenderFlags.Adult | CASAgeGenderFlags.Elder; } if (actor.SimDescription.YoungAdultOrAbove) { allow |= CASAgeGenderFlags.YoungAdult | CASAgeGenderFlags.Adult | CASAgeGenderFlags.Elder; } Dictionary <int, List <SimDescription> > potentials = KamaSimtra.GetPotentials(allow, true); Dictionary <int, SimDescription> choices = new Dictionary <int, SimDescription>(); for (int i = 1; i <= 10; i++) { List <SimDescription> fullList; if (!potentials.TryGetValue(i, out fullList)) { continue; } bool needFemale = false; if (actor.SimDescription.CanAutonomouslyBeRomanticWithGender(CASAgeGenderFlags.Male)) { if (actor.SimDescription.CanAutonomouslyBeRomanticWithGender(CASAgeGenderFlags.Female)) { if (RandomUtil.CoinFlip()) { needFemale = true; } } else { needFemale = false; } } else if (actor.SimDescription.CanAutonomouslyBeRomanticWithGender(CASAgeGenderFlags.Female)) { needFemale = true; } else { needFemale = !actor.IsFemale; } List <SimDescription> randomList = new List <SimDescription>(); foreach (SimDescription sim in fullList) { if (sim.IsFemale != needFemale) { continue; } if (sim.Household == actor.Household) { continue; } string reason; GreyedOutTooltipCallback callback = null; if (!CommonSocials.CanGetRomantic(actor.SimDescription, sim, false, true, true, ref callback, out reason)) { if (callback != null) { Common.Notify(sim.FullName + Common.NewLine + callback()); } continue; } if (choices.ContainsValue(sim)) { continue; } randomList.Add(sim); } if (randomList.Count > 0) { choices.Add(i, RandomUtil.GetRandomObjectFromList(randomList)); } } return(choices); }
protected List <Sim> GeneratePetChildren(SimDescription woman, SimDescription man, int numChildren) { Random pregoRandom = new Random(); float[] chanceOfTwin = new float[] { 1f, PetPregnancy.kChanceEggSizeTwo, PetPregnancy.kChanceEggSizeThree, PetPregnancy.kChanceEggSizeFour }; int index = 0; SimDescription eggLead = null; GeneticsPet.SetName nameSet = GeneticsPet.SetName.SetNameNonInteractive; if (woman.IsHorse) { nameSet = GeneticsPet.SetName.SetNameInteractive; } List <Sim> babies = new List <Sim>(); for (int i = 0; i < numChildren; i++) { try { OccultTypes occult = RandomUtil.CoinFlip() ? woman.OccultManager.CurrentOccultTypes : man.OccultManager.CurrentOccultTypes; if (!OccultManager.DoesOccultTransferToOffspring(occult)) { occult = OccultTypes.None; } SimDescription newBaby = null; if (pregoRandom.NextDouble() > chanceOfTwin[index]) { index = 0x0; } if ((index == 0x0) || (woman.IsHorse)) { CASAgeGenderFlags species = woman.Species; if ((man != null) && (pregoRandom.NextDouble() > 0.5)) { species = man.Species; } newBaby = GeneticsPet.MakePetDescendant(man, woman, CASAgeGenderFlags.Child, NRaas.MasterControllerSpace.Helpers.Baby.InterpretGender(mGender), species, pregoRandom, true, nameSet, i, occult); if (newBaby != null) { if (RandomUtil.CoinFlip()) { newBaby.SetDeathStyle(woman.DeathStyle, true); } else { newBaby.SetDeathStyle(man.DeathStyle, true); } } } else { newBaby = GeneticsPet.MakeSameEggDescendant(eggLead, man, woman, NRaas.MasterControllerSpace.Helpers.Baby.InterpretGender(mGender), pregoRandom, true, nameSet, i); if (newBaby != null) { newBaby.SetDeathStyle(eggLead.DeathStyle, true); } } eggLead = newBaby; index++; if (index >= chanceOfTwin.Length) { index = chanceOfTwin.Length - 1; } if (newBaby == null) { continue; } newBaby.WasCasCreated = false; woman.Household.Add(newBaby); Vector3 position = woman.CreatedSim.Position; Sim babyToHide = Instantiation.Perform(newBaby, position, null, null); babies.Add(babyToHide); if (newBaby.DeathStyle != SimDescription.DeathType.None) { Urnstone.SimToPlayableGhost(babyToHide); } if (i == 0x0) { EventTracker.SendEvent(new SimDescriptionEvent(EventTypeId.kNewBaby, newBaby)); } if (woman.CreatedSim != null) { EventTracker.SendEvent(EventTypeId.kNewOffspringPet, woman.CreatedSim, babyToHide); } if (man.CreatedSim != null) { EventTracker.SendEvent(EventTypeId.kNewOffspringPet, man.CreatedSim, babyToHide); } foreach (Sim sim in CommonSpace.Helpers.Households.AllHumans(woman.Household)) { EventTracker.SendEvent(EventTypeId.kNewPet, sim, babyToHide); } } catch (Exception e) { Common.Exception(woman, man, e); } } return(babies); }
public static SimDescription MakeDescendant(SimDescription dad, SimDescription mom, SimDescription robotDad, SimDescription robotMom, CASAgeGenderFlags age, CASAgeGenderFlags gender, float averageMood, Random pregoRandom, bool interactive, bool updateGenealogy, bool setName, WorldName homeWorld, bool plantSimBaby, Pregnancy.BabyCustomizeData customizeData) { if (robotDad == null && robotMom == null) { Common.DebugNotify("CommonSurrogatePregnancy.MakeDescendant" + Common.NewLine + " - Fail: Robot Parnets Null"); return(null); } SimBuilder simBuilder = new SimBuilder(); simBuilder.Age = age; simBuilder.Gender = gender; simBuilder.Species = CASAgeGenderFlags.Human; simBuilder.TextureSize = 1024u; simBuilder.UseCompression = true; List <SimDescription> list = new List <SimDescription>(); if (mom != null) { list.Add(mom); } if (dad != null) { list.Add(dad); } float alienDNAPercentage = SimDescription.GetAlienDNAPercentage(dad, mom, true); SimDescription[] array = list.ToArray(); bool flag = alienDNAPercentage >= SimDescription.kMinAlienDNAPercentToBeAlien; if (plantSimBaby) { float skinToneIndex = OccultPlantSim.kBaseGreenSkinIndex + RandomUtil.GetFloat(1f - OccultPlantSim.kBaseGreenSkinIndex); simBuilder.SkinTone = new ResourceKey(2751605866008866797uL, 55867754u, 0u); simBuilder.SkinToneIndex = skinToneIndex; } else { Genetics.InheritSkinColor(simBuilder, array, pregoRandom, homeWorld); } if (customizeData.IsBabyCustomized) { CASPart mPart = customizeData.EyeColorPreset.mPart; if (simBuilder.AddPart(mPart)) { string mPresetString = customizeData.EyeColorPreset.mPresetString; if (!string.IsNullOrEmpty(mPresetString)) { OutfitUtils.ApplyPresetStringToPart(simBuilder, mPart, mPresetString); } } } else { Genetics.InheritEyeColor(simBuilder, array, pregoRandom); } Genetics.InheritFacialBlends(simBuilder, array, pregoRandom); ResourceKey geneticHairstyleKey = Genetics.InheritHairStyle(gender, dad, mom, pregoRandom, flag); Genetics.InheritBodyShape(simBuilder, array, pregoRandom); bool flag2 = pregoRandom.Next(0, 2) == 0; float num = (float)pregoRandom.NextDouble() * 100f; Color[] array2; if (customizeData.IsBabyCustomized) { array2 = new Color[10]; for (int i = 0; i < 4; i++) { array2[i] = customizeData.HairColor[i]; array2[i + 5] = customizeData.HairColor[i]; } array2[4] = customizeData.HairColor[0]; array2[9] = customizeData.HairColor[0]; } else if (age == CASAgeGenderFlags.Elder) { array2 = Genetics.GetRandomElderHairColor(); } else { array2 = Genetics.InheritHairColor(simBuilder, array, pregoRandom); } SimDescription baby = Genetics.MakeSim(simBuilder, CASAgeGenderFlags.Baby, gender, simBuilder.SkinTone, simBuilder.SkinToneIndex, array2, homeWorld, 4294967295u, false); if (baby == null) { return(null); } baby.SetAlienDNAPercentage(alienDNAPercentage); baby.GeneticHairstyleKey = geneticHairstyleKey; bool flag3 = false; if (num < Genetics.kInheritMomHiddenBodyHairStyleChance) { flag3 |= Genetics.InheritBodyHairstyle(baby, mom); } if (!flag3 || num < Genetics.kInheritDadBodyHairStyleChance + Genetics.kInheritMomHiddenBodyHairStyleChance) { Genetics.InheritBodyHairstyle(baby, dad); } if (customizeData.IsBabyCustomized) { Genetics.TraitOutcome traitOutcome = Genetics.AssignTraits(baby, dad, mom, false, averageMood, pregoRandom); List <TraitNames> list2 = new List <TraitNames>(); List <Trait> list3 = new List <Trait>(); foreach (Trait current in baby.TraitManager.List) { if (!current.IsVisible) { list3.Add(current); } } baby.TraitManager.RemoveAllElements(); if (customizeData.CurrentTraits != null) { foreach (ITraitEntryInfo current2 in customizeData.CurrentTraits) { baby.TraitManager.AddElement((TraitNames)current2.TraitGuid); } if (customizeData.CurrentTraits.Count != 2) { baby.TraitManager.AddRandomTrait(2 - customizeData.CurrentTraits.Count); } foreach (Trait current3 in list3) { baby.TraitManager.AddHiddenElement((TraitNames)current3.TraitGuid); } } foreach (Trait current4 in baby.TraitManager.List) { if (current4.IsVisible) { list2.Add((TraitNames)current4.TraitGuid); } } if (interactive) { bool isFemale = baby.IsFemale; string titleText = Localization.LocalizeString(baby.IsFemale, "Gameplay/CAS/Genetics:MakeBabyTitle", new object[0]); string promptText = null; switch (traitOutcome) { case Genetics.TraitOutcome.Horrible: { string entryKey = "Gameplay/CAS/Genetics:MakeBabyDescTwoTraitsHorrible"; promptText = Localization.LocalizeString(baby.IsFemale, entryKey, new object[] { robotMom == null ? mom : robotMom, baby.TraitManager.GetElement((ulong)list2[0]).TraitName(baby.IsFemale), baby.TraitManager.GetElement((ulong)list2[1]).TraitName(baby.IsFemale) }); break; } case Genetics.TraitOutcome.Bad: { string entryKey = "Gameplay/CAS/Genetics:MakeBabyDescTwoTraitsBad"; promptText = Localization.LocalizeString(baby.IsFemale, entryKey, new object[] { robotMom == null ? mom : robotMom, baby.TraitManager.GetElement((ulong)list2[0]).TraitName(baby.IsFemale), baby.TraitManager.GetElement((ulong)list2[1]).TraitName(baby.IsFemale) }); break; } case Genetics.TraitOutcome.Average: { string entryKey = "Gameplay/CAS/Genetics:MakeBabyDescTwoTraits"; promptText = Localization.LocalizeString(baby.IsFemale, entryKey, new object[] { robotMom == null ? mom : robotMom, baby.TraitManager.GetElement((ulong)list2[0]).TraitName(baby.IsFemale), baby.TraitManager.GetElement((ulong)list2[1]).TraitName(baby.IsFemale) }); break; } case Genetics.TraitOutcome.Good: { string entryKey = "Gameplay/CAS/Genetics:MakeBabyDescOneTraits"; promptText = Localization.LocalizeString(baby.IsFemale, entryKey, new object[] { robotMom == null ? mom : robotMom, baby.TraitManager.GetElement((ulong)list2[0]).TraitName(baby.IsFemale) }); break; } case Genetics.TraitOutcome.Excellent: { string entryKey = "Gameplay/CAS/Genetics:MakeBabyDesc"; promptText = Localization.LocalizeString(baby.IsFemale, entryKey, new object[] { robotMom == null ? mom : robotMom, }); break; } } while (string.IsNullOrEmpty(baby.FirstName)) { baby.FirstName = StringInputDialog.Show(titleText, promptText, "", CASBasics.GetMaxNameLength(), StringInputDialog.Validation.SimNameText); } } } else { Genetics.AssignTraits(baby, dad, mom, interactive, averageMood, pregoRandom); } if (setName) { baby.LastName = array[0].LastName; if (!interactive) { baby.FirstName = SimUtils.GetRandomGivenName(baby.IsMale, homeWorld); } } baby.CelebrityManager.SetBabyLevel(Genetics.AssignBabyCelebrityLevel(dad, mom)); if (updateGenealogy) { if (robotDad != null && robotMom == null) { if (robotDad.Genealogy != null) { robotDad.Genealogy.AddChild(baby.Genealogy); } if (mom != null && mom.Genealogy != null) { mom.Genealogy.AddChild(baby.Genealogy); } } else if (robotMom != null && robotDad == null) { if (robotMom.Genealogy != null) { robotMom.Genealogy.AddChild(baby.Genealogy); } if (dad != null && dad.Genealogy != null) { dad.Genealogy.AddChild(baby.Genealogy); } } else { if (robotDad.Genealogy != null) { robotDad.Genealogy.AddChild(baby.Genealogy); } if (robotMom.Genealogy != null) { robotMom.Genealogy.AddChild(baby.Genealogy); } } } OccultTypes occultTypes = OccultTypes.None; if (flag2) { if (mom != null) { CASSupernaturalData supernaturalData = mom.SupernaturalData; if (supernaturalData != null) { occultTypes = supernaturalData.OccultType; } } } else if (dad != null) { CASSupernaturalData supernaturalData2 = dad.SupernaturalData; if (supernaturalData2 != null) { occultTypes = supernaturalData2.OccultType; } } if (plantSimBaby) { occultTypes = OccultTypes.PlantSim; } if (!OccultManager.DoesOccultTransferToOffspring(occultTypes)) { occultTypes = OccultTypes.None; } if (RandomUtil.CoinFlip()) { if (occultTypes == OccultTypes.Fairy) { baby.AddSupernaturalData(OccultTypes.Fairy); CASFairyData fairyData = baby.SupernaturalData as CASFairyData; if (fairyData != null) { Vector3 wingColor; WingTypes wingType; Genetics.InheritWings(baby, mom, dad, pregoRandom, out wingColor, out wingType); fairyData.WingType = wingType; fairyData.WingColor = wingColor; } } if (occultTypes != OccultTypes.None) { baby.OccultManager.AddOccultType(occultTypes, false, false, false); } } return(baby); }
public override bool Run() { try { if (!Actor.RouteToObjectRadialRangeAndCheckInUse(Target, Target.MinorPetTuning.CaptureRouteRange[0x0], Target.MinorPetTuning.CaptureRouteRange[0x1])) { return(false); } bool escaped = Target.Escaped; StandardEntry(); EnterStateMachine("MinorPetCapture", "Enter", "x"); SetActor("pet", Target); SetParameter("petType", Target.Data.MinorPetType); BeginCommodityUpdates(); bool succeeded = escaped || RandomUtil.RandomChance01(Target.Data.CatchChance); if (succeeded) { Target.FadeOut(); Target.StopBehaviorSMC(); AnimateSim("Capture"); // Custom if (Actor.Inventory.TryToAdd(Target, false)) { string str; if (escaped) { str = Localization.LocalizeString(Actor.IsFemale, "Gameplay/Objects/MinorPets/Recapture:TNS", new object[] { Actor, Target.GetLocalizedName() }); } else { Target.Captured = true; string localizedPetType = MinorPet.GetLocalizedPetType(Target.Data.MinorPetType); string localizedPetRarity = MinorPet.GetLocalizedPetRarity(Target.Data.Rarity); str = Localization.LocalizeGenderString("Gameplay/Objects/MinorPets:CaptureTNS", new object[] { Actor, Actor, Target.LocalizedSpeciesName, localizedPetType, localizedPetRarity }); } Actor.ShowTNSIfSelectable(str, StyledNotification.NotificationStyle.kGameMessagePositive, ObjectGuid.InvalidObjectGuid, Actor.ObjectId); EventTracker.SendEvent(new MinorPetEvent(EventTypeId.kCaughtMinorPet, Actor, Target, Target.Data.MinorPetType)); using (List <Sim> .Enumerator enumerator = Actor.Household.Sims.GetEnumerator()) { while (enumerator.MoveNext()) { Sim current = enumerator.Current; EventTracker.SendEvent(new Event(EventTypeId.kArkBuilder, Actor, Target)); } } if (Target is IBird) { Tutorialette.TriggerLesson(Lessons.Birds, null); } else { Tutorialette.TriggerLesson(Lessons.MinorPets, null); } } else { mDestroyPet = true; } } else { Target.FadeOut(); mDestroyPet = true; bool flag3 = RandomUtil.CoinFlip(); AnimateSim(flag3 ? "CaptureFailBad" : "CaptureFail"); if (flag3) { Actor.BuffManager.AddElement(BuffNames.Bitten, Origin.FromUncapturedMinorPet); } } AnimateSim("Exit"); EndCommodityUpdates(succeeded); StandardExit(); return(succeeded); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
public static void OnMarried(Sim actor, Sim target, string interaction, ActiveTopic topic, InteractionInstance i) { try { string failReason = null; if ((actor.Household == target.Household) || (!MovingSituation.MovingInProgress && ((Household.ActiveHousehold == null) || InWorldSubState.IsEditTownValid(Household.ActiveHousehold.LotHome, ref failReason)))) { Sim actorSim; Sim targetSim; BuffManager actorBuffManager = actor.BuffManager; BuffManager targetBuffManager = target.BuffManager; actorBuffManager.AddElement(BuffNames.JustMarried, Origin.FromSocialization); targetBuffManager.AddElement(BuffNames.JustMarried, Origin.FromSocialization); BuffJustMarried.BuffInstanceJustMarried element = actorBuffManager.GetElement(BuffNames.JustMarried) as BuffJustMarried.BuffInstanceJustMarried; if (element != null) { element.CreateGiftAlarm(actorBuffManager); } actorBuffManager.RemoveElement(BuffNames.NewlyEngaged); actorBuffManager.RemoveElement(BuffNames.ParentsBlessing); targetBuffManager.RemoveElement(BuffNames.NewlyEngaged); targetBuffManager.RemoveElement(BuffNames.ParentsBlessing); ActiveTopic.AddToSim(actor, "Wedding"); ActiveTopic.AddToSim(target, "Wedding"); Relationship relationship = Relationship.Get(actor, target, true); relationship.LTR.RemoveInteractionBit(LongTermRelationship.InteractionBits.Divorce); relationship.LTR.AddInteractionBit(LongTermRelationship.InteractionBits.Marry); if (actor.IsNPC && !target.IsNPC) { actorSim = target; targetSim = actor; } else if (!actor.IsNPC && target.IsNPC) { actorSim = actor; targetSim = target; } else { SimDescription proposerDesc = relationship.ProposerDesc; actorSim = (proposerDesc == null) ? null : proposerDesc.CreatedSim; if (actorSim == null) { if (RandomUtil.CoinFlip()) { actorSim = actor; } else { actorSim = target; } } targetSim = target; if (actorSim == target) { targetSim = actor; } } SocialCallback.GiveDaysOffIfRequired(actorSim, targetSim); MidlifeCrisisManager.OnBecameMarried(actor.SimDescription, target.SimDescription); relationship.SetMarriedInGame(); if (SeasonsManager.Enabled) { relationship.WeddingAnniversary = new WeddingAnniversary(SeasonsManager.CurrentSeason, (int)SeasonsManager.DaysElapsed); relationship.WeddingAnniversary.SimA = relationship.SimDescriptionA; relationship.WeddingAnniversary.SimB = relationship.SimDescriptionB; relationship.WeddingAnniversary.CreateAlarm(); } if (sStoryProgressionHandleMarriageName.Valid) { sStoryProgressionHandleMarriageName.Invoke <bool>(new object[] { actorSim.SimDescription, targetSim.SimDescription }); } else { targetSim.SimDescription.LastName = actorSim.SimDescription.LastName; foreach (Genealogy genealogy in targetSim.Genealogy.Children) { SimDescription simDescription = genealogy.SimDescription; if (((simDescription != null) && simDescription.TeenOrBelow) && (simDescription.CreatedSim != null)) { simDescription.LastName = actorSim.SimDescription.LastName; } } } actor.Genealogy.Marry(target.Genealogy); OnMoveInWith(actor, target, interaction, topic, i); SocialCallback.EndServiceForActor(actor); SocialCallback.EndServiceForActor(target); actorBuffManager.RemoveElement(BuffNames.MissedWedding); targetBuffManager.RemoveElement(BuffNames.MissedWedding); } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(actor, target, e); } }
public static void AlienRefreshCallback() { string msg = "Alien Household Refresh" + Common.NewLine; if (Household.AlienHousehold == null) { msg += " - Alien household is null"; Common.DebugNotify(msg); return; } if (Household.AlienHousehold.NumMembers < AlienUtils.kAlienHouseholdNumMembers) { msg += " - Adding new alien" + Common.NewLine; CASAgeGenderFlags age = RandomUtil.GetRandomObjectFromList(Aliens.Settings.mValidAlienAges); CASAgeGenderFlags gender = RandomUtil.CoinFlip() ? CASAgeGenderFlags.Male : CASAgeGenderFlags.Female; SimDescription description = MakeAlien(age, gender, GameUtils.GetCurrentWorld(), 1f, true); if (Aliens.Settings.mAllowOccultAliens && RandomUtil.RandomChance(Aliens.Settings.mOccultAlienChance)) { msg += " -- Creating occult alien" + Common.NewLine; int numOccults = RandomUtil.GetInt(1, Aliens.Settings.mMaxAlienOccults); List <OccultTypes> validOccults = new List <OccultTypes>(Aliens.Settings.mValidAlienOccults); for (int i = 0; i < numOccults; i++) { if (validOccults.Count == 0) { break; } OccultTypes type = RandomUtil.GetRandomObjectFromList(validOccults); if (type != OccultTypes.Ghost) { OccultTypeHelper.Add(description, type, false, false); msg += " --- " + OccultTypeHelper.GetLocalizedName(type) + Common.NewLine; } else { SimDescription.DeathType deathType = RandomUtil.GetRandomObjectFromList((SimDescription.DeathType[])Enum.GetValues(typeof(SimDescription.DeathType))); Urnstones.SimToPlayableGhost(description, deathType); msg += " --- " + Urnstones.GetLocalizedString(description.IsFemale, deathType) + Common.NewLine; } validOccults.Remove(type); } } msg += " -- Adding baseline skills" + Common.NewLine; Skill element = null; element = description.SkillManager.AddElement(SkillNames.Logic); if (element != null) { element.ForceSkillLevelUp(RandomUtil.GetInt(Aliens.Settings.mLogicSkill[0], Aliens.Settings.mLogicSkill[1])); } msg += " --- " + element.Name + Common.NewLine; element = description.SkillManager.AddElement(SkillNames.Handiness); if (element != null) { element.ForceSkillLevelUp(RandomUtil.GetInt(Aliens.Settings.mHandinessSkill[0], Aliens.Settings.mHandinessSkill[1])); } msg += " --- " + element.Name + Common.NewLine; try { if (Aliens.Settings.mFutureSim) { msg += " -- Adding Adv Tech skill" + Common.NewLine; description.TraitManager.AddElement(TraitNames.FutureSim); element = description.SkillManager.AddElement(SkillNames.Future); if (element != null) { element.ForceSkillLevelUp(RandomUtil.GetInt(Aliens.Settings.mFutureSkill[0], Aliens.Settings.mFutureSkill[1])); } } } catch (Exception e) { Common.Exception("AlienUtilsEx.AlienRefresh" + Common.NewLine + " - Failed to add Adv Tech skill", e); } /* * if (age == CASAgeGenderFlags.Teen) * { * element = description.SkillManager.AddElement(SkillNames.LearnToDrive); * * if (element != null) * element.ForceSkillLevelUp(SkillManager.GetMaximumSupportedSkillLevel(SkillNames.LearnToDrive)); * } */ try { if (Aliens.Settings.mAlienScience) { msg += " -- Adding Science skill" + Common.NewLine; //Sim temp = description.InstantiateOffScreen(LotManager.GetFarthestLot(Household.ActiveHouseholdLot)); element = description.SkillManager.AddElement(SkillNames.Science); if (element != null) { element.ForceSkillLevelUp(RandomUtil.GetInt(Aliens.Settings.mScienceSkill[0], Aliens.Settings.mScienceSkill[1])); } //temp.Destroy(); } } catch (Exception e) { Common.Exception("AlienUtilsEx.AlienRefresh" + Common.NewLine + " - Failed to add Science skill", e); } try { if (OccultTypeHelper.HasType(description, OccultTypes.Fairy) || OccultTypeHelper.HasType(description, OccultTypes.PlantSim)) { msg += " -- Adding Gardening skill" + Common.NewLine; element = description.SkillManager.AddElement(SkillNames.Gardening); if (element != null) { element.ForceSkillLevelUp(RandomUtil.GetInt(3, 6)); } } } catch (Exception e) { Common.Exception("AlienUtilsEx.AlienRefresh" + Common.NewLine + " - Failed to add Gardening skill", e); } try { if (OccultTypeHelper.HasType(description, OccultTypes.Fairy)) { msg += " -- Adding Fairy Magic skill" + Common.NewLine; element = description.SkillManager.AddElement(SkillNames.FairyMagic); if (element != null) { element.ForceSkillLevelUp(RandomUtil.GetInt(Aliens.Settings.mFairyMagicSkill[0], Aliens.Settings.mFairyMagicSkill[1])); } } } catch (Exception e) { Common.Exception("AlienUtilsEx.AlienRefresh" + Common.NewLine + " - Failed to add Fairy Magic skill", e); } try { if (OccultTypeHelper.HasType(description, OccultTypes.Werewolf)) { msg += " -- Adding Lycanthropy skill" + Common.NewLine; element = description.SkillManager.AddElement(SkillNames.Lycanthropy); if (element != null) { element.ForceSkillLevelUp(RandomUtil.GetInt(Aliens.Settings.mLycanthropySkill[0], Aliens.Settings.mLycanthropySkill[1])); } } } catch (Exception e) { Common.Exception("AlienUtilsEx.AlienRefresh" + Common.NewLine + " - Failed to add Lycanthropy skill", e); } try { if (OccultTypeHelper.HasType(description, OccultTypes.Witch)) { msg += " -- Adding witch skills" + Common.NewLine; element = description.SkillManager.AddElement(SkillNames.Spellcasting); if (element != null) { element.ForceSkillLevelUp(RandomUtil.GetInt(3, 6)); } element = description.SkillManager.AddElement(SkillNames.Spellcraft); if (element != null) { element.ForceSkillLevelUp(RandomUtil.GetInt(3, 6)); } } } catch (Exception e) { Common.Exception("AlienUtilsEx.AlienRefresh" + Common.NewLine + " - Failed to add witch skills", e); } msg += " -- Adding alien to household"; Household.AlienHousehold.AddSilent(description); description.OnHouseholdChanged(Household.AlienHousehold, false); Common.DebugNotify(msg); } }
public override bool InRabbitHole() { try { ActiveStage.Start(); SimDescription choice = null; if (mMaster) { if (!AcceptCancelDialog.Show(Common.Localize("Rendezvous:Prompt", Actor.IsFemale, new object[] { KamaSimtra.Settings.mRendezvousCostPerLevel }))) { return(false); } Dictionary <int, List <SimDescription> > potentials = KamaSimtra.GetPotentials(Woohooer.Settings.AllowTeen(true)); List <SimDescription> choices = new List <SimDescription>(); for (int i = 1; i <= 10; i++) { List <SimDescription> fullList; if (!potentials.TryGetValue(i, out fullList)) { continue; } bool needFemale = false; if (Actor.SimDescription.CanAutonomouslyBeRomanticWithGender(CASAgeGenderFlags.Male)) { if (Actor.SimDescription.CanAutonomouslyBeRomanticWithGender(CASAgeGenderFlags.Female)) { if (RandomUtil.CoinFlip()) { needFemale = true; } } else { needFemale = false; } } else if (Actor.SimDescription.CanAutonomouslyBeRomanticWithGender(CASAgeGenderFlags.Female)) { needFemale = true; } else { needFemale = !Actor.IsFemale; } List <SimDescription> randomList = new List <SimDescription>(); foreach (SimDescription sim in fullList) { if (sim.IsFemale != needFemale) { continue; } if (sim.Household == Actor.Household) { continue; } string reason; GreyedOutTooltipCallback callback = null; if (!CommonSocials.CanGetRomantic(Actor.SimDescription, sim, false, true, true, ref callback, out reason)) { if (callback != null) { Common.DebugNotify(sim.FullName + Common.NewLine + callback()); } continue; } if (choices.Contains(sim)) { continue; } randomList.Add(sim); } if (randomList.Count > 0) { choices.Add(RandomUtil.GetRandomObjectFromList(randomList)); } } if (choices.Count == 0) { Common.Notify(Common.Localize("Rendezvous:NoneAvailable", Actor.IsFemale)); return(false); } choice = new SimSelection(Common.Localize("Rendezvous:MenuName"), Actor.SimDescription, choices, SimSelection.Type.Rendezvous, -1000).SelectSingle(); if (choice == null) { Common.Notify(Common.Localize("Rendezvous:NoSelect", Actor.IsFemale)); return(false); } if (Instantiation.PerformOffLot(choice, Target.LotCurrent, null) == null) { Common.Notify(Common.Localize("Rendezvous:BadSim", Actor.IsFemale, new object[] { choice })); return(false); } Rendezvous interaction = Singleton.CreateInstance(Target, choice.CreatedSim, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true) as Rendezvous; interaction.mMaster = false; interaction.LinkedInteractionInstance = this; choice.CreatedSim.InteractionQueue.CancelAllInteractions(); if (!choice.CreatedSim.InteractionQueue.AddNext(interaction)) { Common.Notify(Common.Localize("Rendezvous:BadSim", Actor.IsFemale, new object[] { choice })); return(false); } if (!DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), WaitPeriodLoop, null)) { Common.Notify(Common.Localize("Rendezvous:BadSim", Actor.IsFemale, new object[] { choice })); return(false); } if (!mBegin) { Common.Notify(Common.Localize("Rendezvous:BadSim", Actor.IsFemale, new object[] { choice })); return(false); } else { Actor.ClearExitReasons(); TimedStage stage = new TimedStage(GetInteractionName(), KamaSimtra.Settings.mRendezvousDuration, false, false, true); Stages = new List <Stage>(new Stage[] { stage }); ActiveStage = stage; ActiveStage.Start(); } } else { Rendezvous interaction = LinkedInteractionInstance as Rendezvous; if (interaction == null) { return(false); } interaction.mBegin = true; } if (mMaster) { if (!CelebrityManager.TryModifyFundsWithCelebrityDiscount(Actor, Target, KamaSimtra.Settings.mRendezvousCostPerLevel * choice.SkillManager.GetSkillLevel(KamaSimtra.StaticGuid), true)) { Common.Notify(Common.Localize("Rendezvous:CannotPay", Actor.IsFemale)); return(false); } Common.Notify(choice.CreatedSim, Common.Localize("Rendezvous:Success", Actor.IsFemale, choice.IsFemale, new object[] { choice })); KamaSimtra skill = KamaSimtra.EnsureSkill(Actor); if (skill != null) { skill.RendezvousActive = true; } } BeginCommodityUpdates(); bool succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)); EndCommodityUpdates(succeeded); if (KamaSimtra.Settings.mRandomRendezvousMoodlet) { Actor.BuffManager.AddElement(RandomUtil.GetRandomObjectFromList(sRandomBuffs), WoohooBuffs.sWoohooOrigin); } if (mMaster) { CommonWoohoo.WoohooLocation location = CommonWoohoo.WoohooLocation.RabbitHole; List <WoohooLocationControl> choices = CommonWoohoo.GetValidLocations(Actor.SimDescription); if (choices.Count > 0) { location = RandomUtil.GetRandomObjectFromList(choices).Location; } CommonWoohoo.RunPostWoohoo(Actor, choice.CreatedSim, Target, CommonWoohoo.WoohooStyle.Safe, location, false); } return(succeeded); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
protected override bool PrivateUpdate(ScenarioFrame frame) { bool wasMarried = Sim.IsMarried; if (!Romances.BumpToLowerState(this, Sim, Target, false)) { IncStat("Bump Fail"); return(false); } if (wasMarried) { if (GetValue <RenameDivorceeOption, bool>()) { RenameDivorcee(Sim); RenameDivorcee(Target); } } if (Sim.Household == Target.Household) { SimDescription go = Sim; SimDescription stay = Target; SimDescription head = SimTypes.HeadOfFamily(Sim.Household); if (head != null) { if (Relationships.IsCloselyRelated(Target, head, false)) { stay = Target; go = Sim; } else if (Relationships.IsCloselyRelated(Sim, head, false)) { stay = Sim; go = Target; } else if (RandomUtil.CoinFlip()) { stay = Sim; go = Target; } } HouseholdBreakdown.ChildrenMove goScore = HouseholdBreakdown.ChildrenMove.Scoring; HouseholdBreakdown.ChildrenMove stayScore = HouseholdBreakdown.ChildrenMove.Scoring; if (mAffair) { // Sim is cheater, so keep children with other parent if (go == Sim) { if (mRelatedStay) { goScore = HouseholdBreakdown.ChildrenMove.RelatedStay; stayScore = HouseholdBreakdown.ChildrenMove.RelatedGo; } else { goScore = HouseholdBreakdown.ChildrenMove.Stay; stayScore = HouseholdBreakdown.ChildrenMove.Go; } } else { if (mRelatedStay) { goScore = HouseholdBreakdown.ChildrenMove.RelatedGo; stayScore = HouseholdBreakdown.ChildrenMove.RelatedStay; } else { goScore = HouseholdBreakdown.ChildrenMove.Go; stayScore = HouseholdBreakdown.ChildrenMove.Stay; } } } Add(frame, new BreakupMoveOutScenario(go, stay, goScore), ScenarioResult.Failure); Add(frame, new BreakupMoveOutScenario(stay, go, stayScore), ScenarioResult.Failure); } return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { if (Sim.CreatedSim == null) { Sims.Instantiate(Sim, Sim.LotHome, false); } if (Target.CreatedSim == null) { Sims.Instantiate(Target, Target.LotHome, false); } if ((Sim.CreatedSim == null) || (Target.CreatedSim == null)) { IncStat("Uninstantiated"); return(false); } else { if (Sim.IsRobot) { if ((Sim.LotHome == null) || ((Sim.LotHome.CountObjects <BotMakingStation> () + Sim.LotHome.CountObjects <InventionWorkbench>()) == 0)) { IncStat("No Workbench"); return(false); } SimDescription child = null; if (Sim.IsFrankenstein) { bool reward = Sim.OccultManager.mIsLifetimeReward; if ((Target.IsFrankenstein) && (RandomUtil.CoinFlip())) { reward = Target.OccultManager.mIsLifetimeReward; } Sim childSim = OccultFrankenstein.CreateFrankenStein(Sim.CreatedSim, CASAgeGenderFlags.None, reward); if (childSim == null) { IncStat("Creation Fail"); return(false); } child = childSim.SimDescription; } else { child = OccultRobot.MakeRobot(CASAgeGenderFlags.Adult, CASAgeGenderFlags.None, RobotForms.MaxType); if (child == null) { IncStat("Creation Fail"); return(false); } CASRobotData supernaturalData = child.SupernaturalData as CASRobotData; if (supernaturalData != null) { supernaturalData.CreatorSim = Sim.SimDescriptionId; int quality = 0; int count = 0; CASRobotData parentData = Sim.SupernaturalData as CASRobotData; if (parentData != null) { quality = parentData.BotQualityLevel; count++; } parentData = Target.SupernaturalData as CASRobotData; if (parentData != null) { quality += parentData.BotQualityLevel; count++; } if (count == 2) { quality /= count; } supernaturalData.BotQualityLevel = quality; } } if (child.Genealogy.Parents.Count == 0) { Sim.Genealogy.AddChild(child.Genealogy); } Target.Genealogy.AddChild(child.Genealogy); if (!Households.MoveSim(child, Sim.Household)) { IncStat("Move Fail"); Deaths.CleansingKill(child, true); return(false); } return(true); } else if (Target.IsRobot) { IncStat("Simbot Partner"); return(false); } else { if (CommonSpace.Helpers.Pregnancies.Start(Sim.CreatedSim, Target, false) != null) { ManagerSim.ForceRecount(); if (Sim.IsHuman) { if (OnGatheringScenario != null) { OnGatheringScenario(this, frame); } } if ((!Sim.IsHuman) && (Sim.Partner != Target)) { if ((GetValue <AllowMarriageOption, bool>(Sim)) && (GetValue <AllowMarriageOption, bool>(Target))) { if ((Romances.AllowBreakup(this, Sim, Managers.Manager.AllowCheck.None)) && (Romances.AllowBreakup(this, Target, Managers.Manager.AllowCheck.None))) { RemoveAllPetMateFlags(Sim); RemoveAllPetMateFlags(Target); Relationship.Get(Sim, Target, false).LTR.AddInteractionBit(LongTermRelationship.InteractionBits.Marry); } } } } return(true); } } }