public override void CheckForGhostBaby(Sim s) { if ((mMomWasGhostFromPotion || mDadWasGhostFromPotion) && RandomUtil.RandomChance(kChanceForGhostBaby)) { Urnstones.SimToPlayableGhost(s.SimDescription, SimDescription.DeathType.OldAge); } }
protected override bool Run(SimDescription me, bool singleSelection) { if (!base.Run(me, singleSelection)) { return(false); } foreach (SelectionCriteria.Occult.Values type in mTypes) { if (type.mOccult != OccultTypes.None) { OccultTypeHelper.Add(me, type.mOccult, false, true); } else { Urnstones.SimToPlayableGhost(me, type.mDeathType); } } return(true); }
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 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); }