コード例 #1
0
ファイル: UnicornControl.cs プロジェクト: yakoder/NRaas
        protected override bool IsAvailable(Sim sim, IMagicalDefinition definition)
        {
            if (!base.IsAvailable(sim, definition))
            {
                return(false);
            }

            OccultUnicorn unicorn = sim.OccultManager.GetOccultType(OccultTypes.Unicorn) as OccultUnicorn;

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

            if (!unicorn.MagicPoints.HasPoints())
            {
                return(false);
            }

            if (GetMana(sim) - definition.SpellSettings.mMinMana <= 0)
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
        public override void ConsumeMana(Sim actor, IInteractionProxy proxy, IMagicalDefinition definition)
        {
            OccultUnicorn unicorn = actor.OccultManager.GetOccultType(OccultTypes.Unicorn) as OccultUnicorn;

            if (unicorn != null)
            {
                unicorn.MagicPoints.UsePoints((int)definition.SpellSettings.mMinMana);
                (Sims3.UI.Responder.Instance.HudModel as HudModel).FlashMagicMotiveBar();
            }
        }
コード例 #3
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);
        }
コード例 #4
0
        public override float GetMana(Sim sim)
        {
            OccultUnicorn unicorn = sim.OccultManager.GetOccultType(OccultTypes.Unicorn) as OccultUnicorn;

            if (unicorn == null)
            {
                return(0);
            }

            return(unicorn.MagicPoints.mCurrentMagicPointValue);
        }
コード例 #5
0
ファイル: SimDisplayEx.cs プロジェクト: yakoder/NRaas
        private static float GetMagicLevel(Sim actor, OccultTypes exclude, out OccultTypes selection)
        {
            if (exclude != OccultTypes.Fairy)
            {
                Motive motive = actor.Motives.GetMotive(CommodityKind.AuraPower);
                if (motive != null)
                {
                    selection = OccultTypes.Fairy;
                    return(motive.UIValue);
                }
            }

            if (exclude != OccultTypes.Witch)
            {
                Motive motive = actor.Motives.GetMotive(CommodityKind.MagicFatigue);
                if (motive != null)
                {
                    selection = OccultTypes.Witch;
                    return(-motive.UIValue);
                }
            }

            if (exclude != OccultTypes.Genie)
            {
                OccultGenie genie = actor.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;
                if (genie != null)
                {
                    selection = OccultTypes.Genie;
                    return((genie.MagicPoints.mCurrentMagicPointValue * 100) / genie.MagicPoints.mMaxMagicPoints);
                }
            }

            if (exclude != OccultTypes.Unicorn)
            {
                OccultUnicorn unicorn = actor.OccultManager.GetOccultType(OccultTypes.Unicorn) as OccultUnicorn;
                if (unicorn != null)
                {
                    selection = OccultTypes.Unicorn;
                    return((unicorn.MagicPoints.mCurrentMagicPointValue * 100) / unicorn.MagicPoints.mMaxMagicPoints);
                }
            }

            selection = OccultTypes.None;
            return(0);
        }
コード例 #6
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);
        }
コード例 #7
0
ファイル: Class1.cs プロジェクト: niec-and-linc/OpenDGS
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                SimDescription simDescription = a.SimDescription;

                if (simDescription.HasActiveRole && simDescription.AssignedRole.Type == Role.RoleType.Bouncer)
                {
                    return(false);
                }
                if (simDescription.IsBonehilda)
                {
                    return(false);
                }
                OccultGenie           occultGenie = a.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;
                OccultImaginaryFriend occultImaginaryFriend;

                return((occultGenie == null || !occultGenie.IsTiedToLamp) && (!OccultImaginaryFriend.TryGetOccultFromSim(a, out occultImaginaryFriend) || occultImaginaryFriend.IsReal) && (!simDescription.IsUnicorn || !OccultUnicorn.IsNPCPoolUnicorn(a)));
            }
コード例 #8
0
ファイル: OccultUnicornEx.cs プロジェクト: yakoder/NRaas
        public static void OnAddition(OccultUnicorn ths, SimDescription simDes, bool alterOutfit)
        {
            if (alterOutfit)
            {
                if (simDes.HorseManager == null)
                {
                    return;
                }

                Color[] maneColors = simDes.HorseManager.ActiveManeHairColors;
                simDes.HorseManager.ActiveUnicornBeardHairColors = maneColors;

                if (sParts == null)
                {
                    sParts = CASParts.GetParts(PartMatches);
                }

                List <CASParts.PartPreset> parts = new List <CASParts.PartPreset>();
                foreach (CASParts.Wrapper part in sParts)
                {
                    if (!part.ValidFor(simDes))
                    {
                        continue;
                    }

                    CASParts.PartPreset preset = part.GetRandomPreset();
                    if (preset == null)
                    {
                        continue;
                    }

                    parts.Add(preset);
                }

                if (parts.Count > 0)
                {
                    GeneticsPet.SpeciesSpecificData speciesData = new GeneticsPet.SpeciesSpecificData();
                    speciesData.UnicornBeardHairColors = simDes.HorseManager.ActiveUnicornBeardHairColors;

                    foreach (OutfitCategories category in simDes.ListOfCategories)
                    {
                        switch (category)
                        {
                        case OutfitCategories.All:
                        case OutfitCategories.CategoryMask:
                        case OutfitCategories.None:
                        case OutfitCategories.PrimaryCategories:
                        case OutfitCategories.PrimaryHorseCategories:
                        case OutfitCategories.Special:
                            continue;

                        default:
                            for (int i = 0x0; i < simDes.GetOutfitCount(category); i++)
                            {
                                using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(simDes, new CASParts.Key(category, i)))
                                {
                                    foreach (CASParts.PartPreset part in parts)
                                    {
                                        builder.Builder.RemoveParts(new BodyTypes[] { part.mPart.BodyType });
                                        builder.ApplyPartPreset(part);
                                        if (part.mPart.BodyType == BodyTypes.PetBeard)
                                        {
                                            OutfitUtils.AdjustPresetForHorseHairColor(builder.Builder, part.mPart, speciesData);
                                        }
                                    }
                                }
                            }
                            break;
                        }
                    }

                    if (simDes.CreatedSim != null)
                    {
                        simDes.CreatedSim.UpdateOutfitInfo();
                        simDes.CreatedSim.RefreshCurrentOutfit(false);
                    }
                }
            }
        }
コード例 #9
0
ファイル: OccultTypeHelper.cs プロジェクト: Robobeurre/NRaas
        // From OccultManager
        protected static bool AddOccultType(OccultManager ths, OccultTypes type, bool addOutfit, bool isReward, bool fromRestore, OccultBaseClass overrideOccultToAdd)
        {            
            OccultBaseClass newOccult = null;
            OccultBaseClass oldOccult = ths.VerifyOccultList(type);
            if (overrideOccultToAdd != null)
            {
                newOccult = overrideOccultToAdd;
            }
            else
            {
                switch (type)
                {
                    case OccultTypes.Mummy:
                        newOccult = new OccultMummy();
                        break;
                    case OccultTypes.Frankenstein:
                        newOccult = new OccultFrankenstein();
                        break;
                    case OccultTypes.Vampire:
                        newOccult = new OccultVampire();
                        break;
                    case OccultTypes.ImaginaryFriend:
                        OccultImaginaryFriend oldImFr = oldOccult as OccultImaginaryFriend;
                        if (oldImFr == null)
                        {
                            newOccult = new OccultImaginaryFriend();
                        }
                        else
                        {
                            newOccult = new OccultImaginaryFriend(oldImFr);
                        }
                        break;
                    case OccultTypes.Unicorn:
                        newOccult = new OccultUnicorn();
                        break;
                    case OccultTypes.Fairy:
                        newOccult = new OccultFairy();
                        break;
                    case OccultTypes.Witch:
                        newOccult = new OccultWitch();
                        break;
                    case OccultTypes.Genie:
                        newOccult = new OccultGenie();
                        break;
                    case OccultTypes.Werewolf:
                        newOccult = new OccultWerewolf();
                        break;
                    case OccultTypes.PlantSim:
                        newOccult = new OccultPlantSim();
                        break;
                    case OccultTypes.Mermaid:
                        newOccult = new OccultMermaid();
                        break;
                    case OccultTypes.TimeTraveler:
                        newOccult = new OccultTimeTraveler();
                        break;
                    case OccultTypes.Robot:
                        newOccult = new OccultRobot();
                        break;
                }
            }

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

            OccultTypes originalTypes = ths.mCurrentOccultTypes;
            Role assignedRole = ths.mOwnerDescription.AssignedRole;
            float alienDNAPercentage = ths.mOwnerDescription.AlienDNAPercentage;

            try
            {
                ths.mCurrentOccultTypes = OccultTypes.None;
                ths.mOwnerDescription.AssignedRole = null;
                ths.mOwnerDescription.mAlienDNAPercentage = 0f;

                if (!newOccult.CanAdd(ths.mOwnerDescription, fromRestore))
                {
                    return false;
                }
            }
            finally
            {
                ths.mCurrentOccultTypes = originalTypes;
                ths.mOwnerDescription.AssignedRole = assignedRole;
                ths.mOwnerDescription.mAlienDNAPercentage = alienDNAPercentage;
            }

            if ((ths.mOwnerDescription.SupernaturalData == null) ||
                ((type == OccultTypes.Fairy) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.Fairy)) ||
                ((type == OccultTypes.Robot) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.Robot)) ||
                ((type == OccultTypes.PlantSim) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.PlantSim)))
            {
                ths.mOwnerDescription.AddSupernaturalData(type);
            }

            ths.mIsLifetimeReward = isReward;

            if (type == OccultTypes.Genie)
            {
                // Corrections for improper handling of the special outfits by OccultGenie
                if (ths.mOwnerDescription.mSpecialOutfitIndices == null)
                {
                    ths.mOwnerDescription.mSpecialOutfitIndices = new Dictionary<uint, int>();
                }

                addOutfit = false;
            }

            if (type == OccultTypes.Unicorn)
            {
                OccultUnicornEx.OnAddition(newOccult as OccultUnicorn, ths.mOwnerDescription, addOutfit);
            }

            ApplyTrait(ths.mOwnerDescription, type);

            MidlifeCrisisManager midlifeCrisisManager = ths.mOwnerDescription.MidlifeCrisisManager;

            try
            {
                // Inactive mummies don't agree with mid-life crisis managers
                ths.mOwnerDescription.MidlifeCrisisManager = null;

                newOccult.OnAddition(ths.mOwnerDescription, addOutfit, ths.mIsLifetimeReward, fromRestore);
            }
            finally
            {
                ths.mOwnerDescription.MidlifeCrisisManager = midlifeCrisisManager;
            }

            ths.mOccultList.Add(newOccult);
            ths.mCurrentOccultTypes |= type;
            EventTracker.SendEvent(new BeAnOccultEvent(EventTypeId.kBeAnOccult, ths.mOwnerDescription.CreatedSim, (uint)type));
            if (ths.mOwnerDescription.CreatedSim != null)
            {
                if (!Cane.IsAllowedToUseCane(ths.mOwnerDescription.CreatedSim))
                {
                    Cane.StopUsingAnyActiveCanes(ths.mOwnerDescription.CreatedSim);
                }
                if (!Backpack.IsAllowedToUseBackpack(ths.mOwnerDescription.CreatedSim))
                {
                    Backpack.StopUsingAnyActiveBackpacks(ths.mOwnerDescription.CreatedSim);
                }
                if (!Jetpack.IsAllowedToUseJetpack(ths.mOwnerDescription.CreatedSim))
                {
                    Jetpack.StopUsingAnyActiveJetpacks(ths.mOwnerDescription.CreatedSim);
                }
            }

            (Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged();
            ths.ClearOneShot();
            ths.UpdateOccultUI();            
            if (!fromRestore)
            {
                EventTracker.SendEvent(EventTypeId.kBecameOccult, ths.mOwnerDescription.CreatedSim);                
            }

            if (oldOccult != null)
            {
                newOccult.MergeOccultData(oldOccult);
            }

            if (ths.mOwnerDescription.CreatedSim != null)
            {
                Sim.StandingPosture standing = ths.mOwnerDescription.CreatedSim.Standing as Sim.StandingPosture;
                if (standing != null)
                {
                    standing.SetDefaultIdleAnim();
                }
            }

            return true;
        }
コード例 #10
0
ファイル: OccultTypeHelper.cs プロジェクト: yakoder/NRaas
        // From OccultManager
        protected static bool AddOccultType(OccultManager ths, OccultTypes type, bool addOutfit, bool isReward, bool fromRestore, OccultBaseClass overrideOccultToAdd)
        {
            OccultBaseClass newOccult = null;
            OccultBaseClass oldOccult = ths.VerifyOccultList(type);

            if (overrideOccultToAdd != null)
            {
                newOccult = overrideOccultToAdd;
            }
            else
            {
                switch (type)
                {
                case OccultTypes.Mummy:
                    newOccult = new OccultMummy();
                    break;

                case OccultTypes.Frankenstein:
                    newOccult = new OccultFrankenstein();
                    break;

                case OccultTypes.Vampire:
                    newOccult = new OccultVampire();
                    break;

                case OccultTypes.ImaginaryFriend:
                    OccultImaginaryFriend oldImFr = oldOccult as OccultImaginaryFriend;
                    if (oldImFr == null)
                    {
                        newOccult = new OccultImaginaryFriend();
                    }
                    else
                    {
                        newOccult = new OccultImaginaryFriend(oldImFr);
                    }
                    break;

                case OccultTypes.Unicorn:
                    newOccult = new OccultUnicorn();
                    break;

                case OccultTypes.Fairy:
                    newOccult = new OccultFairy();
                    break;

                case OccultTypes.Witch:
                    newOccult = new OccultWitch();
                    break;

                case OccultTypes.Genie:
                    newOccult = new OccultGenie();
                    break;

                case OccultTypes.Werewolf:
                    newOccult = new OccultWerewolf();
                    break;

                case OccultTypes.PlantSim:
                    newOccult = new OccultPlantSim();
                    break;

                case OccultTypes.Mermaid:
                    newOccult = new OccultMermaid();
                    break;

                case OccultTypes.TimeTraveler:
                    newOccult = new OccultTimeTraveler();
                    break;

                case OccultTypes.Robot:
                    newOccult = new OccultRobot();
                    break;
                }
            }

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

            OccultTypes originalTypes      = ths.mCurrentOccultTypes;
            Role        assignedRole       = ths.mOwnerDescription.AssignedRole;
            float       alienDNAPercentage = ths.mOwnerDescription.AlienDNAPercentage;

            try
            {
                ths.mCurrentOccultTypes                   = OccultTypes.None;
                ths.mOwnerDescription.AssignedRole        = null;
                ths.mOwnerDescription.mAlienDNAPercentage = 0f;

                if (!newOccult.CanAdd(ths.mOwnerDescription, fromRestore))
                {
                    return(false);
                }
            }
            finally
            {
                ths.mCurrentOccultTypes                   = originalTypes;
                ths.mOwnerDescription.AssignedRole        = assignedRole;
                ths.mOwnerDescription.mAlienDNAPercentage = alienDNAPercentage;
            }

            if ((ths.mOwnerDescription.SupernaturalData == null) ||
                ((type == OccultTypes.Fairy) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.Fairy)) ||
                ((type == OccultTypes.Robot) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.Robot)) ||
                ((type == OccultTypes.PlantSim) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.PlantSim)))
            {
                ths.mOwnerDescription.AddSupernaturalData(type);
            }

            ths.mIsLifetimeReward = isReward;

            if (type == OccultTypes.Genie)
            {
                // Corrections for improper handling of the special outfits by OccultGenie
                if (ths.mOwnerDescription.mSpecialOutfitIndices == null)
                {
                    ths.mOwnerDescription.mSpecialOutfitIndices = new Dictionary <uint, int>();
                }

                addOutfit = false;
            }

            if (type == OccultTypes.Unicorn)
            {
                OccultUnicornEx.OnAddition(newOccult as OccultUnicorn, ths.mOwnerDescription, addOutfit);
            }

            ApplyTrait(ths.mOwnerDescription, type);

            MidlifeCrisisManager midlifeCrisisManager = ths.mOwnerDescription.MidlifeCrisisManager;

            try
            {
                // Inactive mummies don't agree with mid-life crisis managers
                ths.mOwnerDescription.MidlifeCrisisManager = null;

                newOccult.OnAddition(ths.mOwnerDescription, addOutfit, ths.mIsLifetimeReward, fromRestore);
            }
            finally
            {
                ths.mOwnerDescription.MidlifeCrisisManager = midlifeCrisisManager;
            }

            ths.mOccultList.Add(newOccult);
            ths.mCurrentOccultTypes |= type;
            EventTracker.SendEvent(new BeAnOccultEvent(EventTypeId.kBeAnOccult, ths.mOwnerDescription.CreatedSim, (uint)type));
            if (ths.mOwnerDescription.CreatedSim != null)
            {
                if (!Cane.IsAllowedToUseCane(ths.mOwnerDescription.CreatedSim))
                {
                    Cane.StopUsingAnyActiveCanes(ths.mOwnerDescription.CreatedSim);
                }
                if (!Backpack.IsAllowedToUseBackpack(ths.mOwnerDescription.CreatedSim))
                {
                    Backpack.StopUsingAnyActiveBackpacks(ths.mOwnerDescription.CreatedSim);
                }
                if (!Jetpack.IsAllowedToUseJetpack(ths.mOwnerDescription.CreatedSim))
                {
                    Jetpack.StopUsingAnyActiveJetpacks(ths.mOwnerDescription.CreatedSim);
                }
            }

            (Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged();
            ths.ClearOneShot();
            ths.UpdateOccultUI();
            if (!fromRestore)
            {
                EventTracker.SendEvent(EventTypeId.kBecameOccult, ths.mOwnerDescription.CreatedSim);
            }

            if (oldOccult != null)
            {
                newOccult.MergeOccultData(oldOccult);
            }

            if (ths.mOwnerDescription.CreatedSim != null)
            {
                Sim.StandingPosture standing = ths.mOwnerDescription.CreatedSim.Standing as Sim.StandingPosture;
                if (standing != null)
                {
                    standing.SetDefaultIdleAnim();
                }
            }

            return(true);
        }
コード例 #11
0
ファイル: OccultUnicornEx.cs プロジェクト: Robobeurre/NRaas
        public static void OnAddition(OccultUnicorn ths, SimDescription simDes, bool alterOutfit)
        {
            if (alterOutfit)
            {
                if (simDes.HorseManager == null)
                {
                    return;
                }

                Color[] maneColors = simDes.HorseManager.ActiveManeHairColors;
                simDes.HorseManager.ActiveUnicornBeardHairColors = maneColors;

                if (sParts == null)
                {
                    sParts = CASParts.GetParts(PartMatches);
                }

                List<CASParts.PartPreset> parts = new List<CASParts.PartPreset>();
                foreach (CASParts.Wrapper part in sParts)
                {
                    if (!part.ValidFor(simDes)) continue;

                    CASParts.PartPreset preset = part.GetRandomPreset();
                    if (preset == null) continue;

                    parts.Add(preset);
                }

                if (parts.Count > 0)
                {
                    GeneticsPet.SpeciesSpecificData speciesData = new GeneticsPet.SpeciesSpecificData();
                    speciesData.UnicornBeardHairColors = simDes.HorseManager.ActiveUnicornBeardHairColors;

                    foreach (OutfitCategories category in simDes.ListOfCategories)
                    {
                        switch (category)
                        {
                            case OutfitCategories.All:
                            case OutfitCategories.CategoryMask:
                            case OutfitCategories.None:
                            case OutfitCategories.PrimaryCategories:
                            case OutfitCategories.PrimaryHorseCategories:
                            case OutfitCategories.Special:
                                continue;
                            default:
                                for (int i = 0x0; i < simDes.GetOutfitCount(category); i++)
                                {
                                    using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(simDes, new CASParts.Key(category, i)))
                                    {
                                        foreach (CASParts.PartPreset part in parts)
                                        {
                                            builder.Builder.RemoveParts(new BodyTypes[] { part.mPart.BodyType });
                                            builder.ApplyPartPreset(part);
                                            if (part.mPart.BodyType == BodyTypes.PetBeard)
                                            {
                                                OutfitUtils.AdjustPresetForHorseHairColor(builder.Builder, part.mPart, speciesData);
                                            }
                                        }
                                    }
                                }
                                break;
                        }
                    }

                    if (simDes.CreatedSim != null)
                    {
                        simDes.CreatedSim.UpdateOutfitInfo();
                        simDes.CreatedSim.RefreshCurrentOutfit(false);
                    }
                }
            }
        }