public override bool Test(Sim a, Terrain target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (SimTypes.IsSelectable(a)) { if (a.SkillManager.GetSkillLevel(SkillNames.CatHunting) < 1) { return(false); } CatHuntingSkill skill = a.SkillManager.GetSkill <CatHuntingSkill>(SkillNames.CatHunting); if ((skill == null) || (!skill.CanCatchPreyOfType(CatHuntingSkill.PreyType.Fish))) { return(false); } } if (!a.IsCat) { return(false); } return(PetManager.PetSkillFatigueTest(a, ref greyedOutTooltipCallback)); }
public override bool Run() { try { CatHuntingSkill skill = Actor.SkillManager.GetSkill <CatHuntingSkill>(SkillNames.CatHunting); if (skill == null) { skill = Actor.SkillManager.AddElement(SkillNames.CatHunting) as CatHuntingSkill; if (skill == null) { return(false); } } if (!Terrain.DrinkFromPondHelper.RouteToDrinkLocation(Hit.mPoint, Actor, Hit.mType, Hit.mId)) { return(false); } StandardEntry(); EnterStateMachine("CatHuntInPond", "Enter", "x"); AddOneShotScriptEventHandler(0x65, new SacsEventHandler(SnapOnExit)); BeginCommodityUpdates(); AnimateSim("PrePounceLoop"); bool succeeded = false; if (skill.SkillLevel < 1) { succeeded = DoTimedLoop(RandomUtil.GetFloat(30, 60)); } else { succeeded = DoTimedLoop(RandomUtil.GetFloat(kMinMaxPrePounceTime[0x0], kMinMaxPrePounceTime[0x1])); } if (succeeded) { EventTracker.SendEvent(EventTypeId.kGoFishingCat, Actor); AnimateSim("FishLoop"); succeeded = RandomUtil.InterpolatedChance(0f, (float)skill.MaxSkillLevel, kMinMaxSuccesChance[0x0], kMinMaxSuccesChance[0x1], (float)skill.SkillLevel); if (succeeded) { FishType type = FishType.None; try { // This function bounces if there are no fish available at the sim's skill level type = GetCaughtFishType(); } catch { } if (type != FishType.None) { Fish prey = Fish.CreateFishOfRandomWeight(type, Actor.SimDescription); skill.RegisterCaughtPrey(prey); if (prey.CatHuntingComponent != null) { prey.CatHuntingComponent.SetCatcher(Actor); } prey.UpdateVisualState(CatHuntingComponent.CatHuntingModelState.Carried); SetActor("fish", prey); if (Actor.Motives.GetValue(CommodityKind.Hunger) <= kEatFishHungerThreshold) { string message = Localization.LocalizeString("Gameplay/Abstracts/ScriptObject/CatFishHere:EatFishTns", new object[] { Actor, prey.GetLocalizedName(), prey.Weight }); Actor.ShowTNSIfSelectable(message, StyledNotification.NotificationStyle.kGameMessagePositive); AnimateSim("ExitEat"); prey.Destroy(); Actor.Motives.ChangeValue(CommodityKind.Hunger, kHungerGainFromEating); } else { string str2 = Localization.LocalizeString("Gameplay/Abstracts/ScriptObject/CatFishHere:PutFishInInventoryTns", new object[] { Actor, prey.GetLocalizedName(), prey.Weight }); // Custom StoryProgression.Main.Skills.Notify("CatFishHere", Actor, str2); AnimateSim("ExitInventory"); prey.UpdateVisualState(CatHuntingComponent.CatHuntingModelState.InInventory); Sim inventoryActor = Actor; if (!SimTypes.IsSelectable(Actor)) { SimDescription head = SimTypes.HeadOfFamily(Actor.Household); if ((head != null) && (head.CreatedSim != null)) { inventoryActor = head.CreatedSim; } } // Custom if (!inventoryActor.Inventory.TryToAdd(prey, false)) { prey.Destroy(); } } } else { AnimateSim("ExitFailure"); } } else { AnimateSim("ExitFailure"); } } else { AnimateSim("ExitPrePounce"); } EndCommodityUpdates(succeeded); StandardExit(); return(true); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
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); } }
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); } }
protected override bool PrivateUpdate(ScenarioFrame frame) { base.PrivateUpdate(frame); CatHuntingSkill skill = Sim.SkillManager.AddElement(SkillNames.CatHunting) as CatHuntingSkill; if (skill == null) { IncStat("Skill Fail"); return(false); } if ((skill.SkillLevel < 1) || (!skill.CanCatchAnything()) || (RandomUtil.RandomChance(25))) { PopulateFishingPoints(); List <GameObjectHit> fishingSpots = new List <GameObjectHit>(); foreach (Pair <Lot, GameObjectHit> pair in sFishingPoints) { if ((pair.First.IsCommunityLot) || (pair.First.CanSimTreatAsHome(Sim.CreatedSim))) { fishingSpots.Add(pair.Second); } } if (fishingSpots.Count != 0x0) { Terrain.CatFishHere fishing = Terrain.CatFishHere.Singleton.CreateInstance(Terrain.Singleton, Sim.CreatedSim, Sim.CreatedSim.InheritedPriority(), true, true) as Terrain.CatFishHere; if (fishing == null) { IncStat("Fish Creation Fail"); } else { fishing.Hit = RandomUtil.GetRandomObjectFromList <GameObjectHit>(fishingSpots); if (Situations.PushInteraction(this, Sim, Managers.Manager.AllowCheck.Active, fishing)) { return(true); } IncStat("Fish Fail"); } } else { IncStat("No Fishing Spots"); } } List <SimDescription> choices = new List <SimDescription>(); foreach (SimDescription sim in new SimScoringList(this, "LikesCats", HouseholdsEx.Humans(Sim.Household), false).GetBestByMinScore(1)) { if (sim.ChildOrBelow) { continue; } choices.Add(sim); } if (choices.Count == 0) { IncStat("No Master"); return(false); } CatHuntingComponent.StalkForPrey interaction = CatHuntingComponent.StalkForPrey.Singleton.CreateInstance(Sim.CreatedSim, Sim.CreatedSim, Sim.CreatedSim.InheritedPriority(), true, true) as CatHuntingComponent.StalkForPrey; if (interaction == null) { IncStat("Catch Creation Fail"); return(false); } interaction.PushedByGoCatch = true; interaction.PickAnyPrey = true; interaction.PresentToID = RandomUtil.GetRandomObjectFromList(choices).SimDescriptionId; interaction.ForceCatchFailureObject = false; if (Situations.PushInteraction(this, Sim, Managers.Manager.AllowCheck.Active, interaction)) { return(true); } IncStat("Catch Prey Fail"); return(false); }