public bool LoopAnimation() { if (!DrinkFromPondHelper.RouteToDrinkLocation(Hit.mPoint, Actor, Hit.mType, Hit.mId)) { return(false); } StandardEntry(); EnterStateMachine("CatHuntInPond", "Enter", "x"); AddOneShotScriptEventHandler(101u, (SacsEventHandler)(object)new SacsEventHandler(SnapOnExit)); AnimateSim("PrePounceLoop"); // TODO: If we don't have an opportunity for catching fish faster, we should float mLoopLengthForNextFish = RandomUtil.GetFloat(EWCatFishHere.kMinMaxPrePounceTime[0], EWCatFishHere.kMinMaxPrePounceTime[1]); bool loopFlag = DoTimedLoop(mLoopLengthForNextFish); if (loopFlag) { EventTracker.SendEvent(EventTypeId.kGoFishingCat, Actor); float successBonus = 0; // Check for salt and freshwater opportunity bonuses if ((TerrainIsWaterPond && skill.OppPondProvisionerCompleted) || (!TerrainIsWaterPond && skill.OppSaltaholicCompleted)) { successBonus = EWCatFishingSkill.kFishCatchingBonus; } bool successFlag = RandomUtil.InterpolatedChance(0f, skill.MaxSkillLevel, EWCatFishHere.kMinMaxSuccesChance[0] + successBonus, EWCatFishHere.kMinMaxSuccesChance[1] + successBonus, skill.SkillLevel); FishType fishType = FishType.None; AnimateSim("FishLoop"); if (successFlag) { fishType = EWCatFishHere.GetCaughtFishType(Actor, Hit); switch (fishType) { case FishType.None: { // This is just in case there is weirdness. AnimateSim("ExitFailure"); break; } default: { Fish fish = Fish.CreateFishOfRandomWeight(fishType, Actor.SimDescription); EventTracker.SendEvent(EventTypeId.kPreyTypeCaught, Actor, fish); string message = skill.RegisterCaughtFish(fish, TerrainIsWaterPond); if (fish.CatHuntingComponent != null) { fish.CatHuntingComponent.SetCatcher(Actor); } fish.UpdateVisualState(CatHuntingComponent.CatHuntingModelState.Carried); SetActor("fish", (IHasScriptProxy)(object)fish); mNumberFishCaught++; if (Actor.Motives.GetValue(CommodityKind.Hunger) <= EWCatFishHere.kEatFishHungerThreshold) { // Notify if cat eats caught fish message += Localization.LocalizeString("Gameplay/Abstracts/ScriptObject/CatFishHere:EatFishTns", Actor, fish.GetLocalizedName(), fish.Weight); Actor.ShowTNSIfSelectable(message, NotificationStyle.kGameMessagePositive); AnimateSim("ExitEat"); fish.Destroy(); Actor.Motives.ChangeValue(CommodityKind.Hunger, EWCatFishHere.kHungerGainFromEating); } else { if (message != "") { // Notify if the fish is interesting (new type or weight record) message += Localization.LocalizeString("Gameplay/Abstracts/ScriptObject/CatFishHere:PutFishInInventoryTns", Actor, fish.GetLocalizedName(), fish.Weight); Actor.ShowTNSIfSelectable(message, NotificationStyle.kGameMessagePositive); } AnimateSim("ExitInventory"); fish.UpdateVisualState(CatHuntingComponent.CatHuntingModelState.InInventory); if (!Actor.Inventory.TryToAdd(fish)) { fish.Destroy(); } } break; } } } else { AnimateSim("ExitFailure"); } } else { AnimateSim("ExitPrePounce"); } StandardExit(); return(loopFlag); }
public override bool Run() { EWCatFishingSkill skill = Actor.SkillManager.GetSkill <EWCatFishingSkill>(EWCatFishingSkill.SkillNameID); if (skill == null) { skill = (Actor.SkillManager.AddElement(EWCatFishingSkill.SkillNameID) as EWCatFishingSkill); if (skill == null) { return(false); } } if (!DrinkFromPondHelper.RouteToDrinkLocation(Hit.mPoint, Actor, Hit.mType, Hit.mId)) { return(false); } if (skill.OppFishercatCompleted) { skill.StartSkillGain(EWCatFishingSkill.kEWFishingSkillGainRateFishercat); } else { skill.StartSkillGain(EWCatFishingSkill.kEWFishingSkillGainRateNormal); } StandardEntry(); EnterStateMachine("CatHuntInPond", "Enter", "x"); AddOneShotScriptEventHandler(101u, (SacsEventHandler)(object)new SacsEventHandler(SnapOnExit)); BeginCommodityUpdates(); AnimateSim("PrePounceLoop"); // TODO: If we don't have an opportunity for catching fish faster, we should bool flag = DoTimedLoop(RandomUtil.GetFloat(kMinMaxPrePounceTime[0], kMinMaxPrePounceTime[1])); if (flag) { EventTracker.SendEvent(EventTypeId.kGoFishingCat, Actor); AnimateSim("FishLoop"); float successBonus = 0; if ((TerrainIsWaterPond && skill.OppPondProvisionerCompleted) || (!TerrainIsWaterPond && skill.OppSaltaholicCompleted)) { successBonus = EWCatFishingSkill.kFishCatchingBonus; } flag = RandomUtil.InterpolatedChance(0f, skill.MaxSkillLevel, kMinMaxSuccesChance[0] + successBonus, kMinMaxSuccesChance[1] + successBonus, skill.SkillLevel); if (flag) { FishType caughtFishType = GetCaughtFishType(Actor, Hit); Fish fish = Fish.CreateFishOfRandomWeight(caughtFishType, Actor.SimDescription); // Register will return a message if the fish is new or interesting string message = skill.RegisterCaughtFish(fish, TerrainIsWaterPond); if (fish.CatHuntingComponent != null) { fish.CatHuntingComponent.SetCatcher(Actor); } fish.UpdateVisualState(CatHuntingComponent.CatHuntingModelState.Carried); SetActor("fish", fish); if (Actor.Motives.GetValue(CommodityKind.Hunger) <= kEatFishHungerThreshold) { message += Localization.LocalizeString("Gameplay/Abstracts/ScriptObject/CatFishHere:EatFishTns", Actor, fish.GetLocalizedName(), fish.Weight); Actor.ShowTNSIfSelectable(message, NotificationStyle.kGameMessagePositive); AnimateSim("ExitEat"); fish.Destroy(); Actor.Motives.ChangeValue(CommodityKind.Hunger, kHungerGainFromEating); } else { message += Localization.LocalizeString("Gameplay/Abstracts/ScriptObject/CatFishHere:PutFishInInventoryTns", Actor, fish.GetLocalizedName(), fish.Weight); Actor.ShowTNSIfSelectable(message, NotificationStyle.kGameMessagePositive); AnimateSim("ExitInventory"); fish.UpdateVisualState(CatHuntingComponent.CatHuntingModelState.InInventory); if (!Actor.Inventory.TryToAdd(fish)) { fish.Destroy(); } } } else { Actor.ShowTNSIfSelectable(Localization.LocalizeString("Gameplay/Abstracts/ScriptObject/CatFishHere:FishFail", Actor.Name), NotificationStyle.kGameMessageNegative); AnimateSim("ExitFailure"); } } else { AnimateSim("ExitPrePounce"); } EndCommodityUpdates(flag); StandardExit(); skill.StopSkillGain(); return(true); }