예제 #1
0
        protected virtual bool IsAvailable(Sim sim, IMagicalDefinition definition)
        {
            if ((Occult & definition.SpellSettings.mValidTypes) == OccultTypes.None)
            {
                return(false);
            }

            if (!OccultTypeHelper.HasType(sim, Occult))
            {
                return(false);
            }

            if (GetSkillLevel(sim.SimDescription) < GetMinSkillLevel(definition))
            {
                return(false);
            }

            //if (GetMana(sim) + definition.SpellSettings.mMinMana >= 100) return false;

            // fairy starts at 100 and goes to -100 for empty
            // witch at -100 and goes to 100 for empty
            // genie and unicorns are 0 for empty, 100 for full

            return(true);
        }
예제 #2
0
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (!OccultTypeHelper.HasType(a, OccultTypes.Unicorn))
                {
                    return(false);
                }

                return(base.Test(a, target, isAutonomous, ref greyedOutTooltipCallback));
            }
예제 #3
0
            public override bool Test(Sim a, TanningBooth target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (OccultTypeHelper.HasType(a, OccultTypes.Vampire | OccultTypes.ImaginaryFriend | OccultTypes.Werewolf | OccultTypes.Robot | OccultTypes.Frankenstein | OccultTypes.Mummy))
                {
                    return(false);
                }

                return(base.Test(a, target, isAutonomous, ref greyedOutTooltipCallback));
            }
예제 #4
0
            public override bool Test(Sim a, IFishContainer target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (!OccultTypeHelper.HasType(a, OccultTypes.Mermaid))
                {
                    return(false);
                }

                return(base.Test(a, target, isAutonomous, ref greyedOutTooltipCallback));
            }
예제 #5
0
        private static bool PrivateUsePoints(Sim sim, MagicWand wand, int points, OccultTypes type)
        {
            if (!OccultTypeHelper.HasType(sim, type))
            {
                return(false);
            }

            switch (type)
            {
            case OccultTypes.Genie:
                OccultGenie genie = sim.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;
                if (genie != null)
                {
                    genie.MagicPoints.UsePoints(points);
                    (Sims3.UI.Responder.Instance.HudModel as HudModel).FlashMagicMotiveBar();
                    return(true);
                }
                break;

            case OccultTypes.Fairy:
                sim.Motives.ChangeValue(CommodityKind.AuraPower, -points);
                (Sims3.UI.Responder.Instance.HudModel as HudModel).FlashMagicMotiveBar();
                return(true);

            case OccultTypes.Witch:
                if (wand != null)
                {
                    wand.DrainMotive(sim, CommodityKind.MagicFatigue, -points);
                    return(true);
                }
                else
                {
                    float num = (points * DefaultWand.kMotiveDrainMultiplier) * MagicWand.kMoonPhaseMotiveDrainMultiplier[World.GetLunarPhase()];
                    if (sim.BuffManager.HasElement(BuffNames.AnimalFamiliar))
                    {
                        num *= MagicWand.kFamiliarMotiveMultiplier;
                    }
                    sim.Motives.ChangeValue(CommodityKind.MagicFatigue, -num);
                    (Sims3.UI.Responder.Instance.HudModel as HudModel).FlashMagicMotiveBar();
                }
                break;

            case OccultTypes.Unicorn:
                OccultUnicorn unicorn = sim.OccultManager.GetOccultType(OccultTypes.Unicorn) as OccultUnicorn;
                if (unicorn != null)
                {
                    unicorn.MagicPoints.UsePoints(points);
                    (Sims3.UI.Responder.Instance.HudModel as HudModel).FlashMagicMotiveBar();
                    return(true);
                }
                break;
            }

            return(false);
        }
예제 #6
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("CleanupOccult");

            foreach (SimDescription sim in Household.AllSimsLivingInWorld())
            {
                OccultTypeHelper.ValidateOccult(sim, Overwatch.Log);

                OccultTypeHelper.TestAndRebuildWerewolfOutfit(sim);

                // Compensate for a missing line in OccultWerewolf:FixupOccult
                if ((sim.CreatedSim != null) && (sim.ToddlerOrAbove) && (OccultTypeHelper.HasType(sim, OccultTypes.Werewolf)))
                {
                    World.ObjectSetVisualOverride(sim.CreatedSim.ObjectId, eVisualOverrideTypes.Werewolf, null);
                }
            }
        }
예제 #7
0
            public override bool Test(Sim a, GameObject target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (a.SimDescription.Toddler)
                {
                    if (!a.SimDescription.HasTrait(TraitNames.LycanthropyHuman))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!OccultTypeHelper.HasType(a, OccultTypes.Werewolf))
                    {
                        return(false);
                    }
                }

                return(base.Test(a, target, isAutonomous, ref greyedOutTooltipCallback));
            }
예제 #8
0
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if ((isAutonomous) && (a == target))
                {
                    if (OccultTypeHelper.HasType(a, OccultTypes.Vampire))
                    {
                        return(false);
                    }
                }

                MagicControl control = MagicControl.GetBestControl(a, this);

                if (control == null)
                {
                    greyedOutTooltipCallback = Common.DebugTooltip("No Control");
                    return(false);
                }

                return(CastSpellEx.CommonSpellTests(a, target, isAutonomous, ref greyedOutTooltipCallback));
            }
예제 #9
0
        private static bool PrivateIsFailure(IMagicalInteraction interaction, OccultTypes testType, out bool fail, out bool epicFailure)
        {
            fail        = false;
            epicFailure = false;

            if (!OccultTypeHelper.HasType(interaction.Actor, testType))
            {
                return(false);
            }

            switch (testType)
            {
            case OccultTypes.Witch:
                SpellcastingSkill spellcasting = interaction.Actor.SkillManager.GetElement(SkillNames.Spellcasting) as SpellcastingSkill;
                MagicWand         wand         = MagicWand.GetWandToUse(interaction.Actor, spellcasting);
                if (wand != null)
                {
                    fail = RandomUtil.RandomChance(wand.SuccessChance(interaction.Actor, interaction.SpellLevel, spellcasting.SkillLevel));
                    if (!fail)
                    {
                        epicFailure = RandomUtil.RandomChance(wand.EpicFailChance(interaction.Actor));
                    }
                }
                break;

            case OccultTypes.Fairy:
                if (interaction.SpellLevel <= interaction.Actor.SkillManager.GetSkillLevel(SkillNames.FairyMagic))
                {
                    fail = true;
                }
                break;

            case OccultTypes.Genie:
            case OccultTypes.Unicorn:
                return(false);
            }

            return(fail);
        }
예제 #10
0
        private static bool PrivateHasPoints(Sim sim, OccultTypes type, bool allowFailure)
        {
            if (!OccultTypeHelper.HasType(sim, type))
            {
                return(false);
            }

            switch (type)
            {
            case OccultTypes.Genie:
                OccultGenie genie = sim.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;
                if (genie != null)
                {
                    return(genie.MagicPoints.HasPoints());
                }
                break;

            case OccultTypes.Fairy:
                return(!sim.BuffManager.HasElement(BuffNames.FairyAuraFailure));

            case OccultTypes.Witch:
                if (allowFailure)
                {
                    return(true);
                }

                return(!sim.BuffManager.HasElement(BuffNames.DepletedMagic));

            case OccultTypes.Unicorn:
                OccultUnicorn unicorn = sim.OccultManager.GetOccultType(OccultTypes.Unicorn) as OccultUnicorn;
                if (unicorn != null)
                {
                    return(unicorn.MagicPoints.HasPoints());
                }
                break;
            }

            return(false);
        }
예제 #11
0
        protected virtual bool IsAvailable(Sim sim, IMagicalDefinition definition)
        {
            if ((Occult & definition.SpellSettings.mValidTypes) == OccultTypes.None)
            {
                return(false);
            }

            if (!OccultTypeHelper.HasType(sim, Occult))
            {
                return(false);
            }

            if (GetSkillLevel(sim.SimDescription) < GetMinSkillLevel(definition))
            {
                return(false);
            }

            if (GetMana(sim) + definition.SpellSettings.mMinMana >= 100)
            {
                return(false);
            }

            return(true);
        }
예제 #12
0
        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);
            }
        }
예제 #13
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);
        }
예제 #14
0
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (!OccultTypeHelper.HasType(a, OccultTypes.Genie))
                {
                    return(false);
                }

                if (target.LotHome != null)
                {
                    if (Households.All(target.Household).Count <= 1)
                    {
                        return(false);
                    }
                }

                OccultGenie occultType = a.SimDescription.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;

                if (target.SimDescription.IsBonehilda)
                {
                    return(false);
                }

                if (((target.Service != null) && (target.Service.ServiceType == ServiceType.GrimReaper)) || (target.Household == a.Household))
                {
                    return(false);
                }

                if (DaycareSituation.IsInDaycareSituationWith(target, a))
                {
                    return(false);
                }

                if ((target.BuffManager.HasElement(BuffNames.WeddingDay) || target.IsEngaged) || target.SimDescription.IsPregnant)
                {
                    return(false);
                }

                if (GameUtils.IsOnVacation())
                {
                    return(false);
                }

                if (((isAutonomous || (occultType == null)) || (target.OccultManager.HasOccultType(OccultTypes.Genie) || target.BuffManager.HasElement(BuffNames.Ensorcelled))) || !a.SimDescription.ChildOrAbove)
                {
                    return(false);
                }

                if (!occultType.MagicPoints.HasPoints())
                {
                    greyedOutTooltipCallback = delegate
                    {
                        return(Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/GenieOutOfPoints:OutOfPoints", new object[] { a }));
                    };
                    return(false);
                }

                /*
                 * if (!a.Household.CanAddSpeciesToHousehold(CASAgeGenderFlags.Human))
                 * {
                 *  greyedOutTooltipCallback = delegate
                 *  {
                 *      return Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/EnsorcelFail:HouseholdFull", new object[] { a });
                 *  };
                 *  return false;
                 * }
                 *
                 * if (!a.Household.CanAddSpeciesToHousehold(target.SimDescription.Species, 0x1, true))
                 * {
                 *  greyedOutTooltipCallback = delegate {
                 *      return Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/EnsorcelFail:UnableToJoinHousehold", new object[] { a });
                 *  };
                 *  return false;
                 * }
                 */
                if (target.SimDescription.ToddlerOrBelow)
                {
                    return(false);
                }

                if (target.Household.IsServiceNpcHousehold && (target.SimDescription.CreatedByService != null))
                {
                    greyedOutTooltipCallback = delegate
                    {
                        return(Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/EnsorcelFail:UnableToJoinHousehold", new object[] { a }));
                    };
                    return(false);
                }

                if (target.SimDescription.IsDead || ((target.SimDescription.Service != null) && (target.SimDescription.Service.ServiceType == ServiceType.GrimReaper)))
                {
                    greyedOutTooltipCallback = delegate {
                        return(Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/EnsorcelFail:UnableToJoinHousehold", new object[] { a }));
                    };
                    return(false);
                }

                /*
                 * if (target.SimDescription.AssignedRole != null)
                 * {
                 *  RoleData data = target.SimDescription.AssignedRole.Data;
                 *  if ((data != null) && !data.CanBeEnsorceled)
                 *  {
                 *      greyedOutTooltipCallback = delegate
                 *      {
                 *          return Localization.LocalizeString(a.IsFemale, "Gameplay/Actors/Sim/EnsorcelFail:UnableToJoinHousehold", new object[] { a });
                 *      };
                 *      return false;
                 *  }
                 * }
                 */
                return(true);
            }
예제 #15
0
            public override bool Test(Sim a, Fish target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (!OccultTypeHelper.HasType(a, OccultTypes.Mermaid)) return false;

                return base.Test(a, target, isAutonomous, ref greyedOutTooltipCallback);
            }