diff --git a/Buffs/Pets/SeaSlugBuff.cs b/Buffs/Pets/SeaSlugBuff.cs index ba44988cf8..b37d1ec138 100644 --- a/Buffs/Pets/SeaSlugBuff.cs +++ b/Buffs/Pets/SeaSlugBuff.cs @@ -9,8 +9,8 @@ namespace CalamityMod.Buffs.Pets { public override void SetStaticDefaults() { - DisplayName.SetDefault("Sea Slug"); - Description.SetDefault("The bioluminscent sea slug is following you"); + DisplayName.SetDefault("Nudibranch"); + Description.SetDefault("The cutest and most colorful sea creature"); Main.buffNoTimeDisplay[Type] = true; Main.vanityPet[Type] = true; } diff --git a/Buffs/Pets/SeaSlugBuff.png b/Buffs/Pets/SeaSlugBuff.png index 3500e7f445..d3bd4937d2 100644 Binary files a/Buffs/Pets/SeaSlugBuff.png and b/Buffs/Pets/SeaSlugBuff.png differ diff --git a/Gores/Trees/SpineBottom.png b/Gores/Trees/SpineBottom.png new file mode 100644 index 0000000000..670969b718 Binary files /dev/null and b/Gores/Trees/SpineBottom.png differ diff --git a/Gores/Trees/SpineBottom2.png b/Gores/Trees/SpineBottom2.png new file mode 100644 index 0000000000..b2ff701bb9 Binary files /dev/null and b/Gores/Trees/SpineBottom2.png differ diff --git a/Gores/Trees/SpineRib1.png b/Gores/Trees/SpineRib1.png new file mode 100644 index 0000000000..31294a21d8 Binary files /dev/null and b/Gores/Trees/SpineRib1.png differ diff --git a/Gores/Trees/SpineRib1_2.png b/Gores/Trees/SpineRib1_2.png new file mode 100644 index 0000000000..3f8c7a743e Binary files /dev/null and b/Gores/Trees/SpineRib1_2.png differ diff --git a/Gores/Trees/SpineRib2.png b/Gores/Trees/SpineRib2.png new file mode 100644 index 0000000000..6bdc2591de Binary files /dev/null and b/Gores/Trees/SpineRib2.png differ diff --git a/Gores/Trees/SpineRib2_2.png b/Gores/Trees/SpineRib2_2.png new file mode 100644 index 0000000000..3940f89fd5 Binary files /dev/null and b/Gores/Trees/SpineRib2_2.png differ diff --git a/Gores/Trees/SpineRib3.png b/Gores/Trees/SpineRib3.png new file mode 100644 index 0000000000..0e000a1f81 Binary files /dev/null and b/Gores/Trees/SpineRib3.png differ diff --git a/Gores/Trees/SpineRib3_2.png b/Gores/Trees/SpineRib3_2.png new file mode 100644 index 0000000000..18a7c2ac02 Binary files /dev/null and b/Gores/Trees/SpineRib3_2.png differ diff --git a/Gores/Trees/SpineRib3_3.png b/Gores/Trees/SpineRib3_3.png new file mode 100644 index 0000000000..27d5773bc9 Binary files /dev/null and b/Gores/Trees/SpineRib3_3.png differ diff --git a/Gores/Trees/SpineSegment.png b/Gores/Trees/SpineSegment.png new file mode 100644 index 0000000000..d2603444a1 Binary files /dev/null and b/Gores/Trees/SpineSegment.png differ diff --git a/Gores/Trees/SpineSegment2.png b/Gores/Trees/SpineSegment2.png new file mode 100644 index 0000000000..bfe346ac27 Binary files /dev/null and b/Gores/Trees/SpineSegment2.png differ diff --git a/Gores/Trees/SpineSegment3.png b/Gores/Trees/SpineSegment3.png new file mode 100644 index 0000000000..fde649aa7d Binary files /dev/null and b/Gores/Trees/SpineSegment3.png differ diff --git a/Items/Pets/SeaSlugCerata.cs b/Items/Pets/SeaSlugCerata.cs index 5933d6c8aa..270eaeaa8d 100644 --- a/Items/Pets/SeaSlugCerata.cs +++ b/Items/Pets/SeaSlugCerata.cs @@ -13,9 +13,9 @@ namespace CalamityMod.Items.Pets public override void SetStaticDefaults() { SacrificeTotal = 1; - DisplayName.SetDefault("Sea Slug Cerata"); - Tooltip.SetDefault("Summons a bioluminescent sea slug to follow you" - + "\nThe sea slug will change colors in different environments"); + DisplayName.SetDefault("Colorful Cerata"); + Tooltip.SetDefault("Summons a Bioluminescent Nudibranch to follow you" + + "\nThe Nudibranch will change colors and patterns in different environments"); } public override void SetDefaults() @@ -25,11 +25,11 @@ namespace CalamityMod.Items.Pets Item.useAnimation = 20; Item.useTime = 20; Item.noMelee = true; - Item.width = 26; - Item.height = 28; + Item.width = 28; + Item.height = 22; Item.value = Item.sellPrice(gold: 20); - Item.rare = ModContent.RarityType(); + Item.rare = ItemRarityID.Orange; Item.Calamity().devItem = true; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Pets/SeaSlugCerata.png b/Items/Pets/SeaSlugCerata.png index 12adeb6ada..a44dd4f2cc 100644 Binary files a/Items/Pets/SeaSlugCerata.png and b/Items/Pets/SeaSlugCerata.png differ diff --git a/Projectiles/Pets/SeaSlug.cs b/Projectiles/Pets/SeaSlug.cs index 7854cab241..27da4d7ac6 100644 --- a/Projectiles/Pets/SeaSlug.cs +++ b/Projectiles/Pets/SeaSlug.cs @@ -16,12 +16,12 @@ namespace CalamityMod.Projectiles.Pets private Form SeaSlugColor = Form.Normal; private enum Form { - Normal, Sulphur, Abyss, Sunken, Astral, Hell, Snow, Desert, Jungle, Mushroom + Normal, Sulphur, Abyss, Sunken, Astral, Crags, Hell, Snow, Desert, Jungle, Mushroom, Dungeon, Hallow, Corrupt, Crimson } public override void SetStaticDefaults() { - DisplayName.SetDefault("Sea Slug"); + DisplayName.SetDefault("Nudibranch"); Main.projFrames[Projectile.type] = 6; Main.projPet[Projectile.type] = true; } @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Pets { Projectile.netImportant = true; Projectile.width = 54; - Projectile.height = 38; + Projectile.height = 20; Projectile.friendly = true; Projectile.penetrate = -1; Projectile.timeLeft *= 5; @@ -40,66 +40,131 @@ namespace CalamityMod.Projectiles.Pets private void UpdateColor(Player player) { + //note to self: the higher it is in this else if chain, the higher the priority + + //sulphur if (player.InSulphur()) - { SeaSlugColor = Form.Sulphur; - } + //abyss else if (player.InAbyss()) - { SeaSlugColor = Form.Abyss; - } + //sunken sea else if (player.InSunkenSea()) - { SeaSlugColor = Form.Sunken; - } + //astral else if (player.InAstral()) - { SeaSlugColor = Form.Astral; - } + //brimstone crag + else if (player.InCalamity()) + SeaSlugColor = Form.Crags; + //underworld else if (player.ZoneUnderworldHeight) - { SeaSlugColor = Form.Hell; - } - else if (player.ZoneSnow) - { - SeaSlugColor = Form.Snow; - } - else if (player.ZoneDesert) - { - SeaSlugColor = Form.Desert; - } - else if (player.ZoneJungle) - { - SeaSlugColor = Form.Jungle; - } + //dungeon + else if (player.ZoneDungeon) + SeaSlugColor = Form.Dungeon; + //mushroom else if (player.ZoneGlowshroom) - { SeaSlugColor = Form.Mushroom; - } + //hallow + else if (player.ZoneHallow) + SeaSlugColor = Form.Hallow; + //corruption + else if (player.ZoneCorrupt) + SeaSlugColor = Form.Corrupt; + //crimson + else if (player.ZoneCrimson) + SeaSlugColor = Form.Crimson; + //jungle + else if (player.ZoneJungle) + SeaSlugColor = Form.Jungle; + //snow + else if (player.ZoneSnow) + SeaSlugColor = Form.Snow; + //desert + else if (player.ZoneDesert) + SeaSlugColor = Form.Desert; + //normal else - { SeaSlugColor = Form.Normal; - } } public override bool PreDraw(ref Color lightColor) { - Draw(lightColor, ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlug").Value); + Color newColor = new Color(0, 0, 0, 0); + + //set the body colors of each sea slug variant + switch (SeaSlugColor) + { + case Form.Normal: + newColor = new Color(255, 255, 255, 0).MultiplyRGB(lightColor); + break; + case Form.Sulphur: + newColor = new Color(36, 166, 125, 0).MultiplyRGB(lightColor); + break; + case Form.Abyss: + newColor = new Color(49, 59, 79, 0).MultiplyRGB(lightColor); + break; + case Form.Sunken: + newColor = new Color(60, 135, 145, 0).MultiplyRGB(lightColor); + break; + case Form.Astral: + newColor = new Color(100, 100, 133, 0).MultiplyRGB(lightColor); + break; + case Form.Crags: + newColor = new Color(85, 65, 75, 0).MultiplyRGB(lightColor); + break; + case Form.Hell: + newColor = new Color(240, 25, 25, 0).MultiplyRGB(lightColor); + break; + case Form.Snow: + newColor = new Color(255, 255, 255, 0).MultiplyRGB(lightColor); + break; + case Form.Desert: + newColor = new Color(212, 190, 87, 0).MultiplyRGB(lightColor); + break; + case Form.Jungle: + newColor = new Color(105, 80, 85, 0).MultiplyRGB(lightColor); + break; + case Form.Mushroom: + newColor = new Color(175, 189, 142, 0).MultiplyRGB(lightColor); + break; + case Form.Dungeon: + newColor = new Color(130, 229, 255, 0).MultiplyRGB(lightColor); + break; + case Form.Hallow: + newColor = new Color(255, 255, 255, 0).MultiplyRGB(lightColor); + break; + case Form.Corrupt: + newColor = new Color(156, 105, 105, 0).MultiplyRGB(lightColor); + break; + case Form.Crimson: + newColor = new Color(204, 53, 53, 0).MultiplyRGB(lightColor); + break; + } + + Draw(Projectile.GetAlpha(newColor), ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlug").Value); return false; } public override void PostDraw(Color lightColor) { - DrawGlowmask(Color.White, ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlug_Glow").Value, - ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugSulphur_Glow").Value, - ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugAbyss_Glow").Value, - ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugSunken_Glow").Value, - ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugAstral_Glow").Value, - ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugHell_Glow").Value, - ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugSnow_Glow").Value, - ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugDesert_Glow").Value, - ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugJungle_Glow").Value, - ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugMushroom_Glow").Value); + DrawGlowmask(Color.White, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugDefault").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugSulphur").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugAbyss").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugSunken").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugAstral").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugCrags").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugHell").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugSnow").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugDesert").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugJungle").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugMushroom").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugDungeon").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugHallow").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugCorrupt").Value, + ModContent.Request("CalamityMod/Projectiles/Pets/SeaSlugCrimson").Value); } private void Draw(Color color, Texture2D texture) @@ -113,7 +178,8 @@ namespace CalamityMod.Projectiles.Pets Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), color, Projectile.rotation, new Vector2(texture.Width / 2f, height / 2f), Projectile.scale, spriteEffects, 0); } - private void DrawGlowmask(Color color, Texture2D normal, Texture2D sulphur, Texture2D abyss, Texture2D sunken, Texture2D astral, Texture2D hell, Texture2D snow, Texture2D desert, Texture2D jungle, Texture2D mushroom) + private void DrawGlowmask(Color color, Texture2D normal, Texture2D sulphur, Texture2D abyss, Texture2D sunken, Texture2D astral, Texture2D crags, + Texture2D hell, Texture2D snow, Texture2D desert, Texture2D jungle, Texture2D mushroom, Texture2D dungeon, Texture2D hallow, Texture2D corrupt, Texture2D crimson) { Texture2D texture = normal; switch (SeaSlugColor) @@ -133,6 +199,9 @@ namespace CalamityMod.Projectiles.Pets case Form.Astral: texture = astral; break; + case Form.Crags: + texture = crags; + break; case Form.Hell: texture = hell; break; @@ -148,6 +217,18 @@ namespace CalamityMod.Projectiles.Pets case Form.Mushroom: texture = mushroom; break; + case Form.Dungeon: + texture = dungeon; + break; + case Form.Hallow: + texture = hallow; + break; + case Form.Corrupt: + texture = corrupt; + break; + case Form.Crimson: + texture = crimson; + break; } int height = texture.Height / Main.projFrames[Projectile.type]; diff --git a/Projectiles/Pets/SeaSlug.png b/Projectiles/Pets/SeaSlug.png index 7d13907832..743e98343f 100644 Binary files a/Projectiles/Pets/SeaSlug.png and b/Projectiles/Pets/SeaSlug.png differ diff --git a/Projectiles/Pets/SeaSlugAbyss.png b/Projectiles/Pets/SeaSlugAbyss.png new file mode 100644 index 0000000000..62784f293c Binary files /dev/null and b/Projectiles/Pets/SeaSlugAbyss.png differ diff --git a/Projectiles/Pets/SeaSlugAbyss_Glow.png b/Projectiles/Pets/SeaSlugAbyss_Glow.png deleted file mode 100644 index 3e4512d983..0000000000 Binary files a/Projectiles/Pets/SeaSlugAbyss_Glow.png and /dev/null differ diff --git a/Projectiles/Pets/SeaSlugAstral.png b/Projectiles/Pets/SeaSlugAstral.png new file mode 100644 index 0000000000..e8d3315808 Binary files /dev/null and b/Projectiles/Pets/SeaSlugAstral.png differ diff --git a/Projectiles/Pets/SeaSlugAstral_Glow.png b/Projectiles/Pets/SeaSlugAstral_Glow.png deleted file mode 100644 index adad6049d7..0000000000 Binary files a/Projectiles/Pets/SeaSlugAstral_Glow.png and /dev/null differ diff --git a/Projectiles/Pets/SeaSlugCorrupt.png b/Projectiles/Pets/SeaSlugCorrupt.png new file mode 100644 index 0000000000..b50f209ca7 Binary files /dev/null and b/Projectiles/Pets/SeaSlugCorrupt.png differ diff --git a/Projectiles/Pets/SeaSlugCrags.png b/Projectiles/Pets/SeaSlugCrags.png new file mode 100644 index 0000000000..c20cab1036 Binary files /dev/null and b/Projectiles/Pets/SeaSlugCrags.png differ diff --git a/Projectiles/Pets/SeaSlugCrimson.png b/Projectiles/Pets/SeaSlugCrimson.png new file mode 100644 index 0000000000..d42fa926f4 Binary files /dev/null and b/Projectiles/Pets/SeaSlugCrimson.png differ diff --git a/Projectiles/Pets/SeaSlugDefault.png b/Projectiles/Pets/SeaSlugDefault.png new file mode 100644 index 0000000000..b0f7ef388a Binary files /dev/null and b/Projectiles/Pets/SeaSlugDefault.png differ diff --git a/Projectiles/Pets/SeaSlugDesert.png b/Projectiles/Pets/SeaSlugDesert.png new file mode 100644 index 0000000000..f54fbe1b8c Binary files /dev/null and b/Projectiles/Pets/SeaSlugDesert.png differ diff --git a/Projectiles/Pets/SeaSlugDesert_Glow.png b/Projectiles/Pets/SeaSlugDesert_Glow.png deleted file mode 100644 index 1c22ff850f..0000000000 Binary files a/Projectiles/Pets/SeaSlugDesert_Glow.png and /dev/null differ diff --git a/Projectiles/Pets/SeaSlugDungeon.png b/Projectiles/Pets/SeaSlugDungeon.png new file mode 100644 index 0000000000..5ca3239534 Binary files /dev/null and b/Projectiles/Pets/SeaSlugDungeon.png differ diff --git a/Projectiles/Pets/SeaSlugHallow.png b/Projectiles/Pets/SeaSlugHallow.png new file mode 100644 index 0000000000..180220ec5a Binary files /dev/null and b/Projectiles/Pets/SeaSlugHallow.png differ diff --git a/Projectiles/Pets/SeaSlugHell.png b/Projectiles/Pets/SeaSlugHell.png new file mode 100644 index 0000000000..cd8ab0b022 Binary files /dev/null and b/Projectiles/Pets/SeaSlugHell.png differ diff --git a/Projectiles/Pets/SeaSlugHell_Glow.png b/Projectiles/Pets/SeaSlugHell_Glow.png deleted file mode 100644 index 243adcc097..0000000000 Binary files a/Projectiles/Pets/SeaSlugHell_Glow.png and /dev/null differ diff --git a/Projectiles/Pets/SeaSlugJungle.png b/Projectiles/Pets/SeaSlugJungle.png new file mode 100644 index 0000000000..802847d316 Binary files /dev/null and b/Projectiles/Pets/SeaSlugJungle.png differ diff --git a/Projectiles/Pets/SeaSlugJungle_Glow.png b/Projectiles/Pets/SeaSlugJungle_Glow.png deleted file mode 100644 index 9a1df673d5..0000000000 Binary files a/Projectiles/Pets/SeaSlugJungle_Glow.png and /dev/null differ diff --git a/Projectiles/Pets/SeaSlugMushroom.png b/Projectiles/Pets/SeaSlugMushroom.png new file mode 100644 index 0000000000..90503d1aa4 Binary files /dev/null and b/Projectiles/Pets/SeaSlugMushroom.png differ diff --git a/Projectiles/Pets/SeaSlugMushroom_Glow.png b/Projectiles/Pets/SeaSlugMushroom_Glow.png deleted file mode 100644 index 6f5424a5c4..0000000000 Binary files a/Projectiles/Pets/SeaSlugMushroom_Glow.png and /dev/null differ diff --git a/Projectiles/Pets/SeaSlugSnow.png b/Projectiles/Pets/SeaSlugSnow.png new file mode 100644 index 0000000000..564b4d2293 Binary files /dev/null and b/Projectiles/Pets/SeaSlugSnow.png differ diff --git a/Projectiles/Pets/SeaSlugSnow_Glow.png b/Projectiles/Pets/SeaSlugSnow_Glow.png deleted file mode 100644 index a7a00c7118..0000000000 Binary files a/Projectiles/Pets/SeaSlugSnow_Glow.png and /dev/null differ diff --git a/Projectiles/Pets/SeaSlugSulphur.png b/Projectiles/Pets/SeaSlugSulphur.png new file mode 100644 index 0000000000..125cf838d5 Binary files /dev/null and b/Projectiles/Pets/SeaSlugSulphur.png differ diff --git a/Projectiles/Pets/SeaSlugSulphur_Glow.png b/Projectiles/Pets/SeaSlugSulphur_Glow.png deleted file mode 100644 index 060d36f600..0000000000 Binary files a/Projectiles/Pets/SeaSlugSulphur_Glow.png and /dev/null differ diff --git a/Projectiles/Pets/SeaSlugSunken.png b/Projectiles/Pets/SeaSlugSunken.png new file mode 100644 index 0000000000..60565c2b7e Binary files /dev/null and b/Projectiles/Pets/SeaSlugSunken.png differ diff --git a/Projectiles/Pets/SeaSlugSunken_Glow.png b/Projectiles/Pets/SeaSlugSunken_Glow.png deleted file mode 100644 index f5ea6d83fa..0000000000 Binary files a/Projectiles/Pets/SeaSlugSunken_Glow.png and /dev/null differ diff --git a/Projectiles/Pets/SeaSlug_Glow.png b/Projectiles/Pets/SeaSlug_Glow.png deleted file mode 100644 index 5587370bd3..0000000000 Binary files a/Projectiles/Pets/SeaSlug_Glow.png and /dev/null differ diff --git a/Schematics/DungeonArchivePink.csch b/Schematics/DungeonArchivePink.csch index e5122a650a..7db6c068dd 100644 Binary files a/Schematics/DungeonArchivePink.csch and b/Schematics/DungeonArchivePink.csch differ diff --git a/Systems/WorldgenManagementSystem.cs b/Systems/WorldgenManagementSystem.cs index deb7ee0ea7..64f2ea0b42 100644 --- a/Systems/WorldgenManagementSystem.cs +++ b/Systems/WorldgenManagementSystem.cs @@ -86,7 +86,7 @@ namespace CalamityMod.Systems { attempts++; Point origin = WorldGen.RandomWorldPoint((int)Main.worldSurface + 25, 20, Main.maxTilesY - (int)Main.worldSurface - 125, 20); - if (MiscWorldgenRoutines.CanPlaceGiantHive(origin, WorldGen.structures)) + if (GiantHive.CanPlaceGiantHive(origin, WorldGen.structures)) break; } })); diff --git a/Tiles/Crags/Tree/SpineTree.cs b/Tiles/Crags/Tree/SpineTree.cs index 23bd0fbcc2..25fe1f2f04 100644 --- a/Tiles/Crags/Tree/SpineTree.cs +++ b/Tiles/Crags/Tree/SpineTree.cs @@ -21,9 +21,11 @@ namespace CalamityMod.Tiles.Crags.Tree X frame 0 (orange) = bottom segment X frame 18 (dark purple) = main body segment, each of the three y-frame variants draws a different tree segment variant X frame 36 (light purple) = top of the tree - X frame 54 (teal) = rib branch segments, each of the three y-frame variants has a different pattern where: + X frame 54 (teal) = small rib branch segments + X frame 72 (lime) = medium rib branch segments + X frame 90 (yellow) = large rib branch segments - for the branch segments: + each of the branch frames have a pattern where y-frame 1 = left branch y-frame 2 = right branch y-frame 3 = both left and right branch @@ -148,9 +150,23 @@ namespace CalamityMod.Tiles.Crags.Tree //chance to place a branch segment //also dont place branches below a certain threshold - if (Main.rand.Next(3) == 0 && branchSegmentDelay == 0 && k > 5) + if (Main.rand.Next(2) == 0 && branchSegmentDelay == 0 && k > 5) { - Framing.GetTileSafely(i, j - k).TileFrameX = 3 * 18; + float divide = 1.5f; + + if (k < height / 2) + { + Framing.GetTileSafely(i, j - k).TileFrameX = 3 * 18; + } + else if (k > height / 2 && k < height / (int)divide) + { + Framing.GetTileSafely(i, j - k).TileFrameX = 4 * 18; + } + else if (k > height / (int)divide && k < height) + { + Framing.GetTileSafely(i, j - k).TileFrameX = 5 * 18; + } + Framing.GetTileSafely(i, j - k).TileFrameY = (short)(Main.rand.Next(3) * 18); branchSegmentDelay = 3; } @@ -300,25 +316,26 @@ namespace CalamityMod.Tiles.Crags.Tree Vector2 treeSegmentOffset = new Vector2((xOff * 2) - (frameOff / 2) + 25, 14); Vector2 topSegmentOffset = new Vector2((xOff * 2) - (frameOff / 2) + 20, 16); + Texture2D baseTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineBottom").Value; + Texture2D segmentTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineSegments").Value; + //draw the base of the tree if (Framing.GetTileSafely(i, j).TileFrameX == 0) { - Texture2D segmentTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineBottom").Value; int frame = tile.TileFrameY / 18; - DrawTreeSegments(i, j, segmentTex, new Rectangle(34 * frame, 0, 32, 20), TileOffset.ToWorldCoordinates(), treeSegmentOffset, false); + DrawTreeSegments(i, j, baseTex, new Rectangle(34 * frame, 0, 32, 20), TileOffset.ToWorldCoordinates(), treeSegmentOffset, false); } //draw the different segments of the tree if (Framing.GetTileSafely(i, j).TileFrameX == 18) { - Texture2D segmentTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineSegments").Value; int frame = tile.TileFrameY / 18; DrawTreeSegments(i, j, segmentTex, new Rectangle(34 * frame, 0, 32, 20), TileOffset.ToWorldCoordinates(), treeSegmentOffset, false); } - //draw branch segments + //draw small branch segments if (Framing.GetTileSafely(i, j).TileFrameX == 54) { int frame = tile.TileFrameY / 18; @@ -337,8 +354,44 @@ namespace CalamityMod.Tiles.Crags.Tree DrawTreeSegments(i, j, rightBranchTex, new Rectangle(38 * frame, 0, 38, 40), TileOffset.ToWorldCoordinates(), rightBranchOffset, false); //draw segments - Texture2D segmentTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineSegments").Value; + DrawTreeSegments(i, j, segmentTex, new Rectangle(34 * frame, 0, 32, 20), TileOffset.ToWorldCoordinates(), treeSegmentOffset, false); + } + //draw medium branch segments + if (Framing.GetTileSafely(i, j).TileFrameX == 72) + { + int frame = tile.TileFrameY / 18; + + //branch drawing stuff + Texture2D leftBranchTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib2Left").Value; + Texture2D rightBranchTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib2Right").Value; + + Vector2 leftBranchOffset = new Vector2((xOff * 2) - (frameOff / 2) + 60, 14); + Vector2 rightBranchOffset = new Vector2((xOff * 2) - (frameOff / 2) + 4, 14); + + DrawTreeSegments(i, j, leftBranchTex, new Rectangle(50 * frame, 0, 48, 52), TileOffset.ToWorldCoordinates(), leftBranchOffset, false); + DrawTreeSegments(i, j, rightBranchTex, new Rectangle(50 * frame, 0, 48, 52), TileOffset.ToWorldCoordinates(), rightBranchOffset, false); + + //draw segments + DrawTreeSegments(i, j, segmentTex, new Rectangle(34 * frame, 0, 32, 20), TileOffset.ToWorldCoordinates(), treeSegmentOffset, false); + } + + //draw large branch segments + if (Framing.GetTileSafely(i, j).TileFrameX == 90) + { + int frame = tile.TileFrameY / 18; + + //branch drawing stuff + Texture2D leftBranchTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib3Left").Value; + Texture2D rightBranchTex = ModContent.Request("CalamityMod/Tiles/Crags/Tree/SpineRib3Right").Value; + + Vector2 leftBranchOffset = new Vector2((xOff * 2) - (frameOff / 2) + 80, 14); + Vector2 rightBranchOffset = new Vector2((xOff * 2) - (frameOff / 2) + 4, 14); + + DrawTreeSegments(i, j, leftBranchTex, new Rectangle(62 * frame, 0, 60, 58), TileOffset.ToWorldCoordinates(), leftBranchOffset, false); + DrawTreeSegments(i, j, rightBranchTex, new Rectangle(62 * frame, 0, 60, 58), TileOffset.ToWorldCoordinates(), rightBranchOffset, false); + + //draw segments DrawTreeSegments(i, j, segmentTex, new Rectangle(34 * frame, 0, 32, 20), TileOffset.ToWorldCoordinates(), treeSegmentOffset, false); } diff --git a/Tiles/Crags/Tree/SpineTree.png b/Tiles/Crags/Tree/SpineTree.png index 940dc94972..d860812b5d 100644 Binary files a/Tiles/Crags/Tree/SpineTree.png and b/Tiles/Crags/Tree/SpineTree.png differ diff --git a/World/DraedonStructures.cs b/World/DraedonStructures.cs index 6253e6a864..61322e5e69 100644 --- a/World/DraedonStructures.cs +++ b/World/DraedonStructures.cs @@ -367,7 +367,7 @@ namespace CalamityMod.World if (structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y))) { bool hasPlacedLogAndSchematic = false; - PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.Center, ref hasPlacedLogAndSchematic, new Action(FillSunkenSeaLaboratoryChest)); + PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref hasPlacedLogAndSchematic, new Action(FillSunkenSeaLaboratoryChest)); structures.AddProtectedStructure(new Rectangle(placementPoint.X, placementPoint.Y, TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)), 4); //this is center-anchored so it should be correct already CalamityWorld.SunkenSeaLabCenter = placementPoint.ToWorldCoordinates(); diff --git a/World/DungeonArchive.cs b/World/DungeonArchive.cs index c9b0d5d4b4..6c0346c159 100644 --- a/World/DungeonArchive.cs +++ b/World/DungeonArchive.cs @@ -28,18 +28,20 @@ namespace CalamityMod.World bool foundValidPosition = false; int dungeonArchiveColor = 0; //0 = blue, 1 = green, 2 = pink - for (int x = 20; x <= Main.maxTilesX - 20; x++) + int heightLimit = (Main.maxTilesY / 2) + 200; + + for (int x = 5; x <= Main.maxTilesX - 5; x++) { - for (int y = Main.maxTilesY - 200; y > (Main.maxTilesY / 2) + 100; y--) + for (int y = Main.maxTilesY - 5; y >= heightLimit; y--) { Tile tile = Main.tile[x, y]; Tile tileUp = Main.tile[x, y - 1]; Tile tileDown = Main.tile[x, y + 1]; - if (!tile.HasTile && !tileUp.HasTile && (tileDown.TileType == 41 || tileDown.TileType == 43 || tileDown.TileType == 44)) + if ((tile.TileType == 41 || tile.TileType == 43 || tile.TileType == 44 || tile.TileType == 48) && !tileUp.HasTile) { //blue brick walls - if (tile.WallType == 7 || tile.WallType == 94 || tile.WallType == 95) + if (tileUp.WallType == 7 || tileUp.WallType == 94 || tileUp.WallType == 95) { dungeonArchiveColor = 0; archiveX = x; @@ -48,7 +50,7 @@ namespace CalamityMod.World foundValidPosition = true; } //green brick walls - if (tile.WallType == 8 || tile.WallType == 98 || tile.WallType == 99) + if (tileUp.WallType == 8 || tileUp.WallType == 98 || tileUp.WallType == 99) { dungeonArchiveColor = 1; archiveX = x; @@ -57,7 +59,7 @@ namespace CalamityMod.World foundValidPosition = true; } //pink brick walls - if (tile.WallType == 9 || tile.WallType == 96 || tile.WallType == 97) + if (tileUp.WallType == 9 || tileUp.WallType == 96 || tileUp.WallType == 97) { dungeonArchiveColor = 2; archiveX = x; @@ -66,6 +68,17 @@ namespace CalamityMod.World foundValidPosition = true; } } + + //in order to make sure the archive places at the very bottom of the dungeon: + //loop upward a certain amount, and if it doesnt place reset everything and increase the check height before the loop ends + //this way it will keep checking upward so it places nicely and doesnt destroy other parts of the dungeon (or at least not as much) + if (x >= Main.maxTilesX - 5 && y <= heightLimit + 5 && !foundValidPosition) + { + x = 5; + y = Main.maxTilesY - 5; + + heightLimit = heightLimit - 2; + } } } diff --git a/World/GiantHive.cs b/World/GiantHive.cs new file mode 100644 index 0000000000..7785e5dd05 --- /dev/null +++ b/World/GiantHive.cs @@ -0,0 +1,657 @@ +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Potions; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Tiles; +using CalamityMod.Tiles.Abyss; +using CalamityMod.Tiles.Astral; +using CalamityMod.Tiles.Crags; +using CalamityMod.Tiles.FurnitureAncient; +using CalamityMod.Tiles.Ores; +using CalamityMod.Walls; +using Microsoft.Xna.Framework; +using System; +using System.Reflection; +using System.Collections.Generic; +using Terraria; +using Terraria.ID; +using Terraria.IO; +using Terraria.ModLoader; +using Terraria.Utilities; +using Terraria.WorldBuilding; +using Terraria.GameContent.Generation; + +namespace CalamityMod.World +{ + public class GiantHive + { + public static bool GrowLivingJungleTree(Point origin) + { + if (!WorldGen.drunkWorldGen || WorldGen.genRand.Next(50) > 0) + { + Dictionary dictionary = new Dictionary(); + WorldUtils.Gen(new Point(origin.X - 25, origin.Y - 25), new Shapes.Rectangle(50, 50), new Actions.TileScanner(0, 59, 60, 147, 1).Output(dictionary)); + int num = dictionary[0] + dictionary[1]; + int num2 = dictionary[59] + dictionary[60]; + if (dictionary[147] > num2 || num > num2 || num2 < 50) + { + return false; + } + } + + int treeHeight = (int)Main.worldSurface - (Main.maxTilesY / 6); //start here to not touch floating islands + bool validheightFound = false; + int attempts = 0; + while (!validheightFound && attempts++ < 100000) + { + + while (!WorldGen.SolidTile(origin.X, treeHeight) && treeHeight <= Main.worldSurface) + { + treeHeight++; + } + + if (Main.tile[origin.X, treeHeight].HasTile || Main.tile[origin.X, treeHeight].WallType > 0) + { + validheightFound = true; + } + } + + while (validheightFound) + { + int num3 = (origin.Y + treeHeight) / 20; //the height of the tree + int num4 = num3 * 5; + int num5 = 0; + double num6 = WorldGen.genRand.NextDouble() + 1.0; + double num7 = WorldGen.genRand.NextDouble() + 2.0; + + if (WorldGen.genRand.Next(2) == 0) + { + num7 = 0.0 - num7; + } + + for (int i = 0; i < num3; i++) + { + int num8 = (int)(Math.Sin((double)(i + 1) / 12.0 * num6 * 3.1415927410125732) * num7); + int num9 = ((num8 < num5) ? (num8 - num5) : 0); + + //places the actual log of the tree + WorldUtils.Gen(new Point(origin.X + num5 + num9, origin.Y - (i + 1) * 5), new Shapes.Rectangle(6, 6), + Actions.Chain(new Modifiers.SkipTiles(21, 467, 226, 237), new Modifiers.SkipWalls(87), new Actions.RemoveWall(), + new Actions.SetTile(383), new Actions.SetFrames())); + + //digs out the hole on the middle of the tree + WorldUtils.Gen(new Point(origin.X + num5 + num9 + 2, origin.Y - (i + 1) * 5), new Shapes.Rectangle(2 + Math.Abs(num8 - num5), 5), + Actions.Chain(new Modifiers.SkipTiles(21, 467, 226, 237), new Modifiers.SkipWalls(87), + new Actions.ClearTile(frameNeighbors: true), new Actions.PlaceWall(78))); + + //place wood walls on the inside of the tree + WorldUtils.Gen(new Point(origin.X + num5 + 2, origin.Y - i * 5), new Shapes.Rectangle(6, 6), + Actions.Chain(new Modifiers.SkipTiles(21, 467, 226, 237), new Modifiers.SkipWalls(87), + new Actions.ClearTile(frameNeighbors: true), new Actions.PlaceWall(78))); + + num5 = num8; + } + + int num10 = 6; + if (num7 < 0.0) + { + num10 = 0; + } + + List list = new List(); + + //loop to place extra branches on the top of the tree + for (int j = 0; j < 6; j++) + { + double num11 = ((double)j + 1.0) / 3.0; + int num12 = num10 + (int)(Math.Sin((double)num3 * num11 / 12.0 * num6 * 3.1415927410125732) * num7); + double num13 = WorldGen.genRand.NextDouble() * 0.7853981852531433 - 0.7853981852531433 - 0.2; + + if (num10 == 0) + { + num13 -= 1.5707963705062866; + } + + //branches + WorldUtils.Gen(new Point(origin.X + num12, origin.Y - (int)((double)(num3 * 5))), + new ShapeBranch(num13, WorldGen.genRand.Next(12, 22)).OutputEndpoints(list), Actions.Chain(new Modifiers.SkipTiles(21, 467, 226, 237), + new Modifiers.SkipWalls(87), new Actions.SetTile(383), new Actions.SetFrames(frameNeighbors: true))); + + num10 = 6 - num10; + } + + int num14 = (int)(Math.Sin((double)num3 / 12.0 * num6 * 3.1415927410125732) * num7); + + //places branches for the leaves to grow on + WorldUtils.Gen(new Point(origin.X + 6 + num14, origin.Y - num4), new ShapeBranch(-0.6853981852531433, + WorldGen.genRand.Next(16, 22)).OutputEndpoints(list), Actions.Chain(new Modifiers.SkipTiles(21, 467, 226, 237), + new Modifiers.SkipWalls(87), new Actions.SetTile(383), new Actions.SetFrames(frameNeighbors: true))); + + WorldUtils.Gen(new Point(origin.X + num14, origin.Y - num4), new ShapeBranch(-2.45619455575943, + WorldGen.genRand.Next(16, 22)).OutputEndpoints(list), Actions.Chain(new Modifiers.SkipTiles(21, 467, 226, 237), + new Modifiers.SkipWalls(87), new Actions.SetTile(383), new Actions.SetFrames(frameNeighbors: true))); + + foreach (Point item in list) + { + //place living mahogany leaves + WorldUtils.Gen(item, new Shapes.Circle(4), Actions.Chain(new Modifiers.Blotches(WorldGen.genRand.Next(5, 8), WorldGen.genRand.Next(3, 6)), + new Modifiers.SkipTiles(383, 21, 467, 226, 237), new Modifiers.SkipWalls(78, 87), new Actions.SetTile(384), new Actions.SetFrames(frameNeighbors: true))); + } + + for (int k = 0; k < 5; k++) + { + double angle = (double)k / 3.0 * 2.0 + 0.57075; + WorldUtils.Gen(origin, new ShapeRoot((float)angle, WorldGen.genRand.Next(40, 60)), Actions.Chain(new Modifiers.SkipTiles(21, 467, 226, 237), + new Modifiers.SkipWalls(87), new Actions.SetTile(383, setSelfFrames: true))); + } + + WorldGen.AddBuriedChest(origin.X + 3, origin.Y - 1, (WorldGen.genRand.Next(4) != 0) ? WorldGen.GetNextJungleChestItem() : 0, notNearOtherChests: false, 10, trySlope: false, 0); + + //i dunno how to use this properly, so disabled it stays + //though i guess theres not really any other structures in the surface jungle anyways + //structures.AddProtectedStructure(new Rectangle(origin.X - 30, origin.Y - 30, 60, 60)); + + return true; + } + + return false; + } + + public static bool CanPlaceGiantHive(Point origin, StructureMap structures) + { + if (!structures.CanPlace(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100))) + return false; + + if (TooCloseToImportantLocations(origin)) + return false; + + Ref ref1 = new Ref(0); + Ref ref2 = new Ref(0); + Ref ref3 = new Ref(0); + WorldUtils.Gen(origin, new Shapes.Circle(15), Actions.Chain(new Modifiers.IsSolid(), new Actions.Scanner(ref1), new Modifiers.OnlyTiles(TileID.JungleGrass, TileID.Mud), new Actions.Scanner(ref2), new Modifiers.OnlyTiles(TileID.JungleGrass), new Actions.Scanner(ref3))); + if (ref2.Value / (float)ref1.Value < 0.75f || ref3.Value < 2) + return false; + + int num = 0; + int[] array = new int[1000]; + int[] array2 = new int[1000]; + Vector2 larvaLocation = origin.ToVector2(); + int numHiveTunnels = WorldGen.genRand.Next(10, 13); + + GrowLivingJungleTree(new Point(origin.X, origin.Y)); + + for (int i = 0; i < numHiveTunnels; i++) + { + Vector2 vector2 = larvaLocation; + int num3 = WorldGen.genRand.Next(2, 5); + for (int j = 0; j < num3; j++) + vector2 = CreateHiveTunnel((int)larvaLocation.X, (int)larvaLocation.Y, WorldGen.genRand); + + larvaLocation = vector2; + array[num] = (int)larvaLocation.X; + array2[num] = (int)larvaLocation.Y; + num++; + } + + FrameOutAllHiveContents(origin, 50); + + for (int k = 0; k < num; k++) + { + int num4 = array[k]; + int y = array2[k]; + int num5 = 1; + if (WorldGen.genRand.NextBool()) + num5 = -1; + + bool flag = false; + while (WorldGen.InWorld(num4, y, 10) && BadSpotForHoneyFall(num4, y)) + { + num4 += num5; + if (Math.Abs(num4 - array[k]) > 50) + { + flag = true; + break; + } + } + + if (!flag) + { + num4 += num5; + if (!SpotActuallyNotInHive(num4, y)) + { + CreateBlockedHoneyCube(num4, y); + CreateDentForHoneyFall(num4, y, num5); + } + } + } + + CreateStandForLarva(larvaLocation); + + // Generate a second larva stand + Vector2 secondLarvaLocation = default; + int maxAttempts = 1000; + for (int l = 0; l < maxAttempts; l++) + { + Vector2 vector3 = larvaLocation; + vector3.X += WorldGen.genRand.Next(-50, 51); + vector3.Y += WorldGen.genRand.Next(-50, 51); + if (WorldGen.InWorld((int)vector3.X, (int)vector3.Y) && Vector2.Distance(larvaLocation, vector3) > 10f && !Main.tile[(int)vector3.X, (int)vector3.Y].HasTile && Main.tile[(int)vector3.X, (int)vector3.Y].WallType == WallID.HiveUnsafe) + { + secondLarvaLocation = vector3; + CreateStandForLarva(vector3); + break; + } + } + + // Honey chests + Vector2 honeyChestLocation = default; + for (int l = 0; l < maxAttempts; l++) + { + Vector2 vector3 = larvaLocation; + vector3.X += WorldGen.genRand.Next(-100, 101); + vector3.Y += WorldGen.genRand.Next(-100, 101); + if (WorldGen.InWorld((int)vector3.X, (int)vector3.Y) && Vector2.Distance(larvaLocation, vector3) > 10f && Vector2.Distance(secondLarvaLocation, vector3) > 10f && !Main.tile[(int)vector3.X, (int)vector3.Y].HasTile && Main.tile[(int)vector3.X, (int)vector3.Y].WallType == WallID.HiveUnsafe) + { + honeyChestLocation = vector3; + CreateStandAndPlaceHoneyChest(vector3); + break; + } + } + for (int l = 0; l < maxAttempts; l++) + { + Vector2 vector3 = larvaLocation; + vector3.X += WorldGen.genRand.Next(-100, 101); + vector3.Y += WorldGen.genRand.Next(-100, 101); + if (WorldGen.InWorld((int)vector3.X, (int)vector3.Y) && Vector2.Distance(larvaLocation, vector3) > 10f && Vector2.Distance(secondLarvaLocation, vector3) > 10f && Vector2.Distance(honeyChestLocation, vector3) > 10f && !Main.tile[(int)vector3.X, (int)vector3.Y].HasTile && Main.tile[(int)vector3.X, (int)vector3.Y].WallType == WallID.HiveUnsafe) + { + CreateStandAndPlaceHoneyChest(vector3); + break; + } + } + + structures.AddProtectedStructure(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 5); + return true; + } + + private static void FrameOutAllHiveContents(Point origin, int squareHalfWidth) + { + int num = Math.Max(10, origin.X - squareHalfWidth); + int num2 = Math.Min(Main.maxTilesX - 10, origin.X + squareHalfWidth); + int num3 = Math.Max(10, origin.Y - squareHalfWidth); + int num4 = Math.Min(Main.maxTilesY - 10, origin.Y + squareHalfWidth); + for (int i = num; i < num2; i++) + { + for (int j = num3; j < num4; j++) + { + Tile tile = Main.tile[i, j]; + if (tile.HasTile && tile.TileType == TileID.Hive) + WorldGen.SquareTileFrame(i, j); + + if (tile.WallType == WallID.HiveUnsafe) + WorldGen.SquareWallFrame(i, j); + } + } + } + + private static Vector2 CreateHiveTunnel(int i, int j, UnifiedRandom random) + { + double num = random.Next(20, 26); + float num2 = random.Next(30, 41); + float num3 = Main.maxTilesX / 4200; + num3 = (num3 + 1f) / 2f; + num *= (double)num3; + num2 *= num3; + + double num4 = num; + Vector2 result = default; + result.X = i; + result.Y = j; + Vector2 vector = default; + vector.X = random.Next(-10, 11) * 0.2f; + vector.Y = random.Next(-10, 11) * 0.2f; + while (num > 0.0 && num2 > 0f) + { + if (result.Y > (Main.maxTilesY - 250)) + num2 = 0f; + + num = num4 * (double)(1f + random.Next(-20, 20) * 0.01f); + num2 -= 1f; + int num5 = (int)(result.X - num); + int num6 = (int)(result.X + num); + int num7 = (int)(result.Y - num); + int num8 = (int)(result.Y + num); + if (num5 < 1) + num5 = 1; + + if (num6 > Main.maxTilesX - 1) + num6 = Main.maxTilesX - 1; + + if (num7 < 1) + num7 = 1; + + if (num8 > Main.maxTilesY - 1) + num8 = Main.maxTilesY - 1; + + for (int k = num5; k < num6; k++) + { + for (int l = num7; l < num8; l++) + { + if (!WorldGen.InWorld(k, l, 50)) + { + num2 = 0f; + } + else + { + if (Main.tile[k - 10, l].WallType == WallID.LihzahrdBrickUnsafe) + num2 = 0f; + + if (Main.tile[k + 10, l].WallType == WallID.LihzahrdBrickUnsafe) + num2 = 0f; + + if (Main.tile[k, l - 10].WallType == WallID.LihzahrdBrickUnsafe) + num2 = 0f; + + if (Main.tile[k, l + 10].WallType == WallID.LihzahrdBrickUnsafe) + num2 = 0f; + } + + if (l < Main.worldSurface && Main.tile[k, l - 5].WallType == WallID.None) + num2 = 0f; + + float num9 = Math.Abs(k - result.X); + float num10 = Math.Abs(l - result.Y); + double num11 = Math.Sqrt(num9 * num9 + num10 * num10); + if (num11 < num4 * 0.4 * (1.0 + random.Next(-10, 11) * 0.005)) + { + Main.tile[k, l].LiquidAmount = byte.MaxValue; + Main.tile[k, l].Get().LiquidType = LiquidID.Honey; + Main.tile[k, l].WallType = WallID.HiveUnsafe; + Main.tile[k, l].Get().HasTile = false; + Main.tile[k, l].Get().IsHalfBlock = false; + Main.tile[k, l].Get().Slope = SlopeType.Solid; + } + else if (num11 < num4 * 0.75 * (1.0 + random.Next(-10, 11) * 0.005)) + { + Main.tile[k, l].LiquidAmount = 0; + if (Main.tile[k, l].WallType != WallID.HiveUnsafe) + { + Main.tile[k, l].Get().HasTile = true; + Main.tile[k, l].Get().IsHalfBlock = false; + Main.tile[k, l].Get().Slope = SlopeType.Solid; + Main.tile[k, l].TileType = TileID.Hive; + } + } + + if (num11 < num4 * 0.6 * (1.0 + random.Next(-10, 11) * 0.005)) + { + Main.tile[k, l].WallType = WallID.HiveUnsafe; + if (random.NextBool()) + { + Main.tile[k, l].LiquidAmount = byte.MaxValue; + Main.tile[k, l].Get().LiquidType = LiquidID.Honey; + } + } + } + } + + result += vector; + num2 -= 1f; + vector.Y += random.Next(-10, 11) * 0.05f; + vector.X += random.Next(-10, 11) * 0.05f; + } + + return result; + } + + private static bool TooCloseToImportantLocations(Point origin) + { + int x = origin.X; + int y = origin.Y; + int num = 150; + for (int i = x - num; i < x + num; i += 10) + { + if (i <= 0 || i > Main.maxTilesX - 1) + continue; + + for (int j = y - num; j < y + num; j += 10) + { + if (j > 0 && j <= Main.maxTilesY - 1) + { + if (Main.tile[i, j].HasTile && Main.tile[i, j].TileType == TileID.LihzahrdBrick) + return true; + + if (Main.tile[i, j].WallType == WallID.CrimstoneUnsafe || Main.tile[i, j].WallType == WallID.EbonstoneUnsafe || Main.tile[i, j].WallType == WallID.LihzahrdBrickUnsafe) + return true; + } + } + } + + return false; + } + + private static void CreateDentForHoneyFall(int x, int y, int dir) + { + dir *= -1; + y++; + int num = 0; + while ((num < 4 || WorldGen.SolidTile(x, y)) && x > 10 && x < Main.maxTilesX - 10) + { + num++; + x += dir; + if (WorldGen.SolidTile(x, y)) + { + WorldGen.PoundTile(x, y); + if (!Main.tile[x, y + 1].HasTile) + { + Main.tile[x, y + 1].Get().HasTile = true; + Main.tile[x, y + 1].TileType = TileID.Hive; + } + } + } + } + + private static void CreateBlockedHoneyCube(int x, int y) + { + for (int i = x - 1; i <= x + 2; i++) + { + for (int j = y - 1; j <= y + 2; j++) + { + if (i >= x && i <= x + 1 && j >= y && j <= y + 1) + { + Main.tile[i, j].Get().HasTile = false; + Main.tile[i, j].LiquidAmount = byte.MaxValue; + Main.tile[i, j].Get().LiquidType = LiquidID.Honey; + } + else + { + Main.tile[i, j].Get().HasTile = true; + Main.tile[i, j].TileType = TileID.Hive; + } + } + } + } + + private static bool SpotActuallyNotInHive(int x, int y) + { + for (int i = x - 1; i <= x + 2; i++) + { + for (int j = y - 1; j <= y + 2; j++) + { + if (i < 10 || i > Main.maxTilesX - 10) + return true; + + if (Main.tile[i, j].HasTile && Main.tile[i, j].TileType != TileID.Hive) + return true; + } + } + + return false; + } + + private static bool BadSpotForHoneyFall(int x, int y) + { + if (Main.tile[x, y].HasTile && Main.tile[x, y + 1].HasTile && Main.tile[x + 1, y].HasTile) + return !Main.tile[x + 1, y + 1].HasTile; + + return true; + } + + public static void CreateStandForLarva(Vector2 position) + { + WorldGen.larvaX[WorldGen.numLarva] = Utils.Clamp((int)position.X, 5, Main.maxTilesX - 5); + WorldGen.larvaY[WorldGen.numLarva] = Utils.Clamp((int)position.Y, 5, Main.maxTilesY - 5); + WorldGen.numLarva++; + if (WorldGen.numLarva >= WorldGen.larvaX.Length) + WorldGen.numLarva = WorldGen.larvaX.Length - 1; + + int num = (int)position.X; + int num2 = (int)position.Y; + for (int i = num - 1; i <= num + 1 && i > 0 && i < Main.maxTilesX; i++) + { + for (int j = num2 - 2; j <= num2 + 1 && j > 0 && j < Main.maxTilesY; j++) + { + if (j != num2 + 1) + { + Main.tile[i, j].Get().HasTile = false; + continue; + } + + Main.tile[i, j].Get().HasTile = true; + Main.tile[i, j].TileType = TileID.Hive; + Main.tile[i, j].Get().Slope = SlopeType.Solid; + Main.tile[i, j].Get().IsHalfBlock = false; + } + } + } + + public static void CreateStandAndPlaceHoneyChest(Vector2 position) + { + int chestPlacementX = Utils.Clamp((int)position.X, 5, Main.maxTilesX - 5); + int chestPlacementY = Utils.Clamp((int)position.Y, 5, Main.maxTilesY - 5); + + int num = (int)position.X; + int num2 = (int)position.Y; + for (int i = num; i <= num + 1 && i > 0 && i < Main.maxTilesX; i++) + { + for (int j = num2 - 1; j <= num2 + 1 && j > 0 && j < Main.maxTilesY; j++) + { + if (j != num2 + 1) + { + Main.tile[i, j].Get().HasTile = false; + continue; + } + + Main.tile[i, j].Get().HasTile = true; + Main.tile[i, j].TileType = TileID.Hive; + Main.tile[i, j].Get().Slope = SlopeType.Solid; + Main.tile[i, j].Get().IsHalfBlock = false; + } + } + + int num144 = chestPlacementX; + int num145 = chestPlacementY; + for (int num146 = num144; num146 <= num144 + 1; num146++) + { + for (int num147 = num145 - 1; num147 <= num145 + 1; num147++) + { + if (num147 != num145 + 1) + { + Main.tile[num146, num147].Get().HasTile = false; + } + else + { + Main.tile[num146, num147].Get().HasTile = true; + Main.tile[num146, num147].TileType = TileID.Hive; + Main.tile[num146, num147].Get().Slope = SlopeType.Solid; + Main.tile[num146, num147].Get().IsHalfBlock = false; + } + } + } + + int chestID = WorldGen.PlaceChest(num144, num145, 21, false, 29); + FillHoneyChest(chestID, WorldGen.genRand); + } + + // Honey chest stuff, this is also used by the Hive Planetoid + private static int[] FocusLootHoney = new int[] + { + ItemID.NaturesGift, + ItemID.Bezoar, + ItemID.FlowerBoots, + ItemID.BeeMinecart + }; + + private static int[] PotionLootHoney = new int[] + { + ItemID.LifeforcePotion, + ItemID.RegenerationPotion, + ItemID.ManaRegenerationPotion, + ItemID.HeartreachPotion, + ModContent.ItemType() + }; + + private static int[] BarLootHoney = new int[] + { + WorldGen.silverBar == TileID.Silver ? ItemID.SilverBar : ItemID.TungstenBar, + WorldGen.goldBar == TileID.Gold ? ItemID.GoldBar : ItemID.PlatinumBar + }; + + public static void FillHoneyChest(int id, UnifiedRandom random) + { + if (id < 0) + return; + + Chest chest = Main.chest[id]; + if (chest == null) + return; + + int index = 0; + + chest.item[index++].SetDefaults(random.Next(FocusLootHoney)); + + if (random.Next(3) <= 1) + { + chest.item[index].SetDefaults(random.Next(BarLootHoney)); + chest.item[index].SetDefaults(random.Next(7, 15)); + } + else + { + chest.item[index].SetDefaults(ItemID.GoldCoin); + chest.item[index++].stack = random.Next(3, 5); + } + + if (random.NextBool()) + { + chest.item[index].SetDefaults(random.Next(PotionLootHoney)); + chest.item[index++].stack = random.Next(1, 4); + } + else + { + chest.item[index].SetDefaults(ItemID.BottledHoney); + chest.item[index++].stack = random.Next(3, 7); + } + + if (random.NextBool()) + { + chest.item[index].SetDefaults(ItemID.Stinger); + chest.item[index++].stack = random.Next(4, 6); + } + else + { + chest.item[index].SetDefaults(ItemID.JungleSpores); + chest.item[index++].stack = random.Next(3, 5); + } + + if (random.NextBool()) + { + chest.item[index].SetDefaults(ItemID.RecallPotion); + chest.item[index++].stack = random.Next(1, 4); + } + else + { + chest.item[index].SetDefaults(ItemID.JungleTorch); + chest.item[index++].stack = random.Next(18, 36); + } + } + } +} diff --git a/World/MiscWorldgenRoutines.cs b/World/MiscWorldgenRoutines.cs index 46f5379641..ab1a5d1412 100644 --- a/World/MiscWorldgenRoutines.cs +++ b/World/MiscWorldgenRoutines.cs @@ -12,12 +12,14 @@ using CalamityMod.Walls; using Microsoft.Xna.Framework; using System; using System.Reflection; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.IO; using Terraria.ModLoader; using Terraria.Utilities; using Terraria.WorldBuilding; +using Terraria.GameContent.Generation; namespace CalamityMod.World { @@ -177,547 +179,6 @@ namespace CalamityMod.World } #endregion - #region Giant Hive - /*public static void GrowLivingMahoganyTree(Point origin) - { - - }*/ - - public static bool CanPlaceGiantHive(Point origin, StructureMap structures) - { - if (!structures.CanPlace(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100))) - return false; - - if (TooCloseToImportantLocations(origin)) - return false; - - Ref ref1 = new Ref(0); - Ref ref2 = new Ref(0); - Ref ref3 = new Ref(0); - WorldUtils.Gen(origin, new Shapes.Circle(15), Actions.Chain(new Modifiers.IsSolid(), new Actions.Scanner(ref1), new Modifiers.OnlyTiles(TileID.JungleGrass, TileID.Mud), new Actions.Scanner(ref2), new Modifiers.OnlyTiles(TileID.JungleGrass), new Actions.Scanner(ref3))); - if (ref2.Value / (float)ref1.Value < 0.75f || ref3.Value < 2) - return false; - - // Detects where to play the living mahogany tree - /*int treeGenMaxAttempts = 100; - int treeGenAttempts = 0; - Point result; - do - { - bool canGenerateLivingTree = WorldUtils.Find(origin, Searches.Chain(new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()), out result); - if (!canGenerateLivingTree) - { - treeGenAttempts++; - } - else - { - result.Y += origin.Y - (int)WorldGen.worldSurface; - - bool[] tileArray = new bool[TileID.Sets.GeneralPlacementTiles.Length]; - for (int i = 0; i < tileArray.Length; i++) - tileArray[i] = TileID.Sets.GeneralPlacementTiles[i]; - - tileArray[TileID.Containers] = false; - tileArray[TileID.Containers2] = false; - - if (!structures.CanPlace(new Rectangle(origin.X - 8, result.Y + 10, 16, origin.Y - result.Y - 9), tileArray, 2)) - { - treeGenAttempts++; - } - else - { - GrowLivingMahoganyTree(new Point(origin.X, origin.Y - result.Y - 9)); - break; - } - } - - if (treeGenAttempts == treeGenMaxAttempts) - return false; - } - while (treeGenAttempts < treeGenMaxAttempts);*/ - - int num = 0; - int[] array = new int[1000]; - int[] array2 = new int[1000]; - Vector2 larvaLocation = origin.ToVector2(); - int numHiveTunnels = WorldGen.genRand.Next(10, 13); - - for (int i = 0; i < numHiveTunnels; i++) - { - Vector2 vector2 = larvaLocation; - int num3 = WorldGen.genRand.Next(2, 5); - for (int j = 0; j < num3; j++) - vector2 = CreateHiveTunnel((int)larvaLocation.X, (int)larvaLocation.Y, WorldGen.genRand); - - larvaLocation = vector2; - array[num] = (int)larvaLocation.X; - array2[num] = (int)larvaLocation.Y; - num++; - } - - FrameOutAllHiveContents(origin, 50); - - for (int k = 0; k < num; k++) - { - int num4 = array[k]; - int y = array2[k]; - int num5 = 1; - if (WorldGen.genRand.NextBool()) - num5 = -1; - - bool flag = false; - while (WorldGen.InWorld(num4, y, 10) && BadSpotForHoneyFall(num4, y)) - { - num4 += num5; - if (Math.Abs(num4 - array[k]) > 50) - { - flag = true; - break; - } - } - - if (!flag) - { - num4 += num5; - if (!SpotActuallyNotInHive(num4, y)) - { - CreateBlockedHoneyCube(num4, y); - CreateDentForHoneyFall(num4, y, num5); - } - } - } - - CreateStandForLarva(larvaLocation); - - // Generate a second larva stand - Vector2 secondLarvaLocation = default; - int maxAttempts = 1000; - for (int l = 0; l < maxAttempts; l++) - { - Vector2 vector3 = larvaLocation; - vector3.X += WorldGen.genRand.Next(-50, 51); - vector3.Y += WorldGen.genRand.Next(-50, 51); - if (WorldGen.InWorld((int)vector3.X, (int)vector3.Y) && Vector2.Distance(larvaLocation, vector3) > 10f && !Main.tile[(int)vector3.X, (int)vector3.Y].HasTile && Main.tile[(int)vector3.X, (int)vector3.Y].WallType == WallID.HiveUnsafe) - { - secondLarvaLocation = vector3; - CreateStandForLarva(vector3); - break; - } - } - - // Honey chests - Vector2 honeyChestLocation = default; - for (int l = 0; l < maxAttempts; l++) - { - Vector2 vector3 = larvaLocation; - vector3.X += WorldGen.genRand.Next(-100, 101); - vector3.Y += WorldGen.genRand.Next(-100, 101); - if (WorldGen.InWorld((int)vector3.X, (int)vector3.Y) && Vector2.Distance(larvaLocation, vector3) > 10f && Vector2.Distance(secondLarvaLocation, vector3) > 10f && !Main.tile[(int)vector3.X, (int)vector3.Y].HasTile && Main.tile[(int)vector3.X, (int)vector3.Y].WallType == WallID.HiveUnsafe) - { - honeyChestLocation = vector3; - CreateStandAndPlaceHoneyChest(vector3); - break; - } - } - for (int l = 0; l < maxAttempts; l++) - { - Vector2 vector3 = larvaLocation; - vector3.X += WorldGen.genRand.Next(-100, 101); - vector3.Y += WorldGen.genRand.Next(-100, 101); - if (WorldGen.InWorld((int)vector3.X, (int)vector3.Y) && Vector2.Distance(larvaLocation, vector3) > 10f && Vector2.Distance(secondLarvaLocation, vector3) > 10f && Vector2.Distance(honeyChestLocation, vector3) > 10f && !Main.tile[(int)vector3.X, (int)vector3.Y].HasTile && Main.tile[(int)vector3.X, (int)vector3.Y].WallType == WallID.HiveUnsafe) - { - CreateStandAndPlaceHoneyChest(vector3); - break; - } - } - - structures.AddProtectedStructure(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 5); - return true; - } - - private static void FrameOutAllHiveContents(Point origin, int squareHalfWidth) - { - int num = Math.Max(10, origin.X - squareHalfWidth); - int num2 = Math.Min(Main.maxTilesX - 10, origin.X + squareHalfWidth); - int num3 = Math.Max(10, origin.Y - squareHalfWidth); - int num4 = Math.Min(Main.maxTilesY - 10, origin.Y + squareHalfWidth); - for (int i = num; i < num2; i++) - { - for (int j = num3; j < num4; j++) - { - Tile tile = Main.tile[i, j]; - if (tile.HasTile && tile.TileType == TileID.Hive) - WorldGen.SquareTileFrame(i, j); - - if (tile.WallType == WallID.HiveUnsafe) - WorldGen.SquareWallFrame(i, j); - } - } - } - - private static Vector2 CreateHiveTunnel(int i, int j, UnifiedRandom random) - { - double num = random.Next(20, 26); - float num2 = random.Next(30, 41); - float num3 = Main.maxTilesX / 4200; - num3 = (num3 + 1f) / 2f; - num *= (double)num3; - num2 *= num3; - - double num4 = num; - Vector2 result = default; - result.X = i; - result.Y = j; - Vector2 vector = default; - vector.X = random.Next(-10, 11) * 0.2f; - vector.Y = random.Next(-10, 11) * 0.2f; - while (num > 0.0 && num2 > 0f) - { - if (result.Y > (Main.maxTilesY - 250)) - num2 = 0f; - - num = num4 * (double)(1f + random.Next(-20, 20) * 0.01f); - num2 -= 1f; - int num5 = (int)(result.X - num); - int num6 = (int)(result.X + num); - int num7 = (int)(result.Y - num); - int num8 = (int)(result.Y + num); - if (num5 < 1) - num5 = 1; - - if (num6 > Main.maxTilesX - 1) - num6 = Main.maxTilesX - 1; - - if (num7 < 1) - num7 = 1; - - if (num8 > Main.maxTilesY - 1) - num8 = Main.maxTilesY - 1; - - for (int k = num5; k < num6; k++) - { - for (int l = num7; l < num8; l++) - { - if (!WorldGen.InWorld(k, l, 50)) - { - num2 = 0f; - } - else - { - if (Main.tile[k - 10, l].WallType == WallID.LihzahrdBrickUnsafe) - num2 = 0f; - - if (Main.tile[k + 10, l].WallType == WallID.LihzahrdBrickUnsafe) - num2 = 0f; - - if (Main.tile[k, l - 10].WallType == WallID.LihzahrdBrickUnsafe) - num2 = 0f; - - if (Main.tile[k, l + 10].WallType == WallID.LihzahrdBrickUnsafe) - num2 = 0f; - } - - if (l < Main.worldSurface && Main.tile[k, l - 5].WallType == WallID.None) - num2 = 0f; - - float num9 = Math.Abs(k - result.X); - float num10 = Math.Abs(l - result.Y); - double num11 = Math.Sqrt(num9 * num9 + num10 * num10); - if (num11 < num4 * 0.4 * (1.0 + random.Next(-10, 11) * 0.005)) - { - Main.tile[k, l].LiquidAmount = byte.MaxValue; - Main.tile[k, l].Get().LiquidType = LiquidID.Honey; - Main.tile[k, l].WallType = WallID.HiveUnsafe; - Main.tile[k, l].Get().HasTile = false; - Main.tile[k, l].Get().IsHalfBlock = false; - Main.tile[k, l].Get().Slope = SlopeType.Solid; - } - else if (num11 < num4 * 0.75 * (1.0 + random.Next(-10, 11) * 0.005)) - { - Main.tile[k, l].LiquidAmount = 0; - if (Main.tile[k, l].WallType != WallID.HiveUnsafe) - { - Main.tile[k, l].Get().HasTile = true; - Main.tile[k, l].Get().IsHalfBlock = false; - Main.tile[k, l].Get().Slope = SlopeType.Solid; - Main.tile[k, l].TileType = TileID.Hive; - } - } - - if (num11 < num4 * 0.6 * (1.0 + random.Next(-10, 11) * 0.005)) - { - Main.tile[k, l].WallType = WallID.HiveUnsafe; - if (random.NextBool()) - { - Main.tile[k, l].LiquidAmount = byte.MaxValue; - Main.tile[k, l].Get().LiquidType = LiquidID.Honey; - } - } - } - } - - result += vector; - num2 -= 1f; - vector.Y += random.Next(-10, 11) * 0.05f; - vector.X += random.Next(-10, 11) * 0.05f; - } - - return result; - } - - private static bool TooCloseToImportantLocations(Point origin) - { - int x = origin.X; - int y = origin.Y; - int num = 150; - for (int i = x - num; i < x + num; i += 10) - { - if (i <= 0 || i > Main.maxTilesX - 1) - continue; - - for (int j = y - num; j < y + num; j += 10) - { - if (j > 0 && j <= Main.maxTilesY - 1) - { - if (Main.tile[i, j].HasTile && Main.tile[i, j].TileType == TileID.LihzahrdBrick) - return true; - - if (Main.tile[i, j].WallType == WallID.CrimstoneUnsafe || Main.tile[i, j].WallType == WallID.EbonstoneUnsafe || Main.tile[i, j].WallType == WallID.LihzahrdBrickUnsafe) - return true; - } - } - } - - return false; - } - - private static void CreateDentForHoneyFall(int x, int y, int dir) - { - dir *= -1; - y++; - int num = 0; - while ((num < 4 || WorldGen.SolidTile(x, y)) && x > 10 && x < Main.maxTilesX - 10) - { - num++; - x += dir; - if (WorldGen.SolidTile(x, y)) - { - WorldGen.PoundTile(x, y); - if (!Main.tile[x, y + 1].HasTile) - { - Main.tile[x, y + 1].Get().HasTile = true; - Main.tile[x, y + 1].TileType = TileID.Hive; - } - } - } - } - - private static void CreateBlockedHoneyCube(int x, int y) - { - for (int i = x - 1; i <= x + 2; i++) - { - for (int j = y - 1; j <= y + 2; j++) - { - if (i >= x && i <= x + 1 && j >= y && j <= y + 1) - { - Main.tile[i, j].Get().HasTile = false; - Main.tile[i, j].LiquidAmount = byte.MaxValue; - Main.tile[i, j].Get().LiquidType = LiquidID.Honey; - } - else - { - Main.tile[i, j].Get().HasTile = true; - Main.tile[i, j].TileType = TileID.Hive; - } - } - } - } - - private static bool SpotActuallyNotInHive(int x, int y) - { - for (int i = x - 1; i <= x + 2; i++) - { - for (int j = y - 1; j <= y + 2; j++) - { - if (i < 10 || i > Main.maxTilesX - 10) - return true; - - if (Main.tile[i, j].HasTile && Main.tile[i, j].TileType != TileID.Hive) - return true; - } - } - - return false; - } - - private static bool BadSpotForHoneyFall(int x, int y) - { - if (Main.tile[x, y].HasTile && Main.tile[x, y + 1].HasTile && Main.tile[x + 1, y].HasTile) - return !Main.tile[x + 1, y + 1].HasTile; - - return true; - } - - public static void CreateStandForLarva(Vector2 position) - { - WorldGen.larvaX[WorldGen.numLarva] = Utils.Clamp((int)position.X, 5, Main.maxTilesX - 5); - WorldGen.larvaY[WorldGen.numLarva] = Utils.Clamp((int)position.Y, 5, Main.maxTilesY - 5); - WorldGen.numLarva++; - if (WorldGen.numLarva >= WorldGen.larvaX.Length) - WorldGen.numLarva = WorldGen.larvaX.Length - 1; - - int num = (int)position.X; - int num2 = (int)position.Y; - for (int i = num - 1; i <= num + 1 && i > 0 && i < Main.maxTilesX; i++) - { - for (int j = num2 - 2; j <= num2 + 1 && j > 0 && j < Main.maxTilesY; j++) - { - if (j != num2 + 1) - { - Main.tile[i, j].Get().HasTile = false; - continue; - } - - Main.tile[i, j].Get().HasTile = true; - Main.tile[i, j].TileType = TileID.Hive; - Main.tile[i, j].Get().Slope = SlopeType.Solid; - Main.tile[i, j].Get().IsHalfBlock = false; - } - } - } - - public static void CreateStandAndPlaceHoneyChest(Vector2 position) - { - int chestPlacementX = Utils.Clamp((int)position.X, 5, Main.maxTilesX - 5); - int chestPlacementY = Utils.Clamp((int)position.Y, 5, Main.maxTilesY - 5); - - int num = (int)position.X; - int num2 = (int)position.Y; - for (int i = num; i <= num + 1 && i > 0 && i < Main.maxTilesX; i++) - { - for (int j = num2 - 1; j <= num2 + 1 && j > 0 && j < Main.maxTilesY; j++) - { - if (j != num2 + 1) - { - Main.tile[i, j].Get().HasTile = false; - continue; - } - - Main.tile[i, j].Get().HasTile = true; - Main.tile[i, j].TileType = TileID.Hive; - Main.tile[i, j].Get().Slope = SlopeType.Solid; - Main.tile[i, j].Get().IsHalfBlock = false; - } - } - - int num144 = chestPlacementX; - int num145 = chestPlacementY; - for (int num146 = num144; num146 <= num144 + 1; num146++) - { - for (int num147 = num145 - 1; num147 <= num145 + 1; num147++) - { - if (num147 != num145 + 1) - { - Main.tile[num146, num147].Get().HasTile = false; - } - else - { - Main.tile[num146, num147].Get().HasTile = true; - Main.tile[num146, num147].TileType = TileID.Hive; - Main.tile[num146, num147].Get().Slope = SlopeType.Solid; - Main.tile[num146, num147].Get().IsHalfBlock = false; - } - } - } - - int chestID = WorldGen.PlaceChest(num144, num145, 21, false, 29); - FillHoneyChest(chestID, WorldGen.genRand); - } - - // Honey chest stuff, this is also used by the Hive Planetoid - private static int[] FocusLootHoney = new int[] - { - ItemID.NaturesGift, - ItemID.Bezoar, - ItemID.FlowerBoots, - ItemID.BeeMinecart - }; - - private static int[] PotionLootHoney = new int[] - { - ItemID.LifeforcePotion, - ItemID.RegenerationPotion, - ItemID.ManaRegenerationPotion, - ItemID.HeartreachPotion, - ModContent.ItemType() - }; - - private static int[] BarLootHoney = new int[] - { - WorldGen.silverBar == TileID.Silver ? ItemID.SilverBar : ItemID.TungstenBar, - WorldGen.goldBar == TileID.Gold ? ItemID.GoldBar : ItemID.PlatinumBar - }; - - public static void FillHoneyChest(int id, UnifiedRandom random) - { - if (id < 0) - return; - - Chest chest = Main.chest[id]; - if (chest == null) - return; - - int index = 0; - - chest.item[index++].SetDefaults(random.Next(FocusLootHoney)); - - if (random.Next(3) <= 1) - { - chest.item[index].SetDefaults(random.Next(BarLootHoney)); - chest.item[index].SetDefaults(random.Next(7, 15)); - } - else - { - chest.item[index].SetDefaults(ItemID.GoldCoin); - chest.item[index++].stack = random.Next(3, 5); - } - - if (random.NextBool()) - { - chest.item[index].SetDefaults(random.Next(PotionLootHoney)); - chest.item[index++].stack = random.Next(1, 4); - } - else - { - chest.item[index].SetDefaults(ItemID.BottledHoney); - chest.item[index++].stack = random.Next(3, 7); - } - - if (random.NextBool()) - { - chest.item[index].SetDefaults(ItemID.Stinger); - chest.item[index++].stack = random.Next(4, 6); - } - else - { - chest.item[index].SetDefaults(ItemID.JungleSpores); - chest.item[index++].stack = random.Next(3, 5); - } - - if (random.NextBool()) - { - chest.item[index].SetDefaults(ItemID.RecallPotion); - chest.item[index++].stack = random.Next(1, 4); - } - else - { - chest.item[index].SetDefaults(ItemID.JungleTorch); - chest.item[index++].stack = random.Next(18, 36); - } - - } - #endregion - #region Place Rox Shrine public static void PlaceRoxShrine() { diff --git a/World/Planets/MudPlanet.cs b/World/Planets/MudPlanet.cs index 2bcf890cd9..b7d2e063ed 100644 --- a/World/Planets/MudPlanet.cs +++ b/World/Planets/MudPlanet.cs @@ -119,7 +119,7 @@ namespace CalamityMod.World.Planets } //Place chest int chestID = WorldGen.PlaceChest(testX, testY + 1, 21, false, 29); - MiscWorldgenRoutines.FillHoneyChest(chestID, WorldGen.genRand); + GiantHive.FillHoneyChest(chestID, WorldGen.genRand); placedChest = true; } } diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index 3268e447d4..1bf4a4ae16 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -696,7 +696,9 @@ namespace CalamityMod.World else if (tileAtPosition.HasTile && ValidBeachCovertTiles.Contains(tileAtPosition.TileType) && WorldGen.genRand.NextFloat() >= ditherChance) Main.tile[x, y].TileType = sandID; - if (tileAtPosition.WallType > WallID.None) + //do not replace dungeon walls ever + int[] DungeonWalls = { 7, 94, 95, 8, 98, 99, 9, 96, 97 }; + if (tileAtPosition.WallType > WallID.None && !DungeonWalls.Contains(tileAtPosition.TileType)) Main.tile[x, y].WallType = wallID; } } diff --git a/World/UndergroundShrines.cs b/World/UndergroundShrines.cs index f3cc1fc8ed..7d653411d2 100644 --- a/World/UndergroundShrines.cs +++ b/World/UndergroundShrines.cs @@ -500,7 +500,7 @@ namespace CalamityMod.World canGenerateInLocation = false; //Only generated within the area of mushroom plants - if (tile.TileType == TileID.MushroomPlants || tile.TileType == TileID.MushroomVines || tile.TileType == TileID.MushroomTrees) + if (tile.TileType == TileID.MushroomGrass || tile.TileType == TileID.MushroomPlants || tile.TileType == TileID.MushroomVines || tile.TileType == TileID.MushroomTrees) realMushroomsInArea++; } }