Example #1
0
        public static bool AddHuntableToInventory(DogHuntingSkill ths, IGameObject huntable)
        {
            if (huntable == null)
            {
                return false;
            }

            bool flag = false;

            if (SimTypes.IsSelectable(ths.SkillOwner))
            {
                flag = Inventories.TryToMove(huntable, ths.SkillOwner.CreatedSim);
            }
            else
            {
                // Add the item to head of family
                SimDescription head = SimTypes.HeadOfFamily(ths.SkillOwner.Household);
                if (head != null)
                {
                    flag = Inventories.TryToMove(huntable, head.CreatedSim);
                }
            }

            if (!flag)
            {
                huntable.RemoveFromWorld();
                huntable.Destroy();
            }
            else
            {
                StoryProgression.Main.Skills.Notify("SniffOut", ths.SkillOwner.CreatedSim, Common.Localize("SniffOut:Success", ths.SkillOwner.IsFemale, new object[] { ths.SkillOwner, huntable.GetLocalizedName() }));
            }

            return flag;
        }
Example #2
0
        public static bool AddHuntableToInventory(DogHuntingSkill ths, IGameObject huntable)
        {
            if (huntable == null)
            {
                return(false);
            }

            bool flag = false;

            if (SimTypes.IsSelectable(ths.SkillOwner))
            {
                flag = Inventories.TryToMove(huntable, ths.SkillOwner.CreatedSim);
            }
            else
            {
                // Add the item to head of family
                SimDescription head = SimTypes.HeadOfFamily(ths.SkillOwner.Household);
                if (head != null)
                {
                    flag = Inventories.TryToMove(huntable, head.CreatedSim);
                }
            }

            if (!flag)
            {
                huntable.RemoveFromWorld();
                huntable.Destroy();
            }
            else
            {
                StoryProgression.Main.Skills.Notify("SniffOut", ths.SkillOwner.CreatedSim, Common.Localize("SniffOut:Success", ths.SkillOwner.IsFemale, new object[] { ths.SkillOwner, huntable.GetLocalizedName() }));
            }

            return(flag);
        }
Example #3
0
        public static bool GetHuntableAndAddToInventory(DogHuntingSkill ths)
        {
            IGameObject huntable = null;
            try
            {
                huntable = ths.GetHuntable();
            }
            catch (Exception e)
            {
                Common.DebugException(ths.SkillOwner, e);
            }

            return AddHuntableToInventory(ths, huntable);
        }
Example #4
0
        public static bool GetHuntableAndAddToInventory(DogHuntingSkill ths)
        {
            IGameObject huntable = null;

            try
            {
                huntable = ths.GetHuntable();
            }
            catch (Exception e)
            {
                Common.DebugException(ths.SkillOwner, e);
            }

            return(AddHuntableToInventory(ths, huntable));
        }
Example #5
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            DogHuntingSkill skill = Sim.SkillManager.AddElement(SkillNames.DogHunting) as DogHuntingSkill;

            if (skill == null)
            {
                IncStat("Skill Fail");
                return(false);
            }

            if (Situations.PushInteraction <Terrain>(this, Sim, Terrain.Singleton, Terrain.SniffOut.SniffOutSingleton))
            {
                return(true);
            }

            IncStat("Sniff Out Fail");
            return(false);
        }
Example #6
0
        public static int GetPrice(SimDescription sim)
        {
            if (sim.IsHuman)
            {
                return(0);
            }

            List <SimDescription> parents = Relationships.GetParents(sim);

            if (parents.Count < 2)
            {
                return(0);
            }

            Common.StringBuilder msg = new Common.StringBuilder(sim.FullName);

            int price = 0;

            try
            {
                if ((sim.IsHorse) && (sim.AdultOrAbove))
                {
                    price = HorseManager.GetHorseCost(sim, false);
                }
                else
                {
                    List <Pair <SimDescription, int> > parentLevel = new List <Pair <SimDescription, int> >();

                    foreach (SimDescription parent in parents)
                    {
                        parentLevel.Add(new Pair <SimDescription, int>(parent, 0));
                    }

                    Dictionary <SimDescription, bool> lookup = new Dictionary <SimDescription, bool>();

                    int maxLevel = 0;

                    int index = 0;
                    while (index < parentLevel.Count)
                    {
                        Pair <SimDescription, int> level = parentLevel[index];
                        index++;

                        if (lookup.ContainsKey(level.First))
                        {
                            price -= Consigner.Settings.mInbredPenalty;

                            msg += Common.NewLine + "Inbred: -" + Consigner.Settings.mInbredPenalty;

                            continue;
                        }
                        lookup.Add(level.First, true);

                        if (maxLevel < level.Second)
                        {
                            maxLevel = level.Second;
                        }

                        foreach (SimDescription parent in Relationships.GetParents(level.First))
                        {
                            parentLevel.Add(new Pair <SimDescription, int>(parent, level.Second + 1));
                        }
                    }

                    price += maxLevel * Consigner.Settings.mPedigreeBonus;

                    msg += Common.NewLine + "Pedigree: " + maxLevel + " * " + Consigner.Settings.mPedigreeBonus;

                    if (sim.Child)
                    {
                        price += Consigner.Settings.mSellPrice[0];

                        msg += Common.NewLine + "Child: " + Consigner.Settings.mSellPrice[0];
                    }
                    else if (sim.Adult)
                    {
                        price += Consigner.Settings.mSellPrice[1];

                        msg += Common.NewLine + "Adult: " + Consigner.Settings.mSellPrice[1];
                    }
                    else
                    {
                        price += Consigner.Settings.mSellPrice[2];

                        msg += Common.NewLine + "Elder: " + Consigner.Settings.mSellPrice[2];
                    }

                    foreach (Trait trait in sim.TraitManager.List)
                    {
                        if (trait.Score > 0x0)
                        {
                            price += Consigner.Settings.mGoodTraitBonus;

                            msg += Common.NewLine + trait.TraitName(sim.IsFemale) + ": " + Consigner.Settings.mGoodTraitBonus;
                        }
                        else if (trait.Score < 0x0)
                        {
                            price -= Consigner.Settings.mBadTraitPenalty;

                            msg += Common.NewLine + trait.TraitName(sim.IsFemale) + ": -" + Consigner.Settings.mBadTraitPenalty;
                        }
                    }

                    if (sim.IsGhost)
                    {
                        price += Consigner.Settings.mOccultBonus;

                        msg += Common.NewLine + "Occult: " + Consigner.Settings.mOccultBonus;
                    }

                    {
                        CatHuntingSkill skill = sim.SkillManager.GetSkill <CatHuntingSkill>(SkillNames.CatHunting);
                        if ((skill != null) && (skill.IsVisibleInUI()))
                        {
                            price += (int)(skill.SkillLevel * Consigner.Settings.mSkillLevelBonus);

                            msg += Common.NewLine + "Skill: " + skill.SkillLevel + " * " + Consigner.Settings.mSkillLevelBonus;

                            if (skill.mPreyCaughtTypeStats != null)
                            {
                                int count = 0;

                                foreach (int value in skill.mPreyCaughtTypeStats.Values)
                                {
                                    count += value;
                                }

                                price += (int)(count * Consigner.Settings.mPerPreyBonus);

                                msg += Common.NewLine + "Per Prey: " + count + " * " + Consigner.Settings.mPerPreyBonus;
                            }
                        }
                    }

                    {
                        DogHuntingSkill skill = sim.SkillManager.GetSkill <DogHuntingSkill>(SkillNames.DogHunting);
                        if ((skill != null) && (skill.IsVisibleInUI()))
                        {
                            price += (int)(skill.SkillLevel * Consigner.Settings.mSkillLevelBonus);

                            msg += Common.NewLine + "Skill: " + skill.SkillLevel + " * " + Consigner.Settings.mSkillLevelBonus;

                            if (skill.mNumRGMFound != null)
                            {
                                int count = 0;

                                foreach (int value in skill.mNumRGMFound.Values)
                                {
                                    count += value;
                                }

                                price += (int)(count * Consigner.Settings.mPerPreyBonus);

                                msg += Common.NewLine + "RGM: " + count + " * " + Consigner.Settings.mPerPreyBonus;
                            }
                        }
                    }
                }

                msg += Common.NewLine + "Final Price: " + price;

                return(Math.Max(price, 0));
            }
            finally
            {
                Common.DebugNotify(msg);
            }
        }
Example #7
0
        public static void MergeTravelInformation(SimDescription dest, SimDescription source, bool destHomeworld)
        {
            Common.StringBuilder msg = new Common.StringBuilder("MergeTravelInformation " + dest.FullName + Common.NewLine);

            try
            {
                msg += "A";
                Traveler.InsanityWriteLog(msg);

                OccupationNames sourceGuid = OccupationNames.Undefined;
                if (source.Occupation != null)
                {
                    sourceGuid = source.Occupation.Guid;
                }

                OccupationNames destGuid = OccupationNames.Undefined;
                if (dest.Occupation != null)
                {
                    destGuid = dest.Occupation.Guid;
                }

                if ((!destHomeworld) || (sourceGuid != destGuid))
                {
                    msg += "A1";
                    Traveler.InsanityWriteLog(msg);

                    if ((!destHomeworld) || (source.Occupation != null))
                    {
                        dest.CareerManager.mJob = source.Occupation;
                        if (dest.Occupation != null)
                        {
                            dest.Occupation.OwnerDescription = dest;
                        }

                        source.CareerManager.mJob = null;
                    }
                }
                else
                {
                    msg += "A2";
                    Traveler.InsanityWriteLog(msg);

                    // Update career piece-wise
                    foreach (ICareerMerger merger in Common.DerivativeSearch.Find <ICareerMerger>())
                    {
                        msg += Common.NewLine + merger.GetType().ToString();
                        Traveler.InsanityWriteLog(msg);

                        merger.IPerform(dest.Occupation, source.Occupation);
                    }
                }

                msg += Common.NewLine + "B";
                Traveler.InsanityWriteLog(msg);

                // Custom
                //   The MergeOccults in MergeTravelInformation can fail when removing occults
                OccultManagerEx.MergeOccults(dest.OccultManager, source.OccultManager);

                msg += "C";
                Traveler.InsanityWriteLog(msg);

                // Original Function
                dest.MergeTravelInformation(source);

                msg += "D";
                Traveler.InsanityWriteLog(msg);

                TrickSkill sourceTrickSkill = source.SkillManager.GetSkill <TrickSkill>(SkillNames.Trick);
                if (sourceTrickSkill != null)
                {
                    TrickSkill destTrickSkill = dest.SkillManager.AddElement(SkillNames.Trick) as TrickSkill;
                    if (destTrickSkill != null)
                    {
                        destTrickSkill.mExhibitionsPerformed       = sourceTrickSkill.mExhibitionsPerformed;
                        destTrickSkill.mMoneyEarnedFromExhibitions = sourceTrickSkill.mMoneyEarnedFromExhibitions;
                        destTrickSkill.mTricks = sourceTrickSkill.mTricks;
                    }
                }

                msg += "E";
                Traveler.InsanityWriteLog(msg);

                CatHuntingSkill sourceCatSkill = source.SkillManager.GetSkill <CatHuntingSkill>(SkillNames.CatHunting);
                if (sourceCatSkill != null)
                {
                    CatHuntingSkill destCatSkill = dest.SkillManager.AddElement(SkillNames.CatHunting) as CatHuntingSkill;
                    if (destCatSkill != null)
                    {
                        destCatSkill.mOppCreepingAndCrawlingIsNew = sourceCatSkill.mOppCreepingAndCrawlingIsNew;
                        destCatSkill.mOppSlitherStalkerIsNew      = sourceCatSkill.mOppSlitherStalkerIsNew;
                        destCatSkill.mOppFelineFisherIsNew        = sourceCatSkill.mOppFelineFisherIsNew;
                        destCatSkill.mOppHomingWhiskersIsNew      = sourceCatSkill.mOppHomingWhiskersIsNew;
                    }
                }

                msg += "F";
                Traveler.InsanityWriteLog(msg);

                DogHuntingSkill sourceDogSkill = source.SkillManager.GetSkill <DogHuntingSkill>(SkillNames.DogHunting);
                if (sourceDogSkill != null)
                {
                    DogHuntingSkill destDogSkill = dest.SkillManager.AddElement(SkillNames.DogHunting) as DogHuntingSkill;
                    if (destDogSkill != null)
                    {
                        destDogSkill.mOppGemFinderIsNew           = sourceDogSkill.mOppGemFinderIsNew;
                        destDogSkill.mOppMetalFinderIsNew         = sourceDogSkill.mOppMetalFinderIsNew;
                        destDogSkill.mOppRockFinderIsNew          = sourceDogSkill.mOppRockFinderIsNew;
                        destDogSkill.mNumFragmentedItemsCompelted = sourceDogSkill.mNumFragmentedItemsCompelted;
                        destDogSkill.mNumUniqueCollectablesFound  = sourceDogSkill.mNumUniqueCollectablesFound;
                        destDogSkill.mNumRGMFound = sourceDogSkill.mNumRGMFound;
                    }
                }

                msg += "G";
                Traveler.InsanityWriteLog(msg);
            }
            catch (Exception e)
            {
                Common.Exception(source, null, msg, e);
            }
        }