Пример #1
0
        public override void Perform(SimDescription sim, OccultBaseClass sourceParam)
        {
            OccultVampire occult = sim.OccultManager.GetOccultType(sourceParam.ClassOccultType) as OccultVampire;
            OccultVampire source = sourceParam as OccultVampire;

            if (source.mSimsDrunkFrom != null)
            {
                occult.mSimsDrunkFrom = new List <ulong>(source.mSimsDrunkFrom);
            }

            if (source.mSimsMadeThoughtAbout != null)
            {
                occult.mSimsMadeThoughtAbout = new List <ulong>(source.mSimsMadeThoughtAbout);
            }

            if (source.mSimsMindRead != null)
            {
                occult.mSimsMindRead = new List <ulong>(source.mSimsMindRead);
            }

            if (source.mSimsTurned != null)
            {
                occult.mSimsTurned = new List <ulong>(source.mSimsTurned);
            }
        }
Пример #2
0
        public static void ResetSkillModifiers(SimDescription sim)
        {
            if (sim.SkillManager == null)
            {
                return;
            }

            Corrections.CorrectOverallSkillModifier(sim);

            sim.SkillManager.mSkillModifiers = new Dictionary <SkillNames, float>();

            TraitManager traitManager = sim.TraitManager;

            if (traitManager != null)
            {
                foreach (Trait trait in traitManager.List)
                {
                    traitManager.AddTraitSkillGainModifiers(sim, trait.Guid);
                }
            }

            Dictionary <GameObject, bool> inventory = new Dictionary <GameObject, bool>();

            if ((sim.CreatedSim != null) && (sim.CreatedSim.Inventory != null))
            {
                foreach (GameObject obj in Inventories.QuickFind <GameObject>(sim.CreatedSim.Inventory))
                {
                    inventory.Add(obj, true);
                }
            }

            ulong eventId = (ulong)EventTypeId.kSkillLearnedSkill;

            Dictionary <ulong, List <EventListener> > events;

            if (!EventTracker.Instance.mListeners.TryGetValue(eventId, out events))
            {
                events = null;
            }
            else
            {
                EventTracker.Instance.mListeners.Remove(eventId);
            }

            if ((sim.CreatedSim != null) && (!sim.CreatedSim.HasBeenDestroyed))
            {
                foreach (Skill skill in sim.SkillManager.List)
                {
                    bool isChangingWorlds = GameStates.sIsChangingWorlds;

                    // Workaround for issue in IsIdTravelling
                    GameStates.sIsChangingWorlds = false;
                    try
                    {
                        skill.OnSkillAddition(true);
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, null, "Skill: " + skill.Guid.ToString(), e);
                    }
                    finally
                    {
                        GameStates.sIsChangingWorlds = isChangingWorlds;
                    }
                }
            }

            if (events != null)
            {
                EventTracker.Instance.mListeners.Add(eventId, events);
            }

            if ((sim.CreatedSim != null) && (sim.CreatedSim.Inventory != null))
            {
                foreach (GameObject obj in Inventories.QuickFind <GameObject>(sim.CreatedSim.Inventory))
                {
                    if (inventory.ContainsKey(obj))
                    {
                        continue;
                    }

                    try
                    {
                        sim.CreatedSim.Inventory.RemoveByForce(obj);
                        obj.Destroy(); // Do not use FadeOut(), it hangs the game
                    }
                    catch
                    { }
                }
            }

            if (sim.OccultManager != null)
            {
                OccultVampire vampire = sim.OccultManager.GetOccultType(OccultTypes.Vampire) as OccultVampire;
                if ((vampire != null) && (vampire.AppliedNightBenefits))
                {
                    try
                    {
                        if ((sim.CreatedSim != null) && (!sim.CreatedSim.HasBeenDestroyed))
                        {
                            vampire.SunsetCallback();
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, e);
                    }
                }
            }
        }
Пример #3
0
        protected override void PrivatePerformAction(bool prompt)
        {
            try
            {
                Overwatch.Log("Cleanup Skill Modifiers");

                float vampireTotal = OccultVampire.kSkillGainModifierArtistic;
                vampireTotal += OccultVampire.kSkillGainModifierCreative;
                vampireTotal += OccultVampire.kSkillGainModifierMental;
                vampireTotal += OccultVampire.kSkillGainModifierMusical;
                vampireTotal += OccultVampire.kSkillGainModifierPhysical;

                float vampireAverage = vampireTotal / 5;

                foreach (SimDescription sim in Household.EverySimDescription())
                {
                    try
                    {
                        if (sim.SkillManager == null)
                        {
                            continue;
                        }

                        float maxMultiplier = 2;

                        OccultVampire vampire = sim.OccultManager.GetOccultType(OccultTypes.Vampire) as OccultVampire;
                        if ((vampire != null) && (vampire.AppliedNightBenefits))
                        {
                            maxMultiplier += vampireAverage;
                        }

                        if (sim.SkillManager.mSkillModifiers != null)
                        {
                            bool recompute = false;

                            foreach (KeyValuePair <SkillNames, float> modifier in sim.SkillManager.mSkillModifiers)
                            {
                                if (modifier.Value > maxMultiplier)
                                {
                                    recompute = true;
                                }
                                else if (modifier.Value < -1)
                                {
                                    recompute = true;
                                }
                            }

                            if (recompute)
                            {
                                ResetSimTask.ResetSkillModifiers(sim);

                                Overwatch.Log("Recalculated Skill Modifiers : " + sim.FullName);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, e);
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception(Name, e);
            }
        }
Пример #4
0
        // 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;
        }
Пример #5
0
        public static bool Remove(SimDescription sim, OccultTypes type, bool alterOutfit)
        {
            if (sim.OccultManager == null)
            {
                return(false);
            }

            if (sim.CreatedSim != null)
            {
                try
                {
                    if (sim.CreatedSim.CurrentOutfitCategory == OutfitCategories.Special)
                    {
                        sim.CreatedSim.SwitchToOutfitWithoutSpin(OutfitCategories.Everyday);
                    }
                }
                catch
                { }
            }

            OccultVampire vampire = sim.OccultManager.GetOccultType(type) as OccultVampire;

            if (vampire != null)
            {
                if ((vampire.mOwningSim == null) || (vampire.mOwningSim.MapTagManager == null))
                {
                    vampire.mPreyMapTag = null;
                }
            }

            if (sim.GetOutfitCount(OutfitCategories.Everyday) == 1)
            {
                SimOutfit outfit = sim.GetOutfit(OutfitCategories.Everyday, 0);

                using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, new CASParts.Key(OutfitCategories.Everyday, 1), outfit))
                { }
            }

            if (type == OccultTypes.Unicorn)
            {
                OccultUnicornEx.OnRemoval(sim);
            }

            bool success = false;

            OccultManager occultManager = sim.OccultManager;

            try
            {
                if (occultManager.HasOccultType(type))
                {
                    occultManager.mCurrentOccultTypes ^= type;
                    foreach (OccultBaseClass occultClass in occultManager.mOccultList)
                    {
                        if (type == occultClass.ClassOccultType)
                        {
                            if ((occultManager.mOwnerDescription.SupernaturalData != null) && (occultManager.mOwnerDescription.SupernaturalData.OccultType == type))
                            {
                                occultManager.mOwnerDescription.RemoveSupernaturalData();
                            }

                            OccultGenie genie = occultClass as OccultGenie;
                            if (genie != null)
                            {
                                OccultGenieEx.OnRemoval(genie, occultManager.mOwnerDescription, alterOutfit);
                            }
                            else
                            {
                                OccultPlantSim plantSim = occultClass as OccultPlantSim;
                                if (plantSim != null)
                                {
                                    OccultPlantSimEx.OnRemoval(plantSim, occultManager.mOwnerDescription, alterOutfit);
                                }
                                else
                                {
                                    occultClass.OnRemoval(occultManager.mOwnerDescription);
                                }
                            }

                            occultManager.mOccultList.Remove(occultClass);
                            occultManager.mIsLifetimeReward = false;
                            if (occultManager.mOccultList.Count == 0x0)
                            {
                                occultManager.mOccultList = null;
                            }
                            break;
                        }
                    }

                    (Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged();

                    occultManager.UpdateOccultUI();

                    EventTracker.SendEvent(EventTypeId.kLostOccult, occultManager.mOwnerDescription.CreatedSim);
                }

                //occultManager.RemoveOccultType(type);
                success = true;
            }
            catch (Exception e)
            {
                bool showError = true;
                switch (type)
                {
                case OccultTypes.Genie:
                case OccultTypes.ImaginaryFriend:
                    if (sim.CreatedSim == null)
                    {
                        showError = false;
                    }
                    break;
                }

                if (showError)
                {
                    Common.Exception(sim, e);
                }
            }

            if (!success)
            {
                for (int i = occultManager.mOccultList.Count - 1; i >= 0; i--)
                {
                    if (type == occultManager.mOccultList[i].ClassOccultType)
                    {
                        occultManager.mOccultList.RemoveAt(i);
                    }

                    (Sims3.UI.Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged();
                    sim.OccultManager.UpdateOccultUI();
                }
            }

            TraitNames trait = TraitFromOccult(type);

            if (trait != TraitNames.Unknown)
            {
                sim.TraitManager.RemoveElement(trait);
            }

            return(success);
        }
Пример #6
0
        // 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);
        }