Beispiel #1
0
            public override string GetInteractionName(IActor a, Sim target, InteractionObjectPair interaction)
            {
                TraitChipStaticData chipData = TraitChipManager.GetStaticElement(mChip);

                if (chipData != null)
                {
                    return(Localization.LocalizeString(chipData.TraitChipNameKey, new object[0x0]));
                }
                return(null);
            }
Beispiel #2
0
            public override void SetValue(TraitChipName value, TraitChipName storeType)
            {
                mValue = value;

                TraitChipStaticData data = TraitChipManager.GetStaticElement(value);

                if (data != null)
                {
                    mName = Localization.LocalizeString(data.mTraitChipNameKey, new object[0]);
                    SetThumbnail(data.GetThumbnailKey(ThumbnailSize.Medium));
                }
            }
Beispiel #3
0
        public ulong _NMakeUniqueID()
        {
            if (runI)
            {
                return(0);
            }

            //ulong id = mSimDescriptionId;

            try
            {
                for (int i = 0; i < 500 && !IsSimDescriptionIdUnique(safeID); i++)
                {
                    safeID++;
                }
                //id = safeID;
            }
            catch (Exception)
            {
                safeID += 10; //id = safeID;
            }


            if (safeID != mSimDescriptionId)
            {
                mOldSimDescriptionId = mSimDescriptionId;
            }

            mSimDescriptionId = safeID;

            if (CelebrityManager != null)
            {
                CelebrityManager.ResetOwnerSimDescription(mSimDescriptionId);
            }
            if (PetManager != null)
            {
                PetManager.ResetOwnerSimDescription(mSimDescriptionId);
            }
            if (TraitChipManager != null)
            {
                TraitChipManager.ResetOwnerSimDescription(mSimDescriptionId);
            }

            return(mSimDescriptionId);
        }
Beispiel #4
0
        public override bool Run()
        {
            try
            {
                Definition definition = InteractionDefinition as Definition;

                TraitChip chip = TraitChipManager.CreateTraitChip(definition.mChip);
                if (chip == null)
                {
                    return(false);
                }

                Inventories.TryToMove(chip, Target);
                return(true);
            }
            catch (Exception exception)
            {
                Common.Exception(Actor, Target, exception);
                return(false);
            }
        }
Beispiel #5
0
        /*
         * DebugString: "_NFixUp(): if (ListCollon.NullSimSimDescription == this)"
         * DebugString: "NMScript Exception Log
         * System.Exception: no message
         *
         #0: 0x0001f throw      in Sims3.Gameplay.CAS.Sims3.Gameplay.CAS.SimDescription:Fixup () ()
         #1: 0x00050 callvirt   in NRaas.OverwatchSpace.Alarms.NRaas.OverwatchSpace.Alarms.RecoverMissingSims:PrivatePerformAction (bool) (9193E9C0 [0] )
         #2: 0x00011 callvirt   in NRaas.OverwatchSpace.Alarms.NRaas.OverwatchSpace.Alarms.AlarmOption:PerformAction (bool) (9193E9C0 [0] )
         #3: 0x00002 call       in NRaas.OverwatchSpace.Alarms.NRaas.OverwatchSpace.Alarms.AlarmOption:PerformAlarm () ()
         #4: 0x0001b callvirt   in NRaas.NRaas.Overwatch:OnTimer () ()
         #5: 0x00000            in Sims3.Gameplay.Sims3.Gameplay.Function:Invoke () ()
         #6: 0x00003 callvirt   in NRaas.Common+FunctionTask:Simulate () ()
         */
        public void _NFixUp()
        {
            if (runI)
            {
                return;
            }

            if (ListCollon.NullSimSimDescription == this)
            {
                if (niec_native_func.cache_done_niecmod_native_debug_text_to_debugger)
                {
                    niec_native_func.OutputDebugString("_NFixUp(): if (ListCollon.NullSimSimDescription == this)");
                    try
                    {
                        throw new Exception("no message");
                    }
                    catch (Exception ex)
                    {
                        NiecException.SendTextExceptionToDebugger(ex);
                    }
                }

                mIsValidDescription = false;
                NFinalizeDeath.SimDesc_NullToEmpty(this);
                mIsValidDescription = true;

                if (UnsafeFixNUllSimDESC)
                {
                    var p = NFinalizeDeath.GetSafeSelectActor();
                    if (p != null && p.SimDescription != null)
                    {
                        mOutfits = p.SimDescription.Outfits;
                    }
                    if (!waitrunningtask01)
                    {
                        waitrunningtask01 = true;
                        NiecTask.Perform(() =>
                        {
                            for (int i = 0; i < 800; i++)
                            {
                                Simulator.Sleep(0);
                            }
                            waitrunningtask01 = false;
                            NFinalizeDeath.SimDescCleanse(this, true, false);
                        });
                    }
                }
                else if (!waitrunningtask01)
                {
                    waitrunningtask01 = true;
                    NiecTask.Perform(() =>
                    {
                        for (int i = 0; i < 50; i++)
                        {
                            Simulator.Sleep(0);
                        }
                        waitrunningtask01 = false;
                        NFinalizeDeath.SimDescCleanse(this, true, true);
                    });
                }
                return;
            }

            mIsValidDescription = true;

            if (base.TraitManager != null)
            {
                base.TraitManager.SetSimDescription(this);
                base.TraitManager.Fixup();
            }

            if (CreatedSim != null && CreatedSim.Inventory != null)
            {
                foreach (TraitChip item in CreatedSim.Inventory.FindAll <TraitChip>(false))
                {
                    item.OnLoadFixup();
                    if (item.Owner == null)
                    {
                        item.SetOwner(this);
                    }
                }
            }

            MiniSimDescription miniSimDescription = MiniSimDescription.Find(SimDescriptionId);

            if ((GameStates.IsTravelling || GameStates.IsEditingOtherTown) && miniSimDescription != null)
            {
                base.CASGenealogy = miniSimDescription.Genealogy;
            }

            if (GameObjectRelationships != null)
            {
                int i = 0;
                while (i < GameObjectRelationships.Count)
                {
                    if (!Sims3.SimIFace.Objects.IsValid(GameObjectRelationships[i].GameObjectDescription.GameObject.ObjectId))
                    {
                        GameObjectRelationships.RemoveAt(i);
                    }
                    else
                    {
                        i++;
                    }
                }
            }

            if (mGenealogy == null)
            {
                mGenealogy = new Genealogy(this);
            }

            if (SkillManager == null)
            {
                SkillManager = new SkillManager(this);
            }
            else
            {
                SkillManager.OnLoadFixup();
            }

            if (CareerManager == null)
            {
                CareerManager = new CareerManager(this);
            }
            else
            {
                CareerManager.OnLoadFixup();
            }

            if (VisaManager == null)
            {
                VisaManager = new VisaManager(this);
            }
            else
            {
                VisaManager.OnLoadFixup();
            }

            if (CelebrityManager == null)
            {
                CelebrityManager = new CelebrityManager(SimDescriptionId);
            }
            else if (CelebrityManager.Owner == null)
            {
                CelebrityManager.ResetOwnerSimDescription(SimDescriptionId);
            }

            if (LifeEventManager == null || !LifeEventManager.IsValid)
            {
                LifeEventManager = new LifeEventManager(this);
            }

            LifeEventManager.ClearInvalidActiveNodes();

            if (OccultManager == null)
            {
                OccultManager = new OccultManager(this);
            }
            else
            {
                OccultManager.OnLoadFixup();
            }

            if (IsPet)
            {
                if (PetManager == null)
                {
                    PetManager = CreatePetManager();
                }
            }
            else if (PetManager != null)
            {
                PetManager.Dispose();
                PetManager = null;
            }

            if (IsEP11Bot)
            {
                if (TraitChipManager == null)
                {
                    TraitChipManager = new TraitChipManager(this);
                }
                else if (TraitChipManager.Owner == null)
                {
                    TraitChipManager.ResetOwnerSimDescription(SimDescriptionId);
                }
                TraitChipManager.OnLoadFixup();
            }
            else if (TraitChipManager != null)
            {
                TraitChipManager.Dispose();
                TraitChipManager = null;
            }

            AssignSchool();

            if (mSimDescriptionId == 0)
            {
                MakeUniqueId();
            }

            if (ReadBookDataList == null)
            {
                ReadBookDataList = new Dictionary <string, ReadBookData>();
            }

            PushAgingEnabledToAgingManager();

            if (mInitialShape.Owner == null || mCurrentShape.Owner == null || mInitialShape.Owner != this || mCurrentShape.Owner != this)
            {
                mInitialShape.Owner = (mCurrentShape.Owner = this);
            }

            if (OpportunityHistory == null)
            {
                OpportunityHistory = new OpportunityHistory();
            }

            if (Sims3.Gameplay.Gameflow.sGameLoadedFromWorldFile && !Household.IsTravelImport && !GameStates.IsIdTravelling(SimDescriptionId))
            {
                mDisplayedShape.Owner    = mCurrentShape.Owner;
                mDisplayedShape.Fit      = mCurrentShape.Fit;
                mDisplayedShape.Weight   = mCurrentShape.Weight;
                mDisplayedShape.Pregnant = mCurrentShape.Pregnant;
                ResetLifetimeHappinessStatistics();
                mHomeWorld = GameUtils.GetCurrentWorld();
            }

            if (mHomeWorld == WorldName.Undefined)
            {
                mHomeWorld = GameUtils.GetCurrentWorld();
            }

            if (RelicStats == null)
            {
                RelicStats = new RelicStatTracking(this);
            }

            RelicStats.SetSimDescription(this);

            if (TombStats == null)
            {
                TombStats = new TombStatTracking(this);
            }

            TombStats.SetSimDescription(this);

            if (Singing == null)
            {
                Singing = new SingingInfo(this);
            }

            Singing.SetSimDesctiption(this);

            if (AssignedRole != null)
            {
                AssignedRole.OnLoadFixUp();
            }

            Lot lot = LotManager.GetLot(mVirtualLotId);

            if (lot != null)
            {
                lot.VirtualMoveIn(this);
            }

            if (Species == CASAgeGenderFlags.None)
            {
                Species = CASAgeGenderFlags.Human;
            }

            if (!CASLogic.GetSingleton().IsMusicTypeInstalled(FavoriteMusic))
            {
                RandomizeFavoriteMusic();
            }

            if (GetCurrentOutfits() != null)
            {
                OutfitCategories[] array = new OutfitCategories[5]
                {
                    OutfitCategories.None,
                    OutfitCategories.All,
                    OutfitCategories.CategoryMask,
                    OutfitCategories.PrimaryCategories,
                    OutfitCategories.PrimaryHorseCategories
                };

                foreach (var outfitCategories in array)
                {
                    if (GetOutfitCount(outfitCategories) > 0)
                    {
                        RemoveOutfits(outfitCategories, false);
                        if (base.mMaternityOutfits != null)
                        {
                            base.mMaternityOutfits.Remove(outfitCategories);
                        }
                        if (base.mOutfits != null)
                        {
                            base.mOutfits.Remove(outfitCategories);
                        }
                    }
                }
            }

            if (!GameUtils.IsInstalled(ProductVersion.EP4))
            {
                Sim.PlayPretend.RemoveAllChildCostumeOutfits(this);

                if (CreatedSim != null && CreatedSim.CurrentOutfitCategory == OutfitCategories.ChildImagination)
                {
                    CreatedSim.SwitchToOutfitWithoutSpin(OutfitCategories.Everyday);
                }

                RemoveOutfits(OutfitCategories.ChildImagination, true);

                base.Outfits.Remove(OutfitCategories.ChildImagination);

                if (SpoiledGiftHistory != null)
                {
                    SpoiledGiftHistory.Clear();
                    SpoiledGiftHistory = null;
                }
            }

            if (CreatedSim != null && (OccultManager == null || !OccultManager.HasOccultType(OccultTypes.Vampire | OccultTypes.Genie | OccultTypes.Werewolf | OccultTypes.Ghost)) && mSkinToneKey.InstanceId == 15475186560318337848uL)
            {
                World.ObjectSetVisualOverride(CreatedSim.ObjectId, eVisualOverrideTypes.Genie, null);
            }
        }
Beispiel #6
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            List <BotChip.Item> allOptions = new List <BotChip.Item>();

            List <TraitChip> list = new List <TraitChip>();

            list = me.TraitChipManager.GetInstalledTraitChips();

            List <TraitChipName> installed = new List <TraitChipName>();

            foreach (TraitChip chip in list)
            {
                installed.Add(chip.TraitChipName);
            }

            foreach (TraitChipName name in Enum.GetValues(typeof(TraitChipName)))
            {
                TraitChipStaticData data = TraitChipManager.GetStaticElement(name);
                if (data == null)
                {
                    continue;
                }

                int count = 0;
                if (installed.Contains(data.Guid))
                {
                    count++;
                }

                allOptions.Add(new BotChip.Item(data.Guid, count));
            }

            CommonSelection <BotChip.Item> .Results selection = new CommonSelection <BotChip.Item>(Name, me.FullName, allOptions, new BotChip.AuxillaryColumn()).SelectMultiple();
            if (selection.Count == 0)
            {
                return(false);
            }

            List <TraitChipStaticData> chipsToInstall = new List <TraitChipStaticData>();

            foreach (BotChip.Item item in selection)
            {
                if (item == null)
                {
                    continue;
                }

                TraitChipName chipName = item.Value;

                TraitChipStaticData chip = TraitChipManager.GetStaticElement(chipName);
                if (chip != null)
                {
                    if (installed.Contains(chipName))
                    {
                        foreach (TraitChip chipInBot in list)
                        {
                            if (chipInBot.TraitChipName == chipName)
                            {
                                me.TraitChipManager.RemoveTraitChip(chipInBot.mTraitChipSlot);
                                chipInBot.RemoveTraitChipFromSim();
                            }
                        }
                    }
                    else
                    {
                        chipsToInstall.Add(chip);
                    }
                }
            }

            bool exceeded = false;

            foreach (TraitChipStaticData chip in chipsToInstall)
            {
                TraitChipName chipName = chip.Guid;

                TraitChip chipToUse = null;
                foreach (TraitChip inChip in me.CreatedSim.Inventory.FindAll <TraitChip>(false))
                {
                    if (inChip.TraitChipName == chipName)
                    {
                        chipToUse = inChip;
                        break;
                    }
                }

                if (chipToUse == null && me.TraitChipManager.Owner != null)
                {
                    SimDescription owner = me.TraitChipManager.Owner;
                    if (owner.CreatedSim != null && owner.CreatedSim.Inventory != null)
                    {
                        foreach (TraitChip inChip in owner.CreatedSim.Inventory.FindAll <TraitChip>(false))
                        {
                            if (inChip.TraitChipName == chipName)
                            {
                                chipToUse = inChip;
                                break;
                            }
                        }
                    }
                }

                bool created = false;
                if (chipToUse == null)
                {
                    chipToUse = TraitChipManager.CreateTraitChip(chipName);
                    if (chipToUse != null)
                    {
                        me.CreatedSim.Inventory.TryToAdd(chipToUse);
                        chipToUse.CreatorSim = me.SimDescriptionId;
                        chipToUse.SetOwner(me);
                        created = true;
                    }
                }

                if (chipToUse != null)
                {
                    int count = me.TraitChipManager.GetInstalledTraitChips().Count;
                    count++;

                    if (count > me.TraitChipManager.NumTraitSlots && me.TraitChipManager.NumTraitSlots < me.TraitChipManager.MaxNumTraitSlots)
                    {
                        me.TraitChipManager.UpgradeNumTraitChips(count);
                    }

                    int newSlot = me.TraitChipManager.GetOpenTraitChipSlot();
                    if (newSlot != -1)
                    {
                        me.TraitChipManager.AddTraitChip(chipToUse, newSlot);
                    }
                    else
                    {
                        exceeded = true;
                        if (created)
                        {
                            chipToUse.Destroy();
                        }
                        break;
                    }
                }
            }

            if (exceeded)
            {
                // tried to expand this beyond 7 but the change trait chip UI has a cow, chicken, pig and a plumbot when it encounters > 7
                Common.Notify(Common.Localize("ChangeTraitChips:MaxExceeded", me.IsFemale, new object[] { me, 7, 7 }));
            }

            return(true);
        }
Beispiel #7
0
        public static IGameObject FetchRandomOccultTreat(OccultTypes type, bool isAlien)
        {
            if (isAlien)
            {
                InteractionDefinition      instance  = RabbitHole.StealSpaceRocks.Singleton;
                RabbitHole.StealSpaceRocks instance2 = instance as RabbitHole.StealSpaceRocks;
                if (instance2 != null)
                {
                    RabbitHole.StealSpaceRocks.SpaceRockSize weightedIndex = (RabbitHole.StealSpaceRocks.SpaceRockSize)RandomUtil.GetWeightedIndex(instance2.SSRTuning.SpaceRockWeights);
                    RockGemMetal spaceRockSize = RockGemMetal.SpaceRockSmall;
                    switch (weightedIndex)
                    {
                    case RabbitHole.StealSpaceRocks.SpaceRockSize.Small:
                        spaceRockSize = RockGemMetal.SpaceRockSmall;
                        break;

                    case RabbitHole.StealSpaceRocks.SpaceRockSize.Medium:
                        spaceRockSize = RockGemMetal.SpaceRockMedium;
                        break;

                    case RabbitHole.StealSpaceRocks.SpaceRockSize.Large:
                        spaceRockSize = RockGemMetal.SpaceRockLarge;
                        break;
                    }

                    return(RockGemMetalBase.Make(spaceRockSize, false));
                }
            }

            switch (type)
            {
            case OccultTypes.Fairy:
                PlantRarity      rarity  = (PlantRarity)RandomUtil.GetInt(0, 3);
                Quality          quality = (Quality)RandomUtil.GetInt(4, 9);
                PlayerDisclosure playerKnowledgeOfPlantableType = (rarity == PlantRarity.Common) ? PlayerDisclosure.Exposed : PlayerDisclosure.Concealed;
                IGameObject      seed = PlantHelper.CreateRandomPlantable(rarity, quality, true, playerKnowledgeOfPlantableType);

                return(seed);

            case OccultTypes.Frankenstein:
                ScrapInitParameters initData = new ScrapInitParameters(1);
                IGameObject         scrap    = GlobalFunctions.CreateObjectOutOfWorld("scrapPile", ProductVersion.EP2, null, initData);
                return(scrap);

            case OccultTypes.Genie:
                IGameObject lamp = GlobalFunctions.CreateObjectOutOfWorld("GenieLamp", ProductVersion.EP6);
                return(lamp);

            case OccultTypes.Mermaid:
                IGameObject kelp = MermadicKelp.MakeMermadicKelp(RandomUtil.CoinFlip());
                return(kelp);

            case OccultTypes.PlantSim:
                string     randomHerb = RandomUtil.GetRandomObjectFromList <string>(new List <string>(Herb.sIngredientToHerbDataMap.Keys));
                Ingredient herb       = Ingredient.Create(IngredientData.NameToDataMap[randomHerb]);
                return(herb as IGameObject);

            case OccultTypes.Robot:
                TraitChipStaticData data = RandomUtil.GetRandomObjectFromDictionary <ulong, TraitChipStaticData>(GenericManager <TraitChipName, TraitChipStaticData, TraitChip> .sDictionary);
                if (data != null)
                {
                    TraitChip chip = TraitChipManager.CreateTraitChip(data.Guid);
                    return(chip);
                }
                return(null);

            case OccultTypes.Vampire:
                IGameObject vampireTreat = null;
                if (!GameUtils.IsInstalled(ProductVersion.EP3))
                {
                    vampireTreat = Recipe.NameToRecipeHash["VampireJuiceEP7"].CreateFinishedFood(Recipe.MealQuantity.Single, Quality.Perfect);
                }
                else
                {
                    bool coinToss = RandomUtil.CoinFlip();
                    if (coinToss)
                    {
                        vampireTreat = Recipe.NameToRecipeHash["VampireJuice"].CreateFinishedFood(Recipe.MealQuantity.Single, Quality.Perfect);
                    }
                    else
                    {
                        vampireTreat = Ingredient.Create(IngredientData.NameToDataMap["VampireFruit"]);
                    }
                }
                return(vampireTreat);

            case OccultTypes.Werewolf:
                List <FishType> fish    = new List <FishType>();
                List <float>    weights = new List <float>(fish.Count);
                foreach (FishType fishType in Fish.sFishData.Keys)
                {
                    FishData data2 = Fish.sFishData[fishType];
                    if (((data2.IngredientData != null) && data2.IngredientData.CanBuyFromStore) && (data2.Level >= 0))
                    {
                        fish.Add(fishType);
                        weights.Add(1f);
                    }
                }
                int  weightedIndexFish = RandomUtil.GetWeightedIndex(weights.ToArray());
                Fish obj2 = Fish.CreateFishOfRandomWeight(fish[weightedIndexFish]);
                return(obj2 as IGameObject);

            case OccultTypes.Witch:
                if (RandomUtil.CoinFlip())
                {
                    ISoloInteractionDefinition  cdef     = TraitFunctions.ConjureApple.Singleton;
                    TraitFunctions.ConjureApple appleDef = cdef as TraitFunctions.ConjureApple;
                    if (appleDef != null)
                    {
                        return(appleDef.CreateAppleForInventory(RandomUtil.CoinFlip(), Quality.Perfect));
                    }
                }
                else
                {
                    AlchemyPotion potion = AlchemyPotion.CreateARandomPotion(RandomUtil.CoinFlip(), 0);
                    return(potion as IGameObject);
                }
                return(null);

            case OccultTypes.None:
            default:
                return(null);
            }
        }