예제 #1
0
        public override void Update(TerraGuardian guardian)
        {
            bool CanPickupPlayer = guardian.Base.MountUnlockLevel != 255 && guardian.Base.Size >= GuardianBase.GuardianSize.Large && !guardian.PlayerMounted && !guardian.SittingOnPlayerMount;

            AvoidItemUsage = true;
            bool HoldingPlayer = false;

            FocusCameraOnGuardian = false;

            /*if (Target.dead)
             * {
             *  InUse = false;
             *  return;
             * }*/
            switch (Step)
            {
            case 0:
                if (guardian.furniturex > -1)
                {
                    guardian.LeaveFurniture();
                }
                if (TryReachingPlayer(guardian, Target))
                {
                    ChangeStep();
                }
                break;

            case 1:
                if (!CanPickupPlayer)
                {
                    ChangeStep();
                }
                else
                {
                    FocusCameraOnGuardian = true;
                    if (Time < 8)
                    {
                        int AnimFrame = Time / 4;
                        if (guardian.Ducking)
                        {
                            SetPlayerOnHandPosition(guardian, Target, guardian.Base.DuckingSwingFrames[2 - AnimFrame], HeldHand.Right);
                        }
                        else
                        {
                            SetPlayerOnHandPosition(guardian, Target, guardian.Base.ItemUseFrames[3 - AnimFrame], HeldHand.Right);
                        }
                    }
                    else
                    {
                        HoldingPlayer = true;
                        ChangeStep();
                    }
                }
                break;

            case 2:
            {
                IgnoreCombat     = true;
                AvoidItemUsage   = false;
                EffectOnlyMirror = true;
                if (!guardian.HasMagicMirror)
                {
                    ChangeStep(4);
                }
                if (guardian.ItemAnimationTime <= 0)
                {
                    guardian.UseMagicMirror();
                    if (Time >= 10 * 60)
                    {
                        ChangeStep(4);
                        Main.NewText("For some reason, " + guardian.Name + " got Itself confused when using the magic mirror.");
                    }
                }
                if (guardian.MagicMirrorTrigger)
                {
                    ChangeStep();
                    Player player = Target;
                    if (guardian.HasBuff(Terraria.ID.BuffID.Horrified))
                    {
                        string Mes;
                        switch (Main.rand.Next(6))
                        {
                        default:
                            Mes = " is asking if you are nuts.";
                            break;

                        case 0:
                            Mes = " is asking what you have on your head.";
                            break;

                        case 1:
                            Mes = " says that this is not the right time and place to do that.";
                            break;

                        case 2:
                            Mes = " questions itself \"WHAT?!\" a few moments before attempting to teleport.";
                            break;

                        case 3:
                            Mes = " asks if there is something wrong with your head.";
                            break;

                        case 4:
                            Mes = " said that It's not the wisest thing to do right now.";
                            break;
                        }
                        Main.NewText("*" + guardian.Name + Mes + "*");
                    }
                    else
                    {
                        player.Spawn();
                        guardian.Spawn();
                        PlayerMod pm = player.GetModPlayer <PlayerMod>();

                        /*guardian.Spawn();
                         * guardian.Position.X = player.SpawnX * 16;
                         * guardian.Position.Y = player.SpawnY * 16;
                         * player.position.X = player.SpawnX * 16 + 8 - player.width * 0.5f;
                         * player.position.Y = player.SpawnY * 16 - player.height;*/
                        Vector2 PlayerBottom = new Vector2(player.position.X + player.width * 0.5f, player.position.Y + player.height);
                        guardian.Position  = PlayerBottom;
                        guardian.FallStart = (int)guardian.Position.Y / 16;
                        foreach (TerraGuardian mg in pm.GetAllGuardianFollowers)
                        {
                            if (mg.Active && (mg.PlayerMounted || mg.PlayerControl))
                            {
                                mg.Spawn();
                                mg.Position  = PlayerBottom;
                                mg.FallStart = (int)mg.Position.Y / 16;
                            }
                        }
                    }
                }
                HoldingPlayer = true;
            }
            break;

            case 3:
            {
                if (guardian.ItemAnimationTime == 0)
                {
                    ChangeStep();
                }
                HoldingPlayer = true;
            }
            break;

            case 4:
            {
                if (!CanPickupPlayer)
                {
                    ChangeStep();
                }
                else
                {
                    FocusCameraOnGuardian = true;
                    if (Time < 8)
                    {
                        if (guardian.Ducking)
                        {
                            int AnimFrame = 2 - Time / 4;
                            SetPlayerOnHandPosition(guardian, Target, guardian.Base.DuckingSwingFrames[2 - AnimFrame], HeldHand.Right);
                        }
                        else
                        {
                            int AnimFrame = 2 - Time / 4;
                            SetPlayerOnHandPosition(guardian, Target, guardian.Base.ItemUseFrames[3 - AnimFrame], HeldHand.Right);
                        }
                    }
                    else
                    {
                        ChangeStep();
                    }
                }
            }
            break;

            case 5:
                if (CanPickupPlayer)
                {
                    SetPlayerPositionOnGuardianCenter(guardian, Target);
                }
                InUse = false;
                break;
            }
            if (HoldingPlayer)
            {
                if (CanPickupPlayer)
                {
                    FocusCameraOnGuardian = true;
                    if (guardian.Ducking)
                    {
                        SetPlayerOnHandPosition(guardian, Target, guardian.Base.DuckingSwingFrames[1], HeldHand.Right);
                    }
                    else
                    {
                        SetPlayerOnHandPosition(guardian, Target, guardian.Base.ItemUseFrames[2], HeldHand.Right);
                    }
                    Target.velocity.Y = -Player.defaultGravity;
                    guardian.ProtectingPlayerFromHarm = true;
                }
                else if (!guardian.PlayerMounted && !guardian.SittingOnPlayerMount)
                {
                    /*Vector2 HandPosition = GetHandPosition(guardian, guardian.Base.ItemUseFrames[2], HeldHand.Right);
                     * float HorizontalPosChange = Target.Center.X - HandPosition.X;
                     * if (!guardian.PlayerMounted && !guardian.SittingOnPlayerMount && Math.Abs(HorizontalPosChange) >= Target.width * 0.5f)
                     * {
                     *  //guardian.Position.X += HorizontalPosChange;
                     *  if (HorizontalPosChange < 0)
                     *  {
                     *      guardian.MoveLeft = true;
                     *  }
                     *  else
                     *  {
                     *      guardian.MoveRight = true;
                     *  }
                     * }*/
                }
            }
        }
예제 #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;
                }
            }
        }
예제 #3
0
        public override void Update(TerraGuardian guardian)
        {
            LiebreBase.ReaperGuardianData data = (LiebreBase.ReaperGuardianData)guardian.Data;
            switch (Step)
            {
            case 0:
                if (StepStart)
                {
                    SoulsValue = data.SoulsLoaded;
                    if (SoulsValue >= LiebreBase.MaxSoulsContainedValue)
                    {
                        guardian.SaySomething("*I must go, now!*");
                    }
                    else if (SoulsValue >= LiebreBase.MaxSoulsContainedValue * 0.9f)
                    {
                        guardian.SaySomething("*I'll unload those souls, I feel like I'm reaching my capacity.*");
                    }
                    else
                    {
                        guardian.SaySomething("*I'll be right back.*");
                    }
                }
                IgnoreCombat = true;
                if (Main.rand.NextDouble() < 0.333)
                {
                    Dust.NewDust(guardian.TopLeftPosition, guardian.Width, guardian.Height, 192, 0, -0.2f, Scale: Main.rand.NextFloat(0.8f, 1.2f));
                }
                if (Time >= 3 * 60)
                {
                    ChangeStep();
                    data.SoulsLoaded     = 0;
                    Invisibility         = true;
                    LastWasPlayerMounted = guardian.PlayerMounted;
                    guardian.ToggleMount(true);
                    guardian.ClearMessagesSaid();
                }
                break;

            case 1:
                Invisibility = true;
                IgnoreCombat = true;
                Inactivity   = true;
                if (guardian.OwnerPos > -1)
                {
                    guardian.Position = Main.player[guardian.OwnerPos].Bottom;
                }
                if (Time >= 10 * 60)
                {
                    ChangeStep();
                }
                break;

            case 2:
                Invisibility = false;
                IgnoreCombat = false;
                Inactivity   = false;
                if (StepStart)
                {
                    guardian.Spawn();
                    if (guardian.OwnerPos > -1)
                    {
                        guardian.Position = Main.player[guardian.OwnerPos].Bottom;
                        if (LastWasPlayerMounted)
                        {
                            guardian.ToggleMount(true, false);
                        }
                    }
                }
                if (Time >= 30)
                {
                    if (SoulsValue >= LiebreBase.MaxSoulsContainedValue)
                    {
                        guardian.SaySomething("*I felt like about to blow...*");
                    }
                    else if (SoulsValue >= LiebreBase.MaxSoulsContainedValue * 0.9f)
                    {
                        guardian.SaySomething("*I'm glad I managed to do the delivery in time.*");
                    }
                    else
                    {
                        guardian.SaySomething("*I returned.*");
                    }
                }
                if (Time % 10 == 0)
                {
                    float HeightVal = Time / 10 * 0.1f * guardian.Height;
                    for (int i = -1; i < 2; i++)
                    {
                        Vector2 EffectPosition = new Vector2(guardian.Position.X, guardian.Position.Y);
                        EffectPosition.Y -= HeightVal;
                        EffectPosition.X += guardian.Width * 0.6f * i;
                        Dust.NewDust(EffectPosition, 1, 1, 192, 0, -0.2f, 192, Scale: Main.rand.NextFloat(0.8f, 1.2f));
                    }
                }
                if (Time >= 100)
                {
                    {
                        float CapacityPercentage = (float)SoulsValue / LiebreBase.MaxSoulsContainedValue;
                        int   BuffDuration       = (int)(CapacityPercentage * 900) * 60;
                        if (SoulsValue > LiebreBase.MaxSoulsContainedValue)
                        {
                            BuffDuration = (int)(BuffDuration * 0.75f);
                        }
                        for (int i = 0; i < CapacityPercentage * 5; i++)
                        {
                            int BuffID = Utils.SelectRandom(Main.rand, new int[] { Terraria.ID.BuffID.Lifeforce, Terraria.ID.BuffID.Regeneration,
                                                                                   Terraria.ID.BuffID.Endurance, Terraria.ID.BuffID.ManaRegeneration, Terraria.ID.BuffID.Mining, Terraria.ID.BuffID.ObsidianSkin,
                                                                                   Terraria.ID.BuffID.Thorns });
                            for (int p = 0; p < 255; p++)
                            {
                                if (Main.player[p].active && !guardian.IsPlayerHostile(Main.player[p]))
                                {
                                    Main.player[p].AddBuff(BuffID, BuffDuration);
                                }
                            }
                            foreach (TerraGuardian g in MainMod.ActiveGuardians.Values)
                            {
                                if (g.OwnerPos == guardian.OwnerPos && !g.IsGuardianHostile(guardian))
                                {
                                    g.AddBuff(BuffID, BuffDuration);
                                }
                            }
                        }
                        guardian.SaySomethingCanSchedule("*Take this blessing as a reward for helping me.*");
                    }
                    guardian.DoAction.InUse = false;
                }
                break;
            }
        }