Example #1
0
        public override void OnChatButtonClicked(bool firstButton, ref bool shop)
        {
            bool PlayerHasDomino = PlayerMod.PlayerHasGuardian(Main.player[Main.myPlayer], GuardianBase.Domino);

            if (PlayerHasDomino || (DominoDismissed && !PlayerMod.PlayerHasGuardianSummoned(Main.player[Main.myPlayer], BrutusID)))
            {
                Main.npcChatText = "*Thanks mate.*";
                PlayerMod.AddPlayerGuardian(Main.player[Main.myPlayer], GuardianID, GuardianModID);
                if (!PlayerHasDomino)
                {
                    PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], GuardianID, GuardianModID).IncreaseFriendshipProgress(1);
                }
                NpcMod.AddGuardianMet(GuardianID, GuardianModID);
                WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
                //npc.Transform(ModContent.NPCType<GuardianNPC.List.DogGuardian>());
            }
            if (DialogueStep == 10)
            {
                AcceptedIn   = firstButton;
                DialogueTime = DialogueDelay;
                if (firstButton)
                {
                    Main.npcChatText = "*Wise choice, Terrarian.*";
                }
                else
                {
                    Main.npcChatText = "*Eh... Alright... Go Team Brutus... Happy now?*";
                }
            }
        }
Example #2
0
 public override void OnChatButtonClicked(bool firstButton, ref bool shop)
 {
     if (PlayerHasRococo)
     {
         NpcMod.AddGuardianMet(GuardianID, GuardianModID);
         WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
         //npc.Transform(ModContent.NPCType<GuardianNPC.List.RaccoonGuardian>());
     }
     else if (!RejectedOnce && !AcceptedOnce)
     {
         if (firstButton) //Accept
         {
             AcceptedOnce     = true;
             Main.npcChatText = "*It got very happy after I said that It can move to my world, and said that his name is " + Base.Name + ".*";
             Jump             = true;
         }
         else
         {
             RejectedOnce     = true;
             Main.npcChatText = "*It got saddened after hearing my refusal. But says that wont feel bad for that. He told you that you can call him anytime, if you change your mind, and that his name is " + Base.Name + "*";
         }
         PlayerMod.AddPlayerGuardian(Main.player[Main.myPlayer], GuardianID, GuardianModID);
         PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], GuardianID, GuardianModID).IncreaseFriendshipProgress(1);
         NpcMod.AddGuardianMet(GuardianID, GuardianModID, firstButton);
         WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
     }
     else if (AcceptedOnce)
     {
         //npc.Transform(ModContent.NPCType<GuardianNPC.List.RaccoonGuardian>());
     }
 }
Example #3
0
 public override void OnChatButtonClicked(bool firstButton, ref bool shop)
 {
     if (firstButton)
     {
         if (HasBrutusRecruited)
         {
             NpcMod.AddGuardianMet(6);
             WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianBase.Brutus);
         }
         else
         {
             npc.target = Main.myPlayer;
             StartDamageTest();
             //Main.player[Main.myPlayer].talkNPC = -1;
         }
     }
     else
     {
         if (Main.player[Main.myPlayer].BuyItem(Item.buyPrice(0, HirePrice)))
         {
             Main.npcChatText = "*I accept the offer. I, " + Base.Name + ", will protect you until the end of my contract.*";
             PlayerMod.AddPlayerGuardian(Main.player[Main.myPlayer], GuardianID, GuardianModID);
             PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], GuardianID, GuardianModID).IncreaseFriendshipProgress(1);
             NpcMod.AddGuardianMet(6);
             Main.NewText("You bought " + Base.Name + "'s help.", MainMod.RecruitColor);
             WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianBase.Brutus);
         }
         else
         {
             Main.npcChatText = "*He's saying that the only ways of hiring his blade is by either showing how strong you are, or how deep your pocket is.*";
         }
     }
 }
Example #4
0
 public override void OnChatButtonClicked(bool firstButton, ref bool shop)
 {
     if (firstButton)
     {
         NpcMod.AddGuardianMet(16);
         Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().AddNewGuardian(16);
         if (PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], 16).FriendshipLevel == 0)
         {
             PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], 16).IncreaseFriendshipProgress(1);
         }
         Main.npcChatText = "(She looks happy at you, sketches on the floor her name, " + PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], 16).Name + ", then places her hand on your shoulder, telling you that you can count on her.)";
         WorldMod.TurnNpcIntoGuardianTownNpc(npc, 16);
     }
     else
     {
         NpcMod.AddGuardianMet(16, "", false);
         Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().AddNewGuardian(16);
         if (PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], 16).FriendshipLevel == 0)
         {
             PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], 16).IncreaseFriendshipProgress(1);
         }
         Main.npcChatText = "(Her face suddenly changed to a sad look, she sketches her name on the floor, " + PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], 16).Name + ", then signals saying that If you need her help, you just need to call.)";
         WorldMod.TurnNpcIntoGuardianTownNpc(npc, 16);
     }
 }
 public static void TrySpawningMichelle()
 {
     if (NpcMod.HasMetGuardian(GuardianBase.Michelle) || WorldMod.IsGuardianNpcInWorld(GuardianBase.Michelle))
     {
         return;
     }
     if (Main.fastForwardTime || Main.eclipse || !Main.dayTime || Main.time >= 27000 || Main.time % 60 > 0)
     {
         return;
     }
     if (Main.invasionType > 0 && Main.invasionDelay == 0 && Main.invasionSize > 0)
     {
         return;
     }
     if (Main.rand.Next(17) == 0)
     {
         bool HasPlayerWithDefense = false;
         for (int p = 0; p < 255; p++)
         {
             if (Main.player[p].active && Main.player[p].statDefense > 0)
             {
                 HasPlayerWithDefense = true;
                 break;
             }
         }
         if (HasPlayerWithDefense)
         {
             NpcMod.SpawnGuardianNPC(Main.spawnTileX * 16, Main.spawnTileY * 16, GuardianBase.Michelle);
             //NPC.NewNPC(Main.spawnTileX * 16, Main.spawnTileY * 16, ModContent.NPCType<MichelleGuardian>());
             Main.NewText("Michelle has logged in.", 255, 255, 0);
         }
     }
 }
Example #6
0
        public override void OnChatButtonClicked(bool firstButton, ref bool shop)
        {
            if (MetPlayer)
            {
                return;
            }
            if (SpeakingToKnownPlayer > 0)
            {
                if (firstButton)
                {
                    if (SpeakingToKnownPlayer == 1)
                    {
                        Main.npcChatText = "*Huh.*";
                        SayMessage("(I'll follow them again by keeping some distance, maybe they know the way out.)");
                    }
                    else
                    {
                        Main.npcChatText = "*No, I actually lied. Please, let me go with you! Get me out of here!!*";
                    }
                    PlayerMod.AddPlayerGuardian(Main.LocalPlayer, GuardianBase.Fear);
                    NpcMod.AddGuardianMet(GuardianBase.Fear);
                    WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
                }
                else
                {
                    Main.npcChatText = "*Uh.. Alright... Just- Just go away!*";
                    MetPlayer        = true;
                }
            }
            switch (DialogueStep)
            {
            case 0:
                DialogueStep++;
                Main.npcChatText = "*I don't trust you! You will try killing me like you did to those scary monsters!*";
                break;

            case 1:
                DialogueStep++;
                Main.npcChatText = "*Uh.. I guess you're right. BUT! Doesn't mean you can't still turn on me.*";
                break;

            case 2:
                DialogueStep++;
                if (firstButton)
                {
                    Main.npcChatText = "*I, ah... Okay.*";
                    SayMessage("(I'll trail behind them carefully for now, maybe they will help me get out of this horrible place.)");
                    PlayerMod.AddPlayerGuardian(Main.LocalPlayer, GuardianBase.Fear);
                    NpcMod.AddGuardianMet(GuardianBase.Fear);
                    WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
                }
                else
                {
                    Main.npcChatText = "*Uh.. Alright... Just- Just go away!*";
                    MetPlayer        = true;
                }
                break;
            }
        }
Example #7
0
 public void TurnNpcInTownNpc(bool MoveIn)
 {
     PlayerMod.AddPlayerGuardian(Main.player[npc.target], GuardianID, GuardianModID);
     NpcMod.AddGuardianMet(GuardianID, GuardianModID, MoveIn);
     if (PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], GuardianID, GuardianModID).FriendshipLevel == 0)
     {
         PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], GuardianID, GuardianModID).IncreaseFriendshipProgress(1);
     }
     WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
 }
Example #8
0
        private void RecruitmentScripts()
        {
            bool PlayerHadBlue = PlayerMod.PlayerHasGuardian(Main.player[Main.myPlayer], GuardianBase.Blue);

            PlayerMod.AddPlayerGuardian(Main.player[Main.myPlayer], GuardianBase.Blue);
            if (!PlayerHadBlue)
            {
                PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], GuardianBase.Blue).IncreaseFriendshipProgress(1);
            }
            NpcMod.AddGuardianMet(GuardianBase.Blue, "", !Rejected);
            WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianBase.Blue);
        }
Example #9
0
 private void TransformNPC()
 {
     //Transform into Bree guardian npc
     NpcMod.AddGuardianMet(7);
     Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().AddNewGuardian(7);
     if (PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], 7).FriendshipLevel == 0)
     {
         PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], 7).IncreaseFriendshipProgress(1);
     }
     WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianBase.Bree);
     //npc.Transform(ModContent.NPCType<GuardianNPC.List.FemaleCatGuardian>());
 }
Example #10
0
 public override void KillTile(int i, int j, int type, ref bool fail, ref bool effectOnly, ref bool noItem)
 {
     if (!fail)
     {
         WorldMod.UpdateTileStateOnGuardianHouses(i, j, false);
         if (Main.tileSign[type] && GuardianBountyQuest.SignID > -1 && Sign.ReadSign(i, j, false) == GuardianBountyQuest.SignID)
         {
             GuardianBountyQuest.SignID = -1;
         }
         if (Main.halloween && (type == Terraria.ID.TileID.ShadowOrbs || type == Terraria.ID.TileID.DemonAltar) && Main.rand.Next(50) == 0)
         {
             MainMod.TriggerAnyPlayerCompanionJS();
         }
     }
 }
Example #11
0
        public override string GetChat()
        {
            if (PlayerMod.PlayerHasGuardian(Main.LocalPlayer, GuardianBase.Liebre))
            {
                string Text = "*Ah, you're here too. Well, now you know I'm here too.*";
                Main.npcChatText = Text;
                WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianBase.Liebre);
                NpcMod.AddGuardianMet(GuardianBase.Liebre);
                return("");
            }
            int EncounterTimes = LiebreNPC.EncounterTimes;

            if (FinishedTalking)
            {
                EncounterTimes--;
            }
            switch (EncounterTimes)
            {
            case 0:
                if (!FinishedTalking)
                {
                    return("*Please don't be affraid, I'm not after your soul or anything. I'm here because TerraGuardians have been moving here.*");
                }
                return("*I will be moving away from here soon, if you're worried.*");

            case 1:
                if (FinishedTalking)
                {
                    return("*I'm still intrigued about this place, so It may take a while before I leave.*");
                }
                return("*So, we meet again, Terrarian. What kind of place is this? " + (WorldGen.crimson ? "I feel the energy of a godly creature in this organic place" : "This place seems infested with sickness and parasites") + "*");

            case 2:
                if (FinishedTalking)
                {
                    return("*I still need some time to process this. I think better when I'm alone.*");
                }
                return("*What is this place? This place... It's so horrible.*");

            case 3:
                if (FinishedTalking)
                {
                    return("*Terrarian, haven't we introduced ourselves before?*");
                }
                return("*Terrarian, I have something to tell you.*");
            }
            return(base.GetChat());
        }
Example #12
0
        public override string GetChat()
        {
            NpcMod.AddGuardianMet(GuardianID, GuardianModID);
            bool PlayerHasLeopold = PlayerMod.PlayerHasGuardian(Main.player[Main.myPlayer], GuardianID, GuardianModID);

            PlayerMod.AddPlayerGuardian(Main.player[Main.myPlayer], GuardianID, GuardianModID);
            if (!PlayerHasLeopold)
            {
                PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], GuardianID, GuardianModID).IncreaseFriendshipProgress(1);
            }
            string Mes = "";

            if (SceneID == SceneIDs.LeopoldFreeForRecruit)
            {
                Mes = "*Why did you make me act like a fool in front of your TerraGuardians? That will make it harder for people to remember me as a wise sage.*";
            }
            else if (SocialAct)
            {
                Mes = "*You can talk?! Wait, why didn't you talked to me sooner then? I nearly thought you were... No... Nevermind... I'm Leopold, the Sage.*";
            }
            else if (FearAct)
            {
                Mes = "*Huh? You're friendly? And can talk?! Oh... Thank... No... I'm fine.. It's just... Uh... Pleased to meet you, by the way... I'm Leopold, the Sage.*";
            }
            else if (ScareAct)
            {
                Mes = "*What?! You can talk!? Why did you made me pass through all that you idiot! Ugh... I'm Leopold, the Sage, by the way. Do you... Do you have some spare leaves with you...?*";
            }
            else
            {
                Mes = "*You can understand what I say?! Wow! The book was right!!*";
            }
            Main.npcChatText = Mes;
            WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
            //GuardianMouseOverAndDialogueInterface.SetDialogue(Mes);
            return(Mes);
        }
Example #13
0
        public override void OnChatButtonClicked(bool firstButton, ref bool shop)
        {
            switch (DialogueStep)
            {
            case 1:
                if (MetBefore)
                {
                    NpcMod.AddGuardianMet(GuardianBase.CaptainStench);
                    WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianBase.CaptainStench);
                }
                else
                {
                    DialogueStep     = 2;
                    Main.npcChatText = GetChat();
                }
                break;

            case 2:
                DialogueStep     = 3;
                Main.npcChatText = GetChat();
                break;

            case 3:
                DialogueStep     = 4;
                Main.npcChatText = GetChat();
                break;

            case 4:
                if (firstButton && HasMaterials)
                {
                    Main.npcChatText = "Thank you, these materials will be put to good use. Rest assured you won't be disappointed. Now then im ready for adventure when you are.";
                    int    BarsLeftToRemove = BarCount;
                    Player player           = Main.player[Main.myPlayer];
                    if (Main.player[Main.myPlayer].CountItem(Terraria.ID.ItemID.GoldBar) >= BarCount)
                    {
                        const int ToRemoveItemID = Terraria.ID.ItemID.GoldBar;
                        for (int i = 0; i < 50; i++)
                        {
                            if (player.inventory[i].type == ToRemoveItemID)
                            {
                                int ToDiscount = BarsLeftToRemove;
                                if (ToDiscount > player.inventory[i].stack)
                                {
                                    ToDiscount = player.inventory[i].stack;
                                }
                                player.inventory[i].stack -= ToDiscount;
                                BarsLeftToRemove          -= ToDiscount;
                                if (player.inventory[i].stack == 0)
                                {
                                    player.inventory[i].SetDefaults(0, true);
                                }
                                if (BarsLeftToRemove <= 0)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        const int ToRemoveItemID = Terraria.ID.ItemID.PlatinumBar;
                        for (int i = 0; i < 50; i++)
                        {
                            if (player.inventory[i].type == ToRemoveItemID)
                            {
                                int ToDiscount = BarsLeftToRemove;
                                if (ToDiscount > player.inventory[i].stack)
                                {
                                    ToDiscount = player.inventory[i].stack;
                                }
                                player.inventory[i].stack -= ToDiscount;
                                BarsLeftToRemove          -= ToDiscount;
                                if (player.inventory[i].stack == 0)
                                {
                                    player.inventory[i].SetDefaults(0, true);
                                }
                                if (BarsLeftToRemove <= 0)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    PlayerMod.AddPlayerGuardian(player, GuardianBase.CaptainStench);
                    NpcMod.AddGuardianMet(GuardianBase.CaptainStench);
                    WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianBase.CaptainStench);
                }
                else
                {
                    Main.npcChatText = "Oh that's unfortunate. IF you ever stumble apon the metals please consider supplying them to me as I will be left stranded and defenseless here on a foriegn planet.";
                    DialogueStep     = 5;
                }
                break;
            }
        }
Example #14
0
        public override void OnChatButtonClicked(bool firstButton, ref bool shop)
        {
            if (RequestComplete)
            {
                if (firstButton)
                {
                    if (HugPassed)
                    {
                        int HuggedPlayer = HuggingPlayer;
                        WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
                        //npc.Transform(ModContent.NPCType<GuardianNPC.List.BearNPC>());
                        bool PlayerHasVladimir = PlayerMod.PlayerHasGuardian(Main.player[Main.myPlayer], GuardianID);
                        PlayerMod.AddPlayerGuardian(Main.player[Main.myPlayer], GuardianID);
                        if (!PlayerHasVladimir)
                        {
                            PlayerMod.GetPlayerGuardian(Main.player[Main.myPlayer], GuardianID).IncreaseFriendshipProgress(1);
                        }
                        NpcMod.AddGuardianMet(GuardianID);
                        if (HuggedPlayer > -1)
                        {
                            Player player = Main.player[HuggedPlayer];
                            foreach (TerraGuardian tg in MainMod.ActiveGuardians.Values)
                            {
                                if (tg.ID == GuardianID && tg.ModID == GuardianModID)
                                {
                                    if (tg.StartNewGuardianAction(new Companions.Vladimir.HugAction(Main.player[HuggedPlayer]), 0))
                                    {
                                        Main.npcChatText = "*Thank you! I will try finding me a empty house to move in, but first, I will wait until ask me to stop hugging you.*";
                                    }
                                    else
                                    {
                                        Main.npcChatText = "*Thank you! I could hug you more, but for some reason I can't. Just tell me whenever you need one. Now I will try looking for a house to live.*";
                                    }
                                    break;
                                }
                            }
                        }
                        else
                        {
                            Main.npcChatText = "*Thank you! I will try looking for a house for me to live. I see you another time.*";
                        }
                        return;
                    }
                    else if (HuggingPlayer == -1)
                    {
                        npc.ai[0]     = 0;
                        HuggingPlayer = Main.myPlayer;
                        if (PlayerHasVladimir)
                        {
                            Main.npcChatText = "*Please be patient, this wont take long.*";
                        }
                        else
                        {
                            Main.npcChatText = "*It wont take too long.*";
                        }
                    }
                    else if (HuggingPlayer == Main.myPlayer)
                    {
                        Main.npcChatText      = "*Aww... I wanted some more hug...*";
                        HuggingPlayer         = -1;
                        HasHugCommentHappened = false;
                    }
                }
                else
                {
                    if (HugPassed)
                    {
                        Main.npcChatText = "*Oh! Alright, alright. Say... Can I move in to your world? Maybe there are people who need hugs here.*";
                        if (HuggingPlayer > -1)
                        {
                            Main.player[HuggingPlayer].Center = npc.Center;
                            HuggingPlayer = -1;
                        }
                    }
                    else
                    {
                        if (PlayerHasVladimir)
                        {
                            switch (Main.rand.Next(5))
                            {
                            case 0:
                                Main.npcChatText = "*We have done that before, give me a hug.*";
                                break;

                            case 1:
                                Main.npcChatText = "*Don't be like that, you know I wont hurt you.*";
                                break;

                            case 2:
                                Main.npcChatText = "*That gives me flashbacks of when we first met. Or was It another Terrarian?*";
                                break;

                            case 3:
                                Main.npcChatText = "*You will refuse my hug? I'm sad now.*";
                                break;

                            case 4:
                                Main.npcChatText = "*I've been walking for long, would be nice to hug someone friendly.*";
                                break;
                            }
                        }
                        else
                        {
                            switch (Main.rand.Next(6))
                            {
                            case 0:
                                Main.npcChatText = "*Come on, It's just a hug. Are you scared of me?*";
                                break;

                            case 1:
                                Main.npcChatText = "*I need that to make me feel better. It's been a long time since I last saw a person.*";
                                break;

                            case 2:
                                Main.npcChatText = "*I wont eat you or something. Come on, give me a hug.*";
                                break;

                            case 3:
                                Main.npcChatText = "*I'm not a bad person, I wont hurt you either, trust me.*";
                                break;

                            case 4:
                                Main.npcChatText = "*That saddens me, why don't you give me a hug?*";
                                break;

                            case 5:
                                Main.npcChatText = "*You wont end up like the fishs, I just want a hug.*";
                                break;
                            }
                        }
                    }
                }
            }
            else if (RequestTaken)
            {
                if (firstButton)
                {
                    int Fish = Main.player[Main.myPlayer].CountItem(FishID);
                    for (int i = 0; i < 50; i++)
                    {
                        if (Main.player[Main.myPlayer].inventory[i].type == FishID)
                        {
                            Main.player[Main.myPlayer].inventory[i].SetDefaults(0, true);
                        }
                    }
                    if (FishsTaken + Fish > 255)
                    {
                        FishsTaken = 255;
                    }
                    else
                    {
                        FishsTaken += (byte)Fish;
                    }
                    if (FishsTaken >= FishsToTake)
                    {
                        Main.npcChatText = "*I'm stuffed. Thank you friend. You helped me, and I can help you if you give me a hug.*";
                        RequestComplete  = true;
                    }
                    else
                    {
                        Main.npcChatText = "*Amazing! (He eats them) I'm still hungry... Could you get some more " + FishName + " for me?*";
                    }
                }
                else
                {
                }
            }
            else
            {
                if (firstButton)
                {
                    RequestTaken     = true;
                    FishsToTake      = (byte)Main.rand.Next(7, 13);
                    Main.npcChatText = "*Thank you! I need some Honeyfins. Please be fast, I'm so hungry...*";
                }
                else
                {
                    Main.npcChatText = "*Oh... I'll get back to trying to get some fish then... (Stomach growling) Be quiet, I know I'm hungry.*";
                }
            }
        }
Example #15
0
        public override void OnChatButtonClicked(bool firstButton, ref bool shop)
        {
            if (firstButton)
            {
                switch (AiStage)
                {
                default:
                    AiStage++;
                    break;

                case 1:
                    AiStage = 4;
                    break;

                case 3:
                case 4:
                    if (PlayerUsingDryadSet(Main.player[npc.target]))
                    {
                        AiStage = 6;
                    }
                    else
                    {
                        if (!PlayerMod.GetPlayerMainGuardian(Main.player[npc.target]).Active)
                        {
                            AiStage = 9;
                        }
                        else
                        {
                            AiStage = 5;
                        }
                    }
                    break;

                case 5:
                    AiStage = 8;
                    break;

                case 6:
                    if (!PlayerMod.GetPlayerMainGuardian(Main.player[npc.target]).Active)
                    {
                        AiStage = 9;
                    }
                    else
                    {
                        AiStage++;
                    }
                    break;

                case 7:
                    AiStage = 9;
                    break;

                case 11:
                    Main.npcChatText = "*I'm Malisha, by the way. I'll try enjoying my time here.*";
                    PlayerMod.AddPlayerGuardian(Main.player[npc.target], GuardianBase.Malisha);
                    PlayerMod.GetPlayerGuardian(Main.player[npc.target], GuardianBase.Malisha).IncreaseFriendshipProgress(1);
                    NpcMod.AddGuardianMet(GuardianBase.Malisha);
                    WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
                    //npc.Transform(ModContent.NPCType<GuardianNPC.List.PantherGuardian>());
                    return;
                }
                Main.npcChatText = GetStepMessage();
            }
        }
Example #16
0
 public override void AI()
 {
     if (AiStage > 1)
     {
         if (npc.target == -1 || npc.target == 256)
         {
             AiStage = 1;
             SayMessage("*Funny, where did the Terrarian I was talking with to went?*");
         }
         else if (!Main.player[npc.target].active)
         {
             AiStage = 1;
             SayMessage("*Funny, where did the Terrarian I was talking with to went?*");
         }
         else if (Main.player[npc.target].dead)
         {
             AiStage = 1;
             SayMessage("*Well, that was an awful sight.*");
         }
     }
     if (AiStage == 0)
     {
         Idle          = true;
         AiStage       = 1;
         npc.direction = (Main.rand.NextDouble() < 0.5 ? -1 : 1);
         Main.NewText("Something appeared to the " + GuardianBountyQuest.GetDirectionText(npc.Center - Main.player[Main.myPlayer].Center) + " of " + Main.player[Main.myPlayer].name + ".", MainMod.MysteryCloseColor);
     }
     else if (AiStage == 1)
     {
         Idle = true;
         Rectangle FoV = new Rectangle(0, -150, 250, 300);
         if (npc.direction < 0)
         {
             FoV.X = -FoV.Width;
         }
         FoV.X += (int)npc.Center.X;
         FoV.Y += (int)npc.Center.Y;
         for (int p = 0; p < 255; p++)
         {
             if (Main.player[p].active && !Main.player[p].dead && Main.player[p].getRect().Intersects(FoV) && Collision.CanHitLine(npc.position, npc.width, npc.height, Main.player[p].position, Main.player[p].width, Main.player[p].height))
             {
                 //Player found!
                 npc.target = p;
                 if (PlayerMod.PlayerHasGuardian(Main.player[p], GuardianBase.Malisha))
                 {
                     DialogueTime = SayMessage("*Hey, It's you again.*"); //Add later the dialogue
                     AiStage      = 150;
                 }
                 else
                 {
                     AiStage      = 2;
                     DialogueTime = SayMessage("*A Terrarian! I must have really arrived.*");
                 }
                 if (npc.Center.X - Main.player[p].Center.X > 0)
                 {
                     npc.direction = -1;
                 }
                 else
                 {
                     npc.direction = 1;
                 }
                 break;
             }
         }
     }
     else if (AiStage == 2)
     {
         Player player = Main.player[npc.target];
         if (npc.Center.X - player.Center.X > 0)
         {
             npc.direction = -1;
         }
         else
         {
             npc.direction = 1;
         }
         if (DialogueTime > 0)
         {
             DialogueTime--;
         }
         else
         {
             if (PlayerUsingDryadSet(player))
             {
                 DialogueTime = SayMessage("*Look at how It's dressed! This must be the right place.*");
             }
             else
             {
                 DialogueTime = SayMessage("*Wait, why is It using clothes?*");
             }
             AiStage = 3;
         }
     }
     else if (AiStage == 3)
     {
         Player player = Main.player[npc.target];
         if (npc.Center.X - player.Center.X > 0)
         {
             npc.direction = -1;
         }
         else
         {
             npc.direction = 1;
         }
         if (DialogueTime > 0)
         {
             DialogueTime--;
         }
         else
         {
             float Distance = player.Center.X - npc.Center.X;
             if (Math.Abs(Distance) > 96)
             {
                 if (Distance > 0)
                 {
                     MoveRight = true;
                 }
                 else
                 {
                     MoveLeft = true;
                 }
             }
             else
             {
             }
         }
     }
     else if (AiStage == 100)
     {
         npc.TargetClosest(false);
         Player player = Main.player[npc.target];
         Idle = true;
     }
     else if (AiStage == 150)
     {
         Player player = Main.player[npc.target];
         if (npc.Center.X - player.Center.X > 0)
         {
             npc.direction = -1;
         }
         else
         {
             npc.direction = 1;
         }
         if (DialogueTime > 0)
         {
             DialogueTime--;
         }
         else
         {
             DialogueTime = SayMessage("*I think this isn't a naturalist colony, either, right?*");
             AiStage      = 151;
         }
     }
     else if (AiStage == 151)
     {
         Player player = Main.player[npc.target];
         if (npc.Center.X - player.Center.X > 0)
         {
             npc.direction = -1;
         }
         else
         {
             npc.direction = 1;
         }
         if (DialogueTime > 0)
         {
             DialogueTime--;
         }
         else
         {
             DialogueTime = SayMessage("*Well, whatever. I'm here If you need my knowledge. Or feel like wanting to be a guinea pig. You pick.*");
             AiStage      = 152;
         }
     }
     else if (AiStage == 152)
     {
         Player player = Main.player[npc.target];
         if (npc.Center.X - player.Center.X > 0)
         {
             npc.direction = -1;
         }
         else
         {
             npc.direction = 1;
         }
         if (DialogueTime > 0)
         {
             DialogueTime--;
         }
         else
         {
             PlayerMod.AddPlayerGuardian(Main.player[npc.target], GuardianBase.Malisha);
             NpcMod.AddGuardianMet(GuardianBase.Malisha);
             WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
             //npc.Transform(ModContent.NPCType<GuardianNPC.List.PantherGuardian>());
         }
     }
     else
     {
         Player player = Main.player[npc.target];
         //Dialogue Checks
         if (player.talkNPC != npc.whoAmI)
         {
             DialogueTime = SayMessage("*How rude! Speak to me when possible then.*");
             AiStage      = 100;
         }
     }
     base.AI();
 }
Example #17
0
        public override void Update(TerraGuardian guardian) //Add a overrideable method for custom dialogues.
        {
            this.guardian = guardian;
            bool IsWere        = CastellaBase.OnWerewolfForm(guardian);
            bool LookForVictim = false;

            switch (Step)
            {
            case 0:     //Pick behavior step;
                IgnoreCombat = true;
                if (IsWere)
                {
                    if (StepStart)
                    {
                        Main.NewText("Awooooooooooo!!");
                    }
                    if (Time >= 300)
                    {
                        ChangeStep(1);
                    }
                }
                else
                {
                    InUse = false;
                }
                break;

            case 1:
            {
                IgnoreCombat  = false;
                LookForVictim = true;
            }
            break;

            case 200:
            case 201:
            case 202:
            {
                IgnoreCombat      = true;
                AvoidItemUsage    = true;
                guardian.MoveLeft = guardian.MoveRight = guardian.Jump = guardian.MoveDown = false;
                switch (VictimType)
                {
                case TerraGuardian.TargetTypes.Guardian:
                {
                    if (!MainMod.ActiveGuardians.ContainsKey(VictimID))
                    {
                        ChangeStep(1);
                        return;
                    }
                    TerraGuardian Victim = MainMod.ActiveGuardians[VictimID];
                    Victim.IsBeingPulledByPlayer = false;
                    if (Victim.PlayerMounted)
                    {
                        Victim.ToggleMount(true, false);
                    }
                    Vector2 Position = guardian.GetGuardianBetweenHandPosition;
                    Victim.Position  = Position + new Vector2(0, Victim.Height * 0.5f);
                    Victim.Direction = -guardian.Direction;
                    Victim.Velocity  = Vector2.Zero;
                    Victim.SetFallStart();
                    Victim.AddBuff(Terraria.ID.BuffID.Cursed, 5, true);
                    if (Time == 120)
                    {
                        Victim.EnterDownedState();
                        Victim.KnockedOutCold = true;
                    }
                    if (Time >= 150)
                    {
                        ChangeStep(1);
                    }
                }
                break;

                case TerraGuardian.TargetTypes.Player:
                {
                    if (!Main.player[VictimID].active || Main.player[VictimID].dead)
                    {
                        ChangeStep(1);
                        return;
                    }
                    Player    Victim   = Main.player[VictimID];
                    PlayerMod pm       = Victim.GetModPlayer <PlayerMod>();
                    Vector2   Position = guardian.GetGuardianBetweenHandPosition;
                    Position.X      -= Victim.width * 0.5f;
                    Position.Y      -= Victim.height * 0.5f;
                    Victim.position  = Position;
                    Victim.direction = -guardian.Direction;
                    Victim.velocity  = Vector2.Zero;
                    Victim.fallStart = (int)(Victim.position.Y * (1f / 16));
                    Victim.AddBuff(Terraria.ID.BuffID.Cursed, 5);
                    if (guardian.TalkPlayerID > -1)
                    {
                        ChangeStep(201);
                    }
                    if (Step == 200 || Step == 202)
                    {
                        if (Time == 90)
                        {
                            if (Victim.statLife == 1)
                            {
                                Victim.statLife++;
                            }
                            if (!pm.KnockedOut)
                            {
                                Victim.Hurt(Terraria.DataStructures.PlayerDeathReason.ByCustomReason(Victim.name + " couldn't endure the bite."), 1, 0);
                            }
                            pm.EnterDownedState(true);
                            Victim.statLife = 1;
                            Victim.Bottom   = guardian.Position;
                            if (Main.netMode == 0 && Victim.whoAmI == Main.myPlayer)
                            {
                                foreach (TerraGuardian tg in pm.GetAllGuardianFollowers)
                                {
                                    if (tg.Active)
                                    {
                                        tg.EnterDownedState();
                                    }
                                }
                                if (guardian.IsTownNpc)
                                {
                                    guardian.TeleportHome();
                                }
                                else
                                {
                                    if (Main.rand.Next(3) != 0)
                                    {
                                        NpcMod.DespawnGuardianNPC(guardian);
                                    }
                                }
                                MainMod.DoBlackoutPlayer();
                                WorldMod.SkipTimeUntilMorning();
                                return;
                            }
                        }
                        if (Time >= 120)
                        {
                            ChangeStep(1);
                        }
                    }
                }
                break;
                }
            }
            break;
            }
            if (LookForVictim)
            {
                if (guardian.TargetID > -1 && guardian.TargetType != TerraGuardian.TargetTypes.Npc)
                {
                    AvoidItemUsage = true;
                    Rectangle GrabBox = guardian.HitBox;
                    GrabBox.Width += 8;
                    if (guardian.LookingLeft)
                    {
                        GrabBox.X -= 8;
                    }
                    switch (guardian.TargetType)
                    {
                    case TerraGuardian.TargetTypes.Guardian:
                        if (GrabBox.Intersects(MainMod.ActiveGuardians[guardian.TargetID].HitBox))
                        {
                            VictimID   = guardian.TargetID;
                            VictimType = guardian.TargetType;
                            ChangeStep(200);
                        }
                        break;

                    case TerraGuardian.TargetTypes.Player:
                        if (GrabBox.Intersects(Main.player[guardian.TargetID].getRect()))
                        {
                            VictimID   = guardian.TargetID;
                            VictimType = guardian.TargetType;
                            ChangeStep(200);
                        }
                        break;
                    }
                }
                else
                {
                    AvoidItemUsage = false;
                }
            }
        }
Example #18
0
        public override void OnChatButtonClicked(bool firstButton, ref bool shop)
        {
            string NewDialogueMessage = null;

            switch (TalkTimes)
            {
            case 0:
            {
                switch (DialogueStep)
                {
                case 0:
                    if (PlayerMetCille)
                    {
                        NewDialogueMessage = "*Yes.. Still, please leave me be.*";
                        DialogueStep       = 0;
                        TalkTimes          = 8;
                    }
                    else
                    {
                        NewDialogueMessage = "*Nobody. Please, go away..*";
                        DialogueStep++;
                    }
                    MetAtLeastOnce = true;
                    break;
                }
            }
            break;

            case 1:
            {
                switch (DialogueStep)
                {
                case 0:
                    NewDialogueMessage = "*...Because I might hurt you..*";
                    DialogueStep++;
                    break;

                case 1:
                    NewDialogueMessage = "*No... It's not that... I tend to end up hurting people I'm close to...*";
                    DialogueStep++;
                    break;

                case 2:
                    NewDialogueMessage = "*I really don't want to talk to you.. Please, leave me alone.*";
                    DialogueStep++;
                    break;
                }
            }
            break;

            case 2:
            {
                switch (DialogueStep)
                {
                case 0:
                    NewDialogueMessage = "*Okay. What about this. I really miss racing against someone. Could you beat me on a race?*";
                    DialogueStep++;
                    break;

                case 1:
                    if (firstButton)
                    {
                        NewDialogueMessage = "*It's really simple. If you run ahead of me enough time so I can't catch up, you win. I win if I manage to do that to you. What do you say?*";
                    }
                    else
                    {
                        NewDialogueMessage = "*Back then, I used to love racing against other people.. It's just a simple race, if you manage to run ahead of me enough so I can't catch up, you win. I win if I do the that to you. Would you race against me?*";
                    }
                    DialogueStep++;
                    break;

                case 2:
                    if (firstButton)
                    {
                        TalkTimes          = 3;
                        DialogueStep       = 0;
                        RaceStartDelay     = 3 * 60;
                        NewDialogueMessage = "*Once you stop talking to me, I'll start the race in 3 seconds.*";
                    }
                    else
                    {
                        NewDialogueMessage = "*Then leave me alone.*";
                        DialogueStep++;
                    }
                    break;
                }
            }
            break;

            case 6:
            {
                switch (DialogueStep)
                {
                case 0:
                {
                    DialogueStep++;
                    NewDialogueMessage = "*No. Please, leave me alone.*";
                    NpcMod.AddGuardianMet(GuardianID, GuardianModID);
                    TalkTimes = 7;
                    PlayerMod.AddPlayerGuardian(Main.player[Main.myPlayer], GuardianID, GuardianModID);
                }
                break;
                }
            }
            break;

            case 7:
            {
                switch (DialogueStep)
                {
                case 0:
                {
                    DialogueStep++;
                    NewDialogueMessage = "*Cille...*";
                }
                break;
                }
            }
            break;

            case 8:
            {
                NpcMod.AddGuardianMet(GuardianID, GuardianModID);
                TalkTimes        = 9;
                Main.npcChatText = "*... Sorry... You're not safe while close to me..*";
                WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
            }
            break;
            }
            if (NewDialogueMessage != null)
            {
                Main.npcChatText = NewDialogueMessage;
            }
        }
Example #19
0
        public override void AI()
        {
            TerraGuardian Brutustg = PlayerMod.GetPlayerSummonedGuardian(Main.player[Main.myPlayer], BrutusID);
            bool          PlayerHasBrutusSummoned = Brutustg != null;

            if (Brutustg == null)
            {
                foreach (TerraGuardian tg in WorldMod.GuardianTownNPC)
                {
                    if (tg.ID == BrutusID && tg.ModID == MainMod.mod.Name)
                    {
                        Brutustg = tg;
                        break;
                    }
                }
            }
            Player player          = Main.player[Main.myPlayer];
            bool   PlayerHasDomino = PlayerMod.PlayerHasGuardian(Main.player[Main.myPlayer], GuardianBase.Domino);
            string BrutusChat      = "";

            if (PlayerHasBrutusSummoned && !DominoDismissed)
            {
                if (DialogueStep == -1 && Math.Abs(player.Center.X - npc.Center.X) < 128f)
                {
                    DialogueStep = 0;
                    DialogueTime = 0;
                    BrutusChat   = "*Halt! You there!*";
                }
            }
            if (DialogueStep == -1 && player.talkNPC != npc.whoAmI)
            {
                if (DialogueTime == 0)
                {
                    if (player.Center.X - npc.Center.X < 0)
                    {
                        npc.direction = -1;
                    }
                    else
                    {
                        npc.direction = 1;
                    }
                }
                Walk = true;
                if (DialogueTime <= 1401)
                {
                    if (npc.direction < 0)
                    {
                        MoveLeft = true;
                    }
                    else
                    {
                        MoveRight = true;
                    }
                }
                if (DialogueTime >= 1401)
                {
                    DialogueTime -= 1400;
                }
                DialogueTime++;
            }
            npc.npcSlots = 1;
            if (DialogueStep >= 0)
            {
                npc.npcSlots = 200;
                DialogueTime++;
                bool Trigger = false;
                if (DialogueTime >= DialogueDelay)
                {
                    Trigger      = true;
                    DialogueTime = 0;
                    DialogueStep++;
                }
                bool FacePlayer = false;
                if (PlayerHasDomino)
                {
                    FacePlayer = true;
                    switch (DialogueStep)
                    {
                    case 0:
                        if (DialogueTime >= 60)
                        {
                            SayMessage("*This again?!*");
                        }
                        if (DialogueTime >= 90)
                        {
                            DialogueTime = DialogueDelay;
                        }
                        break;

                    case 1:
                        if (Trigger)
                        {
                            if (PlayerHasBrutusSummoned)
                            {
                                BrutusChat = "*You have the audacity of showing up again.*";
                            }
                            else
                            {
                                SayMessage("*Ah, you're not with him... Good.*");
                            }
                        }
                        break;

                    case 2:
                        if (Trigger)
                        {
                            if (PlayerHasBrutusSummoned)
                            {
                                SayMessage("*Yeah right, like as If I'm happy for seeing you again.*");
                            }
                            else
                            {
                                SayMessage("*Since you're here too, I don't think you'll mind if I open my business here too.*");
                            }
                        }
                        break;

                    case 3:
                        if (Trigger)
                        {
                            if (PlayerHasBrutusSummoned)
                            {
                                SayMessage("*Terrarian, you know the drill. Need me for anything, I will be here.*");
                            }
                            else
                            {
                                SayMessage("*Or if you need my help for anything, you know where to find me.*");
                            }
                        }
                        break;

                    case 4:
                        if (Trigger)
                        {
                            if (PlayerHasBrutusSummoned)
                            {
                                BrutusChat = "*Ugh...*";
                            }
                            NpcMod.AddGuardianMet(GuardianID, GuardianModID);
                            WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
                            //npc.Transform(ModContent.NPCType<GuardianNPC.List.DogGuardian>());
                        }
                        break;
                    }
                }
                else if (!PlayerHasDomino && !PlayerHasBrutusSummoned && DialogueStep == -1)
                {
                    Idle         = true;
                    DialogueTime = 0;
                }
                else
                {
                    switch (DialogueStep)
                    {
                    case 0:
                        if (DialogueTime >= 60)
                        {
                            SayMessage("*Uh oh.*");
                            FacePlayer = true;
                        }
                        if (DialogueTime >= 90)
                        {
                            DialogueTime = DialogueDelay;
                        }
                        break;

                    case 1:
                    {
                        if (Trigger)
                        {
                            BrutusChat = "*After him! Don't let him escape!*";
                        }
                        if (player.Center.X - npc.Center.X >= 0)
                        {
                            MoveLeft = true;
                        }
                        else
                        {
                            MoveRight = true;
                        }
                        if (Math.Abs(player.Center.X - npc.Center.X) >= NPC.sWidth ||
                            Math.Abs(player.Center.Y - npc.Center.Y) >= NPC.sHeight)
                        {
                            npc.active = false;
                            BrutusChat = "*Blast it! He got away! He'll return, I'm sure.*";
                        }

                        DialogueTime = 5;
                        if (player.getRect().Intersects(npc.getRect()))
                        {
                            DialogueTime = DialogueDelay;
                        }
                    }
                    break;

                    case 2:
                    {
                        if (Trigger)
                        {
                            BrutusChat = "*Got you now! You wont run away anymore!*";
                        }
                    }
                    break;

                    case 3:
                    {
                        FacePlayer = true;
                        if (Trigger)
                        {
                            SayMessage("*Hey Brutus, didn't you lost your place as a Royal Guard on the Ether Realm?*");
                        }
                    }
                    break;

                    case 4:
                    {
                        FacePlayer = true;
                        if (Trigger)
                        {
                            BrutusChat = "*If It wasn't for you, I wouldn't have lost my job. Beside, I was already sick of that.*";
                        }
                    }
                    break;

                    case 5:
                    {
                        FacePlayer = true;
                        if (Trigger)
                        {
                            SayMessage("*You don't need to thank me for that.*");
                        }
                    }
                    break;

                    case 6:
                    {
                        FacePlayer = true;
                        if (Trigger)
                        {
                            BrutusChat = "*I'm going to have you locked behind bars forever for smuggling.*";
                        }
                    }
                    break;

                    case 7:
                    {
                        FacePlayer = true;
                        if (Trigger)
                        {
                            SayMessage("*You're no longer a guard or anything, so you can't arrest me.*");
                        }
                    }
                    break;

                    case 8:
                    {
                        FacePlayer = true;
                        if (Trigger)
                        {
                            BrutusChat = "*Ugh... Uh...*";
                            SayMessage("*See? You can't arrest me, and the laws of the Ether Realm aren't valid here.*");
                        }
                    }
                    break;

                    case 9:
                    {
                        FacePlayer = true;
                        if (Trigger)
                        {
                            SayMessage("*Now, If you don't mind, I have something to ask to this Terrarian.*");
                        }
                    }
                    break;

                    case 10:
                    {
                        if (Trigger)
                        {
                            SayMessage("*Terrarian, come talk to me.*");
                        }
                        FacePlayer   = true;
                        DialogueTime = 5;
                    }
                    break;
                    }
                    if (AcceptedIn)
                    {
                        switch (DialogueStep)
                        {
                        case 11:
                        {
                            FacePlayer = true;
                            if (Trigger)
                            {
                                SayMessage("*Looks like I will be staying here.*");
                            }
                        }
                        break;

                        case 12:
                        {
                            FacePlayer = true;
                            if (Trigger)
                            {
                                BrutusChat = "*Oh great! Now I will have to share the world with my most hated person.*";
                            }
                        }
                        break;

                        case 13:
                        {
                            FacePlayer = true;
                            if (Trigger)
                            {
                                SayMessage("*Now If you don't mind, I have some things to move in to this world.*");
                            }
                        }
                        break;

                        case 14:
                        {
                            FacePlayer = true;
                            if (Trigger)
                            {
                                BrutusChat = "*Mark my words, slide just a little bit, and I will put you behind bars!*";
                            }
                        }
                        break;

                        case 15:
                        {
                            FacePlayer = true;
                            if (Trigger)
                            {
                                SayMessage("*Yeah, right. I also love having you as a neighbor or something.*");
                            }
                        }
                        break;

                        case 16:
                        {
                            if (Trigger)
                            {
                                PlayerMod.AddPlayerGuardian(player, GuardianID, GuardianModID);
                                NpcMod.AddGuardianMet(GuardianID, GuardianModID);
                                WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
                                //npc.Transform(ModContent.NPCType<GuardianNPC.List.DogGuardian>());
                                return;
                            }
                        }
                        break;
                        }
                    }
                    else
                    {
                        switch (DialogueStep)
                        {
                        case 11:
                        {
                            if (Trigger)
                            {
                                FacePlayer = true;
                                BrutusChat = "*Hah! The Terrarian said it! Now go away!*";
                            }
                        }
                        break;

                        case 12:
                        {
                            if (Trigger)
                            {
                                FacePlayer = true;
                                SayMessage("*Sigh... Well, I'm a man of word, anyway. Goodbye.*");
                            }
                        }
                        break;

                        case 13:
                        {
                            if (Trigger)
                            {
                                DominoDismissed = true;
                                BrutusChat      = "*Good riddance.*";
                                for (int i = 0; i < 5; i++)
                                {
                                    Gore.NewGore(npc.Center, new Microsoft.Xna.Framework.Vector2(Main.rand.Next(-40, 40) * 0.01f, Main.rand.Next(-40, 40) * 0.01f), Main.rand.Next(11, 14));
                                }
                                npc.active = false;
                            }
                        }
                        break;
                        }
                    }
                }
                if (FacePlayer)
                {
                    if (player.Center.X - npc.Center.X >= 0)
                    {
                        npc.direction = 1;
                    }
                    else
                    {
                        npc.direction = -1;
                    }
                    if (Math.Abs(player.Center.X - npc.Center.X) >= 64)
                    {
                        if (player.Center.X - npc.Center.X >= 0)
                        {
                            MoveRight = true;
                        }
                        else
                        {
                            MoveLeft = true;
                        }
                    }
                }
            }
            if (Math.Abs(player.Center.X - npc.Center.X) >= NPC.sWidth + 64 ||
                Math.Abs(player.Center.Y - npc.Center.Y) >= NPC.sHeight + 64)
            {
                npc.active = false;
            }
            if (BrutusChat != "" && Brutustg != null)
            {
                Brutustg.SaySomething(BrutusChat);
            }
            base.AI();
        }
Example #20
0
        public static void TrySpawningBrutus()
        {
            if (Main.netMode == 1 || NpcMod.HasMetGuardian(6, "") || WorldMod.IsGuardianNpcInWorld(GuardianBase.Brutus))
            {
                return;
            }
            const int SpawnTime = 3 * 3600;

            if (Main.fastForwardTime || Main.eclipse || !Main.dayTime || (Main.time < SpawnTime || WorldMod.LastTime >= 7.5))
            {
                return;
            }
            if (Main.invasionType > 0 && Main.invasionDelay == 0 && Main.invasionSize > 0)
            {
                return;
            }
            int NpcCount = (int)(NpcMod.GetCompanionNPCCount() * 0.5f);

            for (int n = 0; n < 200; n++)
            {
                if (Main.npc[n].active && Main.npc[n].townNPC)
                {
                    NpcCount++;
                }
            }
            if (NpcCount < TownNpcsForBrutusToBeginAppearing)
            {
                return;
            }
            int SpawnChance = 20 - ChanceCounter() / 2;

            if (SpawnChance > 0 && Main.rand.Next(SpawnChance) > (NpcCount - TownNpcsForBrutusToBeginAppearing) * 0.5f)
            {
                return;
            }
            List <int> NpcsToSpawnOn = new List <int>();

            for (int i = 0; i < 200; i++)
            {
                if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType <BrutusNPC>())
                {
                    return;
                }
                if (Main.npc[i].active && Main.npc[i].townNPC && !Main.npc[i].homeless && Main.npc[i].type != 37)
                {
                    byte PickedPlayer = Player.FindClosest(Main.npc[i].position, Main.npc[i].width, Main.npc[i].height);
                    if (Math.Abs(Main.player[PickedPlayer].Center.X - Main.npc[i].Center.X) >= NPC.sWidth * 0.5f ||
                        Math.Abs(Main.player[PickedPlayer].Center.Y - Main.npc[i].Center.Y) >= NPC.sHeight * 0.5f)
                    {
                        NpcsToSpawnOn.Add(i);
                    }
                }
            }
            if (NpcsToSpawnOn.Count == 0)
            {
                return;
            }
            int PickedNPC = NpcsToSpawnOn[Main.rand.Next(NpcsToSpawnOn.Count)];
            int SpawnPosX = (int)Main.npc[PickedNPC].Center.X,
                SpawnPosY = (int)(Main.npc[PickedNPC].position.Y + Main.npc[PickedNPC].height);
            int    npcPos = NPC.NewNPC(SpawnPosX, SpawnPosY, ModContent.NPCType <BrutusNPC>());
            string Text   = "<Brutus> *If someone is interessed in having a body guard, come see me near " + Main.npc[PickedNPC].GivenOrTypeName + ".*";

            if (Main.netMode == 0)
            {
                Main.NewText(Text, MainMod.MysteryCloseColor);
            }
            else
            {
                NetMessage.SendData(25, -1, -1, Terraria.Localization.NetworkText.FromLiteral(Text), MainMod.MysteryCloseColor.R, MainMod.MysteryCloseColor.G, MainMod.MysteryCloseColor.B, 255);
            }
            WarnedAboutBrutus = true;
        }
Example #21
0
        public override void AI()
        {
            LeftArmFrame  = -1;
            RightArmFrame = -1;
            BodyFrame     = -1;
            //AI Work here
            npc.homeTileX = npc.homeTileY = -1;
            if (Main.player[Main.myPlayer].talkNPC == npc.whoAmI)
            {
                npc.direction = Main.player[Main.myPlayer].Center.X < npc.Center.X ? -1 : 1;
            }
            if (!WarnedAboutBrutus)
            {
                Main.NewText("<Brutus> I'm still looking for someone to hire me as a bodyguard. Find me by your towns if you want to hire me.", MainMod.MysteryCloseColor);
                WarnedAboutBrutus = true;
            }
            if (SteelTestingTime > 0)
            {
                bool CaughtADebuff = false;
                for (int i = 0; i < npc.buffType.Length; i++)
                {
                    if (npc.buffType[i] > 0 && Main.debuff[npc.buffType[i]])
                    {
                        CaughtADebuff = true;
                        break;
                    }
                }
                if (CaughtADebuff)
                {
                    EndDamageTest();
                    PlayScene(SCENE_PLAYERCHEATS);
                }
            }
            if (SteelTestingTime > 0)
            {
                SteelTestingTime--;
                npc.TargetClosest(true);
                if (SteelTestingTime <= 0)
                {
                    SayMessage("*Growl! Time's up.*");
                    EndDamageTest();
                    PlayScene(0);
                }
            }
            npc.npcSlots = 1;
            switch (Scene)
            {
            default:
            {
                SceneTime++;
                Idle = true;
                if (false && SteelTestingTime <= 0 && SceneTime >= 600 && npc.velocity.X == 0 && npc.velocity.Y == 0)
                {
                    BodyFrame = LeftArmFrame = RightArmFrame = Base.DuckingFrame;
                }
            }
            break;

            case SCENE_PLAYERWINS:
                npc.npcSlots = 200;
                if (SceneTime == 0)
                {
                    npc.FaceTarget();
                    npc.velocity.X -= npc.direction * 7.5f;
                    npc.velocity.Y -= 7.5f;
                    SayMessage("*Rooow!! Ugh... Urgh...*");
                    SceneTime = 1;
                }
                else if (SceneTime >= 1)
                {
                    if (npc.velocity.X == 0 && npc.velocity.Y == 0)
                    {
                        int LastSceneTime = SceneTime;
                        SceneTime++;
                        int Frame = Base.DuckingFrame;
                        if (SceneTime == 180)
                        {
                            SayMessage("*I guess I got a bit rusty.*");
                        }
                        if (SceneTime == 480)
                        {
                            SayMessage("*Maybe helping you on your quest will help making me tougher again.*");
                        }
                        if (SceneTime >= 480)
                        {
                            Frame = Base.StandingFrame;
                        }
                        if (SceneTime == 780)
                        {
                            SayMessage("*I am " + Base.Name + ". Your body guard, from now on.*");
                        }
                        if (SceneTime >= 1080)
                        {
                            NpcMod.AddGuardianMet(6);
                            Player player = Main.player[npc.target];
                            PlayerMod.AddPlayerGuardian(player, GuardianBase.Brutus);
                            PlayerMod.GetPlayerGuardian(player, GuardianBase.Brutus).IncreaseFriendshipProgress(1);
                            GuardianData gd = PlayerMod.GetPlayerGuardian(player, GuardianBase.Brutus);
                            if (gd.FriendshipLevel == 0)
                            {
                                gd.IncreaseFriendshipProgress(1);
                            }
                            WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianBase.Brutus);
                            //npc.Transform(ModContent.NPCType<GuardianNPC.List.LionGuardian>());
                        }
                        BodyFrame = LeftArmFrame = RightArmFrame = Frame;
                    }
                }
                break;

            case SCENE_PLAYERCHEATS:
            {
                npc.npcSlots = 200;
                if (SceneTime == 0)
                {
                    SteelTestingTime = 0;
                    SayMessage("*ROAR*");
                    npc.velocity.Y = -5.5f;
                    npc.FaceTarget();
                    SceneTime = 1;
                }
                else
                {
                    ModTargetting target = new ModTargetting();
                    target.TargettingPlayer = true;
                    if (Main.player[npc.target].GetModPlayer <PlayerMod>().Guardian.Active&& Main.player[npc.target].GetModPlayer <PlayerMod>().Guardian.PlayerControl)
                    {
                        target.TargettingPlayer = false;
                    }
                    target.SetTargetToPlayer(Main.player[npc.target]);
                    if (npc.velocity.Y == 0 && npc.velocity.X == 0)
                    {
                        //Player player = Main.player[npc.target];
                        SceneTime++;
                        bool PlayerPickedUp = false;
                        int  RightHandFrame = 0;
                        if (SceneTime >= 30)
                        {
                            PlayerPickedUp = true;
                        }

                        if (SceneTime == 30)
                        {
                            SayMessage("*I said no tricks, idiot.*");
                        }
                        int       t         = 0;
                        const int FrameTime = 8;
                        if (SceneTime >= 60 + t * FrameTime && SceneTime < 60 + (t + 1) * FrameTime)
                        {
                            RightHandFrame = Base.ItemUseFrames[0];
                        }
                        t++;
                        if (SceneTime >= 60 + t * FrameTime && SceneTime < 60 + (t + 1) * FrameTime)
                        {
                            RightHandFrame = Base.ItemUseFrames[1];
                        }
                        t++;
                        if (SceneTime >= 60 + t * FrameTime && SceneTime < 60 + (t + 1) * FrameTime)
                        {
                            RightHandFrame = Base.ItemUseFrames[2];
                            if (SceneTime == 60 + t * FrameTime + FrameTime / 2)
                            {
                                int Damage = (int)((70f / target.MaxHealthBonus) * target.MaxLife);
                                target.Hurt(Damage, npc.direction, " has got what deserved.");
                            }
                        }
                        t++;
                        if (SceneTime >= 60 + t * FrameTime && SceneTime < 60 + (t + 1) * FrameTime)
                        {
                            RightHandFrame = Base.ItemUseFrames[1];
                        }
                        t++;
                        if (SceneTime >= 60 + t * FrameTime && SceneTime < 60 + (t + 1) * FrameTime)
                        {
                            RightHandFrame = Base.ItemUseFrames[0];
                        }
                        t++;
                        if (SceneTime >= 60 + t * FrameTime)
                        {
                            PlayScene(0);
                        }

                        if (PlayerPickedUp)
                        {
                            int hx, hy;
                            Base.LeftHandPoints.GetPositionFromFrame(Base.ItemUseFrames[2], out hx, out hy);
                            LeftArmFrame = Base.ItemUseFrames[2];
                            Vector2 Pos = new Vector2(hx, Base.SpriteHeight - hy);
                            if (npc.direction < 0)
                            {
                                Pos.X = Base.SpriteWidth - Pos.X;
                            }
                            Pos.X           += npc.width * 0.5f - Base.SpriteWidth * 0.5f;
                            Pos.Y           += npc.height - Base.SpriteHeight;
                            Pos             += npc.position;
                            target.Center    = Pos;
                            target.FallStart = (int)(target.Position.Y / 16);
                        }
                        RightArmFrame = RightHandFrame;
                    }
                }
            }
            break;
            }
            base.AI(); //Never.Remove
            if (!Main.dayTime)
            {
                bool PlayerInRange = false;
                for (int p = 0; p < 255; p++)
                {
                    if (!Main.player[p].active)
                    {
                        continue;
                    }
                    Vector2 PositionDifference = npc.Center - Main.player[p].Center;
                    if (Math.Abs(PositionDifference.X) < NPC.sWidth * 0.5f + NPC.safeRangeX &&
                        Math.Abs(PositionDifference.Y) < NPC.sHeight * 0.5f + NPC.safeRangeY)
                    {
                        PlayerInRange = true;
                        break;
                    }
                }
                if (!PlayerInRange)
                {
                    Main.NewText("The Lion Guardian has returned to the Ether Realm.", Color.OrangeRed);
                    npc.active = false;
                    npc.life   = 0;
                }
            }
        }
Example #22
0
        public override void Update(TerraGuardian guardian)
        {
            IgnoreCombat = true;
            Cancellable  = false;
            if (guardian.Downed || guardian.KnockedOut)
            {
                MainMod.ScreenColorAlpha = 0;
                InUse = false;
                return;
            }
            bool       SetPlayerToGuardianBed = false;
            const bool UseBedSharing          = false;

            switch (Step)
            {
            case 0:
            {
                if (UseBedSharing && guardian.Base.Size >= GuardianBase.GuardianSize.Large)
                {
                    if (guardian.AttemptToGrabPlayer())
                    {
                        ChangeStep();
                    }
                    guardian.WalkMode = true;
                }
                else
                {
                    ChangeStep();
                }
            }
            break;

            case 1:
            {
                if (Time == 0)
                {
                    if (guardian.furniturex > -1)
                    {
                        guardian.LeaveFurniture(false);
                    }
                    guardian.TryFindingNearbyBed(false);
                }
                if (guardian.furniturex == -1 || guardian.UsingFurniture)
                {
                    ChangeStep();
                }
                if (guardian.furniturex > -1)
                {
                    guardian.WalkMode = true;
                }
            }
            break;

            case 2:
            {
                MainMod.ScreenColor.R    = MainMod.ScreenColor.G = MainMod.ScreenColor.B = 0;
                MainMod.ScreenColorAlpha = (float)Time / (5 * 60);
                if (MainMod.ScreenColorAlpha > 1)
                {
                    MainMod.ScreenColorAlpha = 1f;
                }
                if (UseBedSharing && guardian.IsSleeping && guardian.GrabbingPlayer)
                {
                    SetPlayerToGuardianBed = true;
                }
                if (Time >= 5 * 60)
                {
                    //Do time change
                    if (guardian.OwnerPos > -1)
                    {
                        Main.player[guardian.OwnerPos].position.X = guardian.Position.X - Main.player[guardian.OwnerPos].width * 0.5f;
                        Main.player[guardian.OwnerPos].position.Y = guardian.Position.Y - Main.player[guardian.OwnerPos].height;
                        Main.player[guardian.OwnerPos].velocity   = Vector2.Zero;
                        int RestValue = 4;
                        switch (RestTime)
                        {
                        case 0:
                            RestValue = 4;
                            break;

                        case 1:
                            RestValue = 8;
                            break;

                        case 2:             //UntilDawn
                            RestValue = 0;
                            if (Main.dayTime)
                            {
                                RestValue += (int)(24 * 3600 - Main.time) / 3600 + 1;
                            }
                            else
                            {
                                RestValue += (int)(9 * 3600 - Main.time) / 3600 + 1;
                            }
                            break;

                        case 3:             //UntilNight
                            RestValue = 0;
                            if (Main.dayTime)
                            {
                                RestValue += (int)(15 * 3600 - Main.time) / 3600 + 1;
                            }
                            else
                            {
                                RestValue += (int)(24 * 3600 - Main.time) / 3600 + 1;
                            }
                            break;
                        }
                        WorldMod.SkipTime(RestValue);
                        foreach (TerraGuardian g in Main.player[guardian.OwnerPos].GetModPlayer <PlayerMod>().GetAllGuardianFollowers)
                        {
                            float RestBonus = 1.5f;
                            if (g.Base.IsNocturnal)
                            {
                                if (!Main.dayTime)
                                {
                                    RestBonus = 2f;
                                }
                            }
                            else
                            {
                                if (Main.dayTime)
                                {
                                    RestBonus = 2f;
                                }
                            }
                            RestBonus *= RestValue;
                            if ((int)g.Data.Fatigue - RestBonus < 0)
                            {
                                g.Data.Fatigue = 0;
                            }
                            else
                            {
                                g.Data.Fatigue -= (sbyte)RestBonus;
                            }
                            float InjuryValue = RestBonus * 0.5f;
                            if ((int)g.Data.Injury - RestBonus < 0)
                            {
                                g.Data.Injury = 0;
                            }
                            else
                            {
                                g.Data.Injury -= (sbyte)InjuryValue;
                            }
                            if (g.request.Active)
                            {
                                g.request.RequestTimeLeft -= RestValue;
                            }
                        }
                    }
                    guardian.GrabbingPlayer = false;
                    ChangeStep();
                }
            }
            break;

            case 3:
            {
                Player player = Main.player[guardian.OwnerPos];
                if (Time >= 5 * 60)
                {
                    InUse = false;
                    MainMod.ScreenColorAlpha = 0;
                    if (guardian.IsSleeping)
                    {
                        player.fullRotation = 0;
                        guardian.LeaveFurniture();
                    }
                }
                else
                {
                    MainMod.ScreenColor.R    = MainMod.ScreenColor.G = MainMod.ScreenColor.B = 0;
                    MainMod.ScreenColorAlpha = 1f - (float)Time / (5 * 60);
                    if (guardian.IsSleeping)
                    {
                        SetPlayerToGuardianBed = true;
                    }
                }
            }
            break;
            }
            if (UseBedSharing && SetPlayerToGuardianBed)
            {
                Player player = Main.player[guardian.OwnerPos];
                player.direction            = guardian.Direction;
                player.fullRotation         = -1.570796326794897f * player.direction;
                player.position.X           = guardian.Position.X - player.width * 0.5f - guardian.Base.SleepingOffset.X;
                player.position.Y           = guardian.Position.Y - player.height - guardian.Base.SleepingOffset.Y;
                player.velocity             = Vector2.Zero;
                player.fullRotationOrigin.X = player.width * 0.5f;
                player.fullRotationOrigin.Y = player.height * 0.5f;
                guardian.GrabbingPlayer     = false;
            }
        }
 public static void DrawBannerGame()
 {
     if (!ManagingGuardianHouses)
     {
         return;
     }
     try
     {
         string MouseText = "";
         for (int g = 0; g < WorldMod.MaxGuardianNpcsInWorld; g++)
         {
             WorldMod.GuardianTownNpcState townnpc = WorldMod.GuardianNPCsInWorld[g];
             if (townnpc != null && !townnpc.Homeless && WorldMod.IsGuardianNpcInWorld(townnpc.CharID))
             {
                 int BannerX = townnpc.HomeX, BannerY = townnpc.HomeY;
                 if (BannerX < 0 || BannerY < 0)
                 {
                     continue;
                 }
                 BannerY--;
                 if (Main.tile[BannerX, BannerY] == null)
                 {
                     continue;
                 }
                 bool EndsOnNullTile = false;
                 while (!Main.tile[BannerX, BannerY].active() || !Main.tileSolid[(int)Main.tile[BannerX, BannerY].type])
                 {
                     BannerY--;
                     if (BannerY < 10)
                     {
                         break;
                     }
                     if (Main.tile[BannerX, BannerY] == null)
                     {
                         EndsOnNullTile = true;
                         break;
                     }
                 }
                 if (EndsOnNullTile)
                 {
                     continue;
                 }
                 TerraGuardian guardian = null;
                 foreach (TerraGuardian tg in WorldMod.GuardianTownNPC)
                 {
                     if (townnpc.IsID(tg.ID, tg.ModID))
                     {
                         guardian = tg;
                         break;
                     }
                 }
                 if (guardian == null)
                 {
                     continue;
                 }
                 const int PaddingX = 8;
                 int       PaddingY = 18;
                 if (Main.tile[BannerX, BannerY].type == 19)
                 {
                     PaddingY -= 8;
                 }
                 BannerY++;
                 Vector2 BannerPosition = new Vector2(BannerX * 16 + PaddingX, BannerY * 16 + PaddingY) - Main.screenPosition;
                 DrawBanner(guardian, BannerPosition, Lighting.GetColor(BannerX, BannerY));
                 BannerPosition -= new Vector2(Main.HouseBannerTexture[1].Width * 0.5f, Main.HouseBannerTexture[1].Height * 0.5f);
                 if (Main.mouseX >= BannerPosition.X && Main.mouseX < BannerPosition.X + Main.HouseBannerTexture[1].Width &&
                     Main.mouseY >= BannerPosition.Y && Main.mouseY < BannerPosition.Y + Main.HouseBannerTexture[1].Height)
                 {
                     //MainPlayer.mouseInterface = true;
                     MouseText = guardian.Name;
                     if (Main.mouseRight && Main.mouseRightRelease)
                     {
                         if (!guardian.IsStarter && !guardian.IsPlayerBuddy(Main.LocalPlayer) && guardian.FriendshipLevel < guardian.Base.MoveInLevel)
                         {
                             Main.NewText(guardian.Name + (Main.rand.Next(2) == 0 ? " refuses to leave their house." : " doesn't want to be kicked out of their house."), Color.PaleVioletRed);
                         }
                         else
                         {
                             townnpc.Homeless  = true;
                             townnpc.HomeX     =
                                 townnpc.HomeY = -1;
                             townnpc.ValidateHouse();
                             Main.PlaySound(12, -1, -1, 1, 1f, 0f);
                         }
                     }
                 }
             }
         }
         if (MouseText != "")
         {
             Utils.DrawBorderString(Main.spriteBatch, MouseText, new Vector2(Main.mouseX, Main.mouseY + 16), Color.White, 1f, 0.5f);
         }
     }
     catch
     {
     }
 }
 public static void Draw()
 {
     if (!ManagingGuardianHouses)
     {
         return;
     }
     try
     {
         string  MouseText                   = "";
         float   Scale                       = 0.85f;
         float   SlotSpace                   = (56 * Scale);
         int     MaxRowItems                 = (int)((Main.screenWidth - 64) / SlotSpace);
         Vector2 RowPosition                 = new Vector2(0, Main.screenHeight - SlotSpace - 8);
         bool    MouseOverHouseIcon          = false;
         List <TerraGuardian[]> GuardianRows = new List <TerraGuardian[]>();
         {
             List <TerraGuardian> Guardians = new List <TerraGuardian>();
             int Counter = 0;
             foreach (TerraGuardian tg in WorldMod.GuardianTownNPC)
             {
                 if (tg.FriendshipLevel >= tg.Base.MoveInLevel || tg.IsPlayerBuddy(Main.LocalPlayer) || tg.IsStarter)
                 {
                     Guardians.Add(tg);
                 }
                 Counter++;
                 if (Counter >= MaxRowItems)
                 {
                     GuardianRows.Add(Guardians.ToArray());
                     Guardians.Clear();
                 }
             }
             GuardianRows.Add(Guardians.ToArray());
             Guardians.Clear();
         }
         for (int r = 0; r < GuardianRows.Count; r++)
         {
             RowPosition.X = Main.screenWidth * 0.5f - GuardianRows[r].Length * SlotSpace * 0.5f;
             for (int n = 0; n < GuardianRows[r].Length; n++)
             {
                 Main.spriteBatch.Draw(Main.inventoryBack6Texture, RowPosition, null, Main.inventoryBack, 0f, Vector2.Zero, Scale, SpriteEffects.None, 0f);
                 GuardianRows[r][n].DrawHead(RowPosition + new Vector2(28, 28) * Scale);
                 if (Main.mouseX >= RowPosition.X && Main.mouseX < RowPosition.X + SlotSpace &&
                     Main.mouseY >= RowPosition.Y && Main.mouseY < RowPosition.Y + SlotSpace)
                 {
                     MainPlayer.mouseInterface = true;
                     MouseOverHouseIcon        = true;
                     if (Main.mouseLeft && Main.mouseLeftRelease)
                     {
                         IsPickingAGuardianHouse     = true;
                         PickedGuardianToGiveHousing = GuardianRows[r][n].WhoAmID;
                         Main.PlaySound(12, -1, -1, 1, 1f, 0f);
                     }
                 }
                 RowPosition.X += SlotSpace;
             }
             RowPosition.Y -= SlotSpace;
         }
         if (IsPickingAGuardianHouse)
         {
             MainPlayer.mouseInterface = true;
             if (!MainMod.ActiveGuardians.ContainsKey(PickedGuardianToGiveHousing))
             {
                 IsPickingAGuardianHouse = false;
             }
             else
             {
                 DrawBanner(MainMod.ActiveGuardians[PickedGuardianToGiveHousing], new Vector2(Main.mouseX + 16, Main.mouseY + 16), Color.White);
                 if (!MouseOverHouseIcon && Main.mouseLeft && Main.mouseLeftRelease)
                 {
                     int TileX = (int)(Main.mouseX + Main.screenPosition.X) / 16, TileY = (int)(Main.mouseY + Main.screenPosition.Y) / 16;
                     if (WorldMod.MoveGuardianToHouse(MainMod.ActiveGuardians[PickedGuardianToGiveHousing], TileX, TileY))
                     {
                         Main.NewText(MainMod.ActiveGuardians[PickedGuardianToGiveHousing].Name + " will move to this room.", Color.Yellow);
                         IsPickingAGuardianHouse = false;
                         Main.PlaySound(12, -1, -1, 1, 1f, 0f);
                     }
                 }
                 if (Main.mouseRight && Main.mouseRightRelease)
                 {
                     IsPickingAGuardianHouse = false;
                 }
             }
         }
         if (MouseText != "")
         {
             Utils.DrawBorderString(Main.spriteBatch, MouseText, new Vector2(Main.mouseX, Main.mouseY + 16), Color.White, 1f, 0.5f);
         }
     }
     catch { }
 }
Example #25
0
        public override void AI()
        {
            int NextStep = NpcRecruitStep;

            switch (NpcRecruitStep)
            {
            case IdleStep:
            {
                Idle = true;
                Rectangle SightRange = new Rectangle((int)npc.Center.X, (int)npc.Center.Y, 300, 300);
                SightRange.Y -= (int)(SightRange.Height * 0.5f);
                if (npc.direction < 0)
                {
                    SightRange.X -= SightRange.Width;
                }
                DialogueDuration++;
                if (DialogueDuration >= 600)
                {
                    DialogueDuration -= 600;
                    switch (Main.rand.Next(5))
                    {
                    case 0:
                        SayMessage("*Hm... It must be around here somewhere...*");
                        break;

                    case 1:
                        SayMessage("*Come on... Show up...*");
                        break;

                    case 2:
                        SayMessage("*...It's around here... I smell It.*");
                        break;

                    case 3:
                        SayMessage("*Terrarian, where are you...*");
                        break;

                    case 4:
                        SayMessage("*Once I catch that Terrarian.... Ugh...*");
                        break;
                    }
                }
                for (int p = 0; p < 255; p++)
                {
                    if (Main.player[p].active && !Main.player[p].dead)
                    {
                        if (Main.player[p].getRect().Intersects(SightRange) && Collision.CanHitLine(npc.position, npc.width, npc.height, Main.player[p].position, Main.player[p].width, Main.player[p].height) &&
                            !Main.player[p].GetModPlayer <PlayerMod>().ControllingGuardian)
                        {
                            npc.target = p;
                            NextStep   = CallingOutPlayerStep;
                            break;
                        }
                    }
                }
            }
            break;

            case CallingOutPlayerStep:
            {
                Idle = false;
                if (DialogueDuration == 0)
                {
                    if (PlayerMod.PlayerHasGuardian(Main.player[npc.target], GuardianID, GuardianModID))
                    {
                        SayMessage("*Hey, Terrarian! Over here!*");
                    }
                    else if (Main.player[npc.target].GetModPlayer <PlayerMod>().KnockedOut)
                    {
                        SayMessage("*You there! Hang on!*");
                    }
                    else
                    {
                        if (Main.rand.Next(2) == 0)
                        {
                            SayMessage("*Hey! You there! Stop!*");
                        }
                        else
                        {
                            SayMessage("*Hey! You! Don't move!*");
                        }
                    }
                }
                if (DialogueDuration >= 120)
                {
                    NextStep = ChasingPlayerStep;
                }
                else
                {
                    DialogueDuration++;
                }
                if (Main.player[npc.target].Center.X < npc.Center.X)
                {
                    npc.direction = -1;
                }
                else
                {
                    npc.direction = 1;
                }
                if (!Main.player[npc.target].active)
                {
                    NextStep = IdleStep;
                    SayMessage("*Hm... " + (Main.player[npc.target].Male ? "He" : "She") + " disappeared...*");
                }
                else if (Main.player[npc.target].dead)
                {
                    NextStep = IdleStep;
                    SayMessage("*Well... That's... Horrible...*");
                }
            }
            break;

            case ChasingPlayerStep:
            {
                Player player = Main.player[npc.target];
                if (player.Center.X < npc.Center.X)
                {
                    MoveLeft = true;
                }
                else
                {
                    MoveRight = true;
                }
                if (!player.GetModPlayer <PlayerMod>().KnockedOut&& npc.velocity.Y == 0 && player.velocity.Y != 0)
                {
                    Jump = true;
                }
                if (PlayerMod.PlayerHasGuardian(Main.player[npc.target], GuardianID, GuardianModID) && Math.Abs(player.Center.X - npc.Center.X) < 80)
                {
                    NextStep = SpeakingToAlreadyKnownPlayer;
                }
                else if (player.getRect().Intersects(npc.getRect()))
                {
                    if (Main.halloween)
                    {
                        MainMod.TriggerCompanionJS(GuardianID);
                    }
                    if (PlayerMod.PlayerHasGuardian(Main.player[npc.target], GuardianID, GuardianModID))
                    {
                        NextStep = SpeakingToAlreadyKnownPlayer;
                    }
                    else
                    {
                        NextStep = InvestigatingPlayerStep;
                    }
                }
                if (!player.active)
                {
                    NextStep = IdleStep;
                    SayMessage("*Hm... " + (Main.player[npc.target].Male ? "He" : "She") + " disappeared...*");
                }
                else if (player.dead)
                {
                    NextStep = IdleStep;
                    SayMessage("*Damn, I'm too late...*");
                }
            }
            break;

            case InvestigatingPlayerStep:
            {
                if (DialogueDuration == 0)
                {
                    FindFrame(0);
                }
                Player player = Main.player[npc.target];
                if (player.mount.Active)
                {
                    player.mount.Dismount(player);
                }
                if (player.GetModPlayer <PlayerMod>().MountedOnGuardian)
                {
                    foreach (TerraGuardian tg in player.GetModPlayer <PlayerMod>().GetAllGuardianFollowers)
                    {
                        if (tg.Active && tg.PlayerMounted)
                        {
                            tg.ToggleMount(true, false);
                        }
                    }
                }
                player.immuneTime    = 90;
                player.immuneNoBlink = true;
                Vector2 PlayerPosition = new Vector2(npc.Center.X + 32 * npc.direction, npc.position.Y + npc.height);
                player.fullRotationOrigin = new Vector2(player.width, player.height) * 0.5f;
                player.aggro = -99999;
                if (npc.direction > 0)
                {
                    player.fullRotation = 1.570796f;
                    player.direction    = -1;
                }
                else
                {
                    player.fullRotation = -1.570796f;
                    //PlayerPosition.X *= -1;
                    player.direction = 1;
                }
                DrawInFrontOfPlayers.Add(npc.whoAmI);
                player.velocity = Vector2.Zero;
                player.Center   = PlayerPosition;
                player.statLife++;
                if (player.mount.Active)
                {
                    player.mount.Dismount(player);
                }
                player.gfxOffY = -2;
                player.AddBuff(Terraria.ID.BuffID.Cursed, 5);
                if (npc.velocity.X != 0 || npc.velocity.Y != 0)
                {
                }
                else if (player.GetModPlayer <PlayerMod>().KnockedOut)
                {
                    if (DialogueDuration == 0)
                    {
                        SayMessage("*Better I take care of those wounds first.*");
                        DialogueDuration++;
                    }
                    player.GetModPlayer <PlayerMod>().ReviveBoost++;
                }
                else
                {
                    if (DialogueDuration % 210 == 0)
                    {
                        switch (DialogueDuration / 210)
                        {
                        case 0:
                            SayMessage("*Got you! Now don't move.*");
                            break;

                        case 1:
                            SayMessage("*Hm...*");
                            break;

                        case 2:
                            SayMessage("*Interesting...*");
                            break;

                        case 3:
                            SayMessage("*Uh huh...*");
                            break;

                        case 4:
                            SayMessage("*But you're not the one I'm looking for...*");
                            break;

                        case 5:
                            NextStep                  = IntroductingToPlayerStep;
                            player.fullRotation       = 0;
                            player.fullRotationOrigin = new Vector2(40, 56) * 0.5f;
                            player.position           = npc.Bottom;
                            player.position.Y        -= player.height;
                            player.immuneNoBlink      = false;
                            break;
                        }
                    }
                    DialogueDuration++;
                }
                if (!player.active)
                {
                    NextStep = IdleStep;
                    SayMessage("*" + (Main.player[npc.target].Male ? "He" : "She") + " disappeared!*");
                }
            }
            break;

            case IntroductingToPlayerStep:
            {
                if (DialogueDuration == 0)
                {
                    Main.player[npc.target].talkNPC = npc.whoAmI;
                    DialogueDuration = 1;
                    Main.npcChatText = GetChat();
                }
                if (!Main.player[npc.target].active)
                {
                    npc.TargetClosest(false);
                    DialogueDuration = 1;
                }
                if (DialogueDuration > 1 && Main.player[npc.target].talkNPC != npc.whoAmI)
                {
                    DialogueDuration = 1;
                }
            }
            break;

            case SpeakingToAlreadyKnownPlayer:
            {
                if (DialogueDuration % 180 == 0)
                {
                    switch (DialogueDuration / 180)
                    {
                    case 0:
                        SayMessage("*I didn't expected to see you here.*");
                        break;

                    case 1:
                        SayMessage("*I think I may have caught that Terrarian's scent around here.*");
                        break;

                    case 2:
                        SayMessage("*Or maybe I accidentally caught your scent again.*");
                        break;

                    case 3:
                        SayMessage("*Anyway, If you need me, I'll be around.*");
                        break;

                    case 4:
                    {
                        NpcMod.AddGuardianMet(GuardianID, GuardianModID);
                        WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
                    }
                        return;
                    }
                }
                if (Math.Abs(Main.player[npc.target].Center.X - npc.Center.X) >= 30)
                {
                    Walk = true;
                    if (Main.player[npc.target].Center.X < npc.Center.X)
                    {
                        MoveLeft = true;
                    }
                    else
                    {
                        MoveRight = true;
                    }
                }
                else
                {
                    if (Main.player[npc.target].Center.X < npc.Center.X)
                    {
                        npc.direction = -1;
                    }
                    else
                    {
                        npc.direction = 1;
                    }
                }
                if (!Main.player[npc.target].active)
                {
                    NextStep = IdleStep;
                    SayMessage("*" + (Main.player[npc.target].Male ? "He" : "She") + " disappeared!*");
                }
                DialogueDuration++;
            }
            break;
            }
            if (NextStep != NpcRecruitStep)
            {
                NpcRecruitStep   = NextStep;
                DialogueDuration = 0;
            }
            base.AI();
        }
Example #26
0
        public override void AI()
        {
            AlexRecruitScripts.AlexNPCPosition = npc.whoAmI;
            const int Distance = 1024;
            int       SpawnPosX = AlexRecruitScripts.TombstoneTileX * 16, SpawnPosY = AlexRecruitScripts.TombstoneTileY * 16;
            bool      MoveLeft = false, MoveRight = false, Jump = false, Dash = false;
            string    TextToSay     = "";
            bool      PlayerOnFloor = false;

            npc.npcSlots = 1;
            switch ((int)npc.ai[AI_TYPE])
            {
            case 0:     //Wait for Player
                npc.TargetClosest(true);
                bool TeleportToSpawn = false;
                if (npc.target > -1)
                {
                    Player player = Main.player[npc.target];
                    PlayerIsMale = player.Male;
                    Rectangle FoV = new Rectangle(0, -150, 250, 300);
                    if (npc.direction < 0)
                    {
                        FoV.X -= FoV.Width;
                    }
                    FoV.X += (int)npc.Center.X;
                    FoV.Y += (int)npc.Center.Y;
                    if (FoV.Intersects(player.getRect()) && Collision.CanHitLine(npc.position, npc.width, npc.height, player.position, player.width, player.height))
                    {
                        //Chase Player
                        npc.ai[AI_TYPE]  = 1;
                        npc.ai[AI_TIMER] = 0;
                    }
                    else
                    {
                        //Keep looking for player
                        float XDifference = SpawnPosX - npc.Center.X, YDifference = SpawnPosY - npc.Center.Y;
                        if (Math.Abs(XDifference) >= NPC.sWidth || Math.Abs(YDifference) >= NPC.sHeight)
                        {
                            TeleportToSpawn = true;
                        }
                        else if (Math.Abs(XDifference) >= 16 || Math.Abs(YDifference) >= npc.height)
                        {
                            if (XDifference < 0)
                            {
                                MoveLeft = true;
                            }
                            else
                            {
                                MoveRight = true;
                            }
                        }
                    }
                }
                else
                {
                    TeleportToSpawn = Math.Abs(npc.Center.X - SpawnPosX) >= 16 || Math.Abs(npc.Center.Y - SpawnPosY) >= npc.height;
                }
                if (TeleportToSpawn)
                {
                    npc.position.X = AlexRecruitScripts.TombstoneTileX - npc.width * 0.5f;
                    npc.position.Y = AlexRecruitScripts.TombstoneTileY - npc.height;
                }
                break;

            case 1:
                if (npc.target == -1)
                {
                    npc.ai[AI_TYPE]  = 0;
                    npc.ai[AI_TIMER] = 0;
                }
                else
                {
                    Player player = Main.player[npc.target];
                    float  XDifference = player.Center.X - npc.Center.X, YDifference = player.Center.Y - npc.Center.Y;
                    if (Math.Abs(XDifference) >= NPC.sWidth || Math.Abs(YDifference) >= NPC.sHeight)
                    {
                        //TeleportToSpawn = true;
                        npc.ai[AI_TYPE]  = 0;
                        npc.ai[AI_TIMER] = 0;
                    }
                    else
                    {
                        if (XDifference < 0)
                        {
                            MoveLeft = true;
                        }
                        else
                        {
                            MoveRight = true;
                        }
                        if (npc.velocity.Y == 0 && Math.Abs(XDifference) <= AlexGuardianBase.Width * 2 + AlexGuardianBase.JumpSpeed * 2)
                        {
                            Jump = true;
                        }
                        if (npc.Hitbox.Intersects(player.getRect()))
                        {
                            npc.ai[AI_TYPE]  = 2;
                            npc.ai[AI_TIMER] = 0;
                            MessageTime      = 30;
                            if (Main.halloween)
                            {
                                MainMod.TriggerAlexJS();
                            }
                            if (!PlayerMod.PlayerHasGuardian(Main.player[Main.myPlayer], AlexID))
                            {
                                PlayerOnFloor = true;
                            }
                            if (PlayerMod.PlayerMountedOnGuardian(Main.player[Main.myPlayer]))
                            {
                                Main.player[Main.myPlayer].GetModPlayer <PlayerMod>().MountGuardian.ToggleMount(true, false);
                            }
                        }
                    }
                }
                break;

            case 2:     //Speaks with player
            {
                npc.npcSlots = 200;
                if (npc.target == -1)
                {
                    //Go to the chat where he asks where the player went, then return to AI 0;
                    npc.ai[AI_TYPE]  = 3;
                    npc.ai[AI_TIMER] = 0;
                }
                else
                {
                    if (npc.velocity.X != 0 || npc.velocity.Y != 0)         //Only chat when lands.
                    {
                        break;
                    }
                    int  DialogueTimer      = (int)npc.ai[AI_TIMER] / 30;
                    bool Trigger            = npc.ai[AI_TIMER] % 30 == 15;
                    bool HasAlreadyGuardian = false;
                    if (PlayerMod.PlayerHasGuardian(Main.player[Main.myPlayer], AlexID))
                    {
                        HasAlreadyGuardian = true;
                    }
                    if (Trigger)
                    {
                        if (HasAlreadyGuardian)
                        {
                            switch (DialogueTimer / 5)
                            {
                            case 0:
                                TextToSay = "Hey buddy-buddy!";
                                break;

                            case 1:
                                TextToSay = "It's good to see your face again.";
                                break;

                            case 2:
                                TextToSay = "Anything you want, I'm here to protect you.";
                                break;

                            case 3:
                                NpcMod.AddGuardianMet(AlexID);
                                WorldMod.TurnNpcIntoGuardianTownNpc(npc, AlexID);
                                //npc.Transform(ModContent.NPCType<GuardianNPC.List.GiantDogGuardian>());
                                break;
                            }
                        }
                        else
                        {
                            switch (DialogueTimer)
                            {
                            case 0:
                                TextToSay = "Hello! Who are you?";
                                break;

                            case 5:
                                TextToSay = "Are you my new friend? Do you want to be my friend?";
                                break;

                            case 10:
                                TextToSay = "You're saying that I'm crushing your chest? Oh! My bad!";
                                break;

                            case 12:
                                npc.velocity.X -= 15f * npc.direction;
                                npc.velocity.Y -= AlexGuardianBase.JumpSpeed;
                                break;

                            case 15:
                                TextToSay = "By the way, I'm " + AlexGuardianBase.Name + ", let's go on an adventure.";
                                break;

                            case 20:
                                //Guardian GET!
                                PlayerMod.AddPlayerGuardian(Main.player[npc.target], AlexID);
                                PlayerMod.GetPlayerGuardian(Main.player[npc.target], AlexID).IncreaseFriendshipProgress(1);
                                WorldMod.TurnNpcIntoGuardianTownNpc(npc, AlexID);
                                NpcMod.AddGuardianMet(AlexID);
                                break;
                            }
                        }
                    }
                    if (!HasAlreadyGuardian && DialogueTimer < 12)
                    {
                        PlayerOnFloor = true;
                    }
                    if (HasAlreadyGuardian)
                    {
                        float XDifference = Main.player[Main.myPlayer].Center.X - npc.Center.X;
                        if (Math.Abs(XDifference) > AlexGuardianBase.Width)
                        {
                            if (XDifference > 0)
                            {
                                MoveRight = true;
                            }
                            else
                            {
                                MoveLeft = true;
                            }
                        }
                    }
                    npc.ai[AI_TIMER]++;
                }
            }
            break;

            case 3:     //Player disappeared/is missing chat
            {
                int  DialogueTimer = (int)npc.ai[AI_TIMER] / 30;
                bool Trigger       = npc.ai[AI_TIMER] % 30 == 15;
                if (Trigger)
                {
                    if (DialogueTimer == 3)
                    {
                        TextToSay = "Where did " + (PlayerIsMale ? "he" : "she") + " go?";
                    }
                    if (DialogueTimer == 7)
                    {
                        TextToSay = "Better I go guard the tombstone then...";
                    }
                    if (DialogueTimer == 13)
                    {
                        npc.ai[AI_TYPE]  = 0;
                        npc.ai[AI_TIMER] = 0;
                    }
                }
                npc.ai[AI_TIMER]++;
            }
            break;
            }
            if (npc.target > -1)
            {
                Player        player   = Main.player[npc.target];
                TerraGuardian guardian = player.GetModPlayer <PlayerMod>().Guardian;
                if (PlayerOnFloor)
                {
                    Vector2 NewPlayerPosition = Vector2.Zero;
                    NewPlayerPosition.X         = npc.Center.X + (26) * npc.direction;
                    NewPlayerPosition.Y         = npc.position.Y + npc.height;
                    player.fullRotationOrigin.X = player.width * 0.5f;
                    player.fullRotationOrigin.Y = player.height * 0.5f;
                    player.velocity             = Vector2.Zero;
                    if (player.mount.Active)
                    {
                        player.mount.Dismount(player);
                    }
                    if (npc.velocity.Y != 0)
                    {
                        player.fullRotation = npc.direction * MathHelper.ToRadians(45);
                    }
                    else
                    {
                        player.fullRotation = npc.direction * MathHelper.ToRadians(90);
                    }
                    player.gfxOffY       = -2;
                    player.Center        = NewPlayerPosition;
                    player.direction     = -npc.direction;
                    player.immuneTime    = 30;
                    player.immuneNoBlink = true;
                    player.fallStart     = (int)player.position.Y / 16;
                    player.breath        = player.breathMax;
                    player.statLife++;
                    if (player.statLife > player.statLifeMax2)
                    {
                        player.statLife = player.statLifeMax2;
                    }
                    if (guardian.Active)
                    {
                        if (guardian.PlayerMounted)
                        {
                            guardian.PlayerMounted = false;
                        }
                        if (guardian.PlayerControl)
                        {
                            guardian.ImmuneTime = 5;
                            guardian.Rotation   = player.fullRotation;
                            guardian.Position.X = player.position.X - guardian.Height * 0.5f * npc.direction;
                            guardian.Position.Y = player.position.Y + guardian.Width * 0.25f;// -guardian.Width * 0.5f;
                        }
                    }
                }
                else if (LastOnFloor)
                {
                    player.fullRotation       = 0;
                    player.velocity.Y        -= 6.5f;
                    player.direction          = -npc.direction;
                    player.fullRotationOrigin = Vector2.Zero;
                    if (guardian.Active)
                    {
                        if (guardian.PlayerControl)
                        {
                            guardian.Rotation   = player.fullRotation;
                            guardian.Position.X = player.position.X;
                            guardian.Position.Y = player.position.Y;// -guardian.Height * 0.5f;
                            guardian.Velocity   = player.velocity;
                        }
                    }
                }
            }
            LastOnFloor = PlayerOnFloor;
            float Acceleration = AlexGuardianBase.Acceleration, MaxSpeed = AlexGuardianBase.MaxSpeed, Deceleration = AlexGuardianBase.SlowDown,
                  JumpSpeed = AlexGuardianBase.JumpSpeed;

            if (Dash)
            {
                MaxSpeed     *= 2;
                Acceleration *= 2;
            }
            int MaxJumpHeight = AlexGuardianBase.MaxJumpHeight;

            if (MoveLeft)
            {
                npc.direction   = -1;
                npc.velocity.X -= Acceleration;
                if (npc.velocity.X < -MaxSpeed)
                {
                    npc.velocity.X = -MaxSpeed;
                }
                if (npc.collideX && npc.velocity.Y == 0)
                {
                    Jump = true;
                }
            }
            if (MoveRight)
            {
                npc.direction   = 1;
                npc.velocity.X += Acceleration;
                if (npc.velocity.X > MaxSpeed)
                {
                    npc.velocity.X = MaxSpeed;
                }
                if (npc.collideX && npc.velocity.Y == 0)
                {
                    Jump = true;
                }
            }
            if (!MoveRight && !MoveLeft)
            {
                if (npc.velocity.X > 0)
                {
                    npc.velocity.X -= Deceleration;
                    if (npc.velocity.X < 0)
                    {
                        npc.velocity.X = 0;
                    }
                }
                if (npc.velocity.X < 0)
                {
                    npc.velocity.X += Deceleration;
                    if (npc.velocity.X > 0)
                    {
                        npc.velocity.X = 0;
                    }
                }
            }
            if (Jump)
            {
                if (JumpTime == 0)
                {
                    if (npc.velocity.Y == 0)
                    {
                        JumpTime        = MaxJumpHeight;
                        npc.velocity.Y -= JumpSpeed;
                    }
                }
                else
                {
                    if (npc.collideY)
                    {
                        JumpTime = 0;
                    }
                    else
                    {
                        JumpTime--;
                        npc.velocity.Y -= JumpSpeed;
                    }
                }
            }
            else
            {
                if (JumpTime != 0)
                {
                    JumpTime = 0;
                }
            }
            float StepSpeed = 2f, gfxOffY = 0f;

            Collision.StepUp(ref npc.position, ref npc.velocity, npc.width, npc.height, ref StepSpeed, ref gfxOffY);
            Vector4 SlopedCollision = Collision.SlopeCollision(npc.position, npc.velocity, npc.width, npc.height, 1f, false);

            npc.position = SlopedCollision.XY();
            npc.velocity = SlopedCollision.ZW();
            if (TextToSay != "")
            {
                MessageTime = 300;
                MessageText = TextToSay;

                /*if (Main.netMode == 0)
                 * {
                 *  Main.NewText("Giant Dog: " + TextToSay);
                 * }
                 * else
                 * {
                 *
                 * }*/
            }
        }
Example #27
0
        public override void OnChatButtonClicked(bool firstButton, ref bool shop)
        {
            if (FinishedTalking)
            {
                return;
            }
            switch (EncounterTimes)
            {
            case 0:
                switch (DialogueStep)
                {
                case 0:
                    DialogueStep     = 1;
                    Main.npcChatText = "*Yes, I must ensure that in the case some of them ends up having their time up, I can take them where they belong.*";
                    break;

                case 1:
                    DialogueStep     = 2;
                    Main.npcChatText = "*Yes. Just like you, there is some place you'll be taken when you die. In the TerraGuardians case, it's a different place.*";
                    break;

                case 2:
                    DialogueStep     = 3;
                    Main.npcChatText = "*I will not tell you. Anyways, I hope you don't mind if I stay around your world for the time being.*";
                    break;

                case 3:
                    DialogueStep = 4;
                    if (firstButton)
                    {
                        Main.npcChatText = "*Thank you. You will probably not even notice me around, or at least see me few times.*";
                    }
                    else
                    {
                        Main.npcChatText = "*Hmph. Don't worry, you wont notice me around. Maybe sometimes. Be sure to not stay wherever has a TerraGuardian about to die, then.*";
                    }
                    FinishedTalking = true;
                    EncounterTimes++;
                    break;
                }
                break;

            case 1:
                switch (DialogueStep)
                {
                case 0:
                    DialogueStep = 1;
                    if (WorldGen.crimson)
                    {
                        Main.npcChatText = "*The Crimson? Hm, the name actually makes sense.*";
                    }
                    else
                    {
                        Main.npcChatText = "*The Corruption? Hm, interesting choice of name.*";
                    }
                    break;

                case 1:
                    DialogueStep     = 2;
                    Main.npcChatText = "*I was exploring this world, since there isn't a need for me to take any action right now.*";
                    break;

                case 2:
                    DialogueStep     = 3;
                    Main.npcChatText = "*Yes. Whenever I'm not necessary, I like to explore the world I will harvest from. That way I don't feel bored.*";
                    break;

                case 3:
                    DialogueStep     = 4;
                    Main.npcChatText = "*Indeed it is. Anyways, I will return to my travels.*";
                    FinishedTalking  = true;
                    EncounterTimes++;
                    break;
                }
                break;

            case 2:
                switch (DialogueStep)
                {
                case 0:
                    DialogueStep     = 1;
                    Main.npcChatText = "*Who built this place?*";
                    break;

                case 1:
                    DialogueStep     = 2;
                    Main.npcChatText = "*Can't you feel? The grudge, the horrors, the despair... All those souls...*";
                    break;

                case 2:
                    DialogueStep     = 3;
                    Main.npcChatText = "*I can understand that... You're not like me anyways...*";
                    break;

                case 3:
                    DialogueStep     = 4;
                    Main.npcChatText = "*I'm sorry... But leave me be for a while... I need to process all this..*";
                    FinishedTalking  = true;
                    EncounterTimes++;
                    break;
                }
                break;

            case 3:
                switch (DialogueStep)
                {
                case 0:
                    DialogueStep     = 1;
                    Main.npcChatText = "*At ease, Terrarian, It isn't particularly about you, beside It will involve you.*";
                    break;

                case 1:
                    DialogueStep     = 2;
                    Main.npcChatText = "*I spoke to the ones who sent me here about the dungeon, and they appointed me to act in this entire world.*";
                    break;

                case 2:
                    DialogueStep     = 3;
                    Main.npcChatText = "*Yes. They want to avoid more souls from being twisted, by whatever caused that in the dungeon, so I will be making delivery of souls of the deceased from here, includding Terrarians.*";
                    break;

                case 3:
                    DialogueStep     = 4;
                    Main.npcChatText = "*Don't worry, I will not harm anyone, at least unless something threatens to attack me.*";
                    break;

                case 4:
                    EncounterTimes++;
                    DialogueStep     = 5;
                    Main.npcChatText = "*I guess we will have enough time to know each other. You can call me Liebre, which was my name. I am now Terra Realm's reaper.*";
                    PlayerMod.AddPlayerGuardian(Main.LocalPlayer, GuardianBase.Liebre);
                    WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianBase.Liebre);
                    NpcMod.AddGuardianMet(GuardianBase.Liebre);
                    return;
                }
                break;
            }
        }
        public static void CilleSpawningScripts()
        {
            const byte CheckDelayTime = 150;
            const int  CilleID        = GuardianBase.Cille;

            CilleSpawnCheckDelay++;
            if (CilleSpawnCheckDelay < CheckDelayTime)
            {
                return;
            }
            CilleSpawnCheckDelay -= CheckDelayTime;
            if (Main.rand.Next(7) > 0)
            {
                return;
            }
            if (!NpcMod.HasMetGuardian(CilleID) || NPC.AnyNPCs(ModContent.NPCType <Npcs.CilleNPC>()))
            {
                return;
            }
            if (NpcMod.HasGuardianNPC(CilleID))
            {
                TerraGuardian tg = NpcMod.GetGuardianNPCCharacter(CilleID);
                if (tg.FriendshipLevel >= tg.Base.MoveInLevel)
                {
                    return;
                }
                for (int i = 0; i < 255; i++)
                {
                    if (Main.player[i].active && Math.Abs(tg.Position.X - Main.player[i].Center.X) < 2000 && Math.Abs(tg.Position.Y - Main.player[i].Center.Y) < 1600)
                    {
                        return;
                    }
                }
            }
            if (CilleShelterX == -1 && CilleShelterY == -1)
            {
                int Left = (int)(Main.leftWorld * (1f / 16) + 130), Right = (int)(Main.rightWorld * (1f / 16) - 130);
                int Top = (int)(Main.worldSurface * 0.35f), Bottom = (int)(Main.worldSurface);
                int PositionX = Main.rand.Next(Left, Right),
                    PositionY = Main.rand.Next(Top, Bottom);
                Tile tile     = Framing.GetTileSafely(PositionX, PositionY);
                if (tile == null || (tile.active() && Main.tileSolid[tile.type]) || tile.wall > 0)
                {
                    return;
                }
                {
                    byte Counter = 0;
                    while (!tile.active() || !Main.tileSolid[tile.type])
                    {
                        PositionY++;
                        tile = Framing.GetTileSafely(PositionX, PositionY);
                        if (Counter++ >= 250)
                        {
                            return;
                        }
                    }
                }
                tile = Framing.GetTileSafely(PositionX, PositionY);
                switch (tile.type)
                {
                case Terraria.ID.TileID.CorruptGrass:
                case Terraria.ID.TileID.Ebonstone:
                case Terraria.ID.TileID.Ebonsand:
                case Terraria.ID.TileID.FleshGrass:
                case Terraria.ID.TileID.Crimtane:
                case Terraria.ID.TileID.Crimsand:
                case Terraria.ID.TileID.LeafBlock:
                case Terraria.ID.TileID.LivingWood:
                case Terraria.ID.TileID.BlueDungeonBrick:
                case Terraria.ID.TileID.GreenDungeonBrick:
                case Terraria.ID.TileID.PinkDungeonBrick:
                    return;
                }
                PositionY--;
                tile = Framing.GetTileSafely(PositionX, PositionY);
                if (tile.wall > 0)
                {
                    return;
                }
                for (int i = 0; i < 255; i++)
                {
                    if (Main.player[i].active)
                    {
                        if (Math.Abs(Main.player[i].Center.X - PositionX * 16) < 1000 && Math.Abs(Main.player[i].Center.Y - PositionY * 16) < 1000)
                        {
                            return;
                        }
                    }
                    if (i < 200 && Main.npc[i].active)
                    {
                        if (Math.Abs(Main.npc[i].Center.X - PositionX * 16) < 1000 && Math.Abs(Main.npc[i].Center.Y - PositionY * 16) < 800)
                        {
                            return;
                        }
                    }
                }
                int HouseBottom;
                if (!TryPlacingCilleHouse(PositionX, PositionY, out HouseBottom))
                {
                    return;
                }
                CilleShelterX = PositionX;
                CilleShelterY = HouseBottom;

                /*if (!NpcMod.HasGuardianNPC(CilleID))
                 * {
                 *  NpcMod.SpawnGuardianNPC(PositionX * 16, PositionY * 16, CilleID);
                 * }
                 * else
                 * {
                 *  TerraGuardian Cille = NpcMod.GetGuardianNPCCharacter(CilleID);
                 *  Cille.Position.X = PositionX * 16;
                 *  Cille.Position.Y = PositionY * 16;
                 *  Cille.SetFallStart();
                 * }*/
                WorldMod.TrySpawningOrMovingGuardianNPC(CilleID, "", CilleShelterX, CilleShelterY, true, true);
            }
            else
            {
                if (!NpcMod.HasGuardianNPC(CilleID))
                {
                    if (!WorldMod.CanGuardianNPCSpawnInTheWorld(CilleID))
                    {
                        if (Main.dayTime && Main.moonPhase != 4)
                        {
                            List <WorldMod.GuardianTownNpcState> TownNpcsAtThisHouse = WorldMod.GetGuardianLivingHere(CilleShelterX, CilleShelterY);
                            foreach (WorldMod.GuardianTownNpcState tg in TownNpcsAtThisHouse)
                            {
                                if (!tg.CharID.IsSameID(CilleID))
                                {
                                    tg.Homeless = true;
                                    tg.HomeX    = tg.HomeY = -1;
                                }
                            }
                            if (WorldMod.TrySpawningOrMovingGuardianNPC(CilleID, "", CilleShelterX, CilleShelterY, true, true))
                            {
                                //NpcMod.SpawnGuardianNPC(CilleShelterX * 16, CilleShelterY * 16, CilleID);
                            }
                            else
                            {
                                CilleShelterX = CilleShelterY = -1;
                            }
                        }
                    }
                }
                else
                {
                    /*if (!Main.dayTime && !WorldMod.CanGuardianNPCSpawnInTheWorld(CilleID))
                     * {
                     *  WorldMod.GuardianTownNpcState townnpc = CilleGuardian.GetTownNpcInfo;
                     *  if (townnpc != null)
                     *  {
                     *      townnpc.Homeless = true;
                     *  }
                     * }*/
                }
            }
        }
Example #29
0
 public override void PlaceInWorld(int i, int j, Item item)
 {
     WorldMod.UpdateTileStateOnGuardianHouses(i, j, true);
 }
Example #30
0
        public override void AI()
        {
            if (DialogueStep > 0)
            {
                if (!Main.player[npc.target].active)
                {
                    SayMessage("*And " + (Main.player[npc.target].Male ? "he's" : "she's") + " gone. Oh well, until we meet again.*");
                    DialogueStep = 0;
                }
                else if (Main.player[npc.target].dead)
                {
                    SayMessage("*That was really horrible!*");
                    if (DialogueStep >= 5)
                    {
                        DialogueStep = 5;
                    }
                    else
                    {
                        DialogueStep = 0;
                    }
                }
                else if (npc.velocity.X == 0 && npc.velocity.Y == 0)
                {
                    if (DialogueStep >= 5)
                    {
                        if (!PlayerMovedAway)
                        {
                            if (Math.Abs(Main.player[npc.target].Center.X - npc.Center.X) >= 400 ||
                                Math.Abs(Main.player[npc.target].Center.Y - npc.Center.Y) >= 300)
                            {
                                PlayerMovedAway = true;
                                SayMessage("*And " + (Main.player[npc.target].Male ? "he" : "she") + " went away.*");
                                DialogueStep = 5;
                            }
                        }
                        else
                        {
                            npc.TargetClosest(false);
                            if (Math.Abs(Main.player[npc.target].Center.X - npc.Center.X) < 200 &&
                                Math.Abs(Main.player[npc.target].Center.Y - npc.Center.Y) < 100)
                            {
                                PlayerMovedAway = false;
                                SayMessage("*Returned? Now you can try jumping " + (25 - JumpTimes) + ", right?*");
                                DialogueStep = 6;
                            }
                        }
                    }
                    if (Main.player[npc.target].Center.X < npc.Center.X)
                    {
                        npc.direction = -1;
                    }
                    else
                    {
                        npc.direction = 1;
                    }
                }
            }
            switch (DialogueStep)
            {
            case 0:     //Looking for Player
                npc.TargetClosest(false);
                Idle = true;
                Rectangle SeekingRectangle = new Rectangle((int)npc.Center.X, (int)npc.Center.Y, 400, 300);
                if (npc.direction < 0)
                {
                    SeekingRectangle.X -= SeekingRectangle.Width;
                }
                SeekingRectangle.Y -= (int)(SeekingRectangle.Height * 0.5f);
                if (Main.player[npc.target].active && !Main.player[npc.target].dead && Main.player[npc.target].getRect().Intersects(SeekingRectangle))
                {
                    Idle         = false;
                    DialogueStep = 1;
                    SayMessage("*Hey, you!*", true);
                    PlayerHasMiguelRecruited = PlayerMod.PlayerHasGuardian(Main.player[npc.target], GuardianID);
                }
                break;

            case 1:
            {
                if (MessageTime <= 0)
                {
                    if (PlayerHasMiguelRecruited)
                    {
                        SayMessage("*Don't you go thinking that just because you changed worlds, you'll slack on the exercises!*", true);
                    }
                    else
                    {
                        SayMessage("*Are you carrying many loots in that pouch of yours?*", true);
                    }
                    DialogueStep = 2;
                }
            }
            break;

            case 2:
            {
                if (MessageTime <= 0)
                {
                    if (PlayerHasMiguelRecruited)
                    {
                        SayMessage("*I will be here to give you a new batch of exercises.*", true);
                        NpcMod.AddGuardianMet(GuardianID, GuardianModID);
                        WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
                    }
                    else
                    {
                        SayMessage("*Or is that because you haven't been doing abdominal exercises?*", true);
                    }
                    DialogueStep = 3;
                }
            }
            break;

            case 3:
            {
                if (MessageTime <= 0)
                {
                    SayMessage("*Hahahaha.*");
                    DialogueStep = 4;
                }
            }
            break;

            case 4:
            {
                if (MessageTime <= 0)
                {
                    SayMessage("*Don't worry, though, I will help you take carry of that belly.*", true);
                    DialogueStep = 5;
                }
            }
            break;

            case 5:
            {
                if (!PlayerMovedAway && MessageTime <= 0 && Main.player[npc.target].talkNPC != npc.whoAmI)
                {
                    SayMessage("*Why don't you try jumping 25 times.*", true);
                    DialogueStep = 6;
                }
            }
            break;

            case 6:
            {
                if (!PlayerMovedAway && Main.player[npc.target].justJumped)
                {
                    JumpTimes++;
                    if (JumpTimes >= 25)
                    {
                        SayMessage("*Nice job. As you can see, you got a little more fit for jumping all those times.*");
                        Main.player[npc.target].AddBuff(Terraria.ModLoader.ModContent.BuffType <Buffs.Fit>(), 5 * 60 * 60);
                        DialogueStep++;
                    }
                    else
                    {
                        if (JumpTimes % 5 == 0)
                        {
                            if (JumpTimes > 10)
                            {
                                SayMessage("*" + JumpTimes + "! Good job!*");
                            }
                            else
                            {
                                SayMessage("*" + JumpTimes + "! Nice!*");
                            }
                        }
                        else
                        {
                            SayMessage("*" + JumpTimes + "!*");
                        }
                    }
                }
            }
            break;

            case 7:
            {
                if (MessageTime <= 0)
                {
                    SayMessage("*Don't worry, by the way. The great " + Base.Name + " will handle your training from now on.*");
                    DialogueStep++;
                }
            }
            break;

            case 8:
            {
                if (MessageTime <= 0)
                {
                    SayMessage("*And don't you dare to deny my training.*");
                    PlayerMod.AddPlayerGuardian(Main.player[npc.target], GuardianID, GuardianModID);
                    NpcMod.AddGuardianMet(GuardianID, GuardianModID);
                    WorldMod.TurnNpcIntoGuardianTownNpc(npc, GuardianID, GuardianModID);
                    PlayerMod.GetPlayerGuardian(Main.player[npc.target], GuardianID, GuardianModID).IncreaseFriendshipProgress(1);
                    return;
                }
            }
            break;
            }
            base.AI();
        }