Exemplo n.º 1
0
        public override bool UseItem(Player player)
        {
            #region SpiritBiome
            Main.NewText("The Spirits spread through the Land...", Color.Orange.R, Color.Orange.G, Color.Orange.B);
            Random rand = new Random();
            int    XTILE;
            if (Terraria.Main.dungeonX > Main.maxTilesX / 2)         //rightside dungeon
            {
                XTILE = WorldGen.genRand.Next(Main.maxTilesX / 2, Main.maxTilesX - 500);
            }
            else         //leftside dungeon
            {
                XTILE = WorldGen.genRand.Next(75, Main.maxTilesX / 2);
            }
            int xAxis     = XTILE;
            int xAxisMid  = xAxis + 70;
            int xAxisEdge = xAxis + 380;
            int yAxis     = 0;
            for (int y = 0; y < Main.maxTilesY; y++)
            {
                yAxis++;
                xAxis = XTILE;

                for (int i = 0; i < 450; i++)
                {
                    xAxis++;
                    #region islands
                    if (Main.rand.Next(21000) == 1)
                    {
                        WorldMethods.Island(xAxis, Main.rand.Next(100, 275), Main.rand.Next(10, 16), (float)(Main.rand.Next(11, 25) / 10), (ushort)mod.TileType("SpiritGrass"));
                    }
                    #endregion

                    if (Main.tile[xAxis, yAxis] != null)
                    {
                        if (Main.tile[xAxis, yAxis].active())
                        {
                            int[] TileArray = { 0 };
                            if (TileArray.Contains(Main.tile[xAxis, yAxis].type))
                            {
                                if (Main.tile[xAxis, yAxis + 1] == null)
                                {
                                    if (Main.rand.Next(0, 50) == 1)
                                    {
                                        WillGenn = 0;
                                        if (xAxis < xAxisMid - 1)
                                        {
                                            Meme     = xAxisMid - xAxis;
                                            WillGenn = Main.rand.Next(Meme);
                                        }
                                        if (xAxis > xAxisEdge + 1)
                                        {
                                            Meme     = xAxis - xAxisEdge;
                                            WillGenn = Main.rand.Next(Meme);
                                        }
                                        if (WillGenn < 10)
                                        {
                                            Main.tile[xAxis, yAxis].type = (ushort)mod.TileType("SpiritDirt");
                                        }
                                    }
                                }
                                else
                                {
                                    WillGenn = 0;
                                    if (xAxis < xAxisMid - 1)
                                    {
                                        Meme     = xAxisMid - xAxis;
                                        WillGenn = Main.rand.Next(Meme);
                                    }
                                    if (xAxis > xAxisEdge + 1)
                                    {
                                        Meme     = xAxis - xAxisEdge;
                                        WillGenn = Main.rand.Next(Meme);
                                    }
                                    if (WillGenn < 10)
                                    {
                                        Main.tile[xAxis, yAxis].type = (ushort)mod.TileType("SpiritDirt");
                                    }
                                }
                            }
                            int[] TileArray89 = { 3, 24, 110, 113, 115, 201, 205, 52, 62, 32, 165 };
                            if (TileArray89.Contains(Main.tile[xAxis, yAxis].type))
                            {
                                if (Main.tile[xAxis, yAxis + 1] == null)
                                {
                                    if (rand.Next(0, 50) == 1)
                                    {
                                        WillGenn = 0;
                                        if (xAxis < xAxisMid - 1)
                                        {
                                            Meme     = xAxisMid - xAxis;
                                            WillGenn = Main.rand.Next(Meme);
                                        }
                                        if (xAxis > xAxisEdge + 1)
                                        {
                                            Meme     = xAxis - xAxisEdge;
                                            WillGenn = Main.rand.Next(Meme);
                                        }
                                        if (WillGenn < 18)
                                        {
                                            Main.tile[xAxis, yAxis].active(false);
                                        }
                                    }
                                }
                                else
                                {
                                    WillGenn = 0;
                                    if (xAxis < xAxisMid - 1)
                                    {
                                        Meme     = xAxisMid - xAxis;
                                        WillGenn = Main.rand.Next(Meme);
                                    }
                                    if (xAxis > xAxisEdge + 1)
                                    {
                                        Meme     = xAxis - xAxisEdge;
                                        WillGenn = Main.rand.Next(Meme);
                                    }
                                    if (WillGenn < 18)
                                    {
                                        Main.tile[xAxis, yAxis].active(false);
                                    }
                                }
                            }
                            int[] TileArray1 = { 2, 23, 109, 199 };
                            if (TileArray1.Contains(Main.tile[xAxis, yAxis].type))
                            {
                                if (Main.tile[xAxis, yAxis + 1] == null)
                                {
                                    if (rand.Next(0, 50) == 1)
                                    {
                                        WillGenn = 0;
                                        if (xAxis < xAxisMid - 1)
                                        {
                                            Meme     = xAxisMid - xAxis;
                                            WillGenn = Main.rand.Next(Meme);
                                        }
                                        if (xAxis > xAxisEdge + 1)
                                        {
                                            Meme     = xAxis - xAxisEdge;
                                            WillGenn = Main.rand.Next(Meme);
                                        }
                                        if (WillGenn < 18)
                                        {
                                            Main.tile[xAxis, yAxis].type = (ushort)mod.TileType("SpiritGrass");
                                        }
                                    }
                                }
                                else
                                {
                                    WillGenn = 0;
                                    if (xAxis < xAxisMid - 1)
                                    {
                                        Meme     = xAxisMid - xAxis;
                                        WillGenn = Main.rand.Next(Meme);
                                    }
                                    if (xAxis > xAxisEdge + 1)
                                    {
                                        Meme     = xAxis - xAxisEdge;
                                        WillGenn = Main.rand.Next(Meme);
                                    }
                                    if (WillGenn < 18)
                                    {
                                        Main.tile[xAxis, yAxis].type = (ushort)mod.TileType("SpiritGrass");
                                    }
                                }
                            }

                            int[] TileArray2 = { 1, 25, 117, 203 };
                            if (TileArray2.Contains(Main.tile[xAxis, yAxis].type))
                            {
                                if (Main.tile[xAxis, yAxis + 1] == null)
                                {
                                    if (rand.Next(0, 50) == 1)
                                    {
                                        WillGenn = 0;
                                        if (xAxis < xAxisMid - 1)
                                        {
                                            Meme     = xAxisMid - xAxis;
                                            WillGenn = Main.rand.Next(Meme);
                                        }
                                        if (xAxis > xAxisEdge + 1)
                                        {
                                            Meme     = xAxis - xAxisEdge;
                                            WillGenn = Main.rand.Next(Meme);
                                        }
                                        if (WillGenn < 18)
                                        {
                                            Main.tile[xAxis, yAxis].type = (ushort)mod.TileType("SpiritStone");
                                        }
                                    }
                                }
                                else
                                {
                                    WillGenn = 0;
                                    if (xAxis < xAxisMid - 1)
                                    {
                                        Meme     = xAxisMid - xAxis;
                                        WillGenn = Main.rand.Next(Meme);
                                    }
                                    if (xAxis > xAxisEdge + 1)
                                    {
                                        Meme     = xAxis - xAxisEdge;
                                        WillGenn = Main.rand.Next(Meme);
                                    }
                                    if (WillGenn < 18)
                                    {
                                        Main.tile[xAxis, yAxis].type = (ushort)mod.TileType("SpiritStone");
                                    }
                                }
                            }

                            int[] TileArray3 = { 53, 116, 112, 234 };
                            if (TileArray3.Contains(Main.tile[xAxis, yAxis].type))
                            {
                                if (Main.tile[xAxis, yAxis + 1] == null)
                                {
                                    if (rand.Next(0, 50) == 1)
                                    {
                                        WillGenn = 0;
                                        if (xAxis < xAxisMid - 1)
                                        {
                                            Meme     = xAxisMid - xAxis;
                                            WillGenn = Main.rand.Next(Meme);
                                        }
                                        if (xAxis > xAxisEdge + 1)
                                        {
                                            Meme     = xAxis - xAxisEdge;
                                            WillGenn = Main.rand.Next(Meme);
                                        }
                                        if (WillGenn < 18)
                                        {
                                            Main.tile[xAxis, yAxis].type = (ushort)mod.TileType("Spiritsand");
                                        }
                                    }
                                }
                                else
                                {
                                    WillGenn = 0;
                                    if (xAxis < xAxisMid - 1)
                                    {
                                        Meme     = xAxisMid - xAxis;
                                        WillGenn = Main.rand.Next(Meme);
                                    }
                                    if (xAxis > xAxisEdge + 1)
                                    {
                                        Meme     = xAxis - xAxisEdge;
                                        WillGenn = Main.rand.Next(Meme);
                                    }
                                    if (WillGenn < 18)
                                    {
                                        Main.tile[xAxis, yAxis].type = (ushort)mod.TileType("Spiritsand");
                                    }
                                }
                            }

                            int[] TileArray4 = { 161, 163, 200, 164 };
                            if (TileArray4.Contains(Main.tile[xAxis, yAxis].type))
                            {
                                if (Main.tile[xAxis, yAxis + 1] == null)
                                {
                                    if (rand.Next(0, 50) == 1)
                                    {
                                        WillGenn = 0;
                                        if (xAxis < xAxisMid - 1)
                                        {
                                            Meme     = xAxisMid - xAxis;
                                            WillGenn = Main.rand.Next(Meme);
                                        }
                                        if (xAxis > xAxisEdge + 1)
                                        {
                                            Meme     = xAxis - xAxisEdge;
                                            WillGenn = Main.rand.Next(Meme);
                                        }
                                        if (WillGenn < 18)
                                        {
                                            Main.tile[xAxis, yAxis].type = (ushort)mod.TileType("SpiritIce");
                                        }
                                    }
                                }
                                else
                                {
                                    WillGenn = 0;
                                    if (xAxis < xAxisMid - 1)
                                    {
                                        Meme     = xAxisMid - xAxis;
                                        WillGenn = Main.rand.Next(Meme);
                                    }
                                    if (xAxis > xAxisEdge + 1)
                                    {
                                        Meme     = xAxis - xAxisEdge;
                                        WillGenn = Main.rand.Next(Meme);
                                    }
                                    if (WillGenn < 18)
                                    {
                                        Main.tile[xAxis, yAxis].type = (ushort)mod.TileType("SpiritIce");
                                    }
                                }
                            }
                        }
                        if (Main.tile[xAxis, yAxis].type == mod.TileType("SpiritStone") && yAxis > WorldGen.rockLayer + 100 && Main.rand.Next(1500) == 6)
                        {
                            WorldGen.TileRunner(xAxis, yAxis, (double)WorldGen.genRand.Next(5, 7), 1, mod.TileType("SpiritOreTile"), false, 0f, 0f, true, true);
                        }
                    }
                }
            }
            int chests = 0;
            for (int r = 0; r < 380000; r++)
            {
                int success = WorldGen.PlaceChest(xAxis - Main.rand.Next(450), Main.rand.Next(100, 275), (ushort)mod.TileType("SpiritChestLocked"), false, 2);
                if (success > -1)
                {
                    string[] lootTable = { "GhastKnife", "GhastStaff", "GhastStaffMage", "GhastSword", "GhastBeam", };
                    Main.chest[success].item[0].SetDefaults(mod.ItemType(lootTable[chests]), false);

                    int[] lootTable2 = { 499, 1508, mod.ItemType("SpiritBar"), };

                    Main.chest[success].item[1].SetDefaults(lootTable2[Main.rand.Next(3)], false);
                    Main.chest[success].item[1].stack = WorldGen.genRand.Next(3, 8);
                    Main.chest[success].item[2].SetDefaults(lootTable2[Main.rand.Next(3)], false);
                    Main.chest[success].item[2].stack = WorldGen.genRand.Next(3, 8);
                    Main.chest[success].item[3].SetDefaults(lootTable2[Main.rand.Next(3)], false);
                    Main.chest[success].item[3].stack = WorldGen.genRand.Next(3, 8);
                    chests++;
                    if (chests >= 5)
                    {
                        break;
                    }
                }
            }
            #endregion
            return(true);
        }
Exemplo n.º 2
0
        public override void ModifyWorldGenTasks(List <GenPass> tasks, ref float totalWeight)
        {
            int genIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Final Cleanup"));

            tasks.Insert(genIndex + 1, new PassLegacy("Twilight Forest", delegate(GenerationProgress progress)
            {
                progress.Message = "Twilight Forest";
                int XTILE        = WorldGen.genRand.Next(125, Main.maxTilesX - 350);
                int yAxis        = Main.maxTilesY / 13;
                int num          = Main.rand.Next(20, 30);
                for (int g = 0; g <= num; g++)
                {
                    WorldMethods.Island(XTILE + Main.rand.Next(-350, 350), yAxis + Main.rand.Next(-20, 55), Main.rand.Next(26, 35), (float)(Main.rand.Next(11, 25) / 10), (ushort)mod.TileType("TwilightGrass"));
                }

                WorldMethods.Island(XTILE, yAxis, Main.rand.Next(60, 75), (float)(Main.rand.Next(6, 17) / 10), (ushort)mod.TileType("TwilightGrass"));
                for (int trees = 0; trees < 5000; trees++)
                {
                    int E     = XTILE + Main.rand.Next(-350, 350);
                    int F     = yAxis + Main.rand.Next(-20, 55);
                    Tile tile = Framing.GetTileSafely(E, F);
                    if (tile.type == mod.TileType("TwilightGrass"))
                    {
                        WorldGen.GrowTree(E, F);
                    }
                }

                int x;
                int y;
                int maxTries  = 20000;
                int tries     = 0;
                int successes = 0;


                while (tries < maxTries && successes < 10)
                {
                    x = XTILE + Main.rand.Next(-350, 350);
                    y = yAxis + Main.rand.Next(-20, 55);
                    if (WorldGen.PlaceChest(x, y, (ushort)mod.TileType <Tiles.TwiChest>(), false, 0) != -1)
                    {
                        successes++;
                    }
                    tries++;
                }
            }));

            int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Micro Biomes"));

            if (ShiniesIndex == -1)
            {
                // Shinies pass removed by some other mod.
                return;
            }

            tasks.Insert(ShiniesIndex + 1, new PassLegacy("Canyon", delegate(GenerationProgress progress)
            {
                progress.Message     = "Carving canyons";
                int X                = 1;
                int Y                = 1;
                float widthScale     = (Main.maxTilesX / 4200f);
                int numberToGenerate = 2;
                for (int k = 0; k < numberToGenerate; k++)
                {
                    bool placement = false;
                    bool placed    = false;
                    while (!placed)
                    {
                        bool success = false;
                        int attempts = 0;
                        while (!success)
                        {
                            attempts++;
                            if (attempts > 1000)
                            {
                                success = true;
                                continue;
                            }
                            int i = WorldGen.genRand.Next(200, Main.maxTilesX - 200);
                            if (i <= Main.maxTilesX / 2 - 50 || i >= Main.maxTilesX / 2 + 50)
                            {
                                int j = 0;
                                while (!Main.tile[i, j].active() && (double)j < Main.worldSurface)
                                {
                                    j++;
                                }
                                if (Main.tile[i, j].type == 53 || Main.tile[i, j].type == 0)
                                {
                                    j--;
                                    if (j > 150)
                                    {
                                        placement = CanGenerateCanyon(i, j);
                                        if (placement)
                                        {
                                            X = i;
                                            //	progress.Message = "BAZINGA";
                                            Y = j;
                                            PlaceCanyon(i, j);
                                            success = true;
                                            placed  = true;
                                            continue;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }));
        }