diff --git a/Backgrounds/AstralDesertSurfaceBGStyle.cs b/Backgrounds/AstralDesertSurfaceBGStyle.cs new file mode 100644 index 0000000000..836e06f0bc --- /dev/null +++ b/Backgrounds/AstralDesertSurfaceBGStyle.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Backgrounds +{ + public class AstralDesertSurfaceBGStyle : ModSurfaceBgStyle + { + public override int ChooseFarTexture() + { + return mod.GetBackgroundSlot("Backgrounds/AstralDesertSurfaceFar"); + } + public override int ChooseMiddleTexture() + { + return mod.GetBackgroundSlot("Backgrounds/AstralDesertSurfaceMiddle"); + } + public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) + { + b -= 75f; + return mod.GetBackgroundSlot("Backgrounds/AstralDesertSurfaceClose"); + } + + public override bool ChooseBgStyle() + { + return !Main.gameMenu && Main.LocalPlayer.GetModPlayer(mod).ZoneAstral && Main.LocalPlayer.ZoneDesert; + } + + public override void ModifyFarFades(float[] fades, float transitionSpeed) + { + //This just fades in the background and fades out other backgrounds. + for (int i = 0; i < fades.Length; i++) + { + if (i == Slot) + { + fades[i] += transitionSpeed; + if (fades[i] > 1f) + { + fades[i] = 1f; + } + } + else + { + fades[i] -= transitionSpeed; + if (fades[i] < 0f) + { + fades[i] = 0f; + } + } + } + } + } +} diff --git a/Backgrounds/AstralDesertSurfaceClose.png b/Backgrounds/AstralDesertSurfaceClose.png new file mode 100644 index 0000000000..c96ebe2cfd Binary files /dev/null and b/Backgrounds/AstralDesertSurfaceClose.png differ diff --git a/Backgrounds/AstralDesertSurfaceFar.png b/Backgrounds/AstralDesertSurfaceFar.png new file mode 100644 index 0000000000..a2337a7d8f Binary files /dev/null and b/Backgrounds/AstralDesertSurfaceFar.png differ diff --git a/Backgrounds/AstralDesertSurfaceMiddle.png b/Backgrounds/AstralDesertSurfaceMiddle.png new file mode 100644 index 0000000000..6b5c33dee8 Binary files /dev/null and b/Backgrounds/AstralDesertSurfaceMiddle.png differ diff --git a/Backgrounds/AstralSnowSurfaceBGStyle.cs b/Backgrounds/AstralSnowSurfaceBGStyle.cs new file mode 100644 index 0000000000..633029074f --- /dev/null +++ b/Backgrounds/AstralSnowSurfaceBGStyle.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Backgrounds +{ + public class AstralSnowSurfaceBGStyle : ModSurfaceBgStyle + { + public override int ChooseFarTexture() + { + return mod.GetBackgroundSlot("Backgrounds/AstralSnowSurfaceFar"); + } + public override int ChooseMiddleTexture() + { + return mod.GetBackgroundSlot("Backgrounds/AstralSnowSurfaceMiddle"); + } + public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) + { + return mod.GetBackgroundSlot("Backgrounds/AstralSurfaceClose"); + } + + public override bool ChooseBgStyle() + { + return !Main.gameMenu && Main.LocalPlayer.GetModPlayer(mod).ZoneAstral && Main.LocalPlayer.ZoneSnow; + } + + public override void ModifyFarFades(float[] fades, float transitionSpeed) + { + //This just fades in the background and fades out other backgrounds. + for (int i = 0; i < fades.Length; i++) + { + if (i == Slot) + { + fades[i] += transitionSpeed; + if (fades[i] > 1f) + { + fades[i] = 1f; + } + } + else + { + fades[i] -= transitionSpeed; + if (fades[i] < 0f) + { + fades[i] = 0f; + } + } + } + } + } +} diff --git a/Backgrounds/AstralSnowSurfaceFar.png b/Backgrounds/AstralSnowSurfaceFar.png new file mode 100644 index 0000000000..e1b3614aa8 Binary files /dev/null and b/Backgrounds/AstralSnowSurfaceFar.png differ diff --git a/Backgrounds/AstralSnowSurfaceMiddle.png b/Backgrounds/AstralSnowSurfaceMiddle.png new file mode 100644 index 0000000000..fc7c678756 Binary files /dev/null and b/Backgrounds/AstralSnowSurfaceMiddle.png differ diff --git a/Backgrounds/AstralSurfaceBGStyle.cs b/Backgrounds/AstralSurfaceBGStyle.cs new file mode 100644 index 0000000000..963a102679 --- /dev/null +++ b/Backgrounds/AstralSurfaceBGStyle.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Backgrounds +{ + public class AstralSurfaceBGStyle : ModSurfaceBgStyle + { + public override int ChooseFarTexture() + { + return mod.GetBackgroundSlot("Backgrounds/AstralSurfaceFar"); + } + public override int ChooseMiddleTexture() + { + return mod.GetBackgroundSlot("Backgrounds/AstralSurfaceMiddle"); + } + public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) + { + scale *= 0.75f; + return mod.GetBackgroundSlot("Backgrounds/AstralSurfaceClose"); + } + + public override bool ChooseBgStyle() + { + return !Main.gameMenu && Main.LocalPlayer.GetModPlayer(mod).ZoneAstral && !Main.LocalPlayer.ZoneDesert && !Main.LocalPlayer.ZoneSnow; + } + + public override void ModifyFarFades(float[] fades, float transitionSpeed) + { + //This just fades in the background and fades out other backgrounds. + for (int i = 0; i < fades.Length; i++) + { + if (i == Slot) + { + fades[i] += transitionSpeed; + if (fades[i] > 1f) + { + fades[i] = 1f; + } + } + else + { + fades[i] -= transitionSpeed; + if (fades[i] < 0f) + { + fades[i] = 0f; + } + } + } + } + } +} diff --git a/Backgrounds/AstralSurfaceClose.png b/Backgrounds/AstralSurfaceClose.png new file mode 100644 index 0000000000..6701b9a71c Binary files /dev/null and b/Backgrounds/AstralSurfaceClose.png differ diff --git a/Backgrounds/AstralSurfaceFar.png b/Backgrounds/AstralSurfaceFar.png new file mode 100644 index 0000000000..9285cefdae Binary files /dev/null and b/Backgrounds/AstralSurfaceFar.png differ diff --git a/Backgrounds/AstralSurfaceMiddle.png b/Backgrounds/AstralSurfaceMiddle.png new file mode 100644 index 0000000000..89b568c3be Binary files /dev/null and b/Backgrounds/AstralSurfaceMiddle.png differ diff --git a/Backgrounds/AstralUG0.png b/Backgrounds/AstralUG0.png new file mode 100644 index 0000000000..1696af2e5d Binary files /dev/null and b/Backgrounds/AstralUG0.png differ diff --git a/Backgrounds/AstralUG1.png b/Backgrounds/AstralUG1.png new file mode 100644 index 0000000000..08180383d6 Binary files /dev/null and b/Backgrounds/AstralUG1.png differ diff --git a/Backgrounds/AstralUG2.png b/Backgrounds/AstralUG2.png new file mode 100644 index 0000000000..e3ebba44ed Binary files /dev/null and b/Backgrounds/AstralUG2.png differ diff --git a/Backgrounds/AstralUG3.png b/Backgrounds/AstralUG3.png new file mode 100644 index 0000000000..131f2342fc Binary files /dev/null and b/Backgrounds/AstralUG3.png differ diff --git a/Backgrounds/AstralUndergroungBGStyle.cs b/Backgrounds/AstralUndergroungBGStyle.cs new file mode 100644 index 0000000000..c27aa839c7 --- /dev/null +++ b/Backgrounds/AstralUndergroungBGStyle.cs @@ -0,0 +1,21 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Backgrounds +{ + public class ExampleUgBgStyle : ModUgBgStyle + { + public override bool ChooseBgStyle() + { + return Main.LocalPlayer.GetModPlayer().ZoneAstral; + } + + public override void FillTextureArray(int[] textureSlots) + { + textureSlots[0] = mod.GetBackgroundSlot("Backgrounds/AstralUG0"); + textureSlots[1] = mod.GetBackgroundSlot("Backgrounds/AstralUG1"); + textureSlots[2] = mod.GetBackgroundSlot("Backgrounds/AstralUG2"); + textureSlots[3] = mod.GetBackgroundSlot("Backgrounds/AstralUG3"); + } + } +} \ No newline at end of file diff --git a/Backgrounds/MapBackgrounds/AstralBG.png b/Backgrounds/MapBackgrounds/AstralBG.png new file mode 100644 index 0000000000..e277bdefc1 Binary files /dev/null and b/Backgrounds/MapBackgrounds/AstralBG.png differ diff --git a/CalamityMod.cs b/CalamityMod.cs index d1258858c8..7ce60b42f6 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -26,6 +26,7 @@ using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.Polterghast; using CalamityMod.Tiles; using CalamityMod.UI; +using CalamityMod.Skies; namespace CalamityMod { @@ -64,8 +65,16 @@ namespace CalamityMod public static Texture2D manaOriginal; public static Texture2D carpetOriginal; + + public static Texture2D AstralCactusTexture; + + public static Texture2D AstralCactusGlowTexture; + + public static Texture2D AstralSky; public static CalamityMod Instance; + + public static Effect CustomShader; public CalamityMod() { @@ -110,6 +119,11 @@ namespace CalamityMod AddEquipTexture(new Items.Armor.SirenHeadAlt(), null, EquipType.Head, "SirenHeadAlt", "CalamityMod/Items/Armor/SirenTransAlt_Head"); AddEquipTexture(new Items.Armor.SirenBodyAlt(), null, EquipType.Body, "SirenBodyAlt", "CalamityMod/Items/Armor/SirenTransAlt_Body", "CalamityMod/Items/Armor/SirenTransAlt_Arms"); AddEquipTexture(new Items.Armor.SirenLegsAlt(), null, EquipType.Legs, "SirenLegAlt", "CalamityMod/Items/Armor/SirenTransAlt_Legs"); + + AstralCactusTexture = GetTexture("ExtraTextures/Tiles/AstralCactus"); + AstralCactusGlowTexture = GetTexture("ExtraTextures/Tiles/AstralCactusGlow"); + AstralSky = GetTexture("ExtraTextures/AstralSky"); + CustomShader = GetEffect("Effects/CustomShader"); AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Cryogen"), ItemType("CryogenMusicbox"), TileType("CryogenMusicbox")); AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Calamitas"), ItemType("CalamitasMusicbox"), TileType("CalamitasMusicbox")); @@ -119,7 +133,7 @@ namespace CalamityMod AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/PlaguebringerGoliath"), ItemType("PlaguebringerMusicbox"), TileType("PlaguebringerMusicbox")); AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/AquaticScourge"), ItemType("AquaticScourgeMusicbox"), TileType("AquaticScourgeMusicbox")); AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Astrageldon"), ItemType("AstrageldonMusicbox"), TileType("AstrageldonMusicbox")); - AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Astral"), ItemType("AstralMusicbox"), TileType("AstralMusicbox")); + //AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Astral"), ItemType("AstralMusicbox"), TileType("AstralMusicbox")); AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/RUIN"), ItemType("PolterghastMusicbox"), TileType("PolterghastMusicbox")); AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Signus"), ItemType("SignusMusicbox"), TileType("SignusMusicbox")); AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Weaver"), ItemType("StormWeaverMusicbox"), TileType("StormWeaverMusicbox")); @@ -132,6 +146,7 @@ namespace CalamityMod AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/ProvidenceTheme"), ItemType("ProvidenceMusicbox"), TileType("ProvidenceMusicbox")); AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Guardians"), ItemType("ProfanedGuardianMusicbox"), TileType("ProfanedGuardianMusicbox")); AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Ravager"), ItemType("RavagerMusicbox"), TileType("RavagerMusicbox")); + AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Astral"), ItemType("AstralSurfaceMusicBox"), TileType("AstralSurfaceMusicBox")); Filters.Scene["CalamityMod:DevourerofGodsHead"] = new Filter(new DoGScreenShaderData("FilterMiniTower").UseColor(0.4f, 0.1f, 1.0f).UseOpacity(0.5f), EffectPriority.VeryHigh); SkyManager.Instance["CalamityMod:DevourerofGodsHead"] = new DoGSky(); @@ -156,6 +171,9 @@ namespace CalamityMod Filters.Scene["CalamityMod:SupremeCalamitas"] = new Filter(new SCalScreenShaderData("FilterMiniTower").UseColor(1.1f, 0.3f, 0.3f).UseOpacity(0.65f), EffectPriority.VeryHigh); SkyManager.Instance["CalamityMod:SupremeCalamitas"] = new SCalSky(); + + Filters.Scene["CalamityMod:Astral"] = new Filter(new AstralScreenShaderData(new Ref(CustomShader), "AstralPass").UseColor(0.18f, 0.08f, 0.24f), EffectPriority.VeryHigh); + SkyManager.Instance["CalamityMod:Astral"] = new AstralSky(); Mod mod = ModLoader.GetMod("CalamityMod"); UIHandler.OnLoad(mod); @@ -559,6 +577,9 @@ namespace CalamityMod public override void Unload() { + AstralCactusTexture = null; + AstralCactusGlowTexture = null; + AstralSky = null; RageHotKey = null; AdrenalineHotKey = null; AegisHotKey = null; @@ -620,6 +641,10 @@ namespace CalamityMod { music = mod.GetSoundSlot(SoundType.Music, "Sounds/Music/UniversalCollapse"); priority = MusicPriority.BossMedium; } + if (Main.LocalPlayer.GetModPlayer(this).ZoneAstral) + { + if (!CalamityGlobalNPC.AnyBossNPCS()) { music = GetSoundSlot(SoundType.Music, "Sounds/Music/Astral"); priority = MusicPriority.BiomeHigh; } + } } } } diff --git a/CalamityPlayer.cs b/CalamityPlayer.cs index d6774c1ac9..aa2bd608ab 100644 --- a/CalamityPlayer.cs +++ b/CalamityPlayer.cs @@ -1303,13 +1303,15 @@ namespace CalamityMod player.ManageSpecialBiomeVisuals("CalamityMod:Providence", useHoly); bool useSBrimstone = NPC.AnyNPCs(mod.NPCType("SupremeCalamitas")); player.ManageSpecialBiomeVisuals("CalamityMod:SupremeCalamitas", useSBrimstone); + bool inAstral = ZoneAstral; + player.ManageSpecialBiomeVisuals("CalamityMod:Astral", inAstral); } public override void UpdateBiomes() { Point point = player.Center.ToTileCoordinates(); ZoneCalamity = CalamityWorld.calamityTiles > 50; - ZoneAstral = CalamityWorld.astralTiles > 50; + ZoneAstral = CalamityWorld.astralTiles > 950 || (player.ZoneSnow && CalamityWorld.astralTiles > 300); //ZoneGreatSea = CalamityWorld.seaTiles > 30; int x = Main.maxTilesX; @@ -1420,14 +1422,18 @@ namespace CalamityMod ZoneSulphur = flags[7]; } - /*public override Texture2D GetMapBackgroundImage() + public override Texture2D GetMapBackgroundImage() { - if (ZoneSulphur) + /*if (ZoneSulphur) { return mod.GetTexture("Backgrounds/SulphurBG"); + }*/ + if (ZoneAstral) + { + return mod.GetTexture("Backgrounds/MapBackgrounds/AstralBG"); } return null; - }*/ + } #endregion #region InventoryStartup @@ -2502,6 +2508,17 @@ namespace CalamityMod } #endregion + #region PreUpdateBuffs + public override void PreUpdateBuffs() + { + //Remove the mighty wind buff if the player is in the astral desert. + if (player.ZoneDesert && ZoneAstral && player.HasBuff(BuffID.WindPushed)) + { + player.ClearBuff(BuffID.WindPushed); + } + } + #endregion + #region PostUpdateEffects public override void PostUpdateBuffs() { diff --git a/CalamityWorld.cs b/CalamityWorld.cs index 47222c9d51..a99550a347 100644 --- a/CalamityWorld.cs +++ b/CalamityWorld.cs @@ -613,10 +613,19 @@ namespace CalamityMod public override void TileCountsAvailable(int[] tileCounts) { calamityTiles = tileCounts[mod.TileType("CharredOre")] + tileCounts[mod.TileType("BrimstoneSlag")]; - astralTiles = tileCounts[mod.TileType("AstralOre")]; seaTiles = tileCounts[mod.TileType("EutrophicSand")] + tileCounts[mod.TileType("SeaPrism")]; abyssTiles = tileCounts[mod.TileType("AbyssGravel")]; sulphurTiles = tileCounts[mod.TileType("SulphurousSand")]; + + #region Astral Stuff + int astralDesertTiles = tileCounts[mod.TileType("AstralSand")] + tileCounts[mod.TileType("AstralSandstone")] + tileCounts[mod.TileType("HardenedAstralSand")]; + int astralSnowTiles = tileCounts[mod.TileType("AstralIce")]; + + Main.sandTiles += astralDesertTiles; + Main.snowTiles += astralSnowTiles; + + astralTiles = astralDesertTiles + astralSnowTiles + tileCounts[mod.TileType("AstralDirt")] + tileCounts[mod.TileType("AstralStone")] + tileCounts[mod.TileType("AstralGrass")]+ tileCounts[mod.TileType("AstralOre")]; + #endregion } #endregion @@ -1800,10 +1809,588 @@ namespace CalamityMod if (Main.netMode != 1) { NetMessage.SendTileSquare(-1, i, j, 40, TileChangeType.None); + + DoAstralConversion(new Point(i, j)); } return true; } - #endregion + + + + public static void DoAstralConversion(object obj) + { + //Pre-calculate all variables necessary for elliptical area checking + Point origin = (Point)obj; + Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); + + float angle = MathHelper.Pi * 0.15f; + float otherAngle = MathHelper.PiOver2 - angle; + + int distanceInTiles = 150 + ((Main.maxTilesX - 4200) / 4200) * 200; + float distance = distanceInTiles * 16f; + float constant = (distance * 2f) / (float)Math.Sin(angle); + + float fociSpacing = ((distance * (float)Math.Sin(otherAngle)) / (float)Math.Sin(angle)); + int verticalRadius = (int)(constant / 16f); + + Vector2 fociOffset = Vector2.UnitY * fociSpacing; + Vector2 topFoci = center - fociOffset; + Vector2 bottomFoci = center + fociOffset; + + for (int x = origin.X - distanceInTiles - 2; x <= origin.X + distanceInTiles + 2; x++) + { + for (int y = (int)(origin.Y - verticalRadius * 0.4f) - 3; y <= origin.Y + verticalRadius + 3; y++) + { + float dist; + if (CheckInEllipse(new Point(x, y), topFoci, bottomFoci, constant, center, out dist, y < origin.Y)) + { + //If we're in the outer blurPercent% of the ellipse + float percent = dist / constant; + float blurPercent = 0.98f; + if (percent > blurPercent) + { + float outerEdgePercent = (percent - blurPercent) / (1f - blurPercent); + if (Main.rand.NextFloat(1f) > outerEdgePercent) + { + ConvertToAstral(x, y); + } + } + else + { + ConvertToAstral(x, y); + } + } + } + } + } + + public static void ConvertToAstral(int startX, int endX, int startY, int endY) + { + for (int x = startX; x <= endX; x++) + { + for (int y = startY; y <= endY; y++) + { + ConvertToAstral(x, y); + } + } + } + + public static void ConvertToAstral(int x, int y, bool tileframe = true) + { + Mod mod = ModLoader.GetMod("CalamityMod"); + if (WorldGen.InWorld(x, y, 1)) + { + int type = Main.tile[x, y].type; + int wallType = Main.tile[x, y].wall; + + if (WallID.Sets.Conversion.Grass[wallType]) + { + Main.tile[x, y].wall = (ushort)mod.WallType("AstralGrassWallUnsafe"); + } + else if (WallID.Sets.Conversion.HardenedSand[wallType]) + { + Main.tile[x, y].wall = (ushort)mod.WallType("HardenedAstralSandWallUnsafe"); + } + else if (WallID.Sets.Conversion.Sandstone[wallType]) + { + Main.tile[x, y].wall = (ushort)mod.WallType("AstralSandstoneWallUnsafe"); + } + else if (WallID.Sets.Conversion.Stone[wallType]) + { + Main.tile[x, y].wall = (ushort)mod.WallType("AstralStoneWallUnsafe"); + } + else + { + switch (wallType) + { + case WallID.DirtUnsafe: + case WallID.DirtUnsafe1: + case WallID.DirtUnsafe2: + case WallID.DirtUnsafe3: + case WallID.DirtUnsafe4: + case WallID.Cave6Unsafe: + case WallID.Dirt: + Main.tile[x, y].wall = (ushort)mod.WallType("AstralDirtWallUnsafe"); + break; + case WallID.IceUnsafe: + Main.tile[x, y].wall = (ushort)mod.WallType("AstralIceWallUnsafe"); + break; + } + } + + if (TileID.Sets.Conversion.Grass[type] && !TileID.Sets.GrassSpecial[type]) + { + Main.tile[x, y].type = (ushort)mod.TileType("AstralGrass"); + } + else if (TileID.Sets.Conversion.Stone[type] || Main.tileMoss[type]) + { + Main.tile[x, y].type = (ushort)mod.TileType("AstralStone"); + } + else if (TileID.Sets.Conversion.Sand[type]) + { + Main.tile[x, y].type = (ushort)mod.TileType("AstralSand"); + } + else if (TileID.Sets.Conversion.HardenedSand[type]) + { + Main.tile[x, y].type = (ushort)mod.TileType("HardenedAstralSand"); + } + else if (TileID.Sets.Conversion.Sandstone[type]) + { + Main.tile[x, y].type = (ushort)mod.TileType("AstralSandstone"); + } + else if (TileID.Sets.Conversion.Ice[type]) + { + Main.tile[x, y].type = (ushort)mod.TileType("AstralIce"); + } + else + { + Tile tile = Main.tile[x, y]; + switch(type) + { + case TileID.Dirt: + Main.tile[x, y].type = (ushort)mod.TileType("AstralDirt"); + break; + case TileID.Vines: + Main.tile[x, y].type = (ushort)mod.TileType("AstralVines"); + break; + case TileID.LargePiles: + if (tile.frameX <= 1170) + { + RecursiveReplaceToAstral(TileID.LargePiles, (ushort)mod.TileType("AstralNormalLargePiles"), x, y, 324, 0, 1170, 0, 18); + } + if (tile.frameX >= 1728) + { + RecursiveReplaceToAstral(TileID.LargePiles, (ushort)mod.TileType("AstralNormalLargePiles"), x, y, 324, 1728, 1872, 0, 18); + } + if (tile.frameX >= 1404 && tile.frameX <= 1710) + { + RecursiveReplaceToAstral(TileID.LargePiles, (ushort)mod.TileType("AstralIceLargePiles"), x, y, 324, 1404, 1710, 0, 18); + } + break; + case TileID.LargePiles2: + if (tile.frameX >= 1566 && tile.frameY < 36) + { + RecursiveReplaceToAstral(TileID.LargePiles2, (ushort)mod.TileType("AstralDesertLargePiles"), x, y, 324, 1566, 1872, 0, 18); + } + if (tile.frameX >= 756 && tile.frameX <= 900) + { + RecursiveReplaceToAstral(TileID.LargePiles2, (ushort)mod.TileType("AstralNormalLargePiles"), x, y, 324, 756, 900, 0, 18); + } + break; + case TileID.SmallPiles: + if (tile.frameY == 18) + { + ushort newType = 9999; + if (tile.frameX >= 1476 && tile.frameX <= 1674) + { + newType = (ushort)mod.TileType("AstralDesertMediumPiles"); + } + else if (tile.frameX <= 558 || (tile.frameX >= 1368 && tile.frameX <= 1458)) + { + newType = (ushort)mod.TileType("AstralNormalMediumPiles"); + } + else if (tile.frameX >= 900 && tile.frameX <= 1098) + { + newType = (ushort)mod.TileType("AstralIceMediumPiles"); + } + else + { + break; + } + int leftMost = x; + if (tile.frameX % 36 != 0) //this means it's the right tile of the two + { + leftMost--; + } + Main.tile[leftMost, y].type = newType; + Main.tile[leftMost + 1, y].type = newType; + while (Main.tile[leftMost, y].frameX >= 216) + { + Main.tile[leftMost, y].frameX -= 216; + Main.tile[leftMost + 1, y].frameX -= 216; + } + } + else if (tile.frameY == 0) + { + ushort newType3 = 9999; + if (tile.frameX >= 972 && tile.frameX <= 1062) + { + newType3 = (ushort)mod.TileType("AstralDesertSmallPiles"); + } + else if (tile.frameX <= 486) + { + newType3 = (ushort)mod.TileType("AstralNormalSmallPiles"); + } + else if (tile.frameX >= 648 && tile.frameX <= 846) + { + newType3 = (ushort)mod.TileType("AstralIceSmallPiles"); + } + else + { + break; + } + Main.tile[x, y].type = newType3; + while (Main.tile[x, y].frameX >= 108) //REFRAME IT + { + Main.tile[x, y].frameX -= 108; + } + } + break; + case TileID.Stalactite: + int topMost = tile.frameY <= 54 ? (tile.frameY % 36 == 0 ? y : y - 1) : y; + bool twoTall = tile.frameY <= 54; + bool hanging = tile.frameY <= 18 || tile.frameY == 72; + ushort newType2 = 9999; + if (tile.frameX >= 378 && tile.frameX <= 414) //DESERT + { + newType2 = (ushort)mod.TileType("AstralDesertStalactite"); + } + else if ((tile.frameX >= 54 && tile.frameX <= 90) || (tile.frameX >= 216 && tile.frameX <= 360)) + { + newType2 = (ushort)mod.TileType("AstralNormalStalactite"); + } + else if (tile.frameX <= 36) + { + newType2 = (ushort)mod.TileType("AstralIceStalactite"); + } + else + { + break; + } + + //Set types + Main.tile[x, topMost].type = newType2; + if (twoTall) + Main.tile[x, topMost + 1].type = newType2; + + //Fix frames + while (Main.tile[x, topMost].frameX >= 54) + { + Main.tile[x, topMost].frameX -= 54; + if (twoTall) + Main.tile[x, topMost + 1].frameX -= 54; + } + + if (hanging) + { + ConvertToAstral(x, topMost - 1); + break; + } + else + { + if (twoTall) + { + ConvertToAstral(x, topMost + 2); + break; + } + ConvertToAstral(x, topMost + 1); + break; + } + } + } + if (tileframe) + { + if (Main.netMode == 0) + { + WorldGen.SquareTileFrame(x, y, true); + } + else if (Main.netMode == 2) + { + NetMessage.SendTileSquare(-1, x, y, 1); + } + } + } + } + + public static void ConvertFromAstral(int x, int y, ConvertType convert) + { + Tile tile = Main.tile[x, y]; + int type = tile.type; + int wallType = tile.wall; + Mod mod = CalamityMod.Instance; + + if (WorldGen.InWorld(x, y, 1)) + { + #region WALL + if (wallType == mod.WallType("AstralDirtWall")) + { + Main.tile[x, y].wall = WallID.DirtUnsafe; + } + else if (wallType == mod.WallType("AstralGrassWall")) + { + switch (convert) + { + case ConvertType.Corrupt: + Main.tile[x, y].wall = WallID.CorruptGrassUnsafe; + break; + case ConvertType.Crimson: + Main.tile[x, y].wall = WallID.CrimsonGrassUnsafe; + break; + case ConvertType.Hallow: + Main.tile[x, y].wall = WallID.HallowedGrassUnsafe; + break; + case ConvertType.Pure: + Main.tile[x, y].wall = WallID.GrassUnsafe; + break; + } + } + else if (wallType == mod.WallType("AstralIceWall")) + { + Main.tile[x, y].wall = WallID.IceUnsafe; + } + else if (wallType == mod.WallType("AstralStoneWall")) + { + switch (convert) + { + case ConvertType.Corrupt: + Main.tile[x, y].wall = WallID.EbonstoneUnsafe; + break; + case ConvertType.Crimson: + Main.tile[x, y].wall = WallID.CrimstoneUnsafe; + break; + case ConvertType.Hallow: + Main.tile[x, y].wall = WallID.PearlstoneBrickUnsafe; + break; + case ConvertType.Pure: + Main.tile[x, y].wall = WallID.Stone; + break; + } + } + #endregion + + #region TILE + if (type == mod.TileType("AstralDirt")) + { + tile.type = TileID.Dirt; + } + else if (type == mod.TileType("AstralGrass")) + { + SetTileFromConvert(x, y, convert, TileID.CorruptGrass, TileID.FleshGrass, TileID.HallowedGrass, TileID.Grass); + } + else if (type == mod.TileType("AstralStone")) + { + SetTileFromConvert(x, y, convert, TileID.Ebonstone, TileID.Crimstone, TileID.Pearlstone, TileID.Stone); + } + else if (type == mod.TileType("AstralSand")) + { + SetTileFromConvert(x, y, convert, TileID.Ebonsand, TileID.Crimsand, TileID.Pearlsand, TileID.Sand); + } + else if (type == mod.TileType("AstralSandstone")) + { + SetTileFromConvert(x, y, convert, TileID.CorruptSandstone, TileID.CrimsonSandstone, TileID.HallowSandstone, TileID.Sandstone); + } + else if (type == mod.TileType("HardenedAstralSand")) + { + SetTileFromConvert(x, y, convert, TileID.CorruptHardenedSand, TileID.CrimsonHardenedSand, TileID.HallowHardenedSand, TileID.HardenedSand); + } + else if (type == mod.TileType("AstralIce")) + { + SetTileFromConvert(x, y, convert, TileID.CorruptIce, TileID.FleshIce, TileID.HallowedIce, TileID.IceBlock); + } + else if (type == mod.TileType("AstralVines")) + { + SetTileFromConvert(x, y, convert, ushort.MaxValue, TileID.CrimsonVines, TileID.HallowedVines, TileID.Vines); + } + else if (type == mod.TileType("AstralShortPlants")) + { + SetTileFromConvert(x, y, convert, TileID.CorruptPlants, ushort.MaxValue, TileID.HallowedPlants, TileID.Plants); + } + else if (type == mod.TileType("AstralTallPlants")) + { + SetTileFromConvert(x, y, convert, ushort.MaxValue, ushort.MaxValue, TileID.HallowedPlants2, TileID.Plants2); + } + else if (type == mod.TileType("AstralNormalLargePiles")) + { + RecursiveReplaceFromAstral((ushort)type, TileID.LargePiles, x, y, 378, 0); + } + else if (type == mod.TileType("AstralNormalMediumPiles")) + { + RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 0, 18); + } + else if (type == mod.TileType("AstralNormalSmallPiles")) + { + RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 0, 0); + } + else if (type == mod.TileType("AstralDesertLargePiles")) + { + RecursiveReplaceFromAstral((ushort)type, TileID.LargePiles2, x, y, 1566, 0); + } + else if (type == mod.TileType("AstralDesertMediumPiles")) + { + RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 1476, 18); + } + else if (type == mod.TileType("AstralDesertSmallPiles")) + { + RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 972, 0); + } + else if (type == mod.TileType("AstralIceLargePiles")) + { + RecursiveReplaceFromAstral((ushort)type, TileID.LargePiles, x, y, 1404, 0); + } + else if (type == mod.TileType("AstralIceMediumPiles")) + { + RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 900, 18); + } + else if (type == mod.TileType("AstralIceSmallPiles")) + { + RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 648, 0); + } + else if (type == mod.TileType("AstralNormalStalactite")) + { + ushort originType = TileID.Stone; + int frameXAdd = 54; + switch (convert) + { + case ConvertType.Corrupt: + originType = TileID.Ebonstone; + frameXAdd = 324; + break; + case ConvertType.Crimson: + originType = TileID.Crimstone; + frameXAdd = 270; + break; + case ConvertType.Hallow: + originType = TileID.Pearlstone; + frameXAdd = 216; + break; + } + ReplaceAstralStalactite((ushort)type, TileID.Stalactite, originType, x, y, frameXAdd, 0); + } + else if (type == mod.TileType("AstralDesertStalactite")) + { + ushort originType = TileID.Sandstone; + int frameXAdd = 378; + switch (convert) + { + case ConvertType.Corrupt: + originType = TileID.CorruptSandstone; + frameXAdd = 324; + break; + case ConvertType.Crimson: + originType = TileID.CrimsonSandstone; + frameXAdd = 270; + break; + case ConvertType.Hallow: + originType = TileID.HallowSandstone; + frameXAdd = 216; + break; + } + ReplaceAstralStalactite((ushort)type, TileID.Stalactite, originType, x, y, frameXAdd, 0); + } + else if (type == mod.TileType("AstralIceStalactite")) + { + ReplaceAstralStalactite((ushort)type, TileID.Stalactite, TileID.IceBlock, x, y, 0, 0); + } + if (TileID.Sets.Conversion.Grass[type] || type == TileID.Dirt) + { + WorldGen.SquareTileFrame(x, y); + } + #endregion + } + } + + private static void SetTileFromConvert(int x, int y, ConvertType convert, ushort corrupt, ushort crimson, ushort hallow, ushort pure) + { + switch (convert) + { + case ConvertType.Corrupt: + if (corrupt != ushort.MaxValue) + { + Main.tile[x, y].type = corrupt; + WorldGen.SquareTileFrame(x, y); + } + break; + case ConvertType.Crimson: + if (crimson != ushort.MaxValue) + { + Main.tile[x, y].type = crimson; + WorldGen.SquareTileFrame(x, y); + } + break; + case ConvertType.Hallow: + if (hallow != ushort.MaxValue) + { + Main.tile[x, y].type = hallow; + WorldGen.SquareTileFrame(x, y); + } + break; + case ConvertType.Pure: + if (pure != ushort.MaxValue) + { + Main.tile[x, y].type = pure; + WorldGen.SquareTileFrame(x, y); + } + break; + } + } + + private static void RecursiveReplaceToAstral(ushort checkType, ushort replaceType, int x, int y, int replaceTextureWidth, int minFrameX = 0, int maxFrameX = int.MaxValue, int minFrameY = 0, int maxFrameY = int.MaxValue) + { + Tile tile = Main.tile[x, y]; + if (tile == null || !tile.active() || tile.type != checkType || tile.frameX < minFrameX || tile.frameX > maxFrameX || tile.frameY < minFrameY || tile.frameY > maxFrameY) + return; + + Main.tile[x, y].type = replaceType; + while (Main.tile[x, y].frameX >= replaceTextureWidth) + { + Main.tile[x, y].frameX -= (short)replaceTextureWidth; + } + + RecursiveReplaceToAstral(checkType, replaceType, x - 1, y, replaceTextureWidth, minFrameX, maxFrameX, minFrameY, maxFrameY); + RecursiveReplaceToAstral(checkType, replaceType, x + 1, y, replaceTextureWidth, minFrameX, maxFrameX, minFrameY, maxFrameY); + RecursiveReplaceToAstral(checkType, replaceType, x, y - 1, replaceTextureWidth, minFrameX, maxFrameX, minFrameY, maxFrameY); + RecursiveReplaceToAstral(checkType, replaceType, x, y + 1, replaceTextureWidth, minFrameX, maxFrameX, minFrameY, maxFrameY); + } + + private static void RecursiveReplaceFromAstral(ushort checkType, ushort replaceType, int x, int y, int addFrameX, int addFrameY) + { + Tile tile = Main.tile[x, y]; + if (tile == null || !tile.active() || tile.type != checkType) + return; + + Main.tile[x, y].type = replaceType; + Main.tile[x, y].frameX += (short)addFrameX; + Main.tile[x, y].frameY += (short)addFrameY; + + RecursiveReplaceFromAstral(checkType, replaceType, x - 1, y, addFrameX, addFrameY); + RecursiveReplaceFromAstral(checkType, replaceType, x + 1, y, addFrameX, addFrameY); + RecursiveReplaceFromAstral(checkType, replaceType, x, y - 1, addFrameX, addFrameY); + RecursiveReplaceFromAstral(checkType, replaceType, x, y + 1, addFrameX, addFrameY); + } + + private static void ReplaceAstralStalactite(ushort checkType, ushort replaceType, ushort replaceOriginTile, int x, int y, int addFrameX, int addFrameY) + { + Tile tile = Main.tile[x, y]; + + int topMost = tile.frameY <= 54 ? (tile.frameY % 36 == 0 ? y : y - 1) : y; + bool twoTall = tile.frameY <= 54; + bool hanging = tile.frameY <= 18 || tile.frameY == 72; + + int yOriginTile = (hanging ? topMost - 1 : (twoTall ? topMost + 2 : y + 1)); + + Main.tile[x, topMost++].type = replaceType; + if (twoTall) + { + Main.tile[x, topMost].type = replaceType; + } + Main.tile[x, yOriginTile].type = replaceOriginTile; + } + + private static bool CheckInEllipse(Point tile, Vector2 focus1, Vector2 focus2, float distanceConstant, Vector2 center, out float distance, bool collapse = false) + { + Vector2 point = tile.ToVector2() * 16f + new Vector2(8f); + if (collapse) //Collapse ensures the ellipse is shrunk down a lot in terms of distance. + { + float distY = center.Y - point.Y; + point.Y -= distY * 8f; + } + float distance1 = Vector2.Distance(point, focus1); + float distance2 = Vector2.Distance(point, focus2); + distance = distance1 + distance2; + return distance <= distanceConstant; + } + + #endregion #region EvilIsland public static void EvilIsland(int i, int j) diff --git a/CustomTileFraming.cs b/CustomTileFraming.cs new file mode 100644 index 0000000000..48d11d0af0 --- /dev/null +++ b/CustomTileFraming.cs @@ -0,0 +1,955 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +using CalamityMod.Tiles; + +namespace CalamityMod +{ + public static class CustomTileFraming + { + private static int[][] PlantCheckAgainst; + private static Dictionary VineToGrass; + public static bool[] tileMergeAstralDirt; + + static CustomTileFraming() + { + Mod mod = CalamityMod.Instance; + + int size = CalamityGlobalTile.PlantTypes.Length; + PlantCheckAgainst = new int[TileLoader.TileCount][]; + + PlantCheckAgainst[TileID.Plants] = new int[3] { TileID.Grass, TileID.PlanterBox, TileID.ClayPot }; + PlantCheckAgainst[TileID.CorruptPlants] = new int[1] { TileID.CorruptGrass }; + PlantCheckAgainst[TileID.JunglePlants] = new int[1] { TileID.JungleGrass }; + PlantCheckAgainst[TileID.MushroomPlants] = new int[1] { TileID.MushroomGrass }; + PlantCheckAgainst[TileID.Plants2] = new int[3] { TileID.Grass, TileID.PlanterBox, TileID.ClayPot }; + PlantCheckAgainst[TileID.JunglePlants2] = new int[1]{ TileID.JungleGrass }; + PlantCheckAgainst[TileID.HallowedPlants] = new int[1] { TileID.HallowedGrass }; + PlantCheckAgainst[TileID.HallowedPlants2] = new int[1] { TileID.HallowedGrass }; + PlantCheckAgainst[TileID.FleshWeeds] = new int[1] { TileID.FleshWeeds }; + PlantCheckAgainst[CalamityMod.Instance.TileType("AstralShortPlants")] = new int[1] { mod.TileType("AstralGrass") }; + PlantCheckAgainst[CalamityMod.Instance.TileType("AstralTallPlants")] = new int[1] { mod.TileType("AstralGrass") }; + + VineToGrass = new Dictionary(); + VineToGrass[TileID.Vines] = TileID.Grass; + VineToGrass[TileID.CrimsonVines] = TileID.FleshGrass; + VineToGrass[TileID.HallowedVines] = TileID.HallowedGrass; + VineToGrass[(ushort)mod.TileType("AstralVines")] = (ushort)mod.TileType("AstralGrass"); + + tileMergeAstralDirt = new bool[TileLoader.TileCount]; + //TODO: REST OF THESE + tileMergeAstralDirt[mod.TileType("AstralOre")] = true; + tileMergeAstralDirt[mod.TileType("AstralStone")] = true; + tileMergeAstralDirt[mod.TileType("AstralSand")] = true; + } + + private static bool PlantNeedsUpdate(int plantType, int checkType) + { + int size = PlantCheckAgainst[plantType].Length; + for (int i = 0; i < size; i++) + { + if (PlantCheckAgainst[plantType][i] == checkType) + { + return false; + } + } + return true; + } + + public static void CheckPlants(int x, int y) + { + int checkType = -1; + int plantType = Main.tile[x, y].type; + + if (y + 1 >= Main.maxTilesY) + checkType = plantType; + + Tile tile = Main.tile[x, y]; + Tile below = Main.tile[x, y + 1]; + if (y + 1 < Main.maxTilesY && below != null && below.nactive() && !below.halfBrick() && below.slope() == 0) + checkType = below.type; + + if (checkType == -1) return; + + //Check if this plant needs an update + if (PlantNeedsUpdate(plantType, checkType)) + { + if ((plantType == TileID.Plants || plantType == TileID.Plants2) && checkType != TileID.Grass && tile.frameX >= 162) + { + Main.tile[x, y].frameX = 126; + } + if (plantType == TileID.JunglePlants2 && checkType != TileID.JungleGrass && tile.frameX >= 162) + { + Main.tile[x, y].frameX = 126; + } + + if (checkType == TileID.CorruptGrass) + { + plantType = TileID.CorruptPlants; + if (tile.frameX >= 162) + { + Main.tile[x, y].frameX = 126; + } + } + else if (checkType == TileID.Grass) + { + if (plantType == TileID.HallowedPlants2) + { + plantType = TileID.Plants2; + } + else + { + plantType = TileID.Plants; + } + } + else if (checkType == TileID.HallowedGrass) + { + if (plantType == TileID.Plants2) + { + plantType = TileID.HallowedPlants2; + } + else + { + plantType = TileID.HallowedPlants; + } + } + else if (checkType == TileID.FleshGrass) + { + plantType = TileID.FleshWeeds; + } + else if (checkType == TileID.MushroomGrass) + { + plantType = TileID.MushroomPlants; + while (Main.tile[x, y].frameX > 72) + { + Main.tile[x, y].frameX -= 72; + } + } + else if (checkType == CalamityMod.Instance.TileType("AstralGrass")) //ASTRAL + { + if (plantType == TileID.Plants || plantType == TileID.CorruptPlants || + plantType == TileID.FleshWeeds || plantType == TileID.HallowedPlants || + plantType == TileID.MushroomPlants || plantType == TileID.JunglePlants) + { + plantType = CalamityMod.Instance.TileType("AstralShortPlants"); + } + else + { + plantType = CalamityMod.Instance.TileType("AstralTallPlants"); + } + } + if (plantType != Main.tile[x, y].type) + { + Main.tile[x, y].type = (ushort)plantType; + return; + } + WorldGen.KillTile(x, y, false, false, false); + } + } + + public static void VineFrame(int x, int y) + { + Tile tile = Main.tile[x, y]; + int myType = tile.type; + Tile tile2 = Main.tile[x, y - 1]; + Tile tile3 = Main.tile[x, y + 1]; + Tile tile4 = Main.tile[x - 1, y]; + Tile tile5 = Main.tile[x + 1, y]; + Tile tile6 = Main.tile[x - 1, y + 1]; + Tile tile7 = Main.tile[x + 1, y + 1]; + Tile tile8 = Main.tile[x - 1, y - 1]; + Tile tile9 = Main.tile[x + 1, y - 1]; + int num52 = -1; + int num53 = -1; + int num54 = -1; + int num55 = -1; + int num56 = -1; + int num57 = -1; + int num58 = -1; + int num59 = -1; + if (tile4 != null && tile4.active()) + { + if (Main.tileStone[(int)tile4.type]) + { + num55 = 1; + } + else + { + num55 = (int)tile4.type; + } + if (tile4.slope() == 1 || tile4.slope() == 3) + { + num55 = -1; + } + } + if (tile5 != null && tile5.active()) + { + if (Main.tileStone[(int)tile5.type]) + { + num56 = 1; + } + else + { + num56 = (int)tile5.type; + } + if (tile5.slope() == 2 || tile5.slope() == 4) + { + num56 = -1; + } + } + if (tile2 != null && tile2.active()) + { + if (Main.tileStone[(int)tile2.type]) + { + num53 = 1; + } + else + { + num53 = (int)tile2.type; + } + if (tile2.slope() == 3 || tile2.slope() == 4) + { + num53 = -1; + } + } + if (tile3 != null && tile3.active()) + { + if (Main.tileStone[(int)tile3.type]) + { + num58 = 1; + } + else + { + num58 = (int)tile3.type; + } + if (tile3.slope() == 1 || tile3.slope() == 2) + { + num58 = -1; + } + } + if (tile8 != null && tile8.active()) + { + if (Main.tileStone[(int)tile8.type]) + { + num52 = 1; + } + else + { + num52 = (int)tile8.type; + } + } + if (tile9 != null && tile9.active()) + { + if (Main.tileStone[(int)tile9.type]) + { + num54 = 1; + } + else + { + num54 = (int)tile9.type; + } + } + if (tile6 != null && tile6.active()) + { + if (Main.tileStone[(int)tile6.type]) + { + num57 = 1; + } + else + { + num57 = (int)tile6.type; + } + } + if (tile7 != null && tile7.active()) + { + if (Main.tileStone[(int)tile7.type]) + { + num59 = 1; + } + else + { + num59 = (int)tile7.type; + } + } + if (tile.slope() == 2) + { + num53 = -1; + num55 = -1; + } + if (tile.slope() == 1) + { + num53 = -1; + num56 = -1; + } + if (tile.slope() == 4) + { + num58 = -1; + num55 = -1; + } + if (tile.slope() == 3) + { + num58 = -1; + num56 = -1; + } + + if (tile2 != null) + { + if (!tile2.active()) + { + num53 = -1; + } + else if (tile2.bottomSlope()) + { + num53 = -1; + } + else + { + num53 = (int)tile2.type; + } + } + else + { + num53 = myType; + } + + ushort[] vines = VineToGrass.Keys.ToArray(); + + for (int i = 0; i < vines.Length; i++) + { + ushort myGrassType = VineToGrass[(ushort)vines[i]]; + if (myType != vines[i] && (num53 == myGrassType || num53 == vines[i])) + { + Main.tile[x, y].type = vines[i]; + WorldGen.SquareTileFrame(x, y, true); + return; + } + } + + if (num53 != myType) + { + bool flag17 = false; + if (num53 == -1) + { + flag17 = true; + } + else + { + for (int i = 0; i < vines.Length; i++) + { + if (myType != TileID.Vines) + { + if (myType == vines[i] && num53 != VineToGrass[vines[i]]) + { + flag17 = true; + } + } + else if (num53 != TileID.Grass && num53 != TileID.LeafBlock) + { + flag17 = true; + } + } + } + if (flag17) + { + WorldGen.KillTile(x, y, false, false, false); + } + } + return; + } + + enum Similarity + { + Same, + MergeLink, + None + } + + public static void FrameTileForCustomMerge(int x, int y, int myType, int mergeType, bool forceSameDown = false, bool forceSameUp = false, bool forceSameLeft = false, bool forceSameRight = false, bool resetFrame = true) + { + bool tmp; + FrameTileForCustomMerge(x, y, myType, mergeType, out tmp, out tmp, out tmp, out tmp, forceSameDown, forceSameUp, forceSameLeft, forceSameRight, resetFrame); + } + + public static void FrameTileForCustomMerge(int x, int y, int myType, int mergeType, out bool mergedUp, out bool mergedLeft, out bool mergedRight, out bool mergedDown, bool forceSameDown = false, bool forceSameUp = false, bool forceSameLeft = false, bool forceSameRight = false, bool resetFrame = true) + { + Tile tileLeft = Main.tile[x - 1, y]; + Tile tileRight = Main.tile[x + 1, y]; + Tile tileUp = Main.tile[x, y - 1]; + Tile tileDown = Main.tile[x, y + 1]; + Tile tileTopLeft = Main.tile[x - 1, y - 1]; + Tile tileTopRight = Main.tile[x + 1, y - 1]; + Tile tileBottomLeft = Main.tile[x - 1, y + 1]; + Tile tileBottomRight = Main.tile[x + 1, y + 1]; + + //CARDINAL + Similarity leftSim = GetSimilarity(tileLeft, myType, mergeType); + if (forceSameLeft) leftSim = Similarity.Same; + Similarity rightSim = GetSimilarity(tileRight, myType, mergeType); + if (forceSameRight) rightSim = Similarity.Same; + Similarity upSim = GetSimilarity(tileUp, myType, mergeType); + if (forceSameUp) upSim = Similarity.Same; + Similarity downSim = GetSimilarity(tileDown, myType, mergeType); + if (forceSameDown) downSim = Similarity.Same; + + //DIAGONAL + Similarity topLeftSim = GetSimilarity(tileTopLeft, myType, mergeType); + Similarity topRightSim = GetSimilarity(tileTopRight, myType, mergeType); + Similarity bottomLeftSim = GetSimilarity(tileBottomLeft, myType, mergeType); + Similarity bottomRightSim = GetSimilarity(tileBottomRight, myType, mergeType); + + int randomFrame; + if (resetFrame) + { + randomFrame = WorldGen.genRand.Next(3); + Main.tile[x, y].frameNumber((byte)randomFrame); + } + else + { + randomFrame = Main.tile[x, y].frameNumber(); + } + + /* DEBUGGING + if (Player.tileTargetX == x && Player.tileTargetY == y) + { + Main.NewText(StringWriter(leftSim, rightSim, upSim, downSim, topLeftSim, topRightSim, bottomLeftSim, bottomRightSim, forceSameDown, forceSameUp, forceSameLeft, forceSameRight)); + }*/ + + mergedDown = mergedLeft = mergedRight = mergedUp = false; + + if (leftSim == Similarity.None) + { + if (upSim == Similarity.Same) + { + if (downSim == Similarity.Same) + { + if (rightSim == Similarity.Same) + { + SetFrameAt(x, y, 0, 18 * randomFrame); + return; + } + else if (rightSim == Similarity.MergeLink) + { + mergedRight = true; + SetFrameAt(x, y, 234 + 18 * randomFrame, 36); + return; + } + SetFrameAt(x, y, 90, 18 * randomFrame); + return; + } + else if (downSim == Similarity.MergeLink) + { + if (rightSim == Similarity.Same) + { + mergedDown = true; + SetFrameAt(x, y, 72, 90 + 18 * randomFrame); + return; + } + else if (rightSim == Similarity.MergeLink) + { + SetFrameAt(x, y, 108 + 18 * randomFrame, 54); + return; + } + mergedDown = true; + SetFrameAt(x, y, 126, 90 + 18 * randomFrame); + return; + } + if (rightSim == Similarity.Same) + { + SetFrameAt(x, y, 36 * randomFrame, 72); + return; + } + SetFrameAt(x, y, 108 + 18 * randomFrame, 54); + return; + } + else if (upSim == Similarity.MergeLink) + { + if (downSim == Similarity.Same) + { + if (rightSim == Similarity.Same) + { + mergedUp = true; + SetFrameAt(x, y, 72, 144 + 18 * randomFrame); + return; + } + else if (rightSim == Similarity.MergeLink) + { + SetFrameAt(x, y, 108 + 18 * randomFrame, 0); + return; + } + mergedUp = true; + SetFrameAt(x, y, 126, 144 + 18 * randomFrame); + return; + } + else if (downSim == Similarity.MergeLink) + { + if (rightSim == Similarity.Same) + { + SetFrameAt(x, y, 162, 18 * randomFrame); + return; + } + else if (rightSim == Similarity.MergeLink) + { + SetFrameAt(x, y, 162 + 18 * randomFrame, 54); + return; + } + mergedUp = true; + mergedDown = true; + SetFrameAt(x, y, 108, 216 + 18 * randomFrame); + return; + } + if (rightSim == Similarity.Same) + { + SetFrameAt(x, y, 162, 18 * randomFrame); + return; + } + else if (rightSim == Similarity.MergeLink) + { + SetFrameAt(x, y, 162 + 18 * randomFrame, 54); + return; + } + mergedUp = true; + SetFrameAt(x, y, 108, 144 + 18 * randomFrame); + return; + } + if (downSim == Similarity.Same) + { + if (rightSim == Similarity.Same) + { + SetFrameAt(x, y, 36 * randomFrame, 54); + return; + } + else if (rightSim == Similarity.MergeLink) + { + SetFrameAt(x, y, 108 + 18 * randomFrame, 0); + return; + } + SetFrameAt(x, y, 108 + 18 * randomFrame, 0); + return; + } + else if (downSim == Similarity.MergeLink) + { + if (rightSim == Similarity.Same) + { + SetFrameAt(x, y, 162, 18 * randomFrame); + return; + } + else if (rightSim == Similarity.MergeLink) + { + SetFrameAt(x, y, 162 + 18 * randomFrame, 54); + return; + } + mergedDown = true; + SetFrameAt(x, y, 108, 90 + 18 * randomFrame); + return; + } + if (rightSim == Similarity.Same) + { + SetFrameAt(x, y, 162, 18 * randomFrame); + return; + } + else if (rightSim == Similarity.MergeLink) + { + mergedRight = true; + SetFrameAt(x, y, 54 + 18 * randomFrame, 234); + return; + } + SetFrameAt(x, y, 162 + 18 * randomFrame, 54); + return; + } + else if (leftSim == Similarity.MergeLink) + { + if (upSim == Similarity.Same) + { + if (downSim == Similarity.Same) + { + if (rightSim == Similarity.Same) + { + mergedLeft = true; + SetFrameAt(x, y, 162, 126 + 18 * randomFrame); + return; + } + else if (rightSim == Similarity.MergeLink) + { + mergedLeft = true; + mergedRight = true; + SetFrameAt(x, y, 180, 126 + 18 * randomFrame); + return; + } + mergedLeft = true; + SetFrameAt(x, y, 234 + 18 * randomFrame, 54); + return; + } + else if (downSim == Similarity.MergeLink) + { + if (rightSim == Similarity.Same) + { + mergedLeft = mergedDown = true; + SetFrameAt(x, y, 36, 108 + 36 * randomFrame); + return; + } + else if (rightSim == Similarity.MergeLink) + { + mergedLeft = mergedRight = mergedDown = true; + SetFrameAt(x, y, 198, 144 + 18 * randomFrame); + return; + } + SetFrameAt(x, y, 108 + 18 * randomFrame, 54); + return; + } + if (rightSim == Similarity.Same) + { + mergedLeft = true; + SetFrameAt(x, y, 18 * randomFrame, 216); + return; + } + SetFrameAt(x, y, 108 + 18 * randomFrame, 54); + return; + } + else if (upSim == Similarity.MergeLink) + { + if (downSim == Similarity.Same) + { + if (rightSim == Similarity.Same) + { + mergedUp = mergedLeft = true; + SetFrameAt(x, y, 36, 90 + 36 * randomFrame); + return; + } + else if (rightSim == Similarity.MergeLink) + { + mergedLeft = mergedRight = mergedUp = true; + SetFrameAt(x, y, 198, 90 + 18 * randomFrame); + return; + } + SetFrameAt(x, y, 108 + 18 * randomFrame, 0); + return; + } + else if (downSim == Similarity.MergeLink) + { + if (rightSim == Similarity.Same) + { + mergedUp = mergedLeft = mergedDown = true; + SetFrameAt(x, y, 216, 90 + 18 * randomFrame); + return; + } + else if (rightSim == Similarity.MergeLink) + { + mergedDown = mergedLeft = mergedRight = mergedUp = true; + SetFrameAt(x, y, 108 + 18 * randomFrame, 198); + return; + } + SetFrameAt(x, y, 162 + 18 * randomFrame, 54); + return; + } + if (rightSim == Similarity.Same) + { + SetFrameAt(x, y, 162, 18 * randomFrame); + return; + } + SetFrameAt(x, y, 162 + 18 * randomFrame, 54); + return; + } + if (downSim == Similarity.Same) + { + if (rightSim == Similarity.Same) + { + mergedLeft = true; + SetFrameAt(x, y, 18 * randomFrame, 198); + return; + } + else if (rightSim == Similarity.MergeLink) + { + SetFrameAt(x, y, 108 + 18 * randomFrame, 0); + return; + } + SetFrameAt(x, y, 108 + 18 * randomFrame, 0); + return; + } + else if (downSim == Similarity.MergeLink) + { + if (rightSim == Similarity.Same) + { + SetFrameAt(x, y, 162, 18 * randomFrame); + return; + } + else if (rightSim == Similarity.MergeLink) + { + SetFrameAt(x, y, 162 + 18 * randomFrame, 54); + return; + } + SetFrameAt(x, y, 162 + 18 * randomFrame, 54); + return; + } + if (rightSim == Similarity.Same) + { + mergedLeft = true; + SetFrameAt(x, y, 18 * randomFrame, 252); + return; + } + else if (rightSim == Similarity.MergeLink) + { + mergedRight = mergedLeft = true; + SetFrameAt(x, y, 162 + 18 * randomFrame, 198); + return; + } + mergedLeft = true; + SetFrameAt(x, y, 18 * randomFrame, 234); + return; + } + if (upSim == Similarity.Same) + { + if (downSim == Similarity.Same) + { + if (rightSim == Similarity.Same) + { + #region FULL TILE STUFF + if (topLeftSim == Similarity.MergeLink || topRightSim == Similarity.MergeLink || bottomLeftSim == Similarity.MergeLink || bottomRightSim == Similarity.MergeLink) + { + if (bottomRightSim == Similarity.MergeLink) + { + SetFrameAt(x, y, 0, 90 + 36 * randomFrame); + return; + } + else if (bottomLeftSim == Similarity.MergeLink) + { + SetFrameAt(x, y, 18, 90 + 36 * randomFrame); + return; + } + else if (topRightSim == Similarity.MergeLink) + { + SetFrameAt(x, y, 0, 108 + 36 * randomFrame); + return; + } + SetFrameAt(x, y, 18, 108 + 36 * randomFrame); + return; + } + if (topLeftSim == Similarity.Same) + { + if (topRightSim == Similarity.Same) + { + if (bottomLeftSim == Similarity.Same) + { + SetFrameAt(x, y, 18 + 18 * randomFrame, 18); + return; + } + if (bottomRightSim == Similarity.Same) + { + SetFrameAt(x, y, 18 + 18 * randomFrame, 18); + return; + } + SetFrameAt(x, y, 108 + 18 * randomFrame, 36); + return; + } + if (bottomLeftSim == Similarity.Same) + { + if (bottomRightSim == Similarity.Same) + { + if (topRightSim == Similarity.MergeLink) + { + SetFrameAt(x, y, 0, 108 + 36 * randomFrame); + return; + } + SetFrameAt(x, y, 18 + 18 * randomFrame, 18); + return; + } + SetFrameAt(x, y, 198, 18 * randomFrame); + return; + } + } + else if (topLeftSim == Similarity.None) + { + if (topRightSim == Similarity.Same) + { + if (bottomRightSim == Similarity.Same) + { + if (bottomLeftSim == Similarity.Same) + { + SetFrameAt(x, y, 18 + 18 * randomFrame, 18); + return; + } + SetFrameAt(x, y, 18 + 18 * randomFrame, 18); + return; + } + if (bottomLeftSim == Similarity.Same) + { + SetFrameAt(x, y, 18 + 18 * randomFrame, 18); + return; + } + } + SetFrameAt(x, y, 18 + 18 * randomFrame, 18); + return; + } + SetFrameAt(x, y, 18 + 18 * randomFrame, 18); + return; + #endregion + } + else if (rightSim == Similarity.MergeLink) + { + mergedRight = true; + SetFrameAt(x, y, 144, 126 + 18 * randomFrame); + return; + } + SetFrameAt(x, y, 72, 18 * randomFrame); + return; + } + else if (downSim == Similarity.MergeLink) + { + if (rightSim == Similarity.Same) + { + mergedDown = true; + SetFrameAt(x, y, 144 + 18 * randomFrame, 90); + return; + } + else if (rightSim == Similarity.MergeLink) + { + mergedDown = mergedRight = true; + SetFrameAt(x, y, 54, 108 + 36 * randomFrame); + return; + } + mergedDown = true; + SetFrameAt(x, y, 90, 90 + 18 * randomFrame); + return; + } + if (rightSim == Similarity.Same) + { + SetFrameAt(x, y, 18 + 18 * randomFrame, 36); + return; + } + else if (rightSim == Similarity.MergeLink) + { + mergedRight = true; + SetFrameAt(x, y, 54 + 18 * randomFrame, 216); + return; + } + SetFrameAt(x, y, 18 + 36 * randomFrame, 72); + return; + } + else if (upSim == Similarity.MergeLink) + { + if (downSim == Similarity.Same) + { + if (rightSim == Similarity.Same) + { + mergedUp = true; + SetFrameAt(x, y, 144 + 18 * randomFrame, 108); + return; + } + else if (rightSim == Similarity.MergeLink) + { + mergedRight = mergedUp = true; + SetFrameAt(x, y, 54, 90 + 36 * randomFrame); + return; + } + mergedUp = true; + SetFrameAt(x, y, 90, 144 + 18 * randomFrame); + return; + } + else if (downSim == Similarity.MergeLink) + { + if (rightSim == Similarity.Same) + { + mergedUp = mergedDown = true; + SetFrameAt(x, y, 144 + 18 * randomFrame, 180); + return; + } + else if (rightSim == Similarity.MergeLink) + { + mergedUp = mergedRight = mergedDown = true; + SetFrameAt(x, y, 216, 144 + 18 * randomFrame); + return; + } + SetFrameAt(x, y, 216, 18 * randomFrame); + return; + } + if (rightSim == Similarity.Same) + { + mergedUp = true; + SetFrameAt(x, y, 234 + 18 * randomFrame, 18); + return; + } + SetFrameAt(x, y, 216, 18 * randomFrame); + return; + } + if (downSim == Similarity.Same) + { + if (rightSim == Similarity.Same) + { + SetFrameAt(x, y, 18 + 18 * randomFrame, 0); + return; + } + else if (rightSim == Similarity.MergeLink) + { + mergedRight = true; + SetFrameAt(x, y, 54 + 18 * randomFrame, 198); + return; + } + SetFrameAt(x, y, 18 + 36 * randomFrame, 54); + return; + } + else if (downSim == Similarity.MergeLink) + { + if (rightSim == Similarity.Same) + { + mergedDown = true; + SetFrameAt(x, y, 234 + 18 * randomFrame, 0); + return; + } + SetFrameAt(x, y, 216, 18 * randomFrame); + return; + } + if (rightSim == Similarity.Same) + { + SetFrameAt(x, y, 108 + 18 * randomFrame, 72); + return; + } + else if (rightSim == Similarity.MergeLink) + { + mergedRight = true; + SetFrameAt(x, y, 54 + 18 * randomFrame, 252); + return; + } + SetFrameAt(x, y, 216, 18 * randomFrame); + return; + } + + private static void SetFrameAt(int x, int y, int frameX, int frameY) + { + Main.tile[x, y].frameX = (short)frameX; + Main.tile[x, y].frameY = (short)frameY; + } + + private static Similarity GetSimilarity(Tile check, int myType, int mergeType) + { + if (!check.active()) return Similarity.None; + + if (check.type == myType || Main.tileMerge[myType][check.type]) + return Similarity.Same; + else if (check.type == mergeType) + return Similarity.MergeLink; + + return Similarity.None; + } + + private static string StringWriter(params object[] strings) + { + string s = ""; + for (int i = 0; i < strings.Length; i++) + { + s += strings[i].ToString(); + if (i != strings.Length - 1) + { + s += ", "; + } + } + return s; + } + } +} diff --git a/Dusts/AstralBasic.cs b/Dusts/AstralBasic.cs new file mode 100644 index 0000000000..15d3459e9a --- /dev/null +++ b/Dusts/AstralBasic.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Dusts +{ + public class AstralBasic : ModDust + { + public override void OnSpawn(Dust dust) + { + dust.scale = Main.rand.NextFloat(0.9f, 1f); + } + + public override bool Update(Dust dust) + { + //update position + dust.position += dust.velocity; + + dust.scale -= 0.02f; + if (dust.scale < 0.1f) + { + dust.active = false; + } + + return false; + } + } +} diff --git a/Dusts/AstralBasic.png b/Dusts/AstralBasic.png new file mode 100644 index 0000000000..bb6f00e973 Binary files /dev/null and b/Dusts/AstralBasic.png differ diff --git a/Dusts/AstralBlue.cs b/Dusts/AstralBlue.cs new file mode 100644 index 0000000000..912d8e1af7 --- /dev/null +++ b/Dusts/AstralBlue.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Dusts +{ + public class AstralBlue : ModDust + { + public override void OnSpawn(Dust dust) + { + dust.noGravity = true; + } + + public override bool Update(Dust dust) + { + //update position + dust.position += dust.velocity; + + //shrink scale + dust.scale -= 0.02f; + + if (!dust.noLight) + { + Lighting.AddLight(dust.position, 0.1f * dust.scale, 0.3f * dust.scale, 0.4f * dust.scale); + } + + if (dust.customData != null) + { + if (dust.customData is bool && (bool)dust.customData) //slowdown or nah + { + dust.velocity *= 0.94f; + } + else if (dust.customData is float) + { + dust.scale -= (float)dust.customData; + } + } + + if (dust.scale < 0.1f) + { + dust.active = false; + } + + return false; + } + } +} diff --git a/Dusts/AstralBlue.png b/Dusts/AstralBlue.png new file mode 100644 index 0000000000..691796f1c9 Binary files /dev/null and b/Dusts/AstralBlue.png differ diff --git a/Dusts/AstralChunk.cs b/Dusts/AstralChunk.cs new file mode 100644 index 0000000000..33d591739a --- /dev/null +++ b/Dusts/AstralChunk.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Dusts +{ + public class AstralChunk : ModDust + { + public override void OnSpawn(Dust dust) + { + dust.scale = Main.rand.NextFloat(0.9f, 1.2f); + } + + public override bool Update(Dust dust) + { + //update position / rotation + dust.velocity.Y += 0.1f; + dust.position += dust.velocity; + dust.rotation += dust.velocity.X; + + dust.alpha += 6; + if (dust.alpha > 240) + { + dust.active = false; + } + + return false; + } + } +} diff --git a/Dusts/AstralChunk.png b/Dusts/AstralChunk.png new file mode 100644 index 0000000000..ece5798640 Binary files /dev/null and b/Dusts/AstralChunk.png differ diff --git a/Dusts/AstralEnemy.cs b/Dusts/AstralEnemy.cs new file mode 100644 index 0000000000..c0e3194e22 --- /dev/null +++ b/Dusts/AstralEnemy.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Dusts +{ + public class AstralEnemy : ModDust + { + public override void OnSpawn(Dust dust) + { + dust.scale = Main.rand.NextFloat(0.9f, 1f); + } + + public override bool Update(Dust dust) + { + //update position + dust.position += dust.velocity; + dust.velocity.Y += 0.1f; + + dust.scale -= 0.02f; + if (dust.scale < 0.1f) + { + dust.active = false; + } + + return false; + } + } +} diff --git a/Dusts/AstralEnemy.png b/Dusts/AstralEnemy.png new file mode 100644 index 0000000000..d6616874d2 Binary files /dev/null and b/Dusts/AstralEnemy.png differ diff --git a/Dusts/AstralOrange.cs b/Dusts/AstralOrange.cs new file mode 100644 index 0000000000..96889885dc --- /dev/null +++ b/Dusts/AstralOrange.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Dusts +{ + public class AstralOrange : ModDust + { + public override void OnSpawn(Dust dust) + { + dust.noGravity = true; + } + + public override bool Update(Dust dust) + { + //update position + dust.position += dust.velocity; + + //shrink scale + dust.scale -= 0.02f; + + if (!dust.noLight) + { + Lighting.AddLight(dust.position, 0.4f * dust.scale, 0.24f * dust.scale, 0.04f * dust.scale); + } + + if (dust.customData != null) + { + if (dust.customData is bool && (bool)dust.customData) //slowdown or nah + { + dust.velocity *= 0.94f; + } + else if (dust.customData is float) + { + dust.scale -= (float)dust.customData; + } + } + + if (dust.scale < 0.1f) + { + dust.active = false; + } + + return false; + } + } +} diff --git a/Dusts/AstralOrange.png b/Dusts/AstralOrange.png new file mode 100644 index 0000000000..2802603a1e Binary files /dev/null and b/Dusts/AstralOrange.png differ diff --git a/Effects/CustomShader.xnb b/Effects/CustomShader.xnb new file mode 100644 index 0000000000..6f494bec6f Binary files /dev/null and b/Effects/CustomShader.xnb differ diff --git a/Enums.cs b/Enums.cs new file mode 100644 index 0000000000..986550cafe --- /dev/null +++ b/Enums.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace CalamityMod +{ + public enum ConvertType + { + Pure, + Corrupt, + Crimson, + Hallow + } +} diff --git a/ExtraTextures/AstralSky.png b/ExtraTextures/AstralSky.png new file mode 100644 index 0000000000..b30edb57db Binary files /dev/null and b/ExtraTextures/AstralSky.png differ diff --git a/ExtraTextures/Tiles/AstralCactus.png b/ExtraTextures/Tiles/AstralCactus.png new file mode 100644 index 0000000000..4aca391da6 Binary files /dev/null and b/ExtraTextures/Tiles/AstralCactus.png differ diff --git a/ExtraTextures/Tiles/AstralCactusGlow.png b/ExtraTextures/Tiles/AstralCactusGlow.png new file mode 100644 index 0000000000..d408c67bed Binary files /dev/null and b/ExtraTextures/Tiles/AstralCactusGlow.png differ diff --git a/Gores/AstralWaterDroplet.cs b/Gores/AstralWaterDroplet.cs new file mode 100644 index 0000000000..0844c0990e --- /dev/null +++ b/Gores/AstralWaterDroplet.cs @@ -0,0 +1,182 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ModLoader; +using Terraria.Graphics.Effects; +using Terraria.GameContent.Shaders; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Gores +{ + public class AstralWaterDroplet : ModGore + { + public override void OnSpawn(Gore gore) + { + gore.numFrames = 15; + gore.behindTiles = true; + gore.timeLeft = Gore.goreTime * 3; + } + public override bool DrawBehind(Gore gore) + { + Main.instance.LoadGore(gore.type); + + int num = Main.goreTexture[gore.type].Height / (int)gore.numFrames; + + Color alpha = gore.GetAlpha(Lighting.GetColor((int)((double)gore.position.X + (double)Main.goreTexture[gore.type].Width * 0.5) / 16, (int)(((double)gore.position.Y + (double)num * 0.5) / 16.0))); + + Main.spriteBatch.Draw( + Main.goreTexture[gore.type], + new Vector2(gore.position.X - Main.screenPosition.X + (float)(Main.goreTexture[gore.type].Width / 2), gore.position.Y - Main.screenPosition.Y + (float)(num / 2) - 2f), + new Rectangle(0, num * (int)gore.frame, Main.goreTexture[gore.type].Width, num), + alpha, gore.rotation, + new Vector2((float)(Main.goreTexture[gore.type].Width / 2), (float)(num / 2)), + gore.scale, SpriteEffects.None, 0f); + + return false; + } + public override bool Update(Gore gore) + { + if ((double)gore.position.Y < Main.worldSurface * 16.0 + 8.0) + { + gore.alpha = 0; + } + else + { + gore.alpha = 100; + } + int num = 4; + gore.frameCounter++; + if (gore.frame <= 4) + { + int num2 = (int)(gore.position.X / 16f); + int num3 = (int)(gore.position.Y / 16f) - 1; + if (WorldGen.InWorld(num2, num3, 0) && !Main.tile[num2, num3].active()) + { + gore.active = false; + } + if (gore.frame == 0) + { + num = 24 + Main.rand.Next(256); + } + if (gore.frame == 1) + { + num = 24 + Main.rand.Next(256); + } + if (gore.frame == 2) + { + num = 24 + Main.rand.Next(256); + } + if (gore.frame == 3) + { + num = 24 + Main.rand.Next(96); + } + if (gore.frame == 5) + { + num = 16 + Main.rand.Next(64); + } + if ((int)gore.frameCounter >= num) + { + gore.frameCounter = 0; + gore.frame += 1; + if (gore.frame == 5) + { + int num4 = Gore.NewGore(gore.position, gore.velocity, gore.type, 1f); + Main.gore[num4].frame = 9; + Main.gore[num4].velocity *= 0f; + } + } + } + else if (gore.frame <= 6) + { + num = 8; + if ((int)gore.frameCounter >= num) + { + gore.frameCounter = 0; + gore.frame += 1; + if (gore.frame == 7) + { + gore.active = false; + } + } + } + else if (gore.frame <= 9) + { + num = 6; + gore.velocity.Y = gore.velocity.Y + 0.2f; + if ((double)gore.velocity.Y < 0.5) + { + gore.velocity.Y = 0.5f; + } + if (gore.velocity.Y > 12f) + { + gore.velocity.Y = 12f; + } + if ((int)gore.frameCounter >= num) + { + gore.frameCounter = 0; + gore.frame += 1; + } + if (gore.frame > 9) + { + gore.frame = 7; + } + } + else + { + gore.velocity.Y = gore.velocity.Y + 0.1f; + if ((int)gore.frameCounter >= num) + { + gore.frameCounter = 0; + gore.frame += 1; + } + gore.velocity *= 0f; + if (gore.frame > 14) + { + gore.active = false; + } + } + + Vector2 value3 = gore.velocity; + gore.velocity = Collision.TileCollision(gore.position, gore.velocity, 16, 14, false, false, 1); + if (gore.velocity != value3) + { + if (gore.frame < 10) + { + gore.frame = 10; + gore.frameCounter = 0; + if (gore.type != 716 && gore.type != 717 && gore.type != 943) + { + Main.PlaySound(39, (int)gore.position.X + 8, (int)gore.position.Y + 8, Main.rand.Next(2), 1f, 0f); + } + } + } + else if (Collision.WetCollision(gore.position + gore.velocity, 16, 14)) + { + if (gore.frame < 10) + { + gore.frame = 10; + gore.frameCounter = 0; + if (gore.type != 716 && gore.type != 717 && gore.type != 943) + { + Main.PlaySound(39, (int)gore.position.X + 8, (int)gore.position.Y + 8, 2, 1f, 0f); + } + ((WaterShaderData)Filters.Scene["WaterDistortion"].GetShader()).QueueRipple(gore.position + new Vector2(8f, 8f), 1f, RippleShape.Square, 0f); + } + int num21 = (int)(gore.position.X + 8f) / 16; + int num22 = (int)(gore.position.Y + 14f) / 16; + if (Main.tile[num21, num22] != null && Main.tile[num21, num22].liquid > 0) + { + gore.velocity *= 0f; + gore.position.Y = (float)(num22 * 16 - (int)(Main.tile[num21, num22].liquid / 16)); + } + } + + return true; + } + } +} diff --git a/Gores/AstralWaterDroplet.png b/Gores/AstralWaterDroplet.png new file mode 100644 index 0000000000..ae8e3c6820 Binary files /dev/null and b/Gores/AstralWaterDroplet.png differ diff --git a/Gores/Astralachnea/AstralachneaGore0.png b/Gores/Astralachnea/AstralachneaGore0.png new file mode 100644 index 0000000000..acee6746ed Binary files /dev/null and b/Gores/Astralachnea/AstralachneaGore0.png differ diff --git a/Gores/Astralachnea/AstralachneaGore1.png b/Gores/Astralachnea/AstralachneaGore1.png new file mode 100644 index 0000000000..bf9559ad78 Binary files /dev/null and b/Gores/Astralachnea/AstralachneaGore1.png differ diff --git a/Gores/Astralachnea/AstralachneaGore2.png b/Gores/Astralachnea/AstralachneaGore2.png new file mode 100644 index 0000000000..d4b9064b5b Binary files /dev/null and b/Gores/Astralachnea/AstralachneaGore2.png differ diff --git a/Gores/Astralachnea/AstralachneaGore3.png b/Gores/Astralachnea/AstralachneaGore3.png new file mode 100644 index 0000000000..a34a588cee Binary files /dev/null and b/Gores/Astralachnea/AstralachneaGore3.png differ diff --git a/Gores/Astralachnea/AstralachneaGore4.png b/Gores/Astralachnea/AstralachneaGore4.png new file mode 100644 index 0000000000..08536c0680 Binary files /dev/null and b/Gores/Astralachnea/AstralachneaGore4.png differ diff --git a/Gores/Astralachnea/AstralachneaGore5.png b/Gores/Astralachnea/AstralachneaGore5.png new file mode 100644 index 0000000000..322e0d2763 Binary files /dev/null and b/Gores/Astralachnea/AstralachneaGore5.png differ diff --git a/Gores/Atlas/AtlasGore0.png b/Gores/Atlas/AtlasGore0.png new file mode 100644 index 0000000000..2226ce9b7a Binary files /dev/null and b/Gores/Atlas/AtlasGore0.png differ diff --git a/Gores/Atlas/AtlasGore1.png b/Gores/Atlas/AtlasGore1.png new file mode 100644 index 0000000000..a078be68a4 Binary files /dev/null and b/Gores/Atlas/AtlasGore1.png differ diff --git a/Gores/Atlas/AtlasGore2.png b/Gores/Atlas/AtlasGore2.png new file mode 100644 index 0000000000..3229f2cfc5 Binary files /dev/null and b/Gores/Atlas/AtlasGore2.png differ diff --git a/Gores/Atlas/AtlasGore3.png b/Gores/Atlas/AtlasGore3.png new file mode 100644 index 0000000000..3fcdb2847f Binary files /dev/null and b/Gores/Atlas/AtlasGore3.png differ diff --git a/Gores/Atlas/AtlasGore4.png b/Gores/Atlas/AtlasGore4.png new file mode 100644 index 0000000000..abd2bcf6bb Binary files /dev/null and b/Gores/Atlas/AtlasGore4.png differ diff --git a/Gores/Atlas/AtlasGore5.png b/Gores/Atlas/AtlasGore5.png new file mode 100644 index 0000000000..9490045feb Binary files /dev/null and b/Gores/Atlas/AtlasGore5.png differ diff --git a/Gores/Atlas/AtlasGore6.png b/Gores/Atlas/AtlasGore6.png new file mode 100644 index 0000000000..1151b2cdf7 Binary files /dev/null and b/Gores/Atlas/AtlasGore6.png differ diff --git a/Gores/BigSightseer/BigSightseerGore0.png b/Gores/BigSightseer/BigSightseerGore0.png new file mode 100644 index 0000000000..8ca5e14ab1 Binary files /dev/null and b/Gores/BigSightseer/BigSightseerGore0.png differ diff --git a/Gores/BigSightseer/BigSightseerGore1.png b/Gores/BigSightseer/BigSightseerGore1.png new file mode 100644 index 0000000000..7e0be01b95 Binary files /dev/null and b/Gores/BigSightseer/BigSightseerGore1.png differ diff --git a/Gores/BigSightseer/BigSightseerGore2.png b/Gores/BigSightseer/BigSightseerGore2.png new file mode 100644 index 0000000000..7a304beb4c Binary files /dev/null and b/Gores/BigSightseer/BigSightseerGore2.png differ diff --git a/Gores/BigSightseer/BigSightseerGore3.png b/Gores/BigSightseer/BigSightseerGore3.png new file mode 100644 index 0000000000..7bdd3d1ab2 Binary files /dev/null and b/Gores/BigSightseer/BigSightseerGore3.png differ diff --git a/Gores/BigSightseer/BigSightseerGore4.png b/Gores/BigSightseer/BigSightseerGore4.png new file mode 100644 index 0000000000..fe59582883 Binary files /dev/null and b/Gores/BigSightseer/BigSightseerGore4.png differ diff --git a/Gores/FusionFeeder/FusionFeederGore0.png b/Gores/FusionFeeder/FusionFeederGore0.png new file mode 100644 index 0000000000..40fbe3aafb Binary files /dev/null and b/Gores/FusionFeeder/FusionFeederGore0.png differ diff --git a/Gores/FusionFeeder/FusionFeederGore1.png b/Gores/FusionFeeder/FusionFeederGore1.png new file mode 100644 index 0000000000..569c89a9a4 Binary files /dev/null and b/Gores/FusionFeeder/FusionFeederGore1.png differ diff --git a/Gores/FusionFeeder/FusionFeederGore2.png b/Gores/FusionFeeder/FusionFeederGore2.png new file mode 100644 index 0000000000..c74a40cfb3 Binary files /dev/null and b/Gores/FusionFeeder/FusionFeederGore2.png differ diff --git a/Gores/FusionFeeder/FusionFeederGore3.png b/Gores/FusionFeeder/FusionFeederGore3.png new file mode 100644 index 0000000000..eb3f6468af Binary files /dev/null and b/Gores/FusionFeeder/FusionFeederGore3.png differ diff --git a/Gores/FusionFeeder/FusionFeederGore4.png b/Gores/FusionFeeder/FusionFeederGore4.png new file mode 100644 index 0000000000..b1faec763b Binary files /dev/null and b/Gores/FusionFeeder/FusionFeederGore4.png differ diff --git a/Gores/FusionFeeder/FusionFeederGore5.png b/Gores/FusionFeeder/FusionFeederGore5.png new file mode 100644 index 0000000000..9005e46628 Binary files /dev/null and b/Gores/FusionFeeder/FusionFeederGore5.png differ diff --git a/Gores/Hadarian/HadarianGore0.png b/Gores/Hadarian/HadarianGore0.png new file mode 100644 index 0000000000..26f67632ad Binary files /dev/null and b/Gores/Hadarian/HadarianGore0.png differ diff --git a/Gores/Hadarian/HadarianGore1.png b/Gores/Hadarian/HadarianGore1.png new file mode 100644 index 0000000000..c808386e6c Binary files /dev/null and b/Gores/Hadarian/HadarianGore1.png differ diff --git a/Gores/Hadarian/HadarianGore2.png b/Gores/Hadarian/HadarianGore2.png new file mode 100644 index 0000000000..3ba25b16f8 Binary files /dev/null and b/Gores/Hadarian/HadarianGore2.png differ diff --git a/Gores/Hadarian/HadarianGore3.png b/Gores/Hadarian/HadarianGore3.png new file mode 100644 index 0000000000..848121bd1b Binary files /dev/null and b/Gores/Hadarian/HadarianGore3.png differ diff --git a/Gores/Hadarian/HadarianGore4.png b/Gores/Hadarian/HadarianGore4.png new file mode 100644 index 0000000000..93265cbf27 Binary files /dev/null and b/Gores/Hadarian/HadarianGore4.png differ diff --git a/Gores/Nova/NovaGore0.png b/Gores/Nova/NovaGore0.png new file mode 100644 index 0000000000..3e7eb2ac12 Binary files /dev/null and b/Gores/Nova/NovaGore0.png differ diff --git a/Gores/Nova/NovaGore1.png b/Gores/Nova/NovaGore1.png new file mode 100644 index 0000000000..d9da256ef8 Binary files /dev/null and b/Gores/Nova/NovaGore1.png differ diff --git a/Gores/Nova/NovaGore2.png b/Gores/Nova/NovaGore2.png new file mode 100644 index 0000000000..9f02561ab2 Binary files /dev/null and b/Gores/Nova/NovaGore2.png differ diff --git a/Gores/Nova/NovaGore3.png b/Gores/Nova/NovaGore3.png new file mode 100644 index 0000000000..463f94717d Binary files /dev/null and b/Gores/Nova/NovaGore3.png differ diff --git a/Gores/Nova/NovaGore4.png b/Gores/Nova/NovaGore4.png new file mode 100644 index 0000000000..186924178d Binary files /dev/null and b/Gores/Nova/NovaGore4.png differ diff --git a/Gores/Nova/NovaGore5.png b/Gores/Nova/NovaGore5.png new file mode 100644 index 0000000000..e3bbea1dcc Binary files /dev/null and b/Gores/Nova/NovaGore5.png differ diff --git a/Gores/Nova/NovaGore6.png b/Gores/Nova/NovaGore6.png new file mode 100644 index 0000000000..6812d59201 Binary files /dev/null and b/Gores/Nova/NovaGore6.png differ diff --git a/Gores/SmallSightseer/SmallSightseerGore0.png b/Gores/SmallSightseer/SmallSightseerGore0.png new file mode 100644 index 0000000000..b7ec09742a Binary files /dev/null and b/Gores/SmallSightseer/SmallSightseerGore0.png differ diff --git a/Gores/SmallSightseer/SmallSightseerGore1.png b/Gores/SmallSightseer/SmallSightseerGore1.png new file mode 100644 index 0000000000..83ca1c4ecd Binary files /dev/null and b/Gores/SmallSightseer/SmallSightseerGore1.png differ diff --git a/Gores/SmallSightseer/SmallSightseerGore2.png b/Gores/SmallSightseer/SmallSightseerGore2.png new file mode 100644 index 0000000000..2bf6300954 Binary files /dev/null and b/Gores/SmallSightseer/SmallSightseerGore2.png differ diff --git a/Gores/SmallSightseer/SmallSightseerGore3.png b/Gores/SmallSightseer/SmallSightseerGore3.png new file mode 100644 index 0000000000..bdf607005d Binary files /dev/null and b/Gores/SmallSightseer/SmallSightseerGore3.png differ diff --git a/Gores/SmallSightseer/SmallSightseerGore4.png b/Gores/SmallSightseer/SmallSightseerGore4.png new file mode 100644 index 0000000000..29bd675949 Binary files /dev/null and b/Gores/SmallSightseer/SmallSightseerGore4.png differ diff --git a/Gores/StellarCulex/StellarCulexGore0.png b/Gores/StellarCulex/StellarCulexGore0.png new file mode 100644 index 0000000000..1d4e009236 Binary files /dev/null and b/Gores/StellarCulex/StellarCulexGore0.png differ diff --git a/Gores/StellarCulex/StellarCulexGore1.png b/Gores/StellarCulex/StellarCulexGore1.png new file mode 100644 index 0000000000..645bd726a1 Binary files /dev/null and b/Gores/StellarCulex/StellarCulexGore1.png differ diff --git a/Gores/StellarCulex/StellarCulexGore2.png b/Gores/StellarCulex/StellarCulexGore2.png new file mode 100644 index 0000000000..9a89d4a852 Binary files /dev/null and b/Gores/StellarCulex/StellarCulexGore2.png differ diff --git a/Gores/StellarCulex/StellarCulexGore3.png b/Gores/StellarCulex/StellarCulexGore3.png new file mode 100644 index 0000000000..7b710a4018 Binary files /dev/null and b/Gores/StellarCulex/StellarCulexGore3.png differ diff --git a/Gores/StellarCulex/StellarCulexGore4.png b/Gores/StellarCulex/StellarCulexGore4.png new file mode 100644 index 0000000000..d280208f77 Binary files /dev/null and b/Gores/StellarCulex/StellarCulexGore4.png differ diff --git a/Gores/StellarCulex/StellarCulexGore5.png b/Gores/StellarCulex/StellarCulexGore5.png new file mode 100644 index 0000000000..192c7885c4 Binary files /dev/null and b/Gores/StellarCulex/StellarCulexGore5.png differ diff --git a/Items/Ammo/AstralSolution.cs b/Items/Ammo/AstralSolution.cs new file mode 100644 index 0000000000..300c22b3e0 --- /dev/null +++ b/Items/Ammo/AstralSolution.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Ammo +{ + public class AstralSolution : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Solution"); + Tooltip.SetDefault("Used by the Clentaminator.\nSpreads the Astral."); + } + + public override void SetDefaults() + { + item.ammo = AmmoID.Solution; + item.shoot = mod.ProjectileType("AstralSpray") - ProjectileID.PureSpray; + item.width = 10; + item.height = 12; + //item.value = Item.buyPrice(0, 0, 25, 0); + item.rare = 3; + item.maxStack = 999; + item.consumable = true; + return; + } + + public override bool ConsumeAmmo(Player player) + { + return !(player.itemAnimation < player.HeldItem.useAnimation - 3); + } + } +} diff --git a/Items/Ammo/AstralSolution.png b/Items/Ammo/AstralSolution.png new file mode 100644 index 0000000000..f4a5aeabc4 Binary files /dev/null and b/Items/Ammo/AstralSolution.png differ diff --git a/Items/AstralBar.cs b/Items/AstralBar.cs deleted file mode 100644 index 88e780a7cc..0000000000 --- a/Items/AstralBar.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; -using CalamityMod.Items; - -namespace CalamityMod.Items { -public class AstralBar : ModItem -{ - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Astral Bar"); - } - - public override void SetDefaults() - { - item.width = 15; - item.height = 12; - item.maxStack = 999; - item.value = 58750; - item.rare = 7; - } - - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(null, "Stardust", 12); - recipe.AddIngredient(null, "AstralOre", 8); - recipe.AddTile(TileID.AdamantiteForge); - recipe.SetResult(this, 4); - recipe.AddRecipe(); - } -}} \ No newline at end of file diff --git a/Items/AstralBar.png b/Items/AstralBar.png deleted file mode 100644 index cd4d832df7..0000000000 Binary files a/Items/AstralBar.png and /dev/null differ diff --git a/Items/AstralHamaxe.cs b/Items/AstralHamaxe.cs index d736963493..79b2acec36 100644 --- a/Items/AstralHamaxe.cs +++ b/Items/AstralHamaxe.cs @@ -5,51 +5,53 @@ using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Items; -namespace CalamityMod.Items { -public class AstralHamaxe : ModItem +namespace CalamityMod.Items { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Astral Hamaxe"); - } + public class AstralHamaxe : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Hamaxe"); + } - public override void SetDefaults() - { - item.damage = 70; - item.crit += 25; - item.melee = true; - item.width = 38; - item.height = 36; - item.useTime = 10; - item.useAnimation = 20; - item.useTurn = true; - item.axe = 30; - item.hammer = 150; - item.useStyle = 1; - item.knockBack = 5f; - item.value = 350000; - item.rare = 7; - item.UseSound = SoundID.Item1; - item.autoReuse = true; - item.tileBoost += 3; - } - - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.Next(5) == 0) + public override void SetDefaults() { - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 173); + item.damage = 70; + item.crit += 25; + item.melee = true; + item.width = 60; + item.height = 70; + item.useTime = 10; + item.useAnimation = 20; + item.useTurn = true; + item.axe = 30; + item.hammer = 150; + item.useStyle = 1; + item.knockBack = 5f; + item.value = 350000; + item.rare = 7; + item.UseSound = SoundID.Item1; + item.autoReuse = true; + item.tileBoost += 3; + } + + public override void MeleeEffects(Player player, Rectangle hitbox) + { + Dust d = CalamityGlobalItem.MeleeDustHelper(player, Main.rand.Next(2) == 0 ? mod.DustType("AstralOrange") : mod.DustType("AstralBlue"), 0.48f, 50, 78, -0.1f, 0.1f); + if (d != null) + { + d.customData = 0.02f; + } + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(null, "AstralBar", 8); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); } } - - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(null, "AstralBar", 8); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } -}} \ No newline at end of file +} \ No newline at end of file diff --git a/Items/AstralHamaxe.png b/Items/AstralHamaxe.png index a2b8d31471..7e80b3412e 100644 Binary files a/Items/AstralHamaxe.png and b/Items/AstralHamaxe.png differ diff --git a/Items/AstralPickaxe.cs b/Items/AstralPickaxe.cs index 8b68ea3535..d2c7ff5ffb 100644 --- a/Items/AstralPickaxe.cs +++ b/Items/AstralPickaxe.cs @@ -5,50 +5,52 @@ using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Items; -namespace CalamityMod.Items { -public class AstralPickaxe : ModItem +namespace CalamityMod.Items { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Astral Pickaxe"); - } + public class AstralPickaxe : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Pickaxe"); + } - public override void SetDefaults() - { - item.damage = 58; - item.crit += 25; - item.melee = true; - item.width = 36; - item.height = 36; - item.useTime = 5; - item.useAnimation = 10; - item.useTurn = true; - item.pick = 200; - item.useStyle = 1; - item.knockBack = 5f; - item.value = 350000; - item.rare = 7; - item.UseSound = SoundID.Item1; - item.autoReuse = true; - item.tileBoost += 3; - } - - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(null, "AstralBar", 7); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.Next(5) == 0) + public override void SetDefaults() { - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 173); + item.damage = 58; + item.crit += 25; + item.melee = true; + item.width = 50; + item.height = 60; + item.useTime = 5; + item.useAnimation = 10; + item.useTurn = true; + item.pick = 200; + item.useStyle = 1; + item.knockBack = 5f; + item.value = 350000; + item.rare = 7; + item.UseSound = SoundID.Item1; + item.autoReuse = true; + item.tileBoost += 3; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(null, "AstralBar", 7); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + + public override void MeleeEffects(Player player, Rectangle hitbox) + { + Dust d = CalamityGlobalItem.MeleeDustHelper(player, Main.rand.Next(2) == 0 ? mod.DustType("AstralOrange") : mod.DustType("AstralBlue"), 0.56f, 40, 65, -0.13f, 0.13f); + if (d != null) + { + d.customData = 0.02f; + } } } -}} \ No newline at end of file +} \ No newline at end of file diff --git a/Items/AstralPickaxe.png b/Items/AstralPickaxe.png index 411b31984c..9214299d9a 100644 Binary files a/Items/AstralPickaxe.png and b/Items/AstralPickaxe.png differ diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index cd58f4a809..8d2cbcd926 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -264,5 +264,43 @@ namespace CalamityMod.Items modPlayer.jellyfishNecklace = true; } } - } + + /// + /// Dust helper to spawn dust for an item. Allows you to specify where on the item to spawn the dust, essentially. (ONLY WORKS FOR SWINGING WEAPONS?) + /// + /// The player using the item. + /// The type of dust to use. + /// The chance per frame to spawn the dust (0f-1f) + /// The minimum distance between the player and the dust + /// The maximum distance between the player and the dust + /// The minimum random rotation offset for the dust + /// The maximum random rotation offset for the dust + /// The minimum speed that the dust should travel + /// The maximum speed that the dust should travel + public static Dust MeleeDustHelper(Player player, int dustType, float chancePerFrame, float minDistance, float maxDistance, float minRandRot = -0.2f, float maxRandRot = 0.2f, float minSpeed = 0.9f, float maxSpeed = 1.1f) + { + if (Main.rand.NextFloat(1f) < chancePerFrame) + { + //Calculate values + //distance from player, + //the vector offset from the player center + //the vector between the pos and the player + float distance = Main.rand.NextFloat(minDistance, maxDistance); + Vector2 offset = (player.itemRotation - (MathHelper.PiOver4 * player.direction) + Main.rand.NextFloat(minRandRot, maxRandRot)).ToRotationVector2() * distance * player.direction; + Vector2 pos = player.Center + offset; + Vector2 vec = pos - player.Center; + + //spawn the dust + Dust d = Dust.NewDustPerfect(pos, dustType); + + //normalise vector and multiply by velocity magnitude + vec.Normalize(); + d.velocity = vec * Main.rand.NextFloat(minSpeed, maxSpeed); + + return d; + } + + return null; + } + } } diff --git a/Items/Placeables/AstralBar.cs b/Items/Placeables/AstralBar.cs new file mode 100644 index 0000000000..5d8ac2e2bf --- /dev/null +++ b/Items/Placeables/AstralBar.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class AstralBar : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Bar"); + } + + public override void SetDefaults() + { + item.createTile = mod.TileType("AstralBar"); + item.useStyle = 1; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 16; + item.height = 16; + item.maxStack = 99; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + //ASTRAL_IMPLEMENT: UNDO THIS COMMENT + //recipe.AddIngredient(null, "Stardust", 12); + recipe.AddIngredient(mod.ItemType("AstralOre"), 8); + recipe.AddTile(TileID.AdamantiteForge); + recipe.SetResult(this, 4); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Placeables/AstralBar.png b/Items/Placeables/AstralBar.png new file mode 100644 index 0000000000..02fc188d90 Binary files /dev/null and b/Items/Placeables/AstralBar.png differ diff --git a/Items/Placeables/AstralDirt.cs b/Items/Placeables/AstralDirt.cs new file mode 100644 index 0000000000..2d4f9d4952 --- /dev/null +++ b/Items/Placeables/AstralDirt.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class AstralDirt : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Dirt"); + } + + public override void SetDefaults() + { + item.createTile = mod.TileType("AstralDirt"); + item.useStyle = 1; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 16; + item.height = 16; + item.maxStack = 999; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddTile(18); + recipe.AddIngredient(mod.ItemType("AstralDirtWall"), 4); + recipe.SetResult(this, 1); + recipe.AddRecipe(); + base.AddRecipes(); + } + } +} diff --git a/Items/Placeables/AstralDirt.png b/Items/Placeables/AstralDirt.png new file mode 100644 index 0000000000..f8c3da4d73 Binary files /dev/null and b/Items/Placeables/AstralDirt.png differ diff --git a/Items/Placeables/AstralDirtWall.cs b/Items/Placeables/AstralDirtWall.cs new file mode 100644 index 0000000000..e3d99e549f --- /dev/null +++ b/Items/Placeables/AstralDirtWall.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class AstralDirtWall : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Dirt Wall"); + } + + public override void SetDefaults() + { + //item.createWall = mod.TileType("AstralDirtWall"); + item.createWall = Terraria.ID.WallID.Cave8Unsafe; + item.useStyle = 1; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 16; + item.height = 16; + item.maxStack = 999; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddTile(18); + recipe.AddIngredient(mod.ItemType("AstralDirt")); + recipe.SetResult(this, 4); + recipe.AddRecipe(); + base.AddRecipes(); + } + } +} diff --git a/Items/Placeables/AstralDirtWall.png b/Items/Placeables/AstralDirtWall.png new file mode 100644 index 0000000000..ce1e33e02b Binary files /dev/null and b/Items/Placeables/AstralDirtWall.png differ diff --git a/Items/Placeables/AstralGrassWall.cs b/Items/Placeables/AstralGrassWall.cs new file mode 100644 index 0000000000..8ab616d4d1 --- /dev/null +++ b/Items/Placeables/AstralGrassWall.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class AstralGrassWall : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Grass Wall"); + } + + public override void SetDefaults() + { + item.createWall = mod.WallType("AstralGrassWall"); + item.useStyle = 1; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 16; + item.height = 16; + item.maxStack = 999; + } + } +} diff --git a/Items/Placeables/AstralGrassWall.png b/Items/Placeables/AstralGrassWall.png new file mode 100644 index 0000000000..b9190b065a Binary files /dev/null and b/Items/Placeables/AstralGrassWall.png differ diff --git a/Items/Placeables/AstralIce.cs b/Items/Placeables/AstralIce.cs new file mode 100644 index 0000000000..4fad586c16 --- /dev/null +++ b/Items/Placeables/AstralIce.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class AstralIce : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Ice"); + } + + public override void SetDefaults() + { + item.createTile = mod.TileType("AstralIce"); + item.useStyle = 1; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 16; + item.height = 16; + item.maxStack = 999; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddTile(18); + recipe.AddIngredient(mod.ItemType("AstralIceWall"), 4); + recipe.SetResult(this, 1); + recipe.AddRecipe(); + base.AddRecipes(); + } + } +} diff --git a/Items/Placeables/AstralIce.png b/Items/Placeables/AstralIce.png new file mode 100644 index 0000000000..28fe848001 Binary files /dev/null and b/Items/Placeables/AstralIce.png differ diff --git a/Items/Placeables/AstralIceWall.cs b/Items/Placeables/AstralIceWall.cs new file mode 100644 index 0000000000..5ad77da533 --- /dev/null +++ b/Items/Placeables/AstralIceWall.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class AstralIceWall : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Ice Wall"); + } + + public override void SetDefaults() + { + item.createTile = mod.TileType("AstralIceWall"); + item.useStyle = 1; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 16; + item.height = 16; + item.maxStack = 999; + } + } +} diff --git a/Items/Placeables/AstralIceWall.png b/Items/Placeables/AstralIceWall.png new file mode 100644 index 0000000000..6b42aa4194 Binary files /dev/null and b/Items/Placeables/AstralIceWall.png differ diff --git a/Items/Placeables/AstralMonolith.cs b/Items/Placeables/AstralMonolith.cs new file mode 100644 index 0000000000..410648d31a --- /dev/null +++ b/Items/Placeables/AstralMonolith.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Localization; + +namespace CalamityMod.Items.Placeables +{ + public class AstralMonolith : ModItem + { + public override void SetDefaults() + { + item.width = 12; + item.height = 12; + item.maxStack = 999; + item.useTurn = true; + item.autoReuse = true; + item.useAnimation = 15; + item.useTime = 10; + item.useStyle = 1; + item.consumable = true; + item.createTile = mod.TileType("AstralMonolith"); + } + } +} diff --git a/Items/Placeables/AstralMonolith.png b/Items/Placeables/AstralMonolith.png new file mode 100644 index 0000000000..a255617632 Binary files /dev/null and b/Items/Placeables/AstralMonolith.png differ diff --git a/Items/Placeables/AstralOre.cs b/Items/Placeables/AstralOre.cs index 5765e4e4f6..3897f6aa3d 100644 --- a/Items/Placeables/AstralOre.cs +++ b/Items/Placeables/AstralOre.cs @@ -5,7 +5,6 @@ using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Items; namespace CalamityMod.Items.Placeables { @@ -25,8 +24,8 @@ namespace CalamityMod.Items.Placeables item.useTime = 10; item.autoReuse = true; item.consumable = true; - item.width = 13; - item.height = 10; + item.width = 20; + item.height = 20; item.maxStack = 999; item.value = 3750; item.rare = 7; diff --git a/Items/Placeables/AstralOre.png b/Items/Placeables/AstralOre.png index 5869b0191e..04505d6b67 100644 Binary files a/Items/Placeables/AstralOre.png and b/Items/Placeables/AstralOre.png differ diff --git a/Items/Placeables/AstralSand.cs b/Items/Placeables/AstralSand.cs new file mode 100644 index 0000000000..098219134e --- /dev/null +++ b/Items/Placeables/AstralSand.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class AstralSand : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Sand"); + } + + public override void SetDefaults() + { + item.createTile = mod.TileType("AstralSand"); + item.useStyle = 1; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 16; + item.height = 16; + item.maxStack = 999; + } + } +} diff --git a/Items/Placeables/AstralSand.png b/Items/Placeables/AstralSand.png new file mode 100644 index 0000000000..148bf7d0cb Binary files /dev/null and b/Items/Placeables/AstralSand.png differ diff --git a/Items/Placeables/AstralSandstone.cs b/Items/Placeables/AstralSandstone.cs new file mode 100644 index 0000000000..875e694f7c --- /dev/null +++ b/Items/Placeables/AstralSandstone.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class AstralSandstone : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Sandstone"); + } + + public override void SetDefaults() + { + item.createTile = mod.TileType("AstralSandstone"); + item.useStyle = 1; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 16; + item.height = 16; + item.maxStack = 999; + } + } +} diff --git a/Items/Placeables/AstralSandstone.png b/Items/Placeables/AstralSandstone.png new file mode 100644 index 0000000000..81a3887d0b Binary files /dev/null and b/Items/Placeables/AstralSandstone.png differ diff --git a/Items/Placeables/AstralSandstoneWall.cs b/Items/Placeables/AstralSandstoneWall.cs new file mode 100644 index 0000000000..c1bb865486 --- /dev/null +++ b/Items/Placeables/AstralSandstoneWall.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class AstralSandstoneWall : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Sandstone Wall"); + } + + public override void SetDefaults() + { + item.createTile = mod.WallType("AstralSandstoneWall"); + item.useStyle = 1; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 16; + item.height = 16; + item.maxStack = 999; + } + } +} diff --git a/Items/Placeables/AstralSandstoneWall.png b/Items/Placeables/AstralSandstoneWall.png new file mode 100644 index 0000000000..68b9775b79 Binary files /dev/null and b/Items/Placeables/AstralSandstoneWall.png differ diff --git a/Items/Placeables/AstralStone.cs b/Items/Placeables/AstralStone.cs new file mode 100644 index 0000000000..476b9d5960 --- /dev/null +++ b/Items/Placeables/AstralStone.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class AstralStone : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Stone"); + } + + public override void SetDefaults() + { + item.createTile = mod.TileType("AstralStone"); + item.useStyle = 1; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 16; + item.height = 16; + item.maxStack = 999; + } + } +} diff --git a/Items/Placeables/AstralStone.png b/Items/Placeables/AstralStone.png new file mode 100644 index 0000000000..e169904f6e Binary files /dev/null and b/Items/Placeables/AstralStone.png differ diff --git a/Items/Placeables/AstralStoneWall.cs b/Items/Placeables/AstralStoneWall.cs new file mode 100644 index 0000000000..e375bc4bd0 --- /dev/null +++ b/Items/Placeables/AstralStoneWall.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class AstralStoneWall : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Stone Wall"); + } + + public override void SetDefaults() + { + item.createTile = mod.WallType("AstralStoneWall"); + item.useStyle = 1; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 16; + item.height = 16; + item.maxStack = 999; + } + } +} diff --git a/Items/Placeables/AstralStoneWall.png b/Items/Placeables/AstralStoneWall.png new file mode 100644 index 0000000000..af919f2e91 Binary files /dev/null and b/Items/Placeables/AstralStoneWall.png differ diff --git a/Items/Placeables/AstralSurfaceMusicBox.cs b/Items/Placeables/AstralSurfaceMusicBox.cs new file mode 100644 index 0000000000..af884efe4b --- /dev/null +++ b/Items/Placeables/AstralSurfaceMusicBox.cs @@ -0,0 +1,28 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class AstralSurfaceMusicBox : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Music Box (Astral Surface)"); + } + + public override void SetDefaults() + { + item.useStyle = 1; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.createTile = mod.TileType("AstralSurfaceMusicBox"); + item.width = 24; + item.height = 24; + item.rare = 4; + item.value = 100000; + item.accessory = true; + } + } +} \ No newline at end of file diff --git a/Items/Placeables/AstralSurfaceMusicBox.png b/Items/Placeables/AstralSurfaceMusicBox.png new file mode 100644 index 0000000000..3352db4715 Binary files /dev/null and b/Items/Placeables/AstralSurfaceMusicBox.png differ diff --git a/Items/Placeables/HardenedAstralSand.cs b/Items/Placeables/HardenedAstralSand.cs new file mode 100644 index 0000000000..69d7158538 --- /dev/null +++ b/Items/Placeables/HardenedAstralSand.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class HardenedAstralSand : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Hardened Astral Sand"); + } + + public override void SetDefaults() + { + item.createTile = mod.TileType("HardenedAstralSand"); + item.useStyle = 1; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 16; + item.height = 16; + item.maxStack = 999; + } + } +} diff --git a/Items/Placeables/HardenedAstralSand.png b/Items/Placeables/HardenedAstralSand.png new file mode 100644 index 0000000000..64b2e8043c Binary files /dev/null and b/Items/Placeables/HardenedAstralSand.png differ diff --git a/Items/Placeables/HardenedAstralSandWall.cs b/Items/Placeables/HardenedAstralSandWall.cs new file mode 100644 index 0000000000..e64c7136a6 --- /dev/null +++ b/Items/Placeables/HardenedAstralSandWall.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class HardenedAstralSandWall : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Hardened Astral Sand Wall"); + } + + public override void SetDefaults() + { + item.createTile = mod.WallType("HardenedAstralSandWall"); + item.useStyle = 1; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 16; + item.height = 16; + item.maxStack = 999; + } + } +} diff --git a/Items/Placeables/HardenedAstralSandWall.png b/Items/Placeables/HardenedAstralSandWall.png new file mode 100644 index 0000000000..0dc34a0b30 Binary files /dev/null and b/Items/Placeables/HardenedAstralSandWall.png differ diff --git a/Items/Weapons/AstralBlade.cs b/Items/Weapons/AstralBlade.cs index 5724cd0e5d..5811f03f22 100644 --- a/Items/Weapons/AstralBlade.cs +++ b/Items/Weapons/AstralBlade.cs @@ -1,31 +1,30 @@ -using System; +using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Items; namespace CalamityMod.Items.Weapons { public class AstralBlade : ModItem { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Astral Blade"); - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astral Blade"); + } public override void SetDefaults() { item.damage = 90; item.crit += 25; item.melee = true; - item.width = 44; + item.width = 60; item.height = 60; item.useTime = 9; item.useAnimation = 9; - item.useTurn = true; + item.useTurn = true; item.useStyle = 1; item.knockBack = 5f; item.value = 350000; @@ -33,22 +32,26 @@ namespace CalamityMod.Items.Weapons item.UseSound = SoundID.Item1; item.autoReuse = true; } - + public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(null, "AstralBar", 8); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(null, "AstralBar", 8); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + public override void MeleeEffects(Player player, Rectangle hitbox) { - if (Main.rand.Next(5) == 0) - { - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 173); - } + for (int i = 0; i < 3; i++) + { + Dust d = CalamityGlobalItem.MeleeDustHelper(player, Main.rand.Next(2) == 0 ? mod.DustType("AstralOrange") : mod.DustType("AstralBlue"), 0.7f, 55, 110, -0.07f, 0.07f); + if (d != null) + { + d.customData = 0.03f; + } + } } } } \ No newline at end of file diff --git a/Items/Weapons/AstralBlade.png b/Items/Weapons/AstralBlade.png index 154c861b08..96c91d0c8b 100644 Binary files a/Items/Weapons/AstralBlade.png and b/Items/Weapons/AstralBlade.png differ diff --git a/Items/Weapons/AstralStaff.cs b/Items/Weapons/AstralStaff.cs index 8a5620f018..0a1b109bfe 100644 --- a/Items/Weapons/AstralStaff.cs +++ b/Items/Weapons/AstralStaff.cs @@ -5,7 +5,6 @@ using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Items; namespace CalamityMod.Items.Weapons { @@ -14,20 +13,20 @@ namespace CalamityMod.Items.Weapons public override void SetStaticDefaults() { DisplayName.SetDefault("Astral Staff"); - Tooltip.SetDefault("Summons astral stars from the sky"); - Item.staff[item.type] = true; + Tooltip.SetDefault("Summons a large crystal from the sky that has a large area of effect on impact."); + Item.staff[item.type] = true; } public override void SetDefaults() { - item.damage = 53; - item.crit += 25; + item.damage = 110; + item.crit += 15; item.magic = true; - item.mana = 15; - item.width = 42; - item.height = 42; - item.useTime = 9; - item.useAnimation = 18; + item.mana = 26; + item.width = 86; + item.height = 72; + item.useTime = 35; + item.useAnimation = 35; item.useStyle = 5; item.noMelee = true; item.knockBack = 5f; @@ -35,11 +34,11 @@ namespace CalamityMod.Items.Weapons item.rare = 7; item.UseSound = SoundID.Item105; item.autoReuse = true; - item.shoot = mod.ProjectileType("AstralStar"); + item.shoot = mod.ProjectileType("AstralCrystal"); item.shootSpeed = 15f; } - - public override void AddRecipes() + + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(null, "AstralBar", 6); @@ -47,65 +46,19 @@ namespace CalamityMod.Items.Weapons recipe.SetResult(this); recipe.AddRecipe(); } - - public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) - { - float num72 = item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (player.gravDir == -1f) - { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; - } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - float num81 = num80; - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) - { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; - } - else - { - num80 = num72 / num80; - } - num78 *= num80; - num79 *= num80; - int num107 = 2; - if (Main.rand.Next(3) == 0) - { - num107++; - } - if (Main.rand.Next(3) == 0) - { - num107++; - } - for (int num108 = 0; num108 < num107; num108++) - { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) - { - num79 *= -1f; - } - if (num79 < 20f) - { - num79 = 20f; - } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; - int star = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockBack, player.whoAmI, 0f, 0f); - Main.projectile[star].magic = true; - } - return false; + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + Vector2 spawnPos = new Vector2(player.MountedCenter.X + Main.rand.Next(-200, 201), player.MountedCenter.Y - 600f); + Vector2 targetPos = Main.MouseWorld + new Vector2(Main.rand.Next(-30, 31), Main.rand.Next(-30, 31)); + Vector2 velocity = targetPos - spawnPos; + velocity.Normalize(); + velocity *= 13f; + + int p = Projectile.NewProjectile(spawnPos, velocity, type, damage, knockBack, player.whoAmI); + Main.projectile[p].ai[0] = targetPos.Y - 120; + + return false; } } } \ No newline at end of file diff --git a/Items/Weapons/AstralStaff.png b/Items/Weapons/AstralStaff.png index 502d8f0c11..e7008dd1c5 100644 Binary files a/Items/Weapons/AstralStaff.png and b/Items/Weapons/AstralStaff.png differ diff --git a/NPCs/AstralBiomeNPCs/Aries.cs b/NPCs/AstralBiomeNPCs/Aries.cs new file mode 100644 index 0000000000..975212d5e7 --- /dev/null +++ b/NPCs/AstralBiomeNPCs/Aries.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.AstralBiomeNPCs +{ + public class Aries : ModNPC + { + private static Texture2D glowmask; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Aries"); + Main.npcFrameCount[npc.type] = 8; + glowmask = mod.GetTexture("NPCs/AstralBiomeNPCs/AriesGlow"); + } + + public override void SetDefaults() + { + npc.damage = 85; + npc.width = 56; + npc.height = 54; + npc.aiStyle = 41; + npc.defense = 24; + npc.lifeMax = 450; + npc.knockBackResist = 0.5f; + npc.value = 380f; + npc.HitSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyHit"); + npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyDeath"); + } + + public override void FindFrame(int frameHeight) + { + CalamityGlobalNPC.SpawnDustOnNPC(npc, 66, frameHeight, mod.DustType("AstralOrange"), new Rectangle(44, 18, 12, 12)); + if (npc.velocity.Y == 0f) + { + npc.frame.Y = 0; + } + else if ((double)npc.velocity.Y < -1.5) + { + npc.frame.Y = frameHeight * 7; + } + else if ((double)npc.velocity.Y < 0) + { + npc.frame.Y = frameHeight * 4; + } + else if ((double)npc.velocity.Y > 1.5) + { + npc.frame.Y = frameHeight * 6; + } + else + { + npc.frame.Y = frameHeight * 5; + } + } + + public override void HitEffect(int hitDirection, double damage) + { + CalamityGlobalNPC.DoHitDust(npc, hitDirection, mod.DustType("AstralOrange"), 1f, 4, 24); + } + + public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) + { + //draw glowmask + spriteBatch.Draw(glowmask, npc.Center - Main.screenPosition, npc.frame, Color.White * 0.6f, npc.rotation, new Vector2(33, 31), 1f, npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.player.GetModPlayer().ZoneAstral && !spawnInfo.player.ZoneRockLayerHeight) + { + return 0.15f; + } + return 0f; + } + } +} diff --git a/NPCs/AstralBiomeNPCs/Aries.png b/NPCs/AstralBiomeNPCs/Aries.png new file mode 100644 index 0000000000..601d4ab743 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/Aries.png differ diff --git a/NPCs/AstralBiomeNPCs/AriesGlow.png b/NPCs/AstralBiomeNPCs/AriesGlow.png new file mode 100644 index 0000000000..908836638e Binary files /dev/null and b/NPCs/AstralBiomeNPCs/AriesGlow.png differ diff --git a/NPCs/AstralBiomeNPCs/AstralSeekerSpit.png b/NPCs/AstralBiomeNPCs/AstralSeekerSpit.png new file mode 100644 index 0000000000..15aa2ce47e Binary files /dev/null and b/NPCs/AstralBiomeNPCs/AstralSeekerSpit.png differ diff --git a/NPCs/AstralBiomeNPCs/AstralSlime.cs b/NPCs/AstralBiomeNPCs/AstralSlime.cs index 0cf6f54966..b5b90a916c 100644 --- a/NPCs/AstralBiomeNPCs/AstralSlime.cs +++ b/NPCs/AstralBiomeNPCs/AstralSlime.cs @@ -1,140 +1,63 @@ using System; using System.Collections.Generic; -using System.IO; +using System.Linq; +using System.Text; + using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; + using Terraria; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Projectiles; namespace CalamityMod.NPCs.AstralBiomeNPCs { - public class AstralSlime : ModNPC - { - public float spikeTimer = 60f; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Astral Slime"); - Main.npcFrameCount[npc.type] = 2; - } - - public override void SetDefaults() - { - npc.aiStyle = 1; - npc.damage = 40; - npc.width = 40; //324 - npc.height = 30; //216 - npc.defense = 20; - npc.lifeMax = 90; - npc.knockBackResist = 0f; - animationType = 81; - npc.value = Item.buyPrice(0, 0, 5, 0); - npc.alpha = 60; - npc.lavaImmune = false; - npc.noGravity = false; - npc.noTileCollide = false; - npc.HitSound = SoundID.NPCHit1; - npc.DeathSound = SoundID.NPCDeath1; - npc.buffImmune[24] = true; - } - - public override void AI() - { - if (spikeTimer > 0f) - { - spikeTimer -= 1f; - } - if (!npc.wet && !Main.player[npc.target].npcTypeNoAggro[npc.type]) - { - Vector2 vector3 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num14 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector3.X; - float num15 = Main.player[npc.target].position.Y - vector3.Y; - float num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15)); - if (Main.expertMode && num16 < 120f && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && npc.velocity.Y == 0f) - { - npc.ai[0] = -40f; - if (npc.velocity.Y == 0f) - { - npc.velocity.X = npc.velocity.X * 0.9f; - } - if (Main.netMode != 1 && spikeTimer == 0f) - { - for (int n = 0; n < 5; n++) - { - Vector2 vector4 = new Vector2((float)(n - 2), -4f); - vector4.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; - vector4.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; - vector4.Normalize(); - vector4 *= 4f + (float)Main.rand.Next(-50, 51) * 0.01f; - Projectile.NewProjectile(vector3.X, vector3.Y, vector4.X, vector4.Y, mod.ProjectileType("AstralShot"), 15, 0f, Main.myPlayer, 0f, 0f); - spikeTimer = 30f; - } - } - } - else if (num16 < 200f && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && npc.velocity.Y == 0f) - { - npc.ai[0] = -40f; - if (npc.velocity.Y == 0f) - { - npc.velocity.X = npc.velocity.X * 0.9f; - } - if (Main.netMode != 1 && spikeTimer == 0f) - { - num15 = Main.player[npc.target].position.Y - vector3.Y - (float)Main.rand.Next(0, 200); - num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15)); - num16 = 4.5f / num16; - num14 *= num16; - num15 *= num16; - spikeTimer = 50f; - Projectile.NewProjectile(vector3.X, vector3.Y, num14, num15, mod.ProjectileType("AstralShot"), 13, 0f, Main.myPlayer, 0f, 0f); - } - } - } - } - - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 173, hitDirection, -1f, 0, default(Color), 1f); - } - if (npc.life <= 0) - { - for (int k = 0; k < 20; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 173, hitDirection, -1f, 0, default(Color), 1f); - } - } - } - - public override void NPCLoot() - { - if (npc.localAI[3] != 1f) - { - if (Main.rand.Next(2) == 0) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Stardust")); - } - if (Main.expertMode) - { - Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Stardust")); - } - } - } - - public override float SpawnChance(NPCSpawnInfo spawnInfo) + public class AstralSlime : ModNPC + { + public override void SetStaticDefaults() { - return (spawnInfo.player.GetModPlayer(mod).ZoneAstral && !spawnInfo.player.ZoneTowerStardust && !spawnInfo.player.ZoneTowerSolar && !spawnInfo.player.ZoneTowerVortex && !spawnInfo.player.ZoneTowerNebula) ? 1f : 0f; + DisplayName.SetDefault("Astral Slime"); + Main.npcFrameCount[npc.type] = 2; } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - if (CalamityWorld.downedStarGod) - { - player.AddBuff(mod.BuffType("GodSlayerInferno"), 150, true); - } - } - } -} \ No newline at end of file + + public override void SetDefaults() + { + npc.damage = 65; + npc.width = 44; + npc.height = 28; + npc.aiStyle = 1; + npc.defense = 18; + npc.lifeMax = 310; + npc.knockBackResist = 0f; + npc.value = 400f; + npc.alpha = 60; + npc.HitSound = SoundID.NPCHit1; + npc.DeathSound = SoundID.NPCDeath1; + + animationType = NPCID.BlueSlime; + } + + public override void FindFrame(int frameHeight) + { + //DO DUST + Dust d = CalamityGlobalNPC.SpawnDustOnNPC(npc, 44, frameHeight, mod.DustType("AstralOrange"), new Rectangle(4, 4, 36, 24), Vector2.Zero, 0.15f, true); + if (d != null) + { + d.customData = 0.04f; + } + } + + public override void HitEffect(int hitDirection, double damage) + { + CalamityGlobalNPC.DoHitDust(npc, hitDirection, mod.DustType("AstralOrange"), 1f, 4, 24); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.player.GetModPlayer().ZoneAstral && !spawnInfo.player.ZoneRockLayerHeight) + { + return 0.21f; + } + return 0f; + } + } +} diff --git a/NPCs/AstralBiomeNPCs/AstralSlime.png b/NPCs/AstralBiomeNPCs/AstralSlime.png index bec7b9968c..121e7e9173 100644 Binary files a/NPCs/AstralBiomeNPCs/AstralSlime.png and b/NPCs/AstralBiomeNPCs/AstralSlime.png differ diff --git a/NPCs/AstralBiomeNPCs/AstralachneaGround.cs b/NPCs/AstralBiomeNPCs/AstralachneaGround.cs new file mode 100644 index 0000000000..4ada97b872 --- /dev/null +++ b/NPCs/AstralBiomeNPCs/AstralachneaGround.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.NPCs.AstralBiomeNPCs +{ + public class AstralachneaGround : ModNPC + { + private static Texture2D glowmask; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astralachnea"); + + Main.npcFrameCount[npc.type] = 5; + + glowmask = mod.GetTexture("NPCs/AstralBiomeNPCs/AstralachneaGroundGlow"); + + base.SetStaticDefaults(); + } + + public override void SetDefaults() + { + npc.width = 70; + npc.height = 34; + npc.aiStyle = 3; + npc.damage = 90; + npc.defense = 30; + npc.lifeMax = 750; + npc.HitSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyHit"); + npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyDeath"); + npc.knockBackResist = 0.28f; + npc.value = 900f; + npc.buffImmune[20] = true; + npc.buffImmune[31] = false; + npc.timeLeft = NPC.activeTime * 2; + + animationType = NPCID.WallCreeper; + } + + public override void AI() + { + npc.TargetClosest(); + if (Main.netMode != 1 && npc.velocity.Y == 0f) + { + int x = (int)npc.Center.X / 16; + int y = (int)npc.Center.Y / 16; + bool transform = false; + for (int i = x - 1; i <= x + 1; i++) + { + for (int j = y - 1; j <= y + 1; j++) + { + if (Main.tile[i, j] != null && Main.tile[i, j].wall > 0) + { + transform = true; + } + } + } + if (transform) + { + npc.Transform(mod.NPCType("AstralachneaWall")); + } + } + } + + public override void FindFrame(int frameHeight) + { + //DO DUST + int frame = npc.frame.Y / frameHeight; + Rectangle rect = new Rectangle(62, 4, 14, 6); + switch (frame) + { + case 1: + rect = new Rectangle(64, 6, 12, 6); + break; + case 2: + rect = new Rectangle(58, 8, 22, 6); + break; + case 3: + rect = new Rectangle(54, 8, 26, 8); + break; + case 4: + rect = new Rectangle(58, 6, 20, 8); + break; + } + Dust d = CalamityGlobalNPC.SpawnDustOnNPC(npc, 80, frameHeight, mod.DustType("AstralOrange"), rect, Vector2.Zero, 0.45f, true); + if (d != null) + { + d.customData = 0.04f; + } + } + + public override void HitEffect(int hitDirection, double damage) + { + CalamityGlobalNPC.DoHitDust(npc, hitDirection, (Main.rand.Next(0, Math.Max(0, npc.life)) == 0) ? 5 : mod.DustType("AstralEnemy"), 1f, 4, 22); + + //if dead do gores + if (npc.life <= 0) + { + for (int i = 0; i < 6; i++) + { + Gore.NewGore(npc.Center, npc.velocity * 0.3f, mod.GetGoreSlot("Gores/Astralachnea/AstralachneaGore" + i)); + } + } + } + + public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) + { + Vector2 origin = new Vector2(40f, 21f); + spriteBatch.Draw(glowmask, npc.Center - Main.screenPosition, npc.frame, Color.White * 0.6f, npc.rotation, origin, 1f, npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.player.GetModPlayer().ZoneAstral && spawnInfo.player.ZoneRockLayerHeight) + { + return 0.17f; + } + return 0f; + } + } +} diff --git a/NPCs/AstralBiomeNPCs/AstralachneaGround.png b/NPCs/AstralBiomeNPCs/AstralachneaGround.png new file mode 100644 index 0000000000..e34c764249 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/AstralachneaGround.png differ diff --git a/NPCs/AstralBiomeNPCs/AstralachneaGroundGlow.png b/NPCs/AstralBiomeNPCs/AstralachneaGroundGlow.png new file mode 100644 index 0000000000..5cbad1b96f Binary files /dev/null and b/NPCs/AstralBiomeNPCs/AstralachneaGroundGlow.png differ diff --git a/NPCs/AstralBiomeNPCs/AstralachneaWall.cs b/NPCs/AstralBiomeNPCs/AstralachneaWall.cs new file mode 100644 index 0000000000..84531d5ac4 --- /dev/null +++ b/NPCs/AstralBiomeNPCs/AstralachneaWall.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.NPCs.AstralBiomeNPCs +{ + public class AstralachneaWall : ModNPC + { + private static Texture2D glowmask; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Astralachnea"); + + Main.npcFrameCount[npc.type] = 4; + + glowmask = mod.GetTexture("NPCs/AstralBiomeNPCs/AstralachneaWallGlow"); + + base.SetStaticDefaults(); + } + + public override void SetDefaults() + { + npc.width = 60; + npc.height = 60; + npc.aiStyle = -1; + npc.damage = 90; + npc.defense = 30; + npc.lifeMax = 750; + npc.HitSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyHit"); + npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyDeath"); + npc.knockBackResist = 0f; + npc.noGravity = true; + npc.value = 900f; + npc.buffImmune[20] = true; + npc.buffImmune[31] = false; + npc.timeLeft = NPC.activeTime * 2; + + animationType = NPCID.BlackRecluseWall; + } + + public override void AI() + { + CalamityGlobalNPC.DoSpiderWallAI(npc, mod.NPCType("AstralachneaGround"), 2.4f, 0.1f); + } + + public override void FindFrame(int frameHeight) + { + //DO DUST + int frame = npc.frame.Y / frameHeight; + Rectangle rect = new Rectangle(12, 24, 18, 10); + Rectangle rect2 = new Rectangle(12, 44, 18, 10); + switch (frame) + { + case 1: + rect = new Rectangle(6, 26, 28, 8); + rect2 = new Rectangle(6, 44, 28, 8); + break; + case 2: + rect = new Rectangle(12, 26, 18, 8); + rect2 = new Rectangle(12, 44, 18, 8); + break; + case 3: + rect = new Rectangle(16, 24, 16, 10); + rect2 = new Rectangle(16, 44, 16, 10); + break; + } + Dust d = CalamityGlobalNPC.SpawnDustOnNPC(npc, 80, frameHeight, mod.DustType("AstralOrange"), rect, Vector2.Zero, 0.225f, true); + Dust d2 = CalamityGlobalNPC.SpawnDustOnNPC(npc, 80, frameHeight, mod.DustType("AstralOrange"), rect2, Vector2.Zero, 0.225f, true); + if (d != null) + { + d.customData = 0.04f; + } + if (d2 != null) + { + d2.customData = 0.04f; + } + } + + public override void HitEffect(int hitDirection, double damage) + { + CalamityGlobalNPC.DoHitDust(npc, hitDirection, (Main.rand.Next(0, Math.Max(0, npc.life)) == 0) ? 5 : mod.DustType("AstralEnemy"), 1f, 4, 22); + + //if dead do gores + if (npc.life <= 0) + { + for (int i = 0; i < 6; i++) + { + Gore.NewGore(npc.Center, npc.velocity * 0.3f, mod.GetGoreSlot("Gores/Astralachnea/AstralachneaGore" + i)); + } + } + } + + public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) + { + Vector2 origin = new Vector2(40f, 40f); + spriteBatch.Draw(glowmask, npc.Center - Main.screenPosition - new Vector2(0, 8f), npc.frame, Color.White * 0.6f, npc.rotation, origin, 1f, SpriteEffects.None, 0); + } + } +} diff --git a/NPCs/AstralBiomeNPCs/AstralachneaWall.png b/NPCs/AstralBiomeNPCs/AstralachneaWall.png new file mode 100644 index 0000000000..aadbf57b4b Binary files /dev/null and b/NPCs/AstralBiomeNPCs/AstralachneaWall.png differ diff --git a/NPCs/AstralBiomeNPCs/AstralachneaWallGlow.png b/NPCs/AstralBiomeNPCs/AstralachneaWallGlow.png new file mode 100644 index 0000000000..819b2f3aba Binary files /dev/null and b/NPCs/AstralBiomeNPCs/AstralachneaWallGlow.png differ diff --git a/NPCs/AstralBiomeNPCs/Atlas.cs b/NPCs/AstralBiomeNPCs/Atlas.cs new file mode 100644 index 0000000000..187aa60875 --- /dev/null +++ b/NPCs/AstralBiomeNPCs/Atlas.cs @@ -0,0 +1,579 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using Terraria.DataStructures; +using System.IO; + +namespace CalamityMod.NPCs.AstralBiomeNPCs +{ + public class Atlas : ModNPC + { + //TODO: + //draw 4 pixels lower than actual bottom position (arm overlaps tiles) + + private static Texture2D glowmask; + + //CONSTANTS + private const int sheetHeight = 852; + private const int startWalkFrameY = 710; + private const float idle_walkMaxSpeed = 0.8f; + private const float idle_walkAcceleration = 0.1f; + private const float target_walkMaxSpeed = 1.6f; + private const float target_walkAcceleration = 0.12f; + private const float swing_minXDistance = 96f; + private const float swing_minYDistance = 48f; + private const int swing_minCounterHit = 16; + private const int swing_maxCounterHit = 25; //the minimum and maximum values for the counter in which the swing's main hitbox is active. + private const int swing_playSoundOnFrame = 15; + + private bool idling; + private bool idle_impulseWalk; + private bool idle_walkLeft; + private bool idle_blocked; + + private bool swinging; + private bool swingYeet; + private byte swing_counter; + private short swing_untilNext; + + private float idle_counter + { + get + { + return npc.ai[0]; + } + set + { + npc.ai[0] = value; + } + } + private float target_counter + { + get + { + return npc.ai[1]; + } + set + { + npc.ai[1] = value; + } + } + private float grounded_counter + { + get + { + return npc.ai[2]; + } + set + { + npc.ai[2] = value; + } + } + private Player Target + { + get + { + if (npc.HasValidTarget) + { + return Main.player[npc.target]; + } + return null; + } + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Atlas"); + Main.npcFrameCount[npc.type] = 6; + //not really important seeing as custom drawing, but for heights sake, 6 + //also it's visuals are messed up on npc spawners etc. because the sheet is 3 wide. + //not much we can do. looks fine in-game so /shrug + glowmask = mod.GetTexture("NPCs/AstralBiomeNPCs/AtlasGlow"); + } + + public override void SetDefaults() + { + npc.width = 78; + npc.height = 88; + npc.damage = 75; + npc.defense = 50; + npc.lifeMax = 1600; + npc.knockBackResist = 0.04f; + npc.value = 1800; + npc.aiStyle = -1; + + npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/AtlasDeath"); + } + + public override void SendExtraAI(BinaryWriter writer) + { + BitsByte bb = new BitsByte(idling, idle_impulseWalk, idle_walkLeft, idle_blocked, swinging, swingYeet); + writer.Write(bb); + writer.Write(swing_counter); + writer.Write(swing_untilNext); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + BitsByte bb = reader.ReadByte(); + idling = bb[0]; + idle_impulseWalk = bb[1]; + idle_walkLeft = bb[2]; + idle_blocked = bb[3]; + swinging = bb[4]; + swingYeet = bb[5]; + + swing_counter = reader.ReadByte(); + swing_untilNext = reader.ReadInt16(); + } + + public override void AI() + { + //PICK A TARGET + if (!npc.HasValidTarget || idling) + { + //target and reset + npc.TargetClosest(false); + idling = false; + + if (!npc.HasValidTarget) //if we don't have valid target + { + idling = true; + } + else if (!Collision.CanHit(npc.position + Vector2.UnitY * 8, 15, 15, Target.position, Target.width, Target.height)) //else if we do but can't see them + { + idling = true; + } + else + { + //PLAY SOUND (SAD) *but this time it has a target. more like an indicator. he sad because he has to kill you now :c + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AtlasSad1"), npc.Center); + } + } + + if (npc.velocity.Y == 0) + { + grounded_counter++; + } + else + { + grounded_counter = 0; + } + + swing_untilNext--; + + if (idling) + { + DoIdleAI(); + } + else if (swinging) + { + DoSwingUpdate(); + } + else + { + DoTargetAI(); + } + + npc.stepSpeed = 0.75f; + + if (npc.velocity.Y >= 0f) + { + Collision.StepUp(ref npc.position, ref npc.velocity, npc.width, npc.height, ref npc.stepSpeed, ref npc.gfxOffY, 1, false, 1); + } + } + + private void DoSwingUpdate() + { + npc.velocity.X *= 0.84f; + swing_counter++; + + if (swing_counter == swing_playSoundOnFrame) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AtlasSwing"), npc.Center); + } + + if (swing_counter >= swing_minCounterHit && swing_counter <= swing_maxCounterHit) + { + int centerX = (int)npc.Center.X; + int centerY = (int)npc.Center.Y; + int width = (int)swing_minXDistance; + int height = 142; + Rectangle hitbox = new Rectangle( + centerX + (npc.direction == -1 ? -width : 0), + centerY - height / 2, + width, height); + + for (int i = 0; i < Main.player.Length; i++) + { + if (Main.player[i].active && !Main.player[i].dead && Main.player[i].getRect().Intersects(hitbox)) + { + Vector2 before = Main.player[i].velocity; + Main.player[i].Hurt(PlayerDeathReason.ByNPC(npc.whoAmI), 130, npc.direction); + Vector2 after = Main.player[i].velocity; + Vector2 difference = after - before; + + float horMult = 3.5f; + float verMult = 1.2f; + + swingYeet = false; + + if (Main.rand.Next(1) == 0) //Launch the player very fast very rarely + { + horMult = 12f; + verMult = 2.3f; + swingYeet = true; + } + + if (Main.player[i].noKnockback) + { + horMult *= 0.5f; + verMult *= 0.5f; + } + + difference *= new Vector2(horMult, verMult); + + Main.player[i].velocity = before + difference; + } + } + } + } + + private void DoIdleAI() + { + //idling, so I should mostly just walk around and do nothing useful with my life + //oh hey, it's just me haha + if (HoleBelow() || (npc.collideX && npc.oldPosition.X == npc.position.X)) + { + idle_impulseWalk = false; + idle_blocked = true; + } + + idle_counter++; + if (idle_impulseWalk) + { + if (idle_counter == 4) + { + npc.frame.Y = startWalkFrameY; //reset frame to start walk animation. + } + + npc.velocity.X += idle_walkAcceleration * (idle_walkLeft ? -1 : 1); + if (Math.Abs(npc.velocity.X) > idle_walkMaxSpeed) + { + npc.velocity.X = idle_walkLeft ? -idle_walkMaxSpeed : idle_walkMaxSpeed; + } + idle_impulseWalk = idle_impulseWalk && idle_counter > 20 && Main.rand.Next(150) != 0; + if (!idle_impulseWalk) + { + idle_counter = 0; + } + + npc.direction = idle_walkLeft ? -1 : 1; + } + else + { + idle_impulseWalk = idle_counter > 100 && Main.rand.Next(400) == 0; //try to impulse + if (idle_impulseWalk) //if we've just decided to stroll + { + idle_counter = 0; + if (idle_blocked) //if we were blocked before, pick the other direction. + { + idle_blocked = false; + idle_walkLeft = !idle_walkLeft; + } + else + { + idle_walkLeft = Main.rand.NextBool(); //pick direction + } + npc.frameCounter = 0; // reset framecounter to start walk. + + //PLAY SOUND (IDLE) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AtlasIdle" + Main.rand.Next(2)), npc.Center); + } + else + { + npc.velocity.X *= 0.9f; + if (Math.Abs(npc.velocity.X) < 0.1f) + { + npc.velocity.X = 0f; + } + } + } + } + + private void DoTargetAI() + { + //got a target, so I'm gonna chase them down and smack em. + bool targetToLeft = Target.Center.X < npc.Center.X; + int mult = targetToLeft ? -1 : 1; + + npc.velocity.X += target_walkAcceleration * mult; + if (Math.Abs(npc.velocity.X) > target_walkMaxSpeed) + { + npc.velocity.X = target_walkMaxSpeed * mult; + } + + //based on velocity, as he a big hunk and he can't walk backwards whilst facing target + npc.direction = npc.velocity.X < 0f ? -1 : 1; + + //if have been on ground for at least 1.5 seonds, and are hitting wall or there is a hole + if (grounded_counter > 90 && (HoleBelow() || (npc.collideX && npc.position.X == npc.oldPosition.X))) + { + //jump + npc.velocity.Y = -6f; + target_counter++; + } + + bool canHitTarget = Collision.CanHit(npc.position + Vector2.UnitY * 8, 15, 15, Target.position, Target.width, Target.height); + + if (target_counter > 0 && !canHitTarget) + { + target_counter++; + } + else + { + target_counter = 0; + } + + if (target_counter > 180) + { + idling = true; + target_counter = 0; + + //PLAY SOUND (SAD) he sad cos he lost his target :C + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AtlasSad2"), npc.Center); + } + else if (target_counter == 0 && npc.velocity.Y == 0) + { + //check if we can swing at the target + Vector2 distance = npc.Center - Target.Center; + if (swing_untilNext < 0 && canHitTarget && Math.Abs(distance.X) < swing_minXDistance && Math.Abs(distance.Y) < swing_minYDistance) + { + StartSwing(); + } + } + } + + private bool HoleBelow() + { + //width of npc in tiles + int tileWidth = 5; + int tileX = (int)(npc.Center.X / 16f) - tileWidth; + if (npc.velocity.X > 0) //if moving right + { + tileX += tileWidth; + } + int tileY = (int)((npc.position.Y + npc.height) / 16f); + for (int y = tileY; y < tileY + 2; y++) + { + for (int x = tileX; x < tileX + tileWidth; x++) + { + if (Main.tile[x, y].active()) + { + return false; + } + } + } + return true; + } + + private void StartSwing() + { + swinging = true; + swing_counter = 0; + swing_untilNext = 300; + } + + public override void HitEffect(int hitDirection, double damage) + { + //play sound + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AtlasHurt" + Main.rand.Next(3)), npc.Center); + + CalamityGlobalNPC.DoHitDust(npc, hitDirection, (Main.rand.Next(0, Math.Max(0, npc.life)) == 0) ? 5 : mod.DustType("AstralEnemy"), 1f, 3, 30); + + //if dead do gores + if (npc.life <= 0) + { + //head + Gore.NewGore(npc.Top, npc.velocity * 0.5f, mod.GetGoreSlot("Gores/Atlas/AtlasGore4")); + //hand + Gore.NewGore(npc.direction == 1 ? npc.Right : npc.Left, npc.velocity * 0.5f, mod.GetGoreSlot("Gores/Atlas/AtlasGore2")); + //rest + Gore.NewGore(npc.Center, npc.velocity * 0.5f, mod.GetGoreSlot("Gores/Atlas/AtlasGore0")); + Gore.NewGore(npc.Center, npc.velocity * 0.5f, mod.GetGoreSlot("Gores/Atlas/AtlasGore1")); + Gore.NewGore(npc.Center, npc.velocity * 0.5f, mod.GetGoreSlot("Gores/Atlas/AtlasGore3")); + Gore.NewGore(npc.Center, npc.velocity * 0.5f, mod.GetGoreSlot("Gores/Atlas/AtlasGore5")); + Gore.NewGore(npc.Center, npc.velocity * 0.5f, mod.GetGoreSlot("Gores/Atlas/AtlasGore6")); + } + } + + public override void FindFrame(int frameHeight) + { + int width = 142; + int height = 142; + + //ensure width and height are set. + npc.frame.Width = width; + npc.frame.Height = height; + + if (idling) + { + npc.frameCounter++; + if (!idle_impulseWalk) + { + npc.frame.X = 0; + if (npc.frameCounter > 9) + { + npc.frameCounter = 0; + npc.frame.Y += height; + if (npc.frame.Y >= sheetHeight) + { + npc.frame.Y = 0; + } + } + } + else + { + npc.frame.X = width; + if (npc.frameCounter > 8) + { + npc.frameCounter = 0; + npc.frame.Y += height; + if (npc.frame.Y >= sheetHeight) + { + npc.frame.Y = 0; + } + } + } + } + else if (swinging) + { + npc.frameCounter = 0; + npc.frame.X = width * 2; + if (swing_counter < 8) + { + npc.frame.Y = 0; + } + else if (swing_counter < 16) + { + npc.frame.Y = height; + } + else if (swing_counter < 23) + { + npc.frame.Y = height * 2; + } + else if (swing_counter < 30) + { + npc.frame.Y = height * 3; + } + else if (swing_counter < 38) + { + npc.frame.Y = height * 4; + } + else if (swing_counter < 46) + { + npc.frame.Y = height * 5; + } + else + { + swinging = false; + swing_counter = 0; + idling = false; + } + } + else + { + //if walking + npc.frameCounter++; + npc.frame.X = width; + if (npc.frameCounter > 7) + { + npc.frameCounter = 0; + npc.frame.Y += height; + if (npc.frame.Y >= sheetHeight) + { + npc.frame.Y = 0; + } + } + } + + //if we're in the air + if (npc.velocity.Y != 0) + { + npc.frame.X = width; + npc.frame.Y = height * 4; //5th frame down + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + Vector2 position = npc.position - new Vector2(30, 48) - Main.screenPosition; + SpriteEffects effect = npc.direction == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + //draw actual sprite + spriteBatch.Draw(Main.npcTexture[npc.type], position, npc.frame, + drawColor, 0f, default(Vector2), 1f, //color, rotation, origin, scale + effect, 0f); //effect, drawlayer + + //draw glowmask + spriteBatch.Draw( + glowmask, position, npc.frame, + Color.White * 0.65f, 0f, default(Vector2), 1f, //color, rotation, origin, scale + effect, 0f); //effect, drawlayer + + return false; + } + + private Vector2 GetEyePos() + { + int x = 0; + int y = 0; + switch(npc.frame.Y) + { + case 0: + x = 45; + y = 79; + break; + case 142: + x = 41; + y = 79; + break; + case 284: + x = 35; + y = 75; + break; + case 426: + x = 25; + y = 73; + break; + case 568: + x = 31; + y = 77; + break; + case 710: + x = 43; + y = 81; + break; + } + if (npc.direction == 1) + { + x = 142 - x; + } + return new Vector2(x, y); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.player.GetModPlayer().ZoneAstral && spawnInfo.player.ZoneOverworldHeight) + { + return 0.06f; + } + return 0f; + } + } +} diff --git a/NPCs/AstralBiomeNPCs/Atlas.png b/NPCs/AstralBiomeNPCs/Atlas.png new file mode 100644 index 0000000000..8ee6251b84 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/Atlas.png differ diff --git a/NPCs/AstralBiomeNPCs/AtlasGlow.png b/NPCs/AstralBiomeNPCs/AtlasGlow.png new file mode 100644 index 0000000000..dd3d52eb5e Binary files /dev/null and b/NPCs/AstralBiomeNPCs/AtlasGlow.png differ diff --git a/NPCs/AstralBiomeNPCs/BigSightseer.cs b/NPCs/AstralBiomeNPCs/BigSightseer.cs new file mode 100644 index 0000000000..8a16a19d63 --- /dev/null +++ b/NPCs/AstralBiomeNPCs/BigSightseer.cs @@ -0,0 +1,218 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.AstralBiomeNPCs +{ + public class BigSightseer : ModNPC + { + private static Texture2D glowmask; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Big Sightseer"); + Main.npcFrameCount[npc.type] = 4; + + glowmask = mod.GetTexture("NPCs/AstralBiomeNPCs/BigSightseerGlow"); + } + + public override void SetDefaults() + { + npc.width = 64; + npc.height = 56; + npc.damage = 85; + npc.defense = 30; + npc.lifeMax = 640; + npc.HitSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyHit"); + npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyDeath"); + npc.noGravity = true; + npc.knockBackResist = 0.7f; + npc.value = 1000; + npc.aiStyle = -1; + } + + public override void FindFrame(int frameHeight) + { + npc.frameCounter += 0.05f + npc.velocity.Length() * 0.667f; + if (npc.frameCounter >= 8) + { + npc.frameCounter = 0; + npc.frame.Y += frameHeight; + if (npc.frame.Y > npc.height * 3) + { + npc.frame.Y = 0; + } + } + + //DO DUST + Dust d = CalamityGlobalNPC.SpawnDustOnNPC(npc, 118, frameHeight, mod.DustType("AstralOrange"), new Rectangle(70, 18, 48, 18), Vector2.Zero, 0.45f, true); + if (d != null) + { + d.customData = 0.04f; + } + } + + public override void AI() + { + CalamityGlobalNPC.DoFlyingAI(npc, 4f, 0.025f, 300f); + + npc.ai[1]++; + Player target = Main.player[npc.target]; + + if (npc.justHit || target.dead) + { + //reset if hit + npc.ai[1] = 0; + } + + //if can see target and waited long enough + if (Collision.CanHit(target.position, target.width, target.height, npc.position, npc.width, npc.height)) + { + Vector2 vector = (target.Center - npc.Center); + vector.Normalize(); + Vector2 spawnPoint = npc.Center + vector * 42f; + + if (npc.ai[1] >= 160f) + { + npc.ai[1] = 0f; + + int n = NPC.NewNPC((int)spawnPoint.X, (int)spawnPoint.Y, mod.NPCType("AstralSeekerSpit")); + Main.npc[n].Center = spawnPoint; + Main.npc[n].velocity = vector * 10f; + } + else if (npc.ai[1] >= 140f) //oozin dust at the "mouth" + { + int dustType = Main.rand.Next(2) == 0 ? mod.DustType("AstralOrange") : mod.DustType("AstralBlue"); + int d = Dust.NewDust(spawnPoint - new Vector2(5), 10, 10, dustType); + Main.dust[d].velocity = npc.velocity * 0.3f; + Main.dust[d].customData = true; + } + } + } + + public override void HitEffect(int hitDirection, double damage) + { + CalamityGlobalNPC.DoHitDust(npc, hitDirection, (Main.rand.Next(0, Math.Max(0, npc.life)) == 0) ? 5 : mod.DustType("AstralEnemy"), 1f, 4, 22); + + //if dead do gores + if (npc.life <= 0) + { + for (int i = 0; i < 5; i++) + { + float rand = Main.rand.NextFloat(-0.18f, 0.18f); + Gore.NewGore(npc.position + new Vector2(Main.rand.NextFloat(0f, npc.width), Main.rand.NextFloat(0f, npc.height)), npc.velocity * rand, mod.GetGoreSlot("Gores/BigSightseer/BigSightseerGore" + i)); + } + } + } + + public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) + { + spriteBatch.Draw(glowmask, npc.Center - Main.screenPosition + new Vector2(0, 4f), npc.frame, Color.White * 0.75f, npc.rotation, new Vector2(59f, 28f), npc.scale, npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + Tile tile = Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY]; + if (spawnInfo.player.GetModPlayer().ZoneAstral && (spawnInfo.player.ZoneOverworldHeight || spawnInfo.player.ZoneDirtLayerHeight)) + { + return spawnInfo.player.ZoneDesert ? 0.14f : (spawnInfo.player.ZoneRockLayerHeight ? 0.04f : 0.17f); + } + return 0f; + } + } + + public class AstralSeekerSpit : ModNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Seeker Spit"); + Main.npcFrameCount[npc.type] = 1; + } + + public override void SetDefaults() + { + npc.width = 16; + npc.height = 16; + npc.damage = 75; + npc.defense = 0; + npc.lifeMax = 1; + npc.HitSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyHit"); + npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyDeath"); + npc.noGravity = true; + npc.knockBackResist = 0f; + npc.noTileCollide = true; + npc.alpha = 80; + npc.aiStyle = -1; + } + + public override void AI() + { + //DUST + npc.ai[0] += 0.18f; + float angle = npc.velocity.ToRotation() + MathHelper.PiOver2; + float pulse = (float)Math.Sin(npc.ai[0]); + float radius = 5.8f; + Vector2 offset = angle.ToRotationVector2() * pulse * radius; + Dust pink = Dust.NewDustPerfect(npc.Center + offset, mod.DustType("AstralOrange"), Vector2.Zero); + Dust blue = Dust.NewDustPerfect(npc.Center - offset, mod.DustType("AstralBlue"), Vector2.Zero); + + //kill on tile collide + if (Collision.SolidCollision(npc.position, npc.width, npc.height)) + { + npc.StrikeNPCNoInteraction(9999, 0, 0); + } + } + + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit) + { + if (damage > 0) + { + npc.StrikeNPCNoInteraction(9999, 0, 0); + } + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + if (damage > 0) + { + npc.StrikeNPCNoInteraction(9999, 0, 0); + } + } + + //On death + public override bool PreNPCLoot() + { + DoKillDust(); + return false; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + return false; + } + + private void DoKillDust() + { + int numDust = Main.rand.Next(17, 25); + float rotPerIter = MathHelper.TwoPi / numDust; + float angle = 0; + for (int i = 0; i < numDust; i++) + { + Vector2 vel = (angle + Main.rand.NextFloat(-0.04f, 0.04f)).ToRotationVector2(); + int dustType = Main.rand.Next(2) == 0 ? mod.DustType("AstralOrange") : mod.DustType("AstralBlue"); + Dust d = Dust.NewDustPerfect(npc.Center, dustType, vel * Main.rand.NextFloat(1.8f, 2.2f)); + d.customData = npc; + + angle += rotPerIter; + } + } + } +} diff --git a/NPCs/AstralBiomeNPCs/BigSightseer.png b/NPCs/AstralBiomeNPCs/BigSightseer.png new file mode 100644 index 0000000000..6377a7f5a7 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/BigSightseer.png differ diff --git a/NPCs/AstralBiomeNPCs/BigSightseerGlow.png b/NPCs/AstralBiomeNPCs/BigSightseerGlow.png new file mode 100644 index 0000000000..2f71b8f224 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/BigSightseerGlow.png differ diff --git a/NPCs/AstralBiomeNPCs/FusionFeeder.cs b/NPCs/AstralBiomeNPCs/FusionFeeder.cs new file mode 100644 index 0000000000..69c92898ad --- /dev/null +++ b/NPCs/AstralBiomeNPCs/FusionFeeder.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.AstralBiomeNPCs +{ + public class FusionFeeder : ModNPC + { + private static Texture2D glowmask; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Fusion Feeder"); + glowmask = mod.GetTexture("NPCs/AstralBiomeNPCs/FusionFeederGlow"); + Main.npcFrameCount[npc.type] = 4; + } + + public override void SetDefaults() + { + npc.noGravity = true; + npc.width = 120; + npc.height = 24; + npc.damage = 64; + npc.aiStyle = 103; + npc.lifeMax = 600; + npc.defense = 22; + npc.value = 900f; + npc.knockBackResist = 0.7f; + npc.behindTiles = true; + npc.HitSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyHit"); + npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyDeath"); + + animationType = NPCID.SandShark; + } + + public override void FindFrame(int frameHeight) + { + //DO DUST + Dust d = CalamityGlobalNPC.SpawnDustOnNPC(npc, 134, frameHeight, mod.DustType("AstralOrange"), new Rectangle(46, 4, 60, 6), Vector2.Zero, 0.55f, true); + if (d != null) + { + d.customData = 0.04f; + } + } + + public override void HitEffect(int hitDirection, double damage) + { + CalamityGlobalNPC.DoHitDust(npc, hitDirection, (Main.rand.Next(0, Math.Max(0, npc.life)) == 0) ? 5 : mod.DustType("AstralEnemy"), 1f, 4, 25); + + //if dead do gores + if (npc.life <= 0) + { + for (int i = 0; i < 6; i++) + { + float rand = Main.rand.NextFloat(-0.18f, 0.18f); + Gore.NewGore(npc.position + new Vector2(Main.rand.NextFloat(0f, npc.width), Main.rand.NextFloat(0f, npc.height)), npc.velocity * rand, mod.GetGoreSlot("Gores/FusionFeeder/FusionFeederGore" + i)); + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + Vector2 offset = new Vector2(0f, 10f); + Vector2 origin = new Vector2(67f, 23f); + + //draw shark + spriteBatch.Draw(Main.npcTexture[npc.type], npc.Center - Main.screenPosition + offset, npc.frame, drawColor, npc.rotation, origin, 1f, npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + + //draw glowmask + spriteBatch.Draw(glowmask, npc.Center - Main.screenPosition + offset, npc.frame, Color.White * 0.6f, npc.rotation, origin, 1f, npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + + return false; + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.player.GetModPlayer().ZoneAstral && spawnInfo.player.ZoneDesert) + { + return 0.14f; + } + return 0f; + } + } +} diff --git a/NPCs/AstralBiomeNPCs/FusionFeeder.png b/NPCs/AstralBiomeNPCs/FusionFeeder.png new file mode 100644 index 0000000000..7c2cf38882 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/FusionFeeder.png differ diff --git a/NPCs/AstralBiomeNPCs/FusionFeederGlow.png b/NPCs/AstralBiomeNPCs/FusionFeederGlow.png new file mode 100644 index 0000000000..c99bfcc9d1 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/FusionFeederGlow.png differ diff --git a/NPCs/AstralBiomeNPCs/Hadarian.cs b/NPCs/AstralBiomeNPCs/Hadarian.cs new file mode 100644 index 0000000000..66ffdbdba6 --- /dev/null +++ b/NPCs/AstralBiomeNPCs/Hadarian.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.AstralBiomeNPCs +{ + public class Hadarian : ModNPC + { + private static Texture2D glowmask; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Hadarian"); + glowmask = mod.GetTexture("NPCs/AstralBiomeNPCs/HadarianGlow"); + Main.npcFrameCount[npc.type] = 7; + } + + public override void SetDefaults() + { + npc.width = 50; + npc.height = 40; + npc.aiStyle = -1; + npc.damage = 78; + npc.defense = 18; + npc.lifeMax = 490; + npc.HitSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyHit"); + npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyDeath"); + npc.knockBackResist = 0.65f; + npc.value = 450f; + } + + public override void AI() + { + CalamityGlobalNPC.DoVultureAI(npc, 0.15f, 3.5f, 32, 50, 150, 150); + + //usually done in framing but I put it here because it makes more sense to. + npc.rotation = npc.velocity.X * 0.1f; + } + + public override void FindFrame(int frameHeight) + { + if (npc.velocity.Y == 0f) + { + npc.spriteDirection = npc.direction; + } + else + { + if ((double)npc.velocity.X > 0.5) + { + npc.spriteDirection = 1; + } + if ((double)npc.velocity.X < -0.5) + { + npc.spriteDirection = -1; + } + } + + if (npc.velocity.X == 0f && npc.velocity.Y == 0f) + { + npc.frame.Y = 0; + npc.frameCounter = 0.0; + } + else + { + npc.frameCounter++; + if (npc.frameCounter > 5) + { + npc.frameCounter = 0; + npc.frame.Y += frameHeight; + } + if (npc.frame.Y > frameHeight * 6 || npc.frame.Y == 0) + { + npc.frame.Y = frameHeight; + } + } + + DoWingDust(frameHeight); + } + + private void DoWingDust(int frameHeight) + { + int frame = npc.frame.Y / frameHeight; + Dust d = null; + switch (frame) + { + case 1: + d = CalamityGlobalNPC.SpawnDustOnNPC(npc, 82, frameHeight, mod.DustType("AstralOrange"), new Rectangle(38, 16, 22, 20), Vector2.Zero, 0.35f); + break; + case 2: + d = CalamityGlobalNPC.SpawnDustOnNPC(npc, 82, frameHeight, mod.DustType("AstralOrange"), new Rectangle(38, 24, 30, 14), Vector2.Zero); + break; + case 3: + d = CalamityGlobalNPC.SpawnDustOnNPC(npc, 82, frameHeight, mod.DustType("AstralOrange"), new Rectangle(44, 28, 32, 20), Vector2.Zero); + break; + case 4: + d = CalamityGlobalNPC.SpawnDustOnNPC(npc, 82, frameHeight, mod.DustType("AstralOrange"), new Rectangle(42, 36, 18, 30), Vector2.Zero, 0.3f); + break; + } + + if (d != null) + { + d.customData = 0.03f; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + if (npc.ai[0] == 0f) + { + Vector2 position = npc.Bottom - new Vector2(19f, 42f); + //20 34 38 42 + Rectangle src = new Rectangle(20, 34, 38, 42); + spriteBatch.Draw(Main.npcTexture[npc.type], position - Main.screenPosition, src, drawColor, npc.rotation, default(Vector2), 1f, npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + //draw glowmask + spriteBatch.Draw(glowmask, position - Main.screenPosition, src, Color.White * 0.6f, npc.rotation, default(Vector2), 1f, npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + return false; + } + return true; + } + + public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) + { + if (npc.ai[0] != 0f) + { + Vector2 origin = new Vector2(41f, 39f); + + //draw glowmask + spriteBatch.Draw(glowmask, npc.Center - Main.screenPosition - new Vector2(0f, 12f), npc.frame, Color.White * 0.6f, npc.rotation, origin, 1f, npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + } + } + + public override void HitEffect(int hitDirection, double damage) + { + CalamityGlobalNPC.DoHitDust(npc, hitDirection, (Main.rand.Next(0, Math.Max(0, npc.life)) == 0) ? 5 : mod.DustType("AstralEnemy"), 1f, 3, 20); + + //if dead do gores + if (npc.life <= 0) + { + for (int i = 0; i < 5; i++) + { + Gore.NewGore(npc.Center, npc.velocity * 0.3f, mod.GetGoreSlot("Gores/Hadarian/HadarianGore" + i)); + } + } + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + Tile tile = Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY]; + if (spawnInfo.player.GetModPlayer().ZoneAstral && spawnInfo.player.ZoneDesert && spawnInfo.spawnTileType == mod.TileType("AstralSand") && tile.wall == WallID.None) + { + return 0.25f; + } + return 0f; + } + } +} diff --git a/NPCs/AstralBiomeNPCs/Hadarian.png b/NPCs/AstralBiomeNPCs/Hadarian.png new file mode 100644 index 0000000000..43e0f5d8dd Binary files /dev/null and b/NPCs/AstralBiomeNPCs/Hadarian.png differ diff --git a/NPCs/AstralBiomeNPCs/HadarianGlow.png b/NPCs/AstralBiomeNPCs/HadarianGlow.png new file mode 100644 index 0000000000..55bb52a1cb Binary files /dev/null and b/NPCs/AstralBiomeNPCs/HadarianGlow.png differ diff --git a/NPCs/AstralBiomeNPCs/Hive.cs b/NPCs/AstralBiomeNPCs/Hive.cs new file mode 100644 index 0000000000..c6cb45abad --- /dev/null +++ b/NPCs/AstralBiomeNPCs/Hive.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.AstralBiomeNPCs +{ + public class Hive : ModNPC + { + private static Texture2D glowmask; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Hive"); + glowmask = mod.GetTexture("NPCs/AstralBiomeNPCs/HiveGlow"); + Main.npcFrameCount[npc.type] = 6; + } + + public override void SetDefaults() + { + npc.width = 38; + npc.height = 60; + npc.aiStyle = -1; + npc.damage = 90; + npc.defense = 25; + npc.lifeMax = 700; + npc.HitSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyHit"); + npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyDeath"); + npc.knockBackResist = 0f; + npc.value = 550f; + } + + public override void AI() + { + npc.ai[0]++; + if (npc.ai[0] > 180) + { + if (Main.rand.Next(100) == 0) + { + npc.ai[0] = 0; + + //spawn hiveling, it's ai[0] is the hive npc index. + int n = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("Hiveling"), 0, npc.whoAmI); + Main.npc[n].velocity.X = Main.rand.NextFloat(-0.4f, 0.4f); + Main.npc[n].velocity.Y = Main.rand.NextFloat(-0.5f, -0.05f); + } + } + } + + public override void FindFrame(int frameHeight) + { + npc.frameCounter++; + if (npc.frameCounter > 10) + { + npc.frameCounter = 0; + npc.frame.Y += frameHeight; + if (npc.frame.Y > frameHeight * 4) + { + npc.frame.Y = 0; + } + } + } + + public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) + { + //draw glowmask + spriteBatch.Draw(glowmask, npc.Center - Main.screenPosition, npc.frame, Color.White * 0.6f, npc.rotation, new Vector2(19, 30), 1f, npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + } + + public override void HitEffect(int hitDirection, double damage) + { + CalamityGlobalNPC.DoHitDust(npc, hitDirection, (Main.rand.Next(0, Math.Max(0, npc.life)) == 0) ? 5 : mod.DustType("AstralEnemy"), 1f, 3, 20); + + //if dead do gores + if (npc.life <= 0) + { + for (int i = 0; i < 5; i++) + { + Gore.NewGore(npc.Center, npc.velocity * 0.3f, mod.GetGoreSlot("Gores/Hadarian/HadarianGore" + i)); + } + + int type = mod.NPCType("Hiveling"); + for (int i = 0; i < 200; i++) + { + if (Main.npc[i].type == type) + { + Main.npc[i].ai[0] = -1f; + } + } + } + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + //only 1 hive possible. + bool anyHives = NPC.CountNPCS(npc.type) > 0; + if (anyHives) return 0f; + + Tile tile = Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY]; + if (spawnInfo.player.GetModPlayer().ZoneAstral && (spawnInfo.player.ZoneDirtLayerHeight || spawnInfo.player.ZoneRockLayerHeight)) + { + return 0.17f; + } + return 0f; + } + } +} diff --git a/NPCs/AstralBiomeNPCs/Hive.png b/NPCs/AstralBiomeNPCs/Hive.png new file mode 100644 index 0000000000..fcd1ef8827 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/Hive.png differ diff --git a/NPCs/AstralBiomeNPCs/HiveGlow.png b/NPCs/AstralBiomeNPCs/HiveGlow.png new file mode 100644 index 0000000000..eae1314103 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/HiveGlow.png differ diff --git a/NPCs/AstralBiomeNPCs/Hiveling.cs b/NPCs/AstralBiomeNPCs/Hiveling.cs new file mode 100644 index 0000000000..3ef08b1750 --- /dev/null +++ b/NPCs/AstralBiomeNPCs/Hiveling.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.AstralBiomeNPCs +{ + public class Hiveling : ModNPC + { + private static Texture2D glowmask; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Hiveling"); + glowmask = mod.GetTexture("NPCs/AstralBiomeNPCs/HivelingGlow"); + Main.npcFrameCount[npc.type] = 4; + } + + public override void SetDefaults() + { + npc.width = 50; + npc.height = 40; + npc.aiStyle = -1; + npc.damage = 50; + npc.defense = 8; + npc.lifeMax = 220; + npc.HitSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyHit"); + npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyDeath"); + npc.knockBackResist = 0.4f; + npc.noGravity = true; + npc.value = 100f; + } + + public override void AI() + { + if (npc.ai[1] == 0f) + { + npc.velocity *= 0.97f; + + npc.TargetClosest(false); + if (Main.player[npc.target].dead) + { + npc.TargetClosest(false); + } + Player targ = Main.player[npc.target]; + + if (Collision.CanHit(npc.position, npc.width, npc.height, targ.position, targ.width, targ.height) || Vector2.Distance(npc.Center, targ.MountedCenter) < 320f) + { + npc.ai[1] = 1f; + } + } + else + { + CalamityGlobalNPC.DoFlyingAI(npc, 3f, 0.05f, 200f); + } + } + + public override void FindFrame(int frameHeight) + { + npc.frameCounter += 0.05f + npc.velocity.Length() * 0.667f; + if (npc.frameCounter >= 8) + { + npc.frameCounter = 0; + npc.frame.Y += frameHeight; + if (npc.frame.Y > npc.height * 2) + { + npc.frame.Y = 0; + } + } + + //DO DUST + Dust d = CalamityGlobalNPC.SpawnDustOnNPC(npc, 30, frameHeight, mod.DustType("AstralOrange"), new Rectangle(16, 8, 6, 6), Vector2.Zero, 0.3f, true); + if (d != null) + { + d.customData = 0.04f; + } + } + + public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) + { + //draw glowmask + spriteBatch.Draw(glowmask, npc.Center - Main.screenPosition + new Vector2(0, 8), npc.frame, Color.White * 0.6f, npc.rotation, new Vector2(15, 10), 1f, npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + } + + public override void HitEffect(int hitDirection, double damage) + { + CalamityGlobalNPC.DoHitDust(npc, hitDirection, (Main.rand.Next(0, Math.Max(0, npc.life)) == 0) ? 5 : mod.DustType("AstralEnemy"), 1f, 3, 20); + + //if dead do gores + if (npc.life <= 0) + { + for (int i = 0; i < 5; i++) + { + Gore.NewGore(npc.Center, npc.velocity * 0.3f, mod.GetGoreSlot("Gores/Hadarian/HadarianGore" + i)); + } + } + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + return 0f; + } + } +} diff --git a/NPCs/AstralBiomeNPCs/Hiveling.png b/NPCs/AstralBiomeNPCs/Hiveling.png new file mode 100644 index 0000000000..c4e18b5159 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/Hiveling.png differ diff --git a/NPCs/AstralBiomeNPCs/HivelingGlow.png b/NPCs/AstralBiomeNPCs/HivelingGlow.png new file mode 100644 index 0000000000..5361ea3169 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/HivelingGlow.png differ diff --git a/NPCs/AstralBiomeNPCs/Mantis.cs b/NPCs/AstralBiomeNPCs/Mantis.cs new file mode 100644 index 0000000000..3fff3d4719 --- /dev/null +++ b/NPCs/AstralBiomeNPCs/Mantis.cs @@ -0,0 +1,206 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.AstralBiomeNPCs +{ + public class Mantis : ModNPC + { + private static Texture2D glowmask; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Mantis"); + Main.npcFrameCount[npc.type] = 14; + glowmask = mod.GetTexture("NPCs/AstralBiomeNPCs/MantisGlow"); + } + + public override void SetDefaults() + { + npc.damage = 85; + npc.width = 60; + npc.height = 58; + npc.aiStyle = -1; + npc.defense = 16; + npc.lifeMax = 510; + npc.knockBackResist = 0.1f; + npc.value = 450f; + npc.HitSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyHit"); + npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyDeath"); + } + + public override void AI() + { + npc.TargetClosest(false); + + Player target = Main.player[npc.target]; + + if (npc.ai[0] == 0f) + { + float acceleration = 0.045f; + float maxSpeed = 6.8f; + if (npc.Center.X > target.Center.X) + { + npc.velocity.X -= acceleration; + if (npc.velocity.X > 0) + { + npc.velocity.X -= acceleration; + } + if (npc.velocity.X < -maxSpeed) + { + npc.velocity.X = -maxSpeed; + } + } + else + { + npc.velocity.X += acceleration; + if (npc.velocity.X < 0) + { + npc.velocity.X += acceleration; + } + if (npc.velocity.X > maxSpeed) + { + npc.velocity.X = maxSpeed; + } + } + + //if need to jump + if (npc.velocity.Y == 0 && (HoleBelow() || (npc.collideX && npc.position.X == npc.oldPosition.X))) + { + npc.velocity.Y = -5f; + } + + //check if we can shoot at target. + Vector2 vector = npc.Center - target.Center; + if (Math.Abs(vector.Y) < 64 && Math.Abs(vector.X) < 540 && Collision.CanHit(npc.position, npc.width, npc.height, target.position, target.width, target.height)) + { + npc.ai[1]++; + if (npc.ai[1] > 120) + { + //fire projectile + npc.ai[0] = 1f; + npc.ai[1] = npc.ai[2] = 0f; + npc.frame.Y = 400; + npc.frameCounter = 0; + } + } + else + { + npc.ai[1] -= 0.5f; + } + + if (npc.justHit) + { + npc.ai[1] -= 60f; + } + + + if (npc.ai[1] < 0) npc.ai[1] = 0f; + } + else + { + npc.ai[2]++; + npc.velocity.X *= 0.95f; + if (npc.ai[2] == 25f) + { + Vector2 vector = Main.player[npc.target].Center - npc.Center; + vector.Normalize(); + Projectile.NewProjectile(npc.Center + (npc.Center.X < target.Center.X ? -14f : 14f) * Vector2.UnitX, vector * 7f, mod.ProjectileType("MantisRing"), 76, 0.5f); + } + } + + npc.direction = npc.Center.X > target.Center.X ? 0 : 1; + npc.spriteDirection = npc.direction; + } + + private bool HoleBelow() + { + //width of npc in tiles + int tileWidth = 4; + int tileX = (int)(npc.Center.X / 16f) - tileWidth; + if (npc.velocity.X > 0) //if moving right + { + tileX += tileWidth; + } + int tileY = (int)((npc.position.Y + npc.height) / 16f); + for (int y = tileY; y < tileY + 2; y++) + { + for (int x = tileX; x < tileX + tileWidth; x++) + { + if (Main.tile[x, y].active()) + { + return false; + } + } + } + return true; + } + + public override void FindFrame(int frameHeight) + { + if (npc.ai[0] == 0f) + { + if (npc.velocity.Y != 0) + { + npc.frame.Y = frameHeight * 13; + npc.frameCounter = 20; + } + else + { + npc.frameCounter += 0.8f + Math.Abs(npc.velocity.X) * 0.5f; + if (npc.frameCounter > 10.0) + { + npc.frameCounter = 0; + npc.frame.Y += frameHeight; + if (npc.frame.Y > frameHeight * 5) + { + npc.frame.Y = 0; + } + } + } + } + else + { + npc.frameCounter++; + if (npc.frameCounter > 4) + { + npc.frameCounter = 0; + npc.frame.Y += frameHeight; + if (npc.frame.Y >= frameHeight * 13) + { + npc.frame.Y = 0; + npc.frameCounter = 0; + npc.ai[0] = 0f; + } + } + } + } + + public override void HitEffect(int hitDirection, double damage) + { + CalamityGlobalNPC.DoHitDust(npc, hitDirection, mod.DustType("AstralOrange"), 1f, 4, 24); + } + + public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) + { + //draw glowmask + spriteBatch.Draw(glowmask, npc.Center - Main.screenPosition - new Vector2(0, 8), npc.frame, Color.White * 0.6f, npc.rotation, new Vector2(70, 40), 1f, npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.player.GetModPlayer().ZoneAstral && !spawnInfo.player.ZoneRockLayerHeight) + { + return 0.16f; + } + return 0f; + } + } +} diff --git a/NPCs/AstralBiomeNPCs/Mantis.png b/NPCs/AstralBiomeNPCs/Mantis.png new file mode 100644 index 0000000000..1226f549e8 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/Mantis.png differ diff --git a/NPCs/AstralBiomeNPCs/MantisGlow.png b/NPCs/AstralBiomeNPCs/MantisGlow.png new file mode 100644 index 0000000000..d086785f71 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/MantisGlow.png differ diff --git a/NPCs/AstralBiomeNPCs/Nova.cs b/NPCs/AstralBiomeNPCs/Nova.cs new file mode 100644 index 0000000000..4f613cafa1 --- /dev/null +++ b/NPCs/AstralBiomeNPCs/Nova.cs @@ -0,0 +1,237 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.DataStructures; + +namespace CalamityMod.NPCs.AstralBiomeNPCs +{ + public class Nova : ModNPC + { + private static Texture2D glowmask; + + private const float travelAcceleration = 0.2f; + private const float targetTime = 120f; + private const float waitBeforeTravel = 20f; + private const float maxTravelTime = 300f; + private const float slowdown = 0.84f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Nova"); + Main.npcFrameCount[npc.type] = 8; + + glowmask = mod.GetTexture("NPCs/AstralBiomeNPCs/NovaGlow"); + } + + public override void SetDefaults() + { + npc.width = 78; + npc.height = 50; + npc.damage = 75; + npc.defense = 25; + npc.lifeMax = 350; + npc.HitSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyHit"); + npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyDeath"); + npc.noGravity = true; + npc.knockBackResist = 0.4f; + npc.value = 1100; + npc.aiStyle = -1; + } + + public override void FindFrame(int frameHeight) + { + npc.frameCounter++; + if (npc.ai[3] >= 0f) + { + if (npc.frameCounter >= 8) + { + npc.frameCounter = 0; + npc.frame.Y += frameHeight; + if (npc.frame.Y >= frameHeight * 4) + { + npc.frame.Y = 0; + } + } + } + else + { + if (npc.frameCounter >= 7) + { + npc.frameCounter = 0; + npc.frame.Y += frameHeight; + if (npc.frame.Y >= frameHeight * 8) + { + npc.frame.Y = frameHeight * 4; + } + } + } + + //DO DUST + Dust d = CalamityGlobalNPC.SpawnDustOnNPC(npc, 114, frameHeight, mod.DustType("AstralOrange"), new Rectangle(78, 34, 36, 18), Vector2.Zero, 0.45f, true); + if (d != null) + { + d.customData = 0.04f; + } + } + + public override void AI() + { + Player target = Main.player[npc.target]; + if (npc.ai[3] >= 0) + { + CalamityGlobalNPC.DoFlyingAI(npc, 5.5f, 0.035f, 400f, 150, false); + + if (Collision.CanHit(npc.position, npc.width, npc.height, target.position, target.width, target.height)) + { + npc.ai[3]++; + } + else + { + npc.ai[3] = 0f; + } + + Vector2 between = target.Center - npc.Center; + + //after locking target for x amount of time and being far enough away + if (between.Length() > 150 && npc.ai[3] >= targetTime && Main.rand.Next(180) == 0) + { + //set ai mode to target and travel + npc.ai[3] = -1f; + } + return; + } + else + { + npc.ai[3]--; + Vector2 between = target.Center - npc.Center; + + if (npc.ai[3] < -waitBeforeTravel) + { + if (npc.collideX || npc.collideY || npc.ai[3] < -maxTravelTime) + { + Explode(); + } + + npc.velocity += new Vector2(npc.ai[1], npc.ai[2]) * travelAcceleration; //acceleration per frame + + //rotation + npc.rotation = npc.velocity.ToRotation(); + } + else if (npc.ai[3] == -waitBeforeTravel) + { + between.Normalize(); + npc.ai[1] = between.X; + npc.ai[2] = between.Y; + + //rotation + npc.rotation = between.ToRotation(); + npc.velocity = Vector2.Zero; + } + else + { + //slowdown + npc.velocity *= slowdown; + + //rotation + npc.rotation = between.ToRotation(); + } + npc.rotation += MathHelper.Pi; + } + } + + private void Explode() + { + //kill NPC + Main.PlaySound(SoundID.Item14, npc.Center); + + //change stuffs + Vector2 center = npc.Center; + npc.width = 200; + npc.height = 200; + npc.Center = center; + + Rectangle myRect = npc.getRect(); + + if (Main.netMode != 1) + { + for (int i = 0; i < 200; i++) + { + if (Main.player[i].getRect().Intersects(myRect)) + { + int direction = npc.Center.X - Main.player[i].Center.X < 0 ? -1 : 1; + Main.player[i].Hurt(PlayerDeathReason.ByNPC(npc.whoAmI), 100, direction); + } + } + } + + //other things + npc.ai[3] = -20000f; + npc.value = 0f; + npc.extraValue = 0f; + npc.StrikeNPCNoInteraction(9999, 1f, 1); + + int size = 30; + Vector2 off = new Vector2(size / -2f); + + for (int i = 0; i < 45; i++) + { + int dust = Dust.NewDust(npc.Center - off, size, size, mod.DustType("AstralEnemy"), Main.rand.NextFloat(-3f, 3f), Main.rand.NextFloat(-3f, 3f), 0, default(Color), Main.rand.NextFloat(1f, 2f)); + Main.dust[dust].velocity *= 1.4f; + } + for (int i = 0; i < 15; i++) + { + int dust = Dust.NewDust(npc.Center - off, size, size, 31, 0f, 0f, 100, default(Color), 1.7f); + Main.dust[dust].velocity *= 1.4f; + } + for (int i = 0; i < 27; i++) + { + int dust = Dust.NewDust(npc.Center - off, size, size, 6, 0f, 0f, 100, default(Color), 2.4f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 5f; + dust = Dust.NewDust(npc.Center - off, size, size, 6, 0f, 0f, 100, default(Color), 1.6f); + Main.dust[dust].velocity *= 3f; + } + } + + public override void HitEffect(int hitDirection, double damage) + { + CalamityGlobalNPC.DoHitDust(npc, hitDirection, (Main.rand.Next(0, Math.Max(0, npc.life)) == 0) ? 5 : mod.DustType("AstralEnemy"), 1f, 3, 40); + + //if dead do gores + if (npc.life <= 0) + { + for (int i = 0; i < 7; i++) + { + Gore.NewGore(npc.Center, npc.velocity * 0.3f, mod.GetGoreSlot("Gores/Nova/NovaGore" + i)); + } + } + } + + public override bool PreNPCLoot() + { + return npc.ai[3] > -10000; + } + + public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) + { + spriteBatch.Draw(glowmask, npc.Center - Main.screenPosition - new Vector2(0, 4f), npc.frame, Color.White * 0.75f, npc.rotation, new Vector2(57f, 37f), npc.scale, npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.player.GetModPlayer().ZoneAstral && spawnInfo.player.ZoneOverworldHeight) + { + return 0.19f; + } + return 0f; + } + } +} diff --git a/NPCs/AstralBiomeNPCs/Nova.png b/NPCs/AstralBiomeNPCs/Nova.png new file mode 100644 index 0000000000..b7bb8f7f11 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/Nova.png differ diff --git a/NPCs/AstralBiomeNPCs/NovaGlow.png b/NPCs/AstralBiomeNPCs/NovaGlow.png new file mode 100644 index 0000000000..21a89a0cf3 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/NovaGlow.png differ diff --git a/NPCs/AstralBiomeNPCs/SmallSightseer.cs b/NPCs/AstralBiomeNPCs/SmallSightseer.cs new file mode 100644 index 0000000000..c70f4839d5 --- /dev/null +++ b/NPCs/AstralBiomeNPCs/SmallSightseer.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.AstralBiomeNPCs +{ + public class SmallSightseer : ModNPC + { + private static Texture2D glowmask; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Small Sightseer"); + Main.npcFrameCount[npc.type] = 4; + + glowmask = mod.GetTexture("NPCs/AstralBiomeNPCs/SmallSightseerGlow"); + } + + public override void SetDefaults() + { + npc.width = 48; + npc.height = 40; + npc.damage = 58; + npc.defense = 26; + npc.lifeMax = 460; + npc.HitSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyHit"); + npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyDeath"); + npc.noGravity = true; + npc.knockBackResist = 0.48f; + npc.value = 600; + npc.aiStyle = -1; + } + + public override void FindFrame(int frameHeight) + { + npc.frameCounter += 0.05f + npc.velocity.Length() * 0.667f; + if (npc.frameCounter >= 8) + { + npc.frameCounter = 0; + npc.frame.Y += frameHeight; + if (npc.frame.Y > npc.height * 2) + { + npc.frame.Y = 0; + } + } + + //DO DUST + Dust d = CalamityGlobalNPC.SpawnDustOnNPC(npc, 80, frameHeight, mod.DustType("AstralOrange"), new Rectangle(16, 8, 6, 6), Vector2.Zero, 0.45f, true); + if (d != null) + { + d.customData = 0.04f; + } + } + + public override void AI() + { + CalamityGlobalNPC.DoFlyingAI(npc, 5.8f, 0.03f, 350f); + } + + public override void HitEffect(int hitDirection, double damage) + { + CalamityGlobalNPC.DoHitDust(npc, hitDirection, (Main.rand.Next(0, Math.Max(0, npc.life)) == 0) ? 5 : mod.DustType("AstralEnemy"), 1f, 4, 22); + + //if dead do gores + if (npc.life <= 0) + { + for (int i = 0; i < 5; i++) + { + float rand = Main.rand.NextFloat(-0.18f, 0.18f); + Gore.NewGore(npc.position + new Vector2(Main.rand.NextFloat(0f, npc.width), Main.rand.NextFloat(0f, npc.height)), npc.velocity * rand, mod.GetGoreSlot("Gores/SmallSightseer/SmallSightseerGore" + i)); + } + } + } + + public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) + { + spriteBatch.Draw(glowmask, npc.Center - Main.screenPosition + new Vector2(0, 4f), new Rectangle(0, npc.frame.Y, 80, npc.frame.Height), Color.White * 0.75f, npc.rotation, new Vector2(40f, 20f), npc.scale, npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + Tile tile = Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY]; + if (spawnInfo.player.GetModPlayer().ZoneAstral && (spawnInfo.player.ZoneOverworldHeight || spawnInfo.player.ZoneDirtLayerHeight)) + { + return spawnInfo.player.ZoneDesert ? 0.16f : (spawnInfo.player.ZoneRockLayerHeight ? 0.08f : 0.2f); + } + return 0f; + } + } +} diff --git a/NPCs/AstralBiomeNPCs/SmallSightseer.png b/NPCs/AstralBiomeNPCs/SmallSightseer.png new file mode 100644 index 0000000000..02b5a655bd Binary files /dev/null and b/NPCs/AstralBiomeNPCs/SmallSightseer.png differ diff --git a/NPCs/AstralBiomeNPCs/SmallSightseerGlow.png b/NPCs/AstralBiomeNPCs/SmallSightseerGlow.png new file mode 100644 index 0000000000..1afb267655 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/SmallSightseerGlow.png differ diff --git a/NPCs/AstralBiomeNPCs/StellarCulex.cs b/NPCs/AstralBiomeNPCs/StellarCulex.cs new file mode 100644 index 0000000000..024027b1fc --- /dev/null +++ b/NPCs/AstralBiomeNPCs/StellarCulex.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.AstralBiomeNPCs +{ + public class StellarCulex : ModNPC + { + private static Texture2D glowmask; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Stellar Culex"); + glowmask = mod.GetTexture("NPCs/AstralBiomeNPCs/StellarCulexGlow"); + Main.npcFrameCount[npc.type] = 4; + } + + public override void SetDefaults() + { + npc.width = 60; + npc.height = 50; + npc.aiStyle = 14; //bats + npc.npcSlots = 0.5f; //needed? + npc.damage = 90; + npc.defense = 28; + npc.knockBackResist = 0.55f; + npc.lifeMax = 320; + npc.value = 700f; + npc.HitSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyHit"); + npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCHit, "Sounds/NPCHit/AstralEnemyDeath"); + npc.buffImmune[31] = false; + + animationType = NPCID.GiantFlyingFox; + } + + public override void FindFrame(int frameHeight) + { + //DO DUST + int frame = npc.frame.Y / frameHeight; + Dust d = CalamityGlobalNPC.SpawnDustOnNPC(npc, 100, frameHeight, mod.DustType("AstralOrange"), new Rectangle(66, 10, (frame == 0 || frame == 3) ? 32 : 24, 16), Vector2.Zero, 0.45f, true); + if (d != null) + { + d.customData = 0.04f; + } + } + + public override void HitEffect(int hitDirection, double damage) + { + CalamityGlobalNPC.DoHitDust(npc, hitDirection, (Main.rand.Next(0, Math.Max(0, npc.life)) == 0) ? 5 : mod.DustType("AstralEnemy"), 1f, 4, 22); + + //if dead do gores + if (npc.life <= 0) + { + for (int i = 0; i < 6; i++) + { + Gore.NewGore(npc.Center, npc.velocity * 0.3f, mod.GetGoreSlot("Gores/StellarCulex/StellarCulexGore" + i)); + } + } + } + + public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) + { + Vector2 origin = new Vector2(50, 30f); + spriteBatch.Draw(glowmask, npc.Center - Main.screenPosition, npc.frame, Color.White * 0.6f, npc.rotation, origin, 1f, npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + } + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.player.GetModPlayer().ZoneAstral && spawnInfo.player.ZoneRockLayerHeight) + { + return 0.16f; + } + return 0f; + } + } +} diff --git a/NPCs/AstralBiomeNPCs/StellarCulex.png b/NPCs/AstralBiomeNPCs/StellarCulex.png new file mode 100644 index 0000000000..a20b4a225f Binary files /dev/null and b/NPCs/AstralBiomeNPCs/StellarCulex.png differ diff --git a/NPCs/AstralBiomeNPCs/StellarCulexGlow.png b/NPCs/AstralBiomeNPCs/StellarCulexGlow.png new file mode 100644 index 0000000000..75d4870570 Binary files /dev/null and b/NPCs/AstralBiomeNPCs/StellarCulexGlow.png differ diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index ec715c178d..d0986c5e05 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -11378,8 +11378,8 @@ namespace CalamityMod.NPCs } else if (player.GetModPlayer(mod).ZoneAstral) { - spawnRate = (int)((double)spawnRate * 0.4); - maxSpawns = (int)((float)maxSpawns * 1.1f); + spawnRate = (int)((double)spawnRate * 0.5); + maxSpawns = (int)((float)maxSpawns * 1.15f); } if (CalamityWorld.revenge) { @@ -11421,7 +11421,7 @@ namespace CalamityMod.NPCs public override void EditSpawnPool(IDictionary pool, NPCSpawnInfo spawnInfo) { if (spawnInfo.player.GetModPlayer(mod).ZoneAbyss || spawnInfo.player.GetModPlayer(mod).ZoneCalamity || - spawnInfo.player.GetModPlayer(mod).ZoneSulphur) + spawnInfo.player.GetModPlayer(mod).ZoneSulphur || spawnInfo.player.GetModPlayer(mod).ZoneAstral) { pool[0] = 0f; } @@ -11939,5 +11939,503 @@ namespace CalamityMod.NPCs return false; } #endregion + + #region Astral things + public static void DoHitDust(NPC npc, int hitDirection, int dustType = 5, float xSpeedMult = 1f, int numHitDust = 5, int numDeathDust = 20) + { + for (int k = 0; k < 5; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, dustType, hitDirection * xSpeedMult, -1f, 0, default(Color), 1f); + } + if (npc.life <= 0) + { + for (int k = 0; k < 20; k++) + { + Dust.NewDust(npc.position, npc.width, npc.height, dustType, hitDirection * xSpeedMult, -1f, 0, default(Color), 1f); + } + } + } + + public static void DoFlyingAI(NPC npc, float maxSpeed, float acceleration, float circleTime, float minDistanceTarget = 150f, bool shouldAttackTarget = true) + { + //Pick a new target. + if (npc.target < 0 || npc.target >= 255 || Main.player[npc.target].dead) + { + npc.TargetClosest(true); + } + + Player myTarget = Main.player[npc.target]; + Vector2 toTarget = (myTarget.Center - npc.Center); + float distanceToTarget = toTarget.Length(); + + Vector2 maxVelocity = toTarget; + + if (distanceToTarget < 3f) + { + maxVelocity = npc.velocity; + } + else + { + float magnitude = maxSpeed / distanceToTarget; + maxVelocity *= magnitude; + } + + //Circular motion + npc.ai[0]++; + //y motion + if (npc.ai[0] > circleTime * 0.5f) + { + npc.velocity.Y += acceleration; + } + else + { + npc.velocity.Y -= acceleration; + } + //x motion + if (npc.ai[0] < circleTime * 0.25f || npc.ai[0] > circleTime * 0.75f) + { + npc.velocity.X += acceleration; + } + else + { + npc.velocity.X -= acceleration; + } + //reset + if (npc.ai[0] > circleTime) + { + npc.ai[0] = 0f; + } + + //if close enough + if (shouldAttackTarget && distanceToTarget < minDistanceTarget) + { + npc.velocity += maxVelocity * 0.007f; + } + + if (myTarget.dead) + { + maxVelocity.X = npc.direction * maxSpeed / 2f; + maxVelocity.Y = -maxSpeed / 2f; + } + + //maximise velocity + if (npc.velocity.X < maxVelocity.X) + { + npc.velocity.X += acceleration; + } + if (npc.velocity.X > maxVelocity.X) + { + npc.velocity.X -= acceleration; + } + if (npc.velocity.Y < maxVelocity.Y) + { + npc.velocity.Y += acceleration; + } + if (npc.velocity.Y > maxVelocity.Y) + { + npc.velocity.Y -= acceleration; + } + + //rotate towards player if alive + if (!myTarget.dead) + { + npc.rotation = toTarget.ToRotation(); + } + else //don't, do velocity instead + { + npc.rotation = npc.velocity.ToRotation(); + } + + npc.rotation += MathHelper.Pi; + + //tile collision + float collisionDamp = 0.7f; + if (npc.collideX) + { + npc.netUpdate = true; + npc.velocity.X = npc.oldVelocity.X * -collisionDamp; + if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) + { + npc.velocity.X = 2f; + } + if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -2f) + { + npc.velocity.X = -2f; + } + } + if (npc.collideY) + { + npc.netUpdate = true; + npc.velocity.Y = npc.oldVelocity.Y * -collisionDamp; + if (npc.velocity.Y > 0f && npc.velocity.Y < 1.5f) + { + npc.velocity.Y = 1.5f; + } + if (npc.velocity.Y < 0f && npc.velocity.Y > -1.5f) + { + npc.velocity.Y = -1.5f; + } + } + + //water collision + if (npc.wet) + { + if (npc.velocity.Y > 0f) + { + npc.velocity.Y *= 0.95f; + } + npc.velocity.Y -= 0.3f; + if (npc.velocity.Y < -2f) npc.velocity.Y = -2f; + } + + //Taken from source. Important for net? + if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) + { + npc.netUpdate = true; + } + } + + public static void DoSpiderWallAI(NPC npc, int transformType, float chaseMaxSpeed = 2f, float chaseAcceleration = 0.08f) + { + //GET NEW TARGET + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) + { + npc.TargetClosest(); + } + + Vector2 between = Main.player[npc.target].Center - npc.Center; + float distance = between.Length(); + + //modify vector depending on distance and speed. + if (distance == 0f) + { + between.X = npc.velocity.X; + between.Y = npc.velocity.Y; + } + else + { + distance = chaseMaxSpeed / distance; + between.X *= distance; + between.Y *= distance; + } + + //update if target dead. + if (Main.player[npc.target].dead) + { + between.X = (float)npc.direction * chaseMaxSpeed / 2f; + between.Y = -chaseMaxSpeed / 2f; + } + + npc.spriteDirection = -1; + + //If spider can't see target, circle around to attempt to find the target. + if (!Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + { + //CIRCULAR MOTION, SIMILAR TO FLYING AI (Eater of Souls etc.) + npc.ai[0]++; + if (npc.ai[0] > 0f) + { + npc.velocity.Y += 0.023f; + } + else + { + npc.velocity.Y -= 0.023f; + } + if (npc.ai[0] < -100f || npc.ai[0] > 100f) + { + npc.velocity.X += 0.023f; + } + else + { + npc.velocity.X -= 0.023f; + } + if (npc.ai[0] > 200f) + { + npc.ai[0] = -200f; + } + + npc.velocity.X += between.X * 0.007f; + npc.velocity.Y += between.Y * 0.007f; + npc.rotation = npc.velocity.ToRotation(); + + if (npc.velocity.X > 1.5f) + { + npc.velocity.X *= 0.9f; + } + if (npc.velocity.X < -1.5f) + { + npc.velocity.X *= 0.9f; + } + if (npc.velocity.Y > 1.5f) + { + npc.velocity.Y *= 0.9f; + } + if (npc.velocity.Y < -1.5f) + { + npc.velocity.Y *= 0.9f; + } + npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -3f, 3f); + npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y, -3f, 3f); + } + else //CHASE TARGET + { + if (npc.velocity.X < between.X) + { + npc.velocity.X = npc.velocity.X + chaseAcceleration; + if (npc.velocity.X < 0f && between.X > 0f) + { + npc.velocity.X = npc.velocity.X + chaseAcceleration; + } + } + else if (npc.velocity.X > between.X) + { + npc.velocity.X = npc.velocity.X - chaseAcceleration; + if (npc.velocity.X > 0f && between.X < 0f) + { + npc.velocity.X = npc.velocity.X - chaseAcceleration; + } + } + if (npc.velocity.Y < between.Y) + { + npc.velocity.Y = npc.velocity.Y + chaseAcceleration; + if (npc.velocity.Y < 0f && between.Y > 0f) + { + npc.velocity.Y = npc.velocity.Y + chaseAcceleration; + } + } + else if (npc.velocity.Y > between.Y) + { + npc.velocity.Y = npc.velocity.Y - chaseAcceleration; + if (npc.velocity.Y > 0f && between.Y < 0f) + { + npc.velocity.Y = npc.velocity.Y - chaseAcceleration; + } + } + npc.rotation = between.ToRotation(); + } + + //DAMP COLLISIONS OFF OF WALLS + float collisionDamp = 0.5f; + if (npc.collideX) + { + npc.netUpdate = true; + npc.velocity.X = npc.oldVelocity.X * -collisionDamp; + if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) + { + npc.velocity.X = 2f; + } + if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -2f) + { + npc.velocity.X = -2f; + } + } + if (npc.collideY) + { + npc.netUpdate = true; + npc.velocity.Y = npc.oldVelocity.Y * -collisionDamp; + if (npc.velocity.Y > 0f && npc.velocity.Y < 1.5f) + { + npc.velocity.Y = 2f; + } + if (npc.velocity.Y < 0f && npc.velocity.Y > -1.5f) + { + npc.velocity.Y = -2f; + } + } + + if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) + { + npc.netUpdate = true; + } + + if (Main.netMode != 1) + { + int x = (int)npc.Center.X / 16; + int y = (int)npc.Center.Y / 16; + bool flag = false; + for (int i = x - 1; i <= x + 1; i++) + { + for (int j = y - 1; j <= y + 1; j++) + { + if (Main.tile[i, j] == null) + { + return; + } + if (Main.tile[i, j].wall > 0) + { + flag = true; + } + } + } + if (!flag) + { + npc.Transform(transformType); + return; + } + } + } + + public static void DoVultureAI(NPC npc, float acceleration = 0.1f, float maxSpeed = 3f, int sitWidth = 30, int flyWidth = 50, int rangeX = 100, int rangeY = 100) + { + npc.localAI[0]++; + npc.noGravity = true; + npc.TargetClosest(true); + if (npc.ai[0] == 0f) + { + npc.width = sitWidth; + npc.noGravity = false; + if (Main.netMode != 1) + { + if (npc.velocity.X != 0f || npc.velocity.Y < 0f || (double)npc.velocity.Y > 0.3) + { + npc.ai[0] = 1f; + npc.netUpdate = true; + } + else + { + Rectangle playerRect = Main.player[npc.target].getRect(); + Rectangle rangeRect = new Rectangle((int)npc.Center.X - rangeX, (int)npc.Center.Y - rangeY, rangeX * 2, rangeY * 2); + if (npc.localAI[0] > 20f && (rangeRect.Intersects(playerRect) || npc.life < npc.lifeMax)) + { + npc.ai[0] = 1f; + npc.velocity.Y -= 6f; + npc.netUpdate = true; + } + } + } + } + else if (!Main.player[npc.target].dead) + { + npc.width = flyWidth; + //Collision damping + if (npc.collideX) + { + npc.velocity.X = npc.oldVelocity.X * -0.5f; + if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) + { + npc.velocity.X = 2f; + } + if (npc.direction == 1 && npc.velocity.X < 0f && npc.velocity.X > -2f) + { + npc.velocity.X = -2f; + } + } + if (npc.collideY) + { + npc.velocity.Y = npc.oldVelocity.Y * -0.5f; + if (npc.velocity.Y > 0f && npc.velocity.Y < 1f) + { + npc.velocity.Y = 1f; + } + if (npc.velocity.Y < 0f && npc.velocity.Y > -1f) + { + npc.velocity.Y = -1f; + } + } + + if (npc.direction == -1 && npc.velocity.X > -maxSpeed) + { + npc.velocity.X -= acceleration; + if (npc.velocity.X > maxSpeed) + { + npc.velocity.X = npc.velocity.X - acceleration; + } + else if (npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X - acceleration * 0.5f; + } + if (npc.velocity.X < -maxSpeed) + { + npc.velocity.X = -maxSpeed; + } + } + else if (npc.direction == 1 && npc.velocity.X < maxSpeed) + { + npc.velocity.X = npc.velocity.X + acceleration; + if (npc.velocity.X < -maxSpeed) + { + npc.velocity.X = npc.velocity.X + acceleration; + } + else if (npc.velocity.X < 0f) + { + npc.velocity.X = npc.velocity.X + acceleration * 0.5f; + } + if (npc.velocity.X > maxSpeed) + { + npc.velocity.X = maxSpeed; + } + } + float xDistance = Math.Abs(npc.Center.X - Main.player[npc.target].Center.X); + float yLimiter = Main.player[npc.target].position.Y - (npc.height / 2f); + if (xDistance > 50f) + { + yLimiter -= 100f; + } + if (npc.position.Y < yLimiter) + { + npc.velocity.Y = npc.velocity.Y + acceleration * 0.5f; + if (npc.velocity.Y < 0f) + { + npc.velocity.Y = npc.velocity.Y + acceleration * 0.1f; + } + } + else + { + npc.velocity.Y = npc.velocity.Y - acceleration * 0.5f; + if (npc.velocity.Y > 0f) + { + npc.velocity.Y = npc.velocity.Y - acceleration * 0.1f; + } + } + if (npc.velocity.Y < -maxSpeed) + { + npc.velocity.Y = -maxSpeed; + } + if (npc.velocity.Y > maxSpeed) + { + npc.velocity.Y = maxSpeed; + } + } + //Change velocity if wet. + if (npc.wet) + { + if (npc.velocity.Y > 0f) + { + npc.velocity.Y = npc.velocity.Y * 0.95f; + } + npc.velocity.Y = npc.velocity.Y - 0.5f; + if (npc.velocity.Y < -4f) + { + npc.velocity.Y = -4f; + } + } + } + + /// + /// Allows you to spawn dust on the NPC in a certain place. Uses the npc.position value as the base point for the rectangle. + /// Takes direction and rotation into account. + /// + /// The width of the sheet for the NPC. + /// The place to put a dust. + /// The chance to spawn a dust (0.3 = 30%) + public static Dust SpawnDustOnNPC(NPC npc, int frameWidth, int frameHeight, int dustType, Rectangle rect, Vector2 velocity = default(Vector2), float chance = 0.5f, bool useSpriteDirection = false) + { + Vector2 half = new Vector2(frameWidth / 2f, frameHeight / 2f); + //"flip" the rectangle's position x-wise. + if ((!useSpriteDirection && npc.direction == 1) || (useSpriteDirection && npc.spriteDirection == 1)) + { + rect.X = frameWidth - rect.Right; + } + + if (Main.rand.NextFloat(1f) < chance) + { + Vector2 offset = (npc.Center - half + new Vector2(Main.rand.NextFloat(rect.Left, rect.Right), Main.rand.NextFloat(rect.Top, rect.Bottom))) - npc.Center; + offset = offset.RotatedBy(npc.rotation); + Dust d = Dust.NewDustPerfect(npc.Center + offset, dustType, velocity); + return d; + } + return null; + } + #endregion } } \ No newline at end of file diff --git a/Projectiles/AstralCrystal.cs b/Projectiles/AstralCrystal.cs new file mode 100644 index 0000000000..ba6b268e30 --- /dev/null +++ b/Projectiles/AstralCrystal.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + +namespace CalamityMod.Projectiles +{ + public class AstralCrystal : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Crystal"); + Main.projFrames[projectile.type] = 4; + } + + public override void SetDefaults() + { + projectile.width = 40; + projectile.height = 35; + projectile.friendly = true; + projectile.penetrate = 5; + projectile.tileCollide = false; + } + + public override void Kill(int timeLeft) + { + //make dust shape + bool blue = Main.rand.NextBool(); + float angleStart = Main.rand.NextFloat(0f, MathHelper.TwoPi); + for (float angle = 0f; angle < MathHelper.TwoPi; angle += 0.05f) + { + blue = !blue; + Vector2 velocity = angle.ToRotationVector2() * (2f + (float)(Math.Sin(angleStart + angle * 3f) + 1) * 2.5f) * Main.rand.NextFloat(0.95f, 1.05f); + Dust d = Dust.NewDustPerfect(projectile.Center, blue ? mod.DustType("AstralBlue") : mod.DustType("AstralOrange"), velocity); + d.customData = 0.025f; + } + //chunks + for (int i = 0; i < Main.rand.Next(5, 9); i++) + { + Dust d = Dust.NewDustPerfect(projectile.Center, mod.DustType("AstralChunk")); + } + + Main.PlaySound(SoundID.Item27, projectile.Center); + + for (float i = 0; i < MathHelper.TwoPi; i += MathHelper.PiOver4 / 2f) + { + Projectile.NewProjectile(projectile.Center, i.ToRotationVector2() * 9f, mod.ProjectileType("AstralCrystalInvisibleExplosion"), 50, 4f, projectile.owner); + } + } + + public override Color? GetAlpha(Color lightColor) + { + return new Color( + Math.Max((int)lightColor.R, 150), + Math.Max((int)lightColor.G, 150), + Math.Max((int)lightColor.B, 150)); + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + projectile.Kill(); + return false; + } + + public override void AI() + { + //FRAMING + projectile.frameCounter++; + if (projectile.frameCounter > 5) + { + projectile.frameCounter = 0; + projectile.frame++; + if (projectile.frame > 3) + { + projectile.frame = 0; + } + } + + //ROTATION + projectile.rotation = projectile.velocity.ToRotation(); + + //TILE COLLISION + if (projectile.Center.Y > projectile.ai[0]) + { + projectile.tileCollide = true; + } + + //Normal astral dusts + Vector2 vect = projectile.velocity; + vect.Normalize(); + vect *= 32; + Vector2 pos = projectile.Center + vect; + Vector2 perp = new Vector2(projectile.velocity.Y, -projectile.velocity.X); + perp.Normalize(); + bool flag = Main.time % 2 == 0; + int blue = mod.DustType("AstralBlue"); + int orange = mod.DustType("AstralOrange"); + projectile.ai[1] += 0.3141f; //2pi / 20 (total frames for one loop of animation) + Vector2 posOff = perp * (float)Math.Sin(projectile.ai[1]) * 6f; + Dust d1 = Dust.NewDustPerfect(pos + posOff, flag ? blue : orange, perp * Main.rand.NextFloat(2.3f, 3.5f)); + Dust d2 = Dust.NewDustPerfect(pos - posOff, flag ? orange : blue, -perp * Main.rand.NextFloat(2.3f, 3.5f)); + d1.customData = d2.customData = 0.035f; + + //Astral chunk dust + if (Main.rand.Next(30) == 0) + { + Dust dust = Dust.NewDustPerfect(projectile.Center, mod.DustType("AstralChunk")); + dust.velocity *= 0.3f; + } + } + } +} diff --git a/Projectiles/AstralCrystal.png b/Projectiles/AstralCrystal.png new file mode 100644 index 0000000000..e143f3f1a5 Binary files /dev/null and b/Projectiles/AstralCrystal.png differ diff --git a/Projectiles/AstralCrystalInvisibleExplosion.cs b/Projectiles/AstralCrystalInvisibleExplosion.cs new file mode 100644 index 0000000000..59db913597 --- /dev/null +++ b/Projectiles/AstralCrystalInvisibleExplosion.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Projectiles +{ + public class AstralCrystalInvisibleExplosion : ModProjectile + { + public override void SetDefaults() + { + projectile.width = 20; + projectile.height = 20; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + return false; + } + + public override void AI() + { + //KILL VELOCITY + projectile.ai[0]++; + if (projectile.ai[0] > 10) + { + projectile.Kill(); + } + } + } +} diff --git a/Projectiles/AstralCrystalInvisibleExplosion.png b/Projectiles/AstralCrystalInvisibleExplosion.png new file mode 100644 index 0000000000..f87b15108f Binary files /dev/null and b/Projectiles/AstralCrystalInvisibleExplosion.png differ diff --git a/Projectiles/AstralFallingSand.cs b/Projectiles/AstralFallingSand.cs new file mode 100644 index 0000000000..8454230f5a --- /dev/null +++ b/Projectiles/AstralFallingSand.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + +namespace CalamityMod.Projectiles +{ + public class AstralFallingSand : ModProjectile + { + public override void SetDefaults() + { + projectile.knockBack = 6f; + projectile.width = 10; + projectile.height = 10; + projectile.aiStyle = -1; + projectile.friendly = true; + projectile.hostile = true; + projectile.penetrate = -1; + base.SetDefaults(); + } + + public override void Kill(int timeLeft) + { + int tileX = (int)(projectile.Center.X / 16f); + int tileY = (int)(projectile.Center.Y / 16f); + //Move the set tile upwards based on certain conditions + if (Main.tile[tileX, tileY].halfBrick() && projectile.velocity.Y > 0f && Math.Abs(projectile.velocity.Y) > Math.Abs(projectile.velocity.X)) + { + tileY--; + } + if (!Main.tile[tileX, tileY].active()) + { + if (Main.tile[tileX, tileY].type == TileID.MinecartTrack) return; + + WorldGen.PlaceTile(tileX, tileY, mod.TileType("AstralSand"), false, true); + WorldGen.SquareTileFrame(tileX, tileY); + } + } + + public override void AI() + { + if (Main.rand.Next(2) == 0) + { + int i = Dust.NewDust(projectile.position, projectile.width, projectile.height, 108, 0f, projectile.velocity.Y * 0.5f); + Main.dust[i].velocity.X *= 0.2f; + } + projectile.velocity.Y += 0.2f; + projectile.rotation += 0.1f; + if (projectile.velocity.Y > 10f) + { + projectile.velocity.Y = 10f; + } + base.AI(); + } + } +} diff --git a/Projectiles/AstralFallingSand.png b/Projectiles/AstralFallingSand.png new file mode 100644 index 0000000000..1ca14800e4 Binary files /dev/null and b/Projectiles/AstralFallingSand.png differ diff --git a/Projectiles/AstralSpray.cs b/Projectiles/AstralSpray.cs new file mode 100644 index 0000000000..480b89861c --- /dev/null +++ b/Projectiles/AstralSpray.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + +namespace CalamityMod.Projectiles +{ + public class AstralSpray : ModProjectile + { + public override void SetDefaults() + { + projectile.width = 16; + projectile.height = 16; + projectile.aiStyle = -1; + projectile.friendly = true; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.extraUpdates = 2; + projectile.tileCollide = false; + projectile.ignoreWater = true; + } + + public override bool CanDamage() + { + return false; + } + + public override bool PreAI() + { + if (projectile.owner == Main.myPlayer) + { + int x = (int)(projectile.Center.X / 16f); + int y = (int)(projectile.Center.Y / 16f); + CalamityWorld.ConvertToAstral(x - 1, x + 1, y - 1, y + 1); + } + if (projectile.timeLeft > 133) + { + projectile.timeLeft = 133; + } + if (projectile.ai[0] > 7f) + { + float scalar = 1f; + if (projectile.ai[0] == 8f) + { + scalar = 0.2f; + } + else if (projectile.ai[0] == 9f) + { + scalar = 0.4f; + } + else if (projectile.ai[0] == 10f) + { + scalar = 0.6f; + } + else if (projectile.ai[0] == 11f) + { + scalar = 0.8f; + } + projectile.ai[0]++; + for (int i = 0; i < 1; i++) + { + int d = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 118, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100); + Main.dust[d].noGravity = true; + Main.dust[d].scale *= 1.75f * scalar; + Main.dust[d].velocity.X *= 2f; + Main.dust[d].velocity.Y *= 2f; + } + } + else + { + projectile.ai[0]++; + } + projectile.rotation += 0.3f * projectile.direction; + return false; + } + } +} diff --git a/Projectiles/AstralSpray.png b/Projectiles/AstralSpray.png new file mode 100644 index 0000000000..6063d18a0b Binary files /dev/null and b/Projectiles/AstralSpray.png differ diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 4720163164..2b125a0e7e 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -72,6 +72,36 @@ namespace CalamityMod.Projectiles } #endregion + #region PostAI + public override void PostAI(Projectile projectile) + { + int x = (int)(projectile.Center.X / 16f); + int y = (int)(projectile.Center.Y / 16f); + for (int i = x - 1; i <= x + 1; i++) + { + for (int j = y - 1; j <= y + 1; j++) + { + if (projectile.type == ProjectileID.PureSpray) + { + CalamityWorld.ConvertFromAstral(i, j, ConvertType.Pure); + } + if (projectile.type == ProjectileID.CorruptSpray) + { + CalamityWorld.ConvertFromAstral(i, j, ConvertType.Corrupt); + } + if (projectile.type == ProjectileID.CrimsonSpray) + { + CalamityWorld.ConvertFromAstral(i, j, ConvertType.Crimson); + } + if (projectile.type == ProjectileID.HallowSpray) + { + CalamityWorld.ConvertFromAstral(i, j, ConvertType.Hallow); + } + } + } + } + #endregion + #region ModifyHitNPC public override void ModifyHitNPC(Projectile projectile, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { diff --git a/Projectiles/MantisRing.cs b/Projectiles/MantisRing.cs new file mode 100644 index 0000000000..08cac47d79 --- /dev/null +++ b/Projectiles/MantisRing.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Projectiles +{ + public class MantisRing : ModProjectile + { + public override void SetStaticDefaults() + { + Main.projFrames[projectile.type] = 3; + } + + public override void SetDefaults() + { + projectile.knockBack = 3f; + projectile.width = 72; + projectile.height = 30; + projectile.friendly = false; + projectile.hostile = true; + projectile.penetrate = 8; + } + + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item1, projectile.Center); + + for (int i = 0; i < 60; i++) + { + float angle = MathHelper.TwoPi * Main.rand.NextFloat(0f, 1f); + Vector2 angleVec = angle.ToRotationVector2(); + float distance = Main.rand.NextFloat(14f, 36f); + Vector2 off = angleVec * distance; + off.Y *= ((float)projectile.height / projectile.width); + Vector2 pos = projectile.Center + off; + Dust d = Dust.NewDustPerfect(pos, mod.DustType("AstralBlue"), angleVec * Main.rand.NextFloat(2f, 4f)); + d.customData = true; + } + } + + public override void AI() + { + projectile.velocity *= 1.01f; + + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + if (projectile.frame > 2) + { + projectile.frame = 0; + } + } + + //Dust + for (int i = 0; i < 4; i++) + { + float angle = MathHelper.TwoPi * Main.rand.NextFloat(0f, 1f); + float distance = Main.rand.NextFloat(14f, 36f); + Vector2 off = angle.ToRotationVector2() * distance; + off.Y *= ((float)projectile.height / projectile.width); + Vector2 pos = projectile.Center + off; + Dust.NewDustPerfect(pos, mod.DustType("AstralBlue"), Vector2.Zero); + } + } + } +} diff --git a/Projectiles/MantisRing.png b/Projectiles/MantisRing.png new file mode 100644 index 0000000000..81c2a2a657 Binary files /dev/null and b/Projectiles/MantisRing.png differ diff --git a/Skies/AstralScreenShaderData.cs b/Skies/AstralScreenShaderData.cs new file mode 100644 index 0000000000..ef3b859dfe --- /dev/null +++ b/Skies/AstralScreenShaderData.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +using Terraria; +using Terraria.ModLoader; +using Terraria.Graphics.Shaders; + +namespace CalamityMod.Skies +{ + public class AstralScreenShaderData : ScreenShaderData + { + public AstralScreenShaderData(Ref shader, string passName) : base (shader, passName) { } + + public override void Apply() + { + Vector3 vec = Main.bgColor.ToVector3(); + vec *= 0.4f; + base.UseOpacity(Math.Max(vec.X, Math.Max(vec.Y, vec.Z))); + base.Apply(); + } + } +} diff --git a/Skies/AstralSky.cs b/Skies/AstralSky.cs new file mode 100644 index 0000000000..8eb7377474 --- /dev/null +++ b/Skies/AstralSky.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Reflection; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Effects; +using Terraria.ModLoader; + +namespace CalamityMod.Skies +{ + public class AstralSky : CustomSky + { + private bool skyActive; + private float opacity; + + public override void Deactivate(params object[] args) + { + skyActive = false; + } + + public override void Reset() + { + skyActive = false; + } + + public override bool IsActive() + { + return skyActive || opacity > 0f; + } + + public override void Activate(Vector2 position, params object[] args) + { + skyActive = true; + } + + public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) + { + if (maxDepth >= 3.40282347E+38f && minDepth < 3.40282347E+38f) + { + spriteBatch.Draw(CalamityMod.AstralSky, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Main.bgColor * opacity); + + //Terraria's conditions. + if (Main.netMode != 2) + { + for (int i = 0; i < Main.star.Length; i++) + { + Star star = Main.star[i]; + if (star == null) continue; + + Texture2D t2D = Main.starTexture[star.type]; + Vector2 origin = new Vector2(t2D.Width * 0.5f, t2D.Height * 0.5f); + + int bgTop = (int)((-Main.screenPosition.Y) / (Main.worldSurface * 16.0 - 600.0) * 200.0); + float posX = star.position.X * (Main.screenWidth / 800f); + float posY = star.position.Y * (Main.screenHeight / 600f); + + Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), Color.White * star.twinkle * 0.952f * opacity, star.rotation, origin, star.scale * star.twinkle, SpriteEffects.None, 0f); + } + } + } + } + + public override void Update(GameTime gameTime) + { + if (skyActive && opacity < 1f) + { + opacity += 0.02f; + } + else if (!skyActive && opacity > 0f) + { + opacity -= 0.02f; + } + } + + public override float GetCloudAlpha() + { + return (1f - opacity) * 0.97f + 0.03f; + } + } +} diff --git a/Sounds/Custom/AtlasIdle0.cs b/Sounds/Custom/AtlasIdle0.cs new file mode 100644 index 0000000000..4131bde5ed --- /dev/null +++ b/Sounds/Custom/AtlasIdle0.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom +{ + public class AtlasIdle0 : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Pan = pan; + soundInstance.Volume = volume * 0.6f; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/Custom/AtlasIdle0.wav b/Sounds/Custom/AtlasIdle0.wav new file mode 100644 index 0000000000..90924a6d22 Binary files /dev/null and b/Sounds/Custom/AtlasIdle0.wav differ diff --git a/Sounds/Custom/AtlasIdle1.cs b/Sounds/Custom/AtlasIdle1.cs new file mode 100644 index 0000000000..3ed1486985 --- /dev/null +++ b/Sounds/Custom/AtlasIdle1.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom +{ + public class AtlasIdle1 : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Pan = pan; + soundInstance.Volume = volume * 0.6f; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/Custom/AtlasIdle1.wav b/Sounds/Custom/AtlasIdle1.wav new file mode 100644 index 0000000000..3219b970a6 Binary files /dev/null and b/Sounds/Custom/AtlasIdle1.wav differ diff --git a/Sounds/Custom/AtlasSad0.cs b/Sounds/Custom/AtlasSad0.cs new file mode 100644 index 0000000000..acdb2b4a04 --- /dev/null +++ b/Sounds/Custom/AtlasSad0.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom +{ + public class AtlasSad0 : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Pan = pan; + soundInstance.Volume = volume * 0.5f; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/Custom/AtlasSad0.wav b/Sounds/Custom/AtlasSad0.wav new file mode 100644 index 0000000000..7db61cf6f2 Binary files /dev/null and b/Sounds/Custom/AtlasSad0.wav differ diff --git a/Sounds/Custom/AtlasSad1.cs b/Sounds/Custom/AtlasSad1.cs new file mode 100644 index 0000000000..582a523d66 --- /dev/null +++ b/Sounds/Custom/AtlasSad1.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom +{ + public class AtlasSad1 : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Pan = pan; + soundInstance.Volume = volume * 0.5f; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/Custom/AtlasSad1.wav b/Sounds/Custom/AtlasSad1.wav new file mode 100644 index 0000000000..c8421f8e81 Binary files /dev/null and b/Sounds/Custom/AtlasSad1.wav differ diff --git a/Sounds/Custom/AtlasSwing.cs b/Sounds/Custom/AtlasSwing.cs new file mode 100644 index 0000000000..48eb6ecfaa --- /dev/null +++ b/Sounds/Custom/AtlasSwing.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom +{ + public class AtlasSwing : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Pan = pan; + soundInstance.Volume = volume * 0.65f; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/Custom/AtlasSwing.wav b/Sounds/Custom/AtlasSwing.wav new file mode 100644 index 0000000000..e0bcde311d Binary files /dev/null and b/Sounds/Custom/AtlasSwing.wav differ diff --git a/Sounds/NPCDeath/AstralEnemyDeath.cs b/Sounds/NPCDeath/AstralEnemyDeath.cs new file mode 100644 index 0000000000..473d6164e8 --- /dev/null +++ b/Sounds/NPCDeath/AstralEnemyDeath.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.NPCDeath +{ + public class AstralEnemyDeath : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Pan = pan; + soundInstance.Volume = volume * 0.7f; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/NPCDeath/AstralEnemyDeath.wav b/Sounds/NPCDeath/AstralEnemyDeath.wav new file mode 100644 index 0000000000..d1d9b5981a Binary files /dev/null and b/Sounds/NPCDeath/AstralEnemyDeath.wav differ diff --git a/Sounds/NPCDeath/AtlasDeath.cs b/Sounds/NPCDeath/AtlasDeath.cs new file mode 100644 index 0000000000..a8763a8f13 --- /dev/null +++ b/Sounds/NPCDeath/AtlasDeath.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.NPCDeath +{ + public class AtlasDeath : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Pan = pan; + soundInstance.Volume = volume * 0.65f; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/NPCDeath/AtlasDeath.wav b/Sounds/NPCDeath/AtlasDeath.wav new file mode 100644 index 0000000000..ef0d1fbb67 Binary files /dev/null and b/Sounds/NPCDeath/AtlasDeath.wav differ diff --git a/Sounds/NPCHit/AstralEnemyHit.cs b/Sounds/NPCHit/AstralEnemyHit.cs new file mode 100644 index 0000000000..fe78a16abc --- /dev/null +++ b/Sounds/NPCHit/AstralEnemyHit.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.NPCHit +{ + public class AstralEnemyHit : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Pan = pan; + soundInstance.Volume = volume * 0.5f; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/NPCHit/AstralEnemyHit.wav b/Sounds/NPCHit/AstralEnemyHit.wav new file mode 100644 index 0000000000..267f46784c Binary files /dev/null and b/Sounds/NPCHit/AstralEnemyHit.wav differ diff --git a/Sounds/NPCHit/AtlasHurt0.cs b/Sounds/NPCHit/AtlasHurt0.cs new file mode 100644 index 0000000000..2559ae5656 --- /dev/null +++ b/Sounds/NPCHit/AtlasHurt0.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.NPCHit +{ + public class AtlasHurt0 : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Pan = pan; + soundInstance.Volume = volume * 0.5f; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/NPCHit/AtlasHurt0.wav b/Sounds/NPCHit/AtlasHurt0.wav new file mode 100644 index 0000000000..ce50f71fff Binary files /dev/null and b/Sounds/NPCHit/AtlasHurt0.wav differ diff --git a/Sounds/NPCHit/AtlasHurt1.cs b/Sounds/NPCHit/AtlasHurt1.cs new file mode 100644 index 0000000000..a235f4dc6b --- /dev/null +++ b/Sounds/NPCHit/AtlasHurt1.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.NPCHit +{ + public class AtlasHurt1 : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Pan = pan; + soundInstance.Volume = volume * 0.5f; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/NPCHit/AtlasHurt1.wav b/Sounds/NPCHit/AtlasHurt1.wav new file mode 100644 index 0000000000..49e72c1ae0 Binary files /dev/null and b/Sounds/NPCHit/AtlasHurt1.wav differ diff --git a/Sounds/NPCHit/AtlasHurt2.cs b/Sounds/NPCHit/AtlasHurt2.cs new file mode 100644 index 0000000000..9db54fca7c --- /dev/null +++ b/Sounds/NPCHit/AtlasHurt2.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.NPCHit +{ + public class AtlasHurt2 : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Pan = pan; + soundInstance.Volume = volume * 0.5f; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/NPCHit/AtlasHurt2.wav b/Sounds/NPCHit/AtlasHurt2.wav new file mode 100644 index 0000000000..f0a166083f Binary files /dev/null and b/Sounds/NPCHit/AtlasHurt2.wav differ diff --git a/Tiles/Astral/AstralDirt.cs b/Tiles/Astral/AstralDirt.cs new file mode 100644 index 0000000000..4c6c9cd51f --- /dev/null +++ b/Tiles/Astral/AstralDirt.cs @@ -0,0 +1,95 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Astral +{ + public class AstralDirt : ModTile + { + public override void SetDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileMerge[Type][mod.TileType("AstralGrass")] = true; + Main.tileMerge[TileID.Dirt][Type] = true; + + dustType = mod.DustType("AstralBasic"); + drop = mod.ItemType("AstralDirt"); + + AddMapEntry(new Color(65, 56, 83)); + + TileID.Sets.ChecksForMerge[Type] = true; + TileID.Sets.CanBeClearedDuringOreRunner[Type] = true; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + bool forceSameUp = false; + bool forceSameDown = false; + bool forceSameLeft = false; + bool forceSameRight = false; + + Tile up = Main.tile[i, j - 1]; + Tile down = Main.tile[i, j + 1]; + Tile left = Main.tile[i - 1, j]; + Tile right = Main.tile[i + 1, j]; + + bool tmp; + + if (up.active() && CustomTileFraming.tileMergeAstralDirt[up.type]) + { + bool mergedDown; + CustomTileFraming.FrameTileForCustomMerge(i, j - 1, up.type, Type, out tmp, out tmp, out tmp, out mergedDown, false, false, false, false, false); + if (mergedDown) + { + forceSameUp = true; + } + } + if (left.active() && CustomTileFraming.tileMergeAstralDirt[left.type]) + { + bool mergedRight; + CustomTileFraming.FrameTileForCustomMerge(i - 1, j, left.type, Type, out tmp, out tmp, out mergedRight, out tmp, false, false, false, false, false); + if (mergedRight) + { + forceSameLeft = true; + } + } + if (right.active() && CustomTileFraming.tileMergeAstralDirt[right.type]) + { + bool mergedLeft; + CustomTileFraming.FrameTileForCustomMerge(i + 1, j, right.type, Type, out tmp, out mergedLeft, out tmp, out tmp, false, false, false, false, false); + if (mergedLeft) + { + forceSameRight = true; + } + } + if (down.active() && CustomTileFraming.tileMergeAstralDirt[down.type]) + { + bool mergedUp; + CustomTileFraming.FrameTileForCustomMerge(i, j + 1, down.type, Type, out mergedUp, out tmp, out tmp, out tmp, false, false, false, false, false); + if (mergedUp) + { + forceSameDown = true; + } + } + + CustomTileFraming.FrameTileForCustomMerge(i, j, Type, TileID.Dirt, forceSameDown, forceSameUp, forceSameLeft, forceSameRight); + + return false; + } + + public override void RandomUpdate(int i, int j) + { + if (WorldGen.genRand.Next(3) == 0) + { + WorldGen.SpreadGrass(i, j, Type, mod.TileType("AstralGrass"), false); + } + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} \ No newline at end of file diff --git a/Tiles/Astral/AstralDirt.png b/Tiles/Astral/AstralDirt.png new file mode 100644 index 0000000000..23651f4ce5 Binary files /dev/null and b/Tiles/Astral/AstralDirt.png differ diff --git a/Tiles/Astral/AstralGrass.cs b/Tiles/Astral/AstralGrass.cs new file mode 100644 index 0000000000..1a76198b79 --- /dev/null +++ b/Tiles/Astral/AstralGrass.cs @@ -0,0 +1,46 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using System.Reflection; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.Astral +{ + public class AstralGrass : ModTile + { + public override void SetDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileBrick[Type] = true; + + dustType = mod.DustType("AstralBasic"); + drop = mod.ItemType("AstralDirt"); + + SetModTree(new AstralTree()); + + AddMapEntry(new Color(133, 109, 140)); + + TileID.Sets.Grass[Type] = true; + TileID.Sets.Conversion.Grass[Type] = true; + + //Grass framing (<3 terraria devs) + TileID.Sets.NeedsGrassFraming[Type] = true; + TileID.Sets.NeedsGrassFramingDirt[Type] = mod.TileType("AstralDirt"); + } + + public override void NumDust(int i, int j, bool fail, ref int Type) + { + Type = fail ? 1 : 3; + } + + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + if (fail && !effectOnly) + { + Main.tile[i, j].type = (ushort)mod.TileType("AstralDirt"); + } + } + } +} \ No newline at end of file diff --git a/Tiles/Astral/AstralGrass.png b/Tiles/Astral/AstralGrass.png new file mode 100644 index 0000000000..1d227d6f61 Binary files /dev/null and b/Tiles/Astral/AstralGrass.png differ diff --git a/Tiles/Astral/AstralNormalLargePiles.cs b/Tiles/Astral/AstralNormalLargePiles.cs new file mode 100644 index 0000000000..0f75a25756 --- /dev/null +++ b/Tiles/Astral/AstralNormalLargePiles.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ObjectData; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.Astral +{ + public class AstralNormalLargePiles : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.addTile(Type); + + dustType = mod.DustType("AstralBasic"); + + AddMapEntry(new Color(79, 61, 97)); + + base.SetDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/Astral/AstralNormalLargePiles.png b/Tiles/Astral/AstralNormalLargePiles.png new file mode 100644 index 0000000000..d3bea4f3b8 Binary files /dev/null and b/Tiles/Astral/AstralNormalLargePiles.png differ diff --git a/Tiles/Astral/AstralNormalMediumPiles.cs b/Tiles/Astral/AstralNormalMediumPiles.cs new file mode 100644 index 0000000000..65c9b8dc42 --- /dev/null +++ b/Tiles/Astral/AstralNormalMediumPiles.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ObjectData; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.Astral +{ + public class AstralNormalMediumPiles : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.addTile(Type); + + dustType = mod.DustType("AstralBasic"); + + AddMapEntry(new Color(79, 61, 97)); + + base.SetDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/Astral/AstralNormalMediumPiles.png b/Tiles/Astral/AstralNormalMediumPiles.png new file mode 100644 index 0000000000..d18f9067c0 Binary files /dev/null and b/Tiles/Astral/AstralNormalMediumPiles.png differ diff --git a/Tiles/Astral/AstralNormalSmallPiles.cs b/Tiles/Astral/AstralNormalSmallPiles.cs new file mode 100644 index 0000000000..d9bc992b1f --- /dev/null +++ b/Tiles/Astral/AstralNormalSmallPiles.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ObjectData; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.Astral +{ + public class AstralNormalSmallPiles : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + dustType = mod.DustType("AstralBasic"); + AddMapEntry(new Color(79, 61, 97)); + + base.SetDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/Astral/AstralNormalSmallPiles.png b/Tiles/Astral/AstralNormalSmallPiles.png new file mode 100644 index 0000000000..c87da05a9c Binary files /dev/null and b/Tiles/Astral/AstralNormalSmallPiles.png differ diff --git a/Tiles/Astral/AstralNormalStalactite.cs b/Tiles/Astral/AstralNormalStalactite.cs new file mode 100644 index 0000000000..4021b76f84 --- /dev/null +++ b/Tiles/Astral/AstralNormalStalactite.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ObjectData; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.Astral +{ + public class AstralNormalStalactite : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + Main.tileBlockLight[Type] = true; + + dustType = mod.DustType("AstralBasic"); + + AddMapEntry(new Color(79, 61, 97)); + + base.SetDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height) + { + Tile tile = Main.tile[i, j]; + if (tile.frameY <= 18 || tile.frameY == 72) + { + offsetY = -2; + } + else if ((tile.frameY >= 36 && tile.frameY <= 54) || tile.frameY == 90) + { + offsetY = 2; + } + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + WorldGen.CheckTight(i, j); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/Astral/AstralNormalStalactite.png b/Tiles/Astral/AstralNormalStalactite.png new file mode 100644 index 0000000000..565f5727a3 Binary files /dev/null and b/Tiles/Astral/AstralNormalStalactite.png differ diff --git a/Tiles/Astral/AstralOre.cs b/Tiles/Astral/AstralOre.cs new file mode 100644 index 0000000000..0fca9758a9 --- /dev/null +++ b/Tiles/Astral/AstralOre.cs @@ -0,0 +1,78 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Astral +{ + public class AstralOre : ModTile + { + public override void SetDefaults() + { + Main.tileLighted[Type] = true; + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileValue[Type] = 700; + Main.tileSpelunker[Type] = true; + Main.tileShine2[Type] = true; + + minPick = 199; + dustType = 173; + drop = mod.ItemType("AstralOre"); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Astral Ore"); + AddMapEntry(new Color(255, 153, 255), name); + mineResist = 5f; + soundType = 21; + + TileID.Sets.Ore[Type] = true; + TileID.Sets.ChecksForMerge[Type] = true; + } + + public override bool CanKillTile(int i, int j, ref bool blockDamaged) + { + //ASTRAL_IMPLEMENT: UNDO THIS COMMENT + //return CalamityWorld.downedStarGod; + return true; + } + + public override bool CanExplode(int i, int j) + { + //ASTRAL_IMPLEMENT: UNDO THIS COMMENT + //return CalamityWorld.downedStarGod; + return true; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void RandomUpdate(int i, int j) + { + if (Main.rand.Next(7) <= 2) + { + Dust.NewDust(new Vector2(i * 16f, j * 16f), 16, 16, 156, Main.rand.NextFloat(-0.05f, 0.05f), Main.rand.NextFloat(-0.05f, -0.001f)); + } + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.09f; + g = 0.03f; + b = 0.07f; + + float minStrength = 3.4f; + float bonusStrength = 0.5f; + float strength = minStrength + (float)Math.Sin(MathHelper.ToRadians((float)(Main.time / 6.0))) * bonusStrength; + Lighting.AddLight(new Vector2(i * 16 + 8f, j * 16 + 8f), r * strength, g * strength, b * strength); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + CustomTileFraming.FrameTileForCustomMerge(i, j, Type, mod.TileType("AstralDirt"), false, false, false, false, resetFrame); + return false; + } + } +} \ No newline at end of file diff --git a/Tiles/Astral/AstralOre.png b/Tiles/Astral/AstralOre.png new file mode 100644 index 0000000000..a18cb2987c Binary files /dev/null and b/Tiles/Astral/AstralOre.png differ diff --git a/Tiles/Astral/AstralPalmTree.cs b/Tiles/Astral/AstralPalmTree.cs new file mode 100644 index 0000000000..f0b3bf0a66 --- /dev/null +++ b/Tiles/Astral/AstralPalmTree.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria.ModLoader; +using Terraria; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles +{ + public class AstralPalmTree : ModPalmTree + { + public override Texture2D GetTexture() + { + return CalamityMod.Instance.GetTexture("Tiles/Normal/AstralPalmTree"); + } + + public override Texture2D GetTopTextures() + { + return CalamityMod.Instance.GetTexture("Tiles/Normal/AstralPalmTree_Tops"); + } + + public override int DropWood() + { + return CalamityMod.Instance.ItemType("AstralMonolith"); + } + + public override int CreateDust() + { + return CalamityMod.Instance.DustType("AstralBasic"); + } + + public override int GrowthFXGore() + { + return -1; + } + } +} diff --git a/Tiles/Astral/AstralPalmTree.png b/Tiles/Astral/AstralPalmTree.png new file mode 100644 index 0000000000..904e58ab6f Binary files /dev/null and b/Tiles/Astral/AstralPalmTree.png differ diff --git a/Tiles/Astral/AstralPalmTree_Tops.png b/Tiles/Astral/AstralPalmTree_Tops.png new file mode 100644 index 0000000000..586815f7ec Binary files /dev/null and b/Tiles/Astral/AstralPalmTree_Tops.png differ diff --git a/Tiles/Astral/AstralShortPlants.cs b/Tiles/Astral/AstralShortPlants.cs new file mode 100644 index 0000000000..ae65be58d1 --- /dev/null +++ b/Tiles/Astral/AstralShortPlants.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Astral +{ + public class AstralShortPlants : ModTile + { + public override void SetDefaults() + { + Main.tileCut[Type] = true; + Main.tileSolid[Type] = false; + Main.tileNoAttach[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = true; + Main.tileFrameImportant[Type] = true; + + dustType = mod.DustType("AstralBasic"); + + soundStyle = 1; + soundType = 6; + + AddMapEntry(new Color(127, 111, 144)); + + base.SetDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height) + { + offsetY = 2; + } + } +} diff --git a/Tiles/Astral/AstralShortPlants.png b/Tiles/Astral/AstralShortPlants.png new file mode 100644 index 0000000000..89d115934d Binary files /dev/null and b/Tiles/Astral/AstralShortPlants.png differ diff --git a/Tiles/Astral/AstralStone.cs b/Tiles/Astral/AstralStone.cs new file mode 100644 index 0000000000..9f4e954db0 --- /dev/null +++ b/Tiles/Astral/AstralStone.cs @@ -0,0 +1,39 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Astral +{ + public class AstralStone : ModTile + { + public override void SetDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileBrick[Type] = true; + + dustType = mod.DustType("AstralBasic"); + drop = mod.ItemType("AstralStone"); + + soundType = 21; + + AddMapEntry(new Color(45, 36, 63)); + + TileID.Sets.Stone[Type] = true; + TileID.Sets.Conversion.Stone[Type] = true; + TileID.Sets.CanBeClearedDuringOreRunner[Type] = true; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + CustomTileFraming.FrameTileForCustomMerge(i, j, Type, mod.TileType("AstralDirt")); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} \ No newline at end of file diff --git a/Tiles/Astral/AstralStone.png b/Tiles/Astral/AstralStone.png new file mode 100644 index 0000000000..ca9d2ef334 Binary files /dev/null and b/Tiles/Astral/AstralStone.png differ diff --git a/Tiles/Astral/AstralTallPlants.cs b/Tiles/Astral/AstralTallPlants.cs new file mode 100644 index 0000000000..96b92bb64d --- /dev/null +++ b/Tiles/Astral/AstralTallPlants.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Astral +{ + public class AstralTallPlants : ModTile + { + public override void SetDefaults() + { + Main.tileCut[Type] = true; + Main.tileSolid[Type] = false; + Main.tileNoAttach[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileWaterDeath[Type] = true; + Main.tileFrameImportant[Type] = true; + + dustType = mod.DustType("AstralBasic"); + + soundStyle = 1; + soundType = 6; + + AddMapEntry(new Color(127, 111, 144)); + + base.SetDefaults(); + } + } +} diff --git a/Tiles/Astral/AstralTallPlants.png b/Tiles/Astral/AstralTallPlants.png new file mode 100644 index 0000000000..22a35369d3 Binary files /dev/null and b/Tiles/Astral/AstralTallPlants.png differ diff --git a/Tiles/Astral/AstralTree.cs b/Tiles/Astral/AstralTree.cs new file mode 100644 index 0000000000..f93f5cfb85 --- /dev/null +++ b/Tiles/Astral/AstralTree.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria.ModLoader; +using Terraria; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles +{ + public class AstralTree : ModTree + { + public override Texture2D GetTopTextures(int i, int j, ref int frame, ref int frameWidth, ref int frameHeight, ref int xOffsetLeft, ref int yOffset) + { + frame = (i + j * j) % 3; + return CalamityMod.Instance.GetTexture("Tiles/Normal/AstralTree_Tops"); + } + + public override Texture2D GetBranchTextures(int i, int j, int trunkOffset, ref int frame) + { + return CalamityMod.Instance.GetTexture("Tiles/Normal/AstralTree_Branches"); + } + + public override Texture2D GetTexture() + { + return CalamityMod.Instance.GetTexture("Tiles/Normal/AstralTree"); + } + + public override int DropWood() + { + return CalamityMod.Instance.ItemType("AstralMonolith"); + } + + public override int CreateDust() + { + return CalamityMod.Instance.DustType("AstralBasic"); + } + + public override int GrowthFXGore() + { + return -1; + } + } +} diff --git a/Tiles/Astral/AstralTree.png b/Tiles/Astral/AstralTree.png new file mode 100644 index 0000000000..80b0e3aa78 Binary files /dev/null and b/Tiles/Astral/AstralTree.png differ diff --git a/Tiles/Astral/AstralTreeSapling.cs b/Tiles/Astral/AstralTreeSapling.cs new file mode 100644 index 0000000000..7df119f4ca --- /dev/null +++ b/Tiles/Astral/AstralTreeSapling.cs @@ -0,0 +1,71 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.Astral +{ + public class AstralTreeSapling : ModTile + { + //All of this code is taken directly from Example Mod. + //Cheers Blushie + + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileLavaDeath[Type] = true; + TileObjectData.newTile.Width = 1; + TileObjectData.newTile.Height = 2; + TileObjectData.newTile.Origin = new Point16(0, 1); + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.UsesCustomCanPlace = true; + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.AnchorValidTiles = new int[] { mod.TileType("AstralGrass") }; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.DrawFlipHorizontal = true; + TileObjectData.newTile.WaterPlacement = LiquidPlacement.NotAllowed; + TileObjectData.newTile.LavaDeath = true; + TileObjectData.newTile.RandomStyleRange = 3; + TileObjectData.addTile(Type); + sapling = true; + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Sapling"); + AddMapEntry(new Color(200, 200, 200), name); + dustType = mod.DustType("AstralBasic"); + adjTiles = new int[] { TileID.Saplings }; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void RandomUpdate(int i, int j) + { + if (WorldGen.genRand.Next(20) == 0) + { + bool isPlayerNear = WorldGen.PlayerLOS(i, j); + bool success = WorldGen.GrowTree(i, j); + if (success && isPlayerNear) + { + WorldGen.TreeGrowFXCheck(i, j); + } + } + } + + public override void SetSpriteEffects(int i, int j, ref SpriteEffects effects) + { + if (i % 2 == 1) + { + effects = SpriteEffects.FlipHorizontally; + } + } + } +} \ No newline at end of file diff --git a/Tiles/Astral/AstralTreeSapling.png b/Tiles/Astral/AstralTreeSapling.png new file mode 100644 index 0000000000..b23d88731e Binary files /dev/null and b/Tiles/Astral/AstralTreeSapling.png differ diff --git a/Tiles/Astral/AstralTree_Branches.png b/Tiles/Astral/AstralTree_Branches.png new file mode 100644 index 0000000000..8b8112c5b8 Binary files /dev/null and b/Tiles/Astral/AstralTree_Branches.png differ diff --git a/Tiles/Astral/AstralTree_Tops.png b/Tiles/Astral/AstralTree_Tops.png new file mode 100644 index 0000000000..5d8568804d Binary files /dev/null and b/Tiles/Astral/AstralTree_Tops.png differ diff --git a/Tiles/Astral/AstralVines.cs b/Tiles/Astral/AstralVines.cs new file mode 100644 index 0000000000..aaa78fc063 --- /dev/null +++ b/Tiles/Astral/AstralVines.cs @@ -0,0 +1,34 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.Astral +{ + public class AstralVines: ModTile + { + public override void SetDefaults() + { + Main.tileCut[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileNoFail[Type] = true; + + dustType = mod.DustType("AstralBasic"); + + soundType = 6; + soundStyle = 1; + + AddMapEntry(new Color(65, 56, 83)); + } + + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + //GIVE VINE ROPE IF SPECIAL VINE BOOK + if (WorldGen.genRand.Next(2) == 0 && Main.player[(int)Player.FindClosest(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16)].cordage) + { + Item.NewItem(new Vector2(i * 16 + 8f, j * 16 + 8f), ItemID.VineRope); + } + } + } +} \ No newline at end of file diff --git a/Tiles/Astral/AstralVines.png b/Tiles/Astral/AstralVines.png new file mode 100644 index 0000000000..9eb6362cc9 Binary files /dev/null and b/Tiles/Astral/AstralVines.png differ diff --git a/Tiles/AstralBar.cs b/Tiles/AstralBar.cs new file mode 100644 index 0000000000..362294e92c --- /dev/null +++ b/Tiles/AstralBar.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria.ModLoader; +using Terraria; +using Terraria.ID; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles +{ + public class AstralBar : ModTile + { + public override void SetDefaults() + { + Main.tileShine[Type] = 1000; + Main.tileSolid[Type] = true; + Main.tileSolidTop[Type] = true; + Main.tileFrameImportant[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.LavaDeath = false; + TileObjectData.addTile(Type); + + dustType = mod.DustType("AstralBlue"); + drop = mod.ItemType("AstralBar"); + + AddMapEntry(new Color(47, 66, 90)); + } + + public override bool CreateDust(int i, int j, ref int type) + { + if (Main.rand.Next(2) == 0) + { + type = mod.DustType("AstralOrange"); + } + else + { + type = mod.DustType("AstralBlue"); + } + return true; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + WorldGen.Check1x1(i, j, Type); + return true; + } + + public override void PlaceInWorld(int i, int j, Item item) + { + Main.tile[i, j].frameX = 0; + Main.tile[i, j].frameY = 0; + } + } +} diff --git a/Tiles/AstralBar.png b/Tiles/AstralBar.png new file mode 100644 index 0000000000..0f33be340e Binary files /dev/null and b/Tiles/AstralBar.png differ diff --git a/Tiles/AstralDesert/AstralDesertLargePiles.cs b/Tiles/AstralDesert/AstralDesertLargePiles.cs new file mode 100644 index 0000000000..acbdf0645a --- /dev/null +++ b/Tiles/AstralDesert/AstralDesertLargePiles.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ObjectData; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.AstralDesert +{ + public class AstralDesertLargePiles : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.addTile(Type); + + dustType = mod.DustType("AstralBasic"); + + AddMapEntry(new Color(79, 61, 97)); + + base.SetDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/AstralDesert/AstralDesertLargePiles.png b/Tiles/AstralDesert/AstralDesertLargePiles.png new file mode 100644 index 0000000000..6a9309951e Binary files /dev/null and b/Tiles/AstralDesert/AstralDesertLargePiles.png differ diff --git a/Tiles/AstralDesert/AstralDesertMediumPiles.cs b/Tiles/AstralDesert/AstralDesertMediumPiles.cs new file mode 100644 index 0000000000..6ac9431ca1 --- /dev/null +++ b/Tiles/AstralDesert/AstralDesertMediumPiles.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ObjectData; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.AstralDesert +{ + public class AstralDesertMediumPiles : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.addTile(Type); + + dustType = mod.DustType("AstralBasic"); + + AddMapEntry(new Color(79, 61, 97)); + + base.SetDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/AstralDesert/AstralDesertMediumPiles.png b/Tiles/AstralDesert/AstralDesertMediumPiles.png new file mode 100644 index 0000000000..37718ed5d5 Binary files /dev/null and b/Tiles/AstralDesert/AstralDesertMediumPiles.png differ diff --git a/Tiles/AstralDesert/AstralDesertSmallPiles.cs b/Tiles/AstralDesert/AstralDesertSmallPiles.cs new file mode 100644 index 0000000000..e7fd469cff --- /dev/null +++ b/Tiles/AstralDesert/AstralDesertSmallPiles.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ObjectData; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.AstralDesert +{ + public class AstralDesertSmallPiles: ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + dustType = mod.DustType("AstralBasic"); + AddMapEntry(new Color(79, 61, 97)); + + base.SetDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/AstralDesert/AstralDesertSmallPiles.png b/Tiles/AstralDesert/AstralDesertSmallPiles.png new file mode 100644 index 0000000000..44c77aadca Binary files /dev/null and b/Tiles/AstralDesert/AstralDesertSmallPiles.png differ diff --git a/Tiles/AstralDesert/AstralDesertStalactite.cs b/Tiles/AstralDesert/AstralDesertStalactite.cs new file mode 100644 index 0000000000..c5dcd24442 --- /dev/null +++ b/Tiles/AstralDesert/AstralDesertStalactite.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ObjectData; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.AstralDesert +{ + public class AstralDesertStalactite : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + Main.tileBlockLight[Type] = true; + + dustType = mod.DustType("AstralBasic"); + + AddMapEntry(new Color(79, 61, 97)); + + base.SetDefaults(); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + WorldGen.CheckTight(i, j); + return false; + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height) + { + Tile tile = Main.tile[i, j]; + if (tile.frameY <= 18 || tile.frameY == 72) + { + offsetY = -2; + } + else if ((tile.frameY >= 36 && tile.frameY <= 54) || tile.frameY == 90) + { + offsetY = 2; + } + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/AstralDesert/AstralDesertStalactite.png b/Tiles/AstralDesert/AstralDesertStalactite.png new file mode 100644 index 0000000000..4b1705364a Binary files /dev/null and b/Tiles/AstralDesert/AstralDesertStalactite.png differ diff --git a/Tiles/AstralDesert/AstralSand.cs b/Tiles/AstralDesert/AstralSand.cs new file mode 100644 index 0000000000..95c517b064 --- /dev/null +++ b/Tiles/AstralDesert/AstralSand.cs @@ -0,0 +1,65 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.AstralDesert +{ + public class AstralSand : ModTile + { + public override void SetDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileSand[Type] = true; + Main.tileBrick[Type] = true; + + dustType = 108; + drop = mod.ItemType("AstralSand"); + + AddMapEntry(new Color(149, 156, 155)); + + TileID.Sets.TouchDamageSands[Type] = 15; + TileID.Sets.Conversion.Sand[Type] = true; + + SetModCactus(new AstralCactus()); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + if (j < Main.maxTilesY && !Main.tile[i, j + 1].active()) + { + Main.tile[i, j].active(false); + Projectile.NewProjectile(new Vector2(i * 16f + 8f, j * 16f + 8f), Vector2.Zero, mod.ProjectileType("AstralFallingSand"), 15, 0f); + WorldGen.SquareTileFrame(i, j); + return false; + } + CustomTileFraming.FrameTileForCustomMerge(i, j, Type, mod.TileType("AstralDirt")); + return false; + } + + public override bool HasWalkDust() + { + return Main.rand.Next(3) == 0; + } + + public override void WalkDust(ref int dustType, ref bool makeDust, ref Color color) + { + dustType = 108; + } + } + + public class AstralCactus : ModCactus + { + public override Texture2D GetTexture() + { + return CalamityMod.AstralCactusTexture; + } + } +} \ No newline at end of file diff --git a/Tiles/AstralDesert/AstralSand.png b/Tiles/AstralDesert/AstralSand.png new file mode 100644 index 0000000000..e24ef7168e Binary files /dev/null and b/Tiles/AstralDesert/AstralSand.png differ diff --git a/Tiles/AstralDesert/AstralSandstone.cs b/Tiles/AstralDesert/AstralSandstone.cs new file mode 100644 index 0000000000..f7e92234b5 --- /dev/null +++ b/Tiles/AstralDesert/AstralSandstone.cs @@ -0,0 +1,35 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.AstralDesert +{ + public class AstralSandstone : ModTile + { + public override void SetDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileBrick[Type] = true; + + dustType = mod.DustType("AstralBasic"); + drop = mod.ItemType("AstralSandstone"); + + AddMapEntry(new Color(79, 61, 97)); + + TileID.Sets.Conversion.Sandstone[Type] = true; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + CustomTileFraming.FrameTileForCustomMerge(i, j, Type, mod.TileType("HardenedAstralSand"), false, false, false, false, resetFrame); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} \ No newline at end of file diff --git a/Tiles/AstralDesert/AstralSandstone.png b/Tiles/AstralDesert/AstralSandstone.png new file mode 100644 index 0000000000..800db7d5af Binary files /dev/null and b/Tiles/AstralDesert/AstralSandstone.png differ diff --git a/Tiles/AstralDesert/HardenedAstralSand.cs b/Tiles/AstralDesert/HardenedAstralSand.cs new file mode 100644 index 0000000000..47d36c8153 --- /dev/null +++ b/Tiles/AstralDesert/HardenedAstralSand.cs @@ -0,0 +1,35 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.AstralDesert +{ + public class HardenedAstralSand : ModTile + { + public override void SetDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileMerge[mod.TileType("AstralSand")][Type] = true; + + dustType = 108; + drop = mod.ItemType("HardenedAstralSand"); + + AddMapEntry(new Color(45, 36, 63)); + + TileID.Sets.Conversion.HardenedSand[Type] = true; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + CustomTileFraming.FrameTileForCustomMerge(i, j, Type, mod.TileType("AstralSand"), false, false, false, false, resetFrame); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} \ No newline at end of file diff --git a/Tiles/AstralDesert/HardenedAstralSand.png b/Tiles/AstralDesert/HardenedAstralSand.png new file mode 100644 index 0000000000..ef1eb1c408 Binary files /dev/null and b/Tiles/AstralDesert/HardenedAstralSand.png differ diff --git a/Tiles/AstralMonolith.cs b/Tiles/AstralMonolith.cs new file mode 100644 index 0000000000..e0e53a31dd --- /dev/null +++ b/Tiles/AstralMonolith.cs @@ -0,0 +1,153 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles +{ + public class AstralMonolith : ModTile + { + public override void SetDefaults() + { + Main.tileSolid[Type] = true; + Main.tileMergeDirt[Type] = true; + Main.tileBlockLight[Type] = true; + drop = mod.ItemType("AstralMonolith"); + AddMapEntry(new Color(100, 100, 150)); + animationFrameHeight = 270; + } + int animationFrameWidth = 288; + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 1, 0f, 0f, 1, new Color(149, 96, 255), 1f); + return false; + } + + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) + { + //So the basic summary of how this works is that for each possible state there is a unique tile sheet + //for every single unique position. This, as opposed to animating, is used to set which tile sheet is + //used for each tile position. Think of it as a grid, only converted into a single axis. + //Say you have a 3 x 3 grid. The 3 tile sheetes are 1 row, the next three are the next row and the + //final 3 are the last row. Simple. So for determining the y offset, 1 is added to + //uniqueAnimationFrame, and the x dimension of the gid is added to determine the x offset of where + //the tile will appear. Set the relevant uniqueAnimationFrame to equal this value. + //There needs to be a tile sheet for each tile in the grid though, assuming that none are rused, so + //the grid can only be so big due to sheet size limitations. Unless tile sheets are recycled, the + //maximum number of variants is 42, 7 sheets vertically, 6 sheets horizontally. A tile sheet can be + //used multiple times (although this will disrupt the easy to understand arrangement of the tiles + //in the megasheet. When testing for a tile position in the grid, apply a modulo (%) of the + //dimension in the axis to either i (x) or j (y). Test if that modulo is equal to the target position + // (for example: if (i % 4 == 0 && j % 4 == 2) will be for the tile at 0, 2 in a 4x4 grid) + int uniqueAnimationFrameX = Main.tileFrame[Type] + i; + int uniqueAnimationFrameY = Main.tileFrame[Type] + j; + int xPos = i % 4; + int yPos = j % 4; + switch (xPos) + { + case 0: + switch (yPos) + { + case 0: + uniqueAnimationFrameX = 0; + uniqueAnimationFrameY = 0; + break; + case 1: + uniqueAnimationFrameX = 0; + uniqueAnimationFrameY = 1; + break; + case 2: + uniqueAnimationFrameX = 0; + uniqueAnimationFrameY = 2; + break; + case 3: + uniqueAnimationFrameX = 0; + uniqueAnimationFrameY = 3; + break; + default: + uniqueAnimationFrameX = 0; + uniqueAnimationFrameY = 0; + break; + } + break; + case 1: + switch (yPos) + { + case 0: + uniqueAnimationFrameX = 1; + uniqueAnimationFrameY = 0; + break; + case 1: + uniqueAnimationFrameX = 1; + uniqueAnimationFrameY = 1; + break; + case 2: + uniqueAnimationFrameX = 1; + uniqueAnimationFrameY = 2; + break; + case 3: + uniqueAnimationFrameX = 1; + uniqueAnimationFrameY = 3; + break; + default: + uniqueAnimationFrameX = 1; + uniqueAnimationFrameY = 0; + break; + } + break; + case 2: + switch (yPos) + { + case 0: + uniqueAnimationFrameX = 2; + uniqueAnimationFrameY = 0; + break; + case 1: + uniqueAnimationFrameX = 2; + uniqueAnimationFrameY = 1; + break; + case 2: + uniqueAnimationFrameX = 2; + uniqueAnimationFrameY = 2; + break; + case 3: + uniqueAnimationFrameX = 2; + uniqueAnimationFrameY = 3; + break; + default: + uniqueAnimationFrameX = 2; + uniqueAnimationFrameY = 0; + break; + } + break; + case 3: + switch (yPos) + { + case 0: + uniqueAnimationFrameX = 3; + uniqueAnimationFrameY = 0; + break; + case 1: + uniqueAnimationFrameX = 3; + uniqueAnimationFrameY = 1; + break; + case 2: + uniqueAnimationFrameX = 3; + uniqueAnimationFrameY = 2; + break; + case 3: + uniqueAnimationFrameX = 3; + uniqueAnimationFrameY = 3; + break; + default: + uniqueAnimationFrameX = 3; + uniqueAnimationFrameY = 0; + break; + } + break; + } + frameXOffset = uniqueAnimationFrameX * animationFrameWidth; + frameYOffset = uniqueAnimationFrameY * animationFrameHeight; + } + } +} \ No newline at end of file diff --git a/Tiles/AstralMonolith.png b/Tiles/AstralMonolith.png new file mode 100644 index 0000000000..6942d37d12 Binary files /dev/null and b/Tiles/AstralMonolith.png differ diff --git a/Tiles/AstralOre.cs b/Tiles/AstralOre.cs deleted file mode 100644 index 372094c193..0000000000 --- a/Tiles/AstralOre.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles -{ - public class AstralOre : ModTile - { - public override void SetDefaults() - { - Main.tileLighted[Type] = true; - Main.tileSolid[Type] = true; - Main.tileMergeDirt[Type] = true; - Main.tileBlockLight[Type] = true; - Main.tileValue[Type] = 700; - minPick = 199; - dustType = 173; - drop = mod.ItemType("AstralOre"); - ModTranslation name = CreateMapEntryName(); - name.SetDefault("Astral Ore"); - AddMapEntry(new Color(255, 153, 255), name); - mineResist = 5f; - soundType = 21; - Main.tileSpelunker[Type] = true; - } - - public override bool CanKillTile(int i, int j, ref bool blockDamaged) - { - return CalamityWorld.downedStarGod; - } - - public override bool CanExplode(int i, int j) - { - return CalamityWorld.downedStarGod; - } - - public override void NumDust(int i, int j, bool fail, ref int num) - { - num = fail ? 1 : 3; - } - - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) - { - r = 0.08f; - g = 0.04f; - b = 0.10f; - } - } -} \ No newline at end of file diff --git a/Tiles/AstralOre.png b/Tiles/AstralOre.png deleted file mode 100644 index 7e595eb939..0000000000 Binary files a/Tiles/AstralOre.png and /dev/null differ diff --git a/Tiles/AstralSnow/AstralIce.cs b/Tiles/AstralSnow/AstralIce.cs new file mode 100644 index 0000000000..074f6333aa --- /dev/null +++ b/Tiles/AstralSnow/AstralIce.cs @@ -0,0 +1,46 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.AstralSnow +{ + public class AstralIce : ModTile + { + public override void SetDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileBrick[Type] = true; + Main.tileShine2[Type] = true; + //Main.tileMerge[Type][TileID.SnowBlock] = true; + //Main.tileMerge[TileID.SnowBlock][Type] = true; + + dustType = 173; + drop = mod.ItemType("AstralIce"); + + soundType = 2; + soundStyle = 50; + + AddMapEntry(new Color(153, 143, 168)); + + TileID.Sets.Ices[Type] = true; + TileID.Sets.IcesSlush[Type] = true; + TileID.Sets.IcesSnow[Type] = true; + TileID.Sets.ChecksForMerge[Type] = true; + TileID.Sets.Conversion.Ice[Type] = true; + TileID.Sets.CanBeClearedDuringOreRunner[Type] = true; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void FloorVisuals(Player player) + { + player.slippy = true; + base.FloorVisuals(player); + } + } +} \ No newline at end of file diff --git a/Tiles/AstralSnow/AstralIce.png b/Tiles/AstralSnow/AstralIce.png new file mode 100644 index 0000000000..42b7ec1478 Binary files /dev/null and b/Tiles/AstralSnow/AstralIce.png differ diff --git a/Tiles/AstralSnow/AstralIceLargePiles.cs b/Tiles/AstralSnow/AstralIceLargePiles.cs new file mode 100644 index 0000000000..bf4b5b0592 --- /dev/null +++ b/Tiles/AstralSnow/AstralIceLargePiles.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ObjectData; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.AstralSnow +{ + public class AstralIceLargePiles : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.addTile(Type); + + dustType = mod.DustType("AstralBasic"); + + AddMapEntry(new Color(79, 61, 97)); + + base.SetDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/AstralSnow/AstralIceLargePiles.png b/Tiles/AstralSnow/AstralIceLargePiles.png new file mode 100644 index 0000000000..9273420afb Binary files /dev/null and b/Tiles/AstralSnow/AstralIceLargePiles.png differ diff --git a/Tiles/AstralSnow/AstralIceMediumPiles.cs b/Tiles/AstralSnow/AstralIceMediumPiles.cs new file mode 100644 index 0000000000..605baa5656 --- /dev/null +++ b/Tiles/AstralSnow/AstralIceMediumPiles.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ObjectData; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.AstralSnow +{ + public class AstralIceMediumPiles : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.addTile(Type); + + dustType = mod.DustType("AstralBasic"); + + AddMapEntry(new Color(79, 61, 97)); + + base.SetDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/AstralSnow/AstralIceMediumPiles.png b/Tiles/AstralSnow/AstralIceMediumPiles.png new file mode 100644 index 0000000000..81db365580 Binary files /dev/null and b/Tiles/AstralSnow/AstralIceMediumPiles.png differ diff --git a/Tiles/AstralSnow/AstralIceSmallPiles.cs b/Tiles/AstralSnow/AstralIceSmallPiles.cs new file mode 100644 index 0000000000..2f89f67817 --- /dev/null +++ b/Tiles/AstralSnow/AstralIceSmallPiles.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ObjectData; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.AstralSnow +{ + public class AstralIceSmallPiles : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + dustType = mod.DustType("AstralBasic"); + AddMapEntry(new Color(79, 61, 97)); + + base.SetDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/AstralSnow/AstralIceSmallPiles.png b/Tiles/AstralSnow/AstralIceSmallPiles.png new file mode 100644 index 0000000000..947b9069f1 Binary files /dev/null and b/Tiles/AstralSnow/AstralIceSmallPiles.png differ diff --git a/Tiles/AstralSnow/AstralIceStalactite.cs b/Tiles/AstralSnow/AstralIceStalactite.cs new file mode 100644 index 0000000000..960decf52e --- /dev/null +++ b/Tiles/AstralSnow/AstralIceStalactite.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Terraria; +using Terraria.ObjectData; +using Terraria.ModLoader; + +using Microsoft.Xna.Framework; + +namespace CalamityMod.Tiles.AstralSnow +{ + public class AstralIceStalactite : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + Main.tileBlockLight[Type] = true; + + dustType = mod.DustType("AstralBasic"); + AddMapEntry(new Color(79, 61, 97)); + + base.SetDefaults(); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height) + { + Tile tile = Main.tile[i, j]; + if (tile.frameY <= 18 || tile.frameY == 72) + { + offsetY = -2; + } + else if ((tile.frameY >= 36 && tile.frameY <= 54) || tile.frameY == 90) + { + offsetY = 2; + } + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + WorldGen.CheckTight(i, j); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/AstralSnow/AstralIceStalactite.png b/Tiles/AstralSnow/AstralIceStalactite.png new file mode 100644 index 0000000000..14f8d934ce Binary files /dev/null and b/Tiles/AstralSnow/AstralIceStalactite.png differ diff --git a/Tiles/AstralSurfaceMusicBox.cs b/Tiles/AstralSurfaceMusicBox.cs new file mode 100644 index 0000000000..b5840886fb --- /dev/null +++ b/Tiles/AstralSurfaceMusicBox.cs @@ -0,0 +1,39 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; + +namespace CalamityMod.Tiles +{ + public class AstralSurfaceMusicBox : ModTile + { + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileObsidianKill[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.Origin = new Point16(0, 1); + TileObjectData.newTile.LavaDeath = false; + TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.addTile(Type); + disableSmartCursor = true; + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Music Box"); + AddMapEntry(new Color(200, 200, 200), name); + } + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(i * 16, j * 16, 16, 48, mod.ItemType("AstralSurfaceMusicBox")); + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.showItemIcon = true; + player.showItemIcon2 = mod.ItemType("AstralSurfaceMusicBox"); + } + } +} \ No newline at end of file diff --git a/Tiles/AstralSurfaceMusicBox.png b/Tiles/AstralSurfaceMusicBox.png new file mode 100644 index 0000000000..d087e83736 Binary files /dev/null and b/Tiles/AstralSurfaceMusicBox.png differ diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index f98f5c3816..4427f9f351 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -14,6 +14,111 @@ namespace CalamityMod.Tiles { public class CalamityGlobalTile : GlobalTile { + public static ushort[] PlantTypes = new ushort[] + { + TileID.Plants, + TileID.CorruptPlants, + TileID.JunglePlants, + TileID.MushroomPlants, + TileID.Plants2, + TileID.JunglePlants2, + TileID.HallowedPlants, + TileID.HallowedPlants2, + TileID.FleshWeeds, + (ushort)CalamityMod.Instance.TileType("AstralShortPlants"), + (ushort)CalamityMod.Instance.TileType("AstralTallPlants") + }; + + + public override bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak) + { + for (int k = 0; k < PlantTypes.Length; k++) + { + if (PlantTypes[k] == type) + { + CustomTileFraming.CheckPlants(i, j); + return false; + } + } + if (type == TileID.Vines || type == TileID.CrimsonVines || type == TileID.HallowedVines || type == mod.TileType("AstralVines")) + { + CustomTileFraming.VineFrame(i, j); + return false; + } + return base.TileFrame(i, j, type, ref resetFrame, ref noBreak); + } + + public override void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) + { + Tile tile = Main.tile[i, j]; + + if (type == TileID.Cactus) + { + //GRABBING VARIABLES FOR CERTAIN THINGS + Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange); + if (Main.drawToScreen) + zero = Vector2.Zero; + + //TESTING STUFF + int frameX = tile.frameX; + int frameY = tile.frameY; + bool astralCactus = false; + if (!Main.canDrawColorTile(i, j)) + { + int xTile = i; + if (frameX == 36) + { + xTile--; + } + if (frameX == 54) + { + xTile++; + } + if (frameX == 108) + { + if (frameY == 18) + { + xTile--; + } + else + { + xTile++; + } + } + int yTile = j; + bool flag = false; + if (Main.tile[xTile, yTile].type == 80 && Main.tile[xTile, yTile].active()) + { + flag = true; + } + while (!Main.tile[xTile, yTile].active() || !Main.tileSolid[(int)Main.tile[xTile, yTile].type] || !flag) + { + if (Main.tile[xTile, yTile].type == 80 && Main.tile[xTile, yTile].active()) + { + flag = true; + } + yTile++; + if (yTile > i + 20) + { + break; + } + } + //CACTUS CHECK + if (Main.tile[xTile, yTile].type == (ushort)mod.TileType("AstralSand")) + { + astralCactus = true; + } + } + + //Draw Glow + if (astralCactus) + { + spriteBatch.Draw(CalamityMod.AstralCactusGlowTexture, new Vector2((float)(i * 16 - (int)Main.screenPosition.X), (float)(j * 16 - (int)Main.screenPosition.Y)) + zero, new Rectangle((int)frameX, (int)frameY, 16, 18), Color.White * 0.75f, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); + } + return; + } + } + public override bool Drop(int i, int j, int type) { if (type == 28) diff --git a/Walls/AstralDirtWall.cs b/Walls/AstralDirtWall.cs new file mode 100644 index 0000000000..f85c32f80e --- /dev/null +++ b/Walls/AstralDirtWall.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class AstralDirtWall : ModWall + { + public override bool Autoload(ref string name, ref string texture) + { + mod.AddWall("AstralDirtWallUnsafe", this, texture); + return base.Autoload(ref name, ref texture); + } + + public override void SetDefaults() + { + dustType = DustID.Shadowflame; //TODO + drop = mod.ItemType("AstralDirtWall"); + AddMapEntry(new Color(26, 22, 32)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Walls/AstralDirtWall.png b/Walls/AstralDirtWall.png new file mode 100644 index 0000000000..defe18423c Binary files /dev/null and b/Walls/AstralDirtWall.png differ diff --git a/Walls/AstralGrassWall.cs b/Walls/AstralGrassWall.cs new file mode 100644 index 0000000000..7d83713f9f --- /dev/null +++ b/Walls/AstralGrassWall.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class AstralGrassWall : ModWall + { + public override bool Autoload(ref string name, ref string texture) + { + mod.AddWall("AstralGrassWallUnsafe", this, texture); + return base.Autoload(ref name, ref texture); + } + + public override void SetDefaults() + { + dustType = DustID.Shadowflame; //TODO + drop = mod.ItemType("AstralGrassWall"); + + WallID.Sets.Conversion.Grass[Type] = true; + + AddMapEntry(new Color(60, 48, 64)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Walls/AstralGrassWall.png b/Walls/AstralGrassWall.png new file mode 100644 index 0000000000..d673f1974c Binary files /dev/null and b/Walls/AstralGrassWall.png differ diff --git a/Walls/AstralIceWall.cs b/Walls/AstralIceWall.cs new file mode 100644 index 0000000000..6c255d8677 --- /dev/null +++ b/Walls/AstralIceWall.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class AstralIceWall : ModWall + { + public override bool Autoload(ref string name, ref string texture) + { + mod.AddWall("AstralIceWallUnsafe", this, texture); + return base.Autoload(ref name, ref texture); + } + + public override void SetDefaults() + { + dustType = DustID.Shadowflame; //TODO + drop = mod.ItemType("AstralIceWall"); + + AddMapEntry(new Color(83, 76, 92)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Walls/AstralIceWall.png b/Walls/AstralIceWall.png new file mode 100644 index 0000000000..f01257603b Binary files /dev/null and b/Walls/AstralIceWall.png differ diff --git a/Walls/AstralSandstoneWall.cs b/Walls/AstralSandstoneWall.cs new file mode 100644 index 0000000000..97cdead3d3 --- /dev/null +++ b/Walls/AstralSandstoneWall.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class AstralSandstoneWall : ModWall + { + public override bool Autoload(ref string name, ref string texture) + { + mod.AddWall("AstralSandstoneWallUnsafe", this, texture); + return base.Autoload(ref name, ref texture); + } + + public override void SetDefaults() + { + dustType = DustID.Shadowflame; //TODO + drop = mod.ItemType("AstralSandstoneWall"); + + WallID.Sets.Conversion.Sandstone[Type] = true; + + AddMapEntry(new Color(29, 38, 49)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Walls/AstralSandstoneWall.png b/Walls/AstralSandstoneWall.png new file mode 100644 index 0000000000..8e9fb8711b Binary files /dev/null and b/Walls/AstralSandstoneWall.png differ diff --git a/Walls/AstralStoneWall.cs b/Walls/AstralStoneWall.cs new file mode 100644 index 0000000000..07a5728bda --- /dev/null +++ b/Walls/AstralStoneWall.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class AstralStoneWall : ModWall + { + public override bool Autoload(ref string name, ref string texture) + { + mod.AddWall("AstralStoneWallUnsafe", this, texture); + return base.Autoload(ref name, ref texture); + } + + public override void SetDefaults() + { + dustType = DustID.Shadowflame; //TODO + drop = mod.ItemType("AstralStoneWall"); + + WallID.Sets.Conversion.Stone[Type] = true; + + AddMapEntry(new Color(15, 26, 31)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Walls/AstralStoneWall.png b/Walls/AstralStoneWall.png new file mode 100644 index 0000000000..be42b977e1 Binary files /dev/null and b/Walls/AstralStoneWall.png differ diff --git a/Walls/HardenedAstralSandWall.cs b/Walls/HardenedAstralSandWall.cs new file mode 100644 index 0000000000..2f1e023fcb --- /dev/null +++ b/Walls/HardenedAstralSandWall.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Microsoft.Xna.Framework; + +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class HardenedAstralSandWall : ModWall + { + public override bool Autoload(ref string name, ref string texture) + { + mod.AddWall("HardenedAstralSandWallUnsafe", this, texture); + return base.Autoload(ref name, ref texture); + } + + public override void SetDefaults() + { + dustType = DustID.Shadowflame; //TODO + drop = mod.ItemType("HardenedAstralSandWall"); + + WallID.Sets.Conversion.HardenedSand[Type] = true; + + AddMapEntry(new Color(10, 9, 21)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Walls/HardenedAstralSandWall.png b/Walls/HardenedAstralSandWall.png new file mode 100644 index 0000000000..dd04e0127f Binary files /dev/null and b/Walls/HardenedAstralSandWall.png differ diff --git a/Waters/AstralWater.cs b/Waters/AstralWater.cs new file mode 100644 index 0000000000..8f619638a4 --- /dev/null +++ b/Waters/AstralWater.cs @@ -0,0 +1,34 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Waters +{ + public class AstralWater : ModWaterStyle + { + public override bool ChooseWaterStyle() + { + return Main.LocalPlayer.GetModPlayer(mod).ZoneAstral; + } + + public override int ChooseWaterfallStyle() + { + return mod.GetWaterfallStyleSlot("AstralWaterflow"); + } + + public override int GetSplashDust() + { + return 52; //corruption water? + } + + public override int GetDropletGore() + { + return mod.GetGoreSlot("Gores/AstralWaterDroplet"); + } + + public override Color BiomeHairColor() + { + return Color.MediumPurple; + } + } +} \ No newline at end of file diff --git a/Waters/AstralWater.png b/Waters/AstralWater.png new file mode 100644 index 0000000000..10d8bab903 Binary files /dev/null and b/Waters/AstralWater.png differ diff --git a/Waters/AstralWater_Block.png b/Waters/AstralWater_Block.png new file mode 100644 index 0000000000..4d7ec4aa9a Binary files /dev/null and b/Waters/AstralWater_Block.png differ diff --git a/Waters/AstralWaterflow.cs b/Waters/AstralWaterflow.cs new file mode 100644 index 0000000000..84624fb2ff --- /dev/null +++ b/Waters/AstralWaterflow.cs @@ -0,0 +1,9 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Waters +{ + public class AstralWaterflow : ModWaterfallStyle + { + } +} \ No newline at end of file diff --git a/Waters/AstralWaterflow.png b/Waters/AstralWaterflow.png new file mode 100644 index 0000000000..4cc35417cb Binary files /dev/null and b/Waters/AstralWaterflow.png differ