public override bool Run()
        {
            skillActor = Actor.SkillManager.GetSkill <EWPetFightingSkill>(EWPetFightingSkill.skillNameID);
            if (skillActor == null)
            {
                skillActor = Actor.SkillManager.AddElement(EWPetFightingSkill.skillNameID) as EWPetFightingSkill;
                if (skillActor == null)
                {
                    return(false);
                }
            }
            skillActor.StartSkillGain(EWPetFightingSkill.kSkillGainRateNormal);
            bool returnVal = base.Run();

            skillActor.StopSkillGain();
            return(returnVal);
        }
Exemple #2
0
        public override bool Run()
        {
            if (!SafeToSync())
            {
                return(false);
            }
            StandardEntry(addToUseList: false);

            float num = GetSocialDistanceAndSetupJig();

            if (num < 0f)
            {
                Actor.AddExitReason(ExitReason.RouteFailed);
                return(false);
            }

            if (!BeginSocialInteraction(new SocialInteractionB.Definition(null, GetInteractionName(),
                                                                          allowCarryChild: false), pairedSocial: true, doCallOver: false))
            {
                Actor.AddExitReason(ExitReason.FailedToStart);
                return(false);
            }

            skillActor = Actor.SkillManager.GetSkill <EWPetFightingSkill>(EWPetFightingSkill.skillNameID);
            if (skillActor == null)
            {
                skillActor = Actor.SkillManager.AddElement(EWPetFightingSkill.skillNameID) as EWPetFightingSkill;
                if (skillActor == null)
                {
                    return(false);
                }
            }

            skillTarget = Target.SkillManager.GetSkill <MartialArts>(SkillNames.MartialArts);
            if (skillTarget == null)
            {
                skillTarget = Actor.SkillManager.AddElement(SkillNames.MartialArts)
                              as MartialArts;
                if (skillTarget == null)
                {
                    return(false);
                }
            }

            skillActor.StartSkillGain(skillActor.getSkillGainRate(Actor));
            skillTarget.StartSkillGain(EWPetFightingSkill.kSkillGainRateNormal);

            UpdateConversationWhenSocialStarts(Actor, Target);
            mSmc = GetStateMachine();
            string jazzState = mTargetEffect.RHS.JazzState;

            jazzState = SetupAnimationParameters(false, false, false, jazzState);
            mSmc.RequestState(null, jazzState);

            skillActor.StopSkillGain();
            skillTarget.StopSkillGain();

            bool actorWon = DoesActorWinFight();

            if (actorWon)
            {
                skillActor.wonFight(Target, Actor.LotCurrent == Actor.LotHome);
                skillActor.AddPoints(200f, true, true);
                Actor.ShowTNSIfSelectable(Localization.LocalizeString("Echoweaver/PetFighting/EWPetAttackSim:PetAttackWin",
                                                                      Actor.Name), StyledNotification.NotificationStyle.kGameMessagePositive);

                // TODO: Need appropriate origin for dog attack
                Target.BuffManager.AddElement(BuffNames.ShreddedDignity, Origin.FromFight);
                PlayHumanLossAnims();
            }
            else
            {
                skillActor.lostFight(Target);
                Actor.ShowTNSIfSelectable(Localization.LocalizeString("Echoweaver/PetFighting/EWPetAttackSim:PetAttackLose",
                                                                      Actor.Name), StyledNotification.NotificationStyle.kGameMessageNegative);
                PlayScoldAnims();
            }

            AfterAttack();
            FinishLinkedInteraction();
            WaitForSyncComplete();
            if (actorWon && targetRunOnLose && Target.LotCurrent != Target.LotHome)
            {
                // Success! Actor drove the unwanted sim off the lot.
                Target.RequestWalkStyle(WalkStyle.MeanChasedRun);
                MakeSimGoHome(Target, false);
            }
            else if (!actorWon && actorRunOnLose && Actor.LotCurrent != Actor.LotHome)
            {
                // Currently nothing calls this condition, but it seemed good to have it anyway.
                Actor.RequestWalkStyle(WalkStyle.PetRun);
                MakeSimGoHome(Actor, false);
            }

            StandardExit(removeFromUseList: false);
            return(true);
        }
Exemple #3
0
        public override bool Run()
        {
            if (!SafeToSync())
            {
                return(false);
            }

            skillActor = Actor.SkillManager.GetSkill <EWPetFightingSkill>(EWPetFightingSkill.skillNameID);
            if (skillActor == null)
            {
                skillActor = Actor.SkillManager.AddElement(EWPetFightingSkill.skillNameID)
                             as EWPetFightingSkill;
                if (skillActor == null)
                {
                    return(false);
                }
            }

            skillTarget = Target.SkillManager.GetSkill <EWPetFightingSkill>(EWPetFightingSkill.skillNameID);
            if (skillTarget == null)
            {
                skillTarget = Actor.SkillManager.AddElement(EWPetFightingSkill.skillNameID)
                              as EWPetFightingSkill;
                if (skillTarget == null)
                {
                    return(false);
                }
            }

            skillActor.StartSkillGain(skillActor.getSkillGainRate(Actor));
            skillTarget.StartSkillGain(skillTarget.getSkillGainRate(Target));

            BeginCommodityUpdates();
            Actor.RequestWalkStyle(WalkStyle.PetRun);

            if (!BeginSocialInteraction(new SocialInteractionB.Definition(null, GetInteractionName(),
                                                                          allowCarryChild: false), pairedSocial: true, doCallOver: false))
            {
                if (Actor.IsCat)
                {
                    Actor.UnrequestWalkStyle(WalkStyle.CatStalk);
                    PouncePosture pouncePosture2 = Actor.Posture as PouncePosture;
                    if (pouncePosture2 != null)
                    {
                        pouncePosture2.ExitPounce();
                        Actor.PopPosture();
                    }
                }
                else
                {
                    Actor.UnrequestWalkStyle(WalkStyle.PetRun);
                }
                EndCommodityUpdates(false);
                return(false);
            }

            Actor.UnrequestWalkStyle(WalkStyle.PetRun);

            if (Actor.IsCat)
            {
                PouncePosture pouncePosture = PouncePosture.Create(Actor);
                pouncePosture.EnterPounce();
                Actor.Posture = pouncePosture;
            }

            StandardEntry(addToUseList: false);
            StartSocial("Fight Pet");
            ((SocialInteraction)LinkedInteractionInstance).Rejected = Rejected;
            mPetFightNoiseBroadcast = new ReactionBroadcaster(Actor, kPetFightLoudBroadcastParams,
                                                              FightBroadcastCallback);
            PetStartleBehavior.CheckForStartle(Actor, StartleType.Fight);
            EnterStateMachine("PetFight", "Enter", "x");
            SetActor("y", Target);
            AnimateSim("Loop Fight");
            // TODO: A fight should reduce fatigue
            InteractionTuning tuning = InteractionObjectPair.Tuning;

            if (tuning != null && tuning.mTradeoff != null)
            {
                using (List <CommodityChange> .Enumerator enumerator = tuning.mTradeoff.mOutputs.GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        CommodityChange current = enumerator.Current;
                        if (current.Commodity == CommodityKind.CatScratch)
                        {
                            LinkedInteractionInstance.BeginCommodityUpdate(current, 1f);
                        }
                    }
                }
            }

            bool success = DoTimedLoop(RandomUtil.GetFloat(kPetFightTimeMinMax[0], kPetFightTimeMinMax[1]),
                                       ExitReason.Default);

            EndCommodityUpdates(success);
            Actor.Motives.SetValue(CommodityKind.Energy, Actor.Motives.GetMotiveValue(CommodityKind.Energy - 200));
            LinkedInteractionInstance.EndCommodityUpdates(success);
            bool actorWon = DoesActorWinFight();

            if (!actorWon)
            {
                AnimateSim("Swap");
                SetActor("x", Target);
                SetActor("y", Actor);
                skillTarget.wonFight(Actor, Target.LotCurrent == Target.LotHome);
                skillActor.lostFight(Target);
                skillTarget.AddPoints(200f, true, true);
                Actor.ShowTNSIfSelectable(Localization.LocalizeString("Echoweaver/PetFighting/EWFightPet:PetFightLose",
                                                                      Actor.Name), StyledNotification.NotificationStyle.kGameMessageNegative);
            }
            else
            {
                skillActor.wonFight(Target, Actor.LotCurrent == Actor.LotHome);
                skillTarget.lostFight(Actor);
                Actor.ShowTNSIfSelectable(Localization.LocalizeString("Echoweaver/PetFighting/EWFightPet:PetFightWin",
                                                                      Actor.Name), StyledNotification.NotificationStyle.kGameMessagePositive);
            }
            AnimateSim("Exit");

            if (Actor.IsCat)
            {
                Actor.UnrequestWalkStyle(WalkStyle.CatStalk);
                if (Actor.Posture is PouncePosture)
                {
                    Actor.PopPosture();
                }
            }
            else
            {
                Actor.UnrequestWalkStyle(WalkStyle.PetRun);
            }

            EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, Actor, Target, "Fight Pet", wasRecipient: false, wasAccepted: true, actorWon, CommodityTypes.Undefined));
            EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, Target, Actor, "Fight Pet", wasRecipient: true, wasAccepted: true, !actorWon, CommodityTypes.Undefined));

            if (mPetFightNoiseBroadcast != null)
            {
                mPetFightNoiseBroadcast.EndBroadcast();
                mPetFightNoiseBroadcast = null;
            }
            FinishSocial("Fight Pet", bApplySocialEffect: true);
            skillActor.StopSkillGain();
            skillTarget.StopSkillGain();
            FinishLinkedInteraction();
            WaitForSyncComplete();
            StandardExit(removeFromUseList: false);

            LikingChange();

            // Check for death conditions BEFORE new wounds assigned
            CheckForDeath(actorWon);
            AssignFightWounds();

            // If this is called from ChaseOffLot, then the target will flee if it loses
            if (!actorWon && actorRunOnLose && Actor.LotCurrent != Actor.LotHome)
            {
                Actor.PopPosture();
                Actor.RequestWalkStyle(WalkStyle.PetRun);
                MakeSimGoHome(Actor, false);
            }
            else if (actorWon && targetRunOnLose && Target.LotCurrent != Target.LotHome)
            {
                Target.PopPosture();
                if (Target.IsHuman)
                {
                    Target.RequestWalkStyle(WalkStyle.MeanChasedRun);
                }
                else
                {
                    Target.RequestWalkStyle(WalkStyle.PetRun);
                }
                MakeSimGoHome(Target, false);
            }

            return(success);
        }