Ejemplo n.º 1
0
 public override void GuardianAnimationScript(TerraGuardian guardian, ref bool UsingLeftArm, ref bool UsingRightArm)
 {
     if (guardian.BodyAnimationFrame == ThroneSittingFrame && guardian.LookingLeft)
     {
         guardian.FaceDirection(false);
     }
 }
Ejemplo n.º 2
0
        public override void AI()
        {
            if (Main.myPlayer == -1)
            {
                return;
            }
            Player player = Main.player[npc.target];

            if (JustSpawned)
            {
                //if (IsInPerceptionRange(player))
                int     NearestPlayer   = Main.myPlayer;
                float   NearestDistance = float.MaxValue;
                Vector2 NpcCenter       = npc.Center;
                for (int p = 0; p < 255; p++)
                {
                    if (Main.player[p].active)
                    {
                        float Distance = Main.player[p].Distance(NpcCenter);
                        if (Distance < NearestDistance)
                        {
                            NearestDistance = Distance;
                            NearestPlayer   = p;
                        }
                    }
                }
                if (NearestPlayer > -1)
                {
                    player     = Main.player[NearestPlayer];
                    npc.target = NearestPlayer;
                    //Main.NewText("A White Cat appeared to the " + GuardianBountyQuest.GetDirectionText(npc.Center - player.Center) + " of " + player.name + " position.", MainMod.MysteryCloseColor);
                }
                JustSpawned = false;
            }
            if (player.talkNPC == npc.whoAmI)
            {
                npc.direction = player.Center.X - npc.Center.X >= 0 ? 1 : -1;
            }
            if (SceneStep == SceneIds.NoScene && Math.Abs(player.Center.X - npc.Center.X) <= 152 &&
                ((player.Center.X < npc.Center.X && npc.direction < 0) || (player.Center.X > npc.Center.X && npc.direction >= 0)))
            {
                //Found Sardine
                if (PlayerMod.PlayerHasGuardian(player, 7))
                {
                    ChangeScene(SceneIds.BreeSeesFriendlyFace);
                }
                else if (PlayerMod.PlayerHasGuardianSummoned(player, GuardianBase.Glenn) && PlayerMod.PlayerHasGuardianSummoned(player, GuardianBase.Sardine))
                {
                    ChangeScene(SceneIds.BreeSpotsSardineAndGlenn);
                    SayMessage("Are they... Glenn! Sardine!");
                    HadSardineSpotted = HadGlennSpotted = true;
                }
                else if (PlayerMod.PlayerHasGuardianSummoned(player, GuardianBase.Glenn))
                {
                    ChangeScene(SceneIds.GlennSpotted);
                    SayMessage("Gl... Glenn?!");
                    HadSardineSpotted = false;
                    HadGlennSpotted   = true;
                }
                else if (PlayerMod.PlayerHasGuardianSummoned(player, 2))
                {
                    ChangeScene(0);
                    SayMessage("Sardine! I finally found you!");
                    HadSardineSpotted = true;
                    HadGlennSpotted   = false;
                }
            }
            npc.npcSlots = 1;
            if (SceneStep >= 0)
            {
                npc.npcSlots = 200;
                StepTime--;
                bool SceneChange = StepTime == 0;
                if (false && SceneStep == SceneIds.BreePersuadesThePlayerALittleCloser)
                {
                    Vector2 PositionOnPlayer = player.Center;
                    npc.direction       = -player.direction;
                    PositionOnPlayer.X += 12 * player.direction;
                    PositionOnPlayer.Y += -Base.SpriteHeight + Base.SittingPoint.Y;
                    int XMod = Base.SittingPoint.X;
                    if (npc.direction < 0)
                    {
                        XMod = Base.SpriteWidth - XMod;
                    }
                    PositionOnPlayer.X += XMod - Base.SpriteWidth * 0.5f;
                    npc.position        = PositionOnPlayer;
                }
                TerraGuardian guardian = PlayerMod.GetPlayerMainGuardian(player),
                              Sardine  = PlayerMod.GetPlayerSummonedGuardian(player, GuardianBase.Sardine),
                              Glenn    = PlayerMod.GetPlayerSummonedGuardian(player, GuardianBase.Glenn);
                if (HadGlennSpotted && HadSardineSpotted)
                {
                    if (Sardine != null && Glenn != null)
                    {
                        bool GlennIsClosest = (Glenn.CenterPosition - player.Center).Length() < (Sardine.CenterPosition - player.Center).Length();
                        if (GlennIsClosest)
                        {
                            guardian = Glenn;
                            bool IsGlennToTheLeft = guardian.Position.X - npc.Center.X < 0;
                            if (Math.Abs(guardian.Position.X - npc.Center.X) >= 96)
                            {
                                if (!IsGlennToTheLeft)
                                {
                                    MoveRight = true;
                                }
                                else
                                {
                                    MoveLeft = true;
                                }
                            }
                            if (!guardian.IsAttackingSomething && guardian.Velocity.X == 0)
                            {
                                guardian.FaceDirection(!IsGlennToTheLeft);
                            }
                            if (npc.velocity.X == 0)
                            {
                                npc.direction = !IsGlennToTheLeft ? 1 : -1;
                            }
                        }
                        else
                        {
                            guardian = Sardine;
                            bool IsSardineToTheLeft = guardian.Position.X - npc.Center.X < 0;
                            if (Math.Abs(guardian.Position.X - npc.Center.X) >= 96)
                            {
                                if (!IsSardineToTheLeft)
                                {
                                    MoveRight = true;
                                }
                                else
                                {
                                    MoveLeft = true;
                                }
                            }
                            if (!guardian.IsAttackingSomething && guardian.Velocity.X == 0)
                            {
                                guardian.FaceDirection(!IsSardineToTheLeft);
                            }
                            if (npc.velocity.X == 0)
                            {
                                npc.direction = !IsSardineToTheLeft ? 1 : -1;
                            }
                        }
                        if (SceneStep >= SceneIds.BreePersuadesThePlayerToCallHimBack && SceneStep <= SceneIds.BreePersuadesThePlayerALittleCloser)
                        {
                            if (InterruptedOnce)
                            {
                                ChangeScene(SceneIds.SardineIsCalledBackByPlayerAfterInterruption);
                            }
                            else
                            {
                                ChangeScene(SceneIds.PlayerCalledSardineBackAfterBreeAsked);
                            }
                        }
                    }
                    else
                    {
                        bool IsPlayerToTheLeft = player.Center.X - npc.Center.X < 0;
                        if (Math.Abs(player.Center.X - npc.Center.X) >= 96)
                        {
                            if (!IsPlayerToTheLeft)
                            {
                                MoveRight = true;
                            }
                            else
                            {
                                MoveLeft = true;
                            }
                        }
                        if (npc.velocity.X == 0)
                        {
                            npc.direction = !IsPlayerToTheLeft ? 1 : -1;
                        }
                        if (SceneStep >= SceneIds.BothAnswers && SceneStep < SceneIds.BreeThenSaysThatTheyShouldStayInTheWorldForAWhileThen)
                        {
                            InterruptedOnce = true;
                            if (Sardine == null)
                            {
                                ChangeScene(SceneIds.PlayerUnsummonedSardine);
                            }
                            else
                            {
                                ChangeScene(SceneIds.PlayerUnsummonedGlenn);
                            }
                        }
                    }
                }
                else if (HadGlennSpotted)
                {
                    if (Glenn != null)
                    {
                        guardian = Glenn;
                        bool IsGlennToTheLeft = guardian.Position.X - npc.Center.X < 0;
                        if (Math.Abs(guardian.Position.X - npc.Center.X) >= 96)
                        {
                            if (!IsGlennToTheLeft)
                            {
                                MoveRight = true;
                            }
                            else
                            {
                                MoveLeft = true;
                            }
                        }
                        if (!guardian.IsAttackingSomething && guardian.Velocity.X == 0)
                        {
                            guardian.FaceDirection(!IsGlennToTheLeft);
                        }
                        if (npc.velocity.X == 0)
                        {
                            npc.direction = !IsGlennToTheLeft ? 1 : -1;
                        }
                        if (SceneStep >= SceneIds.BreePersuadesThePlayerToCallHimBack && SceneStep <= SceneIds.BreePersuadesThePlayerALittleCloser)
                        {
                            if (InterruptedOnce)
                            {
                                ChangeScene(SceneIds.SardineIsCalledBackByPlayerAfterInterruption);
                            }
                            else
                            {
                                ChangeScene(SceneIds.PlayerCalledSardineBackAfterBreeAsked);
                            }
                        }
                    }
                    else
                    {
                        bool IsPlayerToTheLeft = player.Center.X - npc.Center.X < 0;
                        if (Math.Abs(player.Center.X - npc.Center.X) >= 96)
                        {
                            if (!IsPlayerToTheLeft)
                            {
                                MoveRight = true;
                            }
                            else
                            {
                                MoveLeft = true;
                            }
                        }
                        if (npc.velocity.X == 0)
                        {
                            npc.direction = !IsPlayerToTheLeft ? 1 : -1;
                        }
                        if (SceneStep >= SceneIds.GlennAnswer && SceneStep < SceneIds.BreeJoinsToTakeCareOfGlenn)
                        {
                            InterruptedOnce = true;
                            ChangeScene(SceneIds.PlayerUnsummonedGlenn);
                        }
                    }
                }
                else if (HadSardineSpotted)
                {
                    if (Sardine != null)
                    {
                        guardian = Sardine;
                        bool IsSardineToTheLeft = guardian.Position.X - npc.Center.X < 0;
                        if (Math.Abs(guardian.Position.X - npc.Center.X) >= 96)
                        {
                            if (!IsSardineToTheLeft)
                            {
                                MoveRight = true;
                            }
                            else
                            {
                                MoveLeft = true;
                            }
                        }
                        if (!guardian.IsAttackingSomething)
                        {
                            guardian.FaceDirection(!IsSardineToTheLeft);
                        }
                        if (npc.velocity.X == 0)
                        {
                            npc.direction = !IsSardineToTheLeft ? 1 : -1;
                        }
                        if (SceneStep >= SceneIds.BreePersuadesThePlayerToCallHimBack && SceneStep <= SceneIds.BreePersuadesThePlayerALittleCloser)
                        {
                            if (InterruptedOnce)
                            {
                                ChangeScene(SceneIds.SardineIsCalledBackByPlayerAfterInterruption);
                            }
                            else
                            {
                                ChangeScene(SceneIds.PlayerCalledSardineBackAfterBreeAsked);
                            }
                        }
                    }
                    else
                    {
                        bool IsPlayerToTheLeft = player.Center.X - npc.Center.X < 0;
                        if (Math.Abs(player.Center.X - npc.Center.X) >= 96)
                        {
                            if (!IsPlayerToTheLeft)
                            {
                                MoveRight = true;
                            }
                            else
                            {
                                MoveLeft = true;
                            }
                        }
                        if (npc.velocity.X == 0)
                        {
                            npc.direction = !IsPlayerToTheLeft ? 1 : -1;
                        }
                        if (SceneStep >= SceneIds.SardineStaysAndTalksToBree && SceneStep < SceneIds.BreeTurnsToTownNpc)
                        {
                            InterruptedOnce = true;
                            ChangeScene(SceneIds.PlayerUnsummonedSardine);
                        }
                        if (SceneStep == SceneIds.SardineSpotted)
                        {
                            ChangeScene(SceneIds.SardineFlees);
                        }
                    }
                }
                if (SceneChange)
                {
                    switch (SceneStep)
                    {
                    case SceneIds.SardineSpotted:
                        if (guardian.FriendshipLevel < 5 && (!PlayerMod.HasBuddiesModeOn(player) || !PlayerMod.GetPlayerBuddy(player).IsSameID(guardian)))     //Tries to flee
                        {
                            ChangeScene(SceneIds.SardineFlees);
                            guardian.SaySomething("Uh oh, I gotta go.");
                        }
                        else     //Stays
                        {
                            ChangeScene(SceneIds.SardineStaysAndTalksToBree);
                            guardian.SaySomething("Uh oh.");
                        }
                        break;

                    case SceneIds.SardineFlees:
                        if (PlayerMod.GetPlayerMainGuardian(player).Active)
                        {
                            TerraGuardian SardineRef = null;
                            foreach (TerraGuardian tg in player.GetModPlayer <PlayerMod>().GetAllGuardianFollowers)
                            {
                                if (tg.ID == 2 && tg.ModID == MainMod.mod.Name)
                                {
                                    SardineRef = tg;
                                    break;
                                }
                            }
                            player.GetModPlayer <PlayerMod>().DismissGuardian(2, "");
                            if (SardineRef != null && SardineRef.Active)
                            {
                                SardineRef.Spawn();
                            }
                        }
                        SayMessage("What? Where did he go?");
                        ChangeScene(SceneIds.BreeAsksWhereSardineWent);
                        break;

                    case SceneIds.BreeAsksWhereSardineWent:
                        SayMessage("You can call him back, right? Do so.");
                        ChangeScene(SceneIds.BreePersuadesThePlayerToCallHimBack);
                        break;

                    case SceneIds.BreePersuadesThePlayerToCallHimBack:
                        SayMessage("Call him back. NOW!");
                        ChangeScene(SceneIds.BreePersuadesThePlayerToCallHimBackAgain);
                        break;

                    case SceneIds.BreePersuadesThePlayerToCallHimBackAgain:
                        ChangeScene(SceneIds.BreePersuadesThePlayerALittleCloser);
                        SayMessage("I said... NOW!!!!");
                        break;

                    case SceneIds.BreePersuadesThePlayerALittleCloser:
                    {
                        string Message = "";
                        switch (SceneRepeatTimes)
                        {
                        case 0:
                            Message = "Call him! JUST. CALL. HIM!";
                            break;

                        case 1:
                            Message = "You are making me angry.... EVEN MORE ANGRY!!!";
                            break;

                        case 2:
                            Message = "GRRRRRRR!!! RRRRRRRRRRRRRRRR!!! RRRRRRRRRRRRRRGHHHH!!";
                            break;

                        case 3:
                            Message = "MY PATIENCE IS ALREADY GOING DOWN THE DRAIN! CALL HIM BACK, NOW!!";
                            break;

                        case 4:
                            Message = "ENOUGH!! CALL HIM, NOW!";
                            ChangeScene(SceneIds.BreeForcedPlayerToCallSardineBack);
                            break;
                        }
                        if (SceneStep == SceneIds.BreePersuadesThePlayerALittleCloser && SceneRepeatTimes < 4)
                        {
                            ChangeScene(SceneIds.BreePersuadesThePlayerALittleCloser);
                        }
                        SayMessage(Message);
                    }
                    break;

                    case SceneIds.BreeForcedPlayerToCallSardineBack:
                    {
                        if (HadSardineSpotted)
                        {
                            player.GetModPlayer <PlayerMod>().CallGuardian(2, "");
                        }
                        if (HadGlennSpotted)
                        {
                            player.GetModPlayer <PlayerMod>().CallGuardian(GuardianBase.Glenn, "");
                        }
                        SayMessage("Good.");
                        if (HadSardineSpotted && HadGlennSpotted)
                        {
                            ChangeScene(SceneIds.BreeAsksWhereWasSardine);
                        }
                        else if (HadGlennSpotted)
                        {
                            ChangeScene(SceneIds.GlennSpotted);
                        }
                        else
                        {
                            ChangeScene(SceneIds.SardineStaysAndTalksToBree);
                        }
                    }
                    break;

                    case SceneIds.SardineStaysAndTalksToBree:
                    {
                        guardian.SaySomething("H-Hello dear, how have you been latelly?");
                        ChangeScene(SceneIds.BreeScoldsSardine);
                    }
                    break;

                    case SceneIds.BreeScoldsSardine:
                    {
                        SayMessage("Seriously?! That is all you have to say?");
                        ChangeScene(SceneIds.BreeContinues);
                    }
                    break;

                    case SceneIds.BreeContinues:
                    {
                        SayMessage("You abandon me and your son at home and that is what you have to say?");
                        ChangeScene(SceneIds.SardineTriesToApologise);
                    }
                    break;

                    case SceneIds.SardineTriesToApologise:
                    {
                        guardian.SaySomething("I'm sorry?");
                        ChangeScene(SceneIds.BreeDoesntAcceptTheApology);
                    }
                    break;

                    case SceneIds.BreeDoesntAcceptTheApology:
                    {
                        SayMessage("That is it? You numbskull, you've been missing for " + (guardian.Data.GetBirthdayAge - guardian.Base.Age + 2) + " WHOLE YEARS!!");
                        ChangeScene(SceneIds.BreeContinuesAfterNotAcceptingTheApology);
                    }
                    break;

                    case SceneIds.BreeContinuesAfterNotAcceptingTheApology:
                    {
                        SayMessage("Do you know how many worlds I travelled trying to find you! Even the planet of the tentacles I had to travel through!");
                        ChangeScene(SceneIds.SardineTriesToApologiseAgain);
                    }
                    break;

                    case SceneIds.SardineTriesToApologiseAgain:
                    {
                        guardian.SaySomething("I already said that I'm sorry. I... Kind of forgot what world we lived so... I couldn't return.");
                        guardian.DisplayEmotion(TerraGuardian.Emotions.Sweat);
                        ChangeScene(SceneIds.BreeTalksAboutTakingSardineBackWithHer);
                    }
                    break;

                    case SceneIds.BreeTalksAboutTakingSardineBackWithHer:
                    {
                        SayMessage("Then there is no problem, since YOU are going back home with ME!");
                        ChangeScene(SceneIds.SardineTriesTheButs);
                    }
                    break;

                    case SceneIds.SardineTriesTheButs:
                    {
                        guardian.SaySomething("But... But... I have a job here and...");
                        ChangeScene(SceneIds.BreeSaysNoToButs);
                    }
                    break;

                    case SceneIds.BreeSaysNoToButs:
                    {
                        SayMessage("No buts! We are going back now! I just need to remember which world we-");
                        ChangeScene(SceneIds.BreeTakesAPauseToRealizeSheForgotToo);
                    }
                    break;

                    case SceneIds.BreeTakesAPauseToRealizeSheForgotToo:
                    {
                        SayMessage("...");
                        ChangeScene(SceneIds.BreeForgotTheWorldTheyLived);
                    }
                    break;

                    case SceneIds.BreeForgotTheWorldTheyLived:
                    {
                        SayMessage("This can't be happening... I forgot which world we lived on!");
                        ChangeScene(SceneIds.SardineLaughsOfBree);
                    }
                    break;

                    case SceneIds.SardineLaughsOfBree:
                    {
                        guardian.SaySomething("Haha! Joke is on you now. Looks like you'll have to say here for a while, until you remember.");
                        guardian.DisplayEmotion(TerraGuardian.Emotions.Happy);
                        ChangeScene(SceneIds.BreeAgrees);
                    }
                    break;

                    case SceneIds.BreeAgrees:
                    {
                        SayMessage("Grrr... Alright! I'll stay for a while, but only until I remember the world we lived!");
                        ChangeScene(SceneIds.BreeIntroducesHerself);
                    }
                    break;

                    case SceneIds.BreeIntroducesHerself:
                    {
                        SayMessage("My name is " + Base.Name + ", don't expect me to stay for long.");
                        ChangeScene(SceneIds.BreeTurnsToTownNpc);
                    }
                    break;

                    case SceneIds.BreeTurnsToTownNpc:
                    {
                        TransformNPC();
                    }
                    break;

                    case SceneIds.SardineIsCalledBackByPlayer:
                    {
                        SayMessage("There he is.");
                        ChangeScene(SceneIds.SardineStaysAndTalksToBree);
                    }
                    break;

                    case SceneIds.SardineIsCalledBackByPlayerAfterInterruption:
                    {
                        SayMessage("Don't do that again!");
                        ChangeScene(SceneIds.BreeTalksAboutSardineGoingBackWithHer);
                    }
                    break;

                    case SceneIds.BreeTalksAboutSardineGoingBackWithHer:
                    {
                        SayMessage("We are returning to home right now!");
                        ChangeScene(SceneIds.SardineTriesTheButs);
                    }
                    break;

                    case SceneIds.PlayerUnsummonedSardine:
                    {
                        SayMessage("Hey! We were talking!");
                        InterruptedOnce = true;
                        ChangeScene(SceneIds.BreePersuadesThePlayerToCallHimBack);
                    }
                    break;

                    case SceneIds.PlayerCalledSardineBackAfterBreeAsked:
                    {
                        SayMessage("Thank you. Now where was I?");
                        ChangeScene(SceneIds.SardineStaysAndTalksToBree);
                    }
                    break;

                    case SceneIds.BreeSeesFriendlyFace:
                    {
                        SayMessage("Oh, It's you again.");
                        ChangeScene(SceneIds.BreeSaysHowSheAppearedThere);
                    }
                    break;

                    case SceneIds.BreeSaysHowSheAppearedThere:
                    {
                        SayMessage("I'm still looking for the world I lived, but It's funny to bump into you on the way.");
                        ChangeScene(SceneIds.BreeJoinsYou);
                    }
                    break;

                    case SceneIds.BreeJoinsYou:
                    {
                        SayMessage("Anyway, I'm here, If you need me.");
                        ChangeScene(SceneIds.BreeTurnsToTownNpc);
                    }
                    break;

                    case SceneIds.GlennSpotted:
                    {
                        SayMessage("Glenn! What are you doing here? You should be at home.");
                        ChangeScene(SceneIds.GlennAnswer);
                    }
                    break;

                    case SceneIds.GlennAnswer:
                    {
                        guardian.SaySomething("You and Dad were taking too long to come home, so I came looking for you two.");
                        ChangeScene(SceneIds.AsksGlennIfHesOkay);
                    }
                    break;

                    case SceneIds.AsksGlennIfHesOkay:
                    {
                        SayMessage("But It's dangerous out there! Are you hurt?");
                        ChangeScene(SceneIds.GlennSaysThatIsFine);
                    }
                    break;

                    case SceneIds.GlennSaysThatIsFine:
                    {
                        guardian.SaySomething("I'm okay, don't worry. This Terrarian let me stay here, and It's safe here.");
                        ChangeScene(SceneIds.BreeJoinsToTakeCareOfGlenn);
                    }
                    break;

                    case SceneIds.BreeJoinsToTakeCareOfGlenn:
                    {
                        SayMessage("I can't let you stay here alone, I shouldn't have let you stay alone at home either. I'll stay here to take care of you, and look for your father.");
                        ChangeScene(SceneIds.BreeIntroducesHerself);
                    }
                    break;

                    case SceneIds.BreeSpotsSardineAndGlenn:
                    {
                        SayMessage("Are you two alright?");
                        ChangeScene(SceneIds.BothAnswers);
                    }
                    break;

                    case SceneIds.BothAnswers:
                    {
                        Sardine.SaySomething("Yes, we're fine.");
                        Glenn.SaySomething("I'm okay.");
                        ChangeScene(SceneIds.BreeAsksWhereWasSardine);
                    }
                    break;

                    case SceneIds.BreeAsksWhereWasSardine:
                    {
                        SayMessage("I'm so glad you two are fine. Sardine, where did you go? Why didn't you returned home?");
                        ChangeScene(SceneIds.SardineAnswers);
                    }
                    break;

                    case SceneIds.SardineAnswers:
                    {
                        Sardine.SaySomething("I was trying to find treasures for you two... And then I was saved by that Terrarian from a bounty hunt that gone wrong.");
                        ChangeScene(SceneIds.BreeThenFeelsRelievedAndAsksGlennWhatIsHeDoingHere);
                    }
                    break;

                    case SceneIds.BreeThenFeelsRelievedAndAsksGlennWhatIsHeDoingHere:
                    {
                        SayMessage("I think I should think you then, Terrarian. Now Glenn, I told you to wait for us at home!");
                        ChangeScene(SceneIds.GlennAnswers);
                    }
                    break;

                    case SceneIds.GlennAnswers:
                    {
                        Glenn.SaySomething("I stayed at home, but I was worried that you two didn't returned yet, so I explored worlds trying to find you two.");
                        ChangeScene(SceneIds.BreeSuggestsToSpendSomeTimeTogetherBeforeReturningToTheWorld);
                    }
                    break;

                    case SceneIds.BreeSuggestsToSpendSomeTimeTogetherBeforeReturningToTheWorld:
                    {
                        SayMessage("That's really reckless and dangerous, but I'm glad you two are unharmed. Let's spend a little time here and then return home.");
                        ChangeScene(SceneIds.SardineSaysThatForgotWhereTheWorldIsAt);
                    }
                    break;

                    case SceneIds.SardineSaysThatForgotWhereTheWorldIsAt:
                    {
                        Sardine.SaySomething("I hope you know our way home, because I forgot.");
                        ChangeScene(SceneIds.GlennAlsoSaysThatForgot);
                    }
                    break;

                    case SceneIds.GlennAlsoSaysThatForgot:
                    {
                        Glenn.SaySomething("I also forgot my way back home, sorry mom.");
                        ChangeScene(SceneIds.BreeThenSaysThatTheyShouldStayInTheWorldForAWhileThen);
                    }
                    break;

                    case SceneIds.BreeThenSaysThatTheyShouldStayInTheWorldForAWhileThen:
                    {
                        SayMessage("I can't remember either.... Well, I hope you don't mind if we stay here for longer, Terrarian.");
                        ChangeScene(SceneIds.BreeIntroducesHerself);
                    }
                    break;

                    case SceneIds.PlayerUnsummonedGlenn:
                    {
                        SayMessage("Where did you sent my son? Call him back now!");
                        InterruptedOnce = true;
                        ChangeScene(SceneIds.BreePersuadesThePlayerToCallHimBack);
                    }
                    break;
                    }
                }
                if (StepTime <= -600)
                {
                    SayMessage("Uh... What was I saying? Oh... I remember now.");
                    ChangeScene(SceneStep);
                }
            }
            else
            {
                Idle = true;
            }
            base.AI();
            if (!Main.dayTime)
            {
                bool PlayerInRange = false;
                for (int p = 0; p < 255; p++)
                {
                    Player pl = Main.player[p];
                    if ((Math.Abs(pl.Center.X - npc.Center.X) >= NPC.sWidth * 0.5f + NPC.safeRangeX ||
                         Math.Abs(pl.Center.Y - npc.Center.Y) >= NPC.sHeight * 0.5f + NPC.safeRangeY))
                    {
                        PlayerInRange = true;
                    }
                }
                if (!PlayerInRange)
                {
                    //Main.NewText("The White Cat resumed the search for her husband.", Color.OrangeRed);
                    npc.active = false;
                    npc.life   = 0;
                }
            }
        }
Ejemplo n.º 3
0
        public override void Update(TerraGuardian guardian)
        {
            if (guardian.furniturex > -1)
            {
                guardian.LeaveFurniture(false);
            }
            if (guardian.KnockedOut || guardian.IsBeingPulledByPlayer)
            {
                InUse = false;
                return;
            }
            if ((guardian.OwnerPos > -1 && guardian.PlayerMounted && !Main.player[guardian.OwnerPos].GetModPlayer <PlayerMod>().KnockedOut) || guardian.Is2PControlled)
            {
                if (!guardian.MoveDown)
                {
                    InUse = false;
                    return;
                }
            }
            if (guardian.ItemAnimationTime > 0)
            {
                return;
            }
            Vector2 TargetPosition = Vector2.Zero;
            int     TargetWidth = 0, TargetHeight = 0;
            bool    TryReaching               = false;
            bool    IsMountedPlayer           = false;
            bool    AffectedByNegativeHealing = false;

            if (TargetIsPlayer)
            {
                PlayerMod pm = RevivePlayer.GetModPlayer <PlayerMod>();
                AffectedByNegativeHealing = pm.NegativeReviveBoost;
                TargetPosition            = RevivePlayer.position;
                TargetWidth  = RevivePlayer.width;
                TargetHeight = RevivePlayer.height;
                if (RevivePlayer.dead || !RevivePlayer.active || !pm.KnockedOut)
                {
                    InUse = false;
                    return;
                }
                if (guardian.PlayerMounted && RevivePlayer.whoAmI == guardian.OwnerPos)
                {
                    IsMountedPlayer = true;
                }
            }
            else
            {
                TargetPosition = ReviveGuardian.TopLeftPosition;
                TargetWidth    = ReviveGuardian.Width;
                TargetHeight   = ReviveGuardian.Height;
                if (!ReviveGuardian.Active || ReviveGuardian.Downed || !ReviveGuardian.KnockedOut)
                {
                    InUse = false;
                    return;
                }
                if (ReviveGuardian.OwnerPos == guardian.OwnerPos && ReviveGuardian.PlayerControl && guardian.PlayerMounted)
                {
                    IsMountedPlayer = true;
                }
            }
            bool RepelingEnemies = false;

            guardian.MoveLeft = guardian.MoveRight = false;
            if (guardian.TargetID > -1 && !AffectedByNegativeHealing)
            {
                Vector2 EnemyPosition;
                int     EnemyWidth, EnemyHeight;
                guardian.GetTargetInformation(out EnemyPosition, out EnemyWidth, out EnemyHeight);
                EnemyPosition.X += EnemyWidth * 0.5f;
                EnemyPosition.Y += EnemyHeight * 0.5f;
                if (IsMountedPlayer || (Math.Abs(EnemyPosition.X - guardian.Position.X) < 168f + (EnemyWidth + guardian.Width) * 0.5f &&
                                        Math.Abs(EnemyPosition.Y - guardian.CenterY) < 168f + (EnemyHeight + guardian.Height) * 0.5f))
                {
                    RepelingEnemies          = true;
                    IgnoreCombat             = false;
                    guardian.AttackingTarget = true;
                }
                else
                {
                    IgnoreCombat = true;
                }
            }
            else
            {
                IgnoreCombat = false;
            }
            if (!RepelingEnemies)
            {
                bool OffSetToTheLeft = TargetPosition.X + TargetWidth * 0.5f < guardian.Position.X;
                {
                    int Animation    = guardian.Base.StandingFrame;
                    int ArmAnimation = -1;
                    if (IsMountedPlayer)
                    {
                        ArmAnimation = guardian.Base.ItemUseFrames[2];
                    }
                    else
                    {
                        if (guardian.Base.ReviveFrame > -1)
                        {
                            Animation = guardian.Base.ReviveFrame;
                        }
                        else if (guardian.Base.DuckingFrame > -1)
                        {
                            Animation    = guardian.Base.DuckingFrame;
                            ArmAnimation = guardian.Base.DuckingSwingFrames[2];
                        }
                    }
                    if (ArmAnimation == -1)
                    {
                        ArmAnimation = Animation;
                    }
                    guardian.Base.GetBetweenHandsPosition(ArmAnimation, out int x, out int y);
                    float ArmXDistance = (x - guardian.SpriteWidth * 0.5f) * guardian.Scale;
                    if (ArmXDistance > 0)
                    {
                        TargetWidth += (int)ArmXDistance;
                        if (OffSetToTheLeft)
                        {
                            TargetPosition.X -= ArmXDistance;
                        }
                    }
                }
                if (IsMountedPlayer || new Rectangle((int)TargetPosition.X, (int)TargetPosition.Y, TargetWidth, TargetHeight).Intersects(guardian.HitBox))//(MainMod.RectangleIntersects(guardian.TopLeftPosition, guardian.Width, guardian.Height, TargetPosition, TargetWidth, TargetHeight))
                {
                    guardian.Jump = false;
                    float DistanceFromTarget = Math.Abs(guardian.Position.X - (TargetPosition.X + TargetWidth * 0.5f));
                    if (DistanceFromTarget < 8)
                    {
                        if (Math.Abs(guardian.Velocity.X) < 2f)
                        {
                            if (guardian.Position.X < TargetPosition.X + TargetWidth * 0.5f)
                            {
                                guardian.MoveLeft = true;
                            }
                            else
                            {
                                guardian.MoveRight = true;
                            }
                        }
                    }
                    else if (guardian.Velocity.X != 0)
                    {
                        if (Math.Abs(guardian.Position.X + guardian.Velocity.X - (TargetPosition.X + TargetWidth * 0.5f)) < 12)
                        {
                            guardian.MoveLeft    = guardian.MoveRight = false;
                            guardian.Velocity.X *= 0.8f;
                        }
                    }
                    else if (guardian.Velocity.X == 0)
                    {
                        {
                            Vector2 FacingLeftPosition  = guardian.GetLeftHandPosition(guardian.Base.ReviveFrame, true),
                                    FacingRightPosition = FacingLeftPosition;
                            FacingLeftPosition.X  *= -1;
                            FacingLeftPosition.X  += guardian.Position.X - (TargetPosition.X + TargetWidth * 0.5f);
                            FacingRightPosition.X += guardian.Position.X - (TargetPosition.X + TargetWidth * 0.5f);
                            guardian.FaceDirection(Math.Abs(FacingLeftPosition.X) < Math.Abs(FacingRightPosition.X));
                        }
                        byte ReviveBoost = 1;
                        if (!guardian.IsAttackingSomething)
                        {
                            ReviveBoost += 2;
                        }
                        bool IsMounted = guardian.PlayerMounted;
                        if (TargetIsPlayer)
                        {
                            RevivePlayer.GetModPlayer <PlayerMod>().ReviveBoost += ReviveBoost;
                        }
                        else
                        {
                            ReviveGuardian.ReviveBoost += ReviveBoost;
                        }
                        guardian.StuckTimer    = 0;
                        guardian.OffHandAction = false;
                        if (SpeakToFallen)
                        {
                            SpeakToFallen = false;
                            if (MainMod.CompanionsSpeaksWhileReviving)
                            {
                                guardian.SaySomething(guardian.Base.ReviveMessage(guardian, TargetIsPlayer, (TargetIsPlayer ? RevivePlayer : null), (!TargetIsPlayer ? ReviveGuardian : null)));
                            }
                        }
                    }
                }
                else
                {
                    TryReaching = true;
                }
            }
            if (TryReaching)
            {
                if (ResTime >= 5 * 60)
                {
                    guardian.Position.X = TargetPosition.X + Main.rand.Next(TargetWidth);
                    guardian.Position.Y = TargetPosition.Y + TargetHeight - 1;
                    guardian.FallStart  = (int)guardian.Position.Y / 16;
                }
                else if (TargetPosition.X + TargetWidth * 0.5f - guardian.Position.X < 0)
                {
                    guardian.MoveLeft = true;
                }
                else
                {
                    guardian.MoveRight = true;
                }
                guardian.WalkMode = false;
                ResTime++;
            }
            else
            {
                ResTime = 0;
            }
        }