Beispiel #1
0
        // SpawnBoss(player, mod.NPCType("MyBoss"), true, 0, 0, "DerpyBoi 2", false);
        public static void SpawnBoss(Player player, int bossType, Vector2 Pos = default, string name = "", bool seen = true)
        {
            Vector2 npcCenter = Pos + new Vector2(MathHelper.Lerp(500f, 800f, (float)Main.rand.NextDouble()) * Main.rand.Next(2) == 0 ? -1 : 1, -800f);

            for (int a = 0; a < 8; a++)
            {
                Dust.NewDust(npcCenter, 152, 114, ModContent.DustType <Feather>(), Main.rand.Next(-1, 2), 1, 0);
            }

            if (Main.netMode != 1)
            {
                if (NPC.AnyNPCs(bossType))
                {
                    return;
                }

                int npcID = NPC.NewNPC((int)npcCenter.X, (int)npcCenter.Y, bossType);
                Main.npc[npcID].Center    = npcCenter;
                Main.npc[npcID].netUpdate = true;

                ((Athena)Main.npc[npcID].modNPC).Seen = seen;

                if (Main.netMode == NetmodeID.SinglePlayer)
                {
                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        BaseUtility.Chat(Language.GetTextValue("Announcement.HasAwoken", name), 175, 75, 255, false);
                    }
                }
                else if (Main.netMode == NetmodeID.Server)
                {
                    NetMessage.BroadcastChatMessage(
                        NetworkText.FromKey("Announcement.HasAwoken", new object[] { NetworkText.FromLiteral(name) }),
                        new Color(175, 75, 255)
                        );
                }
            }
            else
            {
                //I have no idea how to convert this to the standard system so im gonna post this method too lol
                AANet.SendNetMessage(AANet.SummonNPCFromClient, (byte)player.whoAmI, (short)bossType, true, (int)npcCenter.X, (int)npcCenter.Y, name, false);
            }
        }
Beispiel #2
0
 public static void SpawnBoss(Player player, int bossType, bool spawnMessage = true, Vector2 npcCenter = default, string overrideDisplayName = "", bool namePlural = false)
 {
     if (npcCenter == default)
     {
         npcCenter = player.Center;
     }
     if (Main.netMode != 1)
     {
         if (NPC.AnyNPCs(bossType))
         {
             return;
         }
         int npcID = NPC.NewNPC((int)npcCenter.X, (int)npcCenter.Y, bossType, 0);
         Main.npc[npcID].ai[3]      = -1;
         Main.npc[npcID].Center     = npcCenter;
         Main.npc[npcID].netUpdate2 = true;
         if (spawnMessage)
         {
             string npcName = !string.IsNullOrEmpty(Main.npc[npcID].GivenName) ? Main.npc[npcID].GivenName : overrideDisplayName;
             if ((npcName == null || npcName.Equals("")) && Main.npc[npcID].modNPC != null)
             {
                 npcName = Main.npc[npcID].modNPC.DisplayName.GetDefault();
             }
             if (namePlural)
             {
                 if (Main.netMode == NetmodeID.SinglePlayer)
                 {
                     if (Main.netMode != 1)
                     {
                         BaseUtility.Chat(npcName + Language.GetTextValue("Mods.AAMod.Common.BosshasAwoken"), 175, 75, 255, false);
                     }
                 }
                 else
                 if (Main.netMode == NetmodeID.Server)
                 {
                     NetMessage.BroadcastChatMessage(NetworkText.FromLiteral(npcName + Language.GetTextValue("Mods.AAMod.Common.BosshasAwoken")), new Color(175, 75, 255), -1);
                 }
             }
             else
             {
                 if (Main.netMode == NetmodeID.SinglePlayer)
                 {
                     if (Main.netMode != 1)
                     {
                         BaseUtility.Chat(Language.GetTextValue("Announcement.HasAwoken", npcName), 175, 75, 255, false);
                     }
                 }
                 else
                 if (Main.netMode == NetmodeID.Server)
                 {
                     NetMessage.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", new object[]
                     {
                         NetworkText.FromLiteral(npcName)
                     }), new Color(175, 75, 255), -1);
                 }
             }
         }
     }
     else
     {
         AANet.SendNetMessage(AANet.SummonNPCFromClient, (byte)player.whoAmI, (short)bossType, spawnMessage, (int)npcCenter.X, (int)npcCenter.Y, overrideDisplayName, namePlural);
     }
 }
Beispiel #3
0
        public override void OnChatButtonClicked(bool firstButton, ref bool shop)
        {
            Player   player = Main.LocalPlayer;
            AAPlayer p      = player.GetModPlayer <AAPlayer>();

            if (firstButton)
            {
                shop = true;
            }

            if (!firstButton)
            {
                Main.PlaySound(12, -1, -1, 1);

                int Mushman = NPC.FindFirstNPC(mod.NPCType("Mushman"));

                int Item1  = player.FindItem(ModContent.ItemType <Items.Materials.TerraShard>());
                int Item2  = player.FindItem(ModContent.ItemType <Items.Materials.DragonScale>());
                int Item3  = player.FindItem(ModContent.ItemType <Items.Materials.MirePod>());
                int Item4  = player.FindItem(ItemID.RottenChunk);
                int Item5  = player.FindItem(ItemID.Vertebrae);
                int Item6  = player.FindItem(ItemID.PixieDust);
                int Item7  = player.FindItem(ModContent.ItemType <Items.Materials.DoomiteScrap>());
                int Item8  = player.FindItem(ItemID.JungleSpores);
                int Item9  = player.FindItem(ModContent.ItemType <Items.Boss.MushroomMonarch.Mushium>());
                int Item10 = player.FindItem(ModContent.ItemType <Items.Boss.MushroomMonarch.GlowingMushium>());
                int Item11 = player.FindItem(ItemID.Stinger);
                int Item12 = player.FindItem(ItemID.IceMachine);
                int Item13 = player.FindItem(ItemID.Bunny);

                if (Item1 >= 0 && AAWorld.squid1 < 5) //Item 1: 3 Blueberries
                {
                    Main.npcChatCornerItem = ModContent.ItemType <Items.Materials.TerraShard>();
                    player.inventory[Item1].stack--;
                    if (player.inventory[Item1].stack <= 0)
                    {
                        player.inventory[Item1] = new Item();
                    }
                    if (AAWorld.squid1 == 4)
                    {
                        Main.npcChatText = Lang.TownNPCLovecraftian("PurityFlaskChat");
                        player.QuickSpawnItem(mod.ItemType("PurityFlask"), 5);
                        Main.npcChatCornerItem = mod.ItemType("PurityFlask");
                    }

                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        AANet.SendNetMessage(AANet.UpdateLovecraftianCount, (byte)1);
                    }
                    AAWorld.squid1++;
                    Main.PlaySound(24, -1, -1, 1);
                }
                else if (Item2 >= 0 && AAWorld.squid2 < 5) //Item 2: 3 Teal Mushrooms
                {
                    Main.npcChatCornerItem = ModContent.ItemType <Items.Materials.DragonScale>();
                    player.inventory[Item2].stack--;
                    if (player.inventory[Item2].stack <= 0)
                    {
                        player.inventory[Item2] = new Item();
                    }
                    if (AAWorld.squid2 == 4)
                    {
                        Main.npcChatText = Lang.TownNPCLovecraftian("AshJarChat");
                        player.QuickSpawnItem(mod.ItemType("AshJar"), 5);
                        Main.npcChatCornerItem = mod.ItemType("AshJar");
                    }

                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        AANet.SendNetMessage(AANet.UpdateLovecraftianCount, (byte)2);
                    }
                    AAWorld.squid2++;
                    Main.PlaySound(24, -1, -1, 1);
                }
                else if (Item3 >= 0 && AAWorld.squid3 < 5)
                {
                    Main.npcChatCornerItem = ModContent.ItemType <Items.Materials.MirePod>();
                    player.inventory[Item3].stack--;
                    if (player.inventory[Item3].stack <= 0)
                    {
                        player.inventory[Item3] = new Item();
                    }
                    if (AAWorld.squid3 == 4)
                    {
                        Main.npcChatText = Lang.TownNPCLovecraftian("DarkwaterFlaskChat");
                        player.QuickSpawnItem(mod.ItemType("DarkwaterFlask"), 5);
                        Main.npcChatCornerItem = mod.ItemType("DarkwaterFlask");
                    }

                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        AANet.SendNetMessage(AANet.UpdateLovecraftianCount, (byte)3);
                    }
                    AAWorld.squid3++;
                    Main.PlaySound(24, -1, -1, 1);
                }
                else if (Item4 >= 0 && AAWorld.squid4 < 5)
                {
                    Main.npcChatCornerItem = ItemID.RottenChunk;
                    player.inventory[Item4].stack--;
                    if (player.inventory[Item4].stack <= 0)
                    {
                        player.inventory[Item4] = new Item();
                    }
                    if (AAWorld.squid4 == 4)
                    {
                        Main.npcChatText = Lang.TownNPCLovecraftian("CorruptionFlaskChat");
                        player.QuickSpawnItem(mod.ItemType("CorruptionFlask"), 5);
                        Main.npcChatCornerItem = mod.ItemType("CorruptionFlask");
                    }

                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        AANet.SendNetMessage(AANet.UpdateLovecraftianCount, (byte)4);
                    }
                    AAWorld.squid4++;
                    Main.PlaySound(24, -1, -1, 1);
                }
                else if (Item5 >= 0 && AAWorld.squid5 < 5)
                {
                    Main.npcChatCornerItem = ItemID.Vertebrae;
                    player.inventory[Item5].stack--;
                    if (player.inventory[Item5].stack <= 0)
                    {
                        player.inventory[Item5] = new Item();
                    }
                    if (AAWorld.squid5 == 4)
                    {
                        Main.npcChatText = Lang.TownNPCLovecraftian("CrimsonFlaskChat");
                        player.QuickSpawnItem(mod.ItemType("CrimsonFlask"), 5);
                        Main.npcChatCornerItem = mod.ItemType("CrimsonFlask");
                    }
                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        AANet.SendNetMessage(AANet.UpdateLovecraftianCount, (byte)5);
                    }
                    AAWorld.squid5++;
                    Main.PlaySound(24, -1, -1, 1);
                }
                else if (Item6 >= 0 && AAWorld.squid6 < 5)
                {
                    Main.npcChatCornerItem = ItemID.PixieDust;
                    player.inventory[Item6].stack--;
                    if (player.inventory[Item6].stack <= 0)
                    {
                        player.inventory[Item6] = new Item();
                    }
                    if (AAWorld.squid6 == 4)
                    {
                        Main.npcChatText = Lang.TownNPCLovecraftian("MeanGreenStewChat");
                        player.QuickSpawnItem(mod.ItemType("MeanGreenStew"), 5);
                        Main.npcChatCornerItem = mod.ItemType("MeanGreenStew");
                    }
                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        AANet.SendNetMessage(AANet.UpdateLovecraftianCount, (byte)6);
                    }
                    AAWorld.squid6++;
                    Main.PlaySound(24, -1, -1, 1);
                }
                else if (Item7 >= 0 && AAWorld.squid7 < 5)
                {
                    Main.npcChatCornerItem = ModContent.ItemType <Items.Materials.DoomiteScrap>();
                    player.inventory[Item7].stack--;
                    if (player.inventory[Item7].stack <= 0)
                    {
                        player.inventory[Item7] = new Item();
                    }
                    if (AAWorld.squid7 == 4)
                    {
                        Main.npcChatText = Lang.TownNPCLovecraftian("VoidFlaskChat");
                        player.QuickSpawnItem(mod.ItemType("VoidFlask"), 5);
                        Main.npcChatCornerItem = mod.ItemType("Z");
                    }
                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        AANet.SendNetMessage(AANet.UpdateLovecraftianCount, (byte)7);
                    }
                    AAWorld.squid7++;
                    Main.PlaySound(24, -1, -1, 1);
                }
                else if (Item8 >= 0 && AAWorld.squid8 < 5)
                {
                    Main.npcChatCornerItem = ItemID.JungleSpores;
                    player.inventory[Item8].stack--;
                    if (player.inventory[Item8].stack <= 0)
                    {
                        player.inventory[Item8] = new Item();
                    }
                    if (AAWorld.squid8 == 4)
                    {
                        Main.npcChatText = Lang.TownNPCLovecraftian("FungicideChat");
                        player.QuickSpawnItem(mod.ItemType("Fungicide"), 5);
                        Main.npcChatCornerItem = mod.ItemType("Fungicide");
                    }
                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        AANet.SendNetMessage(AANet.UpdateLovecraftianCount, (byte)8);
                    }
                    AAWorld.squid8++;
                    Main.PlaySound(24, -1, -1, 1);
                }
                else if (Item9 >= 0 && AAWorld.squid9 < 5 && Mushman >= 0)
                {
                    Main.npcChatCornerItem = ModContent.ItemType <Items.Boss.MushroomMonarch.Mushium>();
                    player.inventory[Item9].stack--;
                    if (player.inventory[Item9].stack <= 0)
                    {
                        player.inventory[Item9] = new Item();
                    }
                    if (AAWorld.squid9 == 4)
                    {
                        Main.npcChatText = Lang.TownNPCLovecraftian("SporeSacChat1") + Main.npc[Mushman].GivenName + Lang.TownNPCLovecraftian("SporeSacChat2");
                        player.QuickSpawnItem(mod.ItemType("SporeSac"), 5);
                        Main.npcChatCornerItem = mod.ItemType("SporeSac");
                    }
                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        AANet.SendNetMessage(AANet.UpdateLovecraftianCount, (byte)9);
                    }
                    AAWorld.squid9++;
                    Main.PlaySound(24, -1, -1, 1);
                }
                else if (Item10 >= 0 && AAWorld.squid10 < 5 && Mushman >= 0)
                {
                    Main.npcChatCornerItem = ModContent.ItemType <Items.Boss.MushroomMonarch.GlowingMushium>();
                    player.inventory[Item10].stack--;
                    if (player.inventory[Item10].stack <= 0)
                    {
                        player.inventory[Item10] = new Item();
                    }
                    if (AAWorld.squid10 == 4)
                    {
                        Main.npcChatText = Lang.TownNPCLovecraftian("GlowingSporeSacChat1") + Main.npc[Mushman].GivenName + Lang.TownNPCLovecraftian("GlowingSporeSacChat2");
                        player.QuickSpawnItem(mod.ItemType("GlowingSporeSac"), 5);
                        Main.npcChatCornerItem = mod.ItemType("GlowingSporeSac");
                    }
                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        AANet.SendNetMessage(AANet.UpdateLovecraftianCount, (byte)10);
                    }
                    AAWorld.squid10++;
                    Main.PlaySound(24, -1, -1, 1);
                }
                else if (Item11 >= 0 && AAWorld.squid11 < 5)
                {
                    Main.npcChatCornerItem = ItemID.Stinger;
                    player.inventory[Item11].stack--;
                    if (player.inventory[Item11].stack <= 0)
                    {
                        player.inventory[Item11] = new Item();
                    }
                    if (AAWorld.squid11 == 4)
                    {
                        Main.npcChatText = Lang.TownNPCLovecraftian("JungleFlaskChat");
                        player.QuickSpawnItem(mod.ItemType("JungleFlask"), 5);
                        Main.npcChatCornerItem = mod.ItemType("JungleFlask");
                    }
                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        AANet.SendNetMessage(AANet.UpdateLovecraftianCount, (byte)11);
                    }
                    AAWorld.squid11++;
                    Main.PlaySound(24, -1, -1, 1);
                }
                else if (Item12 >= 0 && AAWorld.squid12 < 1)
                {
                    Main.npcChatCornerItem = ItemID.IceMachine;
                    player.inventory[Item12].stack--;
                    if (player.inventory[Item12].stack <= 0)
                    {
                        player.inventory[Item12] = new Item();
                    }
                    if (AAWorld.squid12 == 0)
                    {
                        Main.npcChatText = Lang.TownNPCLovecraftian("IceFlaskChat");
                        player.QuickSpawnItem(mod.ItemType("IceFlask"), 3);
                        player.QuickSpawnItem(mod.ItemType("IcemeltFlask"), 3);
                        Main.npcChatCornerItem = mod.ItemType("IceFlask");
                    }
                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        AANet.SendNetMessage(AANet.UpdateLovecraftianCount, (byte)12);
                    }
                    AAWorld.squid12++;
                    Main.PlaySound(24, -1, -1, 1);
                }
                else if (Item13 >= 0 && AAWorld.squid13 < 5)
                {
                    Main.npcChatCornerItem = ItemID.Bunny;
                    player.inventory[Item13].stack--;
                    if (player.inventory[Item13].stack <= 0)
                    {
                        player.inventory[Item13] = new Item();
                    }
                    if (AAWorld.squid13 == 4)
                    {
                        Main.npcChatText = Lang.TownNPCLovecraftian("ForestFlaskChat");
                        player.QuickSpawnItem(mod.ItemType("ForestFlask"), 5);
                        Main.npcChatCornerItem = mod.ItemType("ForestFlask");
                    }
                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        AANet.SendNetMessage(AANet.UpdateLovecraftianCount, (byte)13);
                    }
                    AAWorld.squid13++;
                    Main.PlaySound(24, -1, -1, 1);
                }
                else
                {
                    if (!BaseMod.BasePlayer.HasItem(player, ModContent.ItemType <Items.Flasks.SquidList>()))
                    {
                        Main.npcChatText = Lang.TownNPCLovecraftian("SquidListChat");
                        int itemID = Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, mod.ItemType("SquidList"), 1, false, 0, false, false);
                        if (Main.netMode == NetmodeID.MultiplayerClient)
                        {
                            NetMessage.SendData(21, -1, -1, null, itemID, 1f, 0f, 0f, 0, 0, 0);
                        }
                    }
                    else
                    {
                        Main.npcChatText = Lang.TownNPCLovecraftian("NothingChat");
                    }
                    Main.npcChatCornerItem = 0;
                    Main.PlaySound(12, -1, -1, 1);
                }
            }
        }