diff --git a/Backgrounds/AstralSurfaceBGStyle.cs b/Backgrounds/AstralSurfaceBGStyle.cs index c89092d701..bc53eed640 100644 --- a/Backgrounds/AstralSurfaceBGStyle.cs +++ b/Backgrounds/AstralSurfaceBGStyle.cs @@ -8,6 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Backgrounds { + //this is just a blank background, so each custom background will draw over it public class AstralSurfaceBGStyle : ModSurfaceBackgroundStyle { internal static readonly FieldInfo screenOffField = typeof(Main).GetField("screenOff", BindingFlags.Instance | BindingFlags.NonPublic); @@ -25,13 +26,17 @@ namespace CalamityMod.Backgrounds { 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/FloralParadiseBGStyle.cs b/Backgrounds/FloralParadiseBGStyle.cs new file mode 100644 index 0000000000..9f987956f8 --- /dev/null +++ b/Backgrounds/FloralParadiseBGStyle.cs @@ -0,0 +1,14 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Backgrounds +{ + public class FloralParadiseBGStyle : ModUndergroundBackgroundStyle + { + public override void FillTextureArray(int[] textureSlots) + { + // Corresponds to underground jungle backgrounds. Something custom could probably be made, but for what it is it works sufficiently for the minibiome. + for (int i = 0; i <= 3; i++) + textureSlots[i] = i + 153; + } + } +} diff --git a/Backgrounds/SunkenSeaBGStyle.cs b/Backgrounds/SunkenSeaBGStyle.cs index 8911537bb3..cfd743dd4f 100644 --- a/Backgrounds/SunkenSeaBGStyle.cs +++ b/Backgrounds/SunkenSeaBGStyle.cs @@ -1,4 +1,5 @@ -using Terraria.ModLoader; +using Terraria; +using Terraria.ModLoader; namespace CalamityMod.Backgrounds { @@ -7,7 +8,10 @@ namespace CalamityMod.Backgrounds public override void FillTextureArray(int[] textureSlots) { for (int i = 0; i <= 3; i++) - textureSlots[i] = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG" + i.ToString()); + { + textureSlots[i] = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); + //textureSlots[i] = BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/SunkenSeaBG" + i.ToString()); + } } } } diff --git a/Backgrounds/SunkenSeaBurrowsBG.cs b/Backgrounds/SunkenSeaBurrowsBG.cs new file mode 100644 index 0000000000..e096f3fdfd --- /dev/null +++ b/Backgrounds/SunkenSeaBurrowsBG.cs @@ -0,0 +1,128 @@ +using Terraria; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; + +namespace CalamityMod.Backgrounds +{ + internal static class SunkenSeaBurrowsBG + { + public static void Load() + { + if (Main.dedServ) + { + return; + } + + On_Main.DrawBackgroundBlackFill += DrawBurrowsBG; + } + + public static float Transparency; + + public static float TransitionSpeed => 0.02f; + + private static void DrawBurrowsBG(On_Main.orig_DrawBackgroundBlackFill orig, Main self) + { + if (Main.gameMenu || Main.screenPosition.Y + Main.screenHeight < ((int)Main.worldSurface) * 16f) + { + orig(self); + + return; + } + + orig(self); + + if (Main.LocalPlayer.InModBiome(ModContent.GetInstance())) + { + Transparency += TransitionSpeed; + + if (Transparency > 1f) + { + Transparency = 1f; + } + } + else + { + //make transparency immediately go down so it doesnt look weird, since vanilla underground backgrounds dont have the fade-in effect this background has + Transparency -= 1f; + + if (Transparency < 0f) + { + Transparency = 0f; + } + } + + //dont bother running any of the background drawing if the transparency is zero (meaning the background isnt actually active) + //also do not run any of the background drawing if you have the vanilla background config option turned off + if (Transparency > 0f && Main.BackgroundEnabled) + { + Vector2 vector = Main.screenPosition + new Vector2((Main.screenWidth >> 1), (Main.screenHeight >> 1)); + float num = (Main.GameViewMatrix.Zoom.Y - 1f) * 0.5f * 200f; + float Scale = 1.5f; + + for (int Layers = 4; Layers >= 0; Layers--) + { + //get each background texture + Texture2D BGTexture = ModContent.Request("CalamityMod/Backgrounds/SunkenSeaBurrowsBG" + Layers).Value; + + Vector2 vector2 = new Vector2(BGTexture.Width, BGTexture.Height) * 0.5f; + float num2 = (Layers * 2 + 3f); + Vector2 vector3 = new Vector2(1f / num2); + Rectangle rectangle = new Rectangle(0, 0, BGTexture.Width, BGTexture.Height); + Vector2 zero = Vector2.Zero; + + switch (Layers) + { + case 0: + { + zero.Y += 800f; + break; + } + case 1: + { + zero.Y += 200f; + break; + } + case 2: + { + zero.Y += 450f; + break; + } + case 3: + { + zero.Y += 45f; + break; + } + case 4: + { + zero.Y += 45f; + break; + } + } + + vector2 *= Scale; + + zero.Y -= num; + float LoopWidth = Scale * rectangle.Width; + //float LoopHeight = Scale * rectangle.Height; + int LoopX = (int)((vector.X * vector3.X - vector2.X + zero.X - (Main.screenWidth >> 1)) / LoopWidth); + //int LoopY = (int)((vector.Y * vector3.Y - vector2.Y + zero.Y - (Main.screenWidth >> 1)) / LoopWidth); + + //for (int i = LoopY - 2; i < LoopY + 4 + (int)(Main.screenWidth / LoopHeight); i++) + //{ + for (int j = LoopX - 2; j < LoopX + 4 + (int)(Main.screenWidth / LoopWidth); j++) + { + Vector2 drawPosition = (new Vector2(j * Scale * (rectangle.Width / vector3.X), ((Main.LocalPlayer.Center.Y / 16f) - 90) * 16f) + vector2 - vector) * vector3 + vector - Main.screenPosition - vector2 + zero; + + var frame = rectangle; + var color = Color.MediumTurquoise * Transparency; + + Main.spriteBatch.Draw(BGTexture, drawPosition, frame, color, 0f, Vector2.Zero, Scale, SpriteEffects.None, 0f); + } + //} + } + } + } + } +} \ No newline at end of file diff --git a/Backgrounds/SunkenSeaBurrowsBG0.png b/Backgrounds/SunkenSeaBurrowsBG0.png new file mode 100644 index 0000000000..26ad2b3f50 Binary files /dev/null and b/Backgrounds/SunkenSeaBurrowsBG0.png differ diff --git a/Backgrounds/SunkenSeaBurrowsBG1.png b/Backgrounds/SunkenSeaBurrowsBG1.png new file mode 100644 index 0000000000..452e46c78c Binary files /dev/null and b/Backgrounds/SunkenSeaBurrowsBG1.png differ diff --git a/Backgrounds/SunkenSeaBurrowsBG2.png b/Backgrounds/SunkenSeaBurrowsBG2.png new file mode 100644 index 0000000000..3eb8e53eb6 Binary files /dev/null and b/Backgrounds/SunkenSeaBurrowsBG2.png differ diff --git a/Backgrounds/SunkenSeaBurrowsBG3.png b/Backgrounds/SunkenSeaBurrowsBG3.png new file mode 100644 index 0000000000..13524864b4 Binary files /dev/null and b/Backgrounds/SunkenSeaBurrowsBG3.png differ diff --git a/Backgrounds/SunkenSeaBurrowsBG4.png b/Backgrounds/SunkenSeaBurrowsBG4.png new file mode 100644 index 0000000000..33a816d561 Binary files /dev/null and b/Backgrounds/SunkenSeaBurrowsBG4.png differ diff --git a/Balancing/BalancingChangesManager.cs b/Balancing/BalancingChangesManager.cs index 3daca26a39..c36cc58ade 100644 --- a/Balancing/BalancingChangesManager.cs +++ b/Balancing/BalancingChangesManager.cs @@ -264,6 +264,9 @@ namespace CalamityMod.Balancing // 50% resist to true melee. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AstrumDeusIDs, Do(ResistTrueMelee(0.5f)))); + // 35% resist to Ballistic Poison Bomb's clouds. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AstrumDeusIDs, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); + // 35% resist to Icicle Arrows. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AstrumDeusIDs, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); diff --git a/Balancing/BalancingConstants.cs b/Balancing/BalancingConstants.cs index 5087a7a6cf..4b931a4b1f 100644 --- a/Balancing/BalancingConstants.cs +++ b/Balancing/BalancingConstants.cs @@ -17,6 +17,12 @@ // This is a const because it replaces a hardcoded value in vanilla internal const float BalloonJumpSpeedBoost = 0.75f; + // Default jump speed boost provided by Frog Leg and tinker combinations in vanilla + internal const float VanillaFrogLegJumpSpeedBoost = 1.6f; + + // Altered jump speed boost provided by Amphibian Boots via global item UpdateAccessory + internal static readonly float AmphibianBootsJumpSpeedBoost = 1f; + // Altered movement stats provided by Shadow Armor via IL edit // This item is modified to not stack with Magiluminescence if on the ground. If in the air, it still functions. internal static readonly float ShadowArmorRunAccelerationMultiplier = 1.25f; // Vanilla and Magi = 1.75f diff --git a/BiomeManagers/FloralParadiseBiome.cs b/BiomeManagers/FloralParadiseBiome.cs new file mode 100644 index 0000000000..9789259705 --- /dev/null +++ b/BiomeManagers/FloralParadiseBiome.cs @@ -0,0 +1,18 @@ +using CalamityMod.Systems; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.BiomeManagers +{ + public class FloralParadiseBiome : ModBiome + { + public override ModWaterStyle WaterStyle => ModContent.Find("CalamityMod/FloralParadiseWater"); + public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find("CalamityMod/FloralParadiseBGStyle"); + public override SceneEffectPriority Priority => SceneEffectPriority.BiomeHigh; + + public override bool IsBiomeActive(Player player) + { + return BiomeTileCounterSystem.FloralParadiseTiles >= 300; + } + } +} diff --git a/BiomeManagers/SunkenSeaBiome.cs b/BiomeManagers/SunkenSeaBiome.cs index 394241a43b..eda95f35b0 100644 --- a/BiomeManagers/SunkenSeaBiome.cs +++ b/BiomeManagers/SunkenSeaBiome.cs @@ -1,18 +1,65 @@ -using CalamityMod.Items.Placeables.Furniture; -using CalamityMod.Systems; -using Terraria; +using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Terraria.Graphics.Light; +using Microsoft.Xna.Framework; +using System; +using Mono.Cecil.Cil; +using MonoMod.Cil; +using CalamityMod.Items.Placeables.Furniture; +using CalamityMod.Systems; namespace CalamityMod.BiomeManagers { + //this is just a global sunken sea biome to check if you are in any of the existing biomes public class SunkenSeaBiome : ModBiome { - public override ModWaterStyle WaterStyle => ModContent.Find("CalamityMod/SunkenSeaWater"); - public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find("CalamityMod/SunkenSeaBGStyle"); - public override int BiomeTorchItemType => ModContent.ItemType(); - public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("SunkenSea") ?? MusicID.OceanNight; public override SceneEffectPriority Priority => SceneEffectPriority.BiomeHigh; + + public override void Load() + { + //apply the drawblack edits here since all sunken sea biomes will have custom backgrounds + IL_Main.DrawBlack += ChangeBlackThreshold; + On_Main.DrawBlack += ForceDrawBlack; + } + + private void ForceDrawBlack(On_Main.orig_DrawBlack orig, Main self, bool force) + { + if (Main.LocalPlayer.InModBiome(ModContent.GetInstance()) && Main.BackgroundEnabled) + { + orig(self, true); + } + else + { + orig(self, force); + } + } + + private float NewThreshold(float orig) + { + if (Main.LocalPlayer.InModBiome(ModContent.GetInstance()) && Main.BackgroundEnabled) + { + return 0.1f; + } + else + { + return orig; + } + } + + private void ChangeBlackThreshold(ILContext il) + { + if (Main.BackgroundEnabled) + { + var c = new ILCursor(il); + c.TryGotoNext(n => n.MatchLdloc(6), n => n.MatchStloc(13)); //beginning of the loop, local 11 is a looping variable + c.Index++; //this is kinda goofy since I dont think you could actually ever write c# to compile to the resulting IL from emitting here. + c.Emit(OpCodes.Ldloc, 3); //pass the original value so we can set that instead if we dont want to change the threshold + c.EmitDelegate>(NewThreshold); //check if were in the biome to set, else set the original value + c.Emit(OpCodes.Stloc, 3); //num2 in vanilla, controls minimum threshold to turn a tile black + } + } + public override string BestiaryIcon => "CalamityMod/BiomeManagers/SunkenSeaIcon"; // Placeholder until we get a dedicated Sunken Sea background public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AbyssBGLayer1"; @@ -20,7 +67,8 @@ namespace CalamityMod.BiomeManagers public override bool IsBiomeActive(Player player) { - return BiomeTileCounterSystem.SunkenSeaTiles > 150; + return BiomeTileCounterSystem.SunkenSeaBurrowsTiles > 500 || BiomeTileCounterSystem.SunkenSeaPolypTiles > 500 || + BiomeTileCounterSystem.SunkenSeaReefsTiles > 500 || BiomeTileCounterSystem.SunkenSeaShoresTiles > 500; } } } diff --git a/BiomeManagers/SunkenSeaBurrowsBiome.cs b/BiomeManagers/SunkenSeaBurrowsBiome.cs new file mode 100644 index 0000000000..a0980ce333 --- /dev/null +++ b/BiomeManagers/SunkenSeaBurrowsBiome.cs @@ -0,0 +1,29 @@ +using CalamityMod.Items.Placeables.Furniture; +using CalamityMod.Systems; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.BiomeManagers +{ + public class SunkenSeaBurrowsBiome : ModBiome + { + public override ModWaterStyle WaterStyle => ModContent.Find("CalamityMod/SunkenSeaBurrowsWater"); + public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find("CalamityMod/SunkenSeaBGStyle"); + public override int BiomeTorchItemType => ModContent.ItemType(); + public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("SunkenSea") ?? MusicID.OceanNight; + public override SceneEffectPriority Priority => SceneEffectPriority.Environment; + public override string BestiaryIcon => "CalamityMod/BiomeManagers/SunkenSeaIcon"; + // Placeholder until we get a dedicated Sunken Sea background + public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AbyssBGLayer1"; + public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AbyssBGLayer1"; + + public override bool IsBiomeActive(Player player) + { + bool MoreThanReefs = BiomeTileCounterSystem.SunkenSeaBurrowsTiles > BiomeTileCounterSystem.SunkenSeaReefsTiles; + bool MoreThanPolyp = BiomeTileCounterSystem.SunkenSeaBurrowsTiles > BiomeTileCounterSystem.SunkenSeaPolypTiles; + + return BiomeTileCounterSystem.SunkenSeaBurrowsTiles > 500 && MoreThanReefs && MoreThanPolyp; + } + } +} diff --git a/BiomeManagers/SunkenSeaPolypBiome.cs b/BiomeManagers/SunkenSeaPolypBiome.cs new file mode 100644 index 0000000000..3c2fdeaeda --- /dev/null +++ b/BiomeManagers/SunkenSeaPolypBiome.cs @@ -0,0 +1,29 @@ +using CalamityMod.Items.Placeables.Furniture; +using CalamityMod.Systems; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.BiomeManagers +{ + public class SunkenSeaPolypBiome : ModBiome + { + public override ModWaterStyle WaterStyle => ModContent.Find("CalamityMod/SunkenSeaPolypWater"); + public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find("CalamityMod/SunkenSeaBGStyle"); + public override int BiomeTorchItemType => ModContent.ItemType(); + public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("SunkenSea") ?? MusicID.OceanNight; + public override SceneEffectPriority Priority => SceneEffectPriority.Environment; + public override string BestiaryIcon => "CalamityMod/BiomeManagers/SunkenSeaIcon"; + // Placeholder until we get a dedicated Sunken Sea background + public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AbyssBGLayer1"; + public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AbyssBGLayer1"; + + public override bool IsBiomeActive(Player player) + { + bool MoreThanReefs = BiomeTileCounterSystem.SunkenSeaPolypTiles > BiomeTileCounterSystem.SunkenSeaReefsTiles; + bool MoreThanBurrows = BiomeTileCounterSystem.SunkenSeaPolypTiles > BiomeTileCounterSystem.SunkenSeaBurrowsTiles; + + return BiomeTileCounterSystem.SunkenSeaPolypTiles > 500 && MoreThanReefs && MoreThanBurrows; + } + } +} diff --git a/BiomeManagers/SunkenSeaReefsBiome.cs b/BiomeManagers/SunkenSeaReefsBiome.cs new file mode 100644 index 0000000000..d9d7fe0c79 --- /dev/null +++ b/BiomeManagers/SunkenSeaReefsBiome.cs @@ -0,0 +1,29 @@ +using CalamityMod.Items.Placeables.Furniture; +using CalamityMod.Systems; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.BiomeManagers +{ + public class SunkenSeaReefsBiome : ModBiome + { + public override ModWaterStyle WaterStyle => ModContent.Find("CalamityMod/SunkenSeaReefsWater"); + public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find("CalamityMod/SunkenSeaBGStyle"); + public override int BiomeTorchItemType => ModContent.ItemType(); + public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("SunkenSea") ?? MusicID.OceanNight; + public override SceneEffectPriority Priority => SceneEffectPriority.Environment; + public override string BestiaryIcon => "CalamityMod/BiomeManagers/SunkenSeaIcon"; + // Placeholder until we get a dedicated Sunken Sea background + public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AbyssBGLayer1"; + public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AbyssBGLayer1"; + + public override bool IsBiomeActive(Player player) + { + bool MoreThanBurrows = BiomeTileCounterSystem.SunkenSeaReefsTiles > BiomeTileCounterSystem.SunkenSeaBurrowsTiles; + bool MoreThanPolyp = BiomeTileCounterSystem.SunkenSeaReefsTiles > BiomeTileCounterSystem.SunkenSeaPolypTiles; + + return BiomeTileCounterSystem.SunkenSeaReefsTiles > 500 && MoreThanBurrows && MoreThanPolyp; + } + } +} diff --git a/BiomeManagers/SunkenSeaShoresBiome.cs b/BiomeManagers/SunkenSeaShoresBiome.cs new file mode 100644 index 0000000000..4f6252a37b --- /dev/null +++ b/BiomeManagers/SunkenSeaShoresBiome.cs @@ -0,0 +1,26 @@ +using CalamityMod.Items.Placeables.Furniture; +using CalamityMod.Systems; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.BiomeManagers +{ + public class SunkenSeaShoresBiome : ModBiome + { + public override ModWaterStyle WaterStyle => ModContent.Find("CalamityMod/SunkenSeaShoresWater"); + public override ModUndergroundBackgroundStyle UndergroundBackgroundStyle => ModContent.Find("CalamityMod/SunkenSeaBGStyle"); + public override int BiomeTorchItemType => ModContent.ItemType(); + public override int Music => CalamityMod.Instance.GetMusicFromMusicMod("SunkenSea") ?? MusicID.OceanNight; + public override SceneEffectPriority Priority => SceneEffectPriority.Environment; + public override string BestiaryIcon => "CalamityMod/BiomeManagers/SunkenSeaIcon"; + // Placeholder until we get a dedicated Sunken Sea background + public override string BackgroundPath => "CalamityMod/Backgrounds/MapBackgrounds/AbyssBGLayer1"; + public override string MapBackground => "CalamityMod/Backgrounds/MapBackgrounds/AbyssBGLayer1"; + + public override bool IsBiomeActive(Player player) + { + return BiomeTileCounterSystem.SunkenSeaShoresTiles > 500; + } + } +} diff --git a/Buffs/CalamityGlobalBuff.cs b/Buffs/CalamityGlobalBuff.cs index 93d68380d4..a8239f952a 100644 --- a/Buffs/CalamityGlobalBuff.cs +++ b/Buffs/CalamityGlobalBuff.cs @@ -88,13 +88,6 @@ namespace CalamityMod.Buffs { player.endurance += BalancingConstants.SolarFlareShieldDR; } - - else if (type == BuffID.Warmth) - { - player.buffImmune[ModContent.BuffType()] = true; - player.buffImmune[BuffID.Frozen] = true; - player.buffImmune[BuffID.Chilled] = true; - } else if (type == BuffID.Rabies) { player.GetDamage() -= 0.2f; diff --git a/Buffs/DamageOverTime/Laceration.cs b/Buffs/DamageOverTime/Laceration.cs new file mode 100644 index 0000000000..ded4f05975 --- /dev/null +++ b/Buffs/DamageOverTime/Laceration.cs @@ -0,0 +1,49 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.DamageOverTime +{ + public class Laceration : ModBuff + { + public override void SetStaticDefaults() + { + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + BuffID.Sets.LongerExpertDebuff[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().laceration = true; + } + + public override void Update(NPC npc, ref int buffIndex) + { + if (npc.Calamity().laceration < npc.buffTime[buffIndex]) + npc.Calamity().laceration = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; + } + + internal static void DrawEffects(NPC npc, ref Color drawColor) + { + if (Main.rand.NextBool(3)) + { + for (int b = 0; b < 2; b++) + { + Vector2 bloodVel = Main.rand.NextVector2CircularEdge(1f, 1f); + bloodVel.SafeNormalize(Vector2.Zero); + bloodVel *= Main.rand.NextFloat(4f, 7f); + + Particle bloody = new BloodParticle(npc.Center, bloodVel, 40, 0.75f, new Color(192, 0, 0)); + GeneralParticleHandler.SpawnParticle(bloody); + } + } + } + } +} diff --git a/Buffs/DamageOverTime/Laceration.png b/Buffs/DamageOverTime/Laceration.png new file mode 100644 index 0000000000..5a577ad3dc Binary files /dev/null and b/Buffs/DamageOverTime/Laceration.png differ diff --git a/Buffs/DamageOverTime/Plague.cs b/Buffs/DamageOverTime/Plague.cs index defe20c5b8..f776337e36 100644 --- a/Buffs/DamageOverTime/Plague.cs +++ b/Buffs/DamageOverTime/Plague.cs @@ -36,15 +36,18 @@ namespace CalamityMod.Buffs.DamageOverTime float numberOfDusts = 2f; float rotFactor = 360f / numberOfDusts; + int particleAmt = Player.Calamity().alchFlask ? 1 : 2; + int dustSpawnAmt = Player.Calamity().alchFlask ? 4 : 7; if (Player.miscCounter % 4 == 0) { - for (int i = 0; i < 2; i++) + for (int i = 0; i < particleAmt; i++) { - DirectionalPulseRing pulse = new DirectionalPulseRing(Player.Calamity().RandomDebuffVisualSpot, Vector2.Zero, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Green, new Vector2(1, 1), 0, Main.rand.NextFloat(0.07f, 0.18f), 0f, 35); + float pulseScale = Main.rand.NextFloat(Player.Calamity().alchFlask ? 0.04f : 0.07f, Player.Calamity().alchFlask ? 0.12f : 0.18f); + DirectionalPulseRing pulse = new DirectionalPulseRing(Player.Calamity().RandomDebuffVisualSpot, Vector2.Zero, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Green, Vector2.One, 0, pulseScale, 0f, 20); GeneralParticleHandler.SpawnParticle(pulse); } - for (int i = 0; i < 7; i++) + for (int i = 0; i < dustSpawnAmt; i++) { int DustID = Main.rand.NextBool(30) ? 220 : 89; float rot = MathHelper.ToRadians(i * rotFactor); @@ -62,7 +65,7 @@ namespace CalamityMod.Buffs.DamageOverTime Vector2 npcSize = npc.Center + new Vector2(Main.rand.NextFloat(-npc.width / 2, npc.width / 2), Main.rand.NextFloat(-npc.height / 2, npc.height / 2)); if (Main.rand.NextBool(3)) { - DirectionalPulseRing pulse = new DirectionalPulseRing(npcSize, Vector2.Zero, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Green, new Vector2(1, 1), 0, Main.rand.NextFloat(0.07f, 0.18f) + (0.0000007f * npc.width * npc.height), 0f, 35); + DirectionalPulseRing pulse = new DirectionalPulseRing(npcSize, Vector2.Zero, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Green, new Vector2(1, 1), 0, Main.rand.NextFloat(0.07f, 0.18f) + (0.0000007f * npc.width * npc.height), 0f, 15); GeneralParticleHandler.SpawnParticle(pulse); for (int i = 0; i < 4; i++) diff --git a/Buffs/Placeables/CirrusBlueCandleBuff.cs b/Buffs/Placeables/CirrusBlueCandleBuff.cs index 5552456597..1080599c10 100644 --- a/Buffs/Placeables/CirrusBlueCandleBuff.cs +++ b/Buffs/Placeables/CirrusBlueCandleBuff.cs @@ -6,17 +6,29 @@ namespace CalamityMod.Buffs.Placeables { public class CirrusBlueCandleBuff : ModBuff { + public static float MoveSpeedBoost = 0.1f; + public static double WingTimeBoost = 0.1D; + public static float AccelerationBoost = 0.1f; + public override void SetStaticDefaults() { - Main.buffNoTimeDisplay[Type] = true; - Main.debuff[Type] = true; + // These settings are standard for a "opt-in eternal" buff, which has the following properties: + // - Is not removed on death + // - Saves with the player / is not removed on logout + // - Does not display its time + // - Never reduces its duration + // - Can be manually canceled Main.pvpBuff[Type] = true; + Main.persistentBuff[Type] = true; Main.buffNoSave[Type] = false; - BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; + Main.buffNoTimeDisplay[Type] = true; + BuffID.Sets.TimeLeftDoesNotDecrease[Type] = true; } + // Implementation is partially performed elsewhere using the blueCandle bool. public override void Update(Player player, ref int buffIndex) { + player.moveSpeed += MoveSpeedBoost; player.Calamity().blueCandle = true; } } diff --git a/Buffs/Placeables/CirrusPinkCandleBuff.cs b/Buffs/Placeables/CirrusPinkCandleBuff.cs index eaeb003cbc..8cf6bc1437 100644 --- a/Buffs/Placeables/CirrusPinkCandleBuff.cs +++ b/Buffs/Placeables/CirrusPinkCandleBuff.cs @@ -6,18 +6,24 @@ namespace CalamityMod.Buffs.Placeables { public class CirrusPinkCandleBuff : ModBuff { + public static double PercentHealthPerSecond = 0.004D; + public override void SetStaticDefaults() { - Main.buffNoTimeDisplay[Type] = true; - Main.debuff[Type] = true; + // These settings are standard for a "opt-in eternal" buff, which has the following properties: + // - Is not removed on death + // - Saves with the player / is not removed on logout + // - Does not display its time + // - Never reduces its duration + // - Can be manually canceled Main.pvpBuff[Type] = true; + Main.persistentBuff[Type] = true; Main.buffNoSave[Type] = false; - BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; + Main.buffNoTimeDisplay[Type] = true; + BuffID.Sets.TimeLeftDoesNotDecrease[Type] = true; } - public override void Update(Player player, ref int buffIndex) - { - player.Calamity().pinkCandle = true; - } + // Implementation is performed elsewhere using the pinkCandle bool. + public override void Update(Player player, ref int buffIndex) => player.Calamity().pinkCandle = true; } } diff --git a/Buffs/Placeables/CirrusPurpleCandleBuff.cs b/Buffs/Placeables/CirrusPurpleCandleBuff.cs index 1d50225a40..3ad0e23b18 100644 --- a/Buffs/Placeables/CirrusPurpleCandleBuff.cs +++ b/Buffs/Placeables/CirrusPurpleCandleBuff.cs @@ -6,15 +6,21 @@ namespace CalamityMod.Buffs.Placeables { public class CirrusPurpleCandleBuff : ModBuff { - public static float DefenseRatioBonus = 0.15f; + public static float DefenseRatioBonus = 0.1f; public override void SetStaticDefaults() { - Main.buffNoTimeDisplay[Type] = true; - Main.debuff[Type] = true; + // These settings are standard for a "opt-in eternal" buff, which has the following properties: + // - Is not removed on death + // - Saves with the player / is not removed on logout + // - Does not display its time + // - Never reduces its duration + // - Can be manually canceled Main.pvpBuff[Type] = true; + Main.persistentBuff[Type] = true; Main.buffNoSave[Type] = false; - BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; + Main.buffNoTimeDisplay[Type] = true; + BuffID.Sets.TimeLeftDoesNotDecrease[Type] = true; } public override void Update(Player player, ref int buffIndex) diff --git a/Buffs/Placeables/CirrusYellowCandleBuff.cs b/Buffs/Placeables/CirrusYellowCandleBuff.cs index 8ad664c83a..1b5f9a7f96 100644 --- a/Buffs/Placeables/CirrusYellowCandleBuff.cs +++ b/Buffs/Placeables/CirrusYellowCandleBuff.cs @@ -1,24 +1,37 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; +using static Terraria.NPC; namespace CalamityMod.Buffs.Placeables { public class CirrusYellowCandleBuff : ModBuff { + public static float ExtraChipDamageRatio = 0.07f; + public override void SetStaticDefaults() { - Main.buffNoTimeDisplay[Type] = true; - Main.debuff[Type] = true; + // These settings are standard for a "opt-in eternal" buff, which has the following properties: + // - Is not removed on death + // - Saves with the player / is not removed on logout + // - Does not display its time + // - Never reduces its duration + // - Can be manually canceled Main.pvpBuff[Type] = true; + Main.persistentBuff[Type] = true; Main.buffNoSave[Type] = false; - BuffID.Sets.NurseCannotRemoveDebuff[Type] = true; - - // Spite (the +5% final damage effect of Yellow Candle) is a tag buff. Nothing is immune to it. - // They may however be unaffected by it (including only temporarily) if they have incredibly high DR. - BuffID.Sets.IsATagBuff[Type] = true; + Main.buffNoTimeDisplay[Type] = true; + BuffID.Sets.TimeLeftDoesNotDecrease[Type] = true; } + // Implementation is performed elsewhere using the yellowCandle bool. public override void Update(Player player, ref int buffIndex) => player.Calamity().yellowCandle = true; + + // Yellow Candle is implemented as a dirty modifier. + internal static void ModifyHitInfo_Spite(ref HitInfo info) + { + int damageBoost = (int)(info.SourceDamage * ExtraChipDamageRatio); + info.Damage += damageBoost; + } } } diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index acacedfa82..e7048542a9 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -4,6 +4,7 @@ using System.Linq; using CalamityMod.Balancing; using CalamityMod.BiomeManagers; using CalamityMod.Buffs; +using CalamityMod.Buffs.Placeables; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer.Dashes; @@ -30,6 +31,7 @@ using CalamityMod.Items.TreasureBags.MiscGrabBags; using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.DraedonsArsenal; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs; @@ -53,6 +55,7 @@ using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.IO; +using Terraria.Utilities.Terraria.Utilities; namespace CalamityMod.CalPlayer { @@ -507,6 +510,7 @@ namespace CalamityMod.CalPlayer public bool ascendantTrail = false; public bool eGauntlet = false; public int gloveLevel = 0; // Used to prevent glove stacking + public bool alreadyHasFrogLeg = false; // Used to prevent Frog Leg tinker stacking public bool eTalisman = false; public int statisTimer = 0; public bool nucleogenesis = false; @@ -531,6 +535,8 @@ namespace CalamityMod.CalPlayer public bool honeyDewHalveDebuffs = false; public bool livingDewHalveDebuffs = false; public int jewelBonusDefense = 0; + public float pulseCounter = 0; // Toxic Heart + public float pulseRate = 1; // Toxic Heart public bool aAmpoule = false; public bool rOoze = false; public bool JustWasDebuffed = false; @@ -792,6 +798,7 @@ namespace CalamityMod.CalPlayer public bool astralStarRain = false; public int astralStarRainCooldown = 0; public int AbaddonCooldown = 0; + public int AlchFlaskCooldown = 0; public bool plagueReaper = false; public bool plaguebringerPatronSet = false; public bool plaguebringerCarapace = false; @@ -876,6 +883,7 @@ namespace CalamityMod.CalPlayer public bool gState = false; public bool bBlood = false; public bool brainRot = false; + public bool laceration = false; public bool elementalMix = false; public bool icarusFolly = false; public bool weakPetrification = false; @@ -898,6 +906,9 @@ namespace CalamityMod.CalPlayer public bool wither = false; public bool ManaBurn = false; + public int ImmobilityDebuffImmunityTimer = 0; + public const int ImmobilityDebuffImmunityTimerMax = 300; + public const int SulphSeaWaterSafetyTime = 720; public const int SulphSeaWaterRecoveryTime = 150; #endregion @@ -1095,13 +1106,21 @@ namespace CalamityMod.CalPlayer #region Biome public bool ZoneCalamity => Player.InModBiome(ModContent.GetInstance()); public bool ZoneAstral => Player.InModBiome(ModContent.GetInstance()) && !ZoneAbyss; - public bool ZoneSunkenSea => Player.InModBiome(ModContent.GetInstance()); + public bool ZoneSunkenSea => ZoneSunkenBurrows || ZoneSunkenSeaReefs || ZoneSunkenSeaPolyp || ZoneSunkenSeaShores; + public bool ZoneSunkenBurrows => Player.InModBiome(ModContent.GetInstance()); + public bool ZoneSunkenSeaReefs => Player.InModBiome(ModContent.GetInstance()); + public bool ZoneSunkenSeaPolyp => Player.InModBiome(ModContent.GetInstance()); + public bool ZoneSunkenSeaShores => Player.InModBiome(ModContent.GetInstance()); public bool ZoneSulphur => Player.InModBiome(ModContent.GetInstance()); public bool ZoneAbyss => ZoneAbyssLayer1 || ZoneAbyssLayer2 || ZoneAbyssLayer3 || ZoneAbyssLayer4; public bool ZoneAbyssLayer1 => Player.InModBiome(ModContent.GetInstance()); public bool ZoneAbyssLayer2 => Player.InModBiome(ModContent.GetInstance()); public bool ZoneAbyssLayer3 => Player.InModBiome(ModContent.GetInstance()); public bool ZoneAbyssLayer4 => Player.InModBiome(ModContent.GetInstance()); + public bool ZoneFloralParadise => Player.InModBiome(ModContent.GetInstance()); + + public bool InAnyCalamityBiome => ZoneAbyss || ZoneCalamity || ZoneFloralParadise || ZoneSulphur || ZoneSunkenSea || ZoneAstral; + public bool abyssDeath = false; public int abyssBreathCD; public float caveDarkness = 0f; @@ -1705,6 +1724,7 @@ namespace CalamityMod.CalPlayer ascendantTrail = false; eGauntlet = false; gloveLevel = 0; + alreadyHasFrogLeg = false; eTalisman = false; nucleogenesis = false; nuclearFuelRod = false; @@ -1783,7 +1803,6 @@ namespace CalamityMod.CalPlayer corrosiveSpine = false; RustyMedallionDroplets = false; MiniSwarmers = false; - noStupidNaturalARSpawns = false; rottenDogTooth = false; angelicAlliance = false; BloomStoneRegen = false; @@ -1937,6 +1956,7 @@ namespace CalamityMod.CalPlayer gState = false; bBlood = false; brainRot = false; + laceration = false; elementalMix = false; icarusFolly = false; vHex = false; @@ -2155,7 +2175,8 @@ namespace CalamityMod.CalPlayer StellarTorus = false; LiliesOfFinalityBool = false; - /* + /* Spawn blockers from back when they used to work by being favorited and not a toggleable item + noStupidNaturalARSpawns = false disableVoodooSpawns = false; disablePerfCystSpawns = false; disableHiveCystSpawns = false; @@ -2315,6 +2336,7 @@ namespace CalamityMod.CalPlayer gSabatonTempJumpSpeed = 0; astralStarRainCooldown = 0; AbaddonCooldown = 0; + AlchFlaskCooldown = 0; silvaMageCooldown = 0; bloodflareMageCooldown = 0; tarraRangedCooldown = 0; @@ -2360,6 +2382,7 @@ namespace CalamityMod.CalPlayer gState = false; bBlood = false; brainRot = false; + laceration = false; elementalMix = false; icarusFolly = false; vHex = false; @@ -2381,6 +2404,7 @@ namespace CalamityMod.CalPlayer banishingFire = false; wither = false; PurityHealSlowdownFrames = 0; + ImmobilityDebuffImmunityTimer = 0; #endregion #region Rogue @@ -2703,6 +2727,15 @@ namespace CalamityMod.CalPlayer if (Player.dead) return; + if (ascendantInsignia && Main.myPlayer == Player.whoAmI && CalamityKeybinds.AscendantInsigniaHotKey.JustPressed && ascendantInsigniaCooldown <= 0) + { + var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); + Projectile.NewProjectileDirect(source, Player.Center - Vector2.UnitY * 45f, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/AscendantActivate")); + ascendantInsigniaCooldown = 2400; + ascendantInsigniaBuffTime = 240; //4 seconds + } + //Only increment hotkey holdtime if not on ground, not mounted, not on rope, not hooked, not tongued, otherwise reset hold time to zero if (CalamityKeybinds.GravistarSabatonHotkey.Current && gSabaton && Main.myPlayer == Player.whoAmI && (Player.velocity.Y != Player.oldVelocity.Y) && !Player.pulley && !Player.mount.Active && Player.grappling[0] == -1 && !Player.tongued) { @@ -2738,6 +2771,7 @@ namespace CalamityMod.CalPlayer { Player.Teleport(teleportLocation, 4, 0); NetMessage.SendData(MessageID.TeleportEntity, -1, -1, null, 0, (float)Player.whoAmI, teleportLocation.X, teleportLocation.Y, 1, 0, 0); + SoundEngine.PlaySound(NormalityRelocator.TeleportSound, Player.Center); int duration = areThereAnyDamnBosses ? chaosStateDuration_NR : 360; Player.AddBuff(BuffID.ChaosState, duration, true); @@ -3075,16 +3109,16 @@ namespace CalamityMod.CalPlayer //Right click dash on Speed Blaster if (sBlasterDashActivated == true) { - if ((Player.controlUp || Player.controlDown || Player.controlLeft || Player.controlRight) && !Player.pulley && Player.grappling[0] == -1 && !Player.tongued && !Player.mount.Active && Player.HasCooldown(Cooldowns.SpeedBlasterBoost.ID) && Player.dashDelay == 0) + if ((Player.controlUp || Player.controlDown || Player.controlLeft || Player.controlRight) && !Player.pulley && Player.grappling[0] == -1 && !Player.tongued && !Player.mount.Active && (Player.HasCooldown(SpeedBlasterBoost.ID) || Player.HasCooldown(SuperradiantSawBoost.ID)) && Player.dashDelay == 0) { SpeedBlasterDashStarted = true; } sBlasterDashActivated = false; } - if (Player.Calamity().SpeedBlasterDashStarted || (Player.dashDelay != 0 && Player.Calamity().LastUsedDashID == SpeedBlasterDash.ID)) + if (Player.Calamity().SpeedBlasterDashStarted || (Player.dashDelay != 0 && (Player.Calamity().LastUsedDashID == SuperradiantSawDash.ID || Player.Calamity().LastUsedDashID == SpeedBlasterDash.ID))) { - Player.Calamity().DeferredDashID = SpeedBlasterDash.ID; + Player.Calamity().DeferredDashID = Player.ActiveItem().type == ModContent.ItemType() ? SuperradiantSawDash.ID : SpeedBlasterDash.ID; Player.dash = 0; } @@ -3701,7 +3735,7 @@ namespace CalamityMod.CalPlayer (kamiBoost ? KamiBuff.RunAccelerationBoost : 0f) + (CobaltSet ? CobaltArmorSetChange.SpeedBoostSetBonusPercentage * 0.01f : 0f) + (silvaSet ? 0.05f : 0f) + - (blueCandle ? 0.05f : 0f) + + (blueCandle ? CirrusBlueCandleBuff.AccelerationBoost : 0f) + (planarSpeedBoost > 0 ? (0.01f * planarSpeedBoost) : 0f) + (hasteLevel * 0.05f); @@ -4280,20 +4314,8 @@ namespace CalamityMod.CalPlayer if (weakPetrification) WeakPetrification(); - // Disable vanilla dashes during god slayer dash - if (godSlayerDashHotKeyPressed) - { - // Set the player to have no registered vanilla dashes. - Player.dashType = 0; - - // Prevent the possibility of Shield of Cthulhu invulnerability exploits. - Player.eocHit = -1; - if (Player.eocDash != 0) - Player.eocDash = 0; - } - - // Disable vanilla dashes during god slayer dash - if (SpeedBlasterDashStarted) + // Disable vanilla dashes during God Slayer or Speed Blaster dashes + if (godSlayerDashHotKeyPressed || SpeedBlasterDashStarted) { // Set the player to have no registered vanilla dashes. Player.dashType = 0; @@ -4399,13 +4421,7 @@ namespace CalamityMod.CalPlayer Player.blockExtraJumps = true; Player.rocketBoots = 0; - Player.jumpBoost = false; - Player.slowFall = false; - Player.gravControl = false; - Player.gravControl2 = false; - Player.jumpSpeedBoost = 0f; Player.wingTimeMax = (int)(Player.wingTimeMax * 0.5); - Player.balloon = -1; } #endregion @@ -4870,15 +4886,8 @@ namespace CalamityMod.CalPlayer if (CalamityConfig.Instance.SpeedrunTimer) CalamityMod.SpeedrunTimer.Restart(); - // - // 04JAN2024: Ozzatron: Added a temporary message for the Gimme Swag plushie campaign. - // This message should not exist indefinitely. It is being pushed as a silent public update just for itself. - // As this message always displays and is not configurable, the previous rules about startup messages have been replaced with always-true. - // - // Set a random delay between 12 and 20 seconds. When this delay hits zero, startup messages display - bool plushieMessage = true; - if (plushieMessage || CalamityConfig.Instance.WikiStatusMessage) + if (CalamityConfig.Instance.WikiStatusMessage) { startMessageDisplayDelay = Main.rand.Next(CalamityUtils.SecondsToFrames(12), CalamityUtils.SecondsToFrames(20) + 1); } diff --git a/CalPlayer/CalamityPlayerDashEffects.cs b/CalPlayer/CalamityPlayerDashEffects.cs index 279dff0a6d..5c45619b75 100644 --- a/CalPlayer/CalamityPlayerDashEffects.cs +++ b/CalPlayer/CalamityPlayerDashEffects.cs @@ -13,8 +13,7 @@ namespace CalamityMod.CalPlayer { public partial class CalamityPlayer : ModPlayer { - public int VerticalGodslayerDashTimer; - public int VerticalSpeedBlasterDashTimer; + public int VerticalOmnidashTimer; private string dashID; //private backing variable @@ -104,16 +103,9 @@ namespace CalamityMod.CalPlayer } } - if (Player.dashDelay > 0) //Speed Blaster - { - VerticalSpeedBlasterDashTimer = 0; - LastUsedDashID = string.Empty; - return; - } - if (Player.dashDelay > 0) { - VerticalGodslayerDashTimer = 0; + VerticalOmnidashTimer = 0; LastUsedDashID = string.Empty; return; } @@ -137,21 +129,10 @@ namespace CalamityMod.CalPlayer // Handle mid-dash effects. UsedDash.MidDashEffects(Player, ref dashSpeed, ref dashSpeedDecelerationFactor, ref runSpeedDecelerationFactor); - if (UsedDash.IsOmnidirectional && VerticalGodslayerDashTimer < 25) + if (UsedDash.IsOmnidirectional && VerticalOmnidashTimer < 25) { - VerticalGodslayerDashTimer++; - if (VerticalGodslayerDashTimer >= 25) - { - Player.dashDelay = dashDelayToApply; - // Stop the player from going flying - Player.velocity *= 0.2f; - } - } - - if (UsedDash.IsOmnidirectional && VerticalSpeedBlasterDashTimer < 25) - { - VerticalSpeedBlasterDashTimer++; - if (VerticalSpeedBlasterDashTimer >= 25) + VerticalOmnidashTimer++; + if (VerticalOmnidashTimer >= 25) { Player.dashDelay = dashDelayToApply; // Stop the player from going flying diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index d5326f5e54..19d13db305 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -330,6 +330,24 @@ namespace CalamityMod.CalPlayer } } + // Prideful Hunter's Planar Ripper movement speed boost + if (calamityPlayer.planarSpeedBoost > 0 && drawInfo.shadow == 0f) + { + int spawnChance = (int)(13 - (calamityPlayer.planarSpeedBoost / 2)); + if (Main.rand.NextBool(spawnChance)) + { + Vector2 sparkVelocity = -(Vector2.UnitY * Main.rand.NextFloat(2.5f, 5f)).RotatedByRandom(MathHelper.Pi / 10); + Vector2 sparkPos = new Vector2(Player.position.X + Main.rand.NextFloat(-8f, 40f), Player.position.Y + Main.rand.NextFloat(-8f, 56f)); + Particle movementSpark = new AltLineParticle(sparkPos, sparkVelocity, false, 20, Main.rand.NextFloat(0.375f, 0.5f), new Color(130, 255, 255)); + GeneralParticleHandler.SpawnParticle(movementSpark); + + sparkVelocity = -(Vector2.UnitY * Main.rand.NextFloat(3f, 5.5f)).RotatedByRandom(MathHelper.Pi / 6); + sparkPos = new Vector2(Player.position.X + Main.rand.NextFloat(-8f, 40f), Player.position.Y + Main.rand.NextFloat(-8f, 56f)); + Particle addSparks = new CustomPulse(sparkPos, sparkVelocity, new Color(180, 255, 255), "CalamityMod/Particles/ElectricSpark", Vector2.One, 0f, 0.5f, 0.65f, 20); + GeneralParticleHandler.SpawnParticle(addSparks); + } + } + // Some extraneous and probably undocumented visual effect caused by the heart lad pet thing if ((calamityPlayer.ladHearts > 0) && !Player.loveStruck && Main.netMode != NetmodeID.Server && drawInfo.shadow == 0f) { diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index 7dad272e20..8482bc3f11 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -3,6 +3,7 @@ using System.Linq; using CalamityMod.Balancing; using CalamityMod.Buffs.Cooldowns; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.Placeables; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer.Dashes; @@ -37,6 +38,7 @@ using CalamityMod.Projectiles.Typeless; using CalamityMod.UI; using CalamityMod.World; using Microsoft.Xna.Framework; +using Mono.Cecil; using Terraria; using Terraria.Audio; using Terraria.Chat; @@ -436,6 +438,10 @@ namespace CalamityMod.CalPlayer { damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BrainRot" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); } + if (laceration) + { + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Laceration" + Main.rand.Next(1, 3 + 1)).Format(Player.name)); + } if (elementalMix) { damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.ElementalMix" + Main.rand.Next(1, 2 + 1)).Format(Player.name)); @@ -523,6 +529,14 @@ namespace CalamityMod.CalPlayer // Apply all Calamity multipliers as a sum total to TML New Damage in a single step modifiers.SourceDamage *= totalDamageMult; + // 01JUN2024: Ozzatron: apply Yellow Candle "chip damage" as a dirty modifier + // The registration of the dirty modifier is conditional to ensure it doesn't apply to "near invincible" targets + // + // FinalDamage cannot be used for the intended effect because there is no way to access the actual damage of the hit + CalamityGlobalNPC cgn = target.Calamity(); + if (yellowCandle && cgn.DR < 0.99f && target.takenDamageMultiplier > 0.05f) + modifiers.ModifyHitInfo += CirrusYellowCandleBuff.ModifyHitInfo_Spite; + // Excalibur and True Excalibur deal +100% damage to targets above 75% HP. if (item.type == ItemID.Excalibur || item.type == ItemID.TrueExcalibur) { @@ -589,6 +603,14 @@ namespace CalamityMod.CalPlayer // Apply all Calamity multipliers as a sum total to TML New Damage in a single step modifiers.SourceDamage *= totalDamageMult; + // 01JUN2024: Ozzatron: apply Yellow Candle "chip damage" as a dirty modifier + // The registration of the dirty modifier is conditional to ensure it doesn't apply to "near invincible" targets + // + // FinalDamage cannot be used for the intended effect because there is no way to access the actual damage of the hit + CalamityGlobalNPC cgn = target.Calamity(); + if (yellowCandle && cgn.DR < 0.99f && target.takenDamageMultiplier > 0.05f) + modifiers.ModifyHitInfo += CirrusYellowCandleBuff.ModifyHitInfo_Spite; + // Stealth strike damage multipliers are applied here. // TODO -- stealth should be its own damage class and this should be applied as player StealthDamage *= XYZ if (proj.Calamity().stealthStrike && proj.CountsAsClass()) @@ -1172,6 +1194,8 @@ namespace CalamityMod.CalPlayer if (crawCarapace) { npc.AddBuff(ModContent.BuffType(), 900); + int onHitDamage = Player.CalcIntDamage(40); + Player.ApplyDamageToNPC(npc, onHitDamage, 0f, 0, false); SoundEngine.PlaySound(SoundID.NPCHit33 with { Volume = 0.5f }, Player.Center); } @@ -1179,6 +1203,8 @@ namespace CalamityMod.CalPlayer { npc.AddBuff(ModContent.BuffType(), 900); npc.AddBuff(ModContent.BuffType(), 900); + int onHitDamage = Player.CalcIntDamage(250); + Player.ApplyDamageToNPC(npc, onHitDamage, 0f, 0, false); SoundEngine.PlaySound(BaroclawHit, Player.Center); Vector2 bloodSpawnPosition = Player.Center + Main.rand.NextVector2Circular(Player.width, Player.height) * 0.04f; Vector2 splatterDirection = (Player.Center - bloodSpawnPosition).SafeNormalize(Vector2.UnitY); @@ -1198,6 +1224,8 @@ namespace CalamityMod.CalPlayer if (absorber) { npc.AddBuff(ModContent.BuffType(), 900); + int onHitDamage = Player.CalcIntDamage(350); + Player.ApplyDamageToNPC(npc, onHitDamage, 0f, 0, false); SoundEngine.PlaySound(AbsorberHit, Player.Center); Vector2 bloodSpawnPosition = Player.Center + Main.rand.NextVector2Circular(Player.width, Player.height) * 0.04f; Vector2 splatterDirection = (Player.Center - bloodSpawnPosition).SafeNormalize(Vector2.UnitY); @@ -1213,6 +1241,22 @@ namespace CalamityMod.CalPlayer GeneralParticleHandler.SpawnParticle(spark); } } + + if (alchFlask) + { + for (int i = 0; i < 9; i++) + { + int seekerDamage = (int)Player.GetBestClassDamage().ApplyTo(15); + seekerDamage = Player.ApplyArmorAccDamageBonusesTo(seekerDamage); + + Projectile bee = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), Player.Center, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.2f), ModContent.ProjectileType(), seekerDamage, 0f, Player.whoAmI, -20, 30, 2); + bee.ArmorPenetration = 35; + bee.penetrate = 6; + bee.extraUpdates = 2; + bee.timeLeft = 600; + } + Player.AddBuff(BuffID.Honey, 900); + } } public override void OnHitByProjectile(Projectile proj, Player.HurtInfo hurtInfo) @@ -1233,13 +1277,13 @@ namespace CalamityMod.CalPlayer if (Main.player[proj.owner] is null) { if (!Main.npc[proj.owner].friendly) - Main.npc[proj.owner].AddBuff(BuffID.Poisoned, 120); + Main.npc[proj.owner].AddBuff(BuffID.Poisoned, 60); } else { Player p = Main.player[proj.owner]; if (p.hostile && Player.hostile && (Player.team != p.team || p.team == 0)) - p.AddBuff(BuffID.Poisoned, 120); + p.AddBuff(BuffID.Poisoned, 60); } } @@ -1300,10 +1344,6 @@ namespace CalamityMod.CalPlayer { Player.AddBuff(BuffID.BrokenArmor, 600); } - else if (proj.type == ProjectileID.FrostBeam && !Player.frozen && !gState) - { - Player.AddBuff(ModContent.BuffType(), 60); - } else if (proj.type == ProjectileID.DeathLaser || proj.type == ProjectileID.RocketSkeleton || proj.type == ProjectileID.BombSkeletronPrime) { Player.AddBuff(BuffID.OnFire, 180); @@ -1339,7 +1379,9 @@ namespace CalamityMod.CalPlayer } else if (proj.type == ProjectileID.CultistBossIceMist) { - Player.AddBuff(BuffID.Frozen, 60); + if (!Player.frozen) + Player.AddBuff(BuffID.Frozen, 60); + Player.AddBuff(BuffID.Chilled, 180); } else if (proj.type == ProjectileID.CultistBossLightningOrbArc) @@ -1672,7 +1714,7 @@ namespace CalamityMod.CalPlayer if (blazingCoreParry > 0) //check for active parry { - if (blazingCoreParry >= 18) //only the first 12 frames (0.2 seconds) counts for a valid parry + if (blazingCoreParry >= 12) //only the first 18 frames (0.3 seconds) counts for a valid parry { if (!Player.HasCooldown(ParryCooldown.ID)) { @@ -1696,7 +1738,7 @@ namespace CalamityMod.CalPlayer } else if (flameLickedShellParry > 0) { - if (flameLickedShellParry >= 18) + if (flameLickedShellParry >= 12) { if (!Player.HasCooldown(ParryCooldown.ID)) { diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 73a7ec8f66..8ddeca6781 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -2,17 +2,21 @@ using System.Linq; using CalamityMod.Buffs.Alcohol; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.Placeables; using CalamityMod.Cooldowns; using CalamityMod.Items.Accessories; using CalamityMod.NPCs; using CalamityMod.Projectiles.Ranged; +using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using Terraria.Utilities.Terraria.Utilities; namespace CalamityMod.CalPlayer { @@ -21,9 +25,6 @@ namespace CalamityMod.CalPlayer #region Update Bad Life Regen public override void UpdateBadLifeRegen() { - if (Player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) - noLifeRegen = true; - // Universal +25% increase to DoT debuff damage in Death Mode float deathNegativeRegenBonus = 0.25f; float calamityDebuffMultiplier = 1f + (CalamityWorld.death ? deathNegativeRegenBonus : 0f); @@ -98,6 +99,7 @@ namespace CalamityMod.CalPlayer ApplyDoTDebuff(weakBrimstoneFlames, 7); ApplyDoTDebuff(bBlood, 8, purity); ApplyDoTDebuff(brainRot, 8, purity); + ApplyDoTDebuff(laceration, 12, purity); ApplyDoTDebuff(elementalMix, 50, purity); ApplyDoTDebuff(vaporfied, 8, purity); ApplyDoTDebuff(bFlames, abaddon ? 10 : 30, purity); @@ -106,7 +108,7 @@ namespace CalamityMod.CalPlayer ApplyDoTDebuff(vHex, 35); ApplyDoTDebuff(cDepth, 18, purity); ApplyDoTDebuff(astralInfection, 24, infectedJewel || purity); - ApplyDoTDebuff(pFlames, 30, purity); + ApplyDoTDebuff(pFlames, alchFlask ? 10 : 30, purity); ApplyDoTDebuff(cragsLava, 30); ApplyDoTDebuff(shadowflame, 30, purity); // Profaned Soul Crystal turns you into Providence, a God, and you take more damage from God Slayer Inferno @@ -422,8 +424,8 @@ namespace CalamityMod.CalPlayer if (rOoze || aAmpoule || purity) { float missingLifeRatio = (Player.statLifeMax2 - Player.statLife) / Player.statLifeMax2; - //Ambrosial Ampule and ooze give between 2 and 6 hp/s, Purity gives between 3 and 7 hp/s - float lifeRegenToGive = MathHelper.Lerp(purity ? 6f : 4f, purity ? 14f : 12f, missingLifeRatio); + //Ambrosial Ampule and ooze give between 2 and 6 hp/s + float lifeRegenToGive = MathHelper.Lerp(4f, 12f, missingLifeRatio); Player.lifeRegen += (int)lifeRegenToGive; } @@ -585,13 +587,6 @@ namespace CalamityMod.CalPlayer } } } - - // TODO -- Why is this here? - if (weakPetrification) - { - if (Player.mount.Active) - Player.mount.Dismount(Player); - } #endregion // Chalice of the Blood God bleedout @@ -742,7 +737,7 @@ namespace CalamityMod.CalPlayer if (pinkCandle && !noLifeRegen) { // Every frame, add up 1/60th of the healing value (0.4% max HP per second) - pinkCandleHealFraction += Player.statLifeMax2 * 0.004 / 60; + pinkCandleHealFraction += Player.statLifeMax2 * CirrusPinkCandleBuff.PercentHealthPerSecond / 60; if (pinkCandleHealFraction >= 1D) { @@ -885,6 +880,26 @@ namespace CalamityMod.CalPlayer } } } + + if (toxicHeart) // Since it needs to know your life regen, it must be placed here + { + int auraDamage = (int)Player.GetBestClassDamage().ApplyTo(200); + auraDamage = Player.ApplyArmorAccDamageBonusesTo(auraDamage); + var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); + pulseRate = Utils.Remap(Player.lifeRegen, -30, 10, 20, 1, true); + if (pulseCounter >= 420) + { + Projectile.NewProjectileDirect(source, Player.Center, Vector2.Zero, ModContent.ProjectileType(), auraDamage, 0f, Player.whoAmI, 0, 0, 0); + pulseCounter = 0; + float soundVolume = Utils.Remap(Player.lifeRegen, -30, 10, 1f, 0.3f, true); + SoundStyle heartbeat = new("CalamityMod/Sounds/Item/Heartbeat"); + SoundEngine.PlaySound(heartbeat with { Volume = soundVolume, PitchVariance = 0.2f }, Player.Center); + } + else + { + pulseCounter += MathHelper.Clamp(pulseRate, 1, 20); + } + } } #endregion } diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 8272464bbe..4be7c6685d 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Balancing; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.Placeables; using CalamityMod.Buffs.Potions; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; @@ -144,6 +145,9 @@ namespace CalamityMod.CalPlayer // Check if schematics are present on the mouse, for the sake of registering their recipes. CheckIfMouseItemIsSchematic(); + // Do environmental effects. + DoEnvironmentalEffects(); + // Handle Androomba's Right Click function AndroombaRightClick(); @@ -310,9 +314,9 @@ namespace CalamityMod.CalPlayer SparkParticle spark2 = new SparkParticle(Player.Center + Player.velocity.RotatedBy(-2f * Player.direction) * 1.5f, SparkVelocity2, false, Main.rand.Next(11, 13), sparkscale, Main.rand.NextBool() ? Color.DarkOrange : Color.OrangeRed); GeneralParticleHandler.SpawnParticle(spark2); - if (Player.miscCounter % 5 == 0 && Player.velocity != Vector2.Zero) //every other frame spawn the hitbox + if (Player.miscCounter % 6 == 0 && Player.velocity != Vector2.Zero) { - int damage = Player.ApplyArmorAccDamageBonusesTo(Player.GetBestClassDamage().ApplyTo(175)); + int damage = Player.ApplyArmorAccDamageBonusesTo(Player.GetBestClassDamage().ApplyTo(170)); Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), damage, 10f, Player.whoAmI); } } @@ -1337,6 +1341,22 @@ namespace CalamityMod.CalPlayer if (expiredCooldowns.Count > 0) SyncCooldownRemoval(Main.netMode == NetmodeID.Server, expiredCooldowns); + // Grant the player 5 seconds of immunity to immobilizing debuffs after an immobilizing debuff wears off. + if (Player.stoned || Player.frozen || Player.webbed || gState) + { + ImmobilityDebuffImmunityTimer = ImmobilityDebuffImmunityTimerMax; + } + else if (ImmobilityDebuffImmunityTimer > 0) + { + ImmobilityDebuffImmunityTimer--; + Player.buffImmune[BuffID.Stoned] = true; + Player.buffImmune[BuffID.Frozen] = true; + Player.buffImmune[BuffID.Webbed] = true; + Player.buffImmune[ModContent.BuffType()] = true; + } + + if (ascendantInsigniaCooldown > 0 && ascendantInsigniaBuffTime <= 0) + ascendantInsigniaCooldown--; if (DragonsBreathAudioCooldown > 0) DragonsBreathAudioCooldown--; if (DragonsBreathAudioCooldown2 > 0) @@ -1373,6 +1393,8 @@ namespace CalamityMod.CalPlayer astralStarRainCooldown--; if (AbaddonCooldown > 0) AbaddonCooldown--; + if (AlchFlaskCooldown > 0) + AlchFlaskCooldown--; if (tarraRangedCooldown > 0) tarraRangedCooldown--; if (bloodflareMageCooldown > 0) @@ -2012,6 +2034,13 @@ namespace CalamityMod.CalPlayer } // This section of code ensures set bonuses and accessories with cooldowns go on cooldown immediately if the armor or accessory is removed. + if (!ascendantInsignia && ascendantInsigniaBuffTime > 0) + { + ascendantInsigniaBuffTime = 0; + ascendantInsigniaCooldown = 2400; + Player.AddCooldown(AscendEffect.ID, 2400); + } + if (!brimflameSet && brimflameFrenzy) { brimflameFrenzy = false; @@ -2069,6 +2098,31 @@ namespace CalamityMod.CalPlayer } #endregion + #region Biome Effects + public void DrawPollenInFloralParadise() + { + if (!ZoneFloralParadise || !Main.rand.NextBool(7) || Main.netMode == NetmodeID.Server) + return; + + for (int i = 0; i < 15; i++) + { + Vector2 dustSpawnPosition = Player.Center + Main.rand.NextVector2Square(-360f, 360f); + dustSpawnPosition.Y += 200f; + Tile tile = CalamityUtils.ParanoidTileRetrieval((int)(dustSpawnPosition.X / 16f), (int)(dustSpawnPosition.Y / 16f)); + if (WorldGen.SolidTile(tile) || tile.LiquidAmount > 0) + continue; + + Dust pollen = Dust.NewDustPerfect(dustSpawnPosition, 261); + pollen.velocity = Main.rand.NextVector2Circular(0.4f, 0.4f); + pollen.scale = Main.rand.NextFloat(0.8f, 1f); + pollen.fadeIn = 2f; + pollen.color = Color.YellowGreen; + pollen.noGravity = true; + break; + } + } + #endregion Biome Effects + #region Abyss Effects private void AbyssEffects() { @@ -2519,6 +2573,21 @@ namespace CalamityMod.CalPlayer if (AdamantiteSet) Player.statDefense += AdamantiteSetDefenseBoost; + // Warmth makes Chilled, Frozen, and Glacial State tick down 3x as fast + if (Player.HasBuff(BuffID.Warmth)) + { + for (int b = 0; b < Player.MaxBuffs; b++) + { + if (Player.buffType[b] == BuffID.Chilled || Player.buffType[b] == BuffID.Frozen || Player.buffType[b] == ModContent.BuffType()) + { + if (Player.buffTime[b] > 3) + { + Player.buffTime[b] -= 2; + } + } + } + } + if (astralInjection) { if (Player.statMana < Player.statManaMax2) @@ -2581,10 +2650,13 @@ namespace CalamityMod.CalPlayer } if (crawCarapace) - Player.GetDamage() += 0.05f; + Player.GetDamage() += 0.07f; if (baroclaw) + { + Player.endurance += 0.05f; Player.GetDamage() += 0.1f; + } if (aeroStone && !Player.slowFall && Player.wingTime < Player.wingTimeMax) { @@ -2819,16 +2891,13 @@ namespace CalamityMod.CalPlayer (harpyRing ? 0.2 : 0D) + (reaverSpeed ? 0.1 : 0D) + (angelTreads ? 0.1 : 0D) + - (blueCandle ? 0.1 : 0D) + + (blueCandle ? CirrusBlueCandleBuff.WingTimeBoost : 0D) + (soaring ? 0.1 : 0D) + (prismaticGreaves ? 0.1 : 0D) + (plagueReaper ? 0.05 : 0D) + (ascendantInsignia ? 0.05 : 0D) + // Added to soaring insignia's flight to get 30% (Player.empressBrooch ? 0.25 : 0D); - if (blueCandle) - Player.moveSpeed += 0.1f; - if (community) { float baseBoost = TheCommunity.CalculatePower(); @@ -2915,15 +2984,14 @@ namespace CalamityMod.CalPlayer } if (wDeath && !purity) - Player.GetDamage() -= 0.25f; + Player.GetDamage() -= 0.2f; if (astralInfection && !(infectedJewel || purity)) - Player.GetDamage() -= 0.15f; + Player.GetDamage() -= 0.1f; if (pFlames && !purity) { - Player.blind = true; - Player.GetDamage() -= 0.15f; + Player.GetDamage() -= 0.1f; } if (aCrunch && !laudanum && !purity) @@ -3083,27 +3151,13 @@ namespace CalamityMod.CalPlayer } } - if (ascendantInsignia) + if (ascendantInsignia && ascendantInsigniaBuffTime > 0) { - if (CalamityKeybinds.AscendantInsigniaHotKey.JustPressed && ascendantInsigniaCooldown <= 0) - { - var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); - Projectile.NewProjectileDirect(source, Player.Center - Vector2.UnitY * 45f, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); - SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/AscendantActivate")); - ascendantInsigniaCooldown = 2400; - ascendantInsigniaBuffTime = 240; //4 seconds - } - - if (ascendantInsigniaCooldown > 0 && ascendantInsigniaBuffTime <= 0) - ascendantInsigniaCooldown--; + ascendantTrail = true; + infiniteFlight = true; if (ascendantInsigniaBuffTime == 1) Player.AddCooldown(AscendEffect.ID, 2400); - if (ascendantInsigniaBuffTime > 0) - { - ascendantTrail = true; - infiniteFlight = true; - ascendantInsigniaBuffTime--; - } + ascendantInsigniaBuffTime--; } if (abyssalDivingSuit && !Player.IsUnderwater()) @@ -4153,9 +4207,6 @@ namespace CalamityMod.CalPlayer CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Misc.WikiStatus1"); CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Misc.WikiStatus2"); } - - // 04JAN2024: Ozzatron: Plushie message always appears. - CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.Misc.GimmeSwagPlushieCampaign"); } --startMessageDisplayDelay; diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index 42a6b1c2af..2464cd250f 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -595,14 +595,17 @@ namespace CalamityMod.CalPlayer if (!proj.CountsAsClass() && !proj.CountsAsClass() && Player.meleeEnchant == 7) Projectile.NewProjectile(source, position, proj.velocity, ProjectileID.ConfettiMelee, 0, 0f, proj.owner); - if (alchFlask && Player.ownedProjectileCounts[ProjectileType()] < 3 && hasClass) + if (alchFlask && AlchFlaskCooldown == 0 && proj.type != ModContent.ProjectileType()) { - int seekerDamage = (int)Player.GetBestClassDamage().ApplyTo(30); + int seekerDamage = (int)Player.GetBestClassDamage().ApplyTo(10); seekerDamage = Player.ApplyArmorAccDamageBonusesTo(seekerDamage); + Vector2 seekerVelocity = new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.2f); - Projectile projectile = CalamityUtils.SpawnOrb(proj, seekerDamage, ProjectileType(), 400f, 12f); - if (projectile.whoAmI.WithinBounds(Main.maxProjectiles)) - Main.projectile[projectile.whoAmI].DamageType = DamageClass.Generic; + Projectile bee = Projectile.NewProjectileDirect(source, position, seekerVelocity, ModContent.ProjectileType(), seekerDamage, 0f, Player.whoAmI, -20, 30, 2); + bee.ArmorPenetration = 20; + bee.penetrate = 2; + bee.extraUpdates = 1; + AlchFlaskCooldown = 7; } bool lifeAndShieldCondition = Player.statLife >= Player.statLifeMax2 && (!HasAnyEnergyShield || TotalEnergyShielding >= TotalMaxShieldDurability); @@ -1237,9 +1240,6 @@ namespace CalamityMod.CalPlayer if (divineBless) target.AddBuff(BuffType(), 60); - if (holyMinions) - target.AddBuff(BuffType(), 180); - if (shadowMinions) target.AddBuff(BuffID.ShadowFlame, 180); @@ -1266,7 +1266,7 @@ namespace CalamityMod.CalPlayer if (omegaBlueChestplate) target.AddBuff(BuffType(), 180); if (sulphurSet) - target.AddBuff(BuffID.Poisoned, 120); + target.AddBuff(BuffID.Poisoned, 60); if (abyssalAmulet) { CalamityUtils.Inflict246DebuffsNPC(target, BuffType()); diff --git a/CalPlayer/Dashes/SpeedBlasterDash.cs b/CalPlayer/Dashes/SpeedBlasterDash.cs index 9541964367..22772ab180 100644 --- a/CalPlayer/Dashes/SpeedBlasterDash.cs +++ b/CalPlayer/Dashes/SpeedBlasterDash.cs @@ -1,7 +1,11 @@ using CalamityMod.Enums; using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; +using Terraria.ID; namespace CalamityMod.CalPlayer.Dashes { @@ -12,8 +16,6 @@ namespace CalamityMod.CalPlayer.Dashes public override bool IsOmnidirectional => true; - public bool dustOnce = true; - public override float CalculateDashSpeed(Player player) => 30f; public override void OnDashEffects(Player player) @@ -23,6 +25,15 @@ namespace CalamityMod.CalPlayer.Dashes public override void MidDashEffects(Player player, ref float dashSpeed, ref float dashSpeedDecelerationFactor, ref float runSpeedDecelerationFactor) { + Dust trail = Dust.NewDustPerfect(player.Center + Main.rand.NextVector2Unit() * 12f, DustID.RainbowTorch, -player.velocity * 0.2f, 150, Color.Aqua, 1.2f); + trail.noGravity = true; + + Vector2 sparkVel = player.velocity.SafeNormalize(Vector2.UnitY) * Main.rand.NextFloat(-3f, -6f); + Color sparkColor = SpeedBlasterShot.GetColor(Main.rand.Next(5)); + float scale = Main.rand.NextFloat(1f, 1.6f); // Bloom effect is double the spark's size + Particle spark = new CritSpark(player.Center + Main.rand.NextVector2Unit() * 12f, sparkVel, Color.White, sparkColor, scale, 15, 0.5f, scale * 2f); + GeneralParticleHandler.SpawnParticle(spark); + // Fall way, way, faster than usual. player.maxFallSpeed = 50f; diff --git a/CalPlayer/Dashes/SuperradiantSawDash.cs b/CalPlayer/Dashes/SuperradiantSawDash.cs new file mode 100644 index 0000000000..a434d8d652 --- /dev/null +++ b/CalPlayer/Dashes/SuperradiantSawDash.cs @@ -0,0 +1,43 @@ +using CalamityMod.Enums; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; + +namespace CalamityMod.CalPlayer.Dashes +{ + public class SuperradiantSawDash : PlayerDashEffect + { + public static new string ID => "Superradiant Slaughterer"; + public override DashCollisionType CollisionType => DashCollisionType.NoCollision; + + public override bool IsOmnidirectional => true; + + public override float CalculateDashSpeed(Player player) => 36f; + + public override void MidDashEffects(Player player, ref float dashSpeed, ref float dashSpeedDecelerationFactor, ref float runSpeedDecelerationFactor) + { + Dust trail = Dust.NewDustPerfect(player.Center + Main.rand.NextVector2Unit() * 12f, DustID.RainbowTorch, -player.velocity * 0.2f, 150, Color.Lime, 1.2f); + trail.noGravity = true; + + Vector2 sparkVel = player.velocity.SafeNormalize(Vector2.UnitY) * Main.rand.NextFloat(-3f, -6f); + Color sparkColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.25f); + float scale = Main.rand.NextFloat(1.2f, 2f); // Bloom effect is double the spark's size + Particle spark = new CritSpark(player.Center + Main.rand.NextVector2Unit() * 12f, sparkVel, Color.White, sparkColor, scale, 24, 0.5f, scale * 2f); + GeneralParticleHandler.SpawnParticle(spark); + + // Fall way, way, faster than usual. + player.maxFallSpeed = 50f; + + // Dash at a much, much faster speed than the default value. + dashSpeed = 24f; + runSpeedDecelerationFactor = 0.8f; + + // Cooldown for dash. + player.Calamity().SpeedBlasterDashStarted = false; + player.Calamity().sBlasterDashActivated = false; + } + } +} diff --git a/CalPlayer/PlayerEnvironmentEffects.cs b/CalPlayer/PlayerEnvironmentEffects.cs new file mode 100644 index 0000000000..e440513db4 --- /dev/null +++ b/CalPlayer/PlayerEnvironmentEffects.cs @@ -0,0 +1,37 @@ +using CalamityMod.Projectiles.Environment; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ModLoader; + +namespace CalamityMod.CalPlayer +{ + public partial class CalamityPlayer : ModPlayer + { + public void DoEnvironmentalEffects() + { + CreateLilyglowInFloralParadise(); + } + + public void CreateLilyglowInFloralParadise() + { + // Don't do anything if the player is not in the floral paradise of if this code is called by anyone other than the player. + if (!ZoneFloralParadise || Main.myPlayer != Player.whoAmI) + return; + + if (!Main.rand.NextBool(12)) + return; + + for (int tries = 0; tries < 50; tries++) + { + Vector2 potentialSpawnPosition = Player.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(200f, 800f); + if (Collision.SolidCollision(potentialSpawnPosition, 1, 1)) + continue; + + Vector2 spawnVelocity = -Vector2.UnitY.RotatedByRandom(0.82f) * Main.rand.NextFloat(0.5f, 1.35f); + Projectile.NewProjectile(new EntitySource_WorldEvent(), potentialSpawnPosition, spawnVelocity, ModContent.ProjectileType(), 0, 0f, Player.whoAmI); + break; + } + } + } +} diff --git a/CalamityConfig.cs b/CalamityConfig.cs index eedd4de7ed..2a46a809b2 100644 --- a/CalamityConfig.cs +++ b/CalamityConfig.cs @@ -175,6 +175,27 @@ namespace CalamityMod public float FlightBarPosY { get; set; } #endregion + #region Music Events + [Header("MusicEvents")] + + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + public bool Interlude1 { get; set; } + + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + public bool Interlude2 { get; set; } + + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + public bool Interlude3 { get; set; } + + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + public bool DevourerofGodsEulogy { get; set; } + + #endregion + #region General Gameplay Changes [Header("Gameplay")] diff --git a/CalamityLists.cs b/CalamityLists.cs index 0e29515d35..64a954945e 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -842,8 +842,9 @@ namespace CalamityMod ProjectileType(), ProjectileType(), ProjectileType(), - ProjectileType(), + ProjectileType(), ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), @@ -901,9 +902,9 @@ namespace CalamityMod enemyImmunityList = new List() { NPCID.KingSlime, - NPCType(), - NPCType(), - NPCType(), + NPCType(), + NPCType(), + NPCType(), NPCID.EaterofWorldsHead, NPCID.EaterofWorldsBody, NPCID.EaterofWorldsTail, @@ -1943,6 +1944,7 @@ namespace CalamityMod ProjectileType(), ProjectileType(), ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), @@ -2428,9 +2430,9 @@ namespace CalamityMod { NPCID.UmbrellaSlime, 5400 }, { NPCID.RainbowSlime, 30000 }, { NPCID.Pinky, 15000 }, - { NPCType(), 21000 }, - { NPCType(), 18000 }, - { NPCType(), 24000 }, + { NPCType(), 21000 }, + { NPCType(), 18000 }, + { NPCType(), 24000 }, { NPCID.EyeofCthulhu, 450000 }, // 30 seconds { NPCID.ServantofCthulhu, 6000 }, diff --git a/CalamityMod.cs b/CalamityMod.cs index 62b15634c1..962bf1d33b 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -100,7 +100,7 @@ namespace CalamityMod // Astral Snow Sky/BG public static Texture2D AstralSnowSurfaceMiddle; - // Sulpher Sea Sky/BG + // Sulphur Sea Sky/BG public static Texture2D SulphurSeaSky; public static Texture2D SulphurSeaSkyFront; public static Texture2D SulphurSeaSurface; @@ -132,8 +132,10 @@ namespace CalamityMod internal static CalamityMod Instance; // TODO -- Mod references should be contained in a ModSystem (example name "ModLoadedChecker") - internal Mod musicMod = null; // This is Calamity's official music mod, CalamityModMusic - internal bool MusicAvailable => !(musicMod is null); + + // This is Calamity's official music mod, CalamityModMusic. It is now a hard dependency. + internal Mod musicMod = null; + internal bool MusicAvailable => musicMod is not null; // Please keep this in alphabetical order so it's easy to read internal Mod ancientsAwakened = null; @@ -246,29 +248,6 @@ namespace CalamityMod BalancingChangesManager.Load(); BaseIdleHoldoutProjectile.LoadAll(); PlayerDashManager.Load(); - - /* - //keep this disabled for now, hell bg system isnt used and there is a better way to load it - //hell background loading - HellBGManager.Load(); - - //load stuff for hell background - loadCache = new List(); - - foreach (Type type in Code.GetTypes()) - { - if (!type.IsAbstract && type.GetInterfaces().Contains(typeof(HellBGLoad))) - { - var instance = Activator.CreateInstance(type); - loadCache.Add(instance as HellBGLoad); - } - } - - for (int k = 0; k < loadCache.Count; k++) - { - loadCache[k].Load(); - } - */ } private void LoadClient() @@ -483,21 +462,6 @@ namespace CalamityMod carpetOriginal = null; - /* - //unload hell background stuff - HellBGManager.Unload(); - - if (loadCache != null) - { - foreach (var loadable in loadCache) - { - loadable.Unload(); - } - } - - loadCache = null; - */ - Instance = null; base.Unload(); } diff --git a/CalamityNetcode.cs b/CalamityNetcode.cs index a75cbdfe5c..c498f8c37c 100644 --- a/CalamityNetcode.cs +++ b/CalamityNetcode.cs @@ -6,6 +6,7 @@ using CalamityMod.NPCs; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.Providence; using CalamityMod.NPCs.TownNPCs; +using CalamityMod.Systems; using CalamityMod.TileEntities; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -300,6 +301,17 @@ namespace CalamityMod SyncCalamityWorldDifficulties(sender); break; + // + // Music event syncs + // + case CalamityModMessageType.MusicEventSyncRequest: + MusicEventSystem.FulfillSyncRequest(whoAmI); + break; + + case CalamityModMessageType.MusicEventSyncResponse: + MusicEventSystem.ReceiveSyncResponse(reader); + break; + // // Default case: with no idea how long the packet is, we can't safely read data. // Throw an exception now instead of allowing the network stream to corrupt. @@ -421,6 +433,10 @@ namespace CalamityMod MousePositionSync, // World state sync - SyncDifficulties + SyncDifficulties, + + // Music events + MusicEventSyncRequest, + MusicEventSyncResponse } } diff --git a/Cooldowns/SuperradiantSawBoost.cs b/Cooldowns/SuperradiantSawBoost.cs new file mode 100644 index 0000000000..17371e2aa1 --- /dev/null +++ b/Cooldowns/SuperradiantSawBoost.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.Localization; + +namespace CalamityMod.Cooldowns +{ + public class SuperradiantSawBoost : CooldownHandler + { + public static new string ID => "SuperradiantSawBoost"; + public override bool ShouldDisplay => true; + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override string Texture => "CalamityMod/Cooldowns/SuperradiantSawBoost"; + public override Color OutlineColor => new Color(207, 207, 207); + public override Color CooldownStartColor => new Color(122, 240, 58); + public override Color CooldownEndColor => new Color(32, 186, 171); + } +} diff --git a/Cooldowns/SuperradiantSawBoost.png b/Cooldowns/SuperradiantSawBoost.png new file mode 100644 index 0000000000..1cacbc5c4a Binary files /dev/null and b/Cooldowns/SuperradiantSawBoost.png differ diff --git a/Cooldowns/SuperradiantSawBoostOutline.png b/Cooldowns/SuperradiantSawBoostOutline.png new file mode 100644 index 0000000000..245f680cb5 Binary files /dev/null and b/Cooldowns/SuperradiantSawBoostOutline.png differ diff --git a/Cooldowns/SuperradiantSawBoostOverlay.png b/Cooldowns/SuperradiantSawBoostOverlay.png new file mode 100644 index 0000000000..da21d02b34 Binary files /dev/null and b/Cooldowns/SuperradiantSawBoostOverlay.png differ diff --git a/DamageClasses/MeleeRangedHybridDamageClass.cs b/DamageClasses/MeleeRangedHybridDamageClass.cs new file mode 100644 index 0000000000..1dc965aade --- /dev/null +++ b/DamageClasses/MeleeRangedHybridDamageClass.cs @@ -0,0 +1,27 @@ +using Terraria.ModLoader; + +namespace CalamityMod +{ + public class MeleeRangedHybridDamageClass : DamageClass + { + internal static MeleeRangedHybridDamageClass Instance; + + internal static readonly StatInheritanceData FiftyPercentBoost = new(0.5f, 0.5f, 0.5f, 0.5f, 0.5f); + + public override void Load() => Instance = this; + public override void Unload() => Instance = null; + + public override StatInheritanceData GetModifierInheritance(DamageClass damageClass) + { + if (damageClass == Melee || damageClass == Ranged) + return FiftyPercentBoost; + if (damageClass == Generic) + return StatInheritanceData.Full; + + return StatInheritanceData.None; + } + + // Inherits from both melee and ranged + public override bool GetEffectInheritance(DamageClass damageClass) => damageClass == Melee || damageClass == Ranged; + } +} diff --git a/DataStructures/NPCStats.cs b/DataStructures/NPCStats.cs index 4c0a22518d..0aec9726b2 100644 --- a/DataStructures/NPCStats.cs +++ b/DataStructures/NPCStats.cs @@ -295,7 +295,7 @@ namespace CalamityMod EnemyStats.ContactDamageValues = new SortedDictionary { { NPCID.KingSlime, new int[] { 40, 64, 80, 96, 144 } }, - { ModContent.NPCType(), new int[] { 30, 44, 60, 76, 114 } }, + { ModContent.NPCType(), new int[] { 30, 44, 60, 76, 114 } }, { ModContent.NPCType(), new int[] { 45, 66, 88, 110, 165 } }, { ModContent.NPCType(), new int[] { 24, 32, 40, 48, 72 } }, @@ -561,7 +561,7 @@ namespace CalamityMod EnemyStats.ProjectileDamageValues = new SortedDictionary, int[]> { - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 36, 44, 52, 84 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 36, 44, 52, 84 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 36, 44, 52, 84 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 36, 44, 52, 84 } }, @@ -656,7 +656,7 @@ namespace CalamityMod { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 144, 216 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 200, 240, 280, 420 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 200, 240, 280, 420 } }, // Split shots: 72, 120, 144, 168, 252 { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 144, 216 } }, diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index c98734482d..1000912ace 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -126,6 +126,12 @@ namespace CalamityMod.Effects // Used by Devourer of Gods. Renders the portal that he escapes through at the end of phase 1. internal static Effect DoGPortalShader; + // Used to render all-encompassing fog in the Floral Paradise biome. + internal static Effect FogShader; + + // Used to render background water features in the Floral Paradise biome. + internal static Effect WaterfallShader; + // Metaballs. See the MetaballManager class for comments on how this system works. // These shaders are leveraged to render the results of the metaball simulation to the screen. // The "Base" shader draws the particles themselves. @@ -351,6 +357,12 @@ namespace CalamityMod.Effects DoGPortalShader = LoadShader("ScreenShaders/DoGPortalShader"); RegisterMiscShader(DoGPortalShader, "ScreenPass", "DoGPortal"); + FogShader = LoadShader("ScreenShaders/Fog"); + RegisterMiscShader(FogShader, "DyePass", "Fog"); + + WaterfallShader = LoadShader("WaterfallShader"); + RegisterMiscShader(WaterfallShader, "TrailPass", "Waterfall"); + // These two shaders are often (but not always) used together. MetaballEdgeShader = LoadShader("Metaballs/MetaballEdgeShader"); RegisterMiscShader(MetaballEdgeShader, "ParticlePass", "MetaballEdge"); diff --git a/Effects/ScreenShaders/Fog.fx b/Effects/ScreenShaders/Fog.fx new file mode 100644 index 0000000000..28001e61ab --- /dev/null +++ b/Effects/ScreenShaders/Fog.fx @@ -0,0 +1,61 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +float fogMovementSpeed; +float4 uShaderSpecificData; + +float Random(float2 coords) +{ + return frac(sin(dot(coords, float2(49, 81)) * 100) * 100); +} +float PerlinNoise(float2 coords) +{ + float2 integerPart = floor(coords); + float2 fractionalPart = frac(coords); + float a = Random(integerPart); + float b = Random(integerPart + float2(1, 0)); + float c = Random(integerPart + float2(0, 1)); + float d = Random(integerPart + float2(1, 1)); + float2 cubic = fractionalPart * fractionalPart * (3 - fractionalPart * 2); + return lerp(a, b, cubic.x) + (c - a) * cubic.y * (1 - cubic.x) + (d - b) * cubic.x * cubic.y; +} + +float ScaledNoise(float2 coords) +{ + float result = 0; + float2 coordsCopy = coords; + float scale = 0.5; + for (int i = 0; i < 4; i++) + { + result += PerlinNoise(coordsCopy) * scale; + coordsCopy *= 2; + scale *= 0.5; + } + return result; +} + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float motion = ScaledNoise(coords * uSaturation * 12 + float2(uTime * fogMovementSpeed * -0.23, uTime * fogMovementSpeed * 0.64)); + float2 motion2D = motion; + float3 noise = ScaledNoise(coords * uSaturation * 15 + motion2D + float2(0, uTime * 0.78)); + return lerp(float4(noise, 1), float4(uColor, 1), 0.67) * uOpacity * 0.2; +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_3_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/ScreenShaders/Fog.xnb b/Effects/ScreenShaders/Fog.xnb new file mode 100644 index 0000000000..22323159b2 Binary files /dev/null and b/Effects/ScreenShaders/Fog.xnb differ diff --git a/Effects/WaterfallShader.fx b/Effects/WaterfallShader.fx new file mode 100644 index 0000000000..f7fab820fe --- /dev/null +++ b/Effects/WaterfallShader.fx @@ -0,0 +1,67 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +sampler uImage2 : register(s2); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +matrix uWorldViewProjection; +float4 uShaderSpecificData; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput)0; + float4 pos = mul(input.Position, uWorldViewProjection); + output.Position = pos; + + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + + return output; +} + +// The X coordinate is the trail completion, the Y coordinate is the same as any other. +// This is simply how the primitive TextCoord is layed out in the C# code. +// Inputted images go into uImage1 sampler, in case you have a noise map or something similar. +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float4 color = input.Color; + float2 coords = input.TextureCoordinates; + float2 pixellatedCoords = round(coords * 20) / 20; + float4 noiseColor = tex2D(uImage1, float2(pixellatedCoords.x - uTime * 1.3, pixellatedCoords.y) * float2(0.5, 1)); + float4 noiseColor2 = tex2D(uImage1, float2(pixellatedCoords.x - uTime * 1.1, pixellatedCoords.y + uTime * 0.44) * float2(0.5, 1)); + float4 baseColor = lerp(noiseColor, noiseColor2, sin(uTime * 5.1 + coords.x * 3.4) * 0.5 + 0.5); + baseColor = pow(baseColor, 2); + return lerp(color * 0.4, 1, baseColor.r) * uOpacity; +} + +technique Technique1 +{ + pass TrailPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/WaterfallShader.xnb b/Effects/WaterfallShader.xnb new file mode 100644 index 0000000000..718ba268ef Binary files /dev/null and b/Effects/WaterfallShader.xnb differ diff --git a/Enums/NPCTargetType.cs b/Enums/NPCTargetType.cs new file mode 100644 index 0000000000..6fc9b0ac5c --- /dev/null +++ b/Enums/NPCTargetType.cs @@ -0,0 +1,9 @@ +namespace CalamityMod.Enums +{ + public enum NPCTargetType + { + Anyone = 0, + PreferSame = 1, + ForceSwitch = 2, + } +} diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index 6da1815a4d..76b1624211 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -150,14 +150,12 @@ namespace CalamityMod.Events DownedBossSystem.startedBossRushAtLeastOnce = true; }, permittedNPCs: new int[] { NPCID.BlueSlime, NPCID.YellowSlime, NPCID.PurpleSlime, NPCID.RedSlime, NPCID.GreenSlime, NPCID.RedSlime, - NPCID.IceSlime, NPCID.UmbrellaSlime, NPCID.Pinky, NPCID.SlimeSpiked, NPCID.RainbowSlime, ModContent.NPCType(), - ModContent.NPCType(), ModContent.NPCType() }), + NPCID.IceSlime, NPCID.UmbrellaSlime, NPCID.Pinky, NPCID.SlimeSpiked, NPCID.RainbowSlime, ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType() }), new Boss(ModContent.NPCType(), spawnContext: type => { NPC.SpawnOnPlayer(ClosestPlayerToWorldCenter, ModContent.NPCType()); - NPC.SpawnOnPlayer(ClosestPlayerToWorldCenter, ModContent.NPCType()); - NPC.SpawnOnPlayer(ClosestPlayerToWorldCenter, ModContent.NPCType()); }, permittedNPCs: new int[] { ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }), diff --git a/ExtraTextures/WorleyNoise.png b/ExtraTextures/WorleyNoise.png new file mode 100644 index 0000000000..f614e21acc Binary files /dev/null and b/ExtraTextures/WorleyNoise.png differ diff --git a/Gores/BuzzkillSaw1.png b/Gores/BuzzkillSaw1.png new file mode 100644 index 0000000000..c79c2667d9 Binary files /dev/null and b/Gores/BuzzkillSaw1.png differ diff --git a/Gores/BuzzkillSaw2.png b/Gores/BuzzkillSaw2.png new file mode 100644 index 0000000000..aa8e09a0db Binary files /dev/null and b/Gores/BuzzkillSaw2.png differ diff --git a/Gores/BuzzkillSaw3.png b/Gores/BuzzkillSaw3.png new file mode 100644 index 0000000000..aa75e67d97 Binary files /dev/null and b/Gores/BuzzkillSaw3.png differ diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index c2ea95f2b1..d448d79d77 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -3,6 +3,7 @@ using System.Reflection; using CalamityMod.Graphics.Renderers.CalamityRenderers; using CalamityMod.Tiles.DraedonStructures; using CalamityMod.Tiles.FurnitureExo; +using CalamityMod.Walls; using Terraria; using Terraria.DataStructures; using Terraria.GameContent; @@ -39,6 +40,7 @@ namespace CalamityMod.ILEditing // Graphics IL_Main.DoDraw += AdditiveDrawing; + IL_Main.DoDraw += DrawFloralParadiseFog; On_Main.DrawGore += DrawForegroundStuff; On_Main.DrawCursor += UseCoolFireCursorEffect; On_Main.SortDrawCacheWorms += DrawFusableParticles; @@ -171,6 +173,14 @@ namespace CalamityMod.ILEditing //HeldOnlyItem detours Player.dropItemCheck, ItemSlot.Draw (Sb, itemarray, int, int, vector2, color) and ItemSlot.LeftClick_ItemArray to make its stuff work } + /// + /// Loads things which need to be instantiated later in the load order. + /// + public override void AddRecipes() + { + WallVisibleThroughWater.InitializeWaterMapEntryLookups(); + } + /// /// Unloads all IL Editing changes in the mod. /// diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index fb4fe1510e..d760dabb3a 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -22,6 +22,7 @@ using CalamityMod.Projectiles; using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems; using CalamityMod.Tiles.Abyss; +using CalamityMod.Waterfalls; using CalamityMod.Waters; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -724,6 +725,42 @@ namespace CalamityMod.ILEditing } #endregion + #region Fog Effect in Floral Paradise + private static void DrawFloralParadiseFog(ILContext il) + { + ILCursor cursor = new ILCursor(il); + + cursor.GotoNext(MoveType.Before, i => i.MatchCallOrCallvirt
("DrawInfernoRings")); + cursor.EmitDelegate(() => + { + if (Main.netMode != NetmodeID.Server && BiomeTileCounterSystem.FloralParadiseTiles > 0) + DrawFog(Utils.GetLerpValue(0f, 250f, BiomeTileCounterSystem.FloralParadiseTiles, true)); + }); + } + + private static void DrawFog(float intensity) + { + Main.spriteBatch.EnterShaderRegion(); + WaterfallRenderer.DrawWaterfalls(); + + Texture2D fogTexture = ModContent.Request("Terraria/Images/Misc/Perlin").Value; + Vector2 scale = new Vector2(Main.screenWidth, Main.screenHeight) / fogTexture.Size(); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + GameShaders.Misc["CalamityMod:Fog"].UseOpacity(intensity * 0.74f); + GameShaders.Misc["CalamityMod:Fog"].UseColor(Color.Lerp(Color.Lime, Color.Black, 0.85f)); + GameShaders.Misc["CalamityMod:Fog"].UseSaturation(1.67f); + GameShaders.Misc["CalamityMod:Fog"].Shader.Parameters["fogMovementSpeed"].SetValue(1.75f); + GameShaders.Misc["CalamityMod:Fog"].Apply(); + + Main.spriteBatch.Draw(fogTexture, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(); + } + #endregion Fog Effect in Floral Paradise + #region Custom Draw Layers private static void AdditiveDrawing(ILContext il) { @@ -864,7 +901,11 @@ namespace CalamityMod.ILEditing cursor.Emit(OpCodes.Ldloc, 4); // Caching these values can save a LOT of overhead at runtime. - ModWaterStyle sunkenSeaWater = ModContent.GetInstance(); + ModWaterStyle basaltWater = ModContent.GetInstance(); + ModWaterStyle burrowsWater = ModContent.GetInstance(); + ModWaterStyle polypWater = ModContent.GetInstance(); + ModWaterStyle reefsWater = ModContent.GetInstance(); + ModWaterStyle shoresWater = ModContent.GetInstance(); ModWaterStyle sulphuricWater = ModContent.GetInstance(); ModWaterStyle sulphuricDepthsWater = ModContent.GetInstance(); ModWaterStyle upperAbyssWater = ModContent.GetInstance(); @@ -878,8 +919,11 @@ namespace CalamityMod.ILEditing { initialColor = SelectLavaQuadColor(initialTexture, ref initialColor, liquidType == 1); } - - if (liquidType == sunkenSeaWater.Slot || + if (liquidType == burrowsWater.Slot || + liquidType == basaltWater.Slot || + liquidType == polypWater.Slot || + liquidType == shoresWater.Slot || + liquidType == reefsWater.Slot || liquidType == sulphuricWater.Slot || liquidType == sulphuricDepthsWater.Slot || liquidType == upperAbyssWater.Slot || @@ -1000,13 +1044,13 @@ namespace CalamityMod.ILEditing return; Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); - if (tile.LiquidAmount <= 0 || tile.HasTile || (Main.waterStyle != SulphuricWater.Type && - Main.waterStyle != SulphuricDepthsWater.Type && Main.waterStyle != SunkenSeaWater.Type)) + if (tile.LiquidAmount <= 0 || tile.HasTile || tile.Get().LiquidType != LiquidID.Water || (Main.waterStyle != SulphuricWater.Type && + Main.waterStyle != SulphuricDepthsWater.Type && Main.waterStyle != SunkenSeaBurrowsWater.Type && Main.waterStyle != SunkenSeaPolypWater.Type && + Main.waterStyle != SunkenSeaReefsWater.Type && Main.waterStyle != SunkenSeaShoresWater.Type && Main.waterStyle != BasaltGullyWater.Type)) return; Tile above = CalamityUtils.ParanoidTileRetrieval(x, y - 1); - if (!Main.gamePaused && !above.HasTile && above.LiquidAmount <= 0 && Main.rand.NextBool(9) && - Main.waterStyle == SulphuricWater.Type) + if (!Main.gamePaused && !above.HasTile && above.LiquidAmount <= 0 && Main.rand.NextBool(9) && Main.waterStyle == SulphuricWater.Type) { MediumMistParticle acidFoam = new(new(x * 16f + Main.rand.NextFloat(16f), y * 16f + 8f), -Vector2.UnitY.RotatedByRandom(0.67f) * Main.rand.NextFloat(1f, 2.4f), Color.LightSeaGreen, Color.White, 0.16f, 128f, 0.02f); GeneralParticleHandler.SpawnParticle(acidFoam); @@ -1073,8 +1117,34 @@ namespace CalamityMod.ILEditing if (Main.waterStyle == SulphuricDepthsWater.Type) outputColor = Vector3.Lerp(outputColor, Color.MediumSeaGreen.ToVector3(), 0.18f); - if (Main.waterStyle == SunkenSeaWater.Type) + if (Main.waterStyle == SunkenSeaBurrowsWater.Type || Main.waterStyle == SunkenSeaPolypWater.Type || Main.waterStyle == SunkenSeaReefsWater.Type || + Main.waterStyle == SunkenSeaShoresWater.Type || Main.waterStyle == BasaltGullyWater.Type) { + //default to white + Color waterGlowColor = Color.White; + + //set the glow colors for each sunken sea biome water style + if (Main.waterStyle == SunkenSeaShoresWater.Type) + { + waterGlowColor = new Color(233, 170, 184); + } + if (Main.waterStyle == SunkenSeaPolypWater.Type) + { + waterGlowColor = new Color(213, 185, 178); + } + if (Main.waterStyle == SunkenSeaReefsWater.Type) + { + waterGlowColor = new Color(140, 222, 239); + } + if (Main.waterStyle == SunkenSeaBurrowsWater.Type) + { + waterGlowColor = new Color(76, 211, 231); + } + if (Main.waterStyle == BasaltGullyWater.Type) + { + waterGlowColor = new Color(144, 174, 200); + } + float brightness = MathHelper.Clamp(0.07f, 0f, 0.07f); float waveScale1 = Main.GameUpdateCount * 0.028f; float waveScale2 = Main.GameUpdateCount * 0.1f; @@ -1094,7 +1164,7 @@ namespace CalamityMod.ILEditing float wave5angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave5)); float wave6angle = 0.55f + 0.45f * (float)Math.Sin(MathHelper.ToRadians(wave6)); float bigwaveangle = 0.55f + 0.80f * (float)Math.Sin(MathHelper.ToRadians(bigwave)); - outputColor = Vector3.Lerp(outputColor, Color.DeepSkyBlue.ToVector3(), 0.07f + wave1angle + wave2angle + wave3angle + wave4angle + wave5angle + wave6angle + bigwaveangle); + outputColor = Vector3.Lerp(outputColor, Color.DarkSlateGray.ToVector3(), 0.07f + wave1angle + wave2angle + wave3angle + wave4angle + wave5angle + wave6angle + bigwaveangle); outputColor *= brightness; } } diff --git a/ILEditing/VanillaStupidityFixingILChanges.cs b/ILEditing/VanillaStupidityFixingILChanges.cs index 9a430ec383..c4bb8be5ee 100644 --- a/ILEditing/VanillaStupidityFixingILChanges.cs +++ b/ILEditing/VanillaStupidityFixingILChanges.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Reflection; -using CalamityMod.Balancing; using CalamityMod.Items.Fishing; using CalamityMod.Items.Materials; using CalamityMod.Items.TreasureBags.MiscGrabBags; @@ -13,14 +12,20 @@ using Mono.Cecil.Cil; using MonoMod.Cil; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent.Drawing; using Terraria.ID; -using Terraria.Map; using Terraria.ModLoader; namespace CalamityMod.ILEditing { public partial class ILChanges { + public static WindGrid Windgrid + { + get; + internal set; + } + #region Decrease Sandstorm Wind Speed Requirement private static void DecreaseSandstormWindSpeedRequirement(ILContext il) { @@ -957,5 +962,17 @@ namespace CalamityMod.ILEditing c.Emit(OpCodes.Stloc, relativeMapTypeIndex); } #endregion + + // 02JUN2024: Ozzatron: The below code is being kept in its initial state for historic value. + #region Store The Stupid Fucking Private Wind Map In Public Property + private static void StoreWindGrid(On_TileDrawing.orig_Update orig, TileDrawing self) + { + orig(self); + + // FUCK YOU FUCK YOU FUCK YOU FUCK YOU FUCK YOU FUCK YOU FUCK YOU FUCK YOU FUCK YOU FUCK + if (Windgrid is null) + Windgrid = typeof(TileDrawing).GetField("_windGrid", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self) as WindGrid; + } + #endregion Store The Stupid Fucking Private Wind Map In Public Property } } diff --git a/Items/Accessories/AlchemicalFlask.cs b/Items/Accessories/AlchemicalFlask.cs index 909aa4106f..aea37c1bf8 100644 --- a/Items/Accessories/AlchemicalFlask.cs +++ b/Items/Accessories/AlchemicalFlask.cs @@ -23,15 +23,15 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.alchFlask = true; - player.buffImmune[ModContent.BuffType()] = true; } public override void AddRecipes() { CreateRecipe(). AddIngredient(ItemID.BottledWater). - AddIngredient(ItemID.BeeWax, 5). - AddIngredient(10). + AddIngredient(ItemID.HoneyComb). + AddIngredient(ItemID.BeeWax, 8). + AddIngredient(15). AddTile(TileID.MythrilAnvil). Register(); } diff --git a/Items/Accessories/AmbrosialAmpoule.cs b/Items/Accessories/AmbrosialAmpoule.cs index ae0904ba07..6d42653934 100644 --- a/Items/Accessories/AmbrosialAmpoule.cs +++ b/Items/Accessories/AmbrosialAmpoule.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - player.statLifeMax2 += 70; + player.statLifeMax2 += 50; // bool left in for abyss light purposes and life regen effects modPlayer.aAmpoule = true; diff --git a/Items/Accessories/AsgardianAegis.cs b/Items/Accessories/AsgardianAegis.cs index 4bffcce0e7..cbb8941b60 100644 --- a/Items/Accessories/AsgardianAegis.cs +++ b/Items/Accessories/AsgardianAegis.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Accessories Item.width = 60; Item.height = 54; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 20; + Item.defense = 12; Item.accessory = true; Item.rare = ModContent.RarityType(); } diff --git a/Items/Accessories/AsgardsValor.cs b/Items/Accessories/AsgardsValor.cs index e2aacf1b97..a4e4da6e8c 100644 --- a/Items/Accessories/AsgardsValor.cs +++ b/Items/Accessories/AsgardsValor.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Accessories Item.height = 44; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; - Item.defense = 12; // we buff Ankh Shield to 12 + Item.defense = 8; // we buff Ankh Shield to 8 Item.accessory = true; } diff --git a/Items/Accessories/BlazingCore.cs b/Items/Accessories/BlazingCore.cs index b481df9a76..95911b09b7 100644 --- a/Items/Accessories/BlazingCore.cs +++ b/Items/Accessories/BlazingCore.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Items.Accessories for (int i = 0; i < chains; i++) { int projectileType = ModContent.ProjectileType(); - int dmgAmt = 90; + int dmgAmt = 250; if (!empowered && Main.rand.NextBool(5)) { projectileType = ModContent.ProjectileType(); diff --git a/Items/Accessories/ElysianAegis.cs b/Items/Accessories/ElysianAegis.cs index a7231b9b11..3c1b4d6f67 100644 --- a/Items/Accessories/ElysianAegis.cs +++ b/Items/Accessories/ElysianAegis.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Accessories Item.height = 42; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); - Item.defense = 16; + Item.defense = 10; Item.accessory = true; } diff --git a/Items/Accessories/FlameLickedShell.cs b/Items/Accessories/FlameLickedShell.cs index cbf6b96a33..733218f7e3 100644 --- a/Items/Accessories/FlameLickedShell.cs +++ b/Items/Accessories/FlameLickedShell.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Accessories int totalProjectiles = 6; float offsetAngle = (float)Math.PI * radialOffset; int type = ModContent.ProjectileType(); - int damage = (int)player.GetBestClassDamage().ApplyTo(60); + int damage = (int)player.GetBestClassDamage().ApplyTo(200); damage = player.ApplyArmorAccDamageBonusesTo(damage); if (player.whoAmI == Main.myPlayer) @@ -72,7 +72,7 @@ namespace CalamityMod.Items.Accessories totalProjectiles = 12; float radians2 = MathHelper.TwoPi / totalProjectiles; type = ModContent.ProjectileType(); - damage = (int)player.GetBestClassDamage().ApplyTo(20); + damage = (int)player.GetBestClassDamage().ApplyTo(70); damage = player.ApplyArmorAccDamageBonusesTo(damage); double angleA = radians2 * 0.5; diff --git a/Items/Accessories/OldDukeScales.cs b/Items/Accessories/OldDukeScales.cs index 43a9746187..94816ec2a7 100644 --- a/Items/Accessories/OldDukeScales.cs +++ b/Items/Accessories/OldDukeScales.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Accessories { public new string LocalizationCategory => "Items.Accessories"; - public static int RecoverTime = 120; + public static int RecoverTime = 90; public static int DashFatigueIncrease = 240; public static int MaxFatigue = 1200; // This is also the time that it takes the player to recover from the loss of all stamina. @@ -128,8 +128,9 @@ namespace CalamityMod.Items.Accessories RecoverTimer--; // If the player has recovered, start decreasing the fatigue. + bool PressingMoveKeys = Player.controlLeft || Player.controlRight || Player.controlDown || Player.controlJump; if (Fatigue > 0 && RecoverTimer <= 0) - Fatigue -= Player.StandingStill() ? 2 : 1; + Fatigue -= PressingMoveKeys ? 3 : 5; // The fatigue cannot go higher than the max. if (Fatigue >= OldDukeScales.MaxFatigue) diff --git a/Items/Accessories/OrnateShield.cs b/Items/Accessories/OrnateShield.cs index 4591e8c680..2b12a2aa69 100644 --- a/Items/Accessories/OrnateShield.cs +++ b/Items/Accessories/OrnateShield.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Accessories Item.height = 32; Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; - Item.defense = 8; + Item.defense = 4; // This has a ram dash, it should give a bit less defense due to how good it is Item.accessory = true; } diff --git a/Items/Accessories/PlagueHive.cs b/Items/Accessories/PlagueHive.cs deleted file mode 100644 index c0bc650ec9..0000000000 --- a/Items/Accessories/PlagueHive.cs +++ /dev/null @@ -1,38 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.CalPlayer; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Accessories -{ - public class PlagueHive : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Accessories"; - public override void SetDefaults() - { - Item.width = 42; - Item.height = 48; - Item.value = CalamityGlobalItem.RarityRedBuyPrice; - Item.rare = ItemRarityID.Red; - Item.accessory = true; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(ItemID.HoneyComb). - AddTile(TileID.LunarCraftingStation). - Register(); - } - - public override void UpdateAccessory(Player player, bool hideVisual) - { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.uberBees = true; - modPlayer.alchFlask = true; - player.buffImmune[ModContent.BuffType()] = true; - } - } -} diff --git a/Items/Accessories/PlagueHive.png b/Items/Accessories/PlagueHive.png deleted file mode 100644 index 1cd4a7baaa..0000000000 Binary files a/Items/Accessories/PlagueHive.png and /dev/null differ diff --git a/Items/Accessories/Radiance.cs b/Items/Accessories/Radiance.cs index b8f71335c4..68b3b5836c 100644 --- a/Items/Accessories/Radiance.cs +++ b/Items/Accessories/Radiance.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - player.statLifeMax2 += 100; + player.statLifeMax2 += 70; // Abyss light, debuff near-immunity, life regen effects, and massively enhances debuff halving modPlayer.purity = true; diff --git a/Items/Accessories/RampartofDeities.cs b/Items/Accessories/RampartofDeities.cs index 04b7481d08..2ac41f439d 100644 --- a/Items/Accessories/RampartofDeities.cs +++ b/Items/Accessories/RampartofDeities.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Accessories Item.width = 64; Item.height = 62; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.defense = 18; + Item.defense = 12; Item.accessory = true; Item.rare = ModContent.RarityType(); } diff --git a/Items/Accessories/Regenator.cs b/Items/Accessories/Regenator.cs index 292b762fa4..f13b41822a 100644 --- a/Items/Accessories/Regenator.cs +++ b/Items/Accessories/Regenator.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Accessories Item.height = 56; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; - Item.defense = 10; + Item.defense = 4; // This should have less defense due to the regen it provides Item.accessory = true; } diff --git a/Items/Accessories/ShieldoftheHighRuler.cs b/Items/Accessories/ShieldoftheHighRuler.cs index f717c20560..aa530beaaa 100644 --- a/Items/Accessories/ShieldoftheHighRuler.cs +++ b/Items/Accessories/ShieldoftheHighRuler.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; Item.Calamity().donorItem = true; - Item.defense = 12; + Item.defense = 6; Item.accessory = true; } diff --git a/Items/Accessories/StatMeter.cs b/Items/Accessories/StatMeter.cs index 9fc54df8eb..eb6eb0c6b2 100644 --- a/Items/Accessories/StatMeter.cs +++ b/Items/Accessories/StatMeter.cs @@ -213,7 +213,7 @@ namespace CalamityMod.Items.Accessories string stats3 = "\n" + this.GetLocalization("GenericStats").Format( player.GetCurrentDefense(false), TwoPlaces(100f * player.endurance), - player.lifeRegen, // Normally we'd divide this by 2 in Expert without Well Fed, but we disable that shit + OnePlace((float)player.lifeRegen / 2f), // Divided by 2 to show HP/s, because vanilla! Also normally we'd divide this by 2 in Expert without Well Fed, but we disable that shit Sign(moveSpeedBoost) + TwoPlaces(100f * moveSpeedBoost), TwoPlaces(20f * player.GetJumpBoost())); // Show wing stats only if over 0 flight time diff --git a/Items/Accessories/StatisBlessing.cs b/Items/Accessories/StatisBlessing.cs index 72fa58ce65..a08ba8d9a7 100644 --- a/Items/Accessories/StatisBlessing.cs +++ b/Items/Accessories/StatisBlessing.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.holyMinions = true; player.GetKnockback() += 2.5f; - player.GetDamage() += 0.1f; + player.GetDamage() += 0.12f; } public override void AddRecipes() diff --git a/Items/Accessories/StatisCurse.cs b/Items/Accessories/StatisCurse.cs index e16ebd5b2e..efe65bb8df 100644 --- a/Items/Accessories/StatisCurse.cs +++ b/Items/Accessories/StatisCurse.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.Accessories modPlayer.shadowMinions = true; modPlayer.holyMinions = true; player.GetKnockback() += 2.75f; - player.GetDamage() += 0.1f; + player.GetDamage() += 0.12f; player.buffImmune[ModContent.BuffType()] = true; } diff --git a/Items/Accessories/TheAbsorber.cs b/Items/Accessories/TheAbsorber.cs index cd3aa3500e..7a4ee85420 100644 --- a/Items/Accessories/TheAbsorber.cs +++ b/Items/Accessories/TheAbsorber.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Accessories { Item.width = 20; Item.height = 24; - Item.defense = 15; + Item.defense = 10; Item.value = CalamityGlobalItem.RarityRedBuyPrice; Item.rare = ItemRarityID.Red; Item.accessory = true; diff --git a/Items/Accessories/ToxicHeart.cs b/Items/Accessories/ToxicHeart.cs index ee4b89c267..ca3e9c0e5a 100644 --- a/Items/Accessories/ToxicHeart.cs +++ b/Items/Accessories/ToxicHeart.cs @@ -5,6 +5,7 @@ using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; +using Terraria.Audio; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -12,6 +13,7 @@ namespace CalamityMod.Items.Accessories public class ToxicHeart : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; + public float pulseCounter = 0; public override void SetDefaults() { Item.width = 28; @@ -25,44 +27,6 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.toxicHeart = true; - player.buffImmune[ModContent.BuffType()] = true; - int plagueCounter = 0; - Lighting.AddLight((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f), 0.05f, 1f, 0.1f); - int plagueDebuff = ModContent.BuffType(); - bool shouldInflictPlague = plagueCounter % 60 == 0; - - int auraDamage = (int)player.GetBestClassDamage().ApplyTo(50); - auraDamage = player.ApplyArmorAccDamageBonusesTo(auraDamage); - - int random = Main.rand.Next(10); - var source = player.GetSource_Accessory(Item); - if (player.whoAmI == Main.myPlayer) - { - if (random == 0) - { - foreach (NPC nPC in Main.ActiveNPCs) - { - if (nPC.IsAnEnemy() && !nPC.dontTakeDamage && !nPC.buffImmune[plagueDebuff] && Vector2.Distance(player.Center, nPC.Center) <= 300f) - { - if (nPC.FindBuffIndex(plagueDebuff) == -1) - { - nPC.AddBuff(plagueDebuff, 120, false); - } - if (shouldInflictPlague) - { - if (player.whoAmI == Main.myPlayer) - { - Projectile.NewProjectileDirect(source, nPC.Center, Vector2.Zero, ModContent.ProjectileType(), auraDamage, 0f, player.whoAmI, nPC.whoAmI); - } - } - } - } - } - } - plagueCounter++; - if (plagueCounter >= 180) - { - } } } } diff --git a/Items/Accessories/YharimsGift.cs b/Items/Accessories/YharimsGift.cs index 6f5cc3c2e9..0a59362b0f 100644 --- a/Items/Accessories/YharimsGift.cs +++ b/Items/Accessories/YharimsGift.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Accessories { Item.width = 20; Item.height = 22; - Item.defense = 30; + Item.defense = 15; // Why did this give 30 defense? This thing really needs a rework lol Item.accessory = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; Item.rare = ModContent.RarityType(); diff --git a/Items/Ammo/DryadsTear.cs b/Items/Ammo/DryadsTear.cs index 657029031b..24866b5488 100644 --- a/Items/Ammo/DryadsTear.cs +++ b/Items/Ammo/DryadsTear.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Ammo { Item.width = 8; Item.height = 8; - Item.damage = 8; + Item.damage = 10; Item.DamageType = DamageClass.Ranged; Item.maxStack = 9999; Item.consumable = true; diff --git a/Items/Ammo/HolyFireBullet.cs b/Items/Ammo/HolyFireBullet.cs index 9135150910..9c54ed0152 100644 --- a/Items/Ammo/HolyFireBullet.cs +++ b/Items/Ammo/HolyFireBullet.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Ammo public class HolyFireBullet : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Ammo"; - internal const float ExplosionMultiplier = 0.33f; + internal const float ExplosionMultiplier = 0.275f; public static readonly SoundStyle Explosion = new("CalamityMod/Sounds/Item/HolyFireBulletExplosion") { PitchVariance = 0.2f, Volume = 0.6f }; public override void SetStaticDefaults() { @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Ammo { Item.width = 22; Item.height = 22; - Item.damage = 22; + Item.damage = 20; Item.DamageType = DamageClass.Ranged; Item.maxStack = 9999; Item.consumable = true; diff --git a/Items/Ammo/HyperiusBullet.cs b/Items/Ammo/HyperiusBullet.cs index 39653cceb2..6812c127eb 100644 --- a/Items/Ammo/HyperiusBullet.cs +++ b/Items/Ammo/HyperiusBullet.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Ammo { public new string LocalizationCategory => "Items.Ammo"; - public static int SplitBulletBonusDamage = 10; + public static int SplitBulletBonusDamage = 16; public override void SetStaticDefaults() { diff --git a/Items/Ammo/VeriumBolt.cs b/Items/Ammo/VeriumBolt.cs index b2a1adb08a..bbc4756fe6 100644 --- a/Items/Ammo/VeriumBolt.cs +++ b/Items/Ammo/VeriumBolt.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Ammo { Item.width = 8; Item.height = 8; - Item.damage = 7; + Item.damage = 11; Item.DamageType = DamageClass.Ranged; Item.maxStack = 9999; Item.consumable = true; diff --git a/Items/Armor/Sulphurous/SulphurousBreastplate.cs b/Items/Armor/Sulphurous/SulphurousBreastplate.cs index ee6c63df21..6848c2825b 100644 --- a/Items/Armor/Sulphurous/SulphurousBreastplate.cs +++ b/Items/Armor/Sulphurous/SulphurousBreastplate.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Items.Armor.Sulphurous public override void UpdateEquip(Player player) { - player.GetDamage() += 0.08f; - player.GetCritChance() += 5; + player.GetDamage() += 0.06f; + player.GetCritChance() += 4; } public override void AddRecipes() diff --git a/Items/Armor/Sulphurous/SulphurousHelmet.cs b/Items/Armor/Sulphurous/SulphurousHelmet.cs index b2b6e7b765..f7375d88c0 100644 --- a/Items/Armor/Sulphurous/SulphurousHelmet.cs +++ b/Items/Armor/Sulphurous/SulphurousHelmet.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Armor.Sulphurous var modPlayer = player.Calamity(); modPlayer.sulphurSet = true; player.GetJumpState().Enable(); - modPlayer.rogueStealthMax += 0.7f; + modPlayer.rogueStealthMax += 0.65f; modPlayer.wearingRogueArmor = true; player.ignoreWater = true; } diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 8c6efe6774..077b34fc84 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using CalamityMod.Balancing; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; @@ -437,8 +438,8 @@ namespace CalamityMod.Items modPlayer.canFireAtaxiaRogueProjectile = false; int flareID = ModContent.ProjectileType(); - // Ataxia Rogue Flares: 6 x 50%, soft cap starts at 90 base damage - int flareDamage = CalamityUtils.DamageSoftCap(damage * 0.5, 90); + // Hydrothermic Rogue Flares: 6 x (50 + 15%), soft cap starts at 90 base damage + int flareDamage = CalamityUtils.DamageSoftCap(50 + damage * 0.15, 90); flareDamage = player.ApplyArmorAccDamageBonusesTo(flareDamage); if (player.whoAmI == Main.myPlayer) @@ -1237,6 +1238,35 @@ namespace CalamityMod.Items player.GetDamage() += 0.02f; } + // The Frog Leg line is prevented from stacking. + // Additionally, Amphibian boots are directly nerfed so they aren't the best in slot boots at all times. + // + // 21MAY2024: Ozzatron: Disabled this code. Frog Leg is allowed to stack. Amphibian Boots specific nerf is applied below. + /* + switch (item.type) + { + default: + break; + case ItemID.AmphibianBoots: + if (modPlayer.alreadyHasFrogLeg) + player.jumpSpeedBoost -= BalancingConstants.VanillaFrogLegJumpSpeedBoost; + else + player.jumpSpeedBoost += BalancingConstants.AmphibianBootsJumpSpeedBoost - BalancingConstants.VanillaFrogLegJumpSpeedBoost; + modPlayer.alreadyHasFrogLeg = true; + break; + case ItemID.FrogLeg: + case ItemID.FrogFlipper: + case ItemID.FrogGear: + case ItemID.FrogWebbing: + if (modPlayer.alreadyHasFrogLeg) + player.jumpSpeedBoost -= BalancingConstants.VanillaFrogLegJumpSpeedBoost; + modPlayer.alreadyHasFrogLeg = true; + break; + } + */ + if (item.type == ItemID.AmphibianBoots) + player.jumpSpeedBoost += BalancingConstants.AmphibianBootsJumpSpeedBoost - BalancingConstants.VanillaFrogLegJumpSpeedBoost; + // Feral Claws line melee speed adjustments and nonstacking // First removes all their melee speed so it can be given based on which you wear without stacking if (item.type == ItemID.FeralClaws) diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index d2fa8e249d..9f596ebdba 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -16,6 +16,7 @@ using CalamityMod.Items.Weapons.Summon; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; using Terraria; using Terraria.ID; using Terraria.Localization; @@ -29,7 +30,26 @@ namespace CalamityMod.Items #region Main ModifyTooltips Function public override void ModifyTooltips(Item item, List tooltips) { - // Apply rarity coloration to the item's name. + // Get the first index, last index and total count of standard vanilla tooltip lines. + // The first index and count are used to delete all vanilla tooltips when holding SHIFT, if requested. + // The last index is used to insert various extra tooltip lines in the right position. + // + // This code used to be in the HoldShiftTooltip utility, but is needed to correctly place other tooltips. + int firstTooltipIndex = -1; + int lastTooltipIndex = -1; + int standardTooltipCount = 0; + for (int i = 0; i < tooltips.Count; i++) + { + if (tooltips[i].Name.StartsWith("Tooltip")) + { + if (firstTooltipIndex == -1) + firstTooltipIndex = i; + lastTooltipIndex = i; + standardTooltipCount++; + } + } + + // Apply custom rarity coloration to the item's name if applicable. TooltipLine nameLine = tooltips.FirstOrDefault(x => x.Name == "ItemName" && x.Mod == "Terraria"); if (nameLine != null) ApplyRarityColor(item, nameLine); @@ -40,20 +60,21 @@ namespace CalamityMod.Items // Adds "Does extra damage to enemies shot at point-blank range" to weapons capable of it. if (canFirePointBlankShots) { - TooltipLine line = new TooltipLine(Mod, "PointBlankShot", "Does extra damage to enemies shot at point-blank range"); - tooltips.Add(line); + var lineText = CalamityUtils.GetText("Misc.PointBlank"); + TooltipLine line = new TooltipLine(Mod, "CalamityMod:PointBlankTooltip", lineText.Value); + tooltips.Insert(++lastTooltipIndex, line); } - // If an item has an enchantment, show its prefix in the first tooltip line and append its description to the - // tooltip list. + // If an item has an enchantment, show its prefix in the first tooltip line and append its description to the tooltip list. EnchantmentTooltips(item, tooltips); - // Replace rogue with rouge in gfb + // In GFB, replace all instances of "rogue" with "rouge". if (Main.zenithWorld) { tooltips.FindAndReplace("Rogue", "Rouge"); tooltips.FindAndReplace("rogue", "rouge"); } + // Everything below this line can only apply to modded items. If the item is vanilla, stop here for efficiency. if (item.type < ItemID.Count) return; @@ -65,27 +86,68 @@ namespace CalamityMod.Items // Convert current charge ratio into a percentage. float displayedPercent = ChargeRatio * 100f; TooltipLine line = new TooltipLine(Mod, "CalamityCharge", $"Current Charge: {displayedPercent:N1}%"); - tooltips.Add(line); + tooltips.Insert(++lastTooltipIndex, line); + } + + // Generic support for any and all Hold SHIFT tooltips. + // For more information, see IHoldShiftTooltipItem. + if (item.ModItem is IHoldShiftTooltipItem holdShiftItem) + { + string dynamicKey = $"{Mod.Name}:{item.ModItem.Name}_HoldShift"; + string lineText = item.ModItem.GetLocalizedValue(holdShiftItem.TooltipExtensionKey); + var line = new TooltipLine(Mod, dynamicKey, lineText); + if (holdShiftItem.TooltipExtensionColor is not null) + line.OverrideColor = holdShiftItem.TooltipExtensionColor; + TooltipLine[] lines = { line }; + + // + // Original code lifted from Iban's extended armor tooltips. + // + bool holdingShift = Main.keyState.IsKeyDown(Keys.LeftShift); + + // If holding SHIFT, actually display the extended tooltip. + if (holdingShift && firstTooltipIndex != -1) + { + // If asked to, remove all standard tooltip lines. This moves the last tooltip index. + if (holdShiftItem.HidesNormalTooltip) + { + tooltips.RemoveRange(firstTooltipIndex, standardTooltipCount); + lastTooltipIndex -= standardTooltipCount; + } + + // Append every "Hold SHIFT" tooltip at the end of standard tooltips. + tooltips.InsertRange(++lastTooltipIndex, lines); + } + + // If not holding SHIFT, display the extension indicator if appropriate. + if (!holdingShift && holdShiftItem.ShowExtensionIndicator) + { + LocalizedText indicatorText = CalamityUtils.GetText(holdShiftItem.ExtensionIndicatorKey); + var indicator = new TooltipLine(Mod, IHoldShiftTooltipItem.ExtensionIndicatorTooltipID, indicatorText.Value); + if (holdShiftItem.ExtensionIndicatorColor is not null) + indicator.OverrideColor = holdShiftItem.ExtensionIndicatorColor; + tooltips.Insert(++lastTooltipIndex, indicator); + } } // Adds "Donor Item" and "Developer Item" to donor items and developer items respectively. - if (donorItem) - { - TooltipLine line = new TooltipLine(Mod, "CalamityDonor", CalamityUtils.ColorMessage("- Donor Item -", CalamityUtils.DonatorItemColor)); - tooltips.Add(line); - } + // This is intentionally at the bottom, below everything else. if (devItem) { TooltipLine line = new TooltipLine(Mod, "CalamityDev", CalamityUtils.ColorMessage("- Developer Item -", CalamityUtils.DevItemColor)); tooltips.Add(line); } + else if (donorItem) + { + TooltipLine line = new TooltipLine(Mod, "CalamityDonor", CalamityUtils.ColorMessage("- Donor Item -", CalamityUtils.DonatorItemColor)); + tooltips.Add(line); + } } #endregion #region Rarity Coloration - private void ApplyRarityColor(Item item, TooltipLine nameLine) + private static void ApplyRarityColor(Item item, TooltipLine nameLine) { - #region Uniquely Colored Items if (item.type == ModContent.ItemType()) nameLine.OverrideColor = Color.Lerp(Color.Red, Color.White, (float)Math.Sin(Main.GlobalTimeWrappedHourly) / 2f + 0.5f); if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) @@ -192,7 +254,6 @@ namespace CalamityMod.Items nameLine.OverrideColor = Color.Lerp(currentColor, nextColor, Main.GlobalTimeWrappedHourly % 2f > 1f ? 1f : Main.GlobalTimeWrappedHourly % 1f); } } - #endregion } #endregion @@ -262,6 +323,10 @@ namespace CalamityMod.Items if (item.type == ModContent.ItemType()) EditTooltipByName("Damage", (line) => line.Text = LiliesOfFinality.TheNumber + " summon damage"); + // Apparently 612 is a homestuck reference + if (item.type == ModContent.ItemType()) + EditTooltipByName("AxePower", (line) => line.Text = line.Text.Replace("610%", "612%")); + // Master Mode items also drop in Revengeance // Only affects vanilla and Calamity items if (item.master && (item.type < ItemID.Count || item.ModItem?.Mod is CalamityMod)) @@ -292,10 +357,44 @@ namespace CalamityMod.Items EditTooltipByNum(0, (line) => line.Text += "\nDemon Altars now drop Souls of Night instead of generating ores when destroyed" + "\nHardmode ores now generate after defeating Mechanical Bosses for the first time"); - // Warmth Potion provides debuff immunities + // Exact life regen descriptions + bool isCampfire = item.type == ItemID.Campfire || item.type == ItemID.CursedCampfire || item.type == ItemID.DemonCampfire || item.type == ItemID.FrozenCampfire || item.type == ItemID.IchorCampfire || item.type == ItemID.RainbowCampfire || item.type == ItemID.UltraBrightCampfire || item.type == ItemID.BoneCampfire || item.type == ItemID.DesertCampfire || item.type == ItemID.CoralCampfire || item.type == ItemID.CorruptCampfire || item.type == ItemID.CrimsonCampfire || item.type == ItemID.HallowedCampfire || item.type == ItemID.JungleCampfire || item.type == ItemID.MushroomCampfire || item.type == ItemID.ShimmerCampfire; + if (isCampfire) + EditTooltipByNum(0, (line) => line.Text = "Life regen is increased by 0.5 HP/s when near a campfire"); + + if (item.type == ItemID.HeartLantern) + EditTooltipByNum(0, (line) => line.Text = "Grants +1 HP/s life regeneration when placed nearby"); + + if (item.type == ItemID.BottledHoney) + EditTooltipByNum(0, (line) => line.Text = "Grants +1 HP/s life regen for a short time" + + "\nGrants an additional +1 HP/s life regen while inflicted with a damaging debuff"); + + if (item.type == ItemID.ShinyStone) + EditTooltipByNum(0, (line) => line.Text = "Grants +2 HP/s life regen and accelerates natural life regen when not moving"); + + if (item.type == ItemID.BandofRegeneration) + EditTooltipByNum(0, (line) => line.Text = "Grants +1 HP/s life regeneration"); + + if (item.type == ItemID.CharmofMyths) + EditTooltipByNum(0, (line) => line.Text = "Grants +1 HP/s life regeneration and reduces the cooldown of healing potions by 25%"); + + if (item.type == ItemID.RegenerationPotion) + EditTooltipByNum(0, (line) => line.Text = "Provides +2 HP/s life regeneration"); + + if (item.type == ItemID.SoulDrain) + EditTooltipByNum(0, (line) => line.Text += "\nThis grants +1.5 HP/s life regen and accelerates natural life regen" + + "\nLife drain stacks based on the number of enemies being hit"); + + if (item.type == ItemID.HamBat) + EditTooltipByNum(1, (line) => line.Text = "Defeating enemies temporarily grants +3 HP/s life regen"); + + if (item.type == ItemID.AegisCrystal) + EditTooltipByNum(0, (line) => line.Text = "Permanently boosts natural life regeneration"); + + // Warmth Potion reduces debuff durations if (item.type == ItemID.WarmthPotion) { - string immunityLine = "\nGrants immunity to Chilled, Frozen and Glacial State"; + string immunityLine = "\nGreatly reduces the duration of Chilled, Frozen, and Glacial State"; EditTooltipByNum(0, (line) => line.Text += immunityLine); } @@ -588,7 +687,7 @@ namespace CalamityMod.Items { EditTooltipByNum(0, (line) => line.Text = "Multiplies all fire-based debuff damage by 1.25\n" + "All attacks light enemies on fire\n" + - "'Never get cold feet again'\n"); + "'Never get cold feet again'"); } // Hellfire Treads buff. @@ -889,6 +988,8 @@ namespace CalamityMod.Items // Solar Flare if (item.type == ItemID.SolarFlareHelmet) EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("26%", "20%")); + if (item.type == ItemID.SolarFlareHelmet || item.type == ItemID.SolarFlareBreastplate || item.type == ItemID.SolarFlareLeggings) + EditTooltipByNum(1, (line) => line.Text = "Grants +1 HP/s life regeneration"); // Vortex if (item.type == ItemID.VortexHelmet) @@ -900,8 +1001,10 @@ namespace CalamityMod.Items // DD2 armor tooltip edits #region DD2 Armor - // Reduce DD2 armor piece bonuses because they're overpowered + // Reduce DD2 armor piece bonuses because they're overpowered, and clarify life regen boosts // Squire armor + if (item.type == ItemID.SquireGreatHelm) + EditTooltipByNum(0, (line) => line.Text = "Increases your max number of sentries by 1 and grants +2 HP/s life regen"); if (item.type == ItemID.SquirePlating) EditTooltipByNum(0, (line) => line.Text = "10% increased minion and melee damage"); if (item.type == ItemID.SquireGreaves) @@ -931,7 +1034,7 @@ namespace CalamityMod.Items // Valhalla Knight armor if (item.type == ItemID.SquireAltShirt) - EditTooltipByNum(0, (line) => line.Text = "30% increased minion damage and increased life regeneration"); + EditTooltipByNum(0, (line) => line.Text = "30% increased minion damage and grants +4 HP/s life regen"); if (item.type == ItemID.SquireAltPants) EditTooltipByNum(0, (line) => line.Text = "10% increased minion damage and melee critical strike chance"); diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index 4b73cceaba..107986fa4e 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -45,8 +45,9 @@ namespace CalamityMod.Items { ItemID.Bananarang, Do(DamageExact(76), UseExact(14)) }, { ItemID.BatScepter, Do(DamageExact(56)) }, { ItemID.BeamSword, Do(UseMeleeSpeed, DamageExact(142), UseAnimationExact(45), ShootSpeedExact(23f), KnockbackExact(8)) }, - { ItemID.BeeGun, Do(DamageExact(10), ManaExact(4)) }, - { ItemID.BeesKnees, Do(PointBlank, DamageExact(18), UseExact(38)) }, + { ItemID.BeeGun, Do(DamageExact(13), ManaExact(4)) }, + { ItemID.BeeKeeper, Do((UseTurn),DamageExact(32)) }, + { ItemID.BeesKnees, Do(PointBlank, DamageExact(24), UseExact(38)) }, { ItemID.Bladetongue, Do(UseTurn, UseRatio(0.8f), DamageExact(120)) }, { ItemID.BlizzardStaff, Do(DamageExact(41), ManaExact(7)) }, { ItemID.BloodyMachete, Do(AutoReuse, DamageExact(24)) }, @@ -127,7 +128,7 @@ namespace CalamityMod.Items { ItemID.HellwingBow, Do(PointBlank, DamageExact(16)) }, { ItemID.HighVelocityBullet, Do(DamageExact(13)) }, { ItemID.HiveFive, Do(AutoReuse, DamageExact(26)) }, - { ItemID.HornetStaff, Do(AutoReuse, DamageExact(13), UseExact(30)) }, + { ItemID.HornetStaff, Do(AutoReuse, DamageExact(18), UseExact(30)) }, { ItemID.IceBlade, Do(UseMeleeSpeed) }, { ItemID.IceBoomerang, Do(UseExact(25), ShootSpeedExact(9)) }, { ItemID.IceRod, Do(UseExact(6), DamageExact(30), ShootSpeedExact(20)) }, @@ -162,6 +163,7 @@ namespace CalamityMod.Items { ItemID.MonkStaffT1, Do(TrueMeleeNoSpeed, DamageExact(83)) }, // Sleepy Octopod { ItemID.MonkStaffT2, Do(AutoReuse, TrueMelee, DamageExact(90)) }, // Ghastly Glaive { ItemID.MonkStaffT3, Do(DamageExact(225)) }, // Sky Dragon's Fury + { ItemID.MoonlordBullet, Do(DamageExact(19)) }, // Luminite Bullet { ItemID.MoonlordTurretStaff, Do(DamageExact(50), UseExact(15)) }, //Lunar Portal Staff { ItemID.Muramasa, Do(CritDelta(+20)) }, { ItemID.MushroomSpear, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(100)) }, @@ -184,7 +186,7 @@ namespace CalamityMod.Items { ItemID.PalladiumSword, Do(UseTurn, DamageExact(100)) }, { ItemID.PearlwoodBow, Do(AutoReuse, PointBlank, DamageExact(20), UseDelta(+8), ShootSpeedDelta(+3.4f), KnockbackDelta(+1f)) }, { ItemID.PearlwoodSword, Do(UseTurn, DamageExact(45)) }, - { ItemID.PewMaticHorn, Do(DamageExact(24)) }, + { ItemID.PewMaticHorn, Do(DamageExact(25), ShootSpeedExact(15)) }, { ItemID.Phantasm, Do(PointBlank, DamageExact(48)) }, { ItemID.PhoenixBlaster, Do(AutoReuse, PointBlank, UseExact(18)) }, { ItemID.PiranhaGun, Do(DamageExact(48)) }, @@ -211,13 +213,12 @@ namespace CalamityMod.Items { ItemID.RocketLauncher, Do(DamageExact(70)) }, { ItemID.Sandgun, Do(PointBlank, DamageExact(22), UseExact(20)) }, { ItemID.SapphireStaff, Do(DamageExact(25)) }, - { ItemID.SDMG, Do(PointBlank, DamageExact(80)) }, { ItemID.Seedler, Do(UseMeleeSpeed, DamageExact(74), ShootSpeedDelta(+4f)) }, { ItemID.ShadowbeamStaff, Do(DamageExact(100)) }, { ItemID.ShadowFlameBow, Do(PointBlank, DamageExact(55)) }, { ItemID.ShadowFlameHexDoll, Do(DamageExact(40), ShootSpeedExact(30)) }, { ItemID.ShadowFlameKnife, Do(DamageExact(70)) }, - { ItemID.SharpTears, Do(DamageExact(49)) }, + { ItemID.SharpTears, Do(DamageExact(49)) }, // Blood Thorn { ItemID.Shotgun, Do(PointBlank, DamageExact(36), AutoReuse) }, { ItemID.Shroomerang, Do(ShootSpeedExact(11)) }, { ItemID.SilverBullet, Do(DamageExact(8)) }, @@ -225,6 +226,7 @@ namespace CalamityMod.Items { ItemID.SkyFracture, Do(DamageExact(54), ShootSpeedExact(30f)) }, { ItemID.SlapHand, Do(UseTurn, DamageExact(120)) }, { ItemID.Smolstar, Do(DamageExact(9), AutoReuse, UseExact(25)) }, // Blade Staff + { ItemID.SniperRifle, Do(PointBlank, DamageExact(215)) }, { ItemID.SolarEruption, Do(DamageExact(157)) }, { ItemID.SoulDrain, Do(DamageExact(38)) }, // Life Drain { ItemID.SpaceGun, Do(DamageExact(25)) }, @@ -238,7 +240,7 @@ namespace CalamityMod.Items { ItemID.StylistKilLaKillScissorsIWish, Do(AutoReuse, UseTurn, DamageExact(18)) }, // Stylish Scissors { ItemID.Stynger, Do(DamageExact(75)) }, { ItemID.Swordfish, Do(AutoReuse, TrueMelee, DamageExact(24)) }, - { ItemID.TacticalShotgun, Do(PointBlank, DamageExact(34)) }, + { ItemID.TacticalShotgun, Do(PointBlank, DamageExact(41)) }, { ItemID.TaxCollectorsStickOfDoom, Do(AutoReuse, UseTurn, UseRatio(0.8f), DamageExact(70)) }, // Classy Cane { ItemID.TendonBow, Do(PointBlank, DamageExact(17), AutoReuse) }, { ItemID.TerraBlade, Do(DamageExact(122)) }, @@ -267,6 +269,7 @@ namespace CalamityMod.Items { ItemID.VampireKnives, Do(DamageExact(38)) }, { ItemID.ValkyrieYoyo, Do(AutoReuse, DamageExact(48)) }, // Red's Throw and Valkyrie Yoyo have the same stats { ItemID.VenomStaff, Do(DamageExact(55)) }, + { ItemID.VenusMagnum, Do(PointBlank, DamageExact(65)) }, { ItemID.WaspGun, Do(UseExact(11), DamageExact(58)) }, { ItemID.WaterBolt, Do(DamageExact(23)) }, { ItemID.WhitePhaseblade, Do(AutoReuse, UseTurn, DamageExact(32)) }, @@ -282,31 +285,31 @@ namespace CalamityMod.Items #region CATEGORY 2: Defense Balancing { ItemID.AncientHallowedGreaves, Do(DefenseDelta(+2)) }, { ItemID.AncientHallowedPlateMail, Do(DefenseDelta(+3)) }, - { ItemID.AnkhShield, Do(DefenseDelta(+8)) }, - { ItemID.CobaltShield, Do(DefenseDelta(+3)) }, + { ItemID.AnkhShield, Do(DefenseDelta(+4)) }, // 8 total + { ItemID.CobaltShield, Do(DefenseDelta(+3)) }, // 4 total { ItemID.EoCShield, Do(DefenseDelta(+1)) }, // Shield of Cthulhu - { ItemID.FrozenShield, Do(DefenseDelta(+7)) }, + { ItemID.FrozenShield, Do(DefenseDelta(+4)) }, // 10 total (plus the Frozen Turtle Shell DR effect) { ItemID.FrozenTurtleShell, Do(DefenseExact(6)) }, { ItemID.HallowedGreaves, Do(DefenseDelta(+2)) }, { ItemID.HallowedPlateMail, Do(DefenseDelta(+3)) }, - { ItemID.HeroShield, Do(DefenseDelta(+10)) }, + { ItemID.HeroShield, Do(DefenseDelta(+5)) }, // 15 total (plus increased max life) { ItemID.LavaSkull, Do(DefenseExact(4)) }, // Magma Skull { ItemID.MoltenSkullRose, Do(DefenseExact(8)) }, - { ItemID.ObsidianShield, Do(DefenseDelta(+5)) }, - { ItemID.ObsidianSkull, Do(DefenseDelta(+1)) }, + { ItemID.ObsidianShield, Do(DefenseDelta(+4)) }, // 6 total + { ItemID.ObsidianSkull, Do(DefenseDelta(+1)) }, // 2 total { ItemID.ObsidianSkullRose, Do(DefenseExact(4)) }, { ItemID.OrichalcumBreastplate, Do(DefenseDelta(+3)) }, { ItemID.OrichalcumHeadgear, Do(DefenseDelta(+2)) }, { ItemID.OrichalcumHelmet, Do(DefenseDelta(+3)) }, { ItemID.OrichalcumLeggings, Do(DefenseDelta(+4)) }, { ItemID.OrichalcumMask, Do(DefenseDelta(+3)) }, - { ItemID.PaladinsShield, Do(DefenseDelta(+3)) }, + { ItemID.PaladinsShield, Do(DefenseDelta(+2)) }, // 8 total { ItemID.PalladiumBreastplate, Do(DefenseDelta(+3)) }, { ItemID.PalladiumHeadgear, Do(DefenseDelta(+2)) }, { ItemID.PalladiumHelmet, Do(DefenseDelta(+3)) }, { ItemID.PalladiumMask, Do(DefenseDelta(+1)) }, { ItemID.PalladiumLeggings, Do(DefenseDelta(+3)) }, - { ItemID.Shackle, Do(DefenseDelta(+2)) }, + { ItemID.Shackle, Do(DefenseDelta(+2)) }, // 3 total #endregion #region CATEGORY 3: Tool Balancing @@ -454,15 +457,14 @@ namespace CalamityMod.Items { ItemID.PulseBow, pointBlank }, { ItemID.Revolver, Do(PointBlank, AutoReuse) }, { ItemID.RichMahoganyBow, pointBlank }, + { ItemID.SDMG, pointBlank }, { ItemID.ShadewoodBow, pointBlank }, { ItemID.SilverBow, pointBlank }, - { ItemID.SniperRifle, pointBlank }, { ItemID.SnowballCannon, pointBlank }, { ItemID.StakeLauncher, pointBlank }, { ItemID.TinBow, pointBlank }, { ItemID.TungstenBow, pointBlank }, { ItemID.Uzi, pointBlank }, - { ItemID.VenusMagnum, pointBlank }, { ItemID.VortexBeater, pointBlank }, { ItemID.WoodenBow, pointBlank }, #endregion @@ -510,7 +512,6 @@ namespace CalamityMod.Items #region CATEGORY 7: Other Quality of Life (AutoReuse / UseTurn) { ItemID.Amarok, autoReuse }, { ItemID.BatBat, autoReuse }, - { ItemID.BeeKeeper, Do(UseTurn) }, { ItemID.BladeofGrass, Do(AutoReuse, UseTurn) }, { ItemID.BloodButcherer, Do(AutoReuse, UseTurn) }, { ItemID.BoneSword, Do(AutoReuse, UseTurn) }, diff --git a/Items/Dyes/AerialiteDye.png b/Items/Dyes/AerialiteDye.png index 99402471c4..d5b2f4c35e 100644 Binary files a/Items/Dyes/AerialiteDye.png and b/Items/Dyes/AerialiteDye.png differ diff --git a/Items/Fishing/EnchantedStarfish.cs b/Items/Fishing/EnchantedStarfish.cs index 2109fcecc4..8102c4c1c9 100644 --- a/Items/Fishing/EnchantedStarfish.cs +++ b/Items/Fishing/EnchantedStarfish.cs @@ -13,7 +13,8 @@ namespace CalamityMod.Items.Fishing Item.ResearchUnlockCount = 10; ItemID.Sets.CanBePlacedOnWeaponRacks[Item.type] = true; // For some reason Life/Mana boosting items are in this set (along with Magic Mirror+) - ItemID.Sets.SortingPriorityBossSpawns[Type] = 19; // Mana Crystal + ItemID.Sets.SortingPriorityBossSpawns[Type] = 21; // Mana Crystal + ItemID.Sets.ShimmerTransformToItem[Type] = ItemID.ArcaneCrystal; } public override void SetDefaults() diff --git a/Items/Fishing/SunkenSeaCatches/EutrophicCrate.cs b/Items/Fishing/SunkenSeaCatches/EutrophicCrate.cs index c2c7f48aec..7242d6591c 100644 --- a/Items/Fishing/SunkenSeaCatches/EutrophicCrate.cs +++ b/Items/Fishing/SunkenSeaCatches/EutrophicCrate.cs @@ -51,6 +51,7 @@ namespace CalamityMod.Items.Fishing.SunkenSeaCatches // Materials itemLoot.Add(ModContent.ItemType(), 1, 10, 30); itemLoot.Add(ModContent.ItemType(), 1, 10, 30); + itemLoot.Add(ModContent.ItemType(), 1, 30, 60); postDesertScourge.Add(ModContent.ItemType(), 1, 5, 10); postDesertScourge.Add(ModContent.ItemType(), 5, 2, 5); diff --git a/Items/Fishing/SunkenSeaCatches/PrismCrate.cs b/Items/Fishing/SunkenSeaCatches/PrismCrate.cs index ecf064395c..1c5eeedd9f 100644 --- a/Items/Fishing/SunkenSeaCatches/PrismCrate.cs +++ b/Items/Fishing/SunkenSeaCatches/PrismCrate.cs @@ -54,6 +54,7 @@ namespace CalamityMod.Items.Fishing.SunkenSeaCatches // Materials itemLoot.Add(ModContent.ItemType(), 1, 10, 30); itemLoot.Add(ModContent.ItemType(), 1, 10, 30); + itemLoot.Add(ModContent.ItemType(), 1, 30, 60); postDesertScourge.Add(ModContent.ItemType(), 1, 5, 10); postDesertScourge.Add(ModContent.ItemType(), 5, 2, 5); postHardmodeClam.Add(ModContent.ItemType(), new Fraction(12, 100), 2, 5); diff --git a/Items/IHoldShiftTooltipItem.cs b/Items/IHoldShiftTooltipItem.cs new file mode 100644 index 0000000000..afd8537be5 --- /dev/null +++ b/Items/IHoldShiftTooltipItem.cs @@ -0,0 +1,61 @@ +using Microsoft.Xna.Framework; + +namespace CalamityMod.Items +{ + // This interface is used on items where you can hold Left SHIFT for an expanded tooltip. + // All actual implementation of this behavior is done in CalamityGlobalItemTooltip. + public interface IHoldShiftTooltipItem + { + /// + /// Internal ID for the TooltipLine which contains Calamity items' "Hold SHIFT" extension indicators. + /// + internal const string ExtensionIndicatorTooltipID = "CalamityMod:HoldShiftExtensionIndicator"; + + /// + /// The lang/localization key of the default tooltip extension indicator message. + /// + public const string DefaultExtensionIndicatorKey = "UI.HoldShiftTooltipExtensionIndicator"; + + /// + /// The default color of the default tooltip extension indicator message. + /// + public static readonly Color DefaultExtensionIndicatorColor = new Color(184, 184, 184); // #B8B8B8 + + /// + /// The default lang/localization key which is queried to show an item's tooltip extension. + /// + public const string DefaultTooltipExtensionKey = "HoldShiftTooltip"; + + /// + /// Whether holding Left SHIFT for the tooltip extension hides the normal tooltip. Typically this is false. + /// + public virtual bool HidesNormalTooltip => false; + + /// + /// Whether the "Hold SHIFT for more" extension indicator appears by default. Should essentially always be true.
+ /// You can set this to false for "secret" flavor or easter egg tooltips, like the one on Midas Prime. + ///
+ public virtual bool ShowExtensionIndicator => true; + + /// + /// The lang/localization key of this item's tooltip extension indicator message. + /// + public virtual string ExtensionIndicatorKey => DefaultExtensionIndicatorKey; + + /// + /// The color of this item's tooltip extension indicator message. If set to null, the indicator will not be colored. + /// + public virtual Color? ExtensionIndicatorColor => DefaultExtensionIndicatorColor; + + /// + /// The lang/localization key which this item uses for its tooltip extension. + /// + public virtual string TooltipExtensionKey => DefaultTooltipExtensionKey; + + /// + /// The color of this item's tooltip extension. If set to null, the tooltip extension will not be colored. + /// + public virtual Color? TooltipExtensionColor => null; + + } +} diff --git a/Items/LoreItems/LoreItem.cs b/Items/LoreItems/LoreItem.cs index ef983c0434..193dde3a8f 100644 --- a/Items/LoreItems/LoreItem.cs +++ b/Items/LoreItems/LoreItem.cs @@ -1,21 +1,25 @@ -using System.Collections.Generic; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.LoreItems { - public abstract class LoreItem : ModItem, ILocalizedModType + public abstract class LoreItem : ModItem, ILocalizedModType, IHoldShiftTooltipItem { public new string LocalizationCategory => "Items.Lore"; - // All lore items initially have a short tooltip which indicates there is more to be read. - public override LocalizedText Tooltip => CalamityUtils.GetText($"{LocalizationCategory}.ShortTooltip"); + // When holding SHIFT on a lore item, the default tooltip is removed entirely. + public bool HidesNormalTooltip => true; - // By default, lore text appears in white, but this can be changed. - public virtual Color? LoreColor => null; + // Lore items have a flavorful extension indicator tooltip. + public string ExtensionIndicatorKey => $"{LocalizationCategory}.ShortTooltip"; + + // Each line of the extension indicator tooltip is manually colored, so don't provide an override color. + public Color? ExtensionIndicatorColor => null; + + // The localization key for all lore items' full lore content is just "Lore". + public string TooltipExtensionKey => "Lore"; public override void SetStaticDefaults() { @@ -30,14 +34,5 @@ namespace CalamityMod.Items.LoreItems { itemGroup = (ContentSamples.CreativeHelper.ItemGroup)CalamityResearchSorting.LoreItems; } - - // All lore items use the same code for holding SHIFT to extend tooltips. - public override void ModifyTooltips(List tooltips) - { - TooltipLine fullLore = new(Mod, "CalamityMod:Lore", this.GetLocalizedValue("Lore")); - if (LoreColor.HasValue) - fullLore.OverrideColor = LoreColor.Value; - CalamityUtils.HoldShiftTooltip(tooltips, new TooltipLine[] { fullLore }, true); - } } } diff --git a/Items/NormalityRelocator.cs b/Items/NormalityRelocator.cs index 2b37817793..09f7d279c7 100644 --- a/Items/NormalityRelocator.cs +++ b/Items/NormalityRelocator.cs @@ -3,6 +3,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Items.Placeables.Plates; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -12,6 +13,7 @@ namespace CalamityMod.Items public class NormalityRelocator : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Misc"; + public static readonly SoundStyle TeleportSound = new("CalamityMod/Sounds/Item/NormalityRelocator", 3); public override void SetStaticDefaults() { Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 7)); diff --git a/Items/Pets/AbyssShellFossil.cs b/Items/Pets/AbyssShellFossil.cs index 48415c3dd9..617e861792 100644 --- a/Items/Pets/AbyssShellFossil.cs +++ b/Items/Pets/AbyssShellFossil.cs @@ -20,11 +20,9 @@ namespace CalamityMod.Items.Pets Item.useTime = 20; Item.useStyle = ItemUseStyleID.Swing; Item.noMelee = true; - Item.value = Item.sellPrice(platinum: 1); Item.rare = ItemRarityID.Cyan; Item.Calamity().devItem = true; - Item.shoot = ModContent.ProjectileType(); Item.buffType = ModContent.BuffType(); Item.UseSound = SoundID.Item2; diff --git a/Items/Placeables/AlgalSlateItem.cs b/Items/Placeables/AlgalSlateItem.cs new file mode 100644 index 0000000000..b6d48487fb --- /dev/null +++ b/Items/Placeables/AlgalSlateItem.cs @@ -0,0 +1,30 @@ +using CalamityMod.Tiles.FloralParadise; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class AlgalSlateItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.createTile = ModContent.TileType(); + Item.useStyle = ItemUseStyleID.Swing; + 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/AlgalSlateItem.png b/Items/Placeables/AlgalSlateItem.png new file mode 100644 index 0000000000..a589261603 Binary files /dev/null and b/Items/Placeables/AlgalSlateItem.png differ diff --git a/Items/Placeables/Basalt.cs b/Items/Placeables/Basalt.cs new file mode 100644 index 0000000000..487fd1f7ac --- /dev/null +++ b/Items/Placeables/Basalt.cs @@ -0,0 +1,28 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class Basalt : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + } +} diff --git a/Items/Placeables/Basalt.png b/Items/Placeables/Basalt.png new file mode 100644 index 0000000000..3f4786a23a Binary files /dev/null and b/Items/Placeables/Basalt.png differ diff --git a/Items/Placeables/BlackPearlPile.cs b/Items/Placeables/BlackPearlPile.cs new file mode 100644 index 0000000000..2f44d3cd68 --- /dev/null +++ b/Items/Placeables/BlackPearlPile.cs @@ -0,0 +1,37 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class BlackPearlPile : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.rare = ItemRarityID.Blue; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(ItemID.BlackPearl). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/BlackPearlPile.png b/Items/Placeables/BlackPearlPile.png new file mode 100644 index 0000000000..c35a65ebbc Binary files /dev/null and b/Items/Placeables/BlackPearlPile.png differ diff --git a/Items/Placeables/CyanCoral.cs b/Items/Placeables/CyanCoral.cs new file mode 100644 index 0000000000..b5d7d106bd --- /dev/null +++ b/Items/Placeables/CyanCoral.cs @@ -0,0 +1,37 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class CyanCoral : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.rare = ItemRarityID.Blue; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + + //public override void AddRecipes() + //{ + // CreateRecipe(4). + // AddIngredient(ItemID.PinkPearl). + // AddTile(TileID.HeavyWorkBench). + // Register(); + //} + } +} diff --git a/Items/Placeables/CyanCoral.png b/Items/Placeables/CyanCoral.png new file mode 100644 index 0000000000..3f705ee85b Binary files /dev/null and b/Items/Placeables/CyanCoral.png differ diff --git a/Items/Placeables/Driftwood.cs b/Items/Placeables/Driftwood.cs new file mode 100644 index 0000000000..72db8e2f9f --- /dev/null +++ b/Items/Placeables/Driftwood.cs @@ -0,0 +1,42 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class Driftwood : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + ItemID.Sets.ShimmerTransformToItem[Type] = ItemID.Wood; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + { + itemGroup = ContentSamples.CreativeHelper.ItemGroup.Wood; + } + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(4). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Driftwood.png b/Items/Placeables/Driftwood.png new file mode 100644 index 0000000000..25ff08f299 Binary files /dev/null and b/Items/Placeables/Driftwood.png differ diff --git a/Items/Placeables/Furniture/BossRelics/AstrumDeusRelic.png b/Items/Placeables/Furniture/BossRelics/AstrumDeusRelic.png index beecae5c78..077568f1c7 100644 Binary files a/Items/Placeables/Furniture/BossRelics/AstrumDeusRelic.png and b/Items/Placeables/Furniture/BossRelics/AstrumDeusRelic.png differ diff --git a/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs b/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs index 17aec33a70..63db3bcde1 100644 --- a/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs +++ b/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs @@ -72,8 +72,8 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "CosmaticMango", "CrabBar", "Dia", - "DylanDoe21", "enamoured", + "ENNWAY", "Fluffi", "HaguriHat", "Heart Plus Up!", @@ -94,7 +94,6 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "Shayy", "Spider Prov", "StipulateVenus", - "Tomat", "Triangle", "Uncle Danny", "Xyk", @@ -126,10 +125,10 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "Doog", "drh", "dwshin", + "DylanDoe21", "Earth", "EchoDuck", "Ein", - "ENNWAY", "Enreden", "Epsilon", "Fargowilta", @@ -191,6 +190,7 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "ThousandFields", "TikiWiki", "Tinymanx", + "Tomat", "Trivaxy", "Uberransy", "Vaikyia", diff --git a/Items/Placeables/Furniture/Monoliths/BossRushMonolith.png b/Items/Placeables/Furniture/Monoliths/BossRushMonolith.png index d00e2fd304..700f5dca6d 100644 Binary files a/Items/Placeables/Furniture/Monoliths/BossRushMonolith.png and b/Items/Placeables/Furniture/Monoliths/BossRushMonolith.png differ diff --git a/Items/Placeables/Furniture/ResilientCandle.cs b/Items/Placeables/Furniture/ResilientCandle.cs index 87c79ac75d..68052c8dfe 100644 --- a/Items/Placeables/Furniture/ResilientCandle.cs +++ b/Items/Placeables/Furniture/ResilientCandle.cs @@ -19,8 +19,9 @@ namespace CalamityMod.Items.Placeables.Furniture Item.useTime = 10; Item.useStyle = ItemUseStyleID.Swing; Item.consumable = true; - Item.value = Item.buyPrice(0, 25, 0, 0); - Item.rare = ItemRarityID.LightRed; + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(gold: 20); + Item.rare = ItemRarityID.Pink; Item.createTile = ModContent.TileType(); } } diff --git a/Items/Placeables/Furniture/SpitefulCandle.cs b/Items/Placeables/Furniture/SpitefulCandle.cs index cef61b3d9b..c4b222be8d 100644 --- a/Items/Placeables/Furniture/SpitefulCandle.cs +++ b/Items/Placeables/Furniture/SpitefulCandle.cs @@ -19,8 +19,9 @@ namespace CalamityMod.Items.Placeables.Furniture Item.useTime = 10; Item.useStyle = ItemUseStyleID.Swing; Item.consumable = true; - Item.value = Item.buyPrice(0, 25, 0, 0); - Item.rare = ItemRarityID.LightRed; + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(gold: 20); + Item.rare = ItemRarityID.Pink; Item.createTile = ModContent.TileType(); } } diff --git a/Items/Placeables/Furniture/VigorousCandle.cs b/Items/Placeables/Furniture/VigorousCandle.cs index f5457c0f4a..7e82334566 100644 --- a/Items/Placeables/Furniture/VigorousCandle.cs +++ b/Items/Placeables/Furniture/VigorousCandle.cs @@ -19,8 +19,9 @@ namespace CalamityMod.Items.Placeables.Furniture Item.useTime = 10; Item.useStyle = ItemUseStyleID.Swing; Item.consumable = true; - Item.value = Item.buyPrice(0, 25, 0, 0); - Item.rare = ItemRarityID.LightRed; + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(gold: 20); + Item.rare = ItemRarityID.Pink; Item.createTile = ModContent.TileType(); } } diff --git a/Items/Placeables/Furniture/WeightlessCandle.cs b/Items/Placeables/Furniture/WeightlessCandle.cs index 903f707f04..904a2d2654 100644 --- a/Items/Placeables/Furniture/WeightlessCandle.cs +++ b/Items/Placeables/Furniture/WeightlessCandle.cs @@ -19,8 +19,9 @@ namespace CalamityMod.Items.Placeables.Furniture Item.useTime = 10; Item.useStyle = ItemUseStyleID.Swing; Item.consumable = true; - Item.value = Item.buyPrice(0, 25, 0, 0); - Item.rare = ItemRarityID.LightRed; + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(gold: 20); + Item.rare = ItemRarityID.Pink; Item.createTile = ModContent.TileType(); } } diff --git a/Items/Placeables/LimeCoral.cs b/Items/Placeables/LimeCoral.cs new file mode 100644 index 0000000000..67ed0a5725 --- /dev/null +++ b/Items/Placeables/LimeCoral.cs @@ -0,0 +1,37 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class LimeCoral : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.rare = ItemRarityID.Blue; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + + //public override void AddRecipes() + //{ + // CreateRecipe(4). + // AddIngredient(ItemID.PinkPearl). + // AddTile(TileID.HeavyWorkBench). + // Register(); + //} + } +} diff --git a/Items/Placeables/LimeCoral.png b/Items/Placeables/LimeCoral.png new file mode 100644 index 0000000000..e5388e3811 Binary files /dev/null and b/Items/Placeables/LimeCoral.png differ diff --git a/Items/Placeables/Limestone.cs b/Items/Placeables/Limestone.cs new file mode 100644 index 0000000000..d238c192a1 --- /dev/null +++ b/Items/Placeables/Limestone.cs @@ -0,0 +1,28 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class Limestone : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + } +} diff --git a/Items/Placeables/Limestone.png b/Items/Placeables/Limestone.png new file mode 100644 index 0000000000..65742f7ba5 Binary files /dev/null and b/Items/Placeables/Limestone.png differ diff --git a/Items/Placeables/MagentaCoral.cs b/Items/Placeables/MagentaCoral.cs new file mode 100644 index 0000000000..a78ffb95c0 --- /dev/null +++ b/Items/Placeables/MagentaCoral.cs @@ -0,0 +1,37 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class MagentaCoral : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.rare = ItemRarityID.Blue; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + + //public override void AddRecipes() + //{ + // CreateRecipe(4). + // AddIngredient(ItemID.PinkPearl). + // AddTile(TileID.HeavyWorkBench). + // Register(); + //} + } +} diff --git a/Items/Placeables/MagentaCoral.png b/Items/Placeables/MagentaCoral.png new file mode 100644 index 0000000000..1f394b1b66 Binary files /dev/null and b/Items/Placeables/MagentaCoral.png differ diff --git a/Items/Placeables/OrangeCoral.cs b/Items/Placeables/OrangeCoral.cs new file mode 100644 index 0000000000..d0dc22fe52 --- /dev/null +++ b/Items/Placeables/OrangeCoral.cs @@ -0,0 +1,37 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class OrangeCoral : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.rare = ItemRarityID.Blue; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + + //public override void AddRecipes() + //{ + // CreateRecipe(4). + // AddIngredient(ItemID.PinkPearl). + // AddTile(TileID.HeavyWorkBench). + // Register(); + //} + } +} diff --git a/Items/Placeables/OrangeCoral.png b/Items/Placeables/OrangeCoral.png new file mode 100644 index 0000000000..cfe3fccb6a Binary files /dev/null and b/Items/Placeables/OrangeCoral.png differ diff --git a/Items/Placeables/PeatItem.cs b/Items/Placeables/PeatItem.cs new file mode 100644 index 0000000000..3a66f54c81 --- /dev/null +++ b/Items/Placeables/PeatItem.cs @@ -0,0 +1,30 @@ +using CalamityMod.Tiles.FloralParadise; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class PeatItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.createTile = ModContent.TileType(); + Item.useStyle = ItemUseStyleID.Swing; + 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/PeatItem.png b/Items/Placeables/PeatItem.png new file mode 100644 index 0000000000..2c060a37a8 Binary files /dev/null and b/Items/Placeables/PeatItem.png differ diff --git a/Items/Placeables/PeatMossItem.cs b/Items/Placeables/PeatMossItem.cs new file mode 100644 index 0000000000..716931ef05 --- /dev/null +++ b/Items/Placeables/PeatMossItem.cs @@ -0,0 +1,30 @@ +using CalamityMod.Tiles.FloralParadise; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class PeatMossItem : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.createTile = ModContent.TileType(); + Item.useStyle = ItemUseStyleID.Swing; + 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/PeatMossItem.png b/Items/Placeables/PeatMossItem.png new file mode 100644 index 0000000000..e7b019ef74 Binary files /dev/null and b/Items/Placeables/PeatMossItem.png differ diff --git a/Items/Placeables/PinkPearlPile.cs b/Items/Placeables/PinkPearlPile.cs new file mode 100644 index 0000000000..2307018521 --- /dev/null +++ b/Items/Placeables/PinkPearlPile.cs @@ -0,0 +1,37 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class PinkPearlPile : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.rare = ItemRarityID.Blue; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(ItemID.PinkPearl). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/PinkPearlPile.png b/Items/Placeables/PinkPearlPile.png new file mode 100644 index 0000000000..1b346005d3 Binary files /dev/null and b/Items/Placeables/PinkPearlPile.png differ diff --git a/Items/Placeables/PolishedNavystoneBrick.cs b/Items/Placeables/PolishedNavystoneBrick.cs new file mode 100644 index 0000000000..d8866493c8 --- /dev/null +++ b/Items/Placeables/PolishedNavystoneBrick.cs @@ -0,0 +1,36 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class PolishedNavystoneBrick : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(2). + AddTile(TileID.Furnaces). + Register(); + } + } +} diff --git a/Items/Placeables/PolishedNavystoneBrick.png b/Items/Placeables/PolishedNavystoneBrick.png new file mode 100644 index 0000000000..7bb337525e Binary files /dev/null and b/Items/Placeables/PolishedNavystoneBrick.png differ diff --git a/Items/Placeables/PolypSand.cs b/Items/Placeables/PolypSand.cs new file mode 100644 index 0000000000..89c5bb8aa1 --- /dev/null +++ b/Items/Placeables/PolypSand.cs @@ -0,0 +1,28 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class PolypSand : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + } +} diff --git a/Items/Placeables/PolypSand.png b/Items/Placeables/PolypSand.png new file mode 100644 index 0000000000..a83aa99230 Binary files /dev/null and b/Items/Placeables/PolypSand.png differ diff --git a/Items/Placeables/RuneSand.cs b/Items/Placeables/RuneSand.cs new file mode 100644 index 0000000000..1dc5aebddb --- /dev/null +++ b/Items/Placeables/RuneSand.cs @@ -0,0 +1,29 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class RuneSand : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + ItemID.Sets.ShimmerTransformToItem[Type] = ModContent.ItemType(); + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + } +} diff --git a/Items/Placeables/RuneSand.png b/Items/Placeables/RuneSand.png new file mode 100644 index 0000000000..60335c3ac5 Binary files /dev/null and b/Items/Placeables/RuneSand.png differ diff --git a/Items/Placeables/Runestone.cs b/Items/Placeables/Runestone.cs new file mode 100644 index 0000000000..29e003cc66 --- /dev/null +++ b/Items/Placeables/Runestone.cs @@ -0,0 +1,33 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.Walls; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class Runestone : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 200; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.rare = ItemRarityID.Blue; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + } +} diff --git a/Items/Placeables/Runestone.png b/Items/Placeables/Runestone.png new file mode 100644 index 0000000000..d0d3ec7b6e Binary files /dev/null and b/Items/Placeables/Runestone.png differ diff --git a/Items/Placeables/ScintillatingBloom.cs b/Items/Placeables/ScintillatingBloom.cs new file mode 100644 index 0000000000..cb8daca949 --- /dev/null +++ b/Items/Placeables/ScintillatingBloom.cs @@ -0,0 +1,31 @@ +using CalamityMod.Tiles.FloralParadise; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class ScintillatingBloom : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 10; + } + + public override void SetDefaults() + { + Item.createTile = ModContent.TileType(); + Item.useStyle = ItemUseStyleID.Swing; + Item.useTurn = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.autoReuse = true; + Item.consumable = true; + Item.width = 24; + Item.height = 24; + Item.maxStack = 999; + } + } +} diff --git a/Items/Placeables/ScintillatingBloom.png b/Items/Placeables/ScintillatingBloom.png new file mode 100644 index 0000000000..12b82912c8 Binary files /dev/null and b/Items/Placeables/ScintillatingBloom.png differ diff --git a/Items/Placeables/Shellstone.cs b/Items/Placeables/Shellstone.cs new file mode 100644 index 0000000000..f0e23fd388 --- /dev/null +++ b/Items/Placeables/Shellstone.cs @@ -0,0 +1,28 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class Shellstone : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + } +} diff --git a/Items/Placeables/Shellstone.png b/Items/Placeables/Shellstone.png new file mode 100644 index 0000000000..12c46ba411 Binary files /dev/null and b/Items/Placeables/Shellstone.png differ diff --git a/Items/Placeables/ShellstoneSlab.cs b/Items/Placeables/ShellstoneSlab.cs new file mode 100644 index 0000000000..4ddac14904 --- /dev/null +++ b/Items/Placeables/ShellstoneSlab.cs @@ -0,0 +1,41 @@ +using CalamityMod.Items.Placeables.Walls; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class ShellstoneSlab : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddTile(TileID.HeavyWorkBench). + Register(); + CreateRecipe(). + AddIngredient(4). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/ShellstoneSlab.png b/Items/Placeables/ShellstoneSlab.png new file mode 100644 index 0000000000..de0ea708a5 Binary files /dev/null and b/Items/Placeables/ShellstoneSlab.png differ diff --git a/Items/Placeables/VolcanicSand.cs b/Items/Placeables/VolcanicSand.cs new file mode 100644 index 0000000000..7f79888f53 --- /dev/null +++ b/Items/Placeables/VolcanicSand.cs @@ -0,0 +1,28 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class VolcanicSand : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + } +} diff --git a/Items/Placeables/VolcanicSand.png b/Items/Placeables/VolcanicSand.png new file mode 100644 index 0000000000..5cdd030ddb Binary files /dev/null and b/Items/Placeables/VolcanicSand.png differ diff --git a/Items/Placeables/Walls/DriftwoodWall.cs b/Items/Placeables/Walls/DriftwoodWall.cs new file mode 100644 index 0000000000..61d8eaada7 --- /dev/null +++ b/Items/Placeables/Walls/DriftwoodWall.cs @@ -0,0 +1,37 @@ +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; +using Terraria.ID; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class DriftwoodWall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 7; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createWall = ModContent.WallType(); + } + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Walls/DriftwoodWall.png b/Items/Placeables/Walls/DriftwoodWall.png new file mode 100644 index 0000000000..27ae1c07a6 Binary files /dev/null and b/Items/Placeables/Walls/DriftwoodWall.png differ diff --git a/Items/Placeables/Walls/ShellstoneSlabWall.cs b/Items/Placeables/Walls/ShellstoneSlabWall.cs new file mode 100644 index 0000000000..2cfe2a0d1c --- /dev/null +++ b/Items/Placeables/Walls/ShellstoneSlabWall.cs @@ -0,0 +1,37 @@ +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; +using Terraria.ID; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class ShellstoneSlabWall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 7; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createWall = ModContent.WallType(); + } + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Placeables/Walls/ShellstoneSlabWall.png b/Items/Placeables/Walls/ShellstoneSlabWall.png new file mode 100644 index 0000000000..ceb19599d8 Binary files /dev/null and b/Items/Placeables/Walls/ShellstoneSlabWall.png differ diff --git a/Items/Placeables/Walls/ShellstoneWall.cs b/Items/Placeables/Walls/ShellstoneWall.cs new file mode 100644 index 0000000000..aa28237ecd --- /dev/null +++ b/Items/Placeables/Walls/ShellstoneWall.cs @@ -0,0 +1,29 @@ +using Terraria.ModLoader; +using WallTiles = CalamityMod.Walls; +using Terraria.ID; + +namespace CalamityMod.Items.Placeables.Walls +{ + public class ShellstoneWall : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 400; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 7; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createWall = ModContent.WallType(); + } + } +} diff --git a/Items/Placeables/Walls/ShellstoneWall.png b/Items/Placeables/Walls/ShellstoneWall.png new file mode 100644 index 0000000000..652e1d0e20 Binary files /dev/null and b/Items/Placeables/Walls/ShellstoneWall.png differ diff --git a/Items/Placeables/WhitePearlPile.cs b/Items/Placeables/WhitePearlPile.cs new file mode 100644 index 0000000000..2c771bf04d --- /dev/null +++ b/Items/Placeables/WhitePearlPile.cs @@ -0,0 +1,37 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class WhitePearlPile : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.rare = ItemRarityID.Blue; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + + public override void AddRecipes() + { + CreateRecipe(4). + AddIngredient(ItemID.WhitePearl). + AddTile(TileID.HeavyWorkBench). + Register(); + } + } +} diff --git a/Items/Placeables/WhitePearlPile.png b/Items/Placeables/WhitePearlPile.png new file mode 100644 index 0000000000..3a896ab3da Binary files /dev/null and b/Items/Placeables/WhitePearlPile.png differ diff --git a/Items/Placeables/YellowCoral.cs b/Items/Placeables/YellowCoral.cs new file mode 100644 index 0000000000..410cc62fe5 --- /dev/null +++ b/Items/Placeables/YellowCoral.cs @@ -0,0 +1,37 @@ +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class YellowCoral : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Placeables"; + public override void SetStaticDefaults() + { + Item.ResearchUnlockCount = 100; + } + + public override void SetDefaults() + { + Item.width = 12; + Item.height = 12; + Item.rare = ItemRarityID.Blue; + Item.maxStack = 9999; + Item.useTurn = true; + Item.autoReuse = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.useStyle = ItemUseStyleID.Swing; + Item.consumable = true; + Item.createTile = ModContent.TileType(); + } + + //public override void AddRecipes() + //{ + // CreateRecipe(4). + // AddIngredient(ItemID.PinkPearl). + // AddTile(TileID.HeavyWorkBench). + // Register(); + //} + } +} diff --git a/Items/Placeables/YellowCoral.png b/Items/Placeables/YellowCoral.png new file mode 100644 index 0000000000..0a9f3779aa Binary files /dev/null and b/Items/Placeables/YellowCoral.png differ diff --git a/Items/Potions/Alcohol/BloodyMary.cs b/Items/Potions/Alcohol/BloodyMary.cs index e674edd64a..964b55b6ed 100644 --- a/Items/Potions/Alcohol/BloodyMary.cs +++ b/Items/Potions/Alcohol/BloodyMary.cs @@ -27,7 +27,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(480f); - Item.value = Item.buyPrice(0, 2, 60, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 80); } } } diff --git a/Items/Potions/Alcohol/CaribbeanRum.cs b/Items/Potions/Alcohol/CaribbeanRum.cs index b8d4a37cec..fb3b0a0705 100644 --- a/Items/Potions/Alcohol/CaribbeanRum.cs +++ b/Items/Potions/Alcohol/CaribbeanRum.cs @@ -27,7 +27,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(480f); - Item.value = Item.buyPrice(0, 5, 30, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 60); } } } diff --git a/Items/Potions/Alcohol/CinnamonRoll.cs b/Items/Potions/Alcohol/CinnamonRoll.cs index 0973b19847..1910bad0c8 100644 --- a/Items/Potions/Alcohol/CinnamonRoll.cs +++ b/Items/Potions/Alcohol/CinnamonRoll.cs @@ -27,7 +27,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(480f); - Item.value = Item.buyPrice(0, 5, 30, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(gold: 1); } } } diff --git a/Items/Potions/Alcohol/Everclear.cs b/Items/Potions/Alcohol/Everclear.cs index 677e4b775c..33e4888e93 100644 --- a/Items/Potions/Alcohol/Everclear.cs +++ b/Items/Potions/Alcohol/Everclear.cs @@ -27,7 +27,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(60f); - Item.value = Item.buyPrice(0, 2, 0, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 80); } } } diff --git a/Items/Potions/Alcohol/EvergreenGin.cs b/Items/Potions/Alcohol/EvergreenGin.cs index 86db743607..0453782cd2 100644 --- a/Items/Potions/Alcohol/EvergreenGin.cs +++ b/Items/Potions/Alcohol/EvergreenGin.cs @@ -27,7 +27,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(480f); - Item.value = Item.buyPrice(0, 5, 30, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 60); } } } diff --git a/Items/Potions/Alcohol/FabsolsVodka.cs b/Items/Potions/Alcohol/FabsolsVodka.cs index 4ca2edb060..0ba3d02d36 100644 --- a/Items/Potions/Alcohol/FabsolsVodka.cs +++ b/Items/Potions/Alcohol/FabsolsVodka.cs @@ -31,7 +31,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(900f); - Item.value = Item.buyPrice(0, 2, 60, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 30); } public override void AddRecipes() diff --git a/Items/Potions/Alcohol/Fireball.cs b/Items/Potions/Alcohol/Fireball.cs index d8b5cf82c3..a177520b66 100644 --- a/Items/Potions/Alcohol/Fireball.cs +++ b/Items/Potions/Alcohol/Fireball.cs @@ -27,7 +27,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(480f); - Item.value = Item.buyPrice(0, 2, 0, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 30); } } } diff --git a/Items/Potions/Alcohol/GrapeBeer.cs b/Items/Potions/Alcohol/GrapeBeer.cs index 36f309e56b..c1462f6d78 100644 --- a/Items/Potions/Alcohol/GrapeBeer.cs +++ b/Items/Potions/Alcohol/GrapeBeer.cs @@ -28,7 +28,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.healMana = 100; Item.consumable = true; Item.potion = true; - Item.value = Item.buyPrice(0, 0, 20, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 3); } public override void OnConsumeItem(Player player) diff --git a/Items/Potions/Alcohol/Margarita.cs b/Items/Potions/Alcohol/Margarita.cs index c3070a7bd8..04ebc3f9af 100644 --- a/Items/Potions/Alcohol/Margarita.cs +++ b/Items/Potions/Alcohol/Margarita.cs @@ -31,7 +31,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.potion = true; Item.healLife = 200; Item.healMana = 200; - Item.value = Item.buyPrice(0, 5, 30, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 60); } public override void OnConsumeItem(Player player) diff --git a/Items/Potions/Alcohol/Moonshine.cs b/Items/Potions/Alcohol/Moonshine.cs index 761978e62a..165545297f 100644 --- a/Items/Potions/Alcohol/Moonshine.cs +++ b/Items/Potions/Alcohol/Moonshine.cs @@ -27,7 +27,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(480f); - Item.value = Item.buyPrice(0, 1, 30, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(gold: 1); } } } diff --git a/Items/Potions/Alcohol/MoscowMule.cs b/Items/Potions/Alcohol/MoscowMule.cs index 68360b9557..10433f63b9 100644 --- a/Items/Potions/Alcohol/MoscowMule.cs +++ b/Items/Potions/Alcohol/MoscowMule.cs @@ -29,7 +29,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(480f); - Item.value = Item.buyPrice(0, 5, 30, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(gold: 1); } } } diff --git a/Items/Potions/Alcohol/OddMushroom.cs b/Items/Potions/Alcohol/OddMushroom.cs index 6ef47a0421..f3e1efa5f3 100644 --- a/Items/Potions/Alcohol/OddMushroom.cs +++ b/Items/Potions/Alcohol/OddMushroom.cs @@ -27,7 +27,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(3600f); - Item.value = Item.buyPrice(0, 50, 0, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(gold: 10); } public override void OnConsumeItem(Player player) diff --git a/Items/Potions/Alcohol/OldFashioned.cs b/Items/Potions/Alcohol/OldFashioned.cs index d1a68bde36..a440396e3d 100644 --- a/Items/Potions/Alcohol/OldFashioned.cs +++ b/Items/Potions/Alcohol/OldFashioned.cs @@ -31,7 +31,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(360f); - Item.value = Item.buyPrice(0, 5, 30, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 60); } } } diff --git a/Items/Potions/Alcohol/RedWine.cs b/Items/Potions/Alcohol/RedWine.cs index 5f3cc7a515..a0f4c67292 100644 --- a/Items/Potions/Alcohol/RedWine.cs +++ b/Items/Potions/Alcohol/RedWine.cs @@ -27,7 +27,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.healLife = 200; Item.consumable = true; Item.potion = true; - Item.value = Item.buyPrice(0, 0, 65, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 30); } public override bool? UseItem(Player player) diff --git a/Items/Potions/Alcohol/Rum.cs b/Items/Potions/Alcohol/Rum.cs index 3872d3d561..a6ac51a739 100644 --- a/Items/Potions/Alcohol/Rum.cs +++ b/Items/Potions/Alcohol/Rum.cs @@ -27,7 +27,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(480f); - Item.value = Item.buyPrice(0, 1, 30, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 30); } } } diff --git a/Items/Potions/Alcohol/Screwdriver.cs b/Items/Potions/Alcohol/Screwdriver.cs index c4636851ca..299d0ff7fb 100644 --- a/Items/Potions/Alcohol/Screwdriver.cs +++ b/Items/Potions/Alcohol/Screwdriver.cs @@ -27,7 +27,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(480f); - Item.value = Item.buyPrice(0, 4, 0, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 40); } } } diff --git a/Items/Potions/Alcohol/StarBeamRye.cs b/Items/Potions/Alcohol/StarBeamRye.cs index 8c920d9a0b..f279ce4f8d 100644 --- a/Items/Potions/Alcohol/StarBeamRye.cs +++ b/Items/Potions/Alcohol/StarBeamRye.cs @@ -27,7 +27,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(480f); - Item.value = Item.buyPrice(0, 4, 0, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 80); } } } diff --git a/Items/Potions/Alcohol/Tequila.cs b/Items/Potions/Alcohol/Tequila.cs index ac1c240cc0..3a87ad876d 100644 --- a/Items/Potions/Alcohol/Tequila.cs +++ b/Items/Potions/Alcohol/Tequila.cs @@ -29,7 +29,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(480f); - Item.value = Item.buyPrice(0, 1, 30, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 30); } } } diff --git a/Items/Potions/Alcohol/TequilaSunrise.cs b/Items/Potions/Alcohol/TequilaSunrise.cs index c3cbf82664..c6c181562c 100644 --- a/Items/Potions/Alcohol/TequilaSunrise.cs +++ b/Items/Potions/Alcohol/TequilaSunrise.cs @@ -28,7 +28,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(480f); - Item.value = Item.buyPrice(0, 6, 60, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(gold: 1); } } } diff --git a/Items/Potions/Alcohol/Vodka.cs b/Items/Potions/Alcohol/Vodka.cs index ce5fda48ed..56a28b6ecf 100644 --- a/Items/Potions/Alcohol/Vodka.cs +++ b/Items/Potions/Alcohol/Vodka.cs @@ -29,7 +29,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(480f); - Item.value = Item.buyPrice(0, 1, 30, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 40); } } } diff --git a/Items/Potions/Alcohol/Whiskey.cs b/Items/Potions/Alcohol/Whiskey.cs index 3a69589efd..1b79dd7714 100644 --- a/Items/Potions/Alcohol/Whiskey.cs +++ b/Items/Potions/Alcohol/Whiskey.cs @@ -29,7 +29,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.consumable = true; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(480f); - Item.value = Item.buyPrice(0, 1, 30, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 30); } } } diff --git a/Items/Potions/Alcohol/WhiteWine.cs b/Items/Potions/Alcohol/WhiteWine.cs index d640b9b56e..a75ba175dc 100644 --- a/Items/Potions/Alcohol/WhiteWine.cs +++ b/Items/Potions/Alcohol/WhiteWine.cs @@ -29,7 +29,8 @@ namespace CalamityMod.Items.Potions.Alcohol Item.healMana = 300; Item.buffType = ModContent.BuffType(); Item.buffTime = CalamityUtils.SecondsToFrames(300f); - Item.value = Item.buyPrice(0, 4, 0, 0); + // Cirrus overcharges: 10% sell value instead of 20% + Item.value = Item.sellPrice(silver: 40); } public override bool? UseItem(Player player) diff --git a/Items/SummonItems/AstralChunk.cs b/Items/SummonItems/AstralChunk.cs index c5094efa77..4a0116a906 100644 --- a/Items/SummonItems/AstralChunk.cs +++ b/Items/SummonItems/AstralChunk.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.SummonItems public new string LocalizationCategory => "Items.SummonItems"; public override void SetStaticDefaults() { - ItemID.Sets.SortingPriorityBossSpawns[Type] = 14; // Frost Moon + ItemID.Sets.SortingPriorityBossSpawns[Type] = 12; // Truffle Worm } public override void SetDefaults() diff --git a/Items/SummonItems/CharredIdol.cs b/Items/SummonItems/CharredIdol.cs index 69c33b9bfc..152bac38b9 100644 --- a/Items/SummonItems/CharredIdol.cs +++ b/Items/SummonItems/CharredIdol.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.SummonItems public new string LocalizationCategory => "Items.SummonItems"; public override void SetStaticDefaults() { - ItemID.Sets.SortingPriorityBossSpawns[Type] = 9; // Mechanical Skull + ItemID.Sets.SortingPriorityBossSpawns[Type] = 10; // Mechanical Skull } public override void SetDefaults() diff --git a/Items/SummonItems/CryoKey.cs b/Items/SummonItems/CryoKey.cs index 6fee06e1f8..a128adc1a4 100644 --- a/Items/SummonItems/CryoKey.cs +++ b/Items/SummonItems/CryoKey.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.SummonItems public new string LocalizationCategory => "Items.SummonItems"; public override void SetStaticDefaults() { - ItemID.Sets.SortingPriorityBossSpawns[Type] = 7; // Mechanical Eye + ItemID.Sets.SortingPriorityBossSpawns[Type] = 7; // Ocram's Razor (1 below Mechanical Eye) } public override void SetDefaults() diff --git a/Items/SummonItems/EyeofDesolation.cs b/Items/SummonItems/EyeofDesolation.cs index 7e66341a3c..f8e683b1bf 100644 --- a/Items/SummonItems/EyeofDesolation.cs +++ b/Items/SummonItems/EyeofDesolation.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.SummonItems public int spawnYAdd = 0; public override void SetStaticDefaults() { - ItemID.Sets.SortingPriorityBossSpawns[Type] = 10; // Pirate Map + ItemID.Sets.SortingPriorityBossSpawns[Type] = 11; // Pirate Map (1 above Mechanical Skull) } public override void SetDefaults() diff --git a/Items/SummonItems/OldPowerCell.cs b/Items/SummonItems/OldPowerCell.cs index 29ac9bf111..02c26ef26e 100644 --- a/Items/SummonItems/OldPowerCell.cs +++ b/Items/SummonItems/OldPowerCell.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { NPCID.Sets.MPAllowedEnemies[NPCID.Golem] = true; - ItemID.Sets.SortingPriorityBossSpawns[Type] = 15; // Lihzahrd Power Cell + ItemID.Sets.SortingPriorityBossSpawns[Type] = 16; // Lihzahrd Power Cell } public override void SetDefaults() diff --git a/Items/SummonItems/Portabulb.cs b/Items/SummonItems/Portabulb.cs index 0217cd7379..2f239988b5 100644 --- a/Items/SummonItems/Portabulb.cs +++ b/Items/SummonItems/Portabulb.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { NPCID.Sets.MPAllowedEnemies[NPCID.Plantera] = true; - ItemID.Sets.SortingPriorityBossSpawns[Type] = 11; // Truffle Worm + ItemID.Sets.SortingPriorityBossSpawns[Type] = 11; // Pirate Map (1 above Mechanical Skull) } public override void SetDefaults() diff --git a/Items/SummonItems/ProfanedShard.cs b/Items/SummonItems/ProfanedShard.cs index f5e1076208..e65cceda1b 100644 --- a/Items/SummonItems/ProfanedShard.cs +++ b/Items/SummonItems/ProfanedShard.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.SummonItems public override bool CanUseItem(Player player) { - return !NPC.AnyNPCs(ModContent.NPCType()) && (Main.dayTime || Main.remixWorld) && (player.ZoneHallow || player.ZoneUnderworldHeight) && !BossRushEvent.BossRushActive; + return !NPC.AnyNPCs(ModContent.NPCType()) && (player.ZoneHallow || player.ZoneUnderworldHeight) && !BossRushEvent.BossRushActive; } public override bool? UseItem(Player player) diff --git a/Items/SummonItems/SandstormsCore.cs b/Items/SummonItems/SandstormsCore.cs index 1426db53d5..32dba4f830 100644 --- a/Items/SummonItems/SandstormsCore.cs +++ b/Items/SummonItems/SandstormsCore.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.SummonItems public new string LocalizationCategory => "Items.SummonItems"; public override void SetStaticDefaults() { - ItemID.Sets.SortingPriorityBossSpawns[Type] = 12; // Frost Legion + ItemID.Sets.SortingPriorityBossSpawns[Type] = 13; // Frost Legion } public override void SetDefaults() diff --git a/Items/SummonItems/Seafood.cs b/Items/SummonItems/Seafood.cs index f6618275c1..4d780eb9e0 100644 --- a/Items/SummonItems/Seafood.cs +++ b/Items/SummonItems/Seafood.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.SummonItems public new string LocalizationCategory => "Items.SummonItems"; public override void SetStaticDefaults() { - ItemID.Sets.SortingPriorityBossSpawns[Type] = 8; // Mechanical Worm + ItemID.Sets.SortingPriorityBossSpawns[Type] = 9; // Mechanical Worm } public override void SetDefaults() diff --git a/Items/Tools/AcidwoodAxe.cs b/Items/Tools/AcidwoodAxe.cs new file mode 100644 index 0000000000..a14997a250 --- /dev/null +++ b/Items/Tools/AcidwoodAxe.cs @@ -0,0 +1,37 @@ +using CalamityMod.Items.Placeables; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Tools +{ + public class AcidwoodAxe : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + public override void SetDefaults() + { + Item.damage = 8; + Item.knockBack = 3f; + Item.useTime = 16; + Item.useAnimation = 23; + Item.axe = 55 / 5; + + Item.DamageType = DamageClass.Melee; + Item.width = 40; + Item.height = 32; + Item.useTurn = true; + Item.useStyle = ItemUseStyleID.Swing; + Item.value = CalamityGlobalItem.RarityWhiteBuyPrice; + Item.rare = ItemRarityID.White; + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Tools/AcidwoodAxe.png b/Items/Tools/AcidwoodAxe.png new file mode 100644 index 0000000000..55652b2c68 Binary files /dev/null and b/Items/Tools/AcidwoodAxe.png differ diff --git a/Items/Tools/AcidwoodHammer.cs b/Items/Tools/AcidwoodHammer.cs new file mode 100644 index 0000000000..fb19a29600 --- /dev/null +++ b/Items/Tools/AcidwoodHammer.cs @@ -0,0 +1,37 @@ +using CalamityMod.Items.Placeables; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Tools +{ + public class AcidwoodHammer : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + public override void SetDefaults() + { + Item.damage = 10; + Item.knockBack = 3.5f; + Item.useTime = 10; + Item.useAnimation = 20; + Item.hammer = 25; + + Item.DamageType = DamageClass.Melee; + Item.width = 40; + Item.height = 40; + Item.useTurn = true; + Item.useStyle = ItemUseStyleID.Swing; + Item.value = CalamityGlobalItem.RarityWhiteBuyPrice; + Item.rare = ItemRarityID.White; + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(8). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Tools/AcidwoodHammer.png b/Items/Tools/AcidwoodHammer.png new file mode 100644 index 0000000000..2ebde81d4b Binary files /dev/null and b/Items/Tools/AcidwoodHammer.png differ diff --git a/Items/Tools/AcidwoodPickaxe.cs b/Items/Tools/AcidwoodPickaxe.cs new file mode 100644 index 0000000000..986357d323 --- /dev/null +++ b/Items/Tools/AcidwoodPickaxe.cs @@ -0,0 +1,38 @@ +using CalamityMod.Items.Placeables; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Tools +{ + public class AcidwoodPickaxe : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + public override void SetDefaults() + { + Item.damage = 5; + Item.knockBack = 1f; + Item.useTime = 9; + Item.useAnimation = 18; + Item.pick = 40; + + Item.DamageType = DamageClass.Melee; + Item.width = 36; + Item.height = 36; + Item.useTurn = true; + Item.useStyle = ItemUseStyleID.Swing; + Item.value = CalamityGlobalItem.RarityWhiteBuyPrice; + Item.rare = ItemRarityID.White; + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(15). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Tools/AcidwoodPickaxe.png b/Items/Tools/AcidwoodPickaxe.png new file mode 100644 index 0000000000..800c0698de Binary files /dev/null and b/Items/Tools/AcidwoodPickaxe.png differ diff --git a/Items/Tools/DriftwoodAxe.cs b/Items/Tools/DriftwoodAxe.cs new file mode 100644 index 0000000000..0c772ac67e --- /dev/null +++ b/Items/Tools/DriftwoodAxe.cs @@ -0,0 +1,54 @@ +using CalamityMod.Items.Placeables; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Tools +{ + public class DriftwoodAxe : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + public override void SetDefaults() + { + Item.damage = 9; + Item.knockBack = 3.5f; + Item.useTime = 13; + Item.useAnimation = 30; + Item.axe = 60 / 5; + + Item.DamageType = DamageClass.Melee; + Item.width = 40; + Item.height = 34; + Item.useTurn = true; + Item.useStyle = ItemUseStyleID.Swing; + Item.value = CalamityGlobalItem.RarityWhiteBuyPrice; + Item.rare = ItemRarityID.White; + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + } + public override void MeleeEffects(Player player, Rectangle hitbox) + { + bool surface = player.Center.Y < Main.worldSurface * 16.0; + bool GetEffects = ((Main.raining && surface) || player.dripping || (player.wet && !player.lavaWet && !player.honeyWet)); + if (GetEffects) + { + int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 160); + Item.useTime = 7; + Item.useAnimation = 20; + } + else + { + Item.useTime = 13; + Item.useAnimation = 30; + } + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Tools/DriftwoodAxe.png b/Items/Tools/DriftwoodAxe.png new file mode 100644 index 0000000000..9fb519983f Binary files /dev/null and b/Items/Tools/DriftwoodAxe.png differ diff --git a/Items/Tools/DriftwoodHammer.cs b/Items/Tools/DriftwoodHammer.cs new file mode 100644 index 0000000000..56870482ce --- /dev/null +++ b/Items/Tools/DriftwoodHammer.cs @@ -0,0 +1,55 @@ +using CalamityMod.Items.Placeables; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Tools +{ + public class DriftwoodHammer : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + public override void SetDefaults() + { + Item.damage = 13; + Item.knockBack = 4f; + Item.useTime = 12; + Item.useAnimation = 31; + Item.hammer = 45; + + Item.DamageType = DamageClass.Melee; + Item.width = 40; + Item.height = 42; + Item.useTurn = true; + Item.useStyle = ItemUseStyleID.Swing; + Item.value = CalamityGlobalItem.RarityWhiteBuyPrice; + Item.rare = ItemRarityID.White; + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + } + public override void MeleeEffects(Player player, Rectangle hitbox) + { + bool surface = player.Center.Y < Main.worldSurface * 16.0; + bool GetEffects = ((Main.raining && surface) || player.dripping || (player.wet && !player.lavaWet && !player.honeyWet)); + if (GetEffects) + { + int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 160); + Item.useTime = 7; + Item.useAnimation = 21; + } + else + { + Item.useTime = 12; + Item.useAnimation = 31; + } + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(8). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Tools/DriftwoodHammer.png b/Items/Tools/DriftwoodHammer.png new file mode 100644 index 0000000000..aa27de07a6 Binary files /dev/null and b/Items/Tools/DriftwoodHammer.png differ diff --git a/Items/Tools/DriftwoodPickaxe.cs b/Items/Tools/DriftwoodPickaxe.cs new file mode 100644 index 0000000000..5fec674b3a --- /dev/null +++ b/Items/Tools/DriftwoodPickaxe.cs @@ -0,0 +1,54 @@ +using CalamityMod.Items.Placeables; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Tools +{ + public class DriftwoodPickaxe : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + public override void SetDefaults() + { + Item.damage = 7; + Item.knockBack = 1.5f; + Item.useTime = 9; + Item.useAnimation = 18; + Item.pick = 55; + + Item.DamageType = DamageClass.Melee; + Item.width = 38; + Item.height = 38; + Item.useTurn = true; + Item.useStyle = ItemUseStyleID.Swing; + Item.value = CalamityGlobalItem.RarityWhiteBuyPrice; + Item.rare = ItemRarityID.White; + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + } + public override void MeleeEffects(Player player, Rectangle hitbox) + { + bool surface = player.Center.Y < Main.worldSurface * 16.0; + bool GetEffects = ((Main.raining && surface) || player.dripping || (player.wet && !player.lavaWet && !player.honeyWet)); + if (GetEffects) + { + int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 160); + Item.useTime = 7; + Item.useAnimation = 14; + } + else + { + Item.useTime = 9; + Item.useAnimation = 18; + } + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(15). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Tools/DriftwoodPickaxe.png b/Items/Tools/DriftwoodPickaxe.png new file mode 100644 index 0000000000..8e7156c574 Binary files /dev/null and b/Items/Tools/DriftwoodPickaxe.png differ diff --git a/Items/Tools/MonolithAxe.cs b/Items/Tools/MonolithAxe.cs new file mode 100644 index 0000000000..5ed613a3d3 --- /dev/null +++ b/Items/Tools/MonolithAxe.cs @@ -0,0 +1,44 @@ +using CalamityMod.Dusts; +using CalamityMod.Items.Placeables; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Tools +{ + public class MonolithAxe : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + public override void SetDefaults() + { + Item.damage = 25; + Item.knockBack = 2f; + Item.useTime = 6; + Item.useAnimation = 8; + Item.axe = 75 / 5; + + Item.DamageType = DamageClass.Melee; + Item.width = 38; + Item.height = 36; + Item.useTurn = true; + Item.useStyle = ItemUseStyleID.Swing; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + } + public override void MeleeEffects(Player player, Rectangle hitbox) + { + if (Main.rand.NextBool(3)) + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType()); + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Tools/MonolithAxe.png b/Items/Tools/MonolithAxe.png new file mode 100644 index 0000000000..b87a887ee3 Binary files /dev/null and b/Items/Tools/MonolithAxe.png differ diff --git a/Items/Tools/MonolithHammer.cs b/Items/Tools/MonolithHammer.cs new file mode 100644 index 0000000000..aa50f8cb3d --- /dev/null +++ b/Items/Tools/MonolithHammer.cs @@ -0,0 +1,45 @@ +using CalamityMod.Dusts; +using CalamityMod.Items.Placeables; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Tools +{ + public class MonolithHammer : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + public override void SetDefaults() + { + Item.damage = 29; + Item.knockBack = 2.5f; + Item.useTime = 6; + Item.useAnimation = 9; + Item.hammer = 40; + + Item.DamageType = DamageClass.Melee; + Item.width = 46; + Item.height = 44; + Item.useTurn = true; + Item.useStyle = ItemUseStyleID.Swing; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + } + public override void MeleeEffects(Player player, Rectangle hitbox) + { + if (Main.rand.NextBool(3)) + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType()); + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(8). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Tools/MonolithHammer.png b/Items/Tools/MonolithHammer.png new file mode 100644 index 0000000000..c25333f352 Binary files /dev/null and b/Items/Tools/MonolithHammer.png differ diff --git a/Items/Tools/MonolithPickaxe.cs b/Items/Tools/MonolithPickaxe.cs new file mode 100644 index 0000000000..132c26cd51 --- /dev/null +++ b/Items/Tools/MonolithPickaxe.cs @@ -0,0 +1,44 @@ +using CalamityMod.Dusts; +using CalamityMod.Items.Placeables; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Tools +{ + public class MonolithPickaxe : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Tools"; + public override void SetDefaults() + { + Item.damage = 19; + Item.knockBack = 0.8f; + Item.useTime = 6; + Item.useAnimation = 6; + Item.pick = 70; + + Item.DamageType = DamageClass.Melee; + Item.width = 38; + Item.height = 40; + Item.useTurn = true; + Item.useStyle = ItemUseStyleID.Swing; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + } + public override void MeleeEffects(Player player, Rectangle hitbox) + { + if (Main.rand.NextBool(3)) + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType()); + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(15). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Tools/MonolithPickaxe.png b/Items/Tools/MonolithPickaxe.png new file mode 100644 index 0000000000..d4e945293c Binary files /dev/null and b/Items/Tools/MonolithPickaxe.png differ diff --git a/Items/VanillaArmorChanges/MythrilArmorSetChange.cs b/Items/VanillaArmorChanges/MythrilArmorSetChange.cs index c92a58262a..772fad8a35 100644 --- a/Items/VanillaArmorChanges/MythrilArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MythrilArmorSetChange.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public const int MaxManaBoost = 20; public const int FlareFrameSpawnDelay = 12; - public const int FlareDamageSoftcap = 50; + public const int FlareDamageSoftcap = 40; public override void UpdateSetBonusText(ref string setBonusText) { @@ -51,7 +51,7 @@ namespace CalamityMod.Items.VanillaArmorChanges // Reset the spawn delay. owner.Calamity().MythrilFlareSpawnCountdown = FlareFrameSpawnDelay; - int flareDamage = CalamityUtils.DamageSoftCap(originalDamage * 0.4, FlareDamageSoftcap); + int flareDamage = CalamityUtils.DamageSoftCap(originalDamage * 0.3, FlareDamageSoftcap); flareDamage = owner.ApplyArmorAccDamageBonusesTo(flareDamage); Vector2 flareSpawnPosition = victim.Center + Main.rand.NextVector2Circular(10f, 10f); diff --git a/Items/VanillaArmorChanges/NebulaArmorSetChange.cs b/Items/VanillaArmorChanges/NebulaArmorSetChange.cs new file mode 100644 index 0000000000..ebab9693fb --- /dev/null +++ b/Items/VanillaArmorChanges/NebulaArmorSetChange.cs @@ -0,0 +1,25 @@ +using System.Text; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.VanillaArmorChanges +{ + public class NebulaArmorSetChange : VanillaArmorChange + { + public override int? HeadPieceID => ItemID.NebulaHelmet; + + public override int? BodyPieceID => ItemID.NebulaBreastplate; + + public override int? LegPieceID => ItemID.NebulaLeggings; + + public override string ArmorSetName => "Nebula"; + + // The only thing this class does is change the set bonus text. + // Buff booster nerfs are handled separately as IL edits. + public override void UpdateSetBonusText(ref string setBonusText) + { + setBonusText += $"\n{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; + } + } +} diff --git a/Items/VanillaArmorChanges/PalladiumArmorSetChange.cs b/Items/VanillaArmorChanges/PalladiumArmorSetChange.cs index 7d0756257c..064aa47036 100644 --- a/Items/VanillaArmorChanges/PalladiumArmorSetChange.cs +++ b/Items/VanillaArmorChanges/PalladiumArmorSetChange.cs @@ -28,5 +28,10 @@ namespace CalamityMod.Items.VanillaArmorChanges { player.GetDamage() += LeggingsDamagePercentageBoost * 0.01f; } + + public override void UpdateSetBonusText(ref string setBonusText) + { + setBonusText = $"{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; + } } } diff --git a/Items/Weapons/DraedonsArsenal/PulsePistol.cs b/Items/Weapons/DraedonsArsenal/PulsePistol.cs index 04e2185db0..6c06402f6e 100644 --- a/Items/Weapons/DraedonsArsenal/PulsePistol.cs +++ b/Items/Weapons/DraedonsArsenal/PulsePistol.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.width = 62; Item.height = 22; Item.DamageType = DamageClass.Magic; - Item.damage = 23; + Item.damage = 27; Item.knockBack = 0f; Item.useTime = Item.useAnimation = 21; Item.autoReuse = true; diff --git a/Items/Weapons/DraedonsArsenal/Taser.cs b/Items/Weapons/DraedonsArsenal/Taser.cs index 52c92a47a3..1fb627359e 100644 --- a/Items/Weapons/DraedonsArsenal/Taser.cs +++ b/Items/Weapons/DraedonsArsenal/Taser.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.width = 50; Item.height = 26; Item.DamageType = DamageClass.Ranged; - Item.damage = 15; + Item.damage = 20; Item.knockBack = 0f; Item.useTime = Item.useAnimation = 28; Item.autoReuse = true; @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.rare = ItemRarityID.Orange; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 15f; + Item.shootSpeed = 25f; modItem.UsesCharge = true; modItem.MaxCharge = 50f; diff --git a/Items/Weapons/DraedonsArsenal/TrackingDisk.cs b/Items/Weapons/DraedonsArsenal/TrackingDisk.cs index f69d253b41..3292e3fc4b 100644 --- a/Items/Weapons/DraedonsArsenal/TrackingDisk.cs +++ b/Items/Weapons/DraedonsArsenal/TrackingDisk.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.width = 30; Item.height = 34; - Item.damage = 16; + Item.damage = 19; Item.DamageType = RogueDamageClass.Instance; Item.useTime = 40; Item.useAnimation = 40; diff --git a/Items/Weapons/Magic/AetherfluxCannon.cs b/Items/Weapons/Magic/AetherfluxCannon.cs index 11d3ad3d29..782fffeba9 100644 --- a/Items/Weapons/Magic/AetherfluxCannon.cs +++ b/Items/Weapons/Magic/AetherfluxCannon.cs @@ -39,11 +39,12 @@ namespace CalamityMod.Items.Weapons.Magic public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 shootVelocity = velocity; - Vector2 shootDirection = shootVelocity.SafeNormalize(Vector2.UnitX * player.direction); - Projectile.NewProjectile(source, position, shootDirection, type, damage, knockback, player.whoAmI); + Vector2 spawnPosition = player.RotatedRelativePoint(player.MountedCenter, true); + Projectile.NewProjectileDirect(source, spawnPosition, player.Calamity().mouseWorld - spawnPosition, ModContent.ProjectileType(), damage, knockback, player.whoAmI); return false; } diff --git a/Items/Weapons/Magic/Genesis.cs b/Items/Weapons/Magic/Genesis.cs index 3574304c4f..44c82b67ff 100644 --- a/Items/Weapons/Magic/Genesis.cs +++ b/Items/Weapons/Magic/Genesis.cs @@ -15,6 +15,7 @@ namespace CalamityMod.Items.Weapons.Magic public static float StarterWindup = 60f; public new string LocalizationCategory => "Items.Weapons.Magic"; + public override void SetDefaults() { Item.width = 108; @@ -44,7 +45,8 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0, 1); + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0, 0); + holdout.velocity = player.Calamity().mouseWorld - player.RotatedRelativePoint(player.MountedCenter); return false; } diff --git a/Items/Weapons/Magic/GloriousEnd.cs b/Items/Weapons/Magic/GloriousEnd.cs index 29c4d96f19..59db80cd1d 100644 --- a/Items/Weapons/Magic/GloriousEnd.cs +++ b/Items/Weapons/Magic/GloriousEnd.cs @@ -31,5 +31,7 @@ namespace CalamityMod.Items.Weapons.Magic } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + + public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; } } diff --git a/Items/Weapons/Magic/NanoPurge.cs b/Items/Weapons/Magic/NanoPurge.cs index 558c24ab99..a0522394b9 100644 --- a/Items/Weapons/Magic/NanoPurge.cs +++ b/Items/Weapons/Magic/NanoPurge.cs @@ -10,8 +10,9 @@ namespace CalamityMod.Items.Weapons.Magic [LegacyName("Purge")] public class NanoPurge : ModItem, ILocalizedModType { + public static int UseTime = 20; + public new string LocalizationCategory => "Items.Weapons.Magic"; - public const int UseTime = 20; public override void SetDefaults() { @@ -35,11 +36,12 @@ namespace CalamityMod.Items.Weapons.Magic public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 shootVelocity = velocity; - Vector2 shootDirection = shootVelocity.SafeNormalize(Vector2.UnitX * player.direction); - Projectile.NewProjectile(source, position, shootDirection, type, damage, knockback, player.whoAmI); + Vector2 spawnPosition = player.RotatedRelativePoint(player.MountedCenter, true); + Projectile.NewProjectileDirect(source, spawnPosition, player.Calamity().mouseWorld - spawnPosition, ModContent.ProjectileType(), damage, knockback, player.whoAmI); return false; } diff --git a/Items/Weapons/Magic/Omicron.cs b/Items/Weapons/Magic/Omicron.cs index 5028c9f3a0..2f5274a96d 100644 --- a/Items/Weapons/Magic/Omicron.cs +++ b/Items/Weapons/Magic/Omicron.cs @@ -1,4 +1,6 @@ -using CalamityMod.Items.Materials; +using CalamityMod.CalPlayer; +using CalamityMod.DataStructures; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -12,6 +14,10 @@ namespace CalamityMod.Items.Weapons.Magic { public class Omicron : ModItem, ILocalizedModType { + public static float FireRate = 15f; + public static float StarterWinup = 60f; + public static float WingmanFireRate = 10f; + public new string LocalizationCategory => "Items.Weapons.Magic"; public override void SetDefaults() @@ -37,7 +43,14 @@ namespace CalamityMod.Items.Weapons.Magic public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0 && player.ownedProjectileCounts[ModContent.ProjectileType()] < 2; // Makes the rotation of the mouse around the player sync in multiplayer. - public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; + public override void HoldItem(Player player) + { + CalamityPlayer calPlayer = player.Calamity(); + calPlayer.mouseWorldListener = true; + calPlayer.mouseRotationListener = true; + calPlayer.rightClickListener = true; + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { for (int i = 0; i < 2; i++) diff --git a/Items/Weapons/Magic/TheCauldron.cs b/Items/Weapons/Magic/TheCauldron.cs new file mode 100644 index 0000000000..c05c1dd41c --- /dev/null +++ b/Items/Weapons/Magic/TheCauldron.cs @@ -0,0 +1,79 @@ +using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Magic +{ + public class TheCauldron : ModItem, ILocalizedModType + { + float manaReductionMult = 0.2f; + public new string LocalizationCategory => "Items.Weapons.Magic"; + public static Asset Glow; + public override void SetStaticDefaults() + { + if (!Main.dedServ) + { + Glow = ModContent.Request(Texture + "Glow"); + } + } + public override void SetDefaults() + { + Item.width = 46; + Item.height = 46; + Item.damage = 59; + Item.noMelee = true; + Item.noUseGraphic = true; + Item.useStyle = ItemUseStyleID.Swing; + Item.useAnimation = 60; + Item.useTime = 60; + Item.knockBack = 8f; + Item.mana = 18; + Item.UseSound = SoundID.DD2_MonkStaffSwing; + Item.autoReuse = true; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 12f; + Item.DamageType = DamageClass.Magic; + Item.channel = true; + Item.Calamity().donorItem = true; + } + + // Reduce mana cost while in lava or the underworld + public override void ModifyManaCost(Player player, ref float reduce, ref float mult) + { + if (player.lavaWet || player.ZoneUnderworldHeight) + { + mult = manaReductionMult; + } + } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) + { + Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, Glow.Value); + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 46); + return false; + } + + public override void AddRecipes() + { + CreateRecipe() + .AddIngredient(ItemID.LavaBucket, 1) + .AddIngredient(ItemID.HellstoneBar, 8) + .AddIngredient(ItemID.Obsidian, 20) + .AddIngredient(ItemID.AshBlock, 20) + .AddTile(TileID.Anvils) + .Register(); + } + } +} diff --git a/Items/Weapons/Magic/TheCauldron.png b/Items/Weapons/Magic/TheCauldron.png new file mode 100644 index 0000000000..475a726020 Binary files /dev/null and b/Items/Weapons/Magic/TheCauldron.png differ diff --git a/Items/Weapons/Magic/TheCauldronGlow.png b/Items/Weapons/Magic/TheCauldronGlow.png new file mode 100644 index 0000000000..04cb3a66a5 Binary files /dev/null and b/Items/Weapons/Magic/TheCauldronGlow.png differ diff --git a/Items/Weapons/Magic/Tradewinds.cs b/Items/Weapons/Magic/Tradewinds.cs index 64a725372a..1119ef868d 100644 --- a/Items/Weapons/Magic/Tradewinds.cs +++ b/Items/Weapons/Magic/Tradewinds.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 28; Item.height = 30; - Item.damage = 23; + Item.damage = 27; Item.DamageType = DamageClass.Magic; Item.mana = 5; Item.useTime = 12; @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.UseSound = SoundID.Item7; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 20f; + Item.shootSpeed = 25.5f; } public override void AddRecipes() diff --git a/Items/Weapons/Magic/Wingman.cs b/Items/Weapons/Magic/Wingman.cs index 1526be5dd7..b4960be3d1 100644 --- a/Items/Weapons/Magic/Wingman.cs +++ b/Items/Weapons/Magic/Wingman.cs @@ -35,7 +35,12 @@ namespace CalamityMod.Items.Weapons.Magic public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] < 2; // Makes the rotation of the mouse around the player sync in multiplayer. - public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; + public override void HoldItem(Player player) + { + var modPlayer = player.Calamity(); + modPlayer.mouseRotationListener = true; + modPlayer.rightClickListener = true; + } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Melee/AcidwoodSword.cs b/Items/Weapons/Melee/AcidwoodSword.cs new file mode 100644 index 0000000000..3d8eaf9876 --- /dev/null +++ b/Items/Weapons/Melee/AcidwoodSword.cs @@ -0,0 +1,34 @@ +using CalamityMod.Items.Placeables; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + public class AcidwoodSword : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Melee"; + public override void SetDefaults() + { + Item.damage = 11; + Item.width = 36; + Item.height = 40; + Item.DamageType = DamageClass.Melee; + Item.useAnimation = Item.useTime = 18; + Item.useStyle = ItemUseStyleID.Swing; + Item.knockBack = 3f; + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + Item.useTurn = true; + Item.value = CalamityGlobalItem.RarityWhiteBuyPrice; + Item.rare = ItemRarityID.White; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(7). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Weapons/Melee/AcidwoodSword.png b/Items/Weapons/Melee/AcidwoodSword.png new file mode 100644 index 0000000000..cf8d56267c Binary files /dev/null and b/Items/Weapons/Melee/AcidwoodSword.png differ diff --git a/Items/Weapons/Melee/AirSpinner.cs b/Items/Weapons/Melee/AirSpinner.cs index 9fff13ee27..1ab080f85e 100644 --- a/Items/Weapons/Melee/AirSpinner.cs +++ b/Items/Weapons/Melee/AirSpinner.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = 28; Item.height = 28; Item.DamageType = DamageClass.MeleeNoSpeed; - Item.damage = 26; + Item.damage = 29; Item.knockBack = 4f; Item.useTime = 22; Item.useAnimation = 22; diff --git a/Items/Weapons/Melee/Aorta.cs b/Items/Weapons/Melee/Aorta.cs index 182dab333b..62b40b8710 100644 --- a/Items/Weapons/Melee/Aorta.cs +++ b/Items/Weapons/Melee/Aorta.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = 30; Item.height = 26; Item.DamageType = DamageClass.MeleeNoSpeed; - Item.damage = 29; + Item.damage = 31; Item.knockBack = 4.25f; Item.useTime = 22; Item.useAnimation = 22; diff --git a/Items/Weapons/Melee/Basher.cs b/Items/Weapons/Melee/Basher.cs index ae3d491e6c..f63ec86d3d 100644 --- a/Items/Weapons/Melee/Basher.cs +++ b/Items/Weapons/Melee/Basher.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 56; Item.height = 60; - Item.damage = 41; + Item.damage = 50; Item.DamageType = DamageClass.Melee; Item.useAnimation = Item.useTime = 40; Item.useStyle = ItemUseStyleID.Swing; diff --git a/Items/Weapons/Melee/DepthCrusher.cs b/Items/Weapons/Melee/DepthCrusher.cs index 1714581a67..86f994eb02 100644 --- a/Items/Weapons/Melee/DepthCrusher.cs +++ b/Items/Weapons/Melee/DepthCrusher.cs @@ -16,12 +16,12 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 56; Item.height = 50; - Item.damage = 35; + Item.damage = 48; Item.knockBack = 7.25f; Item.useTime = 65; Item.useAnimation = 65; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 3f; + Item.shootSpeed = 6f; Item.noMelee = true; Item.noUseGraphic = true; diff --git a/Items/Weapons/Melee/DriftwoodSword.cs b/Items/Weapons/Melee/DriftwoodSword.cs new file mode 100644 index 0000000000..57f1ca8924 --- /dev/null +++ b/Items/Weapons/Melee/DriftwoodSword.cs @@ -0,0 +1,53 @@ +using CalamityMod.Items.Placeables; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + public class DriftwoodSword : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Melee"; + public override void SetDefaults() + { + Item.damage = 14; + Item.width = 42; + Item.height = 46; + Item.DamageType = DamageClass.Melee; + Item.useAnimation = Item.useTime = 20; + Item.useStyle = ItemUseStyleID.Swing; + Item.knockBack = 4f; + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + Item.useTurn = true; + Item.value = CalamityGlobalItem.RarityWhiteBuyPrice; + Item.rare = ItemRarityID.White; + } + public override void MeleeEffects(Player player, Rectangle hitbox) + { + bool surface = player.Center.Y < Main.worldSurface * 16.0; + bool GetEffects = ((Main.raining && surface) || player.dripping || (player.wet && !player.lavaWet && !player.honeyWet)); + if (GetEffects) + { + int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 160); + Item.useTime = 12; + Item.useAnimation = 12; + Item.knockBack = 5.5f; + } + else + { + Item.useTime = 20; + Item.useAnimation = 20; + Item.knockBack = 4f; + } + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(7). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Weapons/Melee/DriftwoodSword.png b/Items/Weapons/Melee/DriftwoodSword.png new file mode 100644 index 0000000000..4a95e5f996 Binary files /dev/null and b/Items/Weapons/Melee/DriftwoodSword.png differ diff --git a/Items/Weapons/Melee/ElementalLance.cs b/Items/Weapons/Melee/ElementalLance.cs index 899b8a5f36..a4cf059a36 100644 --- a/Items/Weapons/Melee/ElementalLance.cs +++ b/Items/Weapons/Melee/ElementalLance.cs @@ -19,14 +19,14 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 88; Item.height = 88; - Item.damage = 160; + Item.damage = 240; Item.DamageType = DamageClass.Melee; Item.noMelee = true; Item.useTurn = true; Item.noUseGraphic = true; - Item.useAnimation = 30; + Item.useAnimation = 45; Item.useStyle = ItemUseStyleID.Shoot; - Item.useTime = 30; + Item.useTime = 45; Item.knockBack = 9.5f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; diff --git a/Items/Weapons/Melee/GoldplumeSpear.cs b/Items/Weapons/Melee/GoldplumeSpear.cs index d2b38a87c0..3bd09d84d9 100644 --- a/Items/Weapons/Melee/GoldplumeSpear.cs +++ b/Items/Weapons/Melee/GoldplumeSpear.cs @@ -18,14 +18,14 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 54; Item.height = 54; - Item.damage = 27; + Item.damage = 37; Item.DamageType = DamageClass.Melee; Item.noMelee = true; Item.useTurn = true; Item.noUseGraphic = true; - Item.useAnimation = 23; + Item.useAnimation = 28; Item.useStyle = ItemUseStyleID.Shoot; - Item.useTime = 23; + Item.useTime = 28; Item.knockBack = 5.75f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; diff --git a/Items/Weapons/Melee/GreatswordofJudgement.cs b/Items/Weapons/Melee/GreatswordofJudgement.cs index 1732260e9d..b2ded44e87 100644 --- a/Items/Weapons/Melee/GreatswordofJudgement.cs +++ b/Items/Weapons/Melee/GreatswordofJudgement.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 78; Item.height = 78; - Item.damage = 40; + Item.damage = 85; Item.DamageType = DamageClass.Melee; Item.useAnimation = 18; Item.useStyle = ItemUseStyleID.Swing; diff --git a/Items/Weapons/Melee/MonolithSword.cs b/Items/Weapons/Melee/MonolithSword.cs new file mode 100644 index 0000000000..3af19b0da7 --- /dev/null +++ b/Items/Weapons/Melee/MonolithSword.cs @@ -0,0 +1,54 @@ +using CalamityMod.Dusts; +using CalamityMod.Items.Placeables; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + public class MonolithSword : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Melee"; + public override void SetDefaults() + { + Item.damage = 30; + Item.width = 40; + Item.height = 46; + Item.DamageType = DamageClass.Melee; + Item.useAnimation = Item.useTime = 7; + Item.useStyle = ItemUseStyleID.Swing; + Item.knockBack = 4f; + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + Item.useTurn = true; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + } + public override void UseItemHitbox(Player player, ref Rectangle hitbox, ref bool noHitbox) + { + float scale = 2.5f; + Vector2 newSize = new Point(hitbox.Width, hitbox.Height).ToVector2() * scale; + hitbox = new Rectangle(hitbox.X - (int)((newSize.X - hitbox.Width) / 2f), hitbox.Y - (int)((newSize.Y - hitbox.Height) / 2f), (int)newSize.X, (int)newSize.Y); + } + public override void UseAnimation(Player player) + { + float Rot = (player.direction == -1 ? 5.5f : -5.5f) * Main.rand.NextFloat(0.99f, 1.1f); + Particle Smear = new SemiCircularSmearFade(player.Center, Vector2.Zero, (Main.rand.NextBool() ? Color.DarkTurquoise : Color.Coral) * 0.7f, Rot, Main.rand.NextFloat(1.48f, 1.53f), new Vector2(1, 1), 6, true, false, true); + GeneralParticleHandler.SpawnParticle(Smear); + } + public override void MeleeEffects(Player player, Rectangle hitbox) + { + if (Main.rand.NextBool(3)) + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType()); + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(7). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Weapons/Melee/MonolithSword.png b/Items/Weapons/Melee/MonolithSword.png new file mode 100644 index 0000000000..7448de2787 Binary files /dev/null and b/Items/Weapons/Melee/MonolithSword.png differ diff --git a/Items/Weapons/Melee/PerfectDark.cs b/Items/Weapons/Melee/PerfectDark.cs index 25216877bd..666b744d04 100644 --- a/Items/Weapons/Melee/PerfectDark.cs +++ b/Items/Weapons/Melee/PerfectDark.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 50; Item.height = 50; - Item.damage = 26; + Item.damage = 29; Item.DamageType = DamageClass.Melee; Item.useAnimation = 24; Item.useStyle = ItemUseStyleID.Swing; @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 12f; + Item.shootSpeed = 14.5f; } public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { diff --git a/Items/Weapons/Melee/PrismaticBreaker.cs b/Items/Weapons/Melee/PrismaticBreaker.cs index f86e75a993..81ad513f31 100644 --- a/Items/Weapons/Melee/PrismaticBreaker.cs +++ b/Items/Weapons/Melee/PrismaticBreaker.cs @@ -48,10 +48,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.useStyle = ItemUseStyleID.Swing; Item.useTime = Item.useAnimation = 13; Item.useTurn = true; - // TODO -- Prismatic Breaker should have its own damage type which is half Ranged, half Melee. - // Right now, it uses a hacky damage formula, see below. - // Its custom damage class should CountAs both melee AND ranged for the sake of effects. - Item.DamageType = DamageClass.Melee; + Item.DamageType = MeleeRangedHybridDamageClass.Instance; Item.knockBack = 7f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; @@ -65,12 +62,6 @@ namespace CalamityMod.Items.Weapons.Melee // Terraria seems to really dislike high crit values in SetDefaults public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 8; - public override void ModifyWeaponDamage(Player player, ref StatModifier damage) - { - StatModifier halfMelee = damage.Scale(0.5f); - damage = halfMelee.CombineWith(player.GetTotalDamage().Scale(0.5f)); - } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/Melee/PrismaticBreakerGlow").Value); @@ -80,11 +71,11 @@ namespace CalamityMod.Items.Weapons.Melee { if (player.altFunctionUse == 2) { - Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); } else { - Projectile.NewProjectile(source, position.X, position.Y, velocity.X * 0.5f, velocity.Y * 0.5f, type, (int)(damage * 1.1f), knockback, player.whoAmI); + Projectile.NewProjectile(source, position, velocity * 0.5f, type, (int)(damage * 1.1f), knockback, player.whoAmI); } return false; } diff --git a/Items/Weapons/Melee/Respiteblock.cs b/Items/Weapons/Melee/Respiteblock.cs new file mode 100644 index 0000000000..b7fff3656f --- /dev/null +++ b/Items/Weapons/Melee/Respiteblock.cs @@ -0,0 +1,54 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Melee; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + public class Respiteblock : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Melee"; + + public override void SetDefaults() + { + Item.width = 108; + Item.height = 40; + Item.damage = 70; + Item.knockBack = 9f; + Item.useTime = 10; + Item.useAnimation = 20; + // In-game, the displayed axe power is 5x the value set here. + // This corrects for trees having 500% hardness internally. + // So that the axe power in the code looks like the axe power you see on screen, divide by 5. + Item.axe = 610 / 5; + // The axe power is entirely for show. It instantly one shots trees. + // ***Axe Power is an integer which increments in 5s. So any number not divisible by 5 is impossible without tooltip modifications. + // See CalamityGlobalItemTooltip for axe power tooltip edit + + Item.DamageType = DamageClass.Melee; + Item.noMelee = true; + Item.noUseGraphic = true; + Item.channel = true; + Item.useStyle = ItemUseStyleID.Shoot; + Item.autoReuse = false; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 1f; + + Item.rare = ItemRarityID.Red; + Item.value = CalamityGlobalItem.RarityRedBuyPrice; + Item.Calamity().donorItem = true; + } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.ButchersChainsaw). + AddIngredient(ItemID.FragmentSolar, 4). // 413 is also a homestuck referene I think... + AddIngredient(13). + AddTile(TileID.LunarCraftingStation). + Register(); + } + } +} diff --git a/Items/Weapons/Melee/Respiteblock.png b/Items/Weapons/Melee/Respiteblock.png new file mode 100644 index 0000000000..8e3bfa165c Binary files /dev/null and b/Items/Weapons/Melee/Respiteblock.png differ diff --git a/Items/Weapons/Melee/TheDarkMaster.cs b/Items/Weapons/Melee/TheDarkMaster.cs index 5054b7ed5a..e37cb358fb 100644 --- a/Items/Weapons/Melee/TheDarkMaster.cs +++ b/Items/Weapons/Melee/TheDarkMaster.cs @@ -61,6 +61,13 @@ namespace CalamityMod.Items.Weapons.Melee { SoundEngine.PlaySound(SoundID.Item71, player.Center); } + + // force clones to shoot regardless of health + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == ModContent.ProjectileType() && p.owner == player.whoAmI) + p.ai[1] = 1f; + } } else { @@ -72,7 +79,9 @@ namespace CalamityMod.Items.Weapons.Melee // summon the clones. position is determined by ai[0] for (int i = 0; i < 3; i++) { - Projectile.NewProjectile(Item.GetSource_FromThis(), player.Center.X, player.Center.Y, 0, 0, ModContent.ProjectileType(), damage, knockback, player.whoAmI, i); + // Stats are set to dynamically update, so damage, kb, crit have to be feeded + Projectile clone = Projectile.NewProjectileDirect(Item.GetSource_FromThis(), player.Center, Vector2.Zero, ModContent.ProjectileType(), Item.damage, Item.knockBack, player.whoAmI, i); + clone.OriginalCritChance = Item.crit; } } } diff --git a/Items/Weapons/Melee/VeinBurster.cs b/Items/Weapons/Melee/VeinBurster.cs index fe8d0adf61..206efd2059 100644 --- a/Items/Weapons/Melee/VeinBurster.cs +++ b/Items/Weapons/Melee/VeinBurster.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 52; Item.height = 50; - Item.damage = 42; + Item.damage = 47; Item.DamageType = DamageClass.Melee; Item.useAnimation = 41; Item.useStyle = ItemUseStyleID.Swing; @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 13f; + Item.shootSpeed = 16f; } public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { diff --git a/Items/Weapons/Melee/WindBlade.cs b/Items/Weapons/Melee/WindBlade.cs index 8676601b68..1a580759cc 100644 --- a/Items/Weapons/Melee/WindBlade.cs +++ b/Items/Weapons/Melee/WindBlade.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 3f; + Item.shootSpeed = 5f; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Ranged/AcidwoodBow.cs b/Items/Weapons/Ranged/AcidwoodBow.cs new file mode 100644 index 0000000000..f57096b36e --- /dev/null +++ b/Items/Weapons/Ranged/AcidwoodBow.cs @@ -0,0 +1,48 @@ +using Terraria.DataStructures; +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using CalamityMod.Items.Placeables; + +namespace CalamityMod.Items.Weapons.Ranged +{ + public class AcidwoodBow : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Ranged"; + public override void SetDefaults() + { + Item.damage = 8; + Item.DamageType = DamageClass.Ranged; + Item.width = 20; + Item.height = 50; + Item.useTime = 27; + Item.useAnimation = 27; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.knockBack = 0f; + Item.value = CalamityGlobalItem.RarityWhiteBuyPrice; + Item.rare = ItemRarityID.White; + Item.UseSound = SoundID.Item5; + Item.autoReuse = true; + Item.shoot = ProjectileID.WoodenArrowFriendly; + Item.shootSpeed = 6.6f; + Item.useAmmo = AmmoID.Arrow; + Item.Calamity().canFirePointBlankShots = true; + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); + return false; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Weapons/Ranged/AcidwoodBow.png b/Items/Weapons/Ranged/AcidwoodBow.png new file mode 100644 index 0000000000..2fd33d341f Binary files /dev/null and b/Items/Weapons/Ranged/AcidwoodBow.png differ diff --git a/Items/Weapons/Ranged/Alluvion.cs b/Items/Weapons/Ranged/Alluvion.cs index 86ef655e99..a062ad960f 100644 --- a/Items/Weapons/Ranged/Alluvion.cs +++ b/Items/Weapons/Ranged/Alluvion.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 62; Item.height = 90; - Item.damage = 78; + Item.damage = 83; Item.DamageType = DamageClass.Ranged; Item.useTime = 15; Item.useAnimation = 30; diff --git a/Items/Weapons/Ranged/AngelicShotgun.cs b/Items/Weapons/Ranged/AngelicShotgun.cs index d2fce9bbca..bd1547fa45 100644 --- a/Items/Weapons/Ranged/AngelicShotgun.cs +++ b/Items/Weapons/Ranged/AngelicShotgun.cs @@ -21,14 +21,14 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 86; Item.height = 38; - Item.damage = 96; + Item.damage = 92; Item.knockBack = 3f; Item.DamageType = DamageClass.Ranged; Item.noMelee = true; Item.autoReuse = true; - Item.useTime = 24; - Item.useAnimation = 24; + Item.useTime = 26; + Item.useAnimation = 26; Item.UseSound = SoundID.Item38; Item.useStyle = ItemUseStyleID.Shoot; @@ -49,7 +49,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int NumBullets = Main.rand.Next(5, 8); + int NumBullets = Main.rand.Next(5, 6+1); Vector2 baseVelocity = velocity.SafeNormalize(Vector2.Zero) * BulletSpeed; // If Musket Balls are used, damage is set to match Hallow-Point Rounds for both bullets and lasers @@ -71,7 +71,7 @@ namespace CalamityMod.Items.Weapons.Ranged // Spawn a beam from the sky ala Deathhail Staff or Lunar Flare float laserSpeed = 8f; - int laserDamage = 3 * damage; + int laserDamage = (int)(damage * 2.5f); float laserKB = 5f; Vector2 rrp = player.RotatedRelativePoint(player.MountedCenter, true); diff --git a/Items/Weapons/Ranged/AquashardShotgun.cs b/Items/Weapons/Ranged/AquashardShotgun.cs index 55fe5c3db9..142c00c383 100644 --- a/Items/Weapons/Ranged/AquashardShotgun.cs +++ b/Items/Weapons/Ranged/AquashardShotgun.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.UseSound = SoundID.Item61; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 22f; + Item.shootSpeed = 30f; Item.useAmmo = AmmoID.Bullet; Item.Calamity().canFirePointBlankShots = true; } diff --git a/Items/Weapons/Ranged/ArcNovaDiffuser.cs b/Items/Weapons/Ranged/ArcNovaDiffuser.cs index c47d25ca28..2ce192c482 100644 --- a/Items/Weapons/Ranged/ArcNovaDiffuser.cs +++ b/Items/Weapons/Ranged/ArcNovaDiffuser.cs @@ -26,10 +26,8 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; - public override void SetStaticDefaults() - { - ItemID.Sets.IsRangedSpecialistWeapon[Item.type] = true; - } + public override void SetStaticDefaults() => ItemID.Sets.IsRangedSpecialistWeapon[Type] = true; + public override void SetDefaults() { Item.width = 58; @@ -53,6 +51,15 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0, 1); + holdout.velocity = player.Calamity().mouseWorld - player.RotatedRelativePoint(player.MountedCenter); + return false; + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/Arietes41.cs b/Items/Weapons/Ranged/Arietes41.cs index be78f5ede0..17bcbe0b77 100644 --- a/Items/Weapons/Ranged/Arietes41.cs +++ b/Items/Weapons/Ranged/Arietes41.cs @@ -5,6 +5,7 @@ using CalamityMod.Projectiles; using Microsoft.CodeAnalysis; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -30,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.knockBack = 2.5f; Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; - Item.UseSound = SoundID.Item41; + Item.UseSound = Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/GunShotSmall") with { Volume = 0.65f }; Item.autoReuse = true; Item.shootSpeed = 13f; Item.shoot = ProjectileID.PurificationPowder; diff --git a/Items/Weapons/Ranged/BladedgeRailbow.cs b/Items/Weapons/Ranged/BladedgeRailbow.cs index ebf3c143c0..c870e43a22 100644 --- a/Items/Weapons/Ranged/BladedgeRailbow.cs +++ b/Items/Weapons/Ranged/BladedgeRailbow.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; #region GFB Arrow Array - public int[] arrowArr = + public static int[] arrowArr = { ProjectileID.WoodenArrowFriendly, ProjectileID.FireArrow, @@ -143,7 +143,7 @@ namespace CalamityMod.Items.Weapons.Ranged int projType; if (Main.zenithWorld) - projType = arrowArr[Main.rand.Next(0, arrowArr.Length)]; + projType = arrowArr[Main.rand.Next(arrowArr.Length)]; else projType = ProjectileID.Leaf; diff --git a/Items/Weapons/Ranged/Butcher.png b/Items/Weapons/Ranged/Butcher.png deleted file mode 100644 index 49ddff2d33..0000000000 Binary files a/Items/Weapons/Ranged/Butcher.png and /dev/null differ diff --git a/Items/Weapons/Ranged/Butcher.cs b/Items/Weapons/Ranged/Buzzkill.cs similarity index 57% rename from Items/Weapons/Ranged/Butcher.cs rename to Items/Weapons/Ranged/Buzzkill.cs index 48ec12ad69..a8af69f6c4 100644 --- a/Items/Weapons/Ranged/Butcher.cs +++ b/Items/Weapons/Ranged/Buzzkill.cs @@ -1,5 +1,4 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -8,51 +7,56 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class Butcher : ModItem, ILocalizedModType + [LegacyName("Butcher")] + public class Buzzkill : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public override void SetStaticDefaults() + { + ItemID.Sets.IsRangedSpecialistWeapon[Item.type] = true; + } + public override void SetDefaults() { - Item.width = 20; - Item.height = 12; - Item.damage = 15; - Item.useTime = 40; - Item.useAnimation = 40; + Item.width = 76; + Item.height = 42; + Item.damage = 50; + Item.useTime = 30; + Item.useAnimation = 30; Item.useStyle = ItemUseStyleID.Shoot; Item.knockBack = 1f; Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; Item.rare = ItemRarityID.LightRed; - Item.UseSound = SoundID.Item38; Item.noMelee = true; Item.noUseGraphic = true; Item.DamageType = DamageClass.Ranged; Item.channel = true; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 12f; - Item.useAmmo = AmmoID.Bullet; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 20f; Item.Calamity().canFirePointBlankShots = true; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + // Terraria seems to really dislike high crit values in SetDefaults + public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 21; - // Spawning the holdout cannot consume ammo - public override bool CanConsumeAmmo(Item ammo, Player player) => !Main.rand.NextBool(4) && player.ownedProjectileCounts[Item.shoot] > 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); + // The holdout deals 1.5x base damage. + Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), (int)(damage * 1.5), knockback, player.whoAmI); return false; } public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.Shotgun). AddIngredient(ItemID.IllegalGunParts). - AddRecipeGroup("AnyCobaltBar", 5). - AddIngredient(4). - AddTile(TileID.Anvils). + AddIngredient(ItemID.Cog, 15). + AddIngredient(ItemID.SoulofFright, 10). + AddTile(TileID.MythrilAnvil). Register(); } } diff --git a/Items/Weapons/Ranged/Buzzkill.png b/Items/Weapons/Ranged/Buzzkill.png new file mode 100644 index 0000000000..7ec3235634 Binary files /dev/null and b/Items/Weapons/Ranged/Buzzkill.png differ diff --git a/Items/Weapons/Ranged/ClockGatlignum.cs b/Items/Weapons/Ranged/ClockGatlignum.cs index 47e81821e0..422f865ff1 100644 --- a/Items/Weapons/Ranged/ClockGatlignum.cs +++ b/Items/Weapons/Ranged/ClockGatlignum.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.Calamity().canFirePointBlankShots = true; } - public override Vector2? HoldoutOffset() => new Vector2(-5, 0); + public override Vector2? HoldoutOffset() => new Vector2(-14, 0); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Ranged/ClockGatlignum.png b/Items/Weapons/Ranged/ClockGatlignum.png index b3ec232734..d9483a7d49 100644 Binary files a/Items/Weapons/Ranged/ClockGatlignum.png and b/Items/Weapons/Ranged/ClockGatlignum.png differ diff --git a/Items/Weapons/Ranged/Condemnation.cs b/Items/Weapons/Ranged/Condemnation.cs index 9f80655ae3..8adb29a61a 100644 --- a/Items/Weapons/Ranged/Condemnation.cs +++ b/Items/Weapons/Ranged/Condemnation.cs @@ -44,10 +44,15 @@ namespace CalamityMod.Items.Weapons.Ranged public override void HoldItem(Player player) { - if (Main.myPlayer == player.whoAmI) - player.Calamity().rightClickListener = true; + var calPlayer = player.Calamity(); - if (player.Calamity().mouseRight && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) + if (Main.myPlayer == player.whoAmI) + { + calPlayer.rightClickListener = true; + calPlayer.mouseRotationListener = true; + } + + if (calPlayer.mouseRight && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) { Item.noUseGraphic = false; } diff --git a/Items/Weapons/Ranged/Disseminator.cs b/Items/Weapons/Ranged/Disseminator.cs index a777199c5a..255bbf4bc3 100644 --- a/Items/Weapons/Ranged/Disseminator.cs +++ b/Items/Weapons/Ranged/Disseminator.cs @@ -14,10 +14,10 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 66; Item.height = 24; - Item.damage = 58; + Item.damage = 61; Item.DamageType = DamageClass.Ranged; - Item.useTime = 35; - Item.useAnimation = 35; + Item.useTime = 32; + Item.useAnimation = 32; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 4.5f; diff --git a/Items/Weapons/Ranged/DragonsBreath.cs b/Items/Weapons/Ranged/DragonsBreath.cs index ec7d6f4b76..c3162d97ca 100644 --- a/Items/Weapons/Ranged/DragonsBreath.cs +++ b/Items/Weapons/Ranged/DragonsBreath.cs @@ -22,14 +22,13 @@ namespace CalamityMod.Items.Weapons.Ranged public SlotId WeldSoundSlot; - public int BetweenShotsPause = 14; - public float Counter = 2; - public float MaxFirerateShots = 20; - public float WeldingShots = 50; - public bool StrongShotMode = false; - public int DragonsBreathSetUseTime = 5; - public int DragonsBreathSetUseAnimation = 9; - private Player Owner; + public static int BaseReuseDelay = 14; + public static int MinReuseDelay = 4; + public static int ShotsToMaxFirerate = 20; + public static int ShotsToFireBeams = ShotsToMaxFirerate + 20; + public static int ShotsToReset = ShotsToFireBeams + 50; + + public int Counter = 0; public override void SetDefaults() { @@ -37,9 +36,9 @@ namespace CalamityMod.Items.Weapons.Ranged Item.height = 72; Item.damage = 478; Item.DamageType = DamageClass.Ranged; - Item.useTime = DragonsBreathSetUseTime; - Item.useAnimation = DragonsBreathSetUseAnimation; - Item.reuseDelay = BetweenShotsPause; + Item.useTime = 5; + Item.useAnimation = 9; + Item.reuseDelay = BaseReuseDelay; Item.autoReuse = true; Item.useStyle = ItemUseStyleID.Shoot; @@ -53,69 +52,58 @@ namespace CalamityMod.Items.Weapons.Ranged Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; } - public override bool CanConsumeAmmo(Item ammo, Player player) => !StrongShotMode && Main.rand.NextFloat() > 0.80f; + public override bool CanConsumeAmmo(Item ammo, Player player) => Counter < ShotsToFireBeams && Main.rand.NextFloat() > 0.80f; - public override Vector2? HoldoutOffset() => new Vector2(27, 10); + public override Vector2? HoldoutOffset() => new Vector2(27, 6); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (!StrongShotMode) + Counter++; + if (Counter < ShotsToFireBeams) { - if (Counter == 2) + if (Counter % 2 == 1) SoundEngine.PlaySound(FireballSound, player.Center); + Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(2.5f)); Projectile.NewProjectile(source, position, newVel * Main.rand.NextFloat(1.2f, 0.8f), type, damage, knockback, player.whoAmI); - Counter--; - if (MaxFirerateShots > 0 && BetweenShotsPause == 4) - MaxFirerateShots--; - if (Counter <= 0) - { - if (BetweenShotsPause > 4) - { - BetweenShotsPause -= 1; - Item.reuseDelay = BetweenShotsPause; - } - Counter = 2; - } - if (BetweenShotsPause <= 4 && MaxFirerateShots == 0) - { - BetweenShotsPause = 0; - Item.reuseDelay = BetweenShotsPause; - StrongShotMode = true; - DragonsBreathSetUseTime = 2; - DragonsBreathSetUseAnimation = 2; - SoundEngine.PlaySound(WeldingStart, player.Center); - } + Item.reuseDelay = (int)Utils.Remap(Counter, 0, ShotsToMaxFirerate, BaseReuseDelay, MinReuseDelay); } - else if (StrongShotMode) + else { + if (Counter == ShotsToFireBeams) + SoundEngine.PlaySound(WeldingStart, player.Center); + if (SoundEngine.TryGetActiveSound(WeldSoundSlot, out var WeldSound) && WeldSound.IsPlaying) WeldSound.Position = player.Center; - if ((player.Calamity().DragonsBreathAudioCooldown2 == 0) && (WeldingShots < 45)) + if (player.Calamity().DragonsBreathAudioCooldown2 == 0 && Counter >= ShotsToFireBeams + 5) { player.Calamity().DragonsBreathAudioCooldown2 = 30; WeldSoundSlot = SoundEngine.PlaySound(WeldingShoot, player.Center); } - Projectile.NewProjectile(source, position, velocity * 2f, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 1); - WeldingShots--; - if (WeldingShots <= 0) + + Projectile.NewProjectile(source, position, velocity * 2f, type, damage, knockback, player.whoAmI, 1); + Item.reuseDelay = 0; + + if (Counter >= ShotsToReset) { - Counter = 2; - BetweenShotsPause = 14; - Item.reuseDelay = BetweenShotsPause; + Counter = 0; + Item.reuseDelay = BaseReuseDelay; SoundEngine.PlaySound(SpeedBlaster.Empty, player.Center); Projectile.NewProjectile(source, player.Center, new Vector2(5 * -player.direction, -5), ModContent.ProjectileType(), Main.zenithWorld ? 250000 : 1, knockback, player.whoAmI); - MaxFirerateShots = 20; - WeldingShots = 50; WeldSound?.Stop(); - StrongShotMode = false; - DragonsBreathSetUseTime = 5; - DragonsBreathSetUseAnimation = 9; } } return false; } + + public override void UpdateInventory(Player player) + { + // Reset speed back to initial once swapped to another item (including one of itself) + if (player.ActiveItem() != Item) + Counter = 0; + } + public override void UseStyle(Player player, Rectangle heldItemFrame) { player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); @@ -137,7 +125,7 @@ namespace CalamityMod.Items.Weapons.Ranged float animProgress = 0.5f - player.itemTime / (float)player.itemTimeMax; float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; if (animProgress < 0.4f) - rotation += StrongShotMode && WeldingShots == 1 ? -0.25f * (float)Math.Pow((0.6f - animProgress) / 0.6f, 2) * player.direction : 0; + rotation += Counter == 0 ? -0.25f * (float)Math.Pow((0.6f - animProgress) / 0.6f, 2) * player.direction : 0; player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); } diff --git a/Items/Weapons/Ranged/DriftwoodBow.cs b/Items/Weapons/Ranged/DriftwoodBow.cs new file mode 100644 index 0000000000..f79dfada00 --- /dev/null +++ b/Items/Weapons/Ranged/DriftwoodBow.cs @@ -0,0 +1,68 @@ +using CalamityMod.Items.Placeables; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Ranged +{ + public class DriftwoodBow : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Ranged"; + public override void SetDefaults() + { + Item.damage = 10; + Item.DamageType = DamageClass.Ranged; + Item.width = 22; + Item.height = 42; + Item.useTime = 28; + Item.useAnimation = 28; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.knockBack = 0f; + Item.value = CalamityGlobalItem.RarityWhiteBuyPrice; + Item.rare = ItemRarityID.White; + Item.UseSound = SoundID.Item5; + Item.autoReuse = true; + Item.shoot = ProjectileID.WoodenArrowFriendly; + Item.shootSpeed = 6.6f; + Item.useAmmo = AmmoID.Arrow; + Item.Calamity().canFirePointBlankShots = true; + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + bool surface = player.Center.Y < Main.worldSurface * 16.0; + bool GetEffects = ((Main.raining && surface) || player.dripping || (player.wet && !player.lavaWet && !player.honeyWet)); + if (GetEffects) + { + for (int i = 0; i <= 18; i++) + { + Dust dust = Dust.NewDustPerfect(position + velocity * 3, 160, velocity.RotatedByRandom(MathHelper.ToRadians(19f)) * Main.rand.NextFloat(0.8f, 3.8f), 0, default, Main.rand.NextFloat(1.2f, 1.6f)); + dust.noGravity = true; + } + Item.useTime = 23; + Item.useAnimation = 23; + Item.knockBack = 1f; + Item.shootSpeed = 8.6f; + } + else + { + Item.useTime = 28; + Item.useAnimation = 28; + Item.knockBack = 0f; + Item.shootSpeed = 6.6f; + } + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); + return false; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Weapons/Ranged/DriftwoodBow.png b/Items/Weapons/Ranged/DriftwoodBow.png new file mode 100644 index 0000000000..e6ecd72f56 Binary files /dev/null and b/Items/Weapons/Ranged/DriftwoodBow.png differ diff --git a/Items/Weapons/Ranged/ElementalBlaster.cs b/Items/Weapons/Ranged/ElementalBlaster.cs deleted file mode 100644 index 50c96f5885..0000000000 --- a/Items/Weapons/Ranged/ElementalBlaster.cs +++ /dev/null @@ -1,53 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Ranged; -using CalamityMod.Sounds; -using Microsoft.Xna.Framework; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Ranged -{ - public class ElementalBlaster : ModItem, ILocalizedModType - { - public new string LocalizationCategory => "Items.Weapons.Ranged"; - - public override void SetStaticDefaults() - { - ItemID.Sets.IsRangedSpecialistWeapon[Item.type] = true; - } - public override void SetDefaults() - { - Item.width = 104; - Item.height = 42; - Item.damage = 67; - Item.DamageType = DamageClass.Ranged; - Item.useTime = 2; - Item.useAnimation = 6; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; - Item.knockBack = 1.75f; - Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; - Item.rare = ItemRarityID.Purple; - Item.UseSound = CommonCalamitySounds.PlasmaBoltSound; - Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 18f; - } - - public override Vector2? HoldoutOffset() - { - return new Vector2(-15, 0); - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(ItemID.LunarBar, 5). - AddIngredient(5). - AddIngredient(5). - AddTile(TileID.LunarCraftingStation). - Register(); - } - } -} diff --git a/Items/Weapons/Ranged/ElementalBlaster.png b/Items/Weapons/Ranged/ElementalBlaster.png deleted file mode 100644 index 3ce7de1a2c..0000000000 Binary files a/Items/Weapons/Ranged/ElementalBlaster.png and /dev/null differ diff --git a/Items/Weapons/Ranged/ElementalEruption.cs b/Items/Weapons/Ranged/ElementalEruption.cs index 8c8449aafd..e282838825 100644 --- a/Items/Weapons/Ranged/ElementalEruption.cs +++ b/Items/Weapons/Ranged/ElementalEruption.cs @@ -14,10 +14,7 @@ namespace CalamityMod.Items.Weapons.Ranged public int FlareCounter = 0; - public override void SetStaticDefaults() - { - ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; - } + public override void SetStaticDefaults() => ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; public override void SetDefaults() { @@ -41,13 +38,18 @@ namespace CalamityMod.Items.Weapons.Ranged } public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; + // Spawning the holdout cannot consume ammo public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile.NewProjectile(source, position, Vector2.Zero, type, 0, 0f, player.whoAmI); + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0, 1); + holdout.velocity = player.Calamity().mouseWorld - player.RotatedRelativePoint(player.MountedCenter); return false; } diff --git a/Items/Weapons/Ranged/Eviscerator.cs b/Items/Weapons/Ranged/Eviscerator.cs index 75849b1bb2..9dacc5018b 100644 --- a/Items/Weapons/Ranged/Eviscerator.cs +++ b/Items/Weapons/Ranged/Eviscerator.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 58; Item.height = 22; - Item.damage = 65; + Item.damage = 70; Item.DamageType = DamageClass.Ranged; Item.useTime = 60; Item.useAnimation = 60; diff --git a/Items/Weapons/Ranged/FetidEmesis.cs b/Items/Weapons/Ranged/FetidEmesis.cs index ca3cddecaf..e31d61bab4 100644 --- a/Items/Weapons/Ranged/FetidEmesis.cs +++ b/Items/Weapons/Ranged/FetidEmesis.cs @@ -2,7 +2,6 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -16,15 +15,17 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 76; Item.height = 46; - Item.damage = 129; + Item.damage = 239; Item.DamageType = DamageClass.Ranged; Item.useTime = Item.useAnimation = 6; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 3f; - Item.UseSound = SoundID.Item11; + Item.knockBack = 5f; + Item.UseSound = null; + Item.noUseGraphic = true; + Item.channel = true; Item.autoReuse = true; - Item.shoot = ProjectileID.PurificationPowder; + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 16f; Item.useAmmo = AmmoID.Bullet; @@ -32,32 +33,15 @@ namespace CalamityMod.Items.Weapons.Ranged Item.rare = ModContent.RarityType(); Item.Calamity().canFirePointBlankShots = true; } - - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) > 40; - - public override Vector2? HoldoutOffset() => new Vector2(-5, 0); - + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (Main.rand.NextBool(8)) - { - Projectile.NewProjectile(source, position, velocity * 0.8f, - ModContent.ProjectileType(), damage, knockback, player.whoAmI); - for (int i = 0; i < 5; i++) - { - Dust dust = Dust.NewDustDirect(position, 10, 10, DustID.Shadowflame); - dust.velocity = Vector2.Normalize(velocity).RotatedByRandom(MathHelper.ToRadians(15f)); - dust.noGravity = true; - } - if (player.Calamity().soundCooldown <= 0) - { - // WoF vomit sound. - SoundEngine.PlaySound(SoundID.NPCDeath13 with { Volume = SoundID.NPCDeath13.Volume * 0.5f }, position); - player.Calamity().soundCooldown = 120; - } - return false; - } - return true; + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + + // We set the rotation to the direction to the mouse so the first frame doesn't appear bugged out. + holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); + return false; } } } diff --git a/Items/Weapons/Ranged/FrostbiteBlaster.cs b/Items/Weapons/Ranged/FrostbiteBlaster.cs index 470c62ed7a..38f5f1dca7 100644 --- a/Items/Weapons/Ranged/FrostbiteBlaster.cs +++ b/Items/Weapons/Ranged/FrostbiteBlaster.cs @@ -34,6 +34,8 @@ namespace CalamityMod.Items.Weapons.Ranged Item.Calamity().canFirePointBlankShots = true; } + public override Vector2? HoldoutOffset() => new Vector2(-14, 0); + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { SoundEngine.PlaySound(SoundID.Item36, position); diff --git a/Items/Weapons/Ranged/HavocsBreath.cs b/Items/Weapons/Ranged/HavocsBreath.cs index efad9edd1e..fa23d2cd9b 100644 --- a/Items/Weapons/Ranged/HavocsBreath.cs +++ b/Items/Weapons/Ranged/HavocsBreath.cs @@ -20,6 +20,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useTime = 5; Item.useAnimation = 35; Item.reuseDelay = 20; + Item.useLimitPerAnimation = 7; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1.5f; diff --git a/Items/Weapons/Ranged/Infinity.cs b/Items/Weapons/Ranged/Infinity.cs index 0a3822976f..31868841d0 100644 --- a/Items/Weapons/Ranged/Infinity.cs +++ b/Items/Weapons/Ranged/Infinity.cs @@ -1,4 +1,6 @@ -using CalamityMod.Items.Materials; +using System; +using CalamityMod.Items.Materials; +using CalamityMod.Particles; using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -13,8 +15,7 @@ namespace CalamityMod.Items.Weapons.Ranged public class Infinity : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - internal int rotation = 0; - internal bool limit = true; + public int SineCounter = 0; public override void SetStaticDefaults() { ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; @@ -24,12 +25,10 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 56; Item.height = 24; - Item.damage = 110; + Item.damage = 85; Item.DamageType = DamageClass.Ranged; - Item.useTime = 2; - Item.useAnimation = 12; - Item.reuseDelay = 12; - Item.useLimitPerAnimation = 9; + Item.useTime = 1; + Item.useAnimation = 4; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1f; @@ -38,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.UseSound = SoundID.Item31; Item.autoReuse = true; Item.shoot = ProjectileID.PurificationPowder; - Item.shootSpeed = 12f; + Item.shootSpeed = 6f; Item.useAmmo = AmmoID.Bullet; Item.Calamity().canFirePointBlankShots = true; } @@ -55,63 +54,30 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.altFunctionUse == 2) + int shotType = (player.altFunctionUse == 2 ? type : ModContent.ProjectileType()); + position = position + (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.UnitX) * 65; + float sine = (float)Math.Sin(SineCounter * 0.175f / MathHelper.Pi) * 3.5f; + SineCounter++; + if (SineCounter % 4 == 0) { - //If you right click, shoots a helix of normal bullets - Vector2 helixVel1 = velocity.RotatedBy(MathHelper.ToRadians(rotation)); - Vector2 helixVel2 = velocity.RotatedBy(MathHelper.ToRadians(-rotation)); - int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, type, damage, knockback, player.whoAmI, 0f, 0f); - Main.projectile[shot1].timeLeft = 180; - int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, type, damage, knockback, player.whoAmI, 0f, 0f); - Main.projectile[shot2].timeLeft = 180; - //Code to constantly make the shooting go side to side to make the helix - if (limit) - { - rotation += 2; - } - else - { - rotation -= 2; - } - if (rotation >= 11) - { - limit = false; - } - else if (rotation <= -11) - { - limit = true; - } - return false; + Vector2 helixVel1 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine)); + Vector2 helixVel2 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(-sine)); + int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, 1f); + int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, 1f); } - else + else if (player.altFunctionUse != 2) { - //If left click, do the same as above but spawn Charged Blasts instead - Vector2 helixVel1 = velocity.RotatedBy(MathHelper.ToRadians(rotation)); - Vector2 helixVel2 = velocity.RotatedBy(MathHelper.ToRadians(-rotation)); - int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); - Main.projectile[shot1].timeLeft = 180; - int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); - Main.projectile[shot2].timeLeft = 180; - if (limit) - { - rotation += 2; - } - else - { - rotation -= 2; - } - if (rotation >= 11) - { - limit = false; - } - else if (rotation <= -11) - { - limit = true; - } - return false; + Particle spark2 = new LineParticle(position + Main.rand.NextVector2Circular(6, 6), (velocity * 4).RotatedByRandom(0.2f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(15, 25 + 1), Main.rand.NextFloat(1.5f, 2f), new Color(229, 49, 39)); + GeneralParticleHandler.SpawnParticle(spark2); } + return false; + } + public override bool CanConsumeAmmo(Item ammo, Player player) + { + if (Main.rand.Next(0, 100) > 80 && SineCounter % 4 == 0) + return true; + return false; } - public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/Leviatitan.cs b/Items/Weapons/Ranged/Leviatitan.cs index 2e83fff9d7..2130046725 100644 --- a/Items/Weapons/Ranged/Leviatitan.cs +++ b/Items/Weapons/Ranged/Leviatitan.cs @@ -14,10 +14,10 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 82; Item.height = 28; - Item.damage = 80; + Item.damage = 77; Item.DamageType = DamageClass.Ranged; - Item.useTime = 9; - Item.useAnimation = 9; + Item.useTime = 10; + Item.useAnimation = 10; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 5f; diff --git a/Items/Weapons/Ranged/MagnaCannon.cs b/Items/Weapons/Ranged/MagnaCannon.cs index 4a320fba08..aa926fe2ab 100644 --- a/Items/Weapons/Ranged/MagnaCannon.cs +++ b/Items/Weapons/Ranged/MagnaCannon.cs @@ -22,10 +22,8 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; - public override void SetStaticDefaults() - { - ItemID.Sets.IsRangedSpecialistWeapon[Item.type] = true; - } + public override void SetStaticDefaults() => ItemID.Sets.IsRangedSpecialistWeapon[Item.type] = true; + public override void SetDefaults() { Item.width = 56; @@ -49,6 +47,15 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Vector2 spawnPosition = player.RotatedRelativePoint(player.MountedCenter); + Projectile.NewProjectileDirect(source, spawnPosition, player.Calamity().mouseWorld - player.RotatedRelativePoint(player.MountedCenter), ModContent.ProjectileType(), damage, knockback, player.whoAmI); + return false; + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/MidasPrime.cs b/Items/Weapons/Ranged/MidasPrime.cs index 0a15438517..80ec7fb0ed 100644 --- a/Items/Weapons/Ranged/MidasPrime.cs +++ b/Items/Weapons/Ranged/MidasPrime.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; @@ -10,9 +9,17 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class MidasPrime : ModItem, ILocalizedModType + public class MidasPrime : ModItem, ILocalizedModType, IHoldShiftTooltipItem { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + // The Hold SHIFT tooltip is an easter egg and is not indicated to the player in any way. + public bool ShowExtensionIndicator => false; + + // Easter egg has a special tooltip key and color. + public string TooltipExtensionKey => "UltrakillEasterEgg"; + public Color? TooltipExtensionColor => Color.Red; + internal static readonly SoundStyle ShootSound = new("CalamityMod/Sounds/Item/CrackshotColtShot") { Volume = 0.5f, PitchVariance = 0.1f }; // Internal storage used to keep track between UseItem and Shoot hooks whether a gold coin was queued up @@ -138,14 +145,6 @@ namespace CalamityMod.Items.Weapons.Ranged return base.Shoot(player, source, position, velocity, type, damage, knockback); } - #region Hidden ULTRAKILL Reference Tooltip - public override void ModifyTooltips(List tooltips) - { - TooltipLine ultrakillIntro = new TooltipLine(Mod, "CalamityMod:UltrakillIntroReference", this.GetLocalizedValue("UltrakillEasterEgg")) { OverrideColor = Color.Red }; - CalamityUtils.HoldShiftTooltip(tooltips, new TooltipLine[] { ultrakillIntro }); - } - #endregion - // Make the gun have visible recoil when fired for extra cool factor. #region Firing Animation public override void UseStyle(Player player, Rectangle heldItemFrame) diff --git a/Items/Weapons/Ranged/MineralMortar.cs b/Items/Weapons/Ranged/MineralMortar.cs index aef7481495..2b06fe3f35 100644 --- a/Items/Weapons/Ranged/MineralMortar.cs +++ b/Items/Weapons/Ranged/MineralMortar.cs @@ -43,11 +43,8 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile holdout = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); - - // We set the rotation to the direction to the mouse so the first frame doesn't appear bugged out. - holdout.rotation = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero).ToRotation(); - + Vector2 spawnPosition = player.RotatedRelativePoint(player.MountedCenter, true); + Projectile.NewProjectileDirect(source, spawnPosition, player.Calamity().mouseWorld - spawnPosition, ModContent.ProjectileType(), 0, 0f, player.whoAmI); return false; } diff --git a/Items/Weapons/Ranged/MonolithBow.cs b/Items/Weapons/Ranged/MonolithBow.cs new file mode 100644 index 0000000000..e467e12c49 --- /dev/null +++ b/Items/Weapons/Ranged/MonolithBow.cs @@ -0,0 +1,55 @@ +using CalamityMod.Dusts; +using CalamityMod.Items.Placeables; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Ranged +{ + public class MonolithBow : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Ranged"; + public override void SetDefaults() + { + Item.damage = 19; + Item.DamageType = DamageClass.Ranged; + Item.width = 24; + Item.height = 54; + Item.useTime = 5; + Item.useAnimation = 20; + Item.reuseDelay = 25; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.knockBack = 0f; + Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.rare = ItemRarityID.Orange; + Item.UseSound = SoundID.Item5; + Item.autoReuse = true; + Item.shoot = ProjectileID.WoodenArrowFriendly; + Item.shootSpeed = 9f; + Item.useAmmo = AmmoID.Arrow; + Item.consumeAmmoOnFirstShotOnly = true; + Item.Calamity().canFirePointBlankShots = true; + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + for (int i = 0; i <= 2; i++) + { + Dust dust = Dust.NewDustPerfect(position + velocity * 3, Main.rand.NextBool() ? ModContent.DustType() : ModContent.DustType(), velocity.RotatedByRandom(MathHelper.ToRadians(10f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(1.2f, 1.6f)); + dust.noGravity = true; + } + Projectile.NewProjectile(source, position + velocity * 2, velocity.RotatedByRandom(0.165f), type, damage, knockback, player.whoAmI); + return false; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(10). + AddTile(TileID.WorkBenches). + Register(); + } + } +} diff --git a/Items/Weapons/Ranged/MonolithBow.png b/Items/Weapons/Ranged/MonolithBow.png new file mode 100644 index 0000000000..46a995c5bc Binary files /dev/null and b/Items/Weapons/Ranged/MonolithBow.png differ diff --git a/Items/Weapons/Ranged/OpalStriker.cs b/Items/Weapons/Ranged/OpalStriker.cs index b7add585c2..2367059962 100644 --- a/Items/Weapons/Ranged/OpalStriker.cs +++ b/Items/Weapons/Ranged/OpalStriker.cs @@ -21,10 +21,8 @@ namespace CalamityMod.Items.Weapons.Ranged public static int AftershotCooldownFrames = 17; public static int FullChargeFrames = 88; - public override void SetStaticDefaults() - { - ItemID.Sets.IsRangedSpecialistWeapon[Item.type] = true; - } + public override void SetStaticDefaults() => ItemID.Sets.IsRangedSpecialistWeapon[Type] = true; + public override void SetDefaults() { Item.width = 48; @@ -48,6 +46,15 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Vector2 spawnPosition = player.RotatedRelativePoint(player.MountedCenter, true); + Projectile.NewProjectileDirect(source, spawnPosition, player.Calamity().mouseWorld - spawnPosition, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + return false; + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/PearlGod.cs b/Items/Weapons/Ranged/PearlGod.cs index 458fc149e1..dd50793b44 100644 --- a/Items/Weapons/Ranged/PearlGod.cs +++ b/Items/Weapons/Ranged/PearlGod.cs @@ -8,7 +8,9 @@ using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Rarities; +using Terraria.Audio; using CalamityMod.Items.Materials; +using Steamworks; namespace CalamityMod.Items.Weapons.Ranged { @@ -32,7 +34,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.knockBack = 3f; Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; Item.rare = ModContent.RarityType(); - Item.UseSound = SoundID.Item41; + Item.UseSound = new SoundStyle("CalamityMod/Sounds/Item/GunShotSmall") with { Volume = 0.65f }; Item.autoReuse = true; Item.shootSpeed = 14f; Item.shoot = ProjectileID.PurificationPowder; diff --git a/Items/Weapons/Ranged/Phangasm.cs b/Items/Weapons/Ranged/Phangasm.cs index 5f4e9d8ac4..7a8aab8725 100644 --- a/Items/Weapons/Ranged/Phangasm.cs +++ b/Items/Weapons/Ranged/Phangasm.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 48; Item.height = 82; - Item.damage = 87; + Item.damage = 117; Item.useTime = 12; Item.useAnimation = 12; Item.useStyle = ItemUseStyleID.Shoot; diff --git a/Items/Weapons/Ranged/RealmRavager.cs b/Items/Weapons/Ranged/RealmRavager.cs index 2f0bbf6805..baaed6a188 100644 --- a/Items/Weapons/Ranged/RealmRavager.cs +++ b/Items/Weapons/Ranged/RealmRavager.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 76; Item.height = 32; - Item.damage = 50; + Item.damage = 54; Item.DamageType = DamageClass.Ranged; Item.useTime = 22; Item.useAnimation = 22; @@ -35,11 +35,11 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int numBullets = Main.rand.NextBool() ? 4 : 3; + int numBullets = 4; for (int index = 0; index < numBullets; ++index) { - float SpeedX = velocity.X + Main.rand.Next(-75, 76) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-75, 76) * 0.05f; + float SpeedX = velocity.X + (index == 0 ? 0 : Main.rand.Next(-75, 76) * 0.05f); + float SpeedY = velocity.Y + (index == 0 ? 0 : Main.rand.Next(-75, 76) * 0.05f); if (type == ProjectileID.Bullet) Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockback, player.whoAmI); diff --git a/Items/Weapons/Ranged/SDFMG.cs b/Items/Weapons/Ranged/SDFMG.cs index d6d7b2d767..93660b0972 100644 --- a/Items/Weapons/Ranged/SDFMG.cs +++ b/Items/Weapons/Ranged/SDFMG.cs @@ -63,7 +63,6 @@ namespace CalamityMod.Items.Weapons.Ranged { CreateRecipe(). AddIngredient(ItemID.SDMG). - AddIngredient(). AddIngredient(8). AddIngredient(20). AddTile(). diff --git a/Items/Weapons/Ranged/Shadethrower.cs b/Items/Weapons/Ranged/Shadethrower.cs index a212cfe9d1..a3e0f85b9d 100644 --- a/Items/Weapons/Ranged/Shadethrower.cs +++ b/Items/Weapons/Ranged/Shadethrower.cs @@ -14,10 +14,10 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 76; Item.height = 30; - Item.damage = 23; + Item.damage = 22; Item.DamageType = DamageClass.Ranged; Item.useTime = 10; - Item.useAnimation = 30; + Item.useAnimation = 40; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1.5f; diff --git a/Items/Weapons/Ranged/Shredder.cs b/Items/Weapons/Ranged/Shredder.cs index 6665770842..4996c2f66a 100644 --- a/Items/Weapons/Ranged/Shredder.cs +++ b/Items/Weapons/Ranged/Shredder.cs @@ -5,6 +5,7 @@ using Terraria; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using System; namespace CalamityMod.Items.Weapons.Ranged { @@ -20,11 +21,11 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 56; Item.height = 24; - Item.damage = 31; + Item.damage = 45; Item.DamageType = DamageClass.Ranged; Item.useTime = 4; - Item.useAnimation = 24; - Item.reuseDelay = 20; + Item.useAnimation = 32; + Item.reuseDelay = 35; Item.useLimitPerAnimation = 8; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; @@ -34,7 +35,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.UseSound = SoundID.Item31; Item.autoReuse = true; Item.shoot = ProjectileID.Bullet; - Item.shootSpeed = 9f; + Item.shootSpeed = 5f; Item.useAmmo = AmmoID.Bullet; Item.Calamity().canFirePointBlankShots = true; } @@ -45,33 +46,21 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int bulletAmt = 4; - if (player.altFunctionUse == 2) + int shotType = (player.altFunctionUse == 2 ? type : ModContent.ProjectileType()); + int bulletAmt = 3; + Vector2 newPosition = position + velocity.SafeNormalize(Vector2.UnitY) * 50f; + for (int index = 0; index < bulletAmt; index++) { - velocity *= 2f; - Vector2 newPosition = position + velocity.SafeNormalize(Vector2.UnitY) * 50f; - Vector2 cachedVelocity = velocity; - for (int index = 0; index < bulletAmt; index++) - { - velocity += new Vector2(Main.rand.Next(-30, 31) * 0.05f, Main.rand.Next(-30, 31) * 0.05f); - int shot = Projectile.NewProjectile(source, newPosition, velocity, type, damage, knockback, player.whoAmI); - Main.projectile[shot].timeLeft = 180; - velocity = cachedVelocity; - } - } - else - { - Vector2 newPosition = position + velocity.SafeNormalize(Vector2.UnitY) * 50f; - Vector2 cachedVelocity = velocity; - for (int index = 0; index < bulletAmt; index++) - { - velocity += new Vector2(Main.rand.Next(-30, 31) * 0.05f, Main.rand.Next(-30, 31) * 0.05f); - Projectile.NewProjectile(source, newPosition, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - velocity = cachedVelocity; - } + Projectile.NewProjectile(source, newPosition, (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedByRandom(0.2f), shotType, damage, knockback, player.whoAmI); } return false; } + public override bool CanConsumeAmmo(Item ammo, Player player) + { + if (Main.rand.Next(0, 100) < 60) + return false; + return true; + } public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/SparkSpreader.cs b/Items/Weapons/Ranged/SparkSpreader.cs index 8b292401c2..8ff1657262 100644 --- a/Items/Weapons/Ranged/SparkSpreader.cs +++ b/Items/Weapons/Ranged/SparkSpreader.cs @@ -13,12 +13,14 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 56; Item.height = 26; - Item.damage = 10; + Item.damage = 16; Item.knockBack = 1f; Item.DamageType = DamageClass.Ranged; Item.autoReuse = true; Item.useTime = 12; - Item.useAnimation = 36; + Item.useAnimation = 48; + Item.reuseDelay = 12; + Item.useLimitPerAnimation = 4; Item.useAmmo = AmmoID.Gel; Item.consumeAmmoOnFirstShotOnly = true; Item.shootSpeed = 6f; diff --git a/Items/Weapons/Ranged/SpeedBlaster.cs b/Items/Weapons/Ranged/SpeedBlaster.cs index 83a303c0bb..a146ae3b32 100644 --- a/Items/Weapons/Ranged/SpeedBlaster.cs +++ b/Items/Weapons/Ranged/SpeedBlaster.cs @@ -94,7 +94,8 @@ namespace CalamityMod.Items.Weapons.Ranged Color ColorUsed = SpeedBlasterShot.GetColor(ColorValue); for (int i = 0; i <= 8; i++) { - CritSpark spark = new CritSpark(player.Center, player.velocity.RotatedByRandom(MathHelper.ToRadians(13f)) * Main.rand.NextFloat(-2.1f, -4.5f), Color.White, ColorUsed, 2f, 45, 2f, 2.5f); + Vector2 sparkVel = player.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(MathHelper.ToRadians(45f)) * Main.rand.NextFloat(-28f, -36f); + CritSpark spark = new CritSpark(player.Center, sparkVel, Color.White, ColorUsed, 1.5f, 45, 0.5f, 2f); GeneralParticleHandler.SpawnParticle(spark); } } diff --git a/Items/Weapons/Ranged/SuperradiantSlaughterer.cs b/Items/Weapons/Ranged/SuperradiantSlaughterer.cs new file mode 100644 index 0000000000..0431c9500d --- /dev/null +++ b/Items/Weapons/Ranged/SuperradiantSlaughterer.cs @@ -0,0 +1,130 @@ +using CalamityMod.Cooldowns; +using CalamityMod.Items.Materials; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Ranged; +using CalamityMod.Sounds; +using Microsoft.Xna.Framework; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Ranged +{ + [LegacyName("ElementalBlaster")] + public class SuperradiantSlaughterer : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public const float ShootSpeed = 24f; + + public const int DashCooldown = 360; + + public override void ModifyTooltips(List tooltips) + { + if (tooltips == null) + return; + + Player player = Main.player[Main.myPlayer]; + if (player is null) + return; + + var mainTooltip = tooltips.FirstOrDefault(x => x.Text.Contains("[MAIN]") && x.Mod == "Terraria"); + if (mainTooltip != null) + { + mainTooltip.Text = Lang.SupportGlyphs(this.GetLocalizedValue("MainInfo")); + mainTooltip.OverrideColor = Color.Chartreuse; + } + var altTooltip = tooltips.FirstOrDefault(x => x.Text.Contains("[ALT]") && x.Mod == "Terraria"); + if (altTooltip != null) + { + altTooltip.Text = Lang.SupportGlyphs(this.GetLocalization("AltInfo").Format(DashCooldown / 60)); + altTooltip.OverrideColor = Color.SpringGreen; + } + } + + public override void SetStaticDefaults() + { + ItemID.Sets.IsRangedSpecialistWeapon[Item.type] = true; + } + public override void SetDefaults() + { + Item.width = 84; + Item.height = 46; + Item.damage = 76; + Item.DamageType = DamageClass.Ranged; + Item.useTime = 30; + Item.useAnimation = 30; + Item.useStyle = ItemUseStyleID.Shoot; + Item.noMelee = true; + Item.noUseGraphic = true; + Item.channel = true; + Item.knockBack = 1.75f; + Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; + Item.rare = ItemRarityID.Purple; + Item.autoReuse = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = ShootSpeed; + Item.Calamity().canFirePointBlankShots = true; + } + + // Terraria seems to really dislike high crit values in SetDefaults + public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 21; + public override bool AltFunctionUse(Player player) => true; + public override bool CanUseItem(Player player) + { + if (player.altFunctionUse == 2 && player.HasCooldown(SuperradiantSawBoost.ID)) + return false; + else + return player.ownedProjectileCounts[Item.shoot] <= 0; + } + + public override void HoldItem(Player player) + { + if (player.whoAmI != Main.myPlayer) + return; + + player.Calamity().mouseWorldListener = true; + player.Calamity().rightClickListener = true; + + // Right-click channeling + if (player.Calamity().mouseRight && CanUseItem(player) && !Main.mapFullscreen && !Main.blockMouse && !player.HasCooldown(SuperradiantSawBoost.ID)) + { + // Only one out at a time + if (Main.projectile.Any(n => n.active && n.type == Item.shoot && n.owner == player.whoAmI)) + return; + + int damage = (int)player.GetTotalDamage().ApplyTo(Item.damage); + float kb = player.GetTotalKnockback().ApplyTo(Item.knockBack); + Projectile.NewProjectile(Item.GetSource_FromThis(), player.Center, player.SafeDirectionTo(player.Calamity().mouseWorld), Item.shoot, damage * 2, kb, player.whoAmI, ai1: 2f); + } + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + // The holdout will initially double up when right clicking otherwise + if (player.altFunctionUse == 2) + return false; + + // The holdout deals 2x base damage. + Projectile.NewProjectile(source, position, velocity, Item.shoot, damage * 2, knockback, player.whoAmI); + return false; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(). + AddIngredient(ItemID.LunarBar, 5). + AddIngredient(5). + AddIngredient(5). + AddTile(TileID.LunarCraftingStation). + Register(); + } + } +} diff --git a/Items/Weapons/Ranged/SuperradiantSlaughterer.png b/Items/Weapons/Ranged/SuperradiantSlaughterer.png new file mode 100644 index 0000000000..7dc18da67a Binary files /dev/null and b/Items/Weapons/Ranged/SuperradiantSlaughterer.png differ diff --git a/Items/Weapons/Ranged/Svantechnical.cs b/Items/Weapons/Ranged/Svantechnical.cs index efb03041fc..e304c42a43 100644 --- a/Items/Weapons/Ranged/Svantechnical.cs +++ b/Items/Weapons/Ranged/Svantechnical.cs @@ -1,5 +1,7 @@ using System; using CalamityMod.Items.Materials; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; @@ -13,16 +15,19 @@ namespace CalamityMod.Items.Weapons.Ranged public class Svantechnical : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + public int SineCounter = 0; + public override void SetStaticDefaults() + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; + } public override void SetDefaults() { Item.width = 60; Item.height = 26; - Item.damage = 150; + Item.damage = 200; Item.DamageType = DamageClass.Ranged; - Item.useTime = 2; - Item.useAnimation = 24; - Item.reuseDelay = 10; - Item.useLimitPerAnimation = 12; + Item.useTime = 1; + Item.useAnimation = 3; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 3.5f; @@ -33,70 +38,53 @@ namespace CalamityMod.Items.Weapons.Ranged Item.UseSound = SoundID.Item31; Item.autoReuse = true; - Item.shootSpeed = 12f; + Item.shootSpeed = 6f; Item.shoot = ProjectileID.PurificationPowder; Item.useAmmo = AmmoID.Bullet; + Item.Calamity().canFirePointBlankShots = true; } public override Vector2? HoldoutOffset() => new Vector2(-5, 0); - - public override void HoldItem(Player player) => player.scope = true; - - public override bool CanConsumeAmmo(Item ammo, Player player) + public override bool AltFunctionUse(Player player) { - if (Main.rand.Next(0, 100) < 70) - return false; return true; } + public override void HoldItem(Player player) => player.scope = false; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int i = Main.myPlayer; - float sSpeed = Item.shootSpeed; - player.itemTime = Item.useTime; - Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); - float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; - float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; - if (player.gravDir == -1f) + int shotType = (player.altFunctionUse == 2 ? type : ModContent.ProjectileType()); + position = position + (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.UnitX) * 65; + float sine = (float)Math.Sin(SineCounter * 0.175f / MathHelper.Pi) * 4f; + float sine2 = (float)Math.Sin(SineCounter * 0.275f / MathHelper.Pi) * 2f; + SineCounter++; + if (SineCounter % 4 == 0) { - mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; + Vector2 helixVel1 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine)); + Vector2 helixVel2 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(-sine)); + Vector2 helixVel3 = (velocity * Main.rand.NextFloat(0.9f, 1.1f)).RotatedBy(MathHelper.ToRadians(sine2)); + int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, 2f); + int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, 4f); + int shot3 = Projectile.NewProjectile(source, position.X, position.Y, helixVel3.X, helixVel3.Y, shotType, damage, knockback, player.whoAmI, 0f, 0, 3f); } - float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); - if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) + else if (player.altFunctionUse != 2) { - mouseXDist = (float)player.direction; - mouseYDist = 0f; - } - else - { - mouseDistance = sSpeed / mouseDistance; - } - float randXOffset = mouseXDist; - float randYOffset = mouseYDist; - randXOffset += (float)Main.rand.Next(-1, 2) * 0.5f; - randYOffset += (float)Main.rand.Next(-1, 2) * 0.5f; - if (Collision.CanHitLine(player.Center, 0, 0, realPlayerPos + new Vector2(randXOffset, randYOffset) * 2f, 0, 0)) - { - realPlayerPos += new Vector2(randXOffset, randYOffset); - } - Projectile.NewProjectile(source, position.X, position.Y - player.gravDir * 4f, randXOffset, randYOffset, type, damage, knockback, i, 0f, (float)Main.rand.Next(12) / 6f); - int bulletAmt = Main.rand.Next(2, 4); - for (int index = 0; index < bulletAmt; ++index) - { - float SpeedX = velocity.X + (float)Main.rand.Next(-60, 61) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-60, 61) * 0.05f; - Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, 0f, 0f); + Particle spark2 = new LineParticle(position + Main.rand.NextVector2Circular(6, 6), (velocity * 4).RotatedByRandom(0.35f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(15, 25 + 1), Main.rand.NextFloat(1.5f, 2f), Main.rand.NextBool() ? Color.MediumOrchid : Color.DarkViolet); + GeneralParticleHandler.SpawnParticle(spark2); } return false; } + public override bool CanConsumeAmmo(Item ammo, Player player) + { + if (Main.rand.Next(0, 100) > 90 && SineCounter % 4 == 0) + return true; + return false; + } public override void AddRecipes() { CreateRecipe(). - AddIngredient(). - AddIngredient(ItemID.SoulofMight, 10). - AddIngredient(ItemID.SoulofSight, 10). - AddIngredient(ItemID.SoulofFright, 10). + AddIngredient(). AddIngredient(5). AddTile(). Register(); diff --git a/Items/Weapons/Ranged/TheHive.cs b/Items/Weapons/Ranged/TheHive.cs index 2092626a5c..89e585472d 100644 --- a/Items/Weapons/Ranged/TheHive.cs +++ b/Items/Weapons/Ranged/TheHive.cs @@ -14,6 +14,7 @@ namespace CalamityMod.Items.Weapons.Ranged { public new string LocalizationCategory => "Items.Weapons.Ranged"; + public static float MaxCharge = 90f; public static int OriginalUseTime = 34; public override void SetDefaults() diff --git a/Items/Weapons/Ranged/WildfireBloom.cs b/Items/Weapons/Ranged/WildfireBloom.cs index b6c2286b1a..d821089aeb 100644 --- a/Items/Weapons/Ranged/WildfireBloom.cs +++ b/Items/Weapons/Ranged/WildfireBloom.cs @@ -39,13 +39,21 @@ namespace CalamityMod.Items.Weapons.Ranged } public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; + // Spawning the holdout cannot consume ammo public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile.NewProjectile(source, position, Vector2.Zero, type, 0, 0f, player.whoAmI); + Projectile holdout = Projectile.NewProjectileDirect(source, position, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); + + // We set the rotation to the direction to the mouse so the first frame doesn't appear bugged out. + holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); + return false; } diff --git a/Items/Weapons/Rogue/FeatherKnife.cs b/Items/Weapons/Rogue/FeatherKnife.cs index 545601781a..c90f06dd71 100644 --- a/Items/Weapons/Rogue/FeatherKnife.cs +++ b/Items/Weapons/Rogue/FeatherKnife.cs @@ -38,6 +38,8 @@ namespace CalamityMod.Items.Weapons.Rogue Item.rare = ItemRarityID.Orange; } + public override float StealthDamageMultiplier => 0.80f; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike diff --git a/Items/Weapons/Rogue/NanoblackReaper.cs b/Items/Weapons/Rogue/NanoblackReaper.cs index cc1a2987ba..a6a56bbc4a 100644 --- a/Items/Weapons/Rogue/NanoblackReaper.cs +++ b/Items/Weapons/Rogue/NanoblackReaper.cs @@ -12,8 +12,11 @@ namespace CalamityMod.Items.Weapons.Rogue { // Deny me no longer! [LegacyName("NanoblackReaperMelee", "NanoblackReaperRogue")] - public class NanoblackReaper : RogueWeapon + public class NanoblackReaper : RogueWeapon, IHoldShiftTooltipItem { + public bool ShowExtensionIndicator => false; + public Color? TooltipExtensionColor => new Color(31, 223, 128); // #1FDF80 + public static float Knockback = 9f; public static float Speed = 16f; diff --git a/Items/Weapons/Rogue/Turbulance.cs b/Items/Weapons/Rogue/Turbulance.cs index 00536460cd..ce7c035e66 100644 --- a/Items/Weapons/Rogue/Turbulance.cs +++ b/Items/Weapons/Rogue/Turbulance.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 14; Item.height = 14; - Item.damage = 18; + Item.damage = 28; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = 18; diff --git a/Items/Weapons/Summon/CosmicViperEngine.cs b/Items/Weapons/Summon/CosmicViperEngine.cs index 2f1cacf427..535ad630a2 100644 --- a/Items/Weapons/Summon/CosmicViperEngine.cs +++ b/Items/Weapons/Summon/CosmicViperEngine.cs @@ -40,7 +40,6 @@ namespace CalamityMod.Items.Weapons.Summon if (player.altFunctionUse != 2) { float speed = Item.shootSpeed; - player.itemTime = Item.useTime; Vector2 spawnPos = player.RotatedRelativePoint(player.MountedCenter, true); float xPos = (float)Main.mouseX + Main.screenPosition.X - spawnPos.X; float yPos = (float)Main.mouseY + Main.screenPosition.Y - spawnPos.Y; diff --git a/Items/Weapons/Summon/DankStaff.cs b/Items/Weapons/Summon/DankStaff.cs index 3a40da3bcc..ad9e9a42a6 100644 --- a/Items/Weapons/Summon/DankStaff.cs +++ b/Items/Weapons/Summon/DankStaff.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 58; Item.height = 58; - Item.damage = 9; + Item.damage = 14; Item.mana = 10; Item.useTime = Item.useAnimation = 30; Item.useStyle = ItemUseStyleID.Swing; diff --git a/Items/Weapons/Summon/Endogenesis.cs b/Items/Weapons/Summon/Endogenesis.cs index de42c89bb1..0cface095a 100644 --- a/Items/Weapons/Summon/Endogenesis.cs +++ b/Items/Weapons/Summon/Endogenesis.cs @@ -49,7 +49,6 @@ namespace CalamityMod.Items.Weapons.Summon { if (player.altFunctionUse != 2) { - player.itemTime = Item.useTime; CalamityUtils.KillShootProjectileMany(player, new int[] { type, diff --git a/Items/Weapons/Summon/FleshOfInfidelity.cs b/Items/Weapons/Summon/FleshOfInfidelity.cs index a0ed0e586b..1373817513 100644 --- a/Items/Weapons/Summon/FleshOfInfidelity.cs +++ b/Items/Weapons/Summon/FleshOfInfidelity.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 42; Item.height = 42; - Item.damage = 15; + Item.damage = 20; Item.DamageType = DamageClass.Summon; Item.shoot = ModContent.ProjectileType(); Item.knockBack = 1f; diff --git a/Items/Weapons/Summon/ForgottenApexWand.cs b/Items/Weapons/Summon/ForgottenApexWand.cs index 377c934395..63625ec5e3 100644 --- a/Items/Weapons/Summon/ForgottenApexWand.cs +++ b/Items/Weapons/Summon/ForgottenApexWand.cs @@ -34,7 +34,6 @@ namespace CalamityMod.Items.Weapons.Summon { if (player.altFunctionUse != 2) { - player.itemTime = Item.useTime; Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); vector2.X = Main.mouseX + Main.screenPosition.X; vector2.Y = Main.mouseY + Main.screenPosition.Y; diff --git a/Items/Weapons/Summon/GastricBelcherStaff.cs b/Items/Weapons/Summon/GastricBelcherStaff.cs index e5befad427..6566d75dab 100644 --- a/Items/Weapons/Summon/GastricBelcherStaff.cs +++ b/Items/Weapons/Summon/GastricBelcherStaff.cs @@ -34,7 +34,6 @@ namespace CalamityMod.Items.Weapons.Summon { if (player.altFunctionUse != 2) { - player.itemTime = Item.useTime; Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true); float directionX = Main.mouseX + Main.screenPosition.X - playerPos.X; float directionY = Main.mouseY + Main.screenPosition.Y - playerPos.Y; diff --git a/Items/Weapons/Summon/HarvestStaff.cs b/Items/Weapons/Summon/HarvestStaff.cs index f16756177b..96da01b29c 100644 --- a/Items/Weapons/Summon/HarvestStaff.cs +++ b/Items/Weapons/Summon/HarvestStaff.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - Item.damage = 26; + Item.damage = 27; Item.DamageType = DamageClass.Summon; Item.shoot = ModContent.ProjectileType(); Item.knockBack = 5f; diff --git a/Items/Weapons/Summon/LiliesOfFinality.cs b/Items/Weapons/Summon/LiliesOfFinality.cs index 849286cb14..7e441ab524 100644 --- a/Items/Weapons/Summon/LiliesOfFinality.cs +++ b/Items/Weapons/Summon/LiliesOfFinality.cs @@ -59,8 +59,8 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile.NewProjectileDirect(source, Main.MouseWorld, new Vector2(-1f, -1f) * 3f, type, damage, knockback, player.whoAmI); - Projectile.NewProjectileDirect(source, Main.MouseWorld, new Vector2(1f, -1f) * 3f, ProjectileType(), damage, knockback, player.whoAmI); + Projectile.NewProjectileDirect(source, player.Calamity().mouseWorld, new Vector2(-1f, -1f) * 3f, type, damage, knockback, player.whoAmI); + Projectile.NewProjectileDirect(source, player.Calamity().mouseWorld, new Vector2(1f, -1f) * 3f, ProjectileType(), damage, knockback, player.whoAmI); if (Main.dedServ) return false; diff --git a/Items/Weapons/Summon/ResurrectionButterfly.cs b/Items/Weapons/Summon/ResurrectionButterfly.cs index d91f467d4c..67a1b45685 100644 --- a/Items/Weapons/Summon/ResurrectionButterfly.cs +++ b/Items/Weapons/Summon/ResurrectionButterfly.cs @@ -38,7 +38,6 @@ namespace CalamityMod.Items.Weapons.Summon { int i = Main.myPlayer; float projSpeed = Item.shootSpeed; - player.itemTime = Item.useTime; Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; diff --git a/Localization/en-US/Mods.CalamityMod.Bestiary.hjson b/Localization/en-US/Mods.CalamityMod.Bestiary.hjson index 8a8ccb1a7c..80bf331521 100644 --- a/Localization/en-US/Mods.CalamityMod.Bestiary.hjson +++ b/Localization/en-US/Mods.CalamityMod.Bestiary.hjson @@ -25,9 +25,9 @@ AcidEel: Though they are predators themselves, acid eels lay near the bottom of BabyFlakCrab: Adolescent flak crabs make no attempt to fight off predators, and simply flee from any threats. Their species only learns to pelt their targets from afar later in life, leaving the adolescents defenseless and dependent on their parents. Bloodworm: Bloodworms are an exceedingly rare creature to stumble upon, as they burrow at the first sign of danger. It takes both exceedingly great patience, wisdom, and agility to catch one, leaving the worms ever having but a single natural predator. CragmawMire: A mostly immobile creature that dwells in the depths of the radioactive wasteland, it boasts an exoskeleton harder than titanium to defend its core. To compensate for its lack of movement, it has formed a symbiotic relationship with a worm that reels in prey in exchange for protection. -FlakCrab: Needing to hide themselves from the roaming creatures, flak crabs disguise themselves as the sulfurous gas vents scattered across the Sulphurous Sea. As they reproduce quickly, stumbling upon these and their offspring is a rather common occurrence. +FlakCrab: Needing to hide themselves from the roaming creatures, flak crabs disguise themselves as the sulphurous gas vents scattered across the Sulphurous Sea. As they reproduce quickly, stumbling upon these and their offspring is a rather common occurrence. GammaSlime: A slime overloaded with radiation from Draedon's long-since abandoned experiments with nuclear energy. Though methods of generating power involving nuclear energy surpassed all others that came before in terms of raw efficiency, not even these advancements were enough to satisfy the enigmatic engineer. -IrradiatedSlime: Though slime is known to fall from the sky on occasion, slime in the sky condenses far quicker here in the Sulphurous Sea, as its air is thick with sulfur and radiation. It isn't uncommon for full sized slimes to fall from the heavens during acid rain storms, never mind a fully-fledged slime rain. +IrradiatedSlime: Though slime is known to fall from the sky on occasion, slime in the sky condenses far quicker here in the Sulphurous Sea, as its air is thick with sulphur and radiation. It isn't uncommon for full sized slimes to fall from the heavens during acid rain storms, never mind a fully-fledged slime rain. Mauler: Powerful radiation has caused prehistoric genes to reawaken in this shark, granting it overwhelming speed and strength. The insatiable hunger of this beast draws it to the shoreline during acidic rainstorms for a feeding frenzy. NuclearTerror: The effects of our actions are never immediately obvious. Centuries of poison and constant fighting for its own life created such monstrosity, now dragged to the shore by the unrelenting torrents. Whatever it may have been before, all that is left now is its will to survive. NuclearToad: These toads expand like a pufferfish when creatures are near and burst when in danger. The otherwise terrifying inhabitants of the sea have learned well to avoid these critters due to their particularly explosive nature. @@ -111,7 +111,7 @@ Viruling: Unlike derplings, who use their proboscis to drain the blood of other //Sulphur Sea Enemies AnthozoanCrab: Though disguised as simple rocks, they are capable of hurling entire boulders at creatures with ease, and will retreat swiftly if approached. Elsewhere, a creature such as this would thrive due to its might; yet in such a hostile environment as this, this much is required merely to survive. AquaticUrchin: Closely related to sea urchins, aquatic urchins have been forced to adapt to the acidic water and radioactive waste. Their venomous spikes would normally deter predators, but in the environment it lives in, a painful meal is still a meal. Nothing in this sea can afford to be a picky eater. -BelchingCoral: Although all coral is alive to some extent, this species possesses above average intelligence. They are capable of fending off creatures attempting to consume them by releasing pressurized bursts of sulfuric gas when approached. Occasionally, this process makes a noise resembling music. +BelchingCoral: Although all coral is alive to some extent, this species possesses above average intelligence. They are capable of fending off creatures attempting to consume them by releasing pressurized bursts of sulphuric gas when approached. Occasionally, this process makes a noise resembling music. Gnasher: Though gnashers are relatively slow, these mutated snapping turtles boast an unnaturally strong shell. Attempting to kill and eat one would injure most creatures greatly due to its terrifying biting power and spiked shell easily capable of impaling flesh. Sulflounder: A relative to certain hadopelagic creatures living in the depths, the Sulflounders are a branch in their evolution with a fragile exterior. This allowed them not to sink to the bottom of the Abyss, though their flesh is barely enough to withstand the acidic water. Toxicatfish: Though these fish once threatened none other than their prey, the radiation from nuclear waste generated from Draedon's old experiments has rotted both their bodies and minds. Attacking anything that comes near, this once flourishing species is now on the verge of extinction. diff --git a/Localization/en-US/Mods.CalamityMod.Biomes.hjson b/Localization/en-US/Mods.CalamityMod.Biomes.hjson index f6834ea4a1..aa99aff816 100644 --- a/Localization/en-US/Mods.CalamityMod.Biomes.hjson +++ b/Localization/en-US/Mods.CalamityMod.Biomes.hjson @@ -76,7 +76,32 @@ AstralUnderground: { TownNPCDialogueName: Underground Astral Infection } +SunkenSeaBurrowsBiome: { + DisplayName: Sunken Sea Burrows Biome + TownNPCDialogueName: the Sunken Sea Burrows Biome +} + +SunkenSeaPolypBiome: { + DisplayName: Sunken Sea Polyp Biome + TownNPCDialogueName: the Sunken Sea Polyp Biome +} + +SunkenSeaReefsBiome: { + DisplayName: Sunken Sea Reefs Biome + TownNPCDialogueName: the Sunken Sea Reefs Biome +} + +SunkenSeaShoresBiome: { + DisplayName: Sunken Sea Shores Biome + TownNPCDialogueName: the Sunken Sea Shores Biome +} + AstralCaveDesert: { DisplayName: Astral Cave Desert TownNPCDialogueName: the Astral Cave Desert } + +FloralParadiseBiome: { + DisplayName: Floral Paradise + TownNPCDialogueName: the Floral Paradise +} diff --git a/Localization/en-US/Mods.CalamityMod.Buffs.hjson b/Localization/en-US/Mods.CalamityMod.Buffs.hjson index 052bed0f72..1f5b14e75b 100644 --- a/Localization/en-US/Mods.CalamityMod.Buffs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Buffs.hjson @@ -178,6 +178,11 @@ HolyInferno: { Description: You've gone too far from the Profaned Goddess! } +Laceration: { + DisplayName: Laceration + Description: You're a bloody mess +} + ManaBurn: { DisplayName: Mana Burn Description: The excess of mana sears your body and mind @@ -359,8 +364,8 @@ Dreamfog: { } EidolonSnailBuff: { - DisplayName: Escargidolon Snail - Description: What a silly little prehistoric snail + DisplayName: Eidolon Snail + Description: What a silly little snail } ElectricTroublemaker: { @@ -465,17 +470,17 @@ CirrusBlueCandleBuff: { CirrusPinkCandleBuff: { DisplayName: Vigor - Description: Its brilliant light suffuses those nearby with hope + Description: The brilliant light suffuses you with hope } CirrusPurpleCandleBuff: { DisplayName: Resilience - Description: Neither rain nor wind can snuff its undying flame + Description: Neither rain nor wind can snuff your undying flame } CirrusYellowCandleBuff: { DisplayName: Spite - Description: Its hateful glow flickers with ire + Description: The hateful, flickering glow fuels your ire } CorruptionEffigyBuff: { diff --git a/Localization/en-US/Mods.CalamityMod.Configs.hjson b/Localization/en-US/Mods.CalamityMod.Configs.hjson index ac8eba1fec..ed1ed29342 100644 --- a/Localization/en-US/Mods.CalamityMod.Configs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Configs.hjson @@ -8,6 +8,7 @@ CalamityConfig: { Revengeance: Revengeance Mode Changes UI: UI Changes BaseBoosts: Base Stat Boosts + MusicEvents: Music Events } AdrenalineMeterPosX: { @@ -130,6 +131,11 @@ CalamityConfig: { Tooltip: Adds an array of debuff icons above all bosses and minibosses. } + DevourerofGodsEulogy: { + Label: "[i:CalamityModMusic/DevourerofGodsEulogyMusicBox] Eulogy for the Ego" + Tooltip: Plays Calamity Mod OST - "Scourge of the Universe (Eulogy for the Ego)", after the Devourer of Gods has been defeated. + } + EarlyHardmodeProgressionRework: { Label: "[i:Pwnhammer] Early Hardmode Progression Rework" Tooltip: @@ -226,6 +232,21 @@ CalamityConfig: { ''' } + Interlude1: { + Label: "[i:CalamityModMusic/Interlude1MusicBox] Interlude 1" + Tooltip: Plays Calamity Mod OST - "Silence before the storms", after Calamitas Clone has been defeated. + } + + Interlude2: { + Label: "[i:CalamityModMusic/Interlude2MusicBox] Interlude 2" + Tooltip: Plays Calamity Mod OST - "Storms before the catastrophes", after the Moon Lord has been defeated. + } + + Interlude3: { + Label: "[i:CalamityModMusic/Interlude3MusicBox] Interlude 3" + Tooltip: Plays Calamity Mod OST - "Catastrophes before the calamity", after Yharon has been defeated. + } + MeterPosLock: { Label: "[i:GemLockTopaz] Lock Meter Positions" Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.DamageClasses.hjson b/Localization/en-US/Mods.CalamityMod.DamageClasses.hjson index 5b565b8e71..b261db6100 100644 --- a/Localization/en-US/Mods.CalamityMod.DamageClasses.hjson +++ b/Localization/en-US/Mods.CalamityMod.DamageClasses.hjson @@ -1,5 +1,6 @@ AverageDamageClass.DisplayName: average damage +MeleeRangedHybridDamageClass.DisplayName: melee/ranged damage RogueDamageClass.DisplayName: rogue damage +StealthDamageClass.DisplayName: stealth damage TrueMeleeDamageClass.DisplayName: true melee damage TrueMeleeNoSpeedDamageClass.DisplayName: true melee damage -StealthDamageClass.DisplayName: Stealth Damage Class diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 5726d7ac9a..069adda0db 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -102,8 +102,9 @@ AlchemicalFlask: { DisplayName: Alchemical Flask Tooltip: ''' - All attacks inflict the Plague and grants immunity to the Plague + All attacks inflict the Plague and reduces damage taken from the Plague Projectiles spawn plague seekers on enemy hits + Releases plague bees when damaged and douses you in honey ''' } @@ -136,10 +137,10 @@ AmbrosialAmpoule: { DisplayName: Ambrosial Ampoule Tooltip: ''' - +70 max life + +50 max life Grants +2 to +6 HP/s life regen based on missing health - Provides life regeneration equivalent to standing in Honey - Standing still grants extremely powerful regen + Grants +1 HP/s life regen and an additional 1 HP/s life regen when inflicted with a damage debuff + Standing still grants +1.5 HP/s life regen Halves how long you are afflicted with fire and sickness debuffs You emit yellow light if visibility is enabled ''' @@ -428,7 +429,7 @@ CrawCarapace: { DisplayName: Craw Carapace Tooltip: ''' - 5% increased damage + 7% increased damage Enemies that hit you take damage and are inflicted with Crumbling ''' } @@ -437,7 +438,7 @@ Baroclaw: { DisplayName: Baroclaw Tooltip: ''' - 10% increased damage + 10% increased damage and 5% increased damage reduction Enemies that hit you take high damage and are inflicted with Armor Crunch and Crush Depth ''' } @@ -885,8 +886,9 @@ HallowedRune: { Tooltip: ''' Whenever your minions hit an enemy you will gain a random buff, does not stack with downgrades - These buffs will either boost your defense, summon damage, or life regen for a while - If you have the offensive boost, enemies hit by minions will sometimes be hit by stars + Hallowed Power increases summon damage by 10% and makes minion hits rain stars + Hallowed Defense increases defense by 8 and DR by 4% + Hallowed Regen grants +1.5 HP/s life regeneration ''' } @@ -935,8 +937,8 @@ HoneyDew: { Tooltip: ''' +30 max life - Provides life regeneration equivalent to standing in Honey - Standing still in Honey grants extremely powerful regen + Grants +1 HP/s life regen and an additional 1 HP/s life regen when inflicted with a damage debuff + Standing still in Honey grants +1.5 HP/s life regen Halves how long you are afflicted with sickness debuffs ''' } @@ -1023,8 +1025,8 @@ LivingDew: { Tooltip: ''' +50 max life - Provides life regeneration equivalent to standing in Honey - Standing still in Honey grants extremely powerful regen + Grants +1 HP/s life regen and an additional 1 HP/s life regen when inflicted with a damage debuff + Standing still in Honey grants +1.5 HP/s life regen Halves how long you are afflicted with fire and sickness debuffs ''' } @@ -1064,8 +1066,7 @@ ManaPolarizer: { ''' Increases max mana by 50 and magic damage by 6% -1.5 HP/s life regen if mana is above 50% of its maximum - Grants spectre healing, the amount healed scales with your mana - The healing only works while holding a magic weapon + Magic projectiles give lifesteal while holding a magic weapon The more mana you have, the more you heal ''' } @@ -1243,10 +1244,9 @@ PhantomicArtifact: { Tooltip: ''' Whenever your minions hit an enemy you will gain a random phantomic buff, does not stack with downgrades - These buffs will either boost your defense, summon damage, or life regen for a while - If you have the offensive boost, enemies hit by minions will sometimes be hit by phantomic knives - If you have the regenerative boost, a phantomic heart will occasionally materialise granting massive health regen - If you have the defensive boost, a phantomic bulwark will absorb 20% of the next projectile's damage that hits the bulwark, shattering it + Phantomic Empowerment increases summon damage by 10% and makes minion hits spawn phantomic knives + Phantomic Shield increases defense by 10 and DR by 5% and spawns a phantomic bulwark which absorbs 20% of the next projectile's damage that touches it + Phantomic Regen grants +2 HP/s life regen and spawns a phantomic heart which grants an additional 2 HP/s life regen when touched ''' } @@ -1261,16 +1261,6 @@ PlaguedFuelPack: { ''' } -PlagueHive: { - DisplayName: Plague Hive - Tooltip: - ''' - All attacks inflict the Plague and grants immunity to the Plague - Releases bees when damaged that inflict the Plague - Projectiles spawn plague seekers on enemy hits - ''' -} - ProfanedSoulArtifact: { DisplayName: Profaned Soul Artifact Tooltip: @@ -1331,10 +1321,10 @@ Radiance: { DisplayName: Radiance Tooltip: ''' - +100 max life - Grants +3 to +7 HP/s life regen based on missing health - Provides life regeneration equivalent to standing in Honey - Standing still grants extremely powerful regen + +70 max life + Grants +2 to +6 HP/s life regen based on missing health + Grants +1 HP/s life regen and an additional 1 HP/s life regen when inflicted with a damage debuff + Standing still grants +2 HP/s life regen Grants 20 defense and continuous healing while afflicted with any debuff The healing eventually slows down if debuffed for an extended period of time Massively boosts natural life regen while afflicted with any debuff @@ -1587,7 +1577,9 @@ SpiritGlyph: { Tooltip: ''' Whenever your minions hit an enemy you will gain a random buff - These buffs will either boost your defense, summon damage, or life regen for a while + Spirit Power increases summon damage by 10% + Spirit Defense increases defense by 6 and DR by 3% + Spirit Regen grants +1 HP/s life regeneration ''' } @@ -1615,9 +1607,8 @@ StatisBlessing: { DisplayName: Statis' Blessing Tooltip: ''' - Increased max minions by 2 and 10% increased summon damage + Increased max minions by 2 and 12% increased summon damage Increased minion knockback - Minions inflict holy flames on hit ''' } @@ -1626,9 +1617,9 @@ StatisCurse: { Tooltip: ''' Increases max minions by 3, does not stack with downgrades - 10% increased summon damage + 12% increased summon damage Increased minion knockback - Minions inflict holy flames and shadowflames on hit + Minions inflict shadowflames on hit Grants immunity to Shadowflame ''' } @@ -1720,7 +1711,7 @@ StatMeter: { // Other stats GenericStats: ''' - Defense: {0} | DR: {1}% | Life Regen: {2} + Defense: {0} | DR: {1}% | Life Regen: {2} HP/s Move Speed: {3}% | Jump Boost: {4}% ''' FlightTime: " | Wing Flight Time: {0} seconds" @@ -1882,8 +1873,9 @@ ToxicHeart: { DisplayName: Toxic Heart Tooltip: ''' - Summons a plague aura around you that damages nearby enemies - Makes you immune to the Plague debuff + Causes your heart to beat with powerful plague pulses, inflicting all nearby enemies with the Plague + The rate of these pulses scales with how low your life regen is + Pulses that kill targets create additional pulses and heal you Multiplies all sickness-based debuff damage by 1.5 ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson b/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson index ee6be6c217..e582fd1bcc 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson @@ -50,6 +50,11 @@ CinderArrow: { Tooltip: Explosive arrows that burst into weak flaming shards that inflict Brimstone Flames } +DryadsTear: { + DisplayName: Dryad's Tear + Tooltip: Splits into homing nature shards on impact which ignore enemy defense +} + ElysianArrow: { DisplayName: Elysian Arrow Tooltip: @@ -98,7 +103,7 @@ HailstormBullet: { ''' Bullets imbued with potent ice magic These bullets rapidly decelerate after being fired - Critical hits cause a flash freeze, dealing additional damage + Critical hits cause a flash freeze, dealing additional damage and freezing normal enemies ''' } @@ -159,11 +164,6 @@ SproutingArrow: { ''' } -DryadsTear: { - DisplayName: Dryad's Tear - Tooltip: Explodes and splits into homing nature shards on impact -} - VanquisherArrow: { DisplayName: Vanquisher Arrow Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.PostMoonLord.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.PostMoonLord.hjson index 06272e4042..a0c60646cb 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.PostMoonLord.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.PostMoonLord.hjson @@ -232,7 +232,7 @@ FearmongerGreathelm: { ''' 20% increased summon damage and +2 max minions Minions no longer deal less damage while wielding non-summoner weapons - Immunity to all forms of frost and flame + Immunity to all but the strongest forms of frost and flame Minion attacks grant +3.5 HP/s life regen and massively accelerate life regen 15% increased damage reduction during the Pumpkin and Frost Moons This extra damage reduction ignores the soft cap @@ -527,7 +527,7 @@ TarragonHeadMelee: { ''' 15% increased melee speed Enemies are more likely to target you - You gain a life regen buff when you take damage + Taking damage gives the Tarra Life buff, which grants +1.5 HP/s life regen Press {0} to cloak yourself in life energy that heavily reduces enemy contact damage for 10 seconds This has a 30 second cooldown ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson index b1f4f411f9..ab21fcb087 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson @@ -186,7 +186,7 @@ StatigelHeadSummon: { SulphurousBreastplate: { DisplayName: Sulphurous Breastplate - Tooltip: 8% increased rogue damage and 5% increased rogue critical strike chance + Tooltip: 6% increased rogue damage and 4% increased rogue critical strike chance } SulphurousHelmet: { @@ -199,7 +199,7 @@ SulphurousHelmet: { ''' SetBonus: ''' - +70 maximum stealth + +65 maximum stealth Attacking and being attacked by enemies inflicts poison Grants an additional jump that summons a sulphurous bubble Provides increased underwater mobility and reduces the severity of the sulphuric waters diff --git a/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson b/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson index 8e96193a93..433e0e4d83 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson @@ -54,8 +54,8 @@ Bloodfin: { DisplayName: Bloodfin Tooltip: ''' - Grants a buff that boosts life regen for 10 seconds - The life regen boost is stronger if below 75% health + Grants a buff that grants +2.5 HP/s life regen + This buff directly restores HP if below 75% health 10 second duration 'The wonders of angiogenesis' ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson b/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson index 90e1bb38a2..fad6ef1784 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson @@ -17,6 +17,7 @@ LoreAbyss: { Her great roots continue to thrash and tear at the impossibly dense stone, growing uncontrollably. She will soon remake it in her image. I can think of no worse fate for this accursed, hadal domain. ''' + Tooltip: "" } LoreAquaticScourge: { @@ -29,6 +30,7 @@ LoreAquaticScourge: { What a stark contrast to the rest of the ecosystem. Nearly every other creature in the Sulphur Sea is hostile. A shame that its last bastion of tranquility has fallen. ''' + Tooltip: "" } LoreArchmage: { @@ -42,6 +44,7 @@ LoreArchmage: { As my crusade evolved and my ambitions grew, he expressed vehement disapproval. Where justice was once seen, tyranny had blinded it. He departed along with the Witch not long after. ''' + Tooltip: "" } LoreAstralInfection: { @@ -57,6 +60,7 @@ LoreAstralInfection: { Those whose minds can grasp the true form of the universe are largely immune. They cannot be starstruck by a supposed higher truth, let alone one preached by a pustule. ''' + Tooltip: "" } LoreAstrumAureus: { @@ -70,6 +74,7 @@ LoreAstrumAureus: { However… even the finest silicon is not beyond its reach. Draedon prefers his creations to serve after all. With this experiment concluded, he will certainly be examining you next. Watch yourself. ''' + Tooltip: "" } LoreAstrumDeus: { @@ -83,6 +88,7 @@ LoreAstrumDeus: { Thankfully, such a grandiose being that walks amongst the stars is likely not truly dead. While the land has paid a terrible price, the price of a wrongful conviction is higher still. ''' + Tooltip: "" } LoreAwakening: { @@ -95,6 +101,7 @@ LoreAwakening: { Look upon my works, as they are… Ruined. None would dare seek me out; tread my path. Naught awaits them in this cruel world. ''' + Tooltip: "" } LoreAzafure: { @@ -107,6 +114,7 @@ LoreAzafure: { It pains me to say this even in hindsight, but their own artisanry paved the downfall of the entire city. For the Witch and I… the air here will forever be laden with regret. There is nothing to be done. ''' + Tooltip: "" } LoreBloodMoon: { @@ -119,6 +127,7 @@ LoreBloodMoon: { Those with fire in their veins may strike out on their own, to revel in the slaughter. That is how I remember the sleepless nights from my younger days… Knee deep in corpses. ''' + Tooltip: "" } LoreBrainofCthulhu: { @@ -130,6 +139,7 @@ LoreBrainofCthulhu: { My decimation of the falsely divine left many old horrors unconstrained, with new ones birthed every year. Now, they are your stepping stones. ''' + Tooltip: "" } LoreBrimstoneElemental: { @@ -145,6 +155,7 @@ LoreBrimstoneElemental: { They fought to a standstill, fire against fire. Neither were victorious, with the city razed by flames despite her intentions. ''' + Tooltip: "" } LoreCalamitas: { @@ -163,6 +174,7 @@ LoreCalamitas: { The weight of her deeds haunts her to this day. She despises me, and I cannot blame her. Please, if you would... show her respect where I did not. ''' + Tooltip: "" } LoreCalamitasClone: { @@ -175,6 +187,7 @@ LoreCalamitasClone: { Surely Calamitas would want nothing to do with such a project. I know not how it wields her brimstone magic. Perhaps some day one of us may find answers. ''' + Tooltip: "" } LoreCeaselessVoid: { @@ -190,6 +203,7 @@ LoreCeaselessVoid: { Its eerie persistence gnawed at my mind. It did not just threaten me. It threatened everyone. Everything. Even when faced with blatant lies and harrowing danger, I simply walked away and did not return…. ''' + Tooltip: "" } LoreCorruption: { @@ -200,6 +214,7 @@ LoreCorruption: { Having slain my first Gods, I turned a blind eye as corrupt essence gushed from their rent forms and burrowed into the bowels of Terraria. The mere existence of this putrid place proves that the Gods of old were beyond redemption. ''' + Tooltip: "" } LoreCrabulon: { @@ -210,6 +225,7 @@ LoreCrabulon: { These mushrooms possess a disturbing amount of tenacity. Nothing that lays down to die in their domain is left to rest. It is this sort of ghastly, forceful exertion of control over the unwilling that led me down my path. ''' + Tooltip: "" } LoreCrimson: { @@ -220,6 +236,7 @@ LoreCrimson: { The essence of a God does not simply vanish when the body dies. It must be properly disposed of or destroyed entirely. Essence of a pious God could never fester into a mire as dreadful as this. ''' + Tooltip: "" } LoreCynosure: { @@ -236,6 +253,7 @@ LoreCynosure: { When you are prepared: seek the grave of the Light, at the summit of the Dragon Aerie. I await your challenge. ''' + Tooltip: "" } LoreDesertScourge: { @@ -246,6 +264,7 @@ LoreDesertScourge: { After Ilmeris was incinerated, it became familiar with the hunt. To survive, it quickly learned to seek greater prey. Unfortunately for the scourge, it seems that it too was prey in the end. After all, there is always a bigger fish in the sea. ''' + Tooltip: "" } LoreDestroyer: { @@ -259,6 +278,7 @@ LoreDestroyer: { Draedon understood well and granted them these massive forms. Bristling with weaponry and interlocked armor forged of blessed metal. While in truth it was repurposed mining equipment, their sheer presence on the battlefield was immense. ''' + Tooltip: "" } LoreDevourerofGods: { @@ -275,6 +295,7 @@ LoreDevourerofGods: { The Devourer's alien capabilities and domineering tactics hint that his allegiance lay elsewhere. Is he but one soldier, a mere pawn of a malevolence far beyond…? ''' + Tooltip: "" } LoreDragonfolly: { @@ -289,6 +310,7 @@ LoreDragonfolly: { It is known that Fishrons, Follies, and the Abyssal Wyrms survived the purging hunts of the Deific Era. Notably, they now are all reclusive or exceedingly violent. It is tragic how they evolved to be that way. ''' + Tooltip: "" } LoreDukeFishron: { @@ -301,6 +323,7 @@ LoreDukeFishron: { While there are many such tales of creatures hailing from draconic descent, this case is factual. Genetic heritage or not: the Fishrons lack Dragonblood and Auric souls. I would well know. ''' + Tooltip: "" } LoreEaterofWorlds: { @@ -312,6 +335,7 @@ LoreEaterofWorlds: { One will not need to search long for examples. We are all surrounded by rampant superstition and assumption. I myself have been subjected to a litany of baseless boasts and accusations in my time. ''' + Tooltip: "" } LoreEmpressofLight: { @@ -325,6 +349,7 @@ LoreEmpressofLight: { It made her sickeningly obedient. Dependent, but willingly so as they enabled her to slake her base thirst. I had deigned to slay her myself for her treachery, but she was a notoriously evasive mark. ''' + Tooltip: "" } LoreExoMechs: { @@ -341,6 +366,7 @@ LoreExoMechs: { Were he to lose his temper: if he even has one, all of life's hopes would be smothered in an instant, silenced by a torrent of silicon. Though, perhaps you may leverage his unimaginable craft to your advantage, and seek insight from him. ''' + Tooltip: "" } LoreEyeofCthulhu: { @@ -351,6 +377,7 @@ LoreEyeofCthulhu: { Now they run rampant, spawning from vile influences left unchecked. They blend well with the horrific injustice of their forebears. Slaying one merely paves the way for a dozen more. Surely this does not concern you, either. ''' + Tooltip: "" } LoreGolem: { @@ -364,6 +391,7 @@ LoreGolem: { While I believe this insignificant construct deserves no mention, the Lihzahrds revere it unflinchingly. I see no need to intervene in affairs beneath me and my people. ''' + Tooltip: "" } LoreHiveMind: { @@ -375,6 +403,7 @@ LoreHiveMind: { Fortunately for us, the futility of this effort is unmatched. The biomass obeys; even though nothing is accomplished. Divine power is known to be rooted in faith. Gods are forged of their own strength, and the mindless spread of corruption is its own foul reverence. ''' + Tooltip: "" } LoreKingSlime: { @@ -385,6 +414,7 @@ LoreKingSlime: { There is little need to worry about this. Naturally, slimes are nearly mindless and amass only by chance. Though it appears they are capable of absorbing knowledge, if only in rudimentary form. ''' + Tooltip: "" } LoreLeviathanAnahita: { @@ -398,6 +428,7 @@ LoreLeviathanAnahita: { Regardless of what you believe, they are inseparable even in death. Such stalwart loyalty! It reminds me of Yharon. ''' + Tooltip: "" } LoreMechs: { @@ -411,6 +442,7 @@ LoreMechs: { I dismissed them from duty, yet they linger here still. Scouring the land for evidence of the divine. Unfortunately for you that puts you in their crosshairs. Give them a battle worth dying in. ''' + Tooltip: "" } LoreOldDuke: { @@ -424,6 +456,7 @@ LoreOldDuke: { This particular Duke's guile is self-evident: It evaded centuries of hunting, and until now had survived a most thorough poisoning. Above almost all others, this creature was a living fable. One must wonder what goes through the mind of a fading legend…. ''' + Tooltip: "" } LorePerforators: { @@ -435,6 +468,7 @@ LorePerforators: { The mire reeks of centuries of vile manipulation and callous domination of the hapless. Judgment has long passed and only extinction is left waiting. ''' + Tooltip: "" } LorePlaguebringerGoliath: { @@ -449,6 +483,7 @@ LorePlaguebringerGoliath: { In my later days I was far from virtuous. But I would never shackle a creature to fight in my name. That would make me no better than the divine scoundrels I pursued. ''' + Tooltip: "" } LorePlantera: { @@ -463,6 +498,7 @@ LorePlantera: { Now that you have slain it, more disorderly spiritual energies are flooding the lands. The village's ignorance was shameful in its own right, but this is worse still. ''' + Tooltip: "" } LorePolterghast: { @@ -478,6 +514,7 @@ LorePolterghast: { The dragon cult was furious, their leader demanding I put the haunt down myself. I did not answer. I had long since become deaf to the world outside my crusade. Do not fall as I have. ''' + Tooltip: "" } LorePrelude: { @@ -493,6 +530,7 @@ LorePrelude: { Zeratros himself was gravely injured. It seemed his power, along with his life, would be lost forever. One mortal, sworn to the service of the Dragons, rose in determination to save their virtuous King. ''' + Tooltip: "" } LoreProfanedGuardians: { @@ -505,6 +543,7 @@ LoreProfanedGuardians: { After all, it was you that finished off the star-spawned horror that catalyzed the downfall of the Dragons. Draw her out from hiding. Have no mercy, for the Profaned Goddess shows none herself. ''' + Tooltip: "" } LoreProvidence: { @@ -519,6 +558,7 @@ LoreProvidence: { Those devoted to her were weak-willed, yet she reigned as one of the mightiest Gods. Perhaps it was their easily-swayed nature that let her draw so much power from them…. ''' + Tooltip: "" } LoreQueenBee: { @@ -530,6 +570,7 @@ LoreQueenBee: { Though its death is understandable given the circumstances, I do feel pity for these majestic beings. Fate was cruel to many of their kind. ''' + Tooltip: "" } LoreQueenSlime: { @@ -541,6 +582,7 @@ LoreQueenSlime: { Or perhaps it was overcome by desperation for survival. A glorious hunt, a fine foe. Now you know that you must chase them to the ends of Terraria. ''' + Tooltip: "" } LoreRavager: { @@ -555,6 +597,7 @@ LoreRavager: { Now caked in fresh blood, it hungered for more, setting off on an aimless rampage. I suppose its brutality serves as a reminder to be careful what you believe. ''' + Tooltip: "" } LoreRequiem: { @@ -571,6 +614,7 @@ LoreRequiem: { Wherever your journey may lead, whether you are with me or against…. May fortune favor you. For nothing else will. ''' + Tooltip: "" } LoreSignus: { @@ -585,6 +629,7 @@ LoreSignus: { The serpent ensnared both my assailants in a dimensional vortex. Assuring me they were as good as dead. Yet, Statis must have struck a bargain with Signus. He escaped his banishment unscathed. ''' + Tooltip: "" } LoreSkeletron: { @@ -596,6 +641,7 @@ LoreSkeletron: { The very walls of that place are cursed further still. The magic has long since faded as the soldiers rotted within. Do not expect to learn much from those tarnished tomes. They were penned with misguided zeal. ''' + Tooltip: "" } LoreSkeletronPrime: { @@ -608,6 +654,7 @@ LoreSkeletronPrime: { Leveling places of worship and torching those falsely devout, their expertise lay in unmaking faith with flame. Draedon understood this well. For them he crafted a visage so grim, it evoked oblivion itself. ''' + Tooltip: "" } LoreSlimeGod: { @@ -620,6 +667,7 @@ LoreSlimeGod: { Alas, the Slime god is wise enough to be cowardly. Fleeing battles it cannot win when its servants are vanquished. Perhaps fortune will aid you if you catch it unaware. ''' + Tooltip: "" } LoreStormWeaver: { @@ -634,6 +682,7 @@ LoreStormWeaver: { In his mind, the lesser serpent's similar powers could lead it to be too threatening for him to let live. Little does he know, he has forever stood in a similar position. He thinks himself invincible after all. ''' + Tooltip: "" } LoreSulphurSea: { @@ -646,6 +695,7 @@ LoreSulphurSea: { Long considered uninhabitable, its further deterioration led Draedon to designate it as a dumping ground. Years of careless waste disposal has now left the coast's transformation irreversible. ''' + Tooltip: "" } LoreTwins: { @@ -659,6 +709,7 @@ LoreTwins: { His assistance was infallible, his calculus cold and cruel. Not even the most evasive target stood a chance. ''' + Tooltip: "" } LoreUnderworld: { @@ -671,6 +722,7 @@ LoreUnderworld: { Yet despite being surrounded by magma, Azafure simply burned when their wishes were not met. Such is the unfortunate price of war, though I have no regrets fighting for my people. ''' + Tooltip: "" } LoreWallofFlesh: { @@ -684,6 +736,7 @@ LoreWallofFlesh: { My methods have since evolved. I need not contain such essences, when they can be devoured. May you channel my valor in combating the resulting outpour of energies. ''' + Tooltip: "" } LoreYharon: { @@ -705,4 +758,5 @@ LoreYharon: { Now, that hope is long withered. I am but a husk of the hero I once was, and this is the ultimate proof. Yharon may yet return, as he does, but he… he has bade me farewell. ''' + Tooltip: "" } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson b/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson index 2db3dd95ea..fc6fc8ce4d 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson @@ -360,7 +360,7 @@ AstrumAureusRelic: { AstrumDeusRelic: { DisplayName: Astrum Deus Relic - Tooltip: A glimpse into what could have been... + Tooltip: "" } BrimstoneElementalRelic: { @@ -523,7 +523,6 @@ AltarOfTheAccursedItem: { ''' Offer Ashes of Calamity at this altar to summon the Witch Doing so will create a square arena of blocks, with the altar at its center - During the battle, heart pickups only heal for half as much The Witch enrages while you are outside of the arena {$CommonItemTooltip.SpecialCrafting} ''' @@ -730,7 +729,9 @@ ResilientCandle: { DisplayName: Resilient Candle Tooltip: ''' - When placed, nearby players' defense blocks 15% more damage + when placed to make defense block 10% more damage + (60% in Classic, 85% in Expert, and 110% in Master) + This cannot be stacked with other Cirrus Candle buffs 'Neither rain nor wind can snuff its undying flame' ''' } @@ -749,8 +750,9 @@ SpitefulCandle: { DisplayName: Spiteful Candle Tooltip: ''' - When placed, nearby enemies take 5% more damage. - This extra damage bypasses enemy damage reduction and defense + when placed to deal 1.07x damage to all enemies + The extra 0.07x damage bypasses enemy defense and damage reduction + This cannot be stacked with other Cirrus Candle buffs 'Its hateful glow flickers with ire' ''' } @@ -974,8 +976,9 @@ VigorousCandle: { DisplayName: Vigorous Candle Tooltip: ''' - When placed, nearby players regenerate 0.4% of their maximum health per second + when placed to regenerate 0.4% of your maximum health per second This regeneration is at full power even while moving and bypasses Revengeance Mode caps + This cannot be stacked with other Cirrus Candle buffs 'Its brilliant light suffuses those nearby with hope' ''' } @@ -984,7 +987,8 @@ WeightlessCandle: { DisplayName: Weightless Candle Tooltip: ''' - When placed, nearby players gain 10% movement speed, 10% wing time and 5% acceleration + when placed to gain 10% increased movement speed, wing time and acceleration + This cannot be stacked with other Cirrus Candle buffs 'The floating flame seems to uplift your very spirit' ''' } @@ -2981,11 +2985,51 @@ DraedonTalkMusicBox: { Tooltip: Plays a variant of 'Signal Received' by CDMusic } +Basalt: { + DisplayName: Basalt + Tooltip: "" +} + +Driftwood: { + DisplayName: Driftwood + Tooltip: "" +} + Navystone: { DisplayName: Navystone Tooltip: "" } +Shellstone: { + DisplayName: Shellstone + Tooltip: "" +} + +PolishedNavystoneBrick: { + DisplayName: Polished Navystone Brick + Tooltip: "" +} + +ShellstoneSlab: { + DisplayName: Shellstone Slab + Tooltip: "" +} + +BlackPearlPile: { + DisplayName: Black Pearl Pile + Tooltip: "" +} + +PinkPearlPile: { + DisplayName: Pink Pearl Pile + Tooltip: "" +} + +WhitePearlPile: { + DisplayName: White Pearl Pile + Tooltip: "" +} + NovaeSlag: { DisplayName: Novae Slag Tooltip: "" @@ -3411,6 +3455,16 @@ ScoriaBrickWall: { Tooltip: "" } +ShellstoneSlabWall: { + DisplayName: Shellstone Slab Wall + Tooltip: "" +} + +ShellstoneWall: { + DisplayName: Shellstone Wall + Tooltip: "" +} + SilvaWall: { DisplayName: Silva Wall Tooltip: "" @@ -3578,3 +3632,78 @@ WaterTurret: { Cannot attack while a boss is alive ''' } + +CyanCoral: { + DisplayName: Cyan Coral + Tooltip: "" +} + +MagentaCoral: { + DisplayName: Magenta Coral + Tooltip: "" +} + +OrangeCoral: { + DisplayName: Orange Coral + Tooltip: "" +} + +LimeCoral: { + DisplayName: Lime Coral + Tooltip: "" +} + +YellowCoral: { + DisplayName: Yellow Coral + Tooltip: "" +} + +Runestone: { + DisplayName: Runestone + Tooltip: "" +} + +RuneSand: { + DisplayName: Runesand + Tooltip: "" +} + +Limestone: { + DisplayName: Limestone + Tooltip: "" +} + +PolypSand: { + DisplayName: Polyp Sand + Tooltip: "" +} + +VolcanicSand: { + DisplayName: Volcanic Sand + Tooltip: "" +} + +DriftwoodWall: { + DisplayName: Driftwood Wall + Tooltip: "" +} + +AlgalSlateItem: { + DisplayName: Algal Slate + Tooltip: "" +} + +PeatItem: { + DisplayName: Peat + Tooltip: "" +} + +PeatMossItem: { + DisplayName: Peat Moss + Tooltip: "" +} + +ScintillatingBloom: { + DisplayName: Scintillating Bloom + Tooltip: "" +} diff --git a/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson b/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson index 0c7a8a0250..d90f4519fd 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson @@ -18,7 +18,7 @@ Baguette: { Tooltip: ''' {$CommonItemTooltip.MinorStats} - Boosts the effects of Red Wine + Red Wine heals 250 HP, but reduces life regen by 2 HP/s [c/FCE391:'je suis Monte'] ''' } @@ -104,7 +104,8 @@ PhotosynthesisPotion: { DisplayName: Photosynthesis Potion Tooltip: ''' - You regen life quickly while not moving, this effect is five times as strong during daytime + Grants +0.5 HP/s life regen and accelerates natural life regen while not moving + This natural life regen effect is five times as strong during daytime Dropped hearts heal more HP ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson b/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson index 09de1c4991..9329498724 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson @@ -231,11 +231,14 @@ ProfanedShard: { Tooltip: ''' [SPAWN] - Enrage when not in the Hallow or Underworld Not consumable 'Her Guardians seek the holder of such vast stolen power.' ''' - SpawnNormal: Summons the Profaned Guardians when used in the Hallow or Underworld during daytime + SpawnNormal: + ''' + Summons the Profaned Guardians when used in the Hallow or Underworld + Enrages when fought during nighttime + ''' SpawnRemix: Summons the Profaned Guardians when used in the Hallow or Underworld } @@ -302,11 +305,7 @@ Teratoma: { Terminus: { DisplayName: Terminus GFBName: Ogscule - Tooltip: - ''' - Activates Boss Rush Mode, using it again will deactivate Boss Rush Mode - During the Boss Rush, all wires and wired devices will be disabled - ''' + Tooltip: Activates Boss Rush Mode, using it again will deactivate Boss Rush Mode } YharonEgg: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Tools.hjson b/Localization/en-US/Mods.CalamityMod.Items.Tools.hjson index 7d1594a478..d6ff87ed24 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Tools.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Tools.hjson @@ -210,3 +210,48 @@ WulfrumTreasurePinger: { This contraption seems incredibly shoddy. [c/FC4903:It'll break sooner than later for sure] ''' } + +AcidwoodPickaxe: { + DisplayName: Acidwood Pickaxe + Tooltip: "" +} + +DriftwoodPickaxe: { + DisplayName: Driftwood Pickaxe + Tooltip: Improved efficiency while you are wet +} + +MonolithPickaxe: { + DisplayName: Monolith Pickaxe + Tooltip: "" +} + +AcidwoodAxe: { + DisplayName: Acidwood Axe + Tooltip: "" +} + +DriftwoodAxe: { + DisplayName: Driftwood Axe + Tooltip: Improved efficiency while you are wet +} + +MonolithAxe: { + DisplayName: Monolith Axe + Tooltip: "" +} + +AcidwoodHammer: { + DisplayName: Acidwood Hammer + Tooltip: "" +} + +DriftwoodHammer: { + DisplayName: Driftwood Hammer + Tooltip: Improved efficiency while you are wet +} + +MonolithHammer: { + DisplayName: Monolith Hammer + Tooltip: "" +} diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson index 965e09cde1..d55c6d937c 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson @@ -397,11 +397,6 @@ HadalUrn: { ''' } -HarvestStaff: { - DisplayName: Harvest Staff - Tooltip: Casts flaming pumpkins -} - HeliumFlash: { DisplayName: Helium Flash Tooltip: @@ -807,6 +802,16 @@ Teslastaff: { ''' } +TheCauldron: { + DisplayName: The Cauldron + Tooltip: + ''' + Launches lava bombs which explode into more lava bombs + 80% reduced mana usage while submerged in lava or while in the underworld + 'Believe it or not, its original wielder was only a few centimeters tall!' + ''' +} + TheDanceofLight: { DisplayName: The Dance of Light Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson index afeab0b76b..0d11ae3872 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson @@ -287,7 +287,7 @@ CosmicDischarge: { Tooltip: ''' Striking an enemy with the whip causes glacial explosions and grants the player the cosmic freeze buff - This buff gives the player increased life regen while standing still and freezes enemies near the player + This buff gives the player +2 HP/s life regen while standing still and freezes enemies near the player ''' } @@ -707,7 +707,7 @@ Lacerator: { DisplayName: Lacerator Tooltip: ''' - Enemies that are hit by the yoyo will have their life drained + Accelerates natural life regeneration on hits with the yoyo An exceptionally agile yoyo [GFB] ''' @@ -970,6 +970,16 @@ RemsRevenge: { ''' } +Respiteblock: { + DisplayName: Respiteblock + Tooltip: + ''' + A glistening white chainsaw that spews green and purple blood all over + Hitting enemies with the blade will heal you and deal immense damage + [c/0e8401:'It's Ok To Be Dangerous'] + ''' +} + Riptide: { DisplayName: Riptide Tooltip: Sprays a spiral of aqua streams @@ -1425,3 +1435,18 @@ YinYo: { A very agile yoyo ''' } + +AcidwoodSword: { + DisplayName: Acidwood Sword + Tooltip: "" +} + +DriftwoodSword: { + DisplayName: Driftwood Sword + Tooltip: This sword is stronger while you are wet +} + +MonolithSword: { + DisplayName: Monolith Sword + Tooltip: "" +} diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index 5b6a9163a6..ad463024c5 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -211,12 +211,14 @@ BulletFilledShotgun: { ''' } -Butcher: { - DisplayName: Butcher +Buzzkill: { + DisplayName: Buzzkill Tooltip: ''' - Fires bullets faster and more accurately the longer you hold the trigger - 25% chance to save ammo + Hold to rev up a buzzsaw that deals close-range damage + Release to fire the buzzsaw, which bounces off tiles and lacerates foes + Revving up the saws increases their damage and allows them to pierce more enemies + 'Not to be confused with the Sawed-On Shotgun' ''' } @@ -433,15 +435,6 @@ Drataliornus: { ''' } -ElementalBlaster: { - DisplayName: Elemental Blaster - Tooltip: - ''' - Fires a storm of rainbow blasts - Does not consume ammo - ''' -} - ElementalEruption: { DisplayName: Elemental Eruption Tooltip: @@ -466,8 +459,10 @@ FetidEmesis: { DisplayName: Fetid Emesis Tooltip: ''' - Has a chance to release rotten chunks instead of bullets - 40% chance to save ammo + Fires an accelerating stream of bullets until the barrel overheats + When the barrel overheats, a spread of fetid chunks is vomited out + After firing, the gun must cool back down before it can be used again + 75% chance to save ammo ''' } @@ -653,7 +648,7 @@ Infinity: { DisplayName: Infinity Tooltip: ''' - Fires a barrage of energy bolts that split and bounce + Fires a twin stream of energy bolts that split Press to fire a barrage of normal bullets 'They say infinity is neverending, yet you hold it in your hands' ''' @@ -994,7 +989,7 @@ RealmRavager: { DisplayName: Realm Ravager Tooltip: ''' - Shoots a burst of 3 to 4 bullets + Shoots a burst of 4 bullets Converts musket balls into explosive bullets ''' } @@ -1160,9 +1155,10 @@ SpeedBlaster: { Tooltip: ''' Rapidly fires phosphorescent paintball shots - Press to eject a powerful glob which propels you while moving - This ability has a cooldown of {0} seconds - While under cooldown, you fire more rapidly with greater accuracy + Press to eject a powerful paint stream of a different color + Using this ability rapidly propels you in the direction you are moving + This ability has a {0} second cooldown + During this cooldown, you fire more rapidly with greater accuracy ''' } @@ -1229,6 +1225,31 @@ SulphuricAcidCannon: { Tooltip: Fires an acidic shot that sticks to enemies and dissolves them } +SuperradiantSlaughterer: { + DisplayName: Superradiant Slaughterer + Tooltip: + ''' + [MAIN] + [ALT] + [c/ad1717:'No one knows how it turns blood into rainbows...'] + ''' + MainInfo: + ''' + Hold to rev up an elemental buzzsaw that deals close-range damage + Release to fire the buzzsaw to pierce through and lacerate foes + Fired buzzsaws bounce off tiles and return to the player after winding down + When returning, the saws release extra homing bolts depending on the number of enemy and tile hits + Revving up the saws increases their damage and allows them to pierce more enemies + ''' + AltInfo: + ''' + Press to eject a lingering buzzsaw towards the cursor that fires homing bolts + Using this ability rapidly propels you in the direction you are moving + This ability has a {0} second cooldown + During this cooldown, buzzsaws home to the cursor and constantly release homing bolts while returning + ''' +} + SurgeDriver: { DisplayName: Surge Driver Tooltip: @@ -1242,8 +1263,9 @@ Svantechnical: { DisplayName: Svantechnical Tooltip: ''' - Fires several barrages of bullets - Press to zoom out + Fires a trinity of energy bolts that split into beams that track your cursor + Press to fire a barrage of normal bullets + 'The age old balance of trading damage for frames' ''' } @@ -1406,3 +1428,18 @@ WulfrumBlunderbuss: { [c/83B87E:In fact, it is quite common for a robot to be turned into ammo right after it stops functioning.'] ''' } + +AcidwoodBow: { + DisplayName: Acidwood Bow + Tooltip: "" +} + +DriftwoodBow: { + DisplayName: Driftwood Bow + Tooltip: This bow is stronger while you are wet +} + +MonolithBow: { + DisplayName: Monolith Bow + Tooltip: "" +} diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson index abd9755e31..f3b984bfb6 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson @@ -193,7 +193,7 @@ CorpusAvertor: { Attacks grant lifesteal based on damage dealt The lower your HP the more damage this weapon does and heals the player on enemy hits Stealth strikes throw a single rainbow outlined dagger - On enemy hits, this dagger boosts the damage and life regen of all members of your team + On enemy hits, this dagger grants 10% damage and +2 HP/s life regen to all members of your team However, there is a small chance it will cut your health in half instead 'Seems like it has worn down over time' ''' @@ -777,6 +777,7 @@ NanoblackReaper: { Stealth strikes cause the scythe to create a large amount of homing afterimages instead of energy blades 'She smothered them in Her hatred' ''' + HoldShiftTooltip: "'He who picks up the pen writes the script. She plans to never let go.'" } NastyCholla: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson index 0b7073c368..2fa9a00315 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson @@ -789,7 +789,7 @@ WulfrumController: { Summons a wulfrum droid to fight for you Hold right click while holding the remote to switch all of your drones into supercharge mode Supercharged droids will stop attacking and focus wulfrum energy onto you - The beam provides extra regeneration and defense + Supercharged droids provide +0.5 HP/s life regen and 3 defense per droid Can also be used to heal other players by keeping your mouse cursor close enough to them ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Misc.hjson b/Localization/en-US/Mods.CalamityMod.Misc.hjson index 9a650f9ea6..0066b7de9b 100644 --- a/Localization/en-US/Mods.CalamityMod.Misc.hjson +++ b/Localization/en-US/Mods.CalamityMod.Misc.hjson @@ -21,12 +21,6 @@ RecipeGroup: { // Status WikiStatus1: "[i:Book] [c/EE4939:Note: The Fandom wiki is no longer supported by Calamity.] [i:Book]" WikiStatus2: "[i:Book] [c/EE4939:Check out the Official Calamity Mod Wiki at ][c/3989FF:calamitymod.wiki.gg][c/EE4939:!] [i:Book]" -MusicModReminder: "[i:MusicBoxMartians] [c/71DFF5:Remember to also install the Calamity Music Mod to experience our soundtrack!] [i:MusicBoxMartians]" -GimmeSwagPlushieCampaign: - ''' - - [i:GreenPresent] [c/3BE022:NOW AVAILABLE! Supreme Calamitas Plushie!] [c/3989FF:calamitymod.com/plush] [i:GreenPresent] - ''' // Recipe Conditions Tier1ArsenalRecipeCondition: View an unencrypted schematic from the lab near the Sunken Sea Tier2ArsenalRecipeCondition: Decrypt a schematic from the lab in the large planetoid in the sky @@ -62,3 +56,5 @@ EtherealCoreText: You have already used an Ethereal Core. Your brain would escap PhantomHeartText: You have already used a Phantom Heart. The voices are telling you it's a bad idea to use it again. SulphurSwitchLeft: The Sulphurous Sea is now on the left side of the world. SulphurSwitchRight: The Sulphurous Sea is now on the right side of the world. +// Point Blank +PointBlank: Does extra damage to enemies shot at point-blank range diff --git a/Localization/en-US/Mods.CalamityMod.NPCs.hjson b/Localization/en-US/Mods.CalamityMod.NPCs.hjson index 1d7421b644..42d943f37f 100644 --- a/Localization/en-US/Mods.CalamityMod.NPCs.hjson +++ b/Localization/en-US/Mods.CalamityMod.NPCs.hjson @@ -623,3 +623,7 @@ WITCH: { Princess_LovesNPC: "{NPCName} is always lonely, it's why I want to hang out with her, no one should be left alone like that!" } } + +KingSlimeJewelEmerald.DisplayName: King Slime Jewel Emerald +KingSlimeJewelRuby.DisplayName: King Slime Jewel Ruby +KingSlimeJewelSapphire.DisplayName: King Slime Jewel Sapphire diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson index 5d772b0fbf..c17be87336 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson @@ -41,6 +41,8 @@ BrimstoneFireball.DisplayName: Brimstone Fireball BrimstoneHellfireballFriendly.DisplayName: Hellfireball BrimstoneHomer.DisplayName: Brimstone Homer BrimstoneTentacle.DisplayName: Brimstone Tentacle +CauldronProj.DisplayName: Smauldron +CauldronProjSmall.DisplayName: Smaullerdron ChronoIcicleLarge.DisplayName: Chrono Icicle ChronoIcicleSmall.DisplayName: Chrono Icicle ChronomancersScytheHoldout.DisplayName: Chronomancer's Scythe diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson index 6f5c733c72..2116398cd1 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson @@ -268,8 +268,8 @@ TaintedBladeSlasher.DisplayName: Tainted Blade TenebreusTidesWaterProjectile.DisplayName: Water Spear TenebreusTidesWaterSpear.DisplayName: Tenebreus Tides Water Spear TenebreusTidesWaterSword.DisplayName: Tenebreus Tides Water Sword -TerratomereBeam.DisplayName: Terra Slash Beam -TerratomereBigSlash.DisplayName: Terratomere Slash +TerratomereMeleeSlash.DisplayName: Terratomere Slash +TerratomereSwordBeam.DisplayName: Terra Slash Beam TerratomereExplosion.DisplayName: Terratomere Explosion TerratomereHoldoutProj.DisplayName: Terratomere TerratomereSlash.DisplayName: Terratomere Slash @@ -316,3 +316,5 @@ WulfrumScrewdriverProj.DisplayName: Wulfrum Screwdriver YateveoBloomProj.DisplayName: Yateveo Bloom YinYoDark.DisplayName: Dark Shard YinYoLight.DisplayName: Light Shard +RespiteblockHoldout.DisplayName: Respiteblock +RespiteblockBlood.DisplayName: Respiteblock Blood diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Misc.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Misc.hjson index 2afb5dbc69..867973a1e3 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Misc.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Misc.hjson @@ -68,3 +68,5 @@ PlagueShot.DisplayName: Plague Shot PlagueShotBuffer.DisplayName: Plague Shot WaterShot.DisplayName: Water Shot WaterShotBuffer.DisplayName: Water Shot +Lilyglow.DisplayName: Lilyglow +WaterAlgae.DisplayName: Water Algae diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index ebaa469e9d..00a4491211 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -35,6 +35,7 @@ BouncingShotgunPellet.DisplayName: Shotgun Pellet BrimstoneBolt.DisplayName: Brimstone Bolt BrimstoneFireFriendly.DisplayName: Brimstone Fire BubonicRoundProj.DisplayName: Bubonic Round +BuzzkillSaw.DisplayName: Buzzsaw CardClub.DisplayName: Club CardClubSplit.DisplayName: Club CardDiamond.DisplayName: Diamond @@ -169,7 +170,6 @@ PristineFire.DisplayName: Pristine Fire PristineSecondary.DisplayName: Pristine Lingering Fire PumplerGrenade.DisplayName: Squash Shell P90Round.DisplayName: Armor-piercing Round -RainbowBlast.DisplayName: Blast RainbowFront.DisplayName: Rainbow RainbowTrail.DisplayName: Rainbow RealmRavagerBullet.DisplayName: Explosive Bullet @@ -220,6 +220,9 @@ StarmageddonStar2.DisplayName: Starmageddon Star StormSurgeTornado.DisplayName: Surge SulphuricBlast.DisplayName: Sulphuric Blast SuperballBulletProj.DisplayName: Superball Bullet +SuperradiantBolt.DisplayName: Superradiant Bolt +SuperradiantSawLingering.DisplayName: Ultraradiant Saw +SuperradiantSaw.DisplayName: Superradiant Saw TelluricGlareArrow.DisplayName: Radiant Arrow TheMaelstromExplosion.DisplayName: Reaper Explosion TheMaelstromShark.DisplayName: Reaper Shark @@ -249,3 +252,4 @@ WildfireBloomFire.DisplayName: Wildfire Fire WildfireBloomFlare.DisplayName: Wildfire Flare WulfrumScrapBullet.DisplayName: High Speed Scrap NitroShot.DisplayName: Nitro Shot +ChargedBlastSplit.DisplayName: Charged Blast Split diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson index f56e0e7b4a..f7c34ecdda 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson @@ -94,6 +94,7 @@ PauldronExplosion.DisplayName: Pauldron Explosion PendantProjectile1.DisplayName: Prism Shard PendantProjectile2.DisplayName: Prism Shard PendantProjectile3.DisplayName: Prism Shard +PlaguePulse.DisplayName: Plague Pulse PoisonousSeawater.DisplayName: Seawater PscTransformAnimation.DisplayName: Psc Transform Animation PscTransformRocks.DisplayName: Psc Transform Rocks diff --git a/Localization/en-US/Mods.CalamityMod.Status.Death.hjson b/Localization/en-US/Mods.CalamityMod.Status.Death.hjson index 7a65173f13..a3bcc7dbdf 100644 --- a/Localization/en-US/Mods.CalamityMod.Status.Death.hjson +++ b/Localization/en-US/Mods.CalamityMod.Status.Death.hjson @@ -67,6 +67,9 @@ HolyFlames1: "{0} fell prey to their sins." HolyFlames2: "{0} burst into sinless ash." HolyFlames3: "{0} was purified by the profaned flame." HolyInferno: "{0} was incinerated by the profaned backdraft." +Laceration1: "{0} expired from heavy internal bleeding." +Laceration2: "{0} was turned into a fine red mist." +Laceration3: "{0} forgot that blood is supposed to stay inside the body." ManaBurn: "{0}'s life was completely converted into mana." ManaConversionEnchant: "{0}'s life was fully tapped by dark magics." MiracleBlight1: "{0} was blown away by miraculous technological advancements." diff --git a/Localization/en-US/Mods.CalamityMod.UI.hjson b/Localization/en-US/Mods.CalamityMod.UI.hjson index 7fbda27580..1ed917404e 100644 --- a/Localization/en-US/Mods.CalamityMod.UI.hjson +++ b/Localization/en-US/Mods.CalamityMod.UI.hjson @@ -119,6 +119,7 @@ Cooldowns: { SpeedBlasterBoost: Speed Blaster Boost SpongeDurability: Sponge Barrier Durability SpongeRecharge: Sponge Barrier Recharge + SuperradiantSawBoost: Superradiant Saw Boost TarragonCloak: Tarragon Cloak Cooldown TarragonImmunity: Tarragon Immunity Cooldown UniverseSplitter: Universe Splitter Cooldown @@ -260,7 +261,7 @@ Communication: { The final to begin construction was Artemis. Rather than being founded on raw power, it was made to be the apex of speed and accuracy. There is elegance in simplicity, for all of Artemis' combat efficacy comes from an onboard predictive AI and a battery of hard-light bolt emitters.\n - It was the perfect partner to its twin and required no revisions. Organic beings are naturally inclined to fixate their senses on fire, presenting Artemis with the perfect opportunity to strike with unparalleled precision. + It was the perfect partner to its twin and required only a single revision. Organic beings are naturally inclined to fixate their senses on fire, presenting Artemis with the perfect opportunity to strike with unparalleled precision. ''' } @@ -614,3 +615,5 @@ DraedonFacility: Other minor research projects Abyss: Disposing of Silva's remains SulphurSea2: Irradiating one of the oceans Roxcalibur: I wanna rock +// Hold Shift tooltip default +HoldShiftTooltipExtensionIndicator: Hold "Left Shift" for more diff --git a/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson index f1625a0e8f..3e221f5442 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.Armor.hjson @@ -88,6 +88,12 @@ SetBonus: { Enemy hits release mythril flares, which home in on enemies after a short delay Once a flare is created, there is a {0} frame delay before another one can appear ''' + Nebula: + ''' + Pink damage boosters grant 7.5% damage per stack + Orange life boosters grant +2 HP/s life regen per stack + Blue mana boosters grant +5 MP/s mana regen per stack + ''' Necro: ''' Allows you to temporarily survive fatal damage @@ -99,6 +105,11 @@ SetBonus: { Increases minion damage by 15% Grants immunity to fire blocks and temporary immunity to lava ''' + Palladium: + ''' + Grants +2 HP/s life regeneration after striking an enemy + This life regeneration bypasses negative life regeneration + ''' PlatinumChainmail: 3% increased critical strike chance Platinum: ''' diff --git a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson index aed63d706f..4373a9e37f 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson @@ -4,7 +4,7 @@ BuffDescription: { BeetleMight: Melee damage and speed increase by {0}% and {1}% respectively ChaosState: Rod of Discord teleports are disabled LeafCrystal: Emits powerful life pulses at nearby enemies - WarmthExtra: Grants immunity to Chilled, Frozen and Glacial State + WarmthExtra: Reduced durations of Chilled, Frozen, and Glacial State WeaponImbueConfetti: All attacks cause confetti to appear WeaponImbueCursedFlames: Melee, Whip, and Rogue attacks inflict enemies with cursed flames WeaponImbueFire: Melee, Whip, and Rogue attacks set enemies on fire diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 086ae693e4..fbf4dbf23b 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -235,7 +235,6 @@ namespace CalamityMod ItemRedirect(ItemType(), "Elderberry (calamity)"); ItemRedirect(ItemType(), "Pineapple (calamity)"); ItemRedirect(ItemType(), "Trash Can (pet)"); - ItemRedirect(ItemType(), "Butcher (weapon)"); ItemRedirect(ItemType(), "Sandstorm (weapon)"); ItemRedirect(ItemType(), "Thunderstorm (weapon)"); // Lore items @@ -296,9 +295,9 @@ namespace CalamityMod // Enemies EnemyRedirect(NPCType(), "Hive (enemy)"); - EnemyRedirect(NPCType(), "Ruby Jewel (enemy)"); - EnemyRedirect(NPCType(), "Sapphire Jewel (enemy)"); - EnemyRedirect(NPCType(), "Emerald Jewel (enemy)"); + EnemyRedirect(NPCType(), "Crown Jewels"); + EnemyRedirect(NPCType(), "Crown Jewels"); + EnemyRedirect(NPCType(), "Crown Jewels"); EnemyRedirect(NPCType(), "Tooth Ball (Old Duke)"); EnemyRedirect(NPCType(), "Enchantment"); EnemyRedirect(NPCType(), "%3F%3F%3F"); diff --git a/NPCs/Abyss/ColossalSquid.cs b/NPCs/Abyss/ColossalSquid.cs index 3081a1a826..e44d689057 100644 --- a/NPCs/Abyss/ColossalSquid.cs +++ b/NPCs/Abyss/ColossalSquid.cs @@ -630,7 +630,7 @@ namespace CalamityMod.NPCs.Abyss public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ItemID.BlackInk, 1, 3, 5); - npcLoot.Add(ModContent.ItemType(), 5); + npcLoot.Add(ModContent.ItemType(), 3); var postLevi = npcLoot.DefineConditionalDropSet(DropHelper.PostLevi()); postLevi.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 2, 26, 38, 31, 45)); diff --git a/NPCs/Abyss/Cuttlefish.cs b/NPCs/Abyss/Cuttlefish.cs index 1770f6b684..fe588479a6 100644 --- a/NPCs/Abyss/Cuttlefish.cs +++ b/NPCs/Abyss/Cuttlefish.cs @@ -379,7 +379,7 @@ namespace CalamityMod.NPCs.Abyss public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ModContent.ItemType(), 2); - npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 20, 10)); + npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 10, 5)); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/Abyss/SlabCrab.cs b/NPCs/Abyss/SlabCrab.cs index 0eca2a663d..14a0dbf9f7 100644 --- a/NPCs/Abyss/SlabCrab.cs +++ b/NPCs/Abyss/SlabCrab.cs @@ -309,7 +309,7 @@ namespace CalamityMod.NPCs.Abyss { if (spawnInfo.Player.Calamity().ZoneAbyssLayer1 && spawnInfo.Water) { - return SpawnCondition.OceanMonster.Chance; + return SpawnCondition.CaveJellyfish.Chance; } return 0f; } diff --git a/NPCs/AstrumDeus/AstrumDeusBody.cs b/NPCs/AstrumDeus/AstrumDeusBody.cs index df1beaab43..dfc682dcb0 100644 --- a/NPCs/AstrumDeus/AstrumDeusBody.cs +++ b/NPCs/AstrumDeus/AstrumDeusBody.cs @@ -82,6 +82,7 @@ namespace CalamityMod.NPCs.AstrumDeus public override void SendExtraAI(BinaryWriter writer) { + writer.Write(NPC.localAI[3]); writer.Write(NPC.dontTakeDamage); for (int i = 0; i < 4; i++) writer.Write(NPC.Calamity().newAI[i]); @@ -89,6 +90,7 @@ namespace CalamityMod.NPCs.AstrumDeus public override void ReceiveExtraAI(BinaryReader reader) { + NPC.localAI[3] = reader.ReadSingle(); NPC.dontTakeDamage = reader.ReadBoolean(); for (int i = 0; i < 4; i++) NPC.Calamity().newAI[i] = reader.ReadSingle(); diff --git a/NPCs/BrimstoneElemental/Brimling.cs b/NPCs/BrimstoneElemental/Brimling.cs index f4fc581261..744956486a 100644 --- a/NPCs/BrimstoneElemental/Brimling.cs +++ b/NPCs/BrimstoneElemental/Brimling.cs @@ -232,7 +232,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental NPC.ai[2] = 0f; NPC.ai[3] = 0f; - SoundEngine.PlaySound(SoundID.Item8, NPC.Center); + SoundEngine.PlaySound(BrimstoneElemental.TeleportSound, NPC.Center); for (int j = 0; j < 20; j++) { @@ -251,6 +251,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental float projectileVelocity = 5f; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); + SoundEngine.PlaySound(BrimstoneElemental.HellfireballSound, NPC.Center); Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Normalize(Main.player[Main.npc[CalamityGlobalNPC.brimstoneElemental].target].Center - NPC.Center) * projectileVelocity, type, damage, 0f, Main.myPlayer, Main.player[Main.npc[CalamityGlobalNPC.brimstoneElemental].target].position.X, Main.player[Main.npc[CalamityGlobalNPC.brimstoneElemental].target].position.Y); } diff --git a/NPCs/BrimstoneElemental/BrimstoneElemental.cs b/NPCs/BrimstoneElemental/BrimstoneElemental.cs index 39e33068b0..68297ec7b6 100644 --- a/NPCs/BrimstoneElemental/BrimstoneElemental.cs +++ b/NPCs/BrimstoneElemental/BrimstoneElemental.cs @@ -7,11 +7,9 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; -using CalamityMod.Items.Mounts; using CalamityMod.Items.Placeables.Furniture.BossRelics; using CalamityMod.Items.Placeables.Furniture.DevPaintings; using CalamityMod.Items.Placeables.Furniture.Trophies; -using CalamityMod.Items.Placeables.Pylons; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; @@ -22,6 +20,7 @@ using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.GameContent.ItemDropRules; @@ -44,6 +43,12 @@ namespace CalamityMod.NPCs.BrimstoneElemental } public int currentMode = (int)Elemental.Brimstone; + public static readonly SoundStyle TeleportSound = new("CalamityMod/Sounds/Custom/BrimstoneElemental/Teleport"); + public static readonly SoundStyle HellfireballSound = new("CalamityMod/Sounds/Custom/BrimstoneElemental/Hellfireball", 3); + public static readonly SoundStyle DartSound = new("CalamityMod/Sounds/Custom/BrimstoneElemental/BrimstoneDartRing", 3); + public static readonly SoundStyle HideInShellSound = new("CalamityMod/Sounds/Custom/BrimstoneElemental/ShellTransform"); + public static readonly SoundStyle ShellFireSound = new("CalamityMod/Sounds/Custom/BrimstoneElemental/ShellProjectiles", 3); + public override void SetStaticDefaults() { Main.npcFrameCount[NPC.type] = 12; diff --git a/NPCs/CalClone/SoulSeeker.cs b/NPCs/CalClone/SoulSeeker.cs index 2731b95647..adbefe7503 100644 --- a/NPCs/CalClone/SoulSeeker.cs +++ b/NPCs/CalClone/SoulSeeker.cs @@ -108,10 +108,8 @@ namespace CalamityMod.NPCs.CalClone start = false; } - NPC.TargetClosest(); - float projectileSpeed = 9f; - Vector2 velocity = Main.player[NPC.target].Center - NPC.Center; + Vector2 velocity = Main.player[parent.target].Center - NPC.Center; velocity.Normalize(); velocity *= projectileSpeed; NPC.rotation = velocity.ToRotation() + MathHelper.Pi; @@ -126,7 +124,7 @@ namespace CalamityMod.NPCs.CalClone int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, damage, 1f, NPC.target, 1f, 0f, projectileSpeed * 2f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, damage, 1f, parent.target, 1f, 0f, projectileSpeed * 2f); } timer = 0; } diff --git a/NPCs/CalamityAIs/CalamityBossAIs/AquaticScourgeAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/AquaticScourgeAI.cs index b1086e7143..2ddd4e677e 100644 --- a/NPCs/CalamityAIs/CalamityBossAIs/AquaticScourgeAI.cs +++ b/NPCs/CalamityAIs/CalamityBossAIs/AquaticScourgeAI.cs @@ -87,10 +87,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - Player player = Main.player[npc.target]; bool notOcean = player.position.Y < 300f || diff --git a/NPCs/CalamityAIs/CalamityBossAIs/AstrumAureusAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/AstrumAureusAI.cs index 5a651886f6..e91a6698d7 100644 --- a/NPCs/CalamityAIs/CalamityBossAIs/AstrumAureusAI.cs +++ b/NPCs/CalamityAIs/CalamityBossAIs/AstrumAureusAI.cs @@ -41,6 +41,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Variables bool bossRush = BossRushEvent.BossRushActive; bool expertMode = Main.expertMode || bossRush; + bool masterMode = Main.masterMode || bossRush; bool revenge = CalamityWorld.revenge || bossRush; bool death = CalamityWorld.death || bossRush; @@ -58,13 +59,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs calamityGlobalNPC.DR = exhausted ? 0.25f : 0.5f; npc.defense = exhausted ? npc.defDefense / 2 : npc.defDefense; - // Don't fire projectiles and don't increment phase timers for 4 seconds after the teleport phase to avoid cheap bullshit - float noProjectileOrPhaseIncrementTime = 240f; - - bool dontAttack = npc.localAI[3] > 0f; - if (dontAttack) - npc.localAI[3] -= 1f; - // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); @@ -75,6 +69,19 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs Player player = Main.player[npc.target]; + // Don't fire projectiles and don't increment phase timers for 4 seconds after the teleport phase to avoid cheap bullshit + float noProjectileOrPhaseIncrementTime = 240f; + + bool dontAttack = npc.localAI[3] > 0f; + if (dontAttack) + { + npc.localAI[3] -= 1f; + if (npc.justHit) + npc.localAI[3] -= masterMode ? 7f : expertMode ? 5f : 3f; + if (npc.Distance(player.Center) < 240f) + npc.localAI[3] -= masterMode ? 4f : expertMode ? 2f : 1f; + } + float enrageScale = bossRush ? 1f : 0f; if ((Main.IsItDay() && !player.Calamity().ZoneAstral) || bossRush) { @@ -336,6 +343,11 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Stay vulnerable for 3 seconds npc.ai[1] += 1f; + if (npc.justHit) + npc.ai[1] += masterMode ? 7f : expertMode ? 5f : 3f; + if (npc.Distance(player.Center) < 240f) + npc.ai[1] += masterMode ? 4f : expertMode ? 2f : 1f; + if (npc.ai[1] >= 180f || bossRush) { // Set AI to random state and reset other AI arrays @@ -442,7 +454,11 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Walk for a maximum of 6 seconds if (!dontAttack) + { npc.ai[1] += 1f; + if (npc.Distance(player.Center) < 240f) + npc.ai[1] += masterMode ? 4f : expertMode ? 2f : 1f; + } if (npc.ai[1] >= ((bossRush ? 270f : 360f) - (death ? 90f * (1f - lifeRatio) : 0f))) { diff --git a/NPCs/CalamityAIs/CalamityBossAIs/BrimstoneElementalAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/BrimstoneElementalAI.cs index 77a9dc6558..8a8807a89e 100644 --- a/NPCs/CalamityAIs/CalamityBossAIs/BrimstoneElementalAI.cs +++ b/NPCs/CalamityAIs/CalamityBossAIs/BrimstoneElementalAI.cs @@ -5,18 +5,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.NPCs.Abyss; -using CalamityMod.NPCs.AquaticScourge; -using CalamityMod.NPCs.AstrumAureus; -using CalamityMod.NPCs.AstrumDeus; using CalamityMod.NPCs.BrimstoneElemental; -using CalamityMod.NPCs.Bumblebirb; -using CalamityMod.NPCs.CalClone; -using CalamityMod.NPCs.CeaselessVoid; -using CalamityMod.NPCs.Crags; -using CalamityMod.NPCs.NormalNPCs; -using CalamityMod.NPCs.OldDuke; -using CalamityMod.NPCs.SulphurousSea; -using CalamityMod.NPCs.SunkenSea; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Enemy; using CalamityMod.Sounds; @@ -46,10 +35,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - Player player = Main.player[npc.target]; bool despawnDistance = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; @@ -99,6 +84,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Variables for buffing the AI bool bossRush = BossRushEvent.BossRushActive; bool expertMode = Main.expertMode || bossRush; + bool masterMode = Main.masterMode || bossRush; bool revenge = CalamityWorld.revenge || bossRush; bool death = CalamityWorld.death || bossRush; @@ -232,7 +218,10 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs if (npc.localAI[3] > 0f) npc.localAI[3] -= 1f; else if (phase == 4) + { npc.localAI[3] = 3f; + SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.HideInShellSound, player.Center); + } npc.netUpdate = true; @@ -253,7 +242,12 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs if (Main.netMode != NetmodeID.MultiplayerClient) { npc.localAI[1] += 1f; - if (npc.localAI[1] >= (bossRush ? 5f : death ? 30f : 180f)) + if (npc.justHit) + npc.localAI[1] += masterMode ? 7f : expertMode ? 5f : 3f; + if (npc.Distance(player.Center) < 160f) + npc.localAI[1] += masterMode ? 4f : expertMode ? 2f : 1f; + + if (npc.localAI[1] >= (bossRush ? 60f : death ? 120f : 180f)) { npc.TargetClosest(); npc.localAI[1] = 0f; @@ -307,7 +301,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs Main.dust[dust].noGravity = true; Main.dust[dust].fadeIn = 1f; } - npc.alpha += bossRush ? 4 : death ? 3 : 2; + npc.alpha += bossRush ? 15 : death ? 5 : revenge ? 4 : expertMode ? 3 : 2; if (npc.alpha >= 255) { int spawnType = brimmy.currentMode == 3 ? NPCID.AngryNimbus : ModContent.NPCType(); @@ -317,7 +311,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs for (int i = 0; i < enemyCount; i++) NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, spawnType); } - SoundEngine.PlaySound(SoundID.Item8, npc.Center); + SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.TeleportSound, npc.Center); npc.alpha = 255; npc.position = position; for (int n = 0; n < 15; n++) @@ -421,6 +415,10 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs type = ModContent.ProjectileType(); SoundEngine.PlaySound(SoundID.Item30, player.Center); } + else + { + SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.HellfireballSound, player.Center); + } Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; if (Main.netMode != NetmodeID.MultiplayerClient) @@ -441,6 +439,10 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs type = ModContent.ProjectileType(); SoundEngine.PlaySound(SoundID.Item21, player.Center); } + else + { + SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.DartSound, player.Center); + } projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; int numProj = death ? 8 : 4; int spread = death ? 90 : 45; @@ -538,6 +540,10 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs type = ModContent.ProjectileType(); SoundEngine.PlaySound(SoundID.Item26, player.Center); } + else + { + SoundEngine.PlaySound(BrimstoneElemental.BrimstoneElemental.ShellFireSound, player.Center); + } double angleA = radians2 * 0.5; double angleB = MathHelper.ToRadians(90f) - angleA; float velocityX = (float)(projectileSpeed * Math.Sin(angleA) / Math.Sin(angleB)); diff --git a/NPCs/CalamityAIs/CalamityBossAIs/CalamitasCloneAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/CalamitasCloneAI.cs index 2551962926..885505f155 100644 --- a/NPCs/CalamityAIs/CalamityBossAIs/CalamitasCloneAI.cs +++ b/NPCs/CalamityAIs/CalamityBossAIs/CalamitasCloneAI.cs @@ -185,10 +185,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Target variable Player player = Main.player[npc.target]; @@ -556,7 +552,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs if (death) npc.localAI[0] = 1f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -645,7 +640,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs if (death) npc.localAI[0] = 1f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -706,11 +700,11 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs npc.ai[2] = 0f; npc.rotation = rotation; - npc.TargetClosest(); npc.netUpdate = true; if (npc.ai[3] >= 2f) { + npc.TargetClosest(); npc.ai[1] = 0f; npc.ai[3] = 0f; return; @@ -727,8 +721,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs npc.ai[2] += 1f; if (npc.ai[2] >= (phase4 ? 15f : 30f)) { - npc.TargetClosest(); - npc.ai[1] = 2f; npc.ai[2] = 0f; if (death) @@ -768,10 +760,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - Player player = Main.player[npc.target]; float enrageScale = bossRush ? 1f : 0f; @@ -914,7 +902,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs npc.ai[2] += 1f; if (npc.ai[2] >= (240f - (death ? 120f * (1f - lifeRatio) : 0f))) { - npc.TargetClosest(); npc.ai[1] = 1f; npc.ai[2] = 0f; npc.target = 255; @@ -1047,7 +1034,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs npc.ai[2] = 0f; npc.target = 255; npc.rotation = calCloneBroRotation; - npc.TargetClosest(); if (npc.ai[3] >= 3f) { npc.ai[1] = 0f; @@ -1089,10 +1075,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - Player player = Main.player[npc.target]; float enrageScale = bossRush ? 1f : 0f; @@ -1235,7 +1217,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs npc.ai[2] += 1f; if (npc.ai[2] >= (180f - (death ? 90f * (1f - lifeRatio) : 0f))) { - npc.TargetClosest(); npc.ai[1] = 1f; npc.ai[2] = 0f; npc.target = 255; @@ -1366,7 +1347,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.rotation = calCloneBroRotation; if (npc.ai[3] >= 4f) { diff --git a/NPCs/CalamityAIs/CalamityBossAIs/CeaselessVoidAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/CeaselessVoidAI.cs index 6f7fa5b9bd..e33ab45fd9 100644 --- a/NPCs/CalamityAIs/CalamityBossAIs/CeaselessVoidAI.cs +++ b/NPCs/CalamityAIs/CalamityBossAIs/CeaselessVoidAI.cs @@ -448,7 +448,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs void Movement(bool succ) { float velocity = moveVeryFast ? 25f : bossRush ? 15f : ((expertMode ? 7.5f : 6f) + (float)(death ? 2f * (1D - lifeRatio) : 0f)) * tileEnrageMult; - float acceleration = moveVeryFast ? 0.75f : bossRush ? 0.3f : death ? 0.2f : expertMode ? 0.16f : 0.12f; + float acceleration = (moveVeryFast ? 0.75f : bossRush ? 0.3f : death ? 0.2f : expertMode ? 0.16f : 0.12f) + (float)(death ? 0.04f * (1D - lifeRatio) : 0f) * tileEnrageMult; // Increase speed dramatically in succ phase if (succ) @@ -472,7 +472,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs { // Move to a new location every few seconds calamityGlobalNPC.newAI[2] += 1f; - float newPositionGateValue = bossRush ? 180f : death ? 270f : revenge ? 300f : expertMode ? 360f : 480f; + float newPositionGateValue = bossRush ? 120f : death ? 180f : revenge ? 210f : expertMode ? 240f : 300f; if (calamityGlobalNPC.newAI[2] > newPositionGateValue) { calamityGlobalNPC.newAI[2] = 0f; @@ -520,7 +520,18 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs Vector2 distanceFromDestination = destination - npc.Center; // Movement - CalamityUtils.SmoothMovement(npc, 0f, distanceFromDestination, velocity, acceleration, true); + if (npc.Distance(destination) > maxDistance || succ) + { + CalamityUtils.SmoothMovement(npc, 0f, distanceFromDestination, velocity, acceleration, true); + } + else + { + // Slow down + if (npc.velocity.Length() > 0.5f) + npc.velocity *= 0.8f; + else + npc.velocity = Vector2.Zero; + } } // Spawn more Dark Energies as the fight progresses diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 9dc40ae725..1e6ab76f66 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -244,6 +244,7 @@ namespace CalamityMod.NPCs public int pearlAura = 0; public int bBlood = 0; public int brainRot = 0; + public int laceration = 0; public int elementalMix = 0; public int marked = 0; public int absorberAffliction = 0; @@ -463,6 +464,7 @@ namespace CalamityMod.NPCs myClone.pearlAura = pearlAura; myClone.bBlood = bBlood; myClone.brainRot = brainRot; + myClone.laceration = laceration; myClone.elementalMix = elementalMix; myClone.marked = marked; myClone.absorberAffliction = absorberAffliction; @@ -1114,6 +1116,8 @@ namespace CalamityMod.NPCs ApplyDPSDebuff(40, 10, ref npc.lifeRegen, ref damage); if (brainRot > 0) ApplyDPSDebuff(40, 10, ref npc.lifeRegen, ref damage); + if (laceration > 0) + ApplyDPSDebuff(80, 10, ref npc.lifeRegen, ref damage); if (elementalMix > 0) ApplyDPSDebuff(400, 80, ref npc.lifeRegen, ref damage); if (miracleBlight > 0) @@ -1458,9 +1462,9 @@ namespace CalamityMod.NPCs else if (npc.type == NPCID.SkeletronHand) { if (CalamityWorld.death) - npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.65); + npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.5); else - npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.9); + npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.75); } else if (npc.type == NPCID.QueenBee) { @@ -3197,7 +3201,7 @@ namespace CalamityMod.NPCs // Damage reduction on spawn for certain worm bosses. if (CalamityLists.EaterofWorldsIDs.Contains(npc.type)) - modifiers.FinalDamage *= 1f - MathHelper.Lerp(BossRushEvent.BossRushActive ? 0.8f : 0f, 0.99f, MathHelper.Clamp(1f - newAI[1] / EaterOfWorldsAI.DRIncreaseTime, 0f, 1f)); + modifiers.FinalDamage *= 1f - MathHelper.Lerp(BossRushEvent.BossRushActive ? 0.6f : 0f, 0.99f, MathHelper.Clamp(1f - newAI[1] / EaterOfWorldsAI.DRIncreaseTime, 0f, 1f)); if (CalamityLists.DestroyerIDs.Contains(npc.type)) modifiers.FinalDamage *= 1f - MathHelper.Lerp(0f, 0.99f, MathHelper.Clamp(1f - newAI[1] / DestroyerAI.DRIncreaseTime, 0f, 1f)); if (CalamityLists.AstrumDeusIDs.Contains(npc.type)) @@ -3221,14 +3225,6 @@ namespace CalamityMod.NPCs if (effectiveDR <= 0f) effectiveDR = 0f; - // Add Yellow Candle damage if the NPC isn't supposed to be "near invincible" - // Armor penetration has already been applied as bonus damage. - // Yellow Candle provides +5% damage which ignores both DR and defense. - // This means Yellow Candle is buffing armor penetration and technically not ignoring defense, - // but it's small enough to let it slide. - if (npc.HasBuff() && DR < 0.99f && npc.takenDamageMultiplier > 0.05f) - finalMultiplier += 0.05f; - // Calculate extra DR based on kill time, similar to the Hush boss from The Binding of Isaac // Cirrus being active makes the extra DR cease to function bool cirrusBossActive = false; @@ -3307,6 +3303,7 @@ namespace CalamityMod.NPCs // Apply flat reductions first. All vanilla debuffs check their internal booleans. FlatEditDR(ref calcDR, npc.poisoned, BuffID.Poisoned); FlatEditDR(ref calcDR, npc.onFire, BuffID.OnFire); + FlatEditDR(ref calcDR, npc.onFire3, BuffID.OnFire3); FlatEditDR(ref calcDR, npc.venom, BuffID.Venom); FlatEditDR(ref calcDR, npc.onFrostBurn, BuffID.Frostburn); FlatEditDR(ref calcDR, npc.shadowFlame, BuffID.ShadowFlame); @@ -3325,6 +3322,7 @@ namespace CalamityMod.NPCs // Apply multiplicative reductions second. All vanilla debuffs check their internal booleans. MultEditDR(ref calcDR, npc.poisoned, BuffID.Poisoned); MultEditDR(ref calcDR, npc.onFire, BuffID.OnFire); + MultEditDR(ref calcDR, npc.onFire3, BuffID.OnFire3); MultEditDR(ref calcDR, npc.venom, BuffID.Venom); MultEditDR(ref calcDR, npc.onFrostBurn, BuffID.Frostburn); MultEditDR(ref calcDR, npc.shadowFlame, BuffID.ShadowFlame); @@ -3351,7 +3349,9 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.DukeFishron && (CalamityWorld.death || BossRushEvent.BossRushActive)) { - if (npc.life / (float)npc.lifeMax < 0.4f) + float lifeRatio = npc.life / (float)npc.lifeMax; + float mapIconVanishValue = Main.masterMode ? 0.3f : 0.4f; + if (lifeRatio < mapIconVanishValue || (lifeRatio > 0.9f && Main.masterMode)) index = -1; } } @@ -3487,6 +3487,73 @@ namespace CalamityMod.NPCs return DukeFishronAI.BuffedDetonatingBubbleAI(npc, Mod); } + // Expert+ Hive Mind Vile Spits + if (npc.type == NPCID.VileSpitEaterOfWorlds) + { + if (Main.expertMode || BossRushEvent.BossRushActive) + { + if (npc.ai[1] >= 69f) + { + if (npc.target == Main.maxPlayers) + { + npc.TargetClosest(); + + float velocity = Main.getGoodWorld ? 10f : (Main.masterMode || BossRushEvent.BossRushActive) ? 8f : 6f; + if (npc.ai[1] == 70f) + velocity *= 0.6f; + + npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; + } + + if (Main.getGoodWorld && !npc.dontTakeDamage) + { + if ((double)(npc.Center.Y / 16f) < Main.worldSurface) + npc.dontTakeDamage = true; + } + + npc.damage = npc.GetAttackDamage_ScaledByStrength(32f); + + npc.ai[0] += 1f; + if (npc.ai[0] > 3f) + npc.ai[0] = 3f; + + if (npc.ai[0] == 2f) + { + npc.position += npc.velocity; + SoundEngine.PlaySound(SoundID.NPCDeath9, npc.Center); + for (int i = 0; i < 20; i++) + { + int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f) + npc.netOffset, npc.width, npc.height, 18, 0f, 0f, 100, default, 1.8f); + Main.dust[dust].velocity *= 1.3f; + Main.dust[dust].velocity += npc.velocity; + Main.dust[dust].noGravity = true; + } + } + + if (Collision.SolidCollision(npc.position, npc.width, npc.height)) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + npc.StrikeInstantKill(); + } + + npc.EncourageDespawn(100); + + npc.position += npc.netOffset; + for (int i = 0; i < 2; i++) + { + int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 18, npc.velocity.X * 0.1f, npc.velocity.Y * 0.1f, 80, default, 1.3f); + Main.dust[dust].velocity *= 0.3f; + Main.dust[dust].noGravity = true; + } + + npc.rotation += 0.4f * npc.direction; + npc.position -= npc.netOffset; + + return false; + } + } + } + if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { switch (npc.type) @@ -5020,6 +5087,8 @@ namespace CalamityMod.NPCs bBlood--; if (brainRot > 0) brainRot--; + if (laceration > 0) + laceration--; if (elementalMix > 0) elementalMix--; if (vulnerabilityHex > 0) @@ -5251,7 +5320,7 @@ namespace CalamityMod.NPCs return; if (target.Calamity().sulphurSet) - npc.AddBuff(BuffID.Poisoned, 120); + npc.AddBuff(BuffID.Poisoned, 60); if (target.Calamity().snowman) { @@ -5814,24 +5883,37 @@ namespace CalamityMod.NPCs } } + // Plague debuff on kill effect if (pFlames > 0 && npc.life <= 0) { - Rectangle hitbox = npc.Hitbox; - for (int i = 0; i < 20; i++) - { - int idx = Dust.NewDust(hitbox.TopLeft(), npc.width, npc.height, DustID.GemEmerald, 0f, -2.5f); - Dust dust = Main.dust[idx]; - dust.alpha = 200; - dust.velocity *= 1.4f; - dust.scale += Main.rand.NextFloat(); - } - if (Main.netMode != NetmodeID.MultiplayerClient) { - foreach (NPC nPC in Main.ActiveNPCs) + for (int i = 0; i < 10; i++) { - if (!nPC.buffImmune[BuffType()] && npc.Distance(nPC.Center) < 100f && !nPC.dontTakeDamage && nPC.lifeMax > 5 && !nPC.friendly && !nPC.townNPC) - nPC.AddBuff(BuffType(), 300); + int DustID = 220; + Dust dust2 = Dust.NewDustDirect(npc.Center, npc.width, npc.height, DustID); + dust2.scale = Main.rand.NextFloat(0.6f, 0.75f); + dust2.velocity = new Vector2(12, 12).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 0.8f); + dust2.noGravity = true; + } + + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC target = Main.npc[i]; + + if (target != null && target.IsAnEnemy(true, true) && !target.buffImmune[BuffType()] && Vector2.Distance(target.Center, npc.Center) < 400) + { + if (target.HasBuff() || target.life <= 0) + { + target.AddBuff(BuffType(), 300); + } + else + { + target.AddBuff(BuffType(), 300); + DirectionalPulseRing pulse = new DirectionalPulseRing(target.Center, Vector2.Zero, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Green, new Vector2(1, 1), 0, Main.rand.NextFloat(0.07f, 0.18f) * 3, 0f, 15); + GeneralParticleHandler.SpawnParticle(pulse); + } + } } } } @@ -6311,6 +6393,9 @@ namespace CalamityMod.NPCs if (hFlames > 0 || banishingFire > 0) HolyFlames.DrawEffects(npc, ref drawColor); + if (laceration > 0) + Laceration.DrawEffects(npc, ref drawColor); + // These draw effects do not include Miracle Blight's shader if (miracleBlight > 0) MiracleBlight.DrawEffects(npc, ref drawColor); @@ -6442,7 +6527,10 @@ namespace CalamityMod.NPCs drawColor = Color.Cyan; else if (electrified > 0) - drawColor = Main.rand.NextBool(5) ? Color.White : Color.SlateGray; + { + int scaleFactor = (int)(Utils.Remap(npc.width, 30, 400, 5, 15, true)); + drawColor = Main.rand.NextBool(scaleFactor) ? Color.Lerp(Color.SlateGray, Color.White, Utils.Remap(npc.width, 30, 400, 0, 0.7f, true)) : Color.White; + } else if (absorberAffliction > 0) drawColor = Color.DarkSeaGreen; @@ -6467,7 +6555,7 @@ namespace CalamityMod.NPCs return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Main.DiscoR); if (npc.type == NPCID.KingSlime && Main.masterMode && CalamityWorld.revenge) - return NPC.AnyNPCs(ModContent.NPCType()) ? Color.Lerp(new Color(0, 0, 150, npc.alpha), new Color(125, 125, 255, npc.alpha), (float)Math.Sin(Main.GlobalTimeWrappedHourly) / 2f + 0.5f) : null; + return NPC.AnyNPCs(ModContent.NPCType()) ? Color.Lerp(new Color(0, 0, 150, npc.alpha), new Color(125, 125, 255, npc.alpha), (float)Math.Sin(Main.GlobalTimeWrappedHourly) / 2f + 0.5f) : null; if (npc.type == NPCID.QueenBee && Main.zenithWorld) { @@ -6505,6 +6593,7 @@ namespace CalamityMod.NPCs ("CalamityMod/Buffs/DamageOverTime/ElementalMix", NPC => NPC.Calamity().elementalMix > 0), ("CalamityMod/Buffs/DamageOverTime/GodSlayerInferno", NPC => NPC.Calamity().gsInferno > 0), ("CalamityMod/Buffs/DamageOverTime/HolyFlames", NPC => NPC.Calamity().hFlames > 0), + ("CalamityMod/Buffs/DamageOverTime/Laceration", NPC => NPC.Calamity().laceration > 0), ("CalamityMod/Buffs/DamageOverTime/MiracleBlight", NPC => NPC.Calamity().miracleBlight > 0), ("CalamityMod/Buffs/DamageOverTime/Nightwither", NPC => NPC.Calamity().nightwither > 0), ("CalamityMod/Buffs/DamageOverTime/Plague", NPC => NPC.Calamity().pFlames > 0), @@ -6950,14 +7039,6 @@ namespace CalamityMod.NPCs if (npc.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - if (npc.type == NPCID.TheDestroyerBody) - { - if (npc.ai[2] == 0f) - npc.frame.Y = 0; - else - npc.frame.Y = frameHeight; - } - Color segmentDrawColor = npc.GetAlpha(drawColor); // Check if Destroyer is behind tiles and, if so, how much of the segment is behind tiles and adjust color accordingly diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index ae24263c1f..abf91440b3 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -94,6 +94,7 @@ namespace CalamityMod.NPCs { "Tavish DeGroot", // <@!442447226992721930> (magicoal) "Fimmy", // <@!407348617079160832> (darkmega5) + "Dorira", // <@!215269032360804352> (crimsoncb) }; private static readonly string[] DryadNames = { diff --git a/NPCs/CeaselessVoid/CeaselessVoid.cs b/NPCs/CeaselessVoid/CeaselessVoid.cs index 8a3a648268..b7e2cb704c 100644 --- a/NPCs/CeaselessVoid/CeaselessVoid.cs +++ b/NPCs/CeaselessVoid/CeaselessVoid.cs @@ -146,6 +146,12 @@ namespace CalamityMod.NPCs.CeaselessVoid return minDist <= 50f; } + public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) + { + if (hurtInfo.Damage > 0) + target.AddBuff(BuffID.VortexDebuff, 60, true); + } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { SpriteEffects spriteEffects = SpriteEffects.None; diff --git a/NPCs/CeaselessVoid/DarkEnergy.cs b/NPCs/CeaselessVoid/DarkEnergy.cs index 202e8d1e86..c5fee54bad 100644 --- a/NPCs/CeaselessVoid/DarkEnergy.cs +++ b/NPCs/CeaselessVoid/DarkEnergy.cs @@ -282,10 +282,11 @@ namespace CalamityMod.NPCs.CeaselessVoid public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) { - int debufftype = Main.zenithWorld ? BuffID.Obstructed : BuffID.VortexDebuff; - int duration = Main.zenithWorld ? 30 : 60; - if (hurtInfo.Damage > 0) - target.AddBuff(debufftype, duration, true); + if (Main.zenithWorld) + { + if (hurtInfo.Damage > 0) + target.AddBuff(BuffID.Obstructed, 30, true); + } } public override bool CanHitPlayer(Player target, ref int cooldownSlot) diff --git a/NPCs/Crabulon/CrabShroom.cs b/NPCs/Crabulon/CrabShroom.cs index c3dda3d521..af96c9a5b1 100644 --- a/NPCs/Crabulon/CrabShroom.cs +++ b/NPCs/Crabulon/CrabShroom.cs @@ -76,7 +76,10 @@ namespace CalamityMod.NPCs.Crabulon float xVelocityLimit = BossRushEvent.BossRushActive ? 12f : death ? 8f : revenge ? 6f : 5f; float yVelocityLimit = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.25f : death ? 0.75f : revenge ? 0.9f : 1f; - NPC.TargetClosest(); + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.TargetClosest(); + Player player = Main.player[NPC.target]; NPC.velocity.Y += 0.02f; diff --git a/NPCs/Crabulon/Crabulon.cs b/NPCs/Crabulon/Crabulon.cs index c22d47736d..31653519f3 100644 --- a/NPCs/Crabulon/Crabulon.cs +++ b/NPCs/Crabulon/Crabulon.cs @@ -127,6 +127,7 @@ namespace CalamityMod.NPCs.Crabulon bool death = CalamityWorld.death || bossRush; bool revenge = CalamityWorld.revenge || bossRush; bool expertMode = Main.expertMode || bossRush; + bool masterMode = Main.masterMode || bossRush; NPC.spriteDirection = NPC.direction; @@ -141,10 +142,6 @@ namespace CalamityMod.NPCs.Crabulon if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - NPC.TargetClosest(); - Player player = Main.player[NPC.target]; if (!player.active || player.dead) { @@ -258,6 +255,10 @@ namespace CalamityMod.NPCs.Crabulon NPC.ai[1] += 1f; if (phase3) NPC.ai[1] += 2f; + if (NPC.justHit) + NPC.ai[1] += masterMode ? 7f : expertMode ? 5f : 3f; + if (NPC.Distance(player.Center) < 160f) + NPC.ai[1] += masterMode ? 4f : expertMode ? 2f : 1f; float idleTime = death ? 30f : expertMode ? 60f : 120f; if (NPC.ai[1] >= idleTime) @@ -351,10 +352,12 @@ namespace CalamityMod.NPCs.Crabulon } NPC.ai[1] += 1f; + if (NPC.Distance(player.Center) < 160f) + NPC.ai[1] += masterMode ? 4f : expertMode ? 2f : 1f; + float stompPhaseGateValue = (revenge ? 150f : expertMode ? 240f : 360f) - (death ? 120f * (1f - lifeRatio) : 0f); if (NPC.ai[1] >= stompPhaseGateValue) { - NPC.TargetClosest(); NPC.noGravity = false; NPC.noTileCollide = false; NPC.ai[0] = 2f; @@ -505,8 +508,6 @@ namespace CalamityMod.NPCs.Crabulon } } - NPC.TargetClosest(); - NPC.ai[2] += 1f; if (NPC.ai[2] >= (phase2 ? 4f : 3f)) { diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index a5cb29f29e..36f0b6388c 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -180,10 +180,6 @@ namespace CalamityMod.NPCs.Cryogen if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - NPC.TargetClosest(); - Player player = Main.player[NPC.target]; bool bossRush = BossRushEvent.BossRushActive; @@ -381,7 +377,6 @@ namespace CalamityMod.NPCs.Cryogen if (NPC.localAI[0] >= 120f) { NPC.localAI[0] = 0f; - NPC.TargetClosest(); if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); @@ -449,7 +444,6 @@ namespace CalamityMod.NPCs.Cryogen if (NPC.localAI[0] >= 120f) { NPC.localAI[0] = 0f; - NPC.TargetClosest(); if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); @@ -639,7 +633,6 @@ namespace CalamityMod.NPCs.Cryogen if (NPC.localAI[0] >= 120f) { NPC.localAI[0] = 0f; - NPC.TargetClosest(); if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { SoundEngine.PlaySound(Main.zenithWorld ? SoundID.NPCHit41 : HitSound, NPC.Center); @@ -759,11 +752,10 @@ namespace CalamityMod.NPCs.Cryogen NPC.ai[1] -= 1f; if (NPC.ai[1] == chargeGateValue) { - NPC.TargetClosest(); - calamityGlobalNPC.newAI[1] += 1f; if (calamityGlobalNPC.newAI[1] > 1f) { + NPC.TargetClosest(); NPC.ai[1] = 0f; NPC.localAI[0] = 0f; calamityGlobalNPC.newAI[1] = 0f; @@ -855,16 +847,13 @@ namespace CalamityMod.NPCs.Cryogen NPC.localAI[2] += 1f; if (NPC.localAI[2] >= 180f) { - NPC.TargetClosest(); NPC.localAI[2] = 0f; int attackTimer = 0; - int playerTileX; - int playerTileY; - while (true) + int playerTileX = (int)player.Center.X / 16; + int playerTileY = (int)player.Center.Y / 16; + while (attackTimer <= 100) { attackTimer++; - playerTileX = (int)player.Center.X / 16; - playerTileY = (int)player.Center.Y / 16; int min = 16; int max = 20; @@ -882,15 +871,13 @@ namespace CalamityMod.NPCs.Cryogen if (!WorldGen.SolidTile(playerTileX, playerTileY) && Collision.CanHit(new Vector2(playerTileX * 16, playerTileY * 16), 1, 1, player.position, player.width, player.height)) break; - if (attackTimer > 100) - goto Block; + playerTileX = (int)player.Center.X / 16; + playerTileY = (int)player.Center.Y / 16; } NPC.ai[1] = 1f; teleportLocationX = playerTileX; calamityGlobalNPC.newAI[2] = playerTileY; NPC.netUpdate = true; -Block: - ; } } } @@ -951,6 +938,7 @@ Block: } } + NPC.TargetClosest(); NPC.ai[1] = 2f; NPC.netUpdate = true; } @@ -1046,7 +1034,6 @@ Block: if (NPC.ai[1] <= 0f) // Set the next charge, or switch back to floating above the player { NPC.ai[3] += 1f; - NPC.TargetClosest(); if (NPC.ai[3] > 2f) { NPC.ai[0] = 5f; diff --git a/NPCs/DesertScourge/DesertNuisanceBody.cs b/NPCs/DesertScourge/DesertNuisanceBody.cs index d61794d229..3498f8fe14 100644 --- a/NPCs/DesertScourge/DesertNuisanceBody.cs +++ b/NPCs/DesertScourge/DesertNuisanceBody.cs @@ -33,6 +33,7 @@ namespace CalamityMod.NPCs.DesertScourge BodyTexture3 = ModContent.Request(Texture + "3", AssetRequestMode.AsyncLoad); BodyTexture4 = ModContent.Request(Texture + "4", AssetRequestMode.AsyncLoad); } + NPCID.Sets.CantTakeLunchMoney[Type] = true; } public override void SetDefaults() diff --git a/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs b/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs index c1086817cc..5e9f85ba16 100644 --- a/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs @@ -33,6 +33,7 @@ namespace CalamityMod.NPCs.DesertScourge BodyTexture3 = ModContent.Request(Texture + "3", AssetRequestMode.AsyncLoad); BodyTexture4 = ModContent.Request(Texture + "4", AssetRequestMode.AsyncLoad); } + NPCID.Sets.CantTakeLunchMoney[Type] = true; } public override void SetDefaults() diff --git a/NPCs/DesertScourge/DesertNuisanceHead.cs b/NPCs/DesertScourge/DesertNuisanceHead.cs index 564cf646cc..71e547d8f9 100644 --- a/NPCs/DesertScourge/DesertNuisanceHead.cs +++ b/NPCs/DesertScourge/DesertNuisanceHead.cs @@ -45,6 +45,7 @@ namespace CalamityMod.NPCs.DesertScourge value.Position.Y += 30; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; NPCID.Sets.MPAllowedEnemies[Type] = true; + NPCID.Sets.CantTakeLunchMoney[Type] = true; } public override void SetDefaults() @@ -138,12 +139,12 @@ namespace CalamityMod.NPCs.DesertScourge // Percent life remaining. float lifeRatio = NPC.life / (float)NPC.lifeMax; - float speed = death ? 0.2f : 0.17f; - float turnSpeed = death ? 0.3f : 0.25f; + float speed = death ? 0.18f : 0.16f; + float turnSpeed = death ? 0.26f : 0.22f; speed += speed * 0.4f * (1f - lifeRatio); turnSpeed += turnSpeed * 0.4f * (1f - lifeRatio); - speed += 0.17f * enrageScale; - turnSpeed += 0.25f * enrageScale; + speed += 0.16f * enrageScale; + turnSpeed += 0.22f * enrageScale; if (Main.getGoodWorld) { @@ -317,8 +318,10 @@ namespace CalamityMod.NPCs.DesertScourge if (!shouldFly) { - NPC.TargetClosest(); NPC.velocity.Y += 0.15f; + if (NPC.velocity.Y > 0f && Math.Abs(NPC.Center.Y - Main.player[NPC.target].Center.Y) > 180f) + NPC.velocity.Y += 0.05f; + if (NPC.velocity.Y > maxChaseSpeed) NPC.velocity.Y = maxChaseSpeed; diff --git a/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs b/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs index 9a3e19a915..e984be408c 100644 --- a/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs @@ -37,6 +37,7 @@ namespace CalamityMod.NPCs.DesertScourge Main.npcFrameCount[NPC.type] = 7; this.HideFromBestiary(); NPCID.Sets.MPAllowedEnemies[Type] = true; + NPCID.Sets.CantTakeLunchMoney[Type] = true; } public override void SetDefaults() @@ -134,12 +135,12 @@ namespace CalamityMod.NPCs.DesertScourge // Percent life remaining. float lifeRatio = NPC.life / (float)NPC.lifeMax; - float speed = death ? 0.22f : 0.19f; - float turnSpeed = death ? 0.32f : 0.27f; + float speed = death ? 0.16f : 0.14f; + float turnSpeed = death ? 0.24f : 0.2f; speed += speed * 0.4f * (1f - lifeRatio); turnSpeed += turnSpeed * 0.4f * (1f - lifeRatio); - speed += 0.19f * enrageScale; - turnSpeed += 0.27f * enrageScale; + speed += 0.14f * enrageScale; + turnSpeed += 0.2f * enrageScale; if (Main.getGoodWorld) { @@ -361,7 +362,6 @@ namespace CalamityMod.NPCs.DesertScourge if (!shouldFly) { - NPC.TargetClosest(); NPC.velocity.Y += 0.15f; if (NPC.velocity.Y > maxChaseSpeed) NPC.velocity.Y = maxChaseSpeed; diff --git a/NPCs/DesertScourge/DesertNuisanceTail.cs b/NPCs/DesertScourge/DesertNuisanceTail.cs index 860e56f7b0..709710af2f 100644 --- a/NPCs/DesertScourge/DesertNuisanceTail.cs +++ b/NPCs/DesertScourge/DesertNuisanceTail.cs @@ -15,6 +15,7 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetStaticDefaults() { this.HideFromBestiary(); + NPCID.Sets.CantTakeLunchMoney[Type] = true; } public override void SetDefaults() diff --git a/NPCs/DesertScourge/DesertNuisanceTailYoung.cs b/NPCs/DesertScourge/DesertNuisanceTailYoung.cs index df82733592..c2b49d23c3 100644 --- a/NPCs/DesertScourge/DesertNuisanceTailYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceTailYoung.cs @@ -15,6 +15,7 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetStaticDefaults() { this.HideFromBestiary(); + NPCID.Sets.CantTakeLunchMoney[Type] = true; } public override void SetDefaults() diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index 803655aa4d..4cd787ab44 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -183,10 +183,6 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - NPC.TargetClosest(); - Player player = Main.player[NPC.target]; // Enrage @@ -238,8 +234,8 @@ namespace CalamityMod.NPCs.DesertScourge float burrowDistance = hide ? BurrowDistance_Hide : bossRush ? BurrowDistance_BossRush : BurrowDistance; - float speed = death ? 0.18f : 0.15f; - float turnSpeed = death ? 0.36f : 0.3f; + float speed = death ? 0.15f : 0.12f; + float turnSpeed = death ? 0.3f : 0.24f; if (expertMode) { @@ -249,12 +245,12 @@ namespace CalamityMod.NPCs.DesertScourge if (revenge) { - speed += (death ? 0.06f : 0.05f) * (1f - lifeRatio); - turnSpeed += (death ? 0.12f : 0.1f) * (1f - lifeRatio); + speed += (death ? 0.05f : 0.04f) * (1f - lifeRatio); + turnSpeed += (death ? 0.1f : 0.08f) * (1f - lifeRatio); } - speed += 0.15f * enrageScale; - turnSpeed += 0.3f * enrageScale; + speed += 0.12f * enrageScale; + turnSpeed += 0.24f * enrageScale; if (Main.getGoodWorld) { @@ -262,47 +258,6 @@ namespace CalamityMod.NPCs.DesertScourge turnSpeed *= 1.2f; } - // Projectile spit (unused, for now) - /*if ((phase2 || death) && revenge && NPC.Distance(Main.player[NPC.target].Center) > 400f && (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) - { - if (NPC.Calamity().newAI[0] % (death ? SpitGateValue_Death : SpitGateValue) == 0f) - { - SoundEngine.PlaySound(SoundID.NPCDeath11, NPC.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * (masterMode ? 10f : 8f); - int numProj = death ? 9 : 6; - int spread = masterMode ? 49 : 35; - if (masterMode) - { - numProj += 3; - spread += 14; - } - - float rotation = MathHelper.ToRadians(spread); - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - - for (int k = 0; k < 10; k++) - { - int dust = Dust.NewDust(NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, 10, 10, (int)CalamityDusts.SulphurousSeaAcid); - Main.dust[dust].velocity = perturbedSpeed; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].aiStyle = -1; - Main.projectile[proj].netUpdate = true; - } - } - } - } - }*/ - // Sand splash if (!quickFall) { @@ -595,7 +550,7 @@ namespace CalamityMod.NPCs.DesertScourge float targetDistance = (float)Math.Sqrt((double)(playerX * playerX + targettingPosition * targettingPosition)); // Lunge up towards target - if (burrow && NPC.Center.Y >= burrowTarget - 16f) + if (burrow && NPC.Center.Y >= burrowTarget - 16f && !lungeUpward && !quickFall) { NPC.Calamity().newAI[1] = 1f; NPC.localAI[3] = 0f; @@ -607,7 +562,7 @@ namespace CalamityMod.NPCs.DesertScourge } // Quickly fall back down once above target - if (lungeUpward && NPC.Center.Y <= NPC.Calamity().newAI[3] + LungeUpwardDistanceOffset - LungeUpwardCutoffDistance && Math.Abs(NPC.Center.X - player.Center.X) < 480f) + if (lungeUpward && NPC.Center.Y <= NPC.Calamity().newAI[3] + LungeUpwardDistanceOffset - LungeUpwardCutoffDistance && Math.Abs(NPC.Center.X - player.Center.X) < 480f && !quickFall) { // Spit a huge spread of sand upwards that falls down SoundEngine.PlaySound(SoundID.NPCDeath13, NPC.Center); @@ -660,7 +615,9 @@ namespace CalamityMod.NPCs.DesertScourge { NPC.Calamity().newAI[0] = 0f; NPC.Calamity().newAI[1] = 0f; + NPC.Calamity().newAI[3] = 0f; NPC.localAI[3] = 0f; + playRoarSound = false; } if (hide && !player.dead) @@ -669,8 +626,14 @@ namespace CalamityMod.NPCs.DesertScourge } else if (!shouldFly) { - NPC.TargetClosest(); NPC.velocity.Y += 0.15f; + if (NPC.Center.Y - player.Center.Y < -180f) + { + NPC.velocity.Y += 0.05f; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y += 0.05f; + } + if (NPC.velocity.Y > maxChaseSpeed) NPC.velocity.Y = maxChaseSpeed; diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index 705f248c4c..9d5119195f 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -355,12 +355,10 @@ namespace CalamityMod.NPCs.DevourerofGods if (CalamityConfig.Instance.BossesStopWeather) CalamityMod.StopRain(); - // Get a target + // Get a target (time is checked in the second check to ensure a new target isn't being set constantly) if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + else if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles && Main.time % 60D == 0D) NPC.TargetClosest(); Player player = Main.player[NPC.target]; @@ -2354,6 +2352,10 @@ namespace CalamityMod.NPCs.DevourerofGods } } + // There is no escape... + if (NPC.Distance(player.Center) > 2400f) + NPC.velocity += (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; + // Calculate contact damage based on velocity float minimalContactDamageVelocity = segmentVelocity * 0.25f; float minimalDamageVelocity = segmentVelocity * 0.5f; diff --git a/NPCs/HiveMind/DankCreeper.cs b/NPCs/HiveMind/DankCreeper.cs index a9328ad75e..a6e676023c 100644 --- a/NPCs/HiveMind/DankCreeper.cs +++ b/NPCs/HiveMind/DankCreeper.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; using CalamityMod.Projectiles.Boss; using CalamityMod.World; @@ -25,7 +26,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.height = 70; NPC.defense = 6; - NPC.lifeMax = 90; + NPC.lifeMax = 120; if (BossRushEvent.BossRushActive) NPC.lifeMax = 2000; if (Main.getGoodWorld) @@ -58,10 +59,13 @@ namespace CalamityMod.NPCs.HiveMind // Avoid cheap bullshit NPC.damage = 0; - NPC.TargetClosest(); + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.TargetClosest(); + bool masterMode = Main.masterMode; bool revenge = CalamityWorld.revenge; - float speed = revenge ? 12f : 11f; + float speed = masterMode ? 15f : revenge ? 13f : 11f; if (BossRushEvent.BossRushActive) speed = 18f; @@ -73,56 +77,66 @@ namespace CalamityMod.NPCs.HiveMind NPC.rotation = NPC.velocity.X * 0.05f; Vector2 targetDirection = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); - float playerXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - targetDirection.X; - float playerYDist = Main.player[NPC.target].Center.Y - targetDirection.Y; - float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); - float timeToReachTarget = speed / playerDistance; - playerXDist *= timeToReachTarget; - playerYDist *= timeToReachTarget; + Vector2 targetLocation = Main.player[NPC.target].Center; - NPC.ai[0] -= 1f; - if (playerDistance < 200f || NPC.ai[0] > 0f) + // Fly above if below 25% HP and burst to spawn a Rain Cloud when high enough + bool killYourself = NPC.life / (float)NPC.lifeMax < 0.25f; + if (killYourself && (Main.expertMode || BossRushEvent.BossRushActive)) { - // Set damage - NPC.damage = NPC.defDamage; + targetLocation -= Vector2.UnitY * 400f; + if (NPC.Distance(targetLocation) < 80f) + { + NPC.life = 0; + NPC.HitEffect(); + NPC.checkDead(); + return; + } + } - if (playerDistance < 200f) - NPC.ai[0] = 20f; + if (!killYourself) + { + NPC.ai[0] -= 1f; + bool dash = NPC.Distance(targetLocation) < 200f; + if (dash || NPC.ai[0] > 0f) + { + // Set damage + NPC.damage = NPC.defDamage; - if (NPC.velocity.X < 0f) - NPC.direction = -1; - else - NPC.direction = 1; + if (dash) + NPC.ai[0] = 20f; + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else + NPC.direction = 1; + + return; + } + } + + float inertia = (NPC.Distance(targetLocation) < 300f || killYourself) ? 8f : NPC.Distance(targetLocation) < 400f ? 20f : 50f; + Vector2 idealVelocity = (targetLocation - targetDirection).SafeNormalize(Vector2.UnitX * NPC.direction) * speed; + NPC.velocity = (NPC.velocity * inertia + idealVelocity) / (inertia + 1f); + } + + public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) + { + if (hurtInfo.Damage < 0) return; - } - NPC.velocity.X = (NPC.velocity.X * 50f + playerXDist) / 51f; - NPC.velocity.Y = (NPC.velocity.Y * 50f + playerYDist) / 51f; - if (playerDistance < 350f) - { - NPC.velocity.X = (NPC.velocity.X * 10f + playerXDist) / 11f; - NPC.velocity.Y = (NPC.velocity.Y * 10f + playerYDist) / 11f; - } - if (playerDistance < 300f) - { - NPC.velocity.X = (NPC.velocity.X * 7f + playerXDist) / 8f; - NPC.velocity.Y = (NPC.velocity.Y * 7f + playerYDist) / 8f; - } + target.AddBuff(ModContent.BuffType(), 180); } public override void HitEffect(NPC.HitInfo hit) { for (int k = 0; k < 5; k++) - { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Glass, hit.HitDirection, -1f, 0, default, 1f); - } + if (NPC.life <= 0) { for (int k = 0; k < 20; k++) - { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Glass, hit.HitDirection, -1f, 0, default, 1f); - } + if (Main.netMode != NetmodeID.Server) { Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("DankCreeperGore").Type, 1f); diff --git a/NPCs/HiveMind/DarkHeart.cs b/NPCs/HiveMind/DarkHeart.cs index 0449ae3853..3432898fdc 100644 --- a/NPCs/HiveMind/DarkHeart.cs +++ b/NPCs/HiveMind/DarkHeart.cs @@ -60,67 +60,86 @@ namespace CalamityMod.NPCs.HiveMind // Setting this in SetDefaults will disable expert mode scaling, so put it here instead NPC.damage = 0; + bool masterMode = Main.masterMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - NPC.TargetClosest(); - float npcSpeed = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 8f : revenge ? 4.5f : 4f; - float velocityMult = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 1f : revenge ? 0.8f : 0.75f; + bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + + // Float around the player + NPC.rotation = NPC.velocity.X / 20f; + + // Get a target + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) + NPC.TargetClosest(); + + float velocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 10f : death ? 7f : revenge ? 6f : 4f; + float acceleration = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.5f : death ? 0.35f : revenge ? 0.3f : 0.2f; + float deceleration = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.9f : death ? 0.95f : revenge ? 0.96f : 0.98f; + if (masterMode) + { + velocity += 2f; + acceleration += 0.2f; + deceleration -= 0.05f; + } if (BossRushEvent.BossRushActive) { - npcSpeed *= 2f; - velocityMult *= 2f; + velocity *= 2f; + acceleration *= 2f; } - Vector2 npcCenter = new Vector2(NPC.Center.X, NPC.Center.Y); - float playerXDist = Main.player[NPC.target].Center.X - npcCenter.X; - float playerYDist = Main.player[NPC.target].Center.Y - npcCenter.Y - ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 500f : 400f); - float playerDistance = (float)Math.Sqrt(playerXDist * playerXDist + playerYDist * playerYDist); - if (playerDistance < ((CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 10f : 20f)) + if (NPC.position.Y > Main.player[NPC.target].position.Y - 350f) { - playerXDist = NPC.velocity.X; - playerYDist = NPC.velocity.Y; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= deceleration; + + NPC.velocity.Y -= acceleration; + + if (NPC.velocity.Y > velocity) + NPC.velocity.Y = velocity; } - else + else if (NPC.position.Y < Main.player[NPC.target].position.Y - 450f) { - playerDistance = npcSpeed / playerDistance; - playerXDist *= playerDistance; - playerYDist *= playerDistance; + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= deceleration; + + NPC.velocity.Y += acceleration; + + if (NPC.velocity.Y < -velocity) + NPC.velocity.Y = -velocity; } - if (NPC.velocity.X < playerXDist) + + bool dropRain = NPC.Bottom.Y < Main.player[NPC.target].position.Y - 300f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height); + float distanceX = masterMode ? 200f : 400f; + float velocityX = velocity * 1.5f; + if (NPC.Center.X > Main.player[NPC.target].Center.X + distanceX) { - NPC.velocity.X = NPC.velocity.X + velocityMult; - if (NPC.velocity.X < 0f && playerXDist > 0f) - { - NPC.velocity.X = NPC.velocity.X + velocityMult * 2f; - } + dropRain = false; + + if (NPC.velocity.X > 0f) + NPC.velocity.X *= deceleration; + + NPC.velocity.X -= acceleration; + + if (NPC.velocity.X > velocityX) + NPC.velocity.X = velocityX; } - else if (NPC.velocity.X > playerXDist) + if (NPC.Center.X < Main.player[NPC.target].Center.X - distanceX) { - NPC.velocity.X = NPC.velocity.X - velocityMult; - if (NPC.velocity.X > 0f && playerXDist < 0f) - { - NPC.velocity.X = NPC.velocity.X - velocityMult * 2f; - } + dropRain = false; + + if (NPC.velocity.X < 0f) + NPC.velocity.X *= deceleration; + + NPC.velocity.X += acceleration; + + if (NPC.velocity.X < -velocityX) + NPC.velocity.X = -velocityX; } - if (NPC.velocity.Y < playerYDist) - { - NPC.velocity.Y = NPC.velocity.Y + velocityMult; - if (NPC.velocity.Y < 0f && playerYDist > 0f) - { - NPC.velocity.Y = NPC.velocity.Y + velocityMult * 2f; - } - } - else if (NPC.velocity.Y > playerYDist) - { - NPC.velocity.Y = NPC.velocity.Y - velocityMult; - if (NPC.velocity.Y > 0f && playerYDist < 0f) - { - NPC.velocity.Y = NPC.velocity.Y - velocityMult * 2f; - } - } - if (NPC.position.X + NPC.width > Main.player[NPC.target].position.X && NPC.position.X < Main.player[NPC.target].position.X + Main.player[NPC.target].width && NPC.position.Y + NPC.height < Main.player[NPC.target].position.Y && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && Main.netMode != NetmodeID.MultiplayerClient) + + if (dropRain && Main.netMode != NetmodeID.MultiplayerClient) { NPC.ai[0] += 1f; - if (NPC.ai[0] >= (Main.getGoodWorld ? 12f : 24f)) + float rainDropRate = Main.getGoodWorld ? 8f : death ? 16f : revenge ? 20f : 24f; + if (NPC.ai[0] >= rainDropRate) { NPC.ai[0] = 0f; int shaderainXPos = (int)(NPC.position.X + 10f + Main.rand.Next(NPC.width - 20)); @@ -128,7 +147,8 @@ namespace CalamityMod.NPCs.HiveMind int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); float randomXVelocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.rand.NextFloat() * 5f : 0f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), shaderainXPos, shaderainYos, randomXVelocity, 4f, type, damage, 0f, Main.myPlayer); + float velocityY = 8f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), shaderainXPos, shaderainYos, randomXVelocity, velocityY, type, damage, 0f, Main.myPlayer); } } } @@ -143,15 +163,12 @@ namespace CalamityMod.NPCs.HiveMind public override void HitEffect(NPC.HitInfo hit) { for (int k = 0; k < 3; k++) - { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, hit.HitDirection, -1f, 0, default, 1f); - } + if (NPC.life <= 0) { for (int k = 0; k < 20; k++) - { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, hit.HitDirection, -1f, 0, default, 1f); - } } } } diff --git a/NPCs/HiveMind/HiveBlob.cs b/NPCs/HiveMind/HiveBlob.cs index cd07a4b5fe..6e7c638703 100644 --- a/NPCs/HiveMind/HiveBlob.cs +++ b/NPCs/HiveMind/HiveBlob.cs @@ -14,6 +14,10 @@ namespace CalamityMod.NPCs.HiveMind { public class HiveBlob : ModNPC { + private const float ShootGateValue = 240f; + private const float TelegraphDuration = 120f; + private const float ShowTelegraphValue = ShootGateValue - TelegraphDuration; + public override void SetStaticDefaults() { this.HideFromBestiary(); @@ -54,6 +58,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.damage = 0; bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool masterMode = Main.masterMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; @@ -69,6 +74,20 @@ namespace CalamityMod.NPCs.HiveMind return; } + // When Hive Mind starts flying around + bool phase2 = Main.npc[hiveMind].life / (float)Main.npc[hiveMind].lifeMax < 0.8f; + + if (phase2) + { + NPC.life = 0; + NPC.HitEffect(); + NPC.active = false; + NPC.netUpdate = true; + return; + } + + NPC.alpha = Main.npc[hiveMind].alpha; + if (NPC.ai[3] > 0f) hiveMind = (int)NPC.ai[3] - 1; @@ -85,50 +104,49 @@ namespace CalamityMod.NPCs.HiveMind } } - NPC.TargetClosest(true); - + float hiveMindVelocity = Main.npc[hiveMind].velocity.Length(); float relocateSpeed = getFuckedAI ? 1.2f : death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f; - Vector2 randomLocationVector = new Vector2(NPC.ai[0] * 16f + 8f, NPC.ai[1] * 16f + 8f); - float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2) - (NPC.width / 2) - randomLocationVector.X; - float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2) - (NPC.height / 2) - randomLocationVector.Y; - float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); - float hiveMindX = Main.npc[hiveMind].position.X + (Main.npc[hiveMind].width / 2); - float hiveMindY = Main.npc[hiveMind].position.Y + (Main.npc[hiveMind].height / 2); + float acceleration = 0.8f; + float distanceFromMind = Main.getGoodWorld ? 256f : 128f; + + float hiveMindX = Main.npc[hiveMind].Center.X; + float hiveMindY = Main.npc[hiveMind].Center.Y; Vector2 hiveMindPos = new Vector2(hiveMindX, hiveMindY); float randomPosX = hiveMindX + NPC.ai[0]; float randomPosY = hiveMindY + NPC.ai[1]; float finalRandPosX = randomPosX - hiveMindPos.X; float finalRandPosY = randomPosY - hiveMindPos.Y; float finalRandDistance = (float)Math.Sqrt(finalRandPosX * finalRandPosX + finalRandPosY * finalRandPosY); - finalRandDistance = (Main.getGoodWorld ? 256f : 128f) / finalRandDistance; + finalRandDistance = distanceFromMind / finalRandDistance; finalRandPosX *= finalRandDistance; finalRandPosY *= finalRandDistance; + if (NPC.position.X < hiveMindX + finalRandPosX) { - NPC.velocity.X = NPC.velocity.X + relocateSpeed; + NPC.velocity.X += relocateSpeed; if (NPC.velocity.X < 0f && finalRandPosX > 0f) - NPC.velocity.X = NPC.velocity.X * 0.8f; + NPC.velocity.X *= acceleration; } else if (NPC.position.X > hiveMindX + finalRandPosX) { - NPC.velocity.X = NPC.velocity.X - relocateSpeed; + NPC.velocity.X -= relocateSpeed; if (NPC.velocity.X > 0f && finalRandPosX < 0f) - NPC.velocity.X = NPC.velocity.X * 0.8f; + NPC.velocity.X *= acceleration; } if (NPC.position.Y < hiveMindY + finalRandPosY) { - NPC.velocity.Y = NPC.velocity.Y + relocateSpeed; + NPC.velocity.Y += relocateSpeed; if (NPC.velocity.Y < 0f && finalRandPosY > 0f) - NPC.velocity.Y = NPC.velocity.Y * 0.8f; + NPC.velocity.Y *= acceleration; } else if (NPC.position.Y > hiveMindY + finalRandPosY) { - NPC.velocity.Y = NPC.velocity.Y - relocateSpeed; + NPC.velocity.Y -= relocateSpeed; if (NPC.velocity.Y > 0f && finalRandPosY < 0f) - NPC.velocity.Y = NPC.velocity.Y * 0.8f; + NPC.velocity.Y *= acceleration; } - float velocityLimit = getFuckedAI ? 32f : 8f; + float velocityLimit = relocateSpeed * 16f; if (NPC.velocity.X > velocityLimit) NPC.velocity.X = velocityLimit; if (NPC.velocity.X < -velocityLimit) @@ -140,23 +158,36 @@ namespace CalamityMod.NPCs.HiveMind if (Main.netMode != NetmodeID.MultiplayerClient) { - if (!Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) - NPC.localAI[1] = 180f; + if (!Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[Main.npc[hiveMind].target].position, Main.player[Main.npc[hiveMind].target].width, Main.player[Main.npc[hiveMind].target].height)) + NPC.localAI[1] = ShootGateValue * 0.5f; - NPC.localAI[1] += Main.rand.Next(2) + 1f; - if (NPC.localAI[1] >= 360f && Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 80f) + float shootGateValue = ShootGateValue; + if (NPC.localAI[1] < shootGateValue) + { + NPC.localAI[1] += 1f; + if (NPC.localAI[1] < ShowTelegraphValue) + NPC.localAI[1] += Main.rand.Next(2); + if (masterMode) + NPC.localAI[1] += 1f; + } + + if (NPC.alpha > 0) + return; + + if (NPC.localAI[1] >= shootGateValue && Vector2.Distance(Main.player[Main.npc[hiveMind].target].Center, NPC.Center) > 80f) { NPC.localAI[1] = 0f; - NPC.TargetClosest(true); - if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[Main.npc[hiveMind].target].position, Main.player[Main.npc[hiveMind].target].width, Main.player[Main.npc[hiveMind].target].height)) { - float projSpeed = death ? 5f : revenge ? 4.5f : expertMode ? 4f : 3.5f; + float projSpeed = death ? 8f : revenge ? 7f : expertMode ? 6f : 4f; + if (masterMode) + projSpeed += 2f; if (Main.getGoodWorld) - projSpeed *= 2.4f; + projSpeed *= 1.5f; - Vector2 projDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + (NPC.height / 2)); - float playerX = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - projDirection.X; - float playerY = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - projDirection.Y; + Vector2 projDirection = NPC.Center; + float playerX = Main.player[Main.npc[hiveMind].target].Center.X - projDirection.X; + float playerY = Main.player[Main.npc[hiveMind].target].Center.Y - projDirection.Y; float playerDist = (float)Math.Sqrt(playerX * playerX + playerY * playerY); playerDist = projSpeed / playerDist; playerX *= playerDist; @@ -166,7 +197,7 @@ namespace CalamityMod.NPCs.HiveMind Vector2 projectileVelocity = new Vector2(playerX, playerY); if (type == ProjectileID.CursedFlameHostile) { - Vector2 v = Main.player[NPC.target].Center - NPC.Center - Main.player[NPC.target].velocity * 20f; + Vector2 v = Main.player[Main.npc[hiveMind].target].Center - NPC.Center - Main.player[Main.npc[hiveMind].target].velocity * 20f; projectileVelocity = v.SafeNormalize(Vector2.UnitY) * projSpeed; } Projectile.NewProjectile(NPC.GetSource_FromAI(), projDirection, projectileVelocity, type, damage, 0f, Main.myPlayer); @@ -176,6 +207,8 @@ namespace CalamityMod.NPCs.HiveMind } } + public override bool CanHitNPC(NPC target) => NPC.alpha == 0; // Can only be hit while fully visible + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { SpriteEffects spriteEffects = SpriteEffects.None; @@ -190,8 +223,8 @@ namespace CalamityMod.NPCs.HiveMind vector2 += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); Color color = NPC.GetAlpha(drawColor); - if (NPC.localAI[1] > 240f) - color = Color.Lerp(color, Color.Green, MathHelper.Clamp((NPC.localAI[1] - 240f) / 120f, 0f, 1f)); + if (NPC.localAI[1] > ShowTelegraphValue) + color = Color.Lerp(color, Color.LimeGreen * NPC.Opacity, MathHelper.Clamp((NPC.localAI[1] - ShowTelegraphValue) / TelegraphDuration, 0f, 1f)); spriteBatch.Draw(texture, vector2, NPC.frame, color, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); diff --git a/NPCs/HiveMind/HiveBlob2.cs b/NPCs/HiveMind/HiveBlob2.cs index 1d704aa619..9b3e44fd1f 100644 --- a/NPCs/HiveMind/HiveBlob2.cs +++ b/NPCs/HiveMind/HiveBlob2.cs @@ -14,6 +14,10 @@ namespace CalamityMod.NPCs.HiveMind { public class HiveBlob2 : ModNPC { + private const float ShootGateValue = 180f; + private const float TelegraphDuration = 120f; + private const float ShowTelegraphValue = ShootGateValue - TelegraphDuration; + public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.HiveBlob.DisplayName"); public override string Texture => "CalamityMod/NPCs/HiveMind/HiveBlob"; @@ -57,6 +61,7 @@ namespace CalamityMod.NPCs.HiveMind NPC.damage = 0; bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; + bool masterMode = Main.masterMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; @@ -72,6 +77,20 @@ namespace CalamityMod.NPCs.HiveMind return; } + // When Hive Mind starts flying around + bool phase2 = Main.npc[hiveMind].life / (float)Main.npc[hiveMind].lifeMax < 0.8f; + + if (phase2) + { + NPC.life = 0; + NPC.HitEffect(); + NPC.active = false; + NPC.netUpdate = true; + return; + } + + NPC.alpha = Main.npc[hiveMind].alpha; + if (NPC.ai[3] > 0f) hiveMind = (int)NPC.ai[3] - 1; @@ -88,50 +107,49 @@ namespace CalamityMod.NPCs.HiveMind } } - NPC.TargetClosest(true); - + float hiveMindVelocity = Main.npc[hiveMind].velocity.Length(); float relocateSpeed = getFuckedAI ? 1.2f : death ? 0.8f : revenge ? 0.7f : expertMode ? 0.6f : 0.5f; - Vector2 randomRelocateVector = new Vector2(NPC.ai[0] * 16f + 8f, NPC.ai[1] * 16f + 8f); - float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2) - (NPC.width / 2) - randomRelocateVector.X; - float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2) - (NPC.height / 2) - randomRelocateVector.Y; - float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); - float hiveMindX = Main.npc[hiveMind].position.X + (Main.npc[hiveMind].width / 2); - float hiveMindY = Main.npc[hiveMind].position.Y + (Main.npc[hiveMind].height / 2); + float acceleration = 0.8f; + float distanceFromMind = Main.getGoodWorld ? 192f : 96f; + + float hiveMindX = Main.npc[hiveMind].Center.X; + float hiveMindY = Main.npc[hiveMind].Center.Y; Vector2 hiveMindPos = new Vector2(hiveMindX, hiveMindY); float randomPosX = hiveMindX + NPC.ai[0]; float randomPosY = hiveMindY + NPC.ai[1]; float finalRandPosX = randomPosX - hiveMindPos.X; float finalRandPosY = randomPosY - hiveMindPos.Y; float finalRandDistance = (float)Math.Sqrt(finalRandPosX * finalRandPosX + finalRandPosY * finalRandPosY); - finalRandDistance = (Main.getGoodWorld ? 192f : 96f) / finalRandDistance; + finalRandDistance = distanceFromMind / finalRandDistance; finalRandPosX *= finalRandDistance; finalRandPosY *= finalRandDistance; + if (NPC.position.X < hiveMindX + finalRandPosX) { - NPC.velocity.X = NPC.velocity.X + relocateSpeed; + NPC.velocity.X += relocateSpeed; if (NPC.velocity.X < 0f && finalRandPosX > 0f) - NPC.velocity.X = NPC.velocity.X * 0.8f; + NPC.velocity.X *= acceleration; } else if (NPC.position.X > hiveMindX + finalRandPosX) { - NPC.velocity.X = NPC.velocity.X - relocateSpeed; + NPC.velocity.X -= relocateSpeed; if (NPC.velocity.X > 0f && finalRandPosX < 0f) - NPC.velocity.X = NPC.velocity.X * 0.8f; + NPC.velocity.X *= acceleration; } if (NPC.position.Y < hiveMindY + finalRandPosY) { - NPC.velocity.Y = NPC.velocity.Y + relocateSpeed; + NPC.velocity.Y += relocateSpeed; if (NPC.velocity.Y < 0f && finalRandPosY > 0f) - NPC.velocity.Y = NPC.velocity.Y * 0.8f; + NPC.velocity.Y *= acceleration; } else if (NPC.position.Y > hiveMindY + finalRandPosY) { - NPC.velocity.Y = NPC.velocity.Y - relocateSpeed; + NPC.velocity.Y -= relocateSpeed; if (NPC.velocity.Y > 0f && finalRandPosY < 0f) - NPC.velocity.Y = NPC.velocity.Y * 0.8f; + NPC.velocity.Y *= acceleration; } - float velocityLimit = getFuckedAI ? 32f : 8f; + float velocityLimit = relocateSpeed * 16f; if (NPC.velocity.X > velocityLimit) NPC.velocity.X = velocityLimit; if (NPC.velocity.X < -velocityLimit) @@ -143,23 +161,36 @@ namespace CalamityMod.NPCs.HiveMind if (Main.netMode != NetmodeID.MultiplayerClient) { - if (!Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) - NPC.localAI[1] = 180f; + if (!Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[Main.npc[hiveMind].target].position, Main.player[Main.npc[hiveMind].target].width, Main.player[Main.npc[hiveMind].target].height)) + NPC.localAI[1] = ShootGateValue * 0.5f; - NPC.localAI[1] += Main.rand.Next(3) + 1f; - if (NPC.localAI[1] >= 360f && Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 80f) + float shootGateValue = ShootGateValue; + if (NPC.localAI[1] < shootGateValue) + { + NPC.localAI[1] += 1f; + if (NPC.localAI[1] < ShowTelegraphValue) + NPC.localAI[1] += Main.rand.Next(2); + if (masterMode) + NPC.localAI[1] += 1f; + } + + if (NPC.alpha > 0) + return; + + if (NPC.localAI[1] >= shootGateValue && Vector2.Distance(Main.player[Main.npc[hiveMind].target].Center, NPC.Center) > 80f) { NPC.localAI[1] = 0f; - NPC.TargetClosest(true); - if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[Main.npc[hiveMind].target].position, Main.player[Main.npc[hiveMind].target].width, Main.player[Main.npc[hiveMind].target].height)) { - float projSpeed = death ? 5f : revenge ? 4.5f : expertMode ? 4f : 3.5f; + float projSpeed = death ? 8f : revenge ? 7f : expertMode ? 6f : 4f; + if (masterMode) + projSpeed += 2f; if (Main.getGoodWorld) - projSpeed *= 2.4f; + projSpeed *= 1.5f; - Vector2 projDirection = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + (NPC.height / 2)); - float playerX = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - projDirection.X; - float playerY = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - projDirection.Y; + Vector2 projDirection = NPC.Center; + float playerX = Main.player[Main.npc[hiveMind].target].Center.X - projDirection.X; + float playerY = Main.player[Main.npc[hiveMind].target].Center.Y - projDirection.Y; float playerDist = (float)Math.Sqrt(playerX * playerX + playerY * playerY); playerDist = projSpeed / playerDist; playerX *= playerDist; @@ -169,7 +200,7 @@ namespace CalamityMod.NPCs.HiveMind Vector2 projectileVelocity = new Vector2(playerX, playerY); if (type == ProjectileID.CursedFlameHostile) { - Vector2 v = Main.player[NPC.target].Center - NPC.Center - Main.player[NPC.target].velocity * 20f; + Vector2 v = Main.player[Main.npc[hiveMind].target].Center - NPC.Center - Main.player[Main.npc[hiveMind].target].velocity * 20f; projectileVelocity = v.SafeNormalize(Vector2.UnitY) * projSpeed; } Projectile.NewProjectile(NPC.GetSource_FromAI(), projDirection, projectileVelocity, type, damage, 0f, Main.myPlayer); @@ -179,6 +210,8 @@ namespace CalamityMod.NPCs.HiveMind } } + public override bool CanHitNPC(NPC target) => NPC.alpha == 0; // Can only be hit while fully visible + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { SpriteEffects spriteEffects = SpriteEffects.None; @@ -193,8 +226,8 @@ namespace CalamityMod.NPCs.HiveMind vector2 += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); Color color = NPC.GetAlpha(drawColor); - if (NPC.localAI[1] > 240f) - color = Color.Lerp(color, Color.Green, MathHelper.Clamp((NPC.localAI[1] - 240f) / 120f, 0f, 1f)); + if (NPC.localAI[1] > ShowTelegraphValue) + color = Color.Lerp(color, Color.LimeGreen * NPC.Opacity, MathHelper.Clamp((NPC.localAI[1] - ShowTelegraphValue) / TelegraphDuration, 0f, 1f)); spriteBatch.Draw(texture, vector2, NPC.frame, color, NPC.rotation, vector, NPC.scale, spriteEffects, 0f); diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index 6337421d61..415eae29bc 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -1,4 +1,5 @@ using System.IO; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; @@ -70,6 +71,7 @@ namespace CalamityMod.NPCs.HiveMind private int lungeFade = 15; // Divide 255 by this for duration of hive mind spin before slowing for lunge private double lungeRots = 0.2; // Number of revolutions made while spinning/fading in for lunge private bool dashStarted = false; + private int vileSpitFireRate = 24; // Fire rate for Expert-exclusive Vile Spits during phase 1 teleports private int phase2timer = 360; private int rotationDirection; private double rotation; @@ -129,13 +131,19 @@ namespace CalamityMod.NPCs.HiveMind NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; - if (Main.expertMode) + bool bossRush = BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || bossRush; + bool masterMode = Main.masterMode || bossRush; + bool revenge = CalamityWorld.revenge || bossRush; + bool death = CalamityWorld.death || bossRush; + + if (expertMode) { minimumDriftTime = 120; reelbackFade = 4; } - if (CalamityWorld.revenge) + if (revenge) { lungeRots = 0.3; minimumDriftTime = 90; @@ -143,19 +151,21 @@ namespace CalamityMod.NPCs.HiveMind lungeTime = 28; driftSpeed = 2f; driftBoost = 2f; + vileSpitFireRate = 18; } - if (CalamityWorld.death) + if (death) { lungeRots = 0.4; minimumDriftTime = 60; reelbackFade = 6; lungeTime = 23; - driftSpeed = 3f; - driftBoost = 1f; + driftSpeed = 3.5f; + driftBoost = 1.5f; + vileSpitFireRate = 15; } - if (BossRushEvent.BossRushActive) + if (bossRush) { lungeRots = 0.4; minimumDriftTime = 40; @@ -163,6 +173,18 @@ namespace CalamityMod.NPCs.HiveMind lungeTime = 16; driftSpeed = 6f; driftBoost = 1f; + vileSpitFireRate = 12; + } + + if (masterMode) + { + lungeRots += 0.1; + minimumDriftTime /= 2; + reelbackFade *= 2; + lungeTime -= 5; + driftSpeed += ((death && !bossRush) ? 0.5f : 1f); + driftBoost += ((death && !bossRush) ? 0.5f : 1f); + vileSpitFireRate -= 6; } if (Main.getGoodWorld) @@ -216,11 +238,6 @@ namespace CalamityMod.NPCs.HiveMind writer.Write(reelCount); writer.Write(frameX); writer.Write(frameY); - - writer.Write(NPC.frame.X); - writer.Write(NPC.frame.Y); - writer.Write(NPC.frame.Width); - writer.Write(NPC.frame.Height); } public override void ReceiveExtraAI(BinaryReader reader) @@ -243,10 +260,6 @@ namespace CalamityMod.NPCs.HiveMind reelCount = reader.ReadInt32(); frameX = reader.ReadInt32(); frameY = reader.ReadInt32(); - - Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); - if (frame.Width > 0 && frame.Height > 0) - NPC.frame = frame; } public override void FindFrame(int frameHeight) @@ -279,8 +292,6 @@ namespace CalamityMod.NPCs.HiveMind if ((frameX * maxFramesY_Phase2) + frameY > 15) frameX = frameY = 0; } - - NPC.frame = new Rectangle(NPC.width * frameX, NPC.height * frameY, NPC.width, NPC.height); } else { @@ -300,7 +311,7 @@ namespace CalamityMod.NPCs.HiveMind { SpriteEffects spriteEffects = NPC.direction == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Texture2D texture = Phase2Texture.Value; - Vector2 vector = new Vector2(NPC.width / 2, NPC.height / 2); + Vector2 vector = new Vector2(NPC.width / 2, height_Phase2 / 2); Color afterimageBaseColor = Color.White; int numAfterimages = 5; @@ -312,15 +323,15 @@ namespace CalamityMod.NPCs.HiveMind afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); afterimageColor = NPC.GetAlpha(afterimageColor); afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + Vector2 afterimageCenter = NPC.oldPos[i] + new Vector2(NPC.width, height_Phase2) / 2f - screenPos; afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX_Phase2, maxFramesY_Phase2) * NPC.scale / 2f; afterimageCenter += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, afterimageCenter, NPC.frame, afterimageColor, NPC.oldRot[i], vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, afterimageCenter, new Rectangle(NPC.width * frameX, height_Phase2 * frameY, NPC.width, height_Phase2), afterimageColor, NPC.oldRot[i], vector, NPC.scale, spriteEffects, 0f); } } Vector2 center = NPC.Center - screenPos; - spriteBatch.Draw(texture, center, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, center, new Rectangle(NPC.width * frameX, height_Phase2 * frameY, NPC.width, height_Phase2), NPC.GetAlpha(drawColor), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); return false; } @@ -330,7 +341,13 @@ namespace CalamityMod.NPCs.HiveMind private void SpawnStuff() { - int maxSpawns = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 5 : CalamityWorld.revenge ? 4 : Main.expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); + bool bossRush = BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || bossRush; + bool masterMode = Main.masterMode || bossRush; + bool revenge = CalamityWorld.revenge || bossRush; + bool death = CalamityWorld.death || bossRush; + + int maxSpawns = death ? 5 : revenge ? 4 : expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); for (int i = 0; i < maxSpawns; i++) { int type = NPCID.EaterofSouls; @@ -358,21 +375,24 @@ namespace CalamityMod.NPCs.HiveMind while (NPC.AnyNPCs(type) && choice < 5); if (choice < 5) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + Main.rand.Next(NPC.width), (int)NPC.position.Y + Main.rand.Next(NPC.height), type); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + Main.rand.Next(NPC.width), (int)NPC.position.Y + Main.rand.Next(height_Phase2), type); } // Spawn a Hive Cyst if (Main.zenithWorld && NPC.CountNPCS(ModContent.NPCType()) < 3) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + Main.rand.Next(NPC.width), (int)NPC.position.Y + Main.rand.Next(NPC.height), ModContent.NPCType()); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + Main.rand.Next(NPC.width), (int)NPC.position.Y + Main.rand.Next(height_Phase2), ModContent.NPCType()); } private void ReelBack() { + bool bossRush = BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || bossRush; + NPC.alpha = 0; phase2timer = 0; deceleration = NPC.velocity / 255f * reelbackFade; - if (CalamityWorld.revenge || BossRushEvent.BossRushActive) + if (revenge) { state = 2; SoundEngine.PlaySound(FastRoarSound, NPC.Center); @@ -398,14 +418,11 @@ namespace CalamityMod.NPCs.HiveMind if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - NPC.TargetClosest(); - Player player = Main.player[NPC.target]; bool bossRush = BossRushEvent.BossRushActive; bool expertMode = Main.expertMode || bossRush; + bool masterMode = Main.masterMode || bossRush; bool revenge = CalamityWorld.revenge || bossRush; bool death = CalamityWorld.death || bossRush; @@ -526,7 +543,7 @@ namespace CalamityMod.NPCs.HiveMind maxBlobs = 50; for (int i = 0; i < maxBlobs; i++) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType(), NPC.whoAmI); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, Main.rand.NextBool() ? ModContent.NPCType() : ModContent.NPCType(), NPC.whoAmI); } } @@ -535,13 +552,34 @@ namespace CalamityMod.NPCs.HiveMind if (NPC.life > 0) { - if (Main.netMode != NetmodeID.MultiplayerClient) + int fivePercentHP = (int)(NPC.lifeMax * 0.05); + if ((NPC.life + fivePercentHP) < NPC.ai[3]) { - int fivePercentHP = (int)(NPC.lifeMax * 0.05); - if ((NPC.life + fivePercentHP) < NPC.ai[3]) - { - NPC.ai[3] = NPC.life; + SoundEngine.PlaySound(SoundID.NPCDeath22, NPC.Center); + NPC.ai[3] = NPC.life; + + for (int i = 0; i < 20; i++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 3f; + if (Main.rand.NextBool()) + { + Main.dust[dust].scale = 0.5f; + Main.dust[dust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + for (int j = 0; j < 35; j++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, 0f, 0f, 100, default, 3f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 5f; + dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, 0f, 0f, 100, default, 2f); + Main.dust[dust].velocity *= 2f; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { int maxSpawns = bossRush ? 10 : death ? 5 : revenge ? 4 : expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); int maxDankSpawns = bossRush ? 4 : death ? Main.rand.Next(2, 4) : revenge ? 2 : expertMode ? Main.rand.Next(1, 3) : 1; @@ -550,14 +588,14 @@ namespace CalamityMod.NPCs.HiveMind int x = (int)(NPC.position.X + Main.rand.Next(NPC.width - 32)); int y = (int)(NPC.position.Y + Main.rand.Next(NPC.height - 32)); - int type = ModContent.NPCType(); + int type = Main.rand.NextBool() ? ModContent.NPCType() : ModContent.NPCType(); if (NPC.CountNPCS(ModContent.NPCType()) < maxDankSpawns) type = ModContent.NPCType(); int fivePercentMinions = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, type); Main.npc[fivePercentMinions].SetDefaults(type); if (Main.netMode == NetmodeID.Server && fivePercentMinions < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, fivePercentMinions, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, fivePercentMinions); } return; @@ -580,6 +618,8 @@ namespace CalamityMod.NPCs.HiveMind { NPC.scale += 0.0165f; NPC.alpha -= 4; + if (NPC.alpha < 0) + NPC.alpha = 0; int burrowedDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, DustID.Demonite, 0f, -3f, 100, default, 2.5f * NPC.scale); Main.dust[burrowedDust].velocity *= 2f; @@ -597,6 +637,15 @@ namespace CalamityMod.NPCs.HiveMind burrowedDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, DustID.Demonite, 0f, -3f, 100, default, 2.5f * NPC.scale); Main.dust[burrowedDust2].velocity *= 1f; } + + if (expertMode) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (Collision.CanHitLine(NPC.Center, 1, 1, player.Center, 1, 1) && NPC.Distance(player.Center) > 160f && burrowTimer % vileSpitFireRate == 0) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.VileSpitEaterOfWorlds, 0, 0f, 69f); + } + } } else if (burrowTimer == -60) { @@ -613,6 +662,16 @@ namespace CalamityMod.NPCs.HiveMind tilePosY++; NPC.position.Y += 16; } + + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC hiveBlob = Main.npc[i]; + if (hiveBlob.active && (hiveBlob.type == ModContent.NPCType() || hiveBlob.type == ModContent.NPCType())) + { + hiveBlob.position.X = NPC.position.X; + hiveBlob.position.Y = NPC.position.Y; + } + } } NPC.netUpdate = true; NPC.netSpam = 0; @@ -621,6 +680,8 @@ namespace CalamityMod.NPCs.HiveMind { NPC.scale -= 0.0165f; NPC.alpha += 4; + if (NPC.alpha > 255) + NPC.alpha = 255; int burrowedDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, DustID.Demonite, 0f, -3f, 100, default, 2.5f * NPC.scale); Main.dust[burrowedDust].velocity *= 2f; @@ -638,6 +699,15 @@ namespace CalamityMod.NPCs.HiveMind burrowedDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.Center.Y), NPC.width, NPC.height / 2, DustID.Demonite, 0f, -3f, 100, default, 2.5f * NPC.scale); Main.dust[burrowedDust2].velocity *= 1f; } + + if (expertMode) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (Collision.CanHitLine(NPC.Center, 1, 1, player.Center, 1, 1) && NPC.Distance(player.Center) > 160f && burrowTimer % vileSpitFireRate == 0) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.VileSpitEaterOfWorlds, 0, 0f, 69f); + } + } } else if (burrowTimer == 0) { @@ -663,7 +733,11 @@ namespace CalamityMod.NPCs.HiveMind NPC.damage = 0; if (NPC.alpha > 0) + { NPC.alpha -= 3; + if (NPC.alpha < 0) + NPC.alpha = 0; + } if (nextState == 0) { @@ -702,7 +776,7 @@ namespace CalamityMod.NPCs.HiveMind else { reelCount++; - if (Main.expertMode && reelCount == 2) + if (expertMode && reelCount == 2) { reelCount = 0; nextState = 2; @@ -722,11 +796,11 @@ namespace CalamityMod.NPCs.HiveMind NPC.netSpam = 0; } - if (!player.active || player.dead || Vector2.Distance(NPC.Center, player.Center) > 5000f) + if (!player.active || player.dead || Vector2.Distance(NPC.Center, player.Center) > 8000f) { NPC.TargetClosest(false); player = Main.player[NPC.target]; - if (!player.active || player.dead || Vector2.Distance(NPC.Center, player.Center) > 5000f) + if (!player.active || player.dead || Vector2.Distance(NPC.Center, player.Center) > 8000f) { if (NPC.timeLeft > 60) NPC.timeLeft = 60; @@ -749,9 +823,28 @@ namespace CalamityMod.NPCs.HiveMind return; } + if (expertMode) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.localAI[2] += 1f; + if (Collision.CanHitLine(NPC.Center, 1, 1, player.Center, 1, 1) && NPC.Distance(player.Center) > 160f && NPC.localAI[2] % (vileSpitFireRate * 2) == 0) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.VileSpitEaterOfWorlds, 0, 0f, 69f); + } + } + NPC.velocity = player.Center - NPC.Center; phase2timer--; + + // Use an attack sooner if being hit + if (NPC.justHit) + phase2timer -= masterMode ? 7 : expertMode ? 5 : 3; + + // Use an attack sooner if target is close + if (NPC.Distance(player.Center) < 160f) + phase2timer -= 2; + if (phase2timer <= -180) // No stalling drift mode forever { NPC.velocity *= 2f / 255f * (reelbackFade + 2 * (int)enrageScale); @@ -787,10 +880,10 @@ namespace CalamityMod.NPCs.HiveMind if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[1] != 0f && NPC.ai[2] != 0f) { NPC.position.X = NPC.ai[1] * 16 - NPC.width / 2; - NPC.position.Y = NPC.ai[2] * 16 - NPC.height / 2; + NPC.position.Y = NPC.ai[2] * 16 - height_Phase2 / 2; } - phase2timer = minimumDriftTime + Main.rand.Next(121); + phase2timer = minimumDriftTime + Main.rand.Next(masterMode ? 61 : 121); NPC.netUpdate = true; NPC.netSpam = 0; } @@ -855,13 +948,24 @@ namespace CalamityMod.NPCs.HiveMind NPC.netSpam = 0; if (NPC.alpha > 0) { - NPC.alpha -= lungeFade; - if (Main.netMode != NetmodeID.MultiplayerClient) + { NPC.Center = player.Center + new Vector2(teleportRadius, 0).RotatedBy(rotation); + if (masterMode) + { + NPC.localAI[2] += 1f; + if (Collision.CanHitLine(NPC.Center, 1, 1, player.Center, 1, 1) && NPC.Distance(player.Center) > 160f && NPC.localAI[2] % vileSpitFireRate == 0) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.VileSpitEaterOfWorlds, 0, 0f, 70f); + } + } + rotation += rotationIncrement * rotationDirection; phase2timer = lungeDelay; + + NPC.alpha -= lungeFade; + if (NPC.alpha < 0) + NPC.alpha = 0; } else { @@ -883,8 +987,17 @@ namespace CalamityMod.NPCs.HiveMind else { if (Main.netMode != NetmodeID.MultiplayerClient) + { NPC.Center = player.Center + new Vector2(teleportRadius, 0).RotatedBy(rotation); + if (masterMode) + { + NPC.localAI[2] += 1f; + if (Collision.CanHitLine(NPC.Center, 1, 1, player.Center, 1, 1) && NPC.Distance(player.Center) > 160f && NPC.localAI[2] % vileSpitFireRate == 0) + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.VileSpitEaterOfWorlds, 0, 0f, 70f); + } + } + rotation += rotationIncrement * rotationDirection * phase2timer / lungeDelay; } } @@ -914,12 +1027,16 @@ namespace CalamityMod.NPCs.HiveMind if (NPC.alpha > 0) { - NPC.alpha -= 5; if (Main.netMode != NetmodeID.MultiplayerClient) { NPC.Center = player.Center; NPC.position.Y += teleportRadius; } + + NPC.alpha -= masterMode ? 10 : 5; + if (NPC.alpha < 0) + NPC.alpha = 0; + NPC.netUpdate = true; NPC.netSpam = 0; } @@ -948,24 +1065,25 @@ namespace CalamityMod.NPCs.HiveMind if (phase2timer == (int)arcTime / 6) { phase2timer = 0; - NPC.ai[0]++; + NPC.ai[0] += 1f; if (Main.netMode != NetmodeID.MultiplayerClient && Collision.CanHit(NPC.Center, 1, 1, player.position, player.width, player.height)) { - if (NPC.ai[0] == 2 || NPC.ai[0] == 4) + if (NPC.ai[0] == 2f || (NPC.ai[0] == 4f && death)) { - if (expertMode && !NPC.AnyNPCs(ModContent.NPCType())) + int maxHearts = revenge ? 2 : 1; + if (expertMode && NPC.CountNPCS(ModContent.NPCType()) < maxHearts) NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType()); } else if (!NPC.AnyNPCs(NPCID.EaterofSouls)) NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.EaterofSouls); } - if (NPC.ai[0] == 6) + if (NPC.ai[0] == 6f) { NPC.velocity = NPC.velocity.RotatedBy(MathHelper.Pi / arcTime * -rotationDirection); SpawnStuff(); state = 6; - NPC.ai[0] = 0; + NPC.ai[0] = 0f; deceleration = NPC.velocity / decelerationTime; } } @@ -981,13 +1099,17 @@ namespace CalamityMod.NPCs.HiveMind if (NPC.alpha > 0) { - NPC.alpha -= 5; if (Main.netMode != NetmodeID.MultiplayerClient) { NPC.Center = player.Center; NPC.position.Y -= teleportRadius; NPC.position.X += teleportRadius * rotationDirection; } + + NPC.alpha -= masterMode ? 10 : 5; + if (NPC.alpha < 0) + NPC.alpha = 0; + NPC.netUpdate = true; NPC.netSpam = 0; } @@ -1014,20 +1136,20 @@ namespace CalamityMod.NPCs.HiveMind if (phase2timer == (int)arcTime / 20) { phase2timer = 0; - NPC.ai[0]++; + NPC.ai[0] += 1f; if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Vector2 cloudSpawnPos = new Vector2(NPC.position.X + Main.rand.Next(NPC.width), NPC.position.Y + Main.rand.Next(NPC.height)); + Vector2 cloudSpawnPos = new Vector2(NPC.position.X + Main.rand.Next(NPC.width), NPC.position.Y + Main.rand.Next(height_Phase2)); Vector2 randomVelocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.rand.NextVector2CircularEdge(4f, 4f) : Vector2.Zero; Projectile.NewProjectile(NPC.GetSource_FromAI(), cloudSpawnPos, randomVelocity, type, damage, 0, Main.myPlayer, 11f); } - if (NPC.ai[0] == 10) + if (NPC.ai[0] == 10f) { state = 6; - NPC.ai[0] = 0; + NPC.ai[0] = 0f; deceleration = NPC.velocity / decelerationTime; } } @@ -1045,7 +1167,7 @@ namespace CalamityMod.NPCs.HiveMind phase2timer++; if (phase2timer == decelerationTime) { - phase2timer = minimumDriftTime + Main.rand.Next(121); + phase2timer = minimumDriftTime + Main.rand.Next(masterMode ? 61 : 121); state = 0; NPC.netUpdate = true; NPC.netSpam = 0; @@ -1078,6 +1200,14 @@ namespace CalamityMod.NPCs.HiveMind return minDist <= 60f && NPC.alpha == 0 && NPC.scale == 1f; // No damage while not fully visible or shrunk } + public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) + { + if (hurtInfo.Damage < 0) + return; + + target.AddBuff(ModContent.BuffType(), 300); + } + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => NPC.scale == 1f; // Only draw HP bar while at full size public override void ModifyIncomingHit(ref NPC.HitModifiers modifiers) @@ -1099,34 +1229,26 @@ namespace CalamityMod.NPCs.HiveMind public override void HitEffect(NPC.HitInfo hit) { - for (int k = 0; k < hit.Damage / NPC.lifeMax * 100.0; k++) - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, hit.HitDirection, -1f, 0, default, 1f); - // When Hive Mind starts flying around bool phase2 = NPC.life / (float)NPC.lifeMax < 0.8f; - if (phase2) + for (int k = 0; k < hit.Damage / NPC.lifeMax * 100.0; k++) + Dust.NewDust(NPC.position, NPC.width, phase2 ? height_Phase2 : NPC.height, DustID.Demonite, hit.HitDirection, -1f, 0, default, 1f); + + if (!phase2) { - if (Main.netMode != NetmodeID.MultiplayerClient && Main.zenithWorld ? NPC.CountNPCS(ModContent.NPCType()) < 10 : (Main.rand.NextBool(15) && NPC.CountNPCS(ModContent.NPCType()) < 2)) + if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 spawnAt = NPC.Center + new Vector2(0f, NPC.height / 2f); - NPC.NewNPC(NPC.GetSource_FromThis(), (int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType()); - } - } - else - { - if (NPC.CountNPCS(NPCID.EaterofSouls) < 3 && NPC.CountNPCS(NPCID.DevourerHead) < 1) - { - if (Main.rand.NextBool(60) && Main.netMode != NetmodeID.MultiplayerClient) + if (Main.rand.NextBool(60)) { - Vector2 spawnAt = NPC.Center + new Vector2(0f, NPC.height / 2f); - NPC.NewNPC(NPC.GetSource_FromThis(), (int)spawnAt.X, (int)spawnAt.Y, NPCID.EaterofSouls); + if (NPC.CountNPCS(NPCID.EaterofSouls) < 3) + NPC.NewNPC(NPC.GetSource_FromThis(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.EaterofSouls); } - if (Main.rand.NextBool(150) && Main.netMode != NetmodeID.MultiplayerClient) + if (Main.rand.NextBool(150)) { - Vector2 spawnAt = NPC.Center + new Vector2(0f, NPC.height / 2f); - NPC.NewNPC(NPC.GetSource_FromThis(), (int)spawnAt.X, (int)spawnAt.Y, NPCID.DevourerHead); + if (!NPC.AnyNPCs(NPCID.DevourerHead)) + NPC.NewNPC(NPC.GetSource_FromThis(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.DevourerHead); } } } @@ -1141,14 +1263,14 @@ namespace CalamityMod.NPCs.HiveMind } NPC.position.X = NPC.position.X + (NPC.width / 2); - NPC.position.Y = NPC.position.Y + (NPC.height / 2); + NPC.position.Y = NPC.position.Y + (height_Phase2 / 2); NPC.width = 200; NPC.height = 150; NPC.position.X = NPC.position.X - (NPC.width / 2); - NPC.position.Y = NPC.position.Y - (NPC.height / 2); + NPC.position.Y = NPC.position.Y - (height_Phase2 / 2); for (int i = 0; i < 40; i++) { - int killDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, 0f, 0f, 100, default, 2f); + int killDust = Dust.NewDust(NPC.position, NPC.width, height_Phase2, DustID.Demonite, 0f, 0f, 100, default, 2f); Main.dust[killDust].velocity *= 3f; if (Main.rand.NextBool()) { @@ -1158,10 +1280,10 @@ namespace CalamityMod.NPCs.HiveMind } for (int j = 0; j < 70; j++) { - int killDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, 0f, 0f, 100, default, 3f); + int killDust2 = Dust.NewDust(NPC.position, NPC.width, height_Phase2, DustID.Demonite, 0f, 0f, 100, default, 3f); Main.dust[killDust2].noGravity = true; Main.dust[killDust2].velocity *= 5f; - killDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, 0f, 0f, 100, default, 2f); + killDust2 = Dust.NewDust(NPC.position, NPC.width, height_Phase2, DustID.Demonite, 0f, 0f, 100, default, 2f); Main.dust[killDust2].velocity *= 2f; } } diff --git a/NPCs/NormalNPCs/BloodlettingServant.cs b/NPCs/NormalNPCs/BloodlettingServant.cs index 3ec7e710f1..879a389f03 100644 --- a/NPCs/NormalNPCs/BloodlettingServant.cs +++ b/NPCs/NormalNPCs/BloodlettingServant.cs @@ -248,7 +248,7 @@ namespace CalamityMod.NPCs.NormalNPCs { Texture2D npcTexture = TextureAssets.Npc[NPC.type].Value; Color originalColor = NPC.GetAlpha(drawColor); - Color newColor = new Color(255, 128, 128, 255 - NPC.alpha); + Color newColor = new Color(255, 192, 192, 255 - NPC.alpha); Vector2 drawPosition = NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY); Vector2 origin = NPC.frame.Size() / 2; @@ -284,7 +284,7 @@ namespace CalamityMod.NPCs.NormalNPCs return true; } - public override Color? GetAlpha(Color drawColor) => new Color(128, 0, 0, 255 - NPC.alpha); + public override Color? GetAlpha(Color drawColor) => new Color(192, 0, 0, 255 - NPC.alpha); public override void HitEffect(NPC.HitInfo hit) { diff --git a/NPCs/NormalNPCs/Cnidrion.cs b/NPCs/NormalNPCs/Cnidrion.cs index 89f9538999..7ea2b7e4e1 100644 --- a/NPCs/NormalNPCs/Cnidrion.cs +++ b/NPCs/NormalNPCs/Cnidrion.cs @@ -83,7 +83,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.AnyNPCs(NPC.type)) return 0f; - return 0.1f; + return 0.05f; } public override void FindFrame(int frameHeight) diff --git a/NPCs/NormalNPCs/CrawlerAmber.cs b/NPCs/NormalNPCs/CrawlerAmber.cs index 9333fa56dd..a2ac0b57eb 100644 --- a/NPCs/NormalNPCs/CrawlerAmber.cs +++ b/NPCs/NormalNPCs/CrawlerAmber.cs @@ -97,7 +97,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneSunkenSea) + if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().InAnyCalamityBiome) { return 0f; } diff --git a/NPCs/NormalNPCs/CrawlerAmethyst.cs b/NPCs/NormalNPCs/CrawlerAmethyst.cs index 6109809617..6a432d29cf 100644 --- a/NPCs/NormalNPCs/CrawlerAmethyst.cs +++ b/NPCs/NormalNPCs/CrawlerAmethyst.cs @@ -97,7 +97,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneAbyss || spawnInfo.Player.Calamity().ZoneSunkenSea) + if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().InAnyCalamityBiome) { return 0f; } diff --git a/NPCs/NormalNPCs/CrawlerCrystal.cs b/NPCs/NormalNPCs/CrawlerCrystal.cs index f90f0c6d88..aa32b01389 100644 --- a/NPCs/NormalNPCs/CrawlerCrystal.cs +++ b/NPCs/NormalNPCs/CrawlerCrystal.cs @@ -98,7 +98,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneAbyss || spawnInfo.Player.Calamity().ZoneSunkenSea) + if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().InAnyCalamityBiome) { return 0f; } diff --git a/NPCs/NormalNPCs/CrawlerDiamond.cs b/NPCs/NormalNPCs/CrawlerDiamond.cs index b5c103278c..a53c26e4a7 100644 --- a/NPCs/NormalNPCs/CrawlerDiamond.cs +++ b/NPCs/NormalNPCs/CrawlerDiamond.cs @@ -97,7 +97,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneAbyss || spawnInfo.Player.Calamity().ZoneSunkenSea) + if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().InAnyCalamityBiome) { return 0f; } diff --git a/NPCs/NormalNPCs/CrawlerEmerald.cs b/NPCs/NormalNPCs/CrawlerEmerald.cs index 982d5b5027..187e18bbe4 100644 --- a/NPCs/NormalNPCs/CrawlerEmerald.cs +++ b/NPCs/NormalNPCs/CrawlerEmerald.cs @@ -97,7 +97,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneAbyss || spawnInfo.Player.Calamity().ZoneSunkenSea) + if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().InAnyCalamityBiome) { return 0f; } diff --git a/NPCs/NormalNPCs/CrawlerRuby.cs b/NPCs/NormalNPCs/CrawlerRuby.cs index 9c03ee3ba8..7a70aadd97 100644 --- a/NPCs/NormalNPCs/CrawlerRuby.cs +++ b/NPCs/NormalNPCs/CrawlerRuby.cs @@ -97,7 +97,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneAbyss || spawnInfo.Player.Calamity().ZoneSunkenSea) + if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().InAnyCalamityBiome) { return 0f; } diff --git a/NPCs/NormalNPCs/CrawlerSapphire.cs b/NPCs/NormalNPCs/CrawlerSapphire.cs index 2f61eac7b6..67894c8546 100644 --- a/NPCs/NormalNPCs/CrawlerSapphire.cs +++ b/NPCs/NormalNPCs/CrawlerSapphire.cs @@ -97,7 +97,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneAbyss || spawnInfo.Player.Calamity().ZoneSunkenSea) + if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().InAnyCalamityBiome) { return 0f; } diff --git a/NPCs/NormalNPCs/CrawlerTopaz.cs b/NPCs/NormalNPCs/CrawlerTopaz.cs index a5d17eb520..36752b68e0 100644 --- a/NPCs/NormalNPCs/CrawlerTopaz.cs +++ b/NPCs/NormalNPCs/CrawlerTopaz.cs @@ -97,7 +97,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().ZoneAbyss || spawnInfo.Player.Calamity().ZoneSunkenSea) + if (spawnInfo.PlayerSafe || spawnInfo.Player.Calamity().InAnyCalamityBiome) { return 0f; } diff --git a/NPCs/NormalNPCs/KingSlimeJewel3.cs b/NPCs/NormalNPCs/KingSlimeJewelEmerald.cs similarity index 99% rename from NPCs/NormalNPCs/KingSlimeJewel3.cs rename to NPCs/NormalNPCs/KingSlimeJewelEmerald.cs index 91668e6b70..5d5160792f 100644 --- a/NPCs/NormalNPCs/KingSlimeJewel3.cs +++ b/NPCs/NormalNPCs/KingSlimeJewelEmerald.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class KingSlimeJewel3 : ModNPC + public class KingSlimeJewelEmerald : ModNPC { public override string Texture => "CalamityMod/NPCs/NormalNPCs/KingSlimeJewel"; @@ -35,7 +35,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.defense = 15; NPC.DR_NERD(0.15f); - NPC.lifeMax = 280; + NPC.lifeMax = 240; double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); diff --git a/NPCs/NormalNPCs/KingSlimeJewel.cs b/NPCs/NormalNPCs/KingSlimeJewelRuby.cs similarity index 96% rename from NPCs/NormalNPCs/KingSlimeJewel.cs rename to NPCs/NormalNPCs/KingSlimeJewelRuby.cs index a6edbdf1f8..327d1d0054 100644 --- a/NPCs/NormalNPCs/KingSlimeJewel.cs +++ b/NPCs/NormalNPCs/KingSlimeJewelRuby.cs @@ -10,8 +10,10 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class KingSlimeJewel : ModNPC + public class KingSlimeJewelRuby : ModNPC { + public override string Texture => "CalamityMod/NPCs/NormalNPCs/KingSlimeJewel"; + private const int BoltShootGateValue = 60; private const int BoltShootGateValue_Death = 75; private const int BoltShootGateValue_BossRush = 45; @@ -33,7 +35,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.defense = 10; NPC.DR_NERD(0.1f); - NPC.lifeMax = 140; + NPC.lifeMax = 120; double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); @@ -152,8 +154,8 @@ namespace CalamityMod.NPCs.NormalNPCs int damage = NPC.GetProjectileDamage(type); if (CalamityWorld.death || BossRushEvent.BossRushActive) { - int numProj = 5; - float rotation = MathHelper.ToRadians(12); + int numProj = Main.masterMode ? 5 : 4; + float rotation = MathHelper.ToRadians(18); for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = projVector.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); diff --git a/NPCs/NormalNPCs/KingSlimeJewel2.cs b/NPCs/NormalNPCs/KingSlimeJewelSapphire.cs similarity index 90% rename from NPCs/NormalNPCs/KingSlimeJewel2.cs rename to NPCs/NormalNPCs/KingSlimeJewelSapphire.cs index d18df61e1d..a41db05782 100644 --- a/NPCs/NormalNPCs/KingSlimeJewel2.cs +++ b/NPCs/NormalNPCs/KingSlimeJewelSapphire.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class KingSlimeJewel2 : ModNPC + public class KingSlimeJewelSapphire : ModNPC { public override string Texture => "CalamityMod/NPCs/NormalNPCs/KingSlimeJewel"; @@ -34,7 +34,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.defense = 5; NPC.DR_NERD(0.05f); - NPC.lifeMax = 140; + NPC.lifeMax = 120; double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); @@ -71,7 +71,20 @@ namespace CalamityMod.NPCs.NormalNPCs float velocity = 5f; float acceleration = 0.1f; - if (NPC.position.Y > Main.player[NPC.target].position.Y - 300f) + int distanceFromKingSlime = 1; + Vector2 kingSlimeCenter = NPC.Center; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == NPCID.KingSlime) + { + distanceFromKingSlime = (int)NPC.Distance(Main.npc[i].Center); + kingSlimeCenter = Main.npc[i].Center; + break; + } + } + + Vector2 movementTarget = kingSlimeCenter == NPC.Center ? Main.player[NPC.target].Center : kingSlimeCenter; + if (NPC.position.Y > movementTarget.Y - 200f) { if (NPC.velocity.Y > 0f) NPC.velocity.Y *= 0.98f; @@ -81,7 +94,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.velocity.Y > velocity) NPC.velocity.Y = velocity; } - else if (NPC.position.Y < Main.player[NPC.target].position.Y - 400f) + else if (NPC.position.Y < movementTarget.Y - 250f) { if (NPC.velocity.Y < 0f) NPC.velocity.Y *= 0.98f; @@ -92,7 +105,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.velocity.Y = -velocity; } - if (NPC.Center.X > Main.player[NPC.target].Center.X + 300f) + if (NPC.Center.X > movementTarget.X + 100f) { if (NPC.velocity.X > 0f) NPC.velocity.X *= 0.98f; @@ -102,7 +115,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.velocity.X > 8f) NPC.velocity.X = 8f; } - if (NPC.Center.X < Main.player[NPC.target].Center.X - 300f) + if (NPC.Center.X < movementTarget.X - 100f) { if (NPC.velocity.X < 0f) NPC.velocity.X *= 0.98f; @@ -121,18 +134,6 @@ namespace CalamityMod.NPCs.NormalNPCs SoundEngine.PlaySound(SoundID.Item8, NPC.Center); - int distanceFromKingSlime = 1; - Vector2 kingSlimeCenter = NPC.Center; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == NPCID.KingSlime) - { - distanceFromKingSlime = (int)NPC.Distance(Main.npc[i].Center); - kingSlimeCenter = Main.npc[i].Center; - break; - } - } - for (int dusty = 0; dusty < 10; dusty++) { Vector2 dustVel = (kingSlimeCenter - NPC.Center).SafeNormalize(Vector2.UnitY) * Main.rand.NextFloat(2f, 4f); diff --git a/NPCs/NormalNPCs/SkeletronPrime2.cs b/NPCs/NormalNPCs/SkeletronPrime2.cs index 6164daf879..d644a5d641 100644 --- a/NPCs/NormalNPCs/SkeletronPrime2.cs +++ b/NPCs/NormalNPCs/SkeletronPrime2.cs @@ -268,28 +268,32 @@ namespace CalamityMod.NPCs.NormalNPCs // Start other phases; if arms are dead, start with spin phase bool otherHeadChargingOrSpinning = Main.npc[(int)NPC.ai[0]].ai[1] == 5f || Main.npc[(int)NPC.ai[0]].ai[1] == 1f; - if (phase2 || CalamityWorld.LegendaryMode || allArmsDead) + + // Start spin phase after 1.875 seconds + NPC.ai[2] += phase3 ? 1.2f : 0.8f; + if (NPC.ai[2] >= (90f - (death ? 15f * (1f - lifeRatio) : 0f)) && (!otherHeadChargingOrSpinning || phase3) && canUseAttackInMaster) { - // Start spin phase after 1.875 seconds - NPC.ai[2] += phase3 ? 1.2f : 0.8f; - if (NPC.ai[2] >= (90f - (death ? 15f * (1f - lifeRatio) : 0f)) && (!otherHeadChargingOrSpinning || phase3) && canUseAttackInMaster) + bool shouldSpinAround = NPC.ai[1] == 4f && NPC.position.Y < Main.player[Main.npc[(int)NPC.ai[0]].target].position.Y - 400f && + Vector2.Distance(Main.player[Main.npc[(int)NPC.ai[0]].target].Center, NPC.Center) < 600f && Vector2.Distance(Main.player[Main.npc[(int)NPC.ai[0]].target].Center, NPC.Center) > 400f; + + bool shouldCharge = !phase2 && !allArmsDead && !CalamityWorld.LegendaryMode; + if (shouldCharge) { - bool shouldSpinAround = NPC.ai[1] == 4f && NPC.position.Y < Main.player[Main.npc[(int)NPC.ai[0]].target].position.Y - 400f && - Vector2.Distance(Main.player[Main.npc[(int)NPC.ai[0]].target].Center, NPC.Center) < 600f && Vector2.Distance(Main.player[Main.npc[(int)NPC.ai[0]].target].Center, NPC.Center) > 400f; - - if (shouldSpinAround || NPC.ai[1] != 4f) + NPC.ai[2] = 0f; + NPC.ai[1] = 1f; + NPC.netUpdate = true; + } + else if (shouldSpinAround || NPC.ai[1] != 4f) + { + if (shouldSpinAround) { - if (shouldSpinAround) - { - NPC.localAI[3] = 300f; - NPC.SyncVanillaLocalAI(); - } - - NPC.ai[2] = 0f; - NPC.ai[1] = shouldSpinAround ? 5f : 1f; - NPC.TargetClosest(); - NPC.netUpdate = true; + NPC.localAI[3] = 300f; + NPC.SyncVanillaLocalAI(); } + + NPC.ai[2] = 0f; + NPC.ai[1] = shouldSpinAround ? 5f : 1f; + NPC.netUpdate = true; } } @@ -432,7 +436,6 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.ai[2] >= (phaseTimer - (death ? 60f * (1f - lifeRatio) : 0f))) { - NPC.TargetClosest(); NPC.ai[2] = 0f; NPC.ai[1] = 4f; NPC.localAI[0] = 0f; @@ -691,7 +694,6 @@ namespace CalamityMod.NPCs.NormalNPCs calamityGlobalNPC.newAI[0] = 0f; NPC.SyncVanillaLocalAI(); NPC.SyncExtraAI(); - NPC.TargetClosest(); NPC.netUpdate = true; } } @@ -769,7 +771,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.localAI[0] = 0f; NPC.SyncVanillaLocalAI(); NPC.SyncExtraAI(); - NPC.TargetClosest(); NPC.netUpdate = true; } } diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs index d85a7326d6..a98ab63273 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs @@ -13,6 +13,7 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.SummonItems; using CalamityMod.Items.Weapons.Typeless; using CalamityMod.Projectiles.Boss; +using CalamityMod.UI.VanillaBossBars; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -33,7 +34,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians { private int spearType = 0; private int healTimer = 0; - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; private const float TimeForShieldDespawn = 120f; public static readonly SoundStyle HolyRaySound = new("CalamityMod/Sounds/Custom/ProfanedGuardians/GuardianRay") { Volume = 1.25f }; public static readonly SoundStyle DashSound = new("CalamityMod/Sounds/Custom/ProfanedGuardians/GuardianDash"); @@ -82,6 +82,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.noTileCollide = true; AIType = -1; NPC.boss = true; + NPC.BossBar = ModContent.GetInstance(); NPC.value = Item.buyPrice(1, 0, 0, 0); NPC.HitSound = SoundID.NPCHit52; NPC.DeathSound = SoundID.NPCDeath55; @@ -105,7 +106,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians { writer.Write(spearType); writer.Write(healTimer); - writer.Write(biomeEnrageTimer); writer.Write(NPC.chaseable); writer.Write(NPC.localAI[0]); writer.Write(NPC.localAI[1]); @@ -119,7 +119,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians { spearType = reader.ReadInt32(); healTimer = reader.ReadInt32(); - biomeEnrageTimer = reader.ReadInt32(); NPC.chaseable = reader.ReadBoolean(); NPC.localAI[0] = reader.ReadSingle(); NPC.localAI[1] = reader.ReadSingle(); @@ -297,11 +296,11 @@ namespace CalamityMod.NPCs.ProfanedGuardians Player player = Main.player[NPC.target]; - if ((!Main.dayTime && !Main.remixWorld) || !player.active || player.dead || Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + if (!player.active || player.dead || Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) { NPC.TargetClosest(false); player = Main.player[NPC.target]; - if ((!Main.dayTime && !Main.remixWorld) || !player.active || player.dead || Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + if (!player.active || player.dead || Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) { if (NPC.velocity.Y > 3f) NPC.velocity.Y = 3f; @@ -334,20 +333,13 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (NPC.ai[3] < 0f) NPC.ai[3] = 0f; - // Become immune over time if target isn't in hell or hallow - bool isHoly = player.ZoneHallow; - bool isHell = player.ZoneUnderworldHeight; - if (!isHoly && !isHell && !bossRush) + // Enrage at nighttime + bool enraged = false; + if (!Main.dayTime && !Main.remixWorld) { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - else - NPC.Calamity().CurrentlyEnraged = true; + enraged = true; + NPC.Calamity().CurrentlyEnraged = true; } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - - bool biomeEnraged = biomeEnrageTimer <= 0; bool phase1 = healerAlive || defenderAlive; @@ -373,7 +365,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians float goLowOrHighDistance = 540f; // Side swap variables for Phase 2 - float defenderCommanderGuardPhase2Duration = (bossRush || biomeEnraged) ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; + float defenderCommanderGuardPhase2Duration = (bossRush || enraged) ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; float moveToOtherSideInPhase2GateValue = defenderCommanderGuardPhase2Duration - 120f; float timeBeforeMoveToOtherSideInPhase2Reset = moveToOtherSideInPhase2GateValue * 2f; float totalGoLowDurationPhase2 = 210f; @@ -381,13 +373,13 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Charge variables float chargeVelocityMult = 0.25f; - float maxChargeVelocity = (bossRush || biomeEnraged) ? 32f : death ? 28f : revenge ? 26f : expertMode ? 24f : 20f; + float maxChargeVelocity = (bossRush || enraged) ? 32f : death ? 28f : revenge ? 26f : expertMode ? 24f : 20f; if (Main.getGoodWorld) maxChargeVelocity *= 1.15f; if (CalamityWorld.LegendaryMode && revenge) maxChargeVelocity *= 2f; - float inertia = (bossRush || biomeEnraged) ? 40f : death ? 45f : revenge ? 47f : expertMode ? 50f : 55f; + float inertia = (bossRush || enraged) ? 40f : death ? 45f : revenge ? 47f : expertMode ? 50f : 55f; if (lifeRatio < 0.5f) inertia *= 0.8f; if (!phase1) @@ -470,7 +462,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (!goLow && !goLowPhase2 && !goHigh) calamityGlobalNPC.newAI[0] = -NPC.direction; - float velocity = (bossRush || biomeEnraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + float velocity = (bossRush || enraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; if (Main.getGoodWorld) velocity *= 1.25f; if (healerAlive) @@ -507,7 +499,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians Vector2 targetVector = destination - NPC.Center; Vector2 desiredVelocity = targetVector.SafeNormalize(new Vector2(NPC.direction, 0f)) * velocity; - float phaseGateValue = (bossRush || biomeEnraged) ? 50f : death ? 66f : revenge ? 75f : expertMode ? 83f : 100f; + float phaseGateValue = (bossRush || enraged) ? 50f : death ? 66f : revenge ? 75f : expertMode ? 83f : 100f; bool continueShootingProjectiles = phase1 || (NPC.ai[2] < (phaseGateValue * 5f)); if (continueShootingProjectiles) @@ -521,7 +513,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Alternate between firing profaned spears and holy fire // Shoot holy blasts in final phase NPC.ai[2] += 1f; - float projectileShootGateValue = (bossRush || biomeEnraged) ? 40f : death ? 60f : revenge ? 90f : expertMode ? 100f : 150f; + float projectileShootGateValue = (bossRush || enraged) ? 40f : death ? 60f : revenge ? 90f : expertMode ? 100f : 150f; if (NPC.ai[2] % projectileShootGateValue == 0f) { if (phase1) @@ -535,7 +527,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians } bool shootSpear = NPC.ai[2] % (projectileShootGateValue * 2f) == 0f; - float projectileVelocity = (bossRush || biomeEnraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + float projectileVelocity = (bossRush || enraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; Vector2 finalProjectileVelocity = Vector2.Normalize(player.Center - shootFrom) * projectileVelocity; int type = shootSpear ? ModContent.ProjectileType() : ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); @@ -548,8 +540,8 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (fireExtraProjectiles && shootSpear) { - int baseProjectileAmt = (bossRush || biomeEnraged) ? 4 : 2; - int spread = (bossRush || biomeEnraged) ? 18 : 10; + int baseProjectileAmt = (bossRush || enraged) ? 4 : 2; + int spread = (bossRush || enraged) ? 18 : 10; float rotation = MathHelper.ToRadians(spread); for (int i = 0; i < baseProjectileAmt; i++) { @@ -568,7 +560,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians else { // Shoot holy blasts - float holyBlastVelocity = (bossRush || biomeEnraged) ? 20f : death ? 18f : revenge ? 17f : expertMode ? 16f : 14f; + float holyBlastVelocity = (bossRush || enraged) ? 20f : death ? 18f : revenge ? 17f : expertMode ? 16f : 14f; int projTimeLeft = (int)(2000f / holyBlastVelocity); Vector2 finalHolyBlastVelocity = Vector2.Normalize(player.Center - shootFrom) * holyBlastVelocity; if (Main.netMode != NetmodeID.MultiplayerClient) @@ -681,7 +673,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.spriteDirection = Math.Sign(NPC.velocity.X); NPC.ai[1] += 1f; - float phaseGateValue = (bossRush || biomeEnraged) ? 90f : death ? 100f : revenge ? 110f : expertMode ? 120f : 135f; + float phaseGateValue = (bossRush || enraged) ? 90f : death ? 100f : revenge ? 110f : expertMode ? 120f : 135f; if (NPC.ai[1] >= phaseGateValue) { NPC.ai[0] = 3f; @@ -702,7 +694,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Accelerate if (NPC.velocity.Length() < maxChargeVelocity) { - float velocityMult = (bossRush || biomeEnraged) ? 1.053333f : death ? 1.05037f : revenge ? 1.047407f : expertMode ? 1.044444f : 1.04f; + float velocityMult = (bossRush || enraged) ? 1.053333f : death ? 1.05037f : revenge ? 1.047407f : expertMode ? 1.044444f : 1.04f; NPC.velocity = targetVector * (NPC.velocity.Length() * velocityMult); if (NPC.velocity.Length() > maxChargeVelocity) { @@ -790,7 +782,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians bool targetRanAwayAndWillNowBeFucked = NPC.ai[2] == 1f; bool boostVelocityToCatchUp = NPC.ai[1] == 0f || targetRanAwayAndWillNowBeFucked; - float velocity = (bossRush || biomeEnraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + float velocity = (bossRush || enraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; if (Main.getGoodWorld) velocity *= 1.25f; if (boostVelocityToCatchUp) @@ -802,7 +794,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians Vector2 desiredVelocity = targetVector.SafeNormalize(new Vector2(NPC.direction, 0f)) * velocity; float totalSpears = 12f; - float shootDuration = (bossRush || biomeEnraged) ? 240f : death ? 280f : revenge ? 300f : expertMode ? 320f : 360f; + float shootDuration = (bossRush || enraged) ? 240f : death ? 280f : revenge ? 300f : expertMode ? 320f : 360f; float dontShootTime = shootDuration * 0.3f; float phaseGateValue = dontShootTime + shootDuration; @@ -847,7 +839,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians } else if (NPC.ai[1] % spearShootDivisor == 0f) { - float spearVelocity = (bossRush || biomeEnraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + float spearVelocity = (bossRush || enraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; if (Main.getGoodWorld) spearVelocity *= 1.25f; if (boostVelocityToCatchUp) @@ -865,8 +857,8 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (NPC.ai[1] % (spearShootDivisor * 3) == 0f || targetRanAwayAndWillNowBeFucked) { knockbackVelocity *= 2f; - int baseProjectileAmt = (bossRush || biomeEnraged) ? 8 : expertMode ? 6 : 4; - int spread = (bossRush || biomeEnraged) ? 60 : expertMode ? 50 : 40; + int baseProjectileAmt = (bossRush || enraged) ? 8 : expertMode ? 6 : 4; + int spread = (bossRush || enraged) ? 60 : expertMode ? 50 : 40; float rotation = MathHelper.ToRadians(spread); for (int i = 0; i < baseProjectileAmt; i++) { @@ -902,7 +894,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians } float laserGateValue = 120f; - float velocity = (bossRush || biomeEnraged) ? 4.5f : death ? 4f : revenge ? 3.75f : expertMode ? 3.5f : 3f; + float velocity = (bossRush || enraged) ? 4.5f : death ? 4f : revenge ? 3.75f : expertMode ? 3.5f : 3f; if (NPC.ai[1] < laserGateValue) velocity *= 6f; if (Main.getGoodWorld) @@ -958,7 +950,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians { if (NPC.ai[2] == laserGateValue) { - float rotation = (bossRush || biomeEnraged) ? 435f : death ? 445f : revenge ? 450f : expertMode ? 455f : 465f; + float rotation = (bossRush || enraged) ? 435f : death ? 445f : revenge ? 450f : expertMode ? 455f : 465f; if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, NPC.Center) < 2800f) SoundEngine.PlaySound(HolyRaySound, Main.LocalPlayer.Center); @@ -1048,10 +1040,15 @@ namespace CalamityMod.NPCs.ProfanedGuardians texture2D15 = Texture_Glow.Value; Color timeBasedColorLerp = Color.Lerp(Color.White, Color.Yellow, 0.5f); - if (Main.remixWorld) + if (NPC.Calamity().CurrentlyEnraged) { texture2D15 = TextureNight_Glow.Value; - timeBasedColorLerp = Color.Cyan; + timeBasedColorLerp = Color.Lerp(Color.White, Color.Cyan, 0.75f); + } + if (Main.zenithWorld) + { + texture2D15 = TextureNight_Glow.Value; + timeBasedColorLerp = Main.DiscoColor; } if (colorOverride != null) timeBasedColorLerp = colorOverride.Value; @@ -1150,14 +1147,14 @@ namespace CalamityMod.NPCs.ProfanedGuardians Vector2 shieldDrawPos = NPC.Center - screenPos; shieldDrawPos -= new Vector2(shieldTexture.Width, shieldTexture.Height) * NPC.scale / 2f; shieldDrawPos += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY); - float minHue = (defenderAlive && healerAlive) ? 0.18f : 0.06f; + float minHue = NPC.Calamity().CurrentlyEnraged ? 0.4f : (defenderAlive && healerAlive) ? 0.18f : 0.06f; float maxHue = minHue + 0.12f; float opacityScaleDuringShieldDespawn = (TimeForShieldDespawn - NPC.localAI[1]) / TimeForShieldDespawn; float scaleDuringShieldDespawnScale = 1.8f; float scaleDuringShieldDespawn = (1f - opacityScaleDuringShieldDespawn) * scaleDuringShieldDespawnScale; float colorScale = MathHelper.Lerp(0f, shieldOpacity, opacityScaleDuringShieldDespawn); - Color color = Main.hslToRgb(MathHelper.Lerp(maxHue - minHue, maxHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi) + 1f) * 0.5f), 1f, 0.5f) * colorScale; - Color color2 = Main.hslToRgb(MathHelper.Lerp(minHue, maxHue - minHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.Pi * 3f) + 1f) * 0.5f), 1f, 0.5f) * colorScale; + Color color = Main.hslToRgb(MathHelper.Lerp(NPC.Calamity().CurrentlyEnraged ? minHue : maxHue - minHue, maxHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi) + 1f) * 0.5f), 1f, 0.5f) * colorScale; + Color color2 = Main.hslToRgb(MathHelper.Lerp(minHue, NPC.Calamity().CurrentlyEnraged ? maxHue : maxHue - minHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.Pi * 3f) + 1f) * 0.5f), 1f, 0.5f) * colorScale; color2.A = 0; color *= 0.6f; color2 *= 0.6f; diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs index dc0fba164b..b4033cedc5 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs @@ -24,7 +24,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians public class ProfanedGuardianDefender : ModNPC { private int healTimer = 0; - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; private const float TimeForShieldDespawn = 120f; public static readonly SoundStyle DashSound = new("CalamityMod/Sounds/Custom/ProfanedGuardians/GuardianDash"); public static readonly SoundStyle RockShieldSpawnSound = new("CalamityMod/Sounds/Custom/ProfanedGuardians/GuardianRockShieldActivate"); @@ -100,7 +99,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override void SendExtraAI(BinaryWriter writer) { writer.Write(healTimer); - writer.Write(biomeEnrageTimer); writer.Write(NPC.chaseable); writer.Write(NPC.localAI[0]); writer.Write(NPC.localAI[1]); @@ -111,7 +109,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override void ReceiveExtraAI(BinaryReader reader) { healTimer = reader.ReadInt32(); - biomeEnrageTimer = reader.ReadInt32(); NPC.chaseable = reader.ReadBoolean(); NPC.localAI[0] = reader.ReadSingle(); NPC.localAI[1] = reader.ReadSingle(); @@ -250,28 +247,21 @@ namespace CalamityMod.NPCs.ProfanedGuardians bool expertMode = Main.expertMode || bossRush; bool revenge = CalamityWorld.revenge || bossRush; bool death = CalamityWorld.death || bossRush; - bool isHoly = player.ZoneHallow; - bool isHell = player.ZoneUnderworldHeight; - // Become immune over time if target isn't in hell or hallow - if (!isHoly && !isHell && !bossRush) + // Enrage at nighttime + bool enraged = false; + if (!Main.dayTime && !Main.remixWorld) { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - else - NPC.Calamity().CurrentlyEnraged = true; + enraged = true; + NPC.Calamity().CurrentlyEnraged = true; } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - - bool biomeEnraged = biomeEnrageTimer <= 0; bool phase1 = healerAlive; NPC.chaseable = !phase1; // Phase durations - float commanderGuardPhase2Duration = (bossRush || biomeEnraged) ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; + float commanderGuardPhase2Duration = (bossRush || enraged) ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; float timeBeforeRocksRespawnInPhase2 = 90f; float throwRocksGateValue = 60f; @@ -280,7 +270,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Charge variables float chargeVelocityMult = 0.25f; - float maxChargeVelocity = (bossRush || biomeEnraged) ? 25f : death ? 22f : revenge ? 20.5f : expertMode ? 19f : 16f; + float maxChargeVelocity = (bossRush || enraged) ? 25f : death ? 22f : revenge ? 20.5f : expertMode ? 19f : 16f; if (Main.getGoodWorld) maxChargeVelocity *= 1.15f; @@ -400,7 +390,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians } } - float moveVelocity = (bossRush || biomeEnraged) ? 24f : death ? 22f : revenge ? 21f : expertMode ? 20f : 18f; + float moveVelocity = (bossRush || enraged) ? 24f : death ? 22f : revenge ? 21f : expertMode ? 20f : 18f; if (Main.getGoodWorld) moveVelocity *= 1.25f; if (healerAlive) @@ -450,7 +440,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Lay a holy bomb every once in a while in phase 1 and while not doing the laser attack if (!commanderUsingLaser) { - float projectileShootGateValue = (bossRush || biomeEnraged) ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; + float projectileShootGateValue = (bossRush || enraged) ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; NPC.ai[1] += 1f; if (NPC.ai[1] >= projectileShootGateValue) { @@ -520,7 +510,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians float shootMoltenBlastsGateValue = commanderGuardPhase2Duration / moltenBlastsDivisor; if (NPC.ai[1] % shootMoltenBlastsGateValue == 0f && !commanderGoingLowOrHighInPhase2) { - float moltenBlastVelocity = (bossRush || biomeEnraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + float moltenBlastVelocity = (bossRush || enraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; int projTimeLeft = (int)(2400f / moltenBlastVelocity); Vector2 velocity = Vector2.Normalize(player.Center - shootFrom) * moltenBlastVelocity; if (Main.netMode != NetmodeID.MultiplayerClient) @@ -627,7 +617,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.spriteDirection = Math.Sign(NPC.velocity.X); NPC.ai[1] += 1f; - float phaseGateValue = (bossRush || biomeEnraged) ? 120f : death ? 140f : revenge ? 150f : expertMode ? 160f : 180f; + float phaseGateValue = (bossRush || enraged) ? 120f : death ? 140f : revenge ? 150f : expertMode ? 160f : 180f; if (NPC.ai[1] >= phaseGateValue) { NPC.ai[0] = 3f; @@ -648,7 +638,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Accelerate if (NPC.velocity.Length() < maxChargeVelocity) { - float velocityMult = (bossRush || biomeEnraged) ? 1.04f : death ? 1.036667f : revenge ? 1.035f : expertMode ? 1.033333f : 1.03f; + float velocityMult = (bossRush || enraged) ? 1.04f : death ? 1.036667f : revenge ? 1.035f : expertMode ? 1.033333f : 1.03f; NPC.velocity = targetVector * (NPC.velocity.Length() * velocityMult); if (NPC.velocity.Length() > maxChargeVelocity) { @@ -660,7 +650,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians else { // Charge towards target - float inertia = (bossRush || biomeEnraged) ? 57f : death ? 63f : revenge ? 66f : expertMode ? 69f : 75f; + float inertia = (bossRush || enraged) ? 57f : death ? 63f : revenge ? 66f : expertMode ? 69f : 75f; NPC.velocity = (NPC.velocity * (inertia - 1f) + targetVector * (NPC.velocity.Length() + (0.111111117f * inertia))) / inertia; } @@ -773,10 +763,15 @@ namespace CalamityMod.NPCs.ProfanedGuardians texture2D15 = Texture_Glow.Value; Color timeBasedGlowColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); - if (Main.remixWorld) + if (NPC.Calamity().CurrentlyEnraged) { texture2D15 = TextureNight_Glow.Value; - timeBasedGlowColor = Color.Cyan; + timeBasedGlowColor = Color.Lerp(Color.White, Color.Cyan, 0.75f); + } + if (Main.zenithWorld) + { + texture2D15 = TextureNight_Glow.Value; + timeBasedGlowColor = Main.DiscoColor; } if (colorOverride != null) timeBasedGlowColor = colorOverride.Value; @@ -867,14 +862,14 @@ namespace CalamityMod.NPCs.ProfanedGuardians Vector2 shieldDrawPos = NPC.Center - screenPos; shieldDrawPos -= new Vector2(shieldTexture.Width, shieldTexture.Height) * NPC.scale / 2f; shieldDrawPos += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY); - float minHue = 0.06f; - float maxHue = 0.18f; + float minHue = NPC.Calamity().CurrentlyEnraged ? 0.4f : 0.06f; + float maxHue = minHue + 0.12f; float opacityScaleDuringShieldDespawn = (TimeForShieldDespawn - NPC.localAI[1]) / TimeForShieldDespawn; float scaleDuringShieldDespawnScale = 1.8f; float scaleDuringShieldDespawn = (1f - opacityScaleDuringShieldDespawn) * scaleDuringShieldDespawnScale; float colorScale = MathHelper.Lerp(0f, shieldOpacity, opacityScaleDuringShieldDespawn); - Color color = Main.hslToRgb(MathHelper.Lerp(maxHue - minHue, maxHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi) + 1f) * 0.5f), 1f, 0.5f) * colorScale; - Color color2 = Main.hslToRgb(MathHelper.Lerp(minHue, maxHue - minHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.Pi * 3f) + 1f) * 0.5f), 1f, 0.5f) * colorScale; + Color color = Main.hslToRgb(MathHelper.Lerp(NPC.Calamity().CurrentlyEnraged ? minHue : maxHue - minHue, maxHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi) + 1f) * 0.5f), 1f, 0.5f) * colorScale; + Color color2 = Main.hslToRgb(MathHelper.Lerp(minHue, NPC.Calamity().CurrentlyEnraged ? maxHue : maxHue - minHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.Pi * 3f) + 1f) * 0.5f), 1f, 0.5f) * colorScale; color2.A = 0; color *= 0.6f; color2 *= 0.6f; diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs b/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs index cfc275078d..03ed34ed59 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs @@ -39,7 +39,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians set => NPC.ai[3] = value; } - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; public static Asset Texture_Glow; public static Asset Texture_Glow2; @@ -116,13 +115,11 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override void SendExtraAI(BinaryWriter writer) { - writer.Write(biomeEnrageTimer); writer.Write(NPC.localAI[0]); } public override void ReceiveExtraAI(BinaryReader reader) { - biomeEnrageTimer = reader.ReadInt32(); NPC.localAI[0] = reader.ReadSingle(); } @@ -172,8 +169,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians bool expertMode = Main.expertMode || bossRush; bool revenge = CalamityWorld.revenge || bossRush; bool death = CalamityWorld.death || bossRush; - bool isHoly = player.ZoneHallow; - bool isHell = player.ZoneUnderworldHeight; // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; @@ -183,18 +178,13 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (NPC.ai[0] >= 300f) NPC.ai[1] = 1f; - // Become immune over time if target isn't in hell or hallow - if (!isHoly && !isHell && !BossRushEvent.BossRushActive) + // Enrage at nighttime + bool enraged = false; + if (!Main.dayTime && !Main.remixWorld) { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - else - NPC.Calamity().CurrentlyEnraged = true; + enraged = true; + NPC.Calamity().CurrentlyEnraged = true; } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - - bool biomeEnraged = biomeEnrageTimer <= 0; // Direction if (Math.Abs(NPC.Center.X - player.Center.X) > 10f) @@ -235,7 +225,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians } bool useCrystalShards = AIState == (float)Phase.CrystalShards; - float velocity = useCrystalShards ? ((bossRush || biomeEnraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f) : (Main.npc[CalamityGlobalNPC.doughnutBoss].velocity.Length() + 5f); + float velocity = useCrystalShards ? ((bossRush || enraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f) : (Main.npc[CalamityGlobalNPC.doughnutBoss].velocity.Length() + 5f); if (Main.getGoodWorld) velocity *= 1.25f; @@ -323,7 +313,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians { int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - int totalProjectiles = biomeEnraged ? 18 : death ? 16 : revenge ? 14 : expertMode ? 12 : 10; + int totalProjectiles = (bossRush || enraged) ? 18 : death ? 16 : revenge ? 14 : expertMode ? 12 : 10; float speedX = -12f; float speedAdjustment = Math.Abs(speedX * 2f / (totalProjectiles - 1)); float speedY = -4f; @@ -362,7 +352,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians { SoundEngine.PlaySound(SoundID.DD2_BetsyFireballImpact, shootFrom); - int totalFlameProjectiles = biomeEnraged ? 20 : 16; + int totalFlameProjectiles = (bossRush || enraged) ? 20 : 16; int totalRings = revenge ? 3 : 2; int healingStarChance = revenge ? 8 : expertMode ? 6 : 4; double radians = MathHelper.TwoPi / totalFlameProjectiles; @@ -380,7 +370,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians int type = ModContent.ProjectileType(); int dmgAmt = NPC.GetProjectileDamage(type); - if (Main.rand.NextBool(healingStarChance) && !death) + if (Main.rand.NextBool(healingStarChance) && !enraged && !death) { type = ModContent.ProjectileType(); dmgAmt = NPC.GetProjectileDamageNoScaling(type); @@ -423,7 +413,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Move towards a location above the player if (distanceFromDestination.Length() > idealDistanceFromDestination) { - float inertia = (bossRush || biomeEnraged) ? 28f : death ? 32f : revenge ? 34f : expertMode ? 36f : 40f; + float inertia = (bossRush || enraged) ? 28f : death ? 32f : revenge ? 34f : expertMode ? 36f : 40f; if (lifeRatio < 0.5f) inertia *= 0.8f; if (Main.getGoodWorld) @@ -478,10 +468,15 @@ namespace CalamityMod.NPCs.ProfanedGuardians texture2D15 = Texture_Glow.Value; Color timeBasedDrawColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); - if (Main.remixWorld) + if (NPC.Calamity().CurrentlyEnraged) { texture2D15 = TextureNight_Glow.Value; - timeBasedDrawColor = Color.Cyan; + timeBasedDrawColor = Color.Lerp(Color.White, Color.Cyan, 0.75f); + } + if (Main.zenithWorld) + { + texture2D15 = TextureNight_Glow.Value; + timeBasedDrawColor = Main.DiscoColor; } Color overrideColor = Color.Lerp(Color.White, Color.Violet, 0.5f); if (colorOverride != null) diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 7f0bbfabc3..aeb2b7d136 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -366,7 +366,7 @@ namespace CalamityMod.NPCs.Providence colorShiftTimer = 0; } } - else if (!Main.IsItDay() || bossRush) //Normal Night time activity + else if ((!Main.dayTime && !Main.remixWorld) || bossRush) //Normal Night time activity NPC.localAI[1] = (float)BossMode.Night; else NPC.localAI[1] = (float)BossMode.Day; diff --git a/NPCs/SlimeGod/CrimulanPaladin.cs b/NPCs/SlimeGod/CrimulanPaladin.cs index 2efc4de6b7..8d7147dc4d 100644 --- a/NPCs/SlimeGod/CrimulanPaladin.cs +++ b/NPCs/SlimeGod/CrimulanPaladin.cs @@ -105,22 +105,25 @@ namespace CalamityMod.NPCs.SlimeGod Player player = Main.player[NPC.target]; - if (NPC.ai[0] != 3f && (player.dead || !player.active)) + if (NPC.ai[0] != 3f) { - NPC.TargetClosest(); - player = Main.player[NPC.target]; if (player.dead || !player.active) { - NPC.ai[0] = 3f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - NPC.netUpdate = true; + NPC.TargetClosest(); + player = Main.player[NPC.target]; + if (player.dead || !player.active) + { + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + NPC.netUpdate = true; + } } + else if (NPC.timeLeft < 1800) + NPC.timeLeft = 1800; } - else if (NPC.timeLeft < 1800) - NPC.timeLeft = 1800; if (lifeRatio <= 0.5f && Main.netMode != NetmodeID.MultiplayerClient && expertMode) { @@ -562,6 +565,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.netUpdate = true; } } + + // Despawn else if (NPC.ai[0] == 3f) { // Avoid cheap bullshit @@ -578,6 +583,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.98f; } + else if (NPC.ai[0] == 4f) { // Avoid cheap bullshit @@ -736,8 +742,6 @@ namespace CalamityMod.NPCs.SlimeGod return newColor * NPC.Opacity; } - public override bool CheckActive() => false; - public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Crimson; diff --git a/NPCs/SlimeGod/EbonianPaladin.cs b/NPCs/SlimeGod/EbonianPaladin.cs index f8c225f0cb..fe2ae3f8a7 100644 --- a/NPCs/SlimeGod/EbonianPaladin.cs +++ b/NPCs/SlimeGod/EbonianPaladin.cs @@ -102,22 +102,25 @@ namespace CalamityMod.NPCs.SlimeGod Player player = Main.player[NPC.target]; - if (NPC.ai[0] != 4f && (player.dead || !player.active)) + if (NPC.ai[0] != 4f) { - NPC.TargetClosest(); - player = Main.player[NPC.target]; if (player.dead || !player.active) { - NPC.ai[0] = 4f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - NPC.netUpdate = true; + NPC.TargetClosest(); + player = Main.player[NPC.target]; + if (player.dead || !player.active) + { + NPC.ai[0] = 4f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + NPC.netUpdate = true; + } } + else if (NPC.timeLeft < 1800) + NPC.timeLeft = 1800; } - else if (NPC.timeLeft < 1800) - NPC.timeLeft = 1800; if (lifeRatio <= 0.5f && Main.netMode != NetmodeID.MultiplayerClient && expertMode) { @@ -606,6 +609,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.netUpdate = true; } } + + // Despawn else if (NPC.ai[0] == 4f) { // Avoid cheap bullshit @@ -622,6 +627,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.98f; } + else if (NPC.ai[0] == 5f) { // Set damage @@ -781,8 +787,6 @@ namespace CalamityMod.NPCs.SlimeGod return newColor * NPC.Opacity; } - public override bool CheckActive() => false; - public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Lavender; diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index c0bdd4c2f6..d2f4e0bb7c 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -100,6 +100,7 @@ namespace CalamityMod.NPCs.SlimeGod public override void SendExtraAI(BinaryWriter writer) { + writer.Write(slimesSpawned); writer.Write(buffedSlime); writer.Write(NPC.Opacity); for (int i = 0; i < 4; i++) @@ -108,6 +109,7 @@ namespace CalamityMod.NPCs.SlimeGod public override void ReceiveExtraAI(BinaryReader reader) { + slimesSpawned = reader.ReadBoolean(); buffedSlime = reader.ReadInt32(); NPC.Opacity = reader.ReadSingle(); for (int i = 0; i < 4; i++) @@ -135,11 +137,14 @@ namespace CalamityMod.NPCs.SlimeGod Player player = Main.player[NPC.target]; - if (Main.netMode != NetmodeID.MultiplayerClient && !slimesSpawned) + if (!slimesSpawned) { slimesSpawned = true; - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType()); - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType()); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType()); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType()); + } } // Enrage based on large slimes @@ -158,6 +163,9 @@ namespace CalamityMod.NPCs.SlimeGod calamityGlobalNPC.newAI[0] = Main.npc[CalamityGlobalNPC.slimeGodPurple].Center.X; calamityGlobalNPC.newAI[1] = Main.npc[CalamityGlobalNPC.slimeGodPurple].Center.Y; + // Despawn check + calamityGlobalNPC.newAI[3] = Main.npc[CalamityGlobalNPC.slimeGodPurple].ai[0] == 4f ? 1f : 0f; + purpleSlimeAlive = true; } } @@ -173,6 +181,9 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[1] = Main.npc[CalamityGlobalNPC.slimeGodRed].Center.X; NPC.ai[2] = Main.npc[CalamityGlobalNPC.slimeGodRed].Center.Y; + + // Despawn check + calamityGlobalNPC.newAI[3] = Main.npc[CalamityGlobalNPC.slimeGodRed].ai[0] == 3f ? 1f : 0f; redSlimeAlive = true; } @@ -182,7 +193,7 @@ namespace CalamityMod.NPCs.SlimeGod bool phase2 = !purpleSlimeAlive || !redSlimeAlive; // Vanish phase - if (!purpleSlimeAlive && !redSlimeAlive) + if ((!purpleSlimeAlive && !redSlimeAlive) || calamityGlobalNPC.newAI[3] == 1f || NPC.ai[3] == 1f) { // Avoid cheap bullshit NPC.damage = 0; @@ -251,24 +262,42 @@ namespace CalamityMod.NPCs.SlimeGod Main.dust[slimyDust2].velocity *= 2f; } - // Let the player know that the Slime God isn't dead fr - if (!DownedBossSystem.downedSlimeGod) + if (calamityGlobalNPC.newAI[3] != 1f) { - string key = "Mods.CalamityMod.Status.Boss.SlimeGodRun"; - Color messageColor = Color.Magenta; + // Let the player know that the Slime God isn't dead fr + if (!DownedBossSystem.downedSlimeGod) + { + string key = "Mods.CalamityMod.Status.Boss.SlimeGodRun"; + Color messageColor = Color.Magenta; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + + // Set Slime God to have interacted with all players + for (int i = Main.maxPlayers - 1; i >= 0; i--) + NPC.ApplyInteraction(i); + + NPC.active = false; + NPC.HitEffect(); + NPC.NPCLoot(); + NPC.netUpdate = true; } - - // Set Slime God to have interacted with all players - for (int i = Main.maxPlayers - 1; i >= 0; i--) + else { - NPC.ApplyInteraction(i); + for (int x = 0; x < Main.maxNPCs; x++) + { + if (Main.npc[x].type == ModContent.NPCType() || Main.npc[x].type == ModContent.NPCType() || + Main.npc[x].type == ModContent.NPCType() || Main.npc[x].type == ModContent.NPCType()) + { + Main.npc[x].active = false; + Main.npc[x].netUpdate = true; + } + } + + NPC.active = false; + NPC.HitEffect(); + NPC.netUpdate = true; } - NPC.active = false; - NPC.HitEffect(); - NPC.NPCLoot(); - NPC.netUpdate = true; } return; diff --git a/NPCs/SlimeGod/SplitCrimulanPaladin.cs b/NPCs/SlimeGod/SplitCrimulanPaladin.cs index d00c921ae9..a51706798a 100644 --- a/NPCs/SlimeGod/SplitCrimulanPaladin.cs +++ b/NPCs/SlimeGod/SplitCrimulanPaladin.cs @@ -120,21 +120,24 @@ namespace CalamityMod.NPCs.SlimeGod Player player = Main.player[NPC.target]; - if (NPC.ai[0] != 3f && (player.dead || !player.active)) + if (NPC.ai[0] != 3f) { - NPC.TargetClosest(); - player = Main.player[NPC.target]; if (player.dead || !player.active) { - NPC.ai[0] = 3f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - NPC.netUpdate = true; + NPC.TargetClosest(); + player = Main.player[NPC.target]; + if (player.dead || !player.active) + { + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } } + else if (NPC.timeLeft < 1800) + NPC.timeLeft = 1800; } - else if (NPC.timeLeft < 1800) - NPC.timeLeft = 1800; bool enraged = true; if (CalamityGlobalNPC.slimeGodPurple != -1) @@ -544,6 +547,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.netUpdate = true; } } + + // Despawn else if (NPC.ai[0] == 3f) { // Avoid cheap bullshit @@ -560,6 +565,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.98f; } + else if (NPC.ai[0] == 4f) { // Set damage @@ -730,8 +736,6 @@ namespace CalamityMod.NPCs.SlimeGod npcLoot.Add(ItemID.Gel, 1, 32, 48); } - public override bool CheckActive() => false; - public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Crimson; diff --git a/NPCs/SlimeGod/SplitEbonianPaladin.cs b/NPCs/SlimeGod/SplitEbonianPaladin.cs index 91036c6d16..fad784a39e 100644 --- a/NPCs/SlimeGod/SplitEbonianPaladin.cs +++ b/NPCs/SlimeGod/SplitEbonianPaladin.cs @@ -120,21 +120,24 @@ namespace CalamityMod.NPCs.SlimeGod Player player = Main.player[NPC.target]; - if (NPC.ai[0] != 4f && (player.dead || !player.active)) + if (NPC.ai[0] != 4f) { - NPC.TargetClosest(); - player = Main.player[NPC.target]; if (player.dead || !player.active) { - NPC.ai[0] = 4f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - NPC.netUpdate = true; + NPC.TargetClosest(); + player = Main.player[NPC.target]; + if (player.dead || !player.active) + { + NPC.ai[0] = 4f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } } + else if (NPC.timeLeft < 1800) + NPC.timeLeft = 1800; } - else if (NPC.timeLeft < 1800) - NPC.timeLeft = 1800; bool enraged = true; bool hyperMode = NPC.localAI[1] == 1f; @@ -591,6 +594,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.netUpdate = true; } } + + // Despawn else if (NPC.ai[0] == 4f) { // Avoid cheap bullshit @@ -607,6 +612,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.98f; } + else if (NPC.ai[0] == 5f) { // Set damage @@ -774,8 +780,6 @@ namespace CalamityMod.NPCs.SlimeGod npcLoot.Add(ItemID.Gel, 1, 32, 48); } - public override bool CheckActive() => false; - public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Lavender; diff --git a/NPCs/TownNPCs/FAP.cs b/NPCs/TownNPCs/FAP.cs index 24b57edf9b..df48e4ee91 100644 --- a/NPCs/TownNPCs/FAP.cs +++ b/NPCs/TownNPCs/FAP.cs @@ -822,6 +822,9 @@ namespace CalamityMod.NPCs.TownNPCs public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { + if (Main.LocalPlayer.Calamity().trippy) + return false; + var something = NPC.direction == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; spriteBatch.Draw(BirthdayParty.PartyIsUp ? AltTexture.Value : TextureAssets.Npc[NPC.type].Value, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY) - new Vector2(0f, 6f), NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, something, 0); return false; @@ -882,42 +885,49 @@ namespace CalamityMod.NPCs.TownNPCs public override void AddShops() { - Condition potionSells = CalamityConditions.PotionSellingConfig; - Condition downedAureus = CalamityConditions.DownedAstrumAureus; + Mod musicMod = CalamityMod.Instance.musicMod; + musicMod.TryFind("Interlude1MusicBox", out ModItem interlude1Box); + musicMod.TryFind("Interlude2MusicBox", out ModItem interlude2Box); + musicMod.TryFind("Interlude3MusicBox", out ModItem interlude3Box); + musicMod.TryFind("DevourerofGodsEulogyMusicBox", out ModItem eulogyBox); NPCShop shop = new(Type); - shop.AddWithCustomValue(ItemID.LovePotion, Item.buyPrice(silver: 25), potionSells, Condition.HappyEnough) + shop.AddWithCustomValue(ItemID.LovePotion, Item.buyPrice(silver: 25), CalamityConditions.PotionSellingConfig, Condition.HappyEnough) .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(silver: 30)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 1)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 2)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 2)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 2)) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 3)) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 3)) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 3)) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 3)) .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 3)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 4)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 2), Condition.DownedMechBossAll) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 6), Condition.DownedMechBossAll) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 6), Condition.DownedMechBossAll) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), Condition.DownedPlantera) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), Condition.DownedPlantera) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), Condition.DownedPlantera) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), Condition.DownedPlantera) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 3)) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 4), Condition.DownedMechBossAll) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 4), Condition.DownedMechBossAll) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 4), Condition.DownedMechBossAll) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 6), Condition.DownedPlantera) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 6), Condition.DownedPlantera) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 6), Condition.DownedPlantera) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 6), Condition.DownedPlantera) .AddWithCustomValue(ItemID.EmpressButterfly, Item.buyPrice(gold: 10), Condition.DownedPlantera) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 3), downedAureus) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 4), downedAureus, Condition.BloodMoon) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 6), downedAureus, Condition.TimeNight) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 2), Condition.DownedGolem) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), Condition.DownedGolem) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), Condition.DownedGolem) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), CalamityConditions.DownedAstrumAureus) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), CalamityConditions.DownedAstrumAureus, Condition.BloodMoon) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 8), CalamityConditions.DownedAstrumAureus, Condition.TimeNight) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 10), Condition.DownedGolem) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 10), Condition.DownedGolem) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 10), Condition.DownedGolem) .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 10), Condition.DownedGolem) .AddWithCustomValue(ItemID.BloodyMoscato, Item.buyPrice(gold: 1), Condition.DownedMoonLord, Condition.NpcIsPresent(NPCID.Stylist)) .AddWithCustomValue(ItemID.BananaDaiquiri, Item.buyPrice(silver: 75), Condition.DownedMoonLord, Condition.NpcIsPresent(NPCID.Stylist)) .AddWithCustomValue(ItemID.PeachSangria, Item.buyPrice(silver: 50), Condition.DownedMoonLord, Condition.NpcIsPresent(NPCID.Stylist)) .AddWithCustomValue(ItemID.PinaColada, Item.buyPrice(gold: 1), Condition.DownedMoonLord, Condition.NpcIsPresent(NPCID.Stylist)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 50)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 50)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 50)) - .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 50)) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(2)) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(2)) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(2)) + .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(2)) .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(1)) + .AddWithCustomValue(interlude1Box.Type, Item.buyPrice(gold: 10), CalamityConditions.DownedCalamitasClone) + .AddWithCustomValue(interlude2Box.Type, Item.buyPrice(gold: 10), Condition.DownedMoonLord) + .AddWithCustomValue(interlude3Box.Type, Item.buyPrice(gold: 10), CalamityConditions.DownedYharon) + .AddWithCustomValue(eulogyBox.Type, Item.buyPrice(gold: 10), CalamityConditions.DownedDevourerOfGods) .AddWithCustomValue(ItemID.UnicornHorn, Item.buyPrice(0, 2, 50), Condition.HappyEnough, Condition.InHallow) .AddWithCustomValue(ItemID.Milkshake, Item.buyPrice(gold: 5), Condition.HappyEnough, Condition.InHallow, Condition.NpcIsPresent(NPCID.Stylist)) .AddWithCustomValue(ModContent.ItemType(), Item.buyPrice(gold: 25), Condition.HappyEnough, Condition.NpcIsPresent(NPCID.Stylist), Condition.NpcIsPresent(NPCID.BestiaryGirl)) diff --git a/NPCs/TownNPCs/THIEF.cs b/NPCs/TownNPCs/THIEF.cs index c9ea97d8d4..ff591a3aea 100644 --- a/NPCs/TownNPCs/THIEF.cs +++ b/NPCs/TownNPCs/THIEF.cs @@ -103,12 +103,12 @@ namespace CalamityMod.NPCs.TownNPCs public override List SetNPCNameList() => new List() { // Patron names - "Xplizzy", // <@!98826096237109248> (Whitegiraffe#6342) - "Freakish", // <@!750363283520749598> (Freakish#0001) + "Xplizzy", // <@!98826096237109248> (whitegiraffe) + "Freakish", // <@!750363283520749598> (freak5650) "Calder", // <@!601897959176798228> (hardlightcaster) - "Hunter Jinx", // <@!757401399783850134> (Jinx_enthusiast#1580) - "Goose", // <@!591421917706321962> (DullElili#8016) - "Jackson", // <@!525827730646892549> (ChowChow, Sin of Sleep Schedules#1235) + "Hunter Jinx", // <@!757401399783850134> (dragonslayerornstein.) + "Goose", // <@!591421917706321962> (dullelili) + "Jackson", // <@!525827730646892549> (chowchow360) "Altarca", // <@!1140673052108128337> (altarca_27226_49175) "Jackie", // <@!353241811717718016> (jackalchan) @@ -244,6 +244,9 @@ namespace CalamityMod.NPCs.TownNPCs public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { + if (Main.LocalPlayer.Calamity().trippy) + return false; + var something = NPC.direction == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; spriteBatch.Draw(BirthdayParty.PartyIsUp ? AltTexture.Value : TextureAssets.Npc[NPC.type].Value, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY) - new Vector2(0f, 6f), NPC.frame, drawColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, something, 0); return false; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs index ebfd7f20ae..e8c7ecd7a2 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs @@ -29,10 +29,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - bool enrage = true; int targetTileX = (int)Main.player[npc.target].Center.X / 16; int targetTileY = (int)Main.player[npc.target].Center.Y / 16; @@ -517,7 +513,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -879,11 +874,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - float enrageScale = bossRush ? 1.5f : masterMode ? 0.5f : 0f; - if ((npc.position.Y / 16f) < Main.worldSurface || bossRush) + float enrageScaleMax = 2f; + float enrageScale = bossRush ? enrageScaleMax : masterMode ? 0.5f : 0f; + if ((npc.position.Y / 16f) < Main.worldSurface) enrageScale += 0.5f; - if (!Main.player[npc.target].ZoneCrimson || bossRush) - enrageScale += 2f; + if (!Main.player[npc.target].ZoneCrimson) + enrageScale += 1f; + + if (enrageScale > enrageScaleMax) + enrageScale = enrageScaleMax; bool brainIsNotTeleportingOrCharging = Main.npc[NPC.crimsonBoss].ai[0] == 0f || Main.npc[NPC.crimsonBoss].ai[0] == -1f || Main.npc[NPC.crimsonBoss].ai[0] == -6f; bool brainIsInPhase2 = Main.npc[NPC.crimsonBoss].ai[0] < 0f; @@ -906,7 +905,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses creeperRatio = creeperCount / (float)GetBrainOfCthuluCreepersCountRevDeath(); // Scale the aggressiveness of the charges with amount of Creepers remaining - float chargeAggressionScale = creeperRatio <= 0.1f ? 3.5f : creeperRatio <= 0.2f ? 2.5f : creeperRatio <= 0.4f ? 1.75f : creeperRatio <= 0.6f ? 1f : creeperRatio <= 0.8f ? 0.5f : 0f; + float chargeAggressionScale = creeperRatio <= 0.1f ? 1.75f : creeperRatio <= 0.2f ? 1.25f : creeperRatio <= 0.4f ? 0.875f : creeperRatio <= 0.6f ? 0.5f : creeperRatio <= 0.8f ? 0.25f : 0f; + if (enrageScale > 0f) + chargeAggressionScale *= 1f + enrageScale; if (death) chargeAggressionScale *= 1.25f; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs index cc7f023757..c3fe7ce175 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs @@ -96,23 +96,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses idleTime = 20; } - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(false); - // Center and target Player player = Main.player[npc.target]; - if (npc.target < 0 || npc.target == Main.maxPlayers || player.dead || !player.active) + if (npc.target < 0 || npc.target == Main.maxPlayers || player.dead || !player.active || Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) { npc.TargetClosest(false); player = Main.player[npc.target]; npc.netUpdate = true; } - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(false); - // Enrage if (!Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height) || CalamityWorld.LegendaryMode) { @@ -157,6 +149,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[3] += 1f; npc.velocity = Vector2.Zero; + npc.TargetClosest(false); npc.netUpdate = true; if (Main.netMode != NetmodeID.MultiplayerClient) @@ -170,7 +163,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Despawn - if (player.dead || Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) + if (player.dead || !player.active || Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) { npc.life = 0; npc.HitEffect(0, 10.0); @@ -803,6 +796,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[3] += 1f; npc.velocity = Vector2.Zero; + npc.TargetClosest(false); npc.netUpdate = true; } } @@ -1309,6 +1303,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[3] += 1f; npc.velocity = Vector2.Zero; + npc.TargetClosest(false); npc.netUpdate = true; List list = new List(); for (int i = 0; i < Main.maxNPCs; i++) @@ -2030,6 +2025,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[3] += 1f; npc.velocity = Vector2.Zero; + npc.TargetClosest(false); npc.netUpdate = true; } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs index 7582745b63..1308fee41f 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs @@ -92,10 +92,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Return to ground phase, with less time spent in later phases if (calamityGlobalNPC.newAI[3] >= FlightPhaseResetGateValue) - { calamityGlobalNPC.newAI[3] = flightPhaseTimerSetValue; - npc.TargetClosest(); - } // Spawn DR check bool hasSpawnDR = calamityGlobalNPC.newAI[1] < DRIncreaseTime && calamityGlobalNPC.newAI[1] > 60f; @@ -124,10 +121,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool increaseSpeed = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles; bool increaseSpeedMore = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; - // Get a new target if current target is too far away - if (increaseSpeedMore && npc.type == NPCID.TheDestroyer) - npc.TargetClosest(); - float enrageScale = bossRush ? 1f : 0f; if (Main.IsItDay() || bossRush) { @@ -343,85 +336,88 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - if (Main.netMode != NetmodeID.MultiplayerClient) + if (npc.type == NPCID.TheDestroyer) { - if (npc.type == NPCID.TheDestroyer) + // Spawn segments from head + if (npc.ai[0] == 0f) { - // Spawn segments from head - if (npc.ai[0] == 0f) + npc.ai[3] = npc.whoAmI; + npc.realLife = npc.whoAmI; + int index = npc.whoAmI; + for (int j = 0; j <= totalSegments; j++) { - npc.ai[3] = npc.whoAmI; - npc.realLife = npc.whoAmI; - int index = npc.whoAmI; - for (int j = 0; j <= totalSegments; j++) - { - int type = NPCID.TheDestroyerBody; - if (j == totalSegments) - type = NPCID.TheDestroyerTail; + int type = NPCID.TheDestroyerBody; + if (j == totalSegments) + type = NPCID.TheDestroyerTail; - int segment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)(npc.position.Y + npc.height), type, npc.whoAmI); - Main.npc[segment].ai[3] = npc.whoAmI; - Main.npc[segment].realLife = npc.whoAmI; - Main.npc[segment].ai[1] = index; - Main.npc[index].ai[0] = segment; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segment); - index = segment; - } + int segment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)(npc.position.Y + npc.height), type, npc.whoAmI); + Main.npc[segment].ai[3] = npc.whoAmI; + Main.npc[segment].realLife = npc.whoAmI; + Main.npc[segment].ai[1] = index; + Main.npc[index].ai[0] = segment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segment); + index = segment; + } + } + + // Laser breath in Death Mode + if (spitLaserSpreads) + { + // Set laser color and type + if (calamityGlobalNPC.destroyerLaserColor == -1) + { + calamityGlobalNPC.destroyerLaserColor = phase3 ? 3 : phase2 ? 2 : 1; + npc.SyncDestroyerLaserColor(); } - // Laser breath in Death Mode - if (spitLaserSpreads) + float laserBreathGateValue = DeathModeLaserBreathGateValue; + if (calamityGlobalNPC.newAI[0] < laserBreathGateValue) + calamityGlobalNPC.newAI[0] += 1f; + + if (Main.netMode != NetmodeID.MultiplayerClient) { - // Set laser color and type - if (calamityGlobalNPC.destroyerLaserColor == -1) - { - calamityGlobalNPC.destroyerLaserColor = phase3 ? 3 : phase2 ? 2 : 1; - npc.SyncDestroyerLaserColor(); - } - - float laserBreathGateValue = DeathModeLaserBreathGateValue; - if (calamityGlobalNPC.newAI[0] < laserBreathGateValue) - calamityGlobalNPC.newAI[0] += 1f; - // Sync newAI every 20 frames for the new telegraph - if (calamityGlobalNPC.newAI[0] % 20f == 0f) + if (calamityGlobalNPC.newAI[0] % 20f == 10f) npc.SyncExtraAI(); + } - if ((player.Center - npc.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(npc.velocity.ToRotation(), MathHelper.PiOver4) == npc.velocity.ToRotation() && - calamityGlobalNPC.newAI[0] >= laserBreathGateValue && Vector2.Distance(npc.Center, player.Center) > 480f && - Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + if ((player.Center - npc.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(npc.velocity.ToRotation(), MathHelper.PiOver4) == npc.velocity.ToRotation() && + calamityGlobalNPC.newAI[0] >= laserBreathGateValue && Vector2.Distance(npc.Center, player.Center) > 480f && + Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + { + if (calamityGlobalNPC.newAI[0] % 30f == 0f) { - if (calamityGlobalNPC.newAI[0] % 30f == 0f) + float velocity = bossRush ? 6f : death ? 5.333f : 5f; + int type = ProjectileID.DeathLaser; + switch (calamityGlobalNPC.destroyerLaserColor) { - float velocity = bossRush ? 6f : death ? 5.333f : 5f; - int type = ProjectileID.DeathLaser; - switch (calamityGlobalNPC.destroyerLaserColor) - { - default: - case 0: - break; + default: + case 0: + break; - case 1: - type = ModContent.ProjectileType(); - break; + case 1: + type = ModContent.ProjectileType(); + break; - case 2: - type = ModContent.ProjectileType(); - break; - } - int damage = npc.GetProjectileDamage(type); + case 2: + type = ModContent.ProjectileType(); + break; + } + int damage = npc.GetProjectileDamage(type); - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - double firstMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert; - double secondMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert; - if (!NPC.downedMechBossAny) - damage = (int)(damage * firstMechMultiplier); - else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) - damage = (int)(damage * secondMechMultiplier); - } + // Reduce mech boss projectile damage depending on the new ore progression changes + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) + { + double firstMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert; + double secondMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert; + if (!NPC.downedMechBossAny) + damage = (int)(damage * firstMechMultiplier); + else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) + damage = (int)(damage * secondMechMultiplier); + } + if (Main.netMode != NetmodeID.MultiplayerClient) + { Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; int numProj = calamityGlobalNPC.newAI[0] % 60f == 0f ? (masterMode ? 9 : 7) : (masterMode ? 6 : 4); int spread = masterMode ? 38 : 26; @@ -433,111 +429,132 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Main.projectile[proj].timeLeft = 1200; } } + } - calamityGlobalNPC.newAI[0] += 1f; - if (calamityGlobalNPC.newAI[0] > laserBreathGateValue + 60f) - { - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.destroyerLaserColor = -1; - npc.SyncDestroyerLaserColor(); - npc.SyncExtraAI(); - } + calamityGlobalNPC.newAI[0] += 1f; + if (calamityGlobalNPC.newAI[0] > laserBreathGateValue + 60f) + { + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.destroyerLaserColor = -1; + npc.SyncDestroyerLaserColor(); + npc.SyncExtraAI(); } } } + } - // Fire lasers - if (npc.type == NPCID.TheDestroyerBody) + // Fire lasers + if (npc.type == NPCID.TheDestroyerBody) + { + bool ableToFireLaser = calamityGlobalNPC.destroyerLaserColor != -1; + + // Set laser color and type + if (calamityGlobalNPC.destroyerLaserColor == -1 && !probeLaunched) { - bool ableToFireLaser = calamityGlobalNPC.destroyerLaserColor != -1; - - // Set laser color and type - if (calamityGlobalNPC.destroyerLaserColor == -1 && !probeLaunched) + if (Main.rand.NextBool(masterMode ? OneInXChanceToFireLaser / (phase5 ? 4 : phase4 ? 3 : 2) : OneInXChanceToFireLaser)) { - if (Main.rand.NextBool(masterMode ? OneInXChanceToFireLaser / (phase5 ? 4 : phase4 ? 3 : 2) : OneInXChanceToFireLaser)) + int random = phase3 ? 4 : phase2 ? 3 : 2; + switch (Main.rand.Next(random)) { - int random = phase3 ? 4 : phase2 ? 3 : 2; - switch (Main.rand.Next(random)) - { - case 0: - case 1: - calamityGlobalNPC.destroyerLaserColor = 0; - break; - case 2: - calamityGlobalNPC.destroyerLaserColor = 1; - break; - case 3: - calamityGlobalNPC.destroyerLaserColor = 2; - break; - } - - if (calamityGlobalNPC.newAI[2] > 0f || bossRush) + case 0: + case 1: + calamityGlobalNPC.destroyerLaserColor = 0; + break; + case 2: + calamityGlobalNPC.destroyerLaserColor = 1; + break; + case 3: calamityGlobalNPC.destroyerLaserColor = 2; - - npc.SyncDestroyerLaserColor(); + break; } - } - if (probeLaunched && ableToFireLaser) - { - calamityGlobalNPC.destroyerLaserColor = -1; + if (calamityGlobalNPC.newAI[2] > 0f || bossRush) + calamityGlobalNPC.destroyerLaserColor = 2; + npc.SyncDestroyerLaserColor(); } + } - // Laser rate of fire - float shootProjectileTime = death ? (masterMode ? (phase5 ? 120f : phase4 ? 150f : 180f) : 270f) : (masterMode ? (phase5 ? 150f : phase4 ? 210f : 270f) : 450f); - float bodySegmentTime = npc.ai[0] * (masterMode ? 20f : 30f); - float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; - float laserTimerIncrement = (calamityGlobalNPC.newAI[0] > shootProjectileGateValue - LaserTelegraphTime) ? 1f : 2f; - if (ableToFireLaser) - calamityGlobalNPC.newAI[0] += laserTimerIncrement; + if (probeLaunched && ableToFireLaser) + { + calamityGlobalNPC.destroyerLaserColor = -1; + npc.SyncDestroyerLaserColor(); + } + // Laser rate of fire + float shootProjectileTime = death ? (masterMode ? (phase5 ? 120f : phase4 ? 150f : 180f) : 270f) : (masterMode ? (phase5 ? 150f : phase4 ? 210f : 270f) : 450f); + float bodySegmentTime = npc.ai[0] * (masterMode ? 20f : 30f); + float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; + float laserTimerIncrement = (calamityGlobalNPC.newAI[0] > shootProjectileGateValue - LaserTelegraphTime) ? 1f : 2f; + if (ableToFireLaser) + calamityGlobalNPC.newAI[0] += laserTimerIncrement; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { // Sync newAI every 20 frames for the new telegraph - if (calamityGlobalNPC.newAI[0] % 20f == 0f && ableToFireLaser) + if (calamityGlobalNPC.newAI[0] % 20f == 10f && ableToFireLaser) npc.SyncExtraAI(); + } - Color telegraphColor = Color.Transparent; - switch (calamityGlobalNPC.destroyerLaserColor) + Color telegraphColor = Color.Transparent; + switch (calamityGlobalNPC.destroyerLaserColor) + { + case 0: + telegraphColor = Color.Red; + break; + case 1: + telegraphColor = Color.Green; + break; + case 2: + telegraphColor = Color.Cyan; + break; + } + + if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - LaserTelegraphTime) + { + Particle telegraph = new DestroyerReticleTelegraph( + npc, + telegraphColor, + 1.5f, + 0.15f, + (int)LaserTelegraphTime); + GeneralParticleHandler.SpawnParticle(telegraph); + } + + if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - SparkTelegraphTime) + { + Particle spark = new DestroyerSparkTelegraph( + npc, + telegraphColor * 2f, + Color.White, + 3f, + 30, + Main.rand.NextFloat(MathHelper.ToRadians(3f)) * Main.rand.NextBool().ToDirectionInt()); + GeneralParticleHandler.SpawnParticle(spark); + } + + // Shoot lasers + // Shoot nothing if probe has been launched + if (calamityGlobalNPC.newAI[0] >= shootProjectileGateValue && ableToFireLaser) + { + if (!masterMode) { - case 0: - telegraphColor = Color.Red; - break; - case 1: - telegraphColor = Color.Green; - break; - case 2: - telegraphColor = Color.Cyan; - break; + int numProbeSegments = 0; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == npc.type && Main.npc[i].ai[2] == 0f) + numProbeSegments++; + } + float lerpAmount = MathHelper.Clamp(numProbeSegments / (float)totalSegments, 0f, 1f); + float laserShootTimeBonus = (int)MathHelper.Lerp(0f, (shootProjectileTime + bodySegmentTime * lerpAmount) - LaserTelegraphTime, 1f - lerpAmount); + calamityGlobalNPC.newAI[0] = laserShootTimeBonus; + npc.SyncExtraAI(); + npc.TargetClosest(); } - if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - LaserTelegraphTime) + if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) { - Particle telegraph = new DestroyerReticleTelegraph( - npc, - telegraphColor, - 1.5f, - 0.15f, - (int)LaserTelegraphTime); - GeneralParticleHandler.SpawnParticle(telegraph); - } - - if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - SparkTelegraphTime) - { - Particle spark = new DestroyerSparkTelegraph( - npc, - telegraphColor * 2f, - Color.White, - 3f, - 30, - Main.rand.NextFloat(MathHelper.ToRadians(3f)) * Main.rand.NextBool().ToDirectionInt()); - GeneralParticleHandler.SpawnParticle(spark); - } - - // Shoot lasers - // Shoot nothing if probe has been launched - if (calamityGlobalNPC.newAI[0] >= shootProjectileGateValue && ableToFireLaser) - { - if (!masterMode) + if (masterMode) { int numProbeSegments = 0; for (int i = 0; i < Main.maxNPCs; i++) @@ -552,80 +569,65 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.TargetClosest(); } - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + // Laser speed + float projectileSpeed = (masterMode ? 4.5f : 3.5f) + Main.rand.NextFloat() * 1.5f; + projectileSpeed += enrageScale; + + // Set projectile damage and type + int projectileType = ProjectileID.DeathLaser; + switch (calamityGlobalNPC.destroyerLaserColor) { - if (masterMode) - { - int numProbeSegments = 0; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == npc.type && Main.npc[i].ai[2] == 0f) - numProbeSegments++; - } - float lerpAmount = MathHelper.Clamp(numProbeSegments / (float)totalSegments, 0f, 1f); - float laserShootTimeBonus = (int)MathHelper.Lerp(0f, (shootProjectileTime + bodySegmentTime * lerpAmount) - LaserTelegraphTime, 1f - lerpAmount); - calamityGlobalNPC.newAI[0] = laserShootTimeBonus; - npc.SyncExtraAI(); - npc.TargetClosest(); - } + default: + case 0: + break; - // Laser speed - float projectileSpeed = (masterMode ? 4.5f : 3.5f) + Main.rand.NextFloat() * 1.5f; - projectileSpeed += enrageScale; + case 1: + projectileType = ModContent.ProjectileType(); + break; - // Set projectile damage and type - int projectileType = ProjectileID.DeathLaser; - switch (calamityGlobalNPC.destroyerLaserColor) - { - default: - case 0: - break; - - case 1: - projectileType = ModContent.ProjectileType(); - break; - - case 2: - projectileType = ModContent.ProjectileType(); - break; - } - - // Get target vector - Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; - Vector2 projectileSpawn = npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 100f; - - // Shoot projectile - int damage = npc.GetProjectileDamage(projectileType); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - double firstMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert; - double secondMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert; - if (!NPC.downedMechBossAny) - damage = (int)(damage * firstMechMultiplier); - else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) - damage = (int)(damage * secondMechMultiplier); - } - - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, damage, 0f, Main.myPlayer, 1f, 0f); - Main.projectile[proj].timeLeft = 1200; - - npc.netUpdate = true; - - if (masterMode) - { - calamityGlobalNPC.destroyerLaserColor = -1; - npc.SyncDestroyerLaserColor(); - } + case 2: + projectileType = ModContent.ProjectileType(); + break; } - if (!masterMode) + // Get target vector + Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; + Vector2 projectileSpawn = npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 100f; + + // Shoot projectile + int damage = npc.GetProjectileDamage(projectileType); + + // Reduce mech boss projectile damage depending on the new ore progression changes + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) + { + double firstMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert; + double secondMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert; + if (!NPC.downedMechBossAny) + damage = (int)(damage * firstMechMultiplier); + else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) + damage = (int)(damage * secondMechMultiplier); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, damage, 0f, Main.myPlayer, 1f, 0f); + Main.projectile[proj].timeLeft = 1200; + } + + npc.netUpdate = true; + + if (masterMode) { calamityGlobalNPC.destroyerLaserColor = -1; npc.SyncDestroyerLaserColor(); } } + + if (!masterMode) + { + calamityGlobalNPC.destroyerLaserColor = -1; + npc.SyncDestroyerLaserColor(); + } } } @@ -714,82 +716,67 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.type != NPCID.TheDestroyerBody || !probeLaunched) { Vector3 lightColor = Color.Red.ToVector3(); - int x = (int)((npc.position.X - 8f) / 16f); - int x2 = (int)((npc.position.X + npc.width + 8f) / 16f); - int y = (int)((npc.position.Y - 8f) / 16f); - int y2 = (int)((npc.position.Y + npc.height + 8f) / 16f); - for (int l = x; l <= x2; l++) + + // Light colors + Vector3 groundColor = new Vector3(0.3f, 0.1f, 0.05f); + Vector3 flightColor = new Vector3(0.05f, 0.1f, 0.3f); + Vector3 segmentColor = Vector3.Lerp(groundColor, flightColor, phaseTransitionColorAmount); + Vector3 telegraphColor = groundColor; + + // Telegraph for the laser breath and body lasers + float telegraphProgress = 0f; + if (calamityGlobalNPC.destroyerLaserColor != -1) { - for (int m = y; m <= y2; m++) + if (npc.type == NPCID.TheDestroyer && spitLaserSpreads) { - if (Lighting.Brightness(l, m) == 0f) - lightColor = Color.Black.ToVector3(); + float telegraphGateValue = DeathModeLaserBreathGateValue - LaserTelegraphTime; + if (calamityGlobalNPC.newAI[0] > telegraphGateValue) + { + switch (calamityGlobalNPC.destroyerLaserColor) + { + default: + case 0: + break; + + case 1: + telegraphColor = new Vector3(0.1f, 0.3f, 0.05f); + break; + + case 2: + telegraphColor = new Vector3(0.05f, 0.2f, 0.2f); + break; + } + telegraphProgress = MathHelper.Clamp((calamityGlobalNPC.newAI[0] - telegraphGateValue) / LaserTelegraphTime, 0f, 1f); + } + } + else if (npc.type == NPCID.TheDestroyerBody) + { + float shootProjectileTime = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 270f : 450f; + float bodySegmentTime = npc.ai[0] * 30f; + float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; + float telegraphGateValue = shootProjectileGateValue - LaserTelegraphTime; + if (calamityGlobalNPC.newAI[0] > telegraphGateValue) + { + switch (calamityGlobalNPC.destroyerLaserColor) + { + default: + case 0: + break; + + case 1: + telegraphColor = new Vector3(0.1f, 0.3f, 0.05f); + break; + + case 2: + telegraphColor = new Vector3(0.05f, 0.2f, 0.2f); + break; + } + telegraphProgress = MathHelper.Clamp((calamityGlobalNPC.newAI[0] - telegraphGateValue) / LaserTelegraphTime, 0f, 1f); + } } } - if (lightColor != Color.Black.ToVector3()) - { - // Light colors - Vector3 groundColor = new Vector3(0.3f, 0.1f, 0.05f); - Vector3 flightColor = new Vector3(0.05f, 0.1f, 0.3f); - Vector3 segmentColor = Vector3.Lerp(groundColor, flightColor, phaseTransitionColorAmount); - Vector3 telegraphColor = groundColor; - - // Telegraph for the laser breath and body lasers - float telegraphProgress = 0f; - if (calamityGlobalNPC.destroyerLaserColor != -1) - { - if (npc.type == NPCID.TheDestroyer && spitLaserSpreads) - { - float telegraphGateValue = DeathModeLaserBreathGateValue - LaserTelegraphTime; - if (calamityGlobalNPC.newAI[0] > telegraphGateValue) - { - switch (calamityGlobalNPC.destroyerLaserColor) - { - default: - case 0: - break; - - case 1: - telegraphColor = new Vector3(0.1f, 0.3f, 0.05f); - break; - - case 2: - telegraphColor = new Vector3(0.05f, 0.2f, 0.2f); - break; - } - telegraphProgress = MathHelper.Clamp((calamityGlobalNPC.newAI[0] - telegraphGateValue) / LaserTelegraphTime, 0f, 1f); - } - } - else if (npc.type == NPCID.TheDestroyerBody) - { - float shootProjectileTime = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 270f : 450f; - float bodySegmentTime = npc.ai[0] * 30f; - float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; - float telegraphGateValue = shootProjectileGateValue - LaserTelegraphTime; - if (calamityGlobalNPC.newAI[0] > telegraphGateValue) - { - switch (calamityGlobalNPC.destroyerLaserColor) - { - default: - case 0: - break; - - case 1: - telegraphColor = new Vector3(0.1f, 0.3f, 0.05f); - break; - - case 2: - telegraphColor = new Vector3(0.05f, 0.2f, 0.2f); - break; - } - telegraphProgress = MathHelper.Clamp((calamityGlobalNPC.newAI[0] - telegraphGateValue) / LaserTelegraphTime, 0f, 1f); - } - } - } - - Lighting.AddLight(npc.Center, Vector3.Lerp(segmentColor, telegraphColor * 2f, telegraphProgress)); - } + Lighting.AddLight(npc.Center, Vector3.Lerp(segmentColor, telegraphColor * 2f, telegraphProgress)); } // Despawn @@ -1150,7 +1137,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] > 0f) npc.realLife = (int)npc.ai[3]; - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead) + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); if (npc.type >= NPCID.TheDestroyer && npc.type <= NPCID.TheDestroyerTail) @@ -1240,9 +1227,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (ableToFireLaser) npc.localAI[0] += laserTimerIncrement; - // Sync newAI every 20 frames for the new telegraph - if (npc.localAI[0] % 20f == 0f && ableToFireLaser) - npc.SyncVanillaLocalAI(); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Sync newAI every 20 frames for the new telegraph + if (npc.localAI[0] % 20f == 10f && ableToFireLaser) + npc.SyncVanillaLocalAI(); + } Color telegraphColor = Color.Transparent; switch (npc.Calamity().destroyerLaserColor) @@ -1403,43 +1393,28 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.type != NPCID.TheDestroyerBody || npc.ai[2] != 1f) { Vector3 lightColor = Color.Red.ToVector3(); - int x = (int)((npc.position.X - 8f) / 16f); - int x2 = (int)((npc.position.X + npc.width + 8f) / 16f); - int y = (int)((npc.position.Y - 8f) / 16f); - int y2 = (int)((npc.position.Y + npc.height + 8f) / 16f); - for (int l = x; l <= x2; l++) + + // Light colors + Vector3 groundColor = new Vector3(0.3f, 0.1f, 0.05f); + Vector3 segmentColor = groundColor; + Vector3 telegraphColor = groundColor; + + // Telegraph for the laser breath and body lasers + float telegraphProgress = 0f; + if (npc.Calamity().destroyerLaserColor != -1) { - for (int m = y; m <= y2; m++) + if (npc.type == NPCID.TheDestroyerBody) { - if (Lighting.Brightness(l, m) == 0f) - lightColor = Color.Black.ToVector3(); + float shootProjectileTime = Main.masterMode ? 500f : Main.expertMode ? 700f : 900f; + float bodySegmentTime = npc.ai[0] * 30f; + float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; + float telegraphGateValue = shootProjectileGateValue - LaserTelegraphTime; + if (npc.localAI[0] > telegraphGateValue) + telegraphProgress = MathHelper.Clamp((npc.localAI[0] - telegraphGateValue) / LaserTelegraphTime, 0f, 1f); } } - if (lightColor != Color.Black.ToVector3()) - { - // Light colors - Vector3 groundColor = new Vector3(0.3f, 0.1f, 0.05f); - Vector3 segmentColor = groundColor; - Vector3 telegraphColor = groundColor; - - // Telegraph for the laser breath and body lasers - float telegraphProgress = 0f; - if (npc.Calamity().destroyerLaserColor != -1) - { - if (npc.type == NPCID.TheDestroyerBody) - { - float shootProjectileTime = Main.masterMode ? 500f : Main.expertMode ? 700f : 900f; - float bodySegmentTime = npc.ai[0] * 30f; - float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; - float telegraphGateValue = shootProjectileGateValue - LaserTelegraphTime; - if (npc.localAI[0] > telegraphGateValue) - telegraphProgress = MathHelper.Clamp((npc.localAI[0] - telegraphGateValue) / LaserTelegraphTime, 0f, 1f); - } - } - - Lighting.AddLight(npc.Center, Vector3.Lerp(segmentColor, telegraphColor * 2f, telegraphProgress)); - } + Lighting.AddLight(npc.Center, Vector3.Lerp(segmentColor, telegraphColor * 2f, telegraphProgress)); } npc.localAI[1] = 1f; @@ -1564,7 +1539,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { if (!flag2) { - npc.TargetClosest(); npc.velocity.Y += 0.15f; if (Main.masterMode && npc.velocity.Y > 0f) npc.velocity.Y += 0.05f; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs index b351e11655..c50a12c01b 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs @@ -121,22 +121,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Player player = Main.player[npc.target]; // Get target - if (npc.target < 0 || npc.target == Main.maxPlayers || player.dead || !player.active) + if (npc.target < 0 || npc.target == Main.maxPlayers || player.dead || !player.active || Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) { npc.TargetClosest(); player = Main.player[npc.target]; npc.netUpdate = true; } - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Despawn if (player.dead || Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) { - npc.TargetClosest(); - npc.velocity.Y -= 0.4f; if (npc.timeLeft > 10) @@ -477,7 +471,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 2f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -526,7 +519,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -566,7 +558,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -592,7 +583,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -751,7 +741,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 2f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -797,7 +786,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[0] = 5f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -825,7 +813,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[0] = 5f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -871,7 +858,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -1062,7 +1048,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (!phase4 || !death) npc.ai[3] += 1f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -1163,7 +1148,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 velocityVector = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY); float inertia = 30f; - float velocity = 25f; + float velocity = 24f; npc.velocity = (npc.velocity * inertia + velocityVector * velocity) / (inertia + 1f); npc.scale = npc.ai[3]; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs index 22922a5ce6..7e10b43aef 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs @@ -37,10 +37,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles && npc.type == NPCID.EaterofWorldsHead) - npc.TargetClosest(); - bool enrage = true; int targetTileX = (int)Main.player[npc.target].Center.X / 16; int targetTileY = (int)Main.player[npc.target].Center.Y / 16; @@ -785,7 +781,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.realLife = -1; - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead) + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); if (Main.player[npc.target].dead) @@ -998,7 +994,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { if (!flag2) { - npc.TargetClosest(); npc.velocity.Y += 0.11f; if (Main.masterMode && npc.velocity.Y > 0f) npc.velocity.Y += 0.07f; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs index 8bf28b1f87..3c41eb2737 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs @@ -55,10 +55,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - bool dead = Main.player[npc.target].dead; float targetXDistance = npc.Center.X - Main.player[npc.target].position.X - (Main.player[npc.target].width / 2); float targetYDistance = npc.position.Y + npc.height - 59f - Main.player[npc.target].position.Y - (Main.player[npc.target].height / 2); @@ -277,7 +273,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.rotation = eyeRotation; float numCharges = death ? 4f : 3f; @@ -486,13 +481,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ProjectileID.BloodNautilusShot; + int damage = npc.GetProjectileDamage(type); int numProj = masterMode ? Main.rand.Next(4, 6) : 3; int spread = masterMode ? numProj * 3 : 10; float rotation = MathHelper.ToRadians(spread); for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * ProjectileOffset, perturbedSpeed, type, 15, 0f, Main.myPlayer); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * ProjectileOffset, perturbedSpeed, type, damage, 0f, Main.myPlayer); Main.projectile[proj].timeLeft = 600; } } @@ -503,7 +499,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 1f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -570,7 +565,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.rotation = eyeRotation; float numCharges = death ? 4f : 3f; @@ -598,7 +592,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Deal less damage overall while not charging npc.damage = reducedSetDamage; - npc.TargetClosest(); npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; @@ -744,6 +737,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float accelerationBoost = death ? 0.425f * (phase3LifeRatio - lifeRatio) : 0.125f * (phase3LifeRatio - lifeRatio); float hoverSpeed = 8f + speedBoost; float hoverAcceleration = 0.25f + accelerationBoost; + + bool horizontalCharge = calamityGlobalNPC.newAI[0] == 1f || calamityGlobalNPC.newAI[0] == 3f; + float timeGateValue = horizontalCharge ? (100f - (death ? 80f * (phase3LifeRatio - lifeRatio) : 0f)) : (85f - (death ? 70f * (phase3LifeRatio - lifeRatio) : 0f)); + if (npc.ai[2] > timeGateValue) + { + float velocityScalar = npc.ai[2] - timeGateValue; + hoverSpeed += velocityScalar * 0.05f; + hoverAcceleration += velocityScalar * 0.0025f; + } + hoverSpeed += enrageScale * 4f; hoverAcceleration += enrageScale * 0.125f; @@ -752,7 +755,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float lineUpChargeTargetY = Main.player[npc.target].Center.Y + offset - eyeLineUpChargeDirection.Y; Vector2 hoverDestination = Main.player[npc.target].Center + Vector2.UnitY * offset; - bool horizontalCharge = calamityGlobalNPC.newAI[0] == 1f || calamityGlobalNPC.newAI[0] == 3f; if (horizontalCharge) { float horizontalChargeOffset = death ? 450f : 500f; @@ -765,7 +767,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 idealHoverVelocity = npc.SafeDirectionTo(hoverDestination) * hoverSpeed; npc.SimpleFlyMovement(idealHoverVelocity, hoverAcceleration); - float timeGateValue = horizontalCharge ? (100f - (death ? 80f * (phase3LifeRatio - lifeRatio) : 0f)) : (85f - (death ? 70f * (phase3LifeRatio - lifeRatio) : 0f)); float servantSpawnGateValue = horizontalCharge ? (death ? 23f : 35f) : (death ? 17f : 27f); float maxServantSpawnsPerAttack = 2f; @@ -845,7 +846,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - if (npc.ai[2] >= timeGateValue) + float requiredDistanceForHorizontalCharge = 160f; + if (npc.ai[2] >= timeGateValue && (npc.Distance(hoverDestination) < requiredDistanceForHorizontalCharge || !horizontalCharge)) { switch ((int)calamityGlobalNPC.newAI[0]) { @@ -874,7 +876,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; } - npc.TargetClosest(); calamityGlobalNPC.newAI[0] += ((masterMode && calamityGlobalNPC.newAI[0] % 2f != 0f) ? Main.rand.Next(2) + 1f : 1f); if (calamityGlobalNPC.newAI[0] > 3f) calamityGlobalNPC.newAI[0] = masterMode ? Main.rand.Next(2) : 0f; @@ -1114,7 +1115,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 1f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.target = Main.maxPlayers; + npc.TargetClosest(); npc.netUpdate = true; } else if ((npc.position.Y + (float)npc.height < Main.player[npc.target].position.Y && num15 < 500f) || (Main.expertMode && num15 < (Main.masterMode ? 750f : 500f))) @@ -1233,7 +1234,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.target = Main.maxPlayers; npc.rotation = num7; if (npc.ai[3] >= (Main.masterMode ? 4f : 3f)) { @@ -1263,6 +1263,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; + npc.TargetClosest(); npc.netUpdate = true; if (npc.netSpam > 10) npc.netSpam = 10; @@ -1464,13 +1465,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.expertMode && (double)npc.life < (double)npc.lifeMax * (Main.masterMode ? 0.45 : 0.35)) npc.ai[1] = 3f; - npc.target = Main.maxPlayers; npc.netUpdate = true; } if (Main.expertMode && flag3) { - npc.TargetClosest(); npc.netUpdate = true; npc.ai[1] = 3f; npc.ai[2] = 0f; @@ -1542,7 +1541,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.target = Main.maxPlayers; npc.rotation = num7; if (npc.ai[3] >= 3f) { @@ -1572,7 +1570,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Deal less damage while not charging npc.damage = reducedSetDamage; - npc.TargetClosest(); npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; @@ -1582,7 +1579,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } else if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.TargetClosest(); float num50 = Main.masterMode ? 24f : 20f; Vector2 vector10 = npc.Center; float num51 = Main.player[npc.target].Center.X - vector10.X; @@ -1775,7 +1771,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[2] += 1f; if (npc.ai[2] >= (Main.masterMode ? 40f : 70f)) { - npc.TargetClosest(); npc.ai[1] = 3f; npc.ai[2] = -1f; npc.ai[3] = Main.rand.Next(-3, 1); diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs index df15000bff..4ade8b50a9 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs @@ -43,14 +43,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X - 3, (int)npc.Center.Y - 57, NPCID.GolemHead); } - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Despawn if (npc.target >= 0 && Main.player[npc.target].dead) { @@ -265,7 +257,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else if (npc.ai[1] == -1f) { // Set jump velocity - npc.TargetClosest(); + if (!headAlive) + npc.TargetClosest(); // Set damage npc.damage = npc.defDamage; @@ -412,8 +405,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Avoid cheap bullshit npc.damage = 0; - npc.TargetClosest(); - // Play sound SoundEngine.PlaySound(SoundID.Item14, npc.Center); @@ -602,6 +593,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.velocity.Y = maxFallSpeed; } + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + // Despawn if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > despawnDistance) { @@ -705,8 +700,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float fistPunchGateValue = masterMode ? 120f : 40f; if (npc.ai[1] >= fistPunchGateValue) { - npc.TargetClosest(); - if (canPunch) { npc.ai[1] = 0f; @@ -950,10 +943,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Die if body is gone if (NPC.golemBoss < 0) { @@ -1021,8 +1010,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= shootFireballGateValue) { - npc.TargetClosest(); - npc.ai[1] = 0f; Vector2 headCent = new Vector2(npc.Center.X, npc.Center.Y + 10f * npc.scale); @@ -1076,8 +1063,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= shootFireballGateValue) { - npc.TargetClosest(); - npc.ai[1] = 0f; float fireballSpeedFistsDed = turboEnrage ? 32f : enrage ? 24f : 12f; @@ -1111,8 +1096,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[2] >= 300f) { - npc.TargetClosest(); - npc.ai[2] = 0f; int projType = ProjectileID.EyeBeam; @@ -1199,10 +1182,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Die if body is gone if (NPC.golemBoss < 0) { @@ -1393,8 +1372,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= shootFireballGateValue) { - npc.TargetClosest(); - npc.ai[1] = 0f; Vector2 freeHeadCenter = new Vector2(npc.Center.X, npc.Center.Y + 20f * npc.scale); @@ -1434,8 +1411,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float laserGateValue = 300f - (death ? 240f * (1f - combinedLifeRatio) : 180f * (1f - combinedLifeRatio)); if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] >= laserGateValue) { - npc.TargetClosest(); - npc.ai[2] = 0f; int numLasers = 2; @@ -1676,7 +1651,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.damage = npc.defDamage; npc.noTileCollide = true; - npc.TargetClosest(); + + if (!flag) + npc.TargetClosest(); + npc.velocity.X = 4 * npc.direction; if (npc.life < npc.lifeMax) { @@ -1718,7 +1696,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); if (npc.position.X < Main.player[npc.target].position.X && npc.position.X + (float)npc.width > Main.player[npc.target].position.X + (float)Main.player[npc.target].width) { npc.velocity.X *= 0.9f; @@ -1752,7 +1729,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - if (npc.target <= 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead) + if (npc.target <= 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); int num8 = 3000; @@ -1776,6 +1753,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.getGoodWorld) enrageScale += 3f; + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + if ((!Main.player[npc.target].ZoneLihzhardTemple && !Main.player[npc.target].ZoneJungle) || (double)Main.player[npc.target].Center.Y < Main.worldSurface * 16.0) enrageScale *= 2f; @@ -1843,7 +1824,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[1] >= 60f) { - npc.TargetClosest(); if ((npc.type == NPCID.GolemFistLeft && npc.Center.X + 100f > Main.player[npc.target].Center.X) || (npc.type == NPCID.GolemFistRight && npc.Center.X - 100f < Main.player[npc.target].Center.X)) { npc.ai[1] = 0f; @@ -2044,6 +2024,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.getGoodWorld) enrageScale += 3f; + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + if ((!Main.player[npc.target].ZoneLihzhardTemple && !Main.player[npc.target].ZoneJungle) || (double)Main.player[npc.target].Center.Y < Main.worldSurface * 16.0) enrageScale *= 2f; @@ -2103,7 +2087,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[1] >= (float)num711) { - npc.TargetClosest(); npc.ai[1] = 0f; Vector2 vector90 = new Vector2(npc.Center.X, npc.Center.Y + 10f * npc.scale); float num712 = 8f; @@ -2122,7 +2105,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } else if (npc.ai[0] == 1f) { - npc.TargetClosest(); Vector2 vector91 = new Vector2(npc.Center.X, npc.Center.Y + 10f * npc.scale); if (Main.player[npc.target].Center.X < npc.Center.X - (float)npc.width) { @@ -2153,7 +2135,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[1] >= (float)num720) { - npc.TargetClosest(); npc.ai[1] = 0f; float num721 = 8f; float num722 = Main.player[npc.target].Center.X - vector91.X; @@ -2257,6 +2238,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.getGoodWorld) enrageScale += 3f; + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + if ((!Main.player[npc.target].ZoneLihzhardTemple && !Main.player[npc.target].ZoneJungle) || (double)Main.player[npc.target].Center.Y < Main.worldSurface * 16.0) enrageScale *= 2f; @@ -2276,7 +2261,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } - npc.TargetClosest(); float num742 = 7f; float num743 = 0.05f; Vector2 vector92 = npc.Center; @@ -2337,7 +2321,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[1] >= (float)num748) { - npc.TargetClosest(); npc.ai[1] = 0f; Vector2 vector93 = new Vector2(npc.Center.X, npc.Center.Y + 20f * npc.scale); float num749 = 8f; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs index 54060f5524..e49f711b79 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs @@ -39,30 +39,38 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Phases based on life percentage // Higher velocity jumps phase bool phase2 = lifeRatio < 0.75f; - // Spawn Crystal phase + // Spawn Emerald Crystal phase + bool spawnGreenCrystal = lifeRatio < 0.7f; + + // Spawn Ruby Crystal phase bool phase3 = lifeRatio < 0.5f; + // Spawn Sapphire Crystal phase + bool spawnBlueCrystal = lifeRatio < 0.3f; + // Check if the crystals are alive bool crystalAlive = true; bool blueCrystalAlive = false; bool greenCrystalAlive = true; - if (phase3) + + if (spawnGreenCrystal) { - crystalAlive = NPC.AnyNPCs(ModContent.NPCType()); if (masterMode) - { - blueCrystalAlive = NPC.AnyNPCs(ModContent.NPCType()); - greenCrystalAlive = NPC.AnyNPCs(ModContent.NPCType()); - } + greenCrystalAlive = NPC.AnyNPCs(ModContent.NPCType()); + } + + if (phase3) + crystalAlive = NPC.AnyNPCs(ModContent.NPCType()); + + if (spawnBlueCrystal) + { + if (masterMode) + blueCrystalAlive = NPC.AnyNPCs(ModContent.NPCType()); } // Sapphire Crystal buffs @@ -77,27 +85,63 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Dust color when the blue crystal is alive Color dustColor = Color.Lerp(new Color(0, 0, 150, npc.alpha), new Color(125, 125, 255, npc.alpha), (float)Math.Sin(Main.GlobalTimeWrappedHourly) / 2f + 0.5f); - // Spawn crystal in phase 2 - if (phase3 && npc.Calamity().newAI[0] == 0f) + // Master Mode Crystal spawning + if (masterMode) { - npc.Calamity().newAI[0] = 1f; - npc.SyncExtraAI(); - Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; - int totalDustPerCrystalSpawn = 20; - for (int i = 0; i < totalDustPerCrystalSpawn; i++) + if (spawnGreenCrystal && npc.Calamity().newAI[0] == 0f) { - int rubyDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemRuby, 0f, 0f, 100, default, 2f); - Main.dust[rubyDust].velocity *= 2f; - Main.dust[rubyDust].noGravity = true; - if (Main.rand.NextBool()) + npc.Calamity().newAI[0] = 1f; + npc.SyncExtraAI(); + Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; + int totalDustPerCrystalSpawn = 20; + for (int i = 0; i < totalDustPerCrystalSpawn; i++) { - Main.dust[rubyDust].scale = 0.5f; - Main.dust[rubyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + int emeraldDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemEmerald, 0f, 0f, 100, default, 2f); + Main.dust[emeraldDust].velocity *= 2f; + Main.dust[emeraldDust].noGravity = true; + if (Main.rand.NextBool()) + { + Main.dust[emeraldDust].scale = 0.5f; + Main.dust[emeraldDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } } + + SoundEngine.PlaySound(SoundID.Item38, vector); + + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); } - if (masterMode) + if (phase3 && npc.Calamity().newAI[0] == 1f) { + npc.Calamity().newAI[0] = 2f; + npc.SyncExtraAI(); + Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; + int totalDustPerCrystalSpawn = 20; + for (int i = 0; i < totalDustPerCrystalSpawn; i++) + { + int rubyDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemRuby, 0f, 0f, 100, default, 2f); + Main.dust[rubyDust].velocity *= 2f; + Main.dust[rubyDust].noGravity = true; + if (Main.rand.NextBool()) + { + Main.dust[rubyDust].scale = 0.5f; + Main.dust[rubyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + + SoundEngine.PlaySound(SoundID.Item38, vector); + + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); + } + + if (spawnBlueCrystal && npc.Calamity().newAI[0] == 2f) + { + npc.Calamity().newAI[0] = 3f; + npc.SyncExtraAI(); + Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; + int totalDustPerCrystalSpawn = 20; for (int i = 0; i < totalDustPerCrystalSpawn; i++) { int sapphireDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemSapphire, 0f, 0f, 100, default, 2f); @@ -110,29 +154,37 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + SoundEngine.PlaySound(SoundID.Item38, vector); + + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); + } + } + else + { + // Spawn crystal in phase 2 + if (phase3 && npc.Calamity().newAI[0] == 0f) + { + npc.Calamity().newAI[0] = 1f; + npc.SyncExtraAI(); + Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; + int totalDustPerCrystalSpawn = 20; for (int i = 0; i < totalDustPerCrystalSpawn; i++) { - int emeraldDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemEmerald, 0f, 0f, 100, default, 2f); - Main.dust[emeraldDust].velocity *= 2f; - Main.dust[emeraldDust].noGravity = true; + int rubyDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemRuby, 0f, 0f, 100, default, 2f); + Main.dust[rubyDust].velocity *= 2f; + Main.dust[rubyDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[emeraldDust].scale = 0.5f; - Main.dust[emeraldDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[rubyDust].scale = 0.5f; + Main.dust[rubyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - } - SoundEngine.PlaySound(SoundID.Item38, vector); + SoundEngine.PlaySound(SoundID.Item38, vector); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); - if (masterMode) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); - NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); - } + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); } } @@ -280,6 +332,38 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (masterMode) teleportRate *= 2f; + if (npc.ai[0] == 0f) + { + // Move Blue Crystal + if (blueCrystalAlive) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC blueCrystal = Main.npc[i]; + if (blueCrystal.active && blueCrystal.type == ModContent.NPCType()) + { + blueCrystal.position.X = npc.position.X; + blueCrystal.position.Y = npc.position.Y - 200f; + + for (int dusty = 0; dusty < 10; dusty++) + { + Vector2 dustVel = Main.rand.NextVector2CircularEdge(5f, 5f); + int sapphire = Dust.NewDust(blueCrystal.Center, blueCrystal.width, blueCrystal.height, DustID.GemSapphire, 0f, 0f, 100, default, 2f); + Main.dust[sapphire].velocity = dustVel * Main.rand.NextFloat(1f, 2f); + Main.dust[sapphire].noGravity = true; + if (Main.rand.NextBool()) + { + Main.dust[sapphire].scale = 0.5f; + Main.dust[sapphire].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + + break; + } + } + } + } + npc.ai[0] += teleportRate; teleportScale = MathHelper.Clamp(npc.ai[0] / 30f, 0f, 1f); teleportScale = 0.5f + teleportScale * 0.5f; @@ -603,7 +687,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 5f; if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.TargetClosest(faceTarget: false); + npc.TargetClosest(false); Point point3 = npc.Center.ToTileCoordinates(); Point point4 = Main.player[npc.target].Center.ToTileCoordinates(); Vector2 vector30 = Main.player[npc.target].Center - npc.Center; @@ -791,6 +875,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.netUpdate = true; npc.TargetClosest(); + if (npc.ai[1] == 3f) { npc.velocity.Y = -13f; @@ -895,6 +980,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 randomDefault = Main.rand.NextBool() ? Vector2.UnitX : -Vector2.UnitX; Vector2 vectorAimedAheadOfTarget = Main.player[npc.target].Center + new Vector2((float)Math.Round(Main.player[npc.target].velocity.X), 0f).SafeNormalize(randomDefault) * distanceAhead; Point predictiveTeleportPoint = vectorAimedAheadOfTarget.ToTileCoordinates(); + if (predictiveTeleportPoint.X < 10) + predictiveTeleportPoint.X = 10; + if (predictiveTeleportPoint.X > Main.maxTilesX - 10) + predictiveTeleportPoint.X = Main.maxTilesX - 10; + if (predictiveTeleportPoint.Y < 10) + predictiveTeleportPoint.Y = 10; + if (predictiveTeleportPoint.Y > Main.maxTilesY - 10) + predictiveTeleportPoint.Y = Main.maxTilesY - 10; + int randomPredictiveTeleportOffset = 5; int teleportTries = 0; while (teleportTries < 100) @@ -918,10 +1012,22 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; } else + { predictiveTeleportPoint.X += predictiveTeleportPoint.X < 0f ? 1 : -1; + if (predictiveTeleportPoint.X < 10) + predictiveTeleportPoint.X = 10; + if (predictiveTeleportPoint.X > Main.maxTilesX - 10) + predictiveTeleportPoint.X = Main.maxTilesX - 10; + } } else + { predictiveTeleportPoint.X += predictiveTeleportPoint.X < 0f ? 1 : -1; + if (predictiveTeleportPoint.X < 10) + predictiveTeleportPoint.X = 10; + if (predictiveTeleportPoint.X > Main.maxTilesX - 10) + predictiveTeleportPoint.X = Main.maxTilesX - 10; + } } // Default teleport if the above conditions aren't met in 100 iterations diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs index a7c993715b..04d87dc3be 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs @@ -39,10 +39,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -301,6 +297,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + npc.TargetClosest(); + npc.ai[1] = -SeedGatlingDuration; } } @@ -622,7 +620,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.localAI[1] >= shootProjectileGateValue) { npc.localAI[1] = 0f; - npc.TargetClosest(); bool shootPoisonSeed = CalamityWorld.LegendaryMode || Main.rand.NextBool(masterMode ? 2 : 4); int projectileType = shootPoisonSeed ? ProjectileID.PoisonSeedPlantera : ProjectileID.SeedPlantera; float projectileSpeed = masterMode ? 16f : 14f; @@ -1208,7 +1205,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { bool flag39 = false; bool flag40 = false; - npc.TargetClosest(); + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + if (Main.player[npc.target].dead) { flag40 = true; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs index 95257c3031..f7b4de517e 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs @@ -23,10 +23,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - bool bossRush = BossRushEvent.BossRushActive; bool masterMode = Main.masterMode || bossRush; bool death = CalamityWorld.death || bossRush; @@ -426,7 +422,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool spawnBee = phase4 && calamityGlobalNPC.newAI[0] % beeSpawnGateValue == 0f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); if (spawnBee) { - SoundEngine.PlaySound(SoundID.NPCHit1, npc.Center); + SoundEngine.PlaySound(SoundID.NPCHit18, npc.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -619,10 +615,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Spawn bees if (Collision.CanHit(beeSpawnLocation, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && spawnBee && (!beeLimitReached || !hornetLimitReached)) { - if (!phase3 || Main.zenithWorld) - SoundEngine.PlaySound(SoundID.NPCHit1, beeSpawnLocation); - else - SoundEngine.PlaySound(SoundID.NPCHit18, beeSpawnLocation); + SoundEngine.PlaySound(SoundID.NPCHit18, beeSpawnLocation); if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -721,9 +714,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Get target location and shoot from ass float stingerAttackSpeed = 16f + enrageScale * 4f; - float stingerAttackAccel = phase6 ? 0.32f : 0.24f; + float stingerAttackAccel = phase6 ? 0.24f : 0.18f; if (enrageScale > 0f) - stingerAttackAccel = MathHelper.Lerp(phase6 ? 0.4f : 0.32f, phase6 ? 0.8f : 0.64f, enrageScale / maxEnrageScale); + stingerAttackAccel = MathHelper.Lerp(phase6 ? 0.3f : 0.24f, phase6 ? 0.6f : 0.48f, enrageScale / maxEnrageScale); if (masterMode) { @@ -1031,6 +1024,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } while ((float)num647 == num646); + npc.TargetClosest(); npc.ai[0] = num647; npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -1081,8 +1075,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { // Avoid cheap bullshit npc.damage = 0; - - npc.TargetClosest(); float chargeDistanceY = 20f; chargeDistanceY += 20f * num644; @@ -1239,8 +1231,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Avoid cheap bullshit npc.damage = 0; - npc.TargetClosest(); - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; npc.direction = playerLocation < 0 ? 1 : -1; npc.spriteDirection = npc.direction; @@ -1290,8 +1280,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Avoid cheap bullshit npc.damage = 0; - npc.TargetClosest(); - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; npc.direction = playerLocation < 0 ? 1 : -1; npc.spriteDirection = npc.direction; @@ -1322,7 +1310,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.damage = 0; npc.localAI[0] = 0f; - npc.TargetClosest(); float num672 = Main.masterMode ? 16f : 14f; float num673 = Main.masterMode ? 0.15f : 0.1f; @@ -1369,7 +1356,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Collision.CanHit(beeSpawnLocation, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && flag35) { - SoundEngine.PlaySound(SoundID.NPCHit1, npc.Center); + SoundEngine.PlaySound(SoundID.NPCHit18, npc.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { int num670 = Main.rand.Next(NPCID.Bee, NPCID.BeeSmall + 1); diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs index 40b7d577b3..5b0ba579c7 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs @@ -68,7 +68,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { npc.netUpdate = true; - npc.TargetClosest(faceTarget: false); + npc.TargetClosest(false); Vector2 vectorAimedAheadOfTarget = Main.player[npc.target].Center + new Vector2((float)Math.Round(Main.player[npc.target].velocity.X), 0f).SafeNormalize(Vector2.Zero) * 800f; Point predictiveTeleportPoint = vectorAimedAheadOfTarget.ToTileCoordinates(); int randomTeleportOffset = 5; @@ -404,6 +404,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.netUpdate = true; npc.TargetClosest(); + if (npc.ai[2] == 3f) { npc.velocity.Y = -13f * speedMult; @@ -1252,6 +1253,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.netUpdate = true; npc.TargetClosest(); + if (npc.ai[2] == 3f) { npc.velocity.Y = -13f; @@ -1629,8 +1631,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float flyAcceleration = bossRush ? 0.3f : death ? (masterMode ? 0.18f : 0.14f) : (masterMode ? 0.16f : 0.12f); float flyDistanceY = masterMode ? 350f : 450f; - npc.TargetClosest(); - Vector2 desiredVelocity = npc.Center; if (npc.timeLeft > 10) @@ -1698,7 +1698,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float num = Main.masterMode ? 18f : Main.expertMode ? 15f : 12f; float num2 = Main.masterMode ? 0.12f : Main.expertMode ? 0.1f : 0.085f; float num3 = 250f; - npc.TargetClosest(); Vector2 desiredVelocity = npc.Center; if (npc.timeLeft > 10) { diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs index 0eb710efcb..d8e4856b6b 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs @@ -34,6 +34,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float phase3LifeRatio = masterMode ? 0.9f : 0.7f; float respawnHandsLifeRatio = 0.5f; float phase4LifeRatio = masterMode ? 0.4f : 0.3f; + float useSkullSpreadsAfterChargeLifeRatio = masterMode ? 0.3f : 0.2f; float phase5LifeRatio = masterMode ? 0.2f : 0.1f; // Begin firing spreads of skulls phase @@ -48,6 +49,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Fire giant cursed skull projectiles (yes, these curse you if you get hit) during charge attack and hands fire skulls phase bool phase4 = lifeRatio < phase4LifeRatio; + // Self-explanatory + bool useSkullSpreadsAfterCharge = lifeRatio < useSkullSpreadsAfterChargeLifeRatio; + // Rapid teleport and charge, stop using idle phase bool phase5 = lifeRatio < phase5LifeRatio; @@ -60,10 +64,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Spawn hands if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -125,16 +125,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - // Distance from target - float distance = Vector2.Distance(Main.player[npc.target].Center, npc.Center); - // Despawn - int despawnDistanceInTiles = 500; - if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) + if (npc.ai[1] != 3f) { - npc.TargetClosest(); + int despawnDistanceInTiles = 500; if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) - npc.ai[1] = 3f; + { + npc.TargetClosest(); + if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) + npc.ai[1] = 3f; + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; } // Daytime enrage @@ -203,6 +205,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (death) headSpinVelocityMult *= 1.2f; + // Velocity used to move Skeletron away from the target before charging + float moveAwayVelocity = headSpinVelocityMult; + if (!phase3) + moveAwayVelocity *= (bossRush ? 1.5f : 2f); + // Hand DR, scale DR up if the hands are still alive as Skeletron's HP lowers npc.chaseable = handsDead; float minDR = 0.05f; @@ -458,7 +465,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.localAI[2] = 0f; calamityGlobalNPC.newAI[1] = 0f; - npc.TargetClosest(); npc.SyncExtraAI(); npc.SyncVanillaLocalAI(); npc.netUpdate = true; @@ -483,23 +489,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { if (!canCharge || !hasMovedForcedDistance) { - float maxAcceleration = headXAcceleration + headYAcceleration + (npc.ai[2] - moveAwayGateValue) * (phase5 ? 0.006f : 0.004f); - float maxAccelerationCap = (headXAcceleration + headYAcceleration) * 5f; - if (maxAcceleration > maxAccelerationCap) - maxAcceleration = maxAccelerationCap; + float phase5Multiplier = 1.5f; + float maxVelocity = (npc.ai[2] - moveAwayGateValue) * (moveAwayVelocity * 0.008f); + if (phase5) + maxVelocity *= phase5Multiplier; - npc.velocity += (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * -maxAcceleration; - - float maxVelocity = headSpinVelocityMult + (npc.ai[2] - moveAwayGateValue) * (phase5 ? 0.12f : 0.08f); - float maxVelocityCap = headSpinVelocityMult * 2.5f; + float maxVelocityCap = moveAwayVelocity; + if (phase5) + maxVelocityCap *= phase5Multiplier; if (maxVelocity > maxVelocityCap) maxVelocity = maxVelocityCap; - if (npc.velocity.Length() > maxVelocity) - { - npc.velocity = npc.velocity.SafeNormalize(Vector2.UnitY); - npc.velocity *= maxVelocity; - } + npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * -maxVelocity; } // New charge attack @@ -694,7 +695,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - if (respawnHands && !disableSkullsAfterCharge && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + if (useSkullSpreadsAfterCharge && !disableSkullsAfterCharge && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { // Spawn projectiles if (Main.netMode != NetmodeID.MultiplayerClient) @@ -702,7 +703,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int chargeSkullAmt = death ? 5 : 3; int chargeSkullSpread = death ? 80 : 60; float rotation = MathHelper.ToRadians(chargeSkullSpread); - float skullProjSpeed = phase4 ? (6f + (death ? 2f * ((phase4LifeRatio - lifeRatio) / phase4LifeRatio) : 0f)) : 4f; + float skullProjSpeed = phase5 ? (6f + (death ? 2f * ((phase5LifeRatio - lifeRatio) / phase5LifeRatio) : 0f)) : 4f; Vector2 initialProjectileVelocity = npc.Center.DirectionTo(Main.player[npc.target].Center) * skullProjSpeed; int type = ProjectileID.Skull; int damage = npc.GetProjectileDamage(type); @@ -861,10 +862,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - float yMultiplier = 1f; if (calamityGlobalNPC.newAI[0] != 0f) yMultiplier = calamityGlobalNPC.newAI[0]; @@ -1009,6 +1006,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += slapTimerIncrement; if (npc.ai[3] >= slapGateValue) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.ai[2] += 1f; npc.ai[3] = calamityGlobalNPC.newAI[2] = slapGateValue; calamityGlobalNPC.newAI[3] = 0f; @@ -1098,7 +1096,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); npc.ai[2] = 2f; npc.ai[3] = 0f; npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * handSwipeVelocity; @@ -1158,7 +1155,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); npc.ai[2] = 5f; npc.ai[3] = 0f; npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * handSwipeVelocity; @@ -1245,9 +1241,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.reflectsProjectiles = false; npc.defense = npc.defDefense; + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + if (npc.ai[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - npc.TargetClosest(); npc.ai[0] = 1f; int num148 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)npc.Center.Y, NPCID.SkeletronHand, npc.whoAmI); Main.npc[num148].ai[0] = -1f; @@ -1346,7 +1346,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[2] = 0f; npc.ai[1] = 1f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -1442,6 +1441,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[2] = 0f; npc.ai[1] = 0f; + npc.TargetClosest(); } npc.rotation += (float)npc.direction * 0.3f; @@ -1566,6 +1566,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + if (npc.ai[2] == 0f || npc.ai[2] == 3f) { // Avoid cheap bullshit @@ -1631,6 +1635,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] >= 300f) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.ai[2] += 1f; npc.ai[3] = 0f; npc.netUpdate = true; @@ -1756,7 +1761,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); npc.ai[2] = 2f; vector23 = npc.Center; num184 = Main.player[npc.target].Center.X - vector23.X; @@ -1811,7 +1815,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); npc.ai[2] = 5f; vector24 = npc.Center; num187 = Main.player[npc.target].Center.X - vector24.X; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs index 96febd4b2a..a7f40acc14 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs @@ -26,10 +26,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -208,11 +204,17 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Despawn - if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > 6000f || Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > 6000f) + if (npc.ai[1] != 3f) { - npc.TargetClosest(); - if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > 6000f || Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > 6000f) - npc.ai[1] = 3f; + int despawnDistanceInTiles = 500; + if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) + { + npc.TargetClosest(); + if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) + npc.ai[1] = 3f; + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; } // Activate daytime enrage @@ -260,7 +262,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Start other phases; if arms are dead, start with spin phase bool otherHeadChargingOrSpinning = Main.npc[(int)npc.ai[0]].ai[1] == 5f || Main.npc[(int)npc.ai[0]].ai[1] == 1f; - if (phase2 || CalamityWorld.LegendaryMode || allArmsDead) + if (phase2 || CalamityWorld.LegendaryMode || allArmsDead || masterMode) { // Start spin phase after 1.5 seconds npc.ai[2] += phase3 ? 1.5f : 1f; @@ -269,7 +271,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool shouldSpinAround = npc.ai[1] == 4f && npc.position.Y < Main.player[npc.target].position.Y - 400f && Vector2.Distance(Main.player[npc.target].Center, npc.Center) < 600f && Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 400f; - if (shouldSpinAround || npc.ai[1] != 4f) + bool shouldCharge = masterMode && !phase2 && !allArmsDead && !CalamityWorld.LegendaryMode; + if (shouldCharge) + { + npc.ai[2] = 0f; + npc.ai[1] = 1f; + npc.netUpdate = true; + } + else if (shouldSpinAround || npc.ai[1] != 4f) { if (shouldSpinAround) { @@ -279,7 +288,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[2] = 0f; npc.ai[1] = shouldSpinAround ? 5f : 1f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -780,10 +788,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Set direction npc.spriteDirection = -(int)npc.ai[0]; @@ -914,10 +918,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] >= (masterMode ? 200f : 800f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.localAI[0] = 0f; npc.ai[2] = 1f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -941,7 +945,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.localAI[0] >= 48f) { npc.localAI[0] = 0f; - npc.TargetClosest(); float laserSpeed = bossRush ? 5f : 4f; int type = ProjectileID.DeathLaser; int damage = npc.GetProjectileDamage(type); @@ -983,10 +986,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] >= timeLimit) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.localAI[0] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -1009,7 +1012,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.localAI[0] >= 120f) { npc.localAI[0] = 0f; - npc.TargetClosest(); int totalProjectiles = bossRush ? 32 : (masterMode ? 24 : 16); float radians = MathHelper.TwoPi / totalProjectiles; int type = ProjectileID.DeathLaser; @@ -1055,10 +1057,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - npc.spriteDirection = -(int)npc.ai[0]; if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) @@ -1131,11 +1129,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] >= (masterMode ? 200f : 800f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.localAI[0] = 0f; npc.ai[2] = 1f; fireSlower = false; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -1155,11 +1153,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] >= timeLimit) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.localAI[0] = 0f; npc.ai[2] = 0f; fireSlower = true; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -1251,7 +1249,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { SoundEngine.PlaySound(SoundID.Item62, npc.Center); npc.localAI[0] = 0f; - npc.TargetClosest(); int type = ProjectileID.RocketSkeleton; int damage = npc.GetProjectileDamage(type); @@ -1299,7 +1296,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { SoundEngine.PlaySound(SoundID.Item62, npc.Center); npc.localAI[0] = 0f; - npc.TargetClosest(); int type = ProjectileID.RocketSkeleton; int damage = npc.GetProjectileDamage(type); @@ -1341,10 +1337,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Direction npc.spriteDirection = -(int)npc.ai[0]; @@ -1487,9 +1479,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] >= (masterMode ? 150f : 600f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.ai[2] += 1f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -1595,7 +1587,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses chargeVelocity += 1.5f; npc.ai[2] = 2f; - npc.TargetClosest(); viceArmChargePosition = npc.Center; viceArmChargeTargetX = Main.player[npc.target].Center.X - viceArmChargePosition.X; viceArmChargeTargetY = Main.player[npc.target].Center.Y - viceArmChargePosition.Y; @@ -1628,7 +1619,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Return to head npc.ai[2] = 3f; npc.ai[3] = 0f; - npc.TargetClosest(); return false; } @@ -1665,7 +1655,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses chargeVelocity += 1.15f; npc.ai[2] = 5f; - npc.TargetClosest(); viceArmOtherChargePosition = npc.Center; viceArmOtherChargeTargetX = Main.player[npc.target].Center.X - viceArmOtherChargePosition.X; viceArmOtherChargeTargetY = Main.player[npc.target].Center.Y - viceArmOtherChargePosition.Y; @@ -1696,7 +1685,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Return to head npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); return false; } @@ -1718,10 +1706,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - Vector2 sawArmLocation = npc.Center; float sawArmIdleXPos = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - sawArmLocation.X; float sawArmIdleYPos = Main.npc[(int)npc.ai[1]].position.Y + 230f - sawArmLocation.Y; @@ -1858,9 +1842,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] >= (masterMode ? 90f : 180f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.ai[2] += 1f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -1960,7 +1944,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses chargeVelocity += 1.5f; npc.ai[2] = 2f; - npc.TargetClosest(); sawArmChargePos = npc.Center; sawArmChargeTargetX = Main.player[npc.target].Center.X - sawArmChargePos.X; sawArmChargeTargetY = Main.player[npc.target].Center.Y - sawArmChargePos.Y; @@ -2049,7 +2032,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -2125,7 +2107,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[2] = 0f; npc.ai[1] = 1f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -2212,6 +2193,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[2] = 0f; npc.ai[1] = 0f; + npc.TargetClosest(); } if (NPC.IsMechQueenUp) @@ -2367,6 +2349,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + npc.damage = 0; if (npc.ai[2] == 0f || npc.ai[2] == 3f) @@ -2435,6 +2421,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += 1f; if (npc.ai[3] >= (Main.masterMode ? 400f : Main.expertMode ? 600f : 800f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.ai[2] += 1f; npc.ai[3] = 0f; npc.netUpdate = true; @@ -2494,7 +2481,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - npc.TargetClosest(); Vector2 vector68 = npc.Center; float num559 = Main.player[npc.target].Center.X - vector68.X; float num560 = Main.player[npc.target].Center.Y - vector68.Y; @@ -2538,6 +2524,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += 1f; if (npc.ai[3] >= (Main.masterMode ? 150f : Main.expertMode ? 175f : 200f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.localAI[0] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; @@ -2594,7 +2581,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.velocity.Y += num498; } - npc.TargetClosest(); vector69 = npc.Center; num566 = Main.player[npc.target].Center.X - vector69.X; num567 = Main.player[npc.target].Center.Y - vector69.Y; @@ -2648,6 +2634,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + npc.damage = 0; if (npc.ai[2] == 0f) @@ -2716,6 +2706,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += 1f; if (npc.ai[3] >= (Main.masterMode ? 700f : Main.expertMode ? 900f : 1100f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.localAI[0] = 0f; npc.ai[2] = 1f; npc.ai[3] = 0f; @@ -2807,6 +2798,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += 1f; if (npc.ai[3] >= (Main.masterMode ? 180f : Main.expertMode ? 240f : 300f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.localAI[0] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; @@ -2864,7 +2856,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.velocity.Y += num498; } - npc.TargetClosest(); vector67 = npc.Center; num552 = Main.player[npc.target].Center.X - vector67.X; num553 = Main.player[npc.target].Center.Y - vector67.Y; @@ -2918,6 +2909,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + // Avoid cheap bullshit npc.damage = 0; @@ -2983,7 +2978,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.npc[(int)npc.ai[1]].ai[1] != 0f) { - npc.TargetClosest(); if (Main.player[npc.target].dead) { npc.velocity.Y += 0.1f; @@ -3025,6 +3019,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += 1f; if (npc.ai[3] >= (Main.masterMode ? 400f : Main.expertMode ? 500f : 600f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.ai[2] += 1f; npc.ai[3] = 0f; npc.netUpdate = true; @@ -3112,7 +3107,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); npc.ai[2] = 2f; vector64 = npc.Center; num539 = Main.player[npc.target].Center.X - vector64.X; @@ -3161,7 +3155,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); npc.ai[2] = 5f; vector65 = npc.Center; num542 = Main.player[npc.target].Center.X - vector65.X; @@ -3220,6 +3213,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + // Min saw damage int reducedSetDamage = (int)Math.Round(npc.defDamage * 0.5); @@ -3288,7 +3285,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.npc[(int)npc.ai[1]].ai[1] != 0f) { - npc.TargetClosest(); if (Main.player[npc.target].dead) { npc.velocity.Y += 0.1f; @@ -3354,6 +3350,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += 1f; if (npc.ai[3] >= (Main.masterMode ? 180f : Main.expertMode ? 240f : 300f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.ai[2] += 1f; npc.ai[3] = 0f; npc.netUpdate = true; @@ -3438,7 +3435,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); npc.ai[2] = 2f; vector59 = npc.Center; num524 = Main.player[npc.target].Center.X - vector59.X; @@ -3463,7 +3459,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); Vector2 vector60 = npc.Center; float num527 = Main.player[npc.target].Center.X - vector60.X; float num528 = Main.player[npc.target].Center.Y - vector60.Y; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs index 7f270bebca..1647c03d42 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs @@ -25,10 +25,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - float enrageScale = bossRush ? 0.5f : masterMode ? 0.4f : 0f; if (Main.IsItDay() || bossRush) { @@ -382,13 +378,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.rotation = retinazerHoverRotation; float totalCharges = death ? 6f : 5f; if (npc.ai[3] >= totalCharges) { npc.ai[1] = 0f; npc.ai[3] = 0f; + npc.TargetClosest(); } else npc.ai[1] = 1f; @@ -895,13 +891,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += chargeIncrement; - npc.TargetClosest(); npc.rotation = retinazerHoverRotation; float maxChargeAmt = spazAlive ? 2f : 4f; if (npc.ai[3] >= maxChargeAmt) { npc.ai[1] = 0f; npc.ai[3] = 0f; + npc.TargetClosest(); } else npc.ai[1] = 4f; @@ -974,7 +970,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[2] += 1f; if (npc.ai[2] >= (spazAlive ? 75f : 60f) - (death ? 20f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f)) { - npc.TargetClosest(); npc.ai[1] = 2f; npc.ai[2] = 0f; npc.netUpdate = true; @@ -998,10 +993,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - float enrageScale = bossRush ? 0.5f : masterMode ? 0.4f : 0f; if (Main.IsItDay() || bossRush) { @@ -1261,7 +1252,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 1f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } else @@ -1367,7 +1357,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Reset AI array and go to cursed fireball phase npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.rotation = spazmatismRotation; float totalCharges = 8f; if (death) @@ -1584,7 +1573,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = (!retAlive || finalPhase) ? 5f : 1f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -1744,7 +1732,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.rotation = spazmatismRotation; if (npc.ai[3] >= 5f) { @@ -1766,7 +1753,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float secondFastCharge = 4f; if (npc.ai[3] >= (retAlive ? secondFastCharge : secondFastCharge + 1f)) { - npc.TargetClosest(); npc.ai[1] = retAlive ? 0f : 5f; npc.ai[2] = 0f; npc.ai[3] = 0f; @@ -1996,7 +1982,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Take 3 seconds to get in position, then charge if (npc.ai[2] >= (retAlive ? 180f : 135f) - (death ? 45f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f)) { - npc.TargetClosest(); npc.ai[1] = 3f; npc.ai[2] = -1f; npc.ai[3] = 0f; @@ -2196,7 +2181,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 1f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.target = Main.maxPlayers; + npc.TargetClosest(); npc.netUpdate = true; } else if (npc.position.Y + (float)npc.height < Main.player[npc.target].position.Y && num425 < (Main.masterMode ? 720f : Main.expertMode ? 560f : 400f)) @@ -2299,11 +2284,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.target = Main.maxPlayers; npc.rotation = num414; float numCharges = Main.masterMode ? 6f : Main.expertMode ? 5f : 4f; if (npc.ai[3] >= numCharges) { + npc.TargetClosest(); npc.ai[1] = 0f; npc.ai[3] = 0f; } @@ -2318,6 +2303,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; + npc.TargetClosest(); npc.netUpdate = true; } @@ -2748,7 +2734,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Avoid cheap bullshit npc.damage = 0; - npc.TargetClosest(); float num463 = 12f; float num464 = 0.4f; if (Main.expertMode) @@ -2838,7 +2823,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 1f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.target = Main.maxPlayers; npc.netUpdate = true; } else @@ -2942,7 +2926,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.target = Main.maxPlayers; npc.rotation = num458; float numCharges = Main.masterMode ? 6f : Main.expertMode ? 8f : 10f; if (npc.ai[3] >= numCharges) @@ -3130,7 +3113,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 1f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.target = Main.maxPlayers; npc.netUpdate = true; } @@ -3274,7 +3256,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.target = Main.maxPlayers; npc.rotation = num458; float numCharges = Main.masterMode ? Main.rand.Next(4, 7) : 6f; if (npc.ai[3] >= numCharges) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs index 8ece6740c8..b9facd07ba 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs @@ -872,7 +872,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.localAI[2] = 1f; npc.localAI[1] = 0f; - npc.TargetClosest(); } } else if (npc.localAI[1] > 45f && (canHit || masterModeDetach) && !charging) @@ -880,7 +879,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.localAI[1] = 0f; npc.localAI[2] += 1f; if (npc.localAI[2] >= TotalLasersPerBarrage + 1f) + { npc.localAI[2] = 0f; + npc.TargetClosest(); + } if (shouldFireLasers) { @@ -1348,10 +1350,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.npc[Main.wofNPCIndex].life > 0) npc.life = Main.npc[Main.wofNPCIndex].life; + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.target = Main.npc[Main.wofNPCIndex].target; + // Avoid cheap bullshit npc.damage = 0; - npc.TargetClosest(); npc.position.X = Main.npc[Main.wofNPCIndex].position.X; npc.direction = Main.npc[Main.wofNPCIndex].direction; npc.spriteDirection = npc.direction; @@ -1464,7 +1469,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.localAI[1] = 0f; npc.localAI[2] += 1f; if (npc.localAI[2] >= (float)num396) + { npc.localAI[2] = 0f; + npc.TargetClosest(); + } if (flag27) { diff --git a/Particles/DeathAshParticle.cs b/Particles/DeathAshParticle.cs index 58284da0b3..9687520e99 100644 --- a/Particles/DeathAshParticle.cs +++ b/Particles/DeathAshParticle.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Particles public Vector2 BottomRight => Center + Vector2.One * Scale * 3.5f; public Vector2 BottomLeft => Center + new Vector2(-1f, 1f) * Scale * 3.5f; - public static HashSet Ashes = new HashSet(); + public static HashSet Ashes = new(); public const int PrimitiveBatchSize = 256; public const int AshCountLimit = 45000; public static BasicEffect BasicShader diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index ddcc4ff9da..6791e8a9ed 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -6,6 +6,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ModLoader.Core; @@ -15,6 +16,7 @@ namespace CalamityMod.Particles public static class GeneralParticleHandler { private static List particles; + private static Queue particlesToSpawnNextFrame; //List containing the particles to delete private static List particlesToKill; //Static list for details concerning every particle type @@ -53,6 +55,7 @@ namespace CalamityMod.Particles internal static void Load() { particles = new List(); + particlesToSpawnNextFrame = new Queue(); particlesToKill = new List(); particleTypes = new Dictionary(); particleTextures = new Dictionary(); @@ -66,6 +69,7 @@ namespace CalamityMod.Particles internal static void Unload() { particles = null; + particlesToSpawnNextFrame = null; particlesToKill = null; particleTypes = null; particleTextures = null; @@ -82,8 +86,8 @@ namespace CalamityMod.Particles { // Don't queue particles if the game is paused. // This precedent is established with how Dust instances are created. - //Don't spawn particles if on the server side either, or if the particles dict is somehow null - if (Main.gamePaused || Main.dedServ || particles == null) + // Don't spawn particles if on the server either, or if the particles dictionary is somehow null. + if (Main.gamePaused || Main.netMode == NetmodeID.Server || particles == null) return; if (particles.Count >= CalamityConfig.Instance.ParticleLimit && !particle.Important) @@ -93,8 +97,22 @@ namespace CalamityMod.Particles particle.Type = particleTypes[particle.GetType()]; } + public static void QueueParticleForNextFrame(Particle particle) + { + // Don't queue particles if the game is paused. + // This precedent is established with how Dust instances are created. + // Don't spawn particles if on the server side, or if the particles dictionary is somehow null. + if (Main.gamePaused || Main.netMode == NetmodeID.Server || particles == null) + return; + + particlesToSpawnNextFrame.Enqueue(particle); + } + public static void Update() { + while (particlesToSpawnNextFrame.Count > 0) + SpawnParticle(particlesToSpawnNextFrame.Dequeue()); + foreach (Particle particle in particles) { if (particle == null) diff --git a/Particles/SemiCircularSmearFade.cs b/Particles/SemiCircularSmearFade.cs new file mode 100644 index 0000000000..8ee2296013 --- /dev/null +++ b/Particles/SemiCircularSmearFade.cs @@ -0,0 +1,59 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Particles +{ + public class SemiCircularSmearFade : Particle + { + public override string Texture => "CalamityMod/Particles/SemiCircularSmearVertical"; + public override bool UseAdditiveBlend => true; + public override bool UseCustomDraw => true; + public override bool SetLifetime => true; + public Player player = Main.player[Main.myPlayer]; + public Color InitialColor; + public bool PlayerCentered; + public bool RotateToVelocity; + public Vector2 Squish; + public bool ProduceLight; + public SemiCircularSmearFade(Vector2 position, Vector2 velocity, Color color, float rotation, float scale, Vector2 squish, int lifetime, bool playerCentered = false, bool rotateToVelocity = false, bool produceLight = true) + { + Position = position; + Velocity = velocity; + Color = InitialColor = color; + Scale = scale; + Squish = squish; + Rotation = rotation; + Lifetime = lifetime; + PlayerCentered = playerCentered; + RotateToVelocity = rotateToVelocity; + ProduceLight = produceLight; + + } + public override void Update() + { + if (PlayerCentered) + Position = player.MountedCenter; + if (RotateToVelocity) + Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + if (ProduceLight) + { + Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f); + } + + Scale *= 0.95f; + Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)); + Velocity *= 0.95f; + } + + //Use custom draw for the squish + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D tex = ModContent.Request(Texture).Value; + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color, Rotation, tex.Size() * 0.5f, Scale * Squish, 0, 0f); + } + } +} diff --git a/Particles/SemiCircularSmearVFX.cs b/Particles/SemiCircularSmearVFX.cs index d7ad76efb0..6fba683ae4 100644 --- a/Particles/SemiCircularSmearVFX.cs +++ b/Particles/SemiCircularSmearVFX.cs @@ -1,7 +1,9 @@ -using Microsoft.Xna.Framework; +using System; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; namespace CalamityMod.Particles { @@ -11,9 +13,11 @@ namespace CalamityMod.Particles public override bool UseAdditiveBlend => true; public override bool UseCustomDraw => true; public override bool SetLifetime => true; + public Player player = Main.player[Main.myPlayer]; + public bool PlayerCentered; public Vector2 Squish; - public SemiCircularSmearVFX(Vector2 position, Color color, float rotation, float scale, Vector2 squish) + public SemiCircularSmearVFX(Vector2 position, Color color, float rotation, float scale, Vector2 squish, bool playerCentered = false) { Position = position; Velocity = Vector2.Zero; @@ -22,6 +26,12 @@ namespace CalamityMod.Particles Squish = squish; Rotation = rotation; Lifetime = 2; + PlayerCentered = playerCentered; + } + public override void Update() + { + if (PlayerCentered) + Position = player.MountedCenter; } //Use custom draw for the squish diff --git a/Particles/WaterFoam.png b/Particles/WaterFoam.png new file mode 100644 index 0000000000..71ed6ff84b Binary files /dev/null and b/Particles/WaterFoam.png differ diff --git a/Particles/WaterFoamParticle.cs b/Particles/WaterFoamParticle.cs new file mode 100644 index 0000000000..3b873bed48 --- /dev/null +++ b/Particles/WaterFoamParticle.cs @@ -0,0 +1,62 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class WaterFoamParticle : Particle + { + public Color InitialColor; + public bool HasCreatedFoam = false; + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + public override bool UseAdditiveBlend => true; + + public override string Texture => "CalamityMod/Particles/WaterFoam"; + + public WaterFoamParticle(Vector2 relativePosition, Vector2 velocity, int lifetime, float scale, Color color) + { + Position = relativePosition; + Velocity = velocity; + Scale = scale; + Lifetime = lifetime; + Color = InitialColor = color; + Rotation = Main.rand.NextFloat(MathHelper.TwoPi); + } + + public override void Update() + { + Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 1.7D)); + + if (Collision.WetCollision(Position, 1, 1)) + { + if (!HasCreatedFoam) + { + Vector2 foamVelocity = Main.rand.NextVector2Circular(2f, 0.3f); + if (foamVelocity.Y < -0.2f) + foamVelocity.Y = -0.2f; + + // Spawning the particle directly will result in the particle list collection being modified prematurely within the update loop. + // Doing it the next frame results in a single-frame buffer, but that shouldn't really be a problem and it ensures that the loop is + // not interrupted in unanticipated ways. + GeneralParticleHandler.QueueParticleForNextFrame(new MediumMistParticle(Position, foamVelocity, Color.LightCyan * 0.6f, Color.White * 0.6f, 0.2f, 255f, 0.03f)); + HasCreatedFoam = true; + } + + Velocity.Y *= 0.7f; + Time += 4; + } + else + Velocity.Y = MathHelper.Clamp(Velocity.Y + 0.12f, -8f, 12f); + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + float brightness = (float)Math.Pow(Lighting.Brightness((int)(Position.X / 16f), (int)(Position.Y / 16f)), 0.15); + Texture2D texture = ModContent.Request(Texture).Value; + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color * brightness, Rotation, texture.Size() * 0.5f, Scale, 0, 0f); + } + } +} diff --git a/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs b/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs index ca12e9cbd7..48e3be1879 100644 --- a/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs @@ -2,6 +2,7 @@ using System.IO; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent; @@ -126,6 +127,8 @@ namespace CalamityMod.Projectiles.BaseProjectiles private Type AssociatedItemType => ItemLoader.GetItem(AssociatedItemID).GetType(); + private Asset ItemTexture => TextureAssets.Item[AssociatedItemID]; + #endregion #region Overridden Members @@ -138,18 +141,12 @@ namespace CalamityMod.Projectiles.BaseProjectiles public override void SetDefaults() { - Projectile.width = Projectile.height = TextureAssets.Item[AssociatedItemID].Width(); + Projectile.width = Projectile.height = ItemTexture is null ? 1 : ItemTexture.Width(); Projectile.tileCollide = false; Projectile.netImportant = true; } - public override void OnSpawn(IEntitySource source) - { - Owner = Main.player[Projectile.owner]; - OffsetLengthFromArm = MaxOffsetLengthFromArm; - HeldItem = Owner.ActiveItem(); - Projectile.velocity = Owner.Calamity().mouseWorld - Owner.RotatedRelativePoint(Owner.MountedCenter); - } + public override void OnSpawn(IEntitySource source) => OffsetLengthFromArm = MaxOffsetLengthFromArm; public override bool ShouldUpdatePosition() => false; @@ -161,6 +158,10 @@ namespace CalamityMod.Projectiles.BaseProjectiles public override void AI() { + // Multiplayer null-checking. + Owner ??= Main.player[Projectile.owner]; + HeldItem ??= Owner.ActiveItem(); + KillHoldoutLogic(); ManageHoldout(); HoldoutAI(); @@ -168,15 +169,12 @@ namespace CalamityMod.Projectiles.BaseProjectiles /// /// Here goes the code for when the holdout needs to despawn.
- /// Defaults to despawning when the owner isn't holding or isn't using the correspondent weapon. + /// Defaults to despawning when the owner isn't using the correspondent weapon. ///
public virtual void KillHoldoutLogic() { if (Owner.CantUseHoldout()) - { - Projectile.netUpdate = true; Projectile.Kill(); - } } /// @@ -222,6 +220,9 @@ namespace CalamityMod.Projectiles.BaseProjectiles if (OffsetLengthFromArm != MaxOffsetLengthFromArm) OffsetLengthFromArm = MathHelper.Lerp(OffsetLengthFromArm, MaxOffsetLengthFromArm, RecoilResolveSpeed); + + Projectile.netUpdate = true; + Projectile.netSpam = 0; } /// @@ -255,6 +256,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles writer.Write(Projectile.rotation); writer.Write(KeepRefreshingLifetime); writer.Write(OffsetLengthFromArm); + writer.Write7BitEncodedInt(Projectile.spriteDirection); SendExtraAIHoldout(writer); } @@ -263,6 +265,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles Projectile.rotation = reader.ReadSingle(); KeepRefreshingLifetime = reader.ReadBoolean(); OffsetLengthFromArm = reader.ReadSingle(); + Projectile.spriteDirection = reader.Read7BitEncodedInt(); ReceiveExtraAIHoldout(reader); } diff --git a/Projectiles/Boss/BrimstoneRay.cs b/Projectiles/Boss/BrimstoneRay.cs index 4630d227b5..7e18a2f859 100644 --- a/Projectiles/Boss/BrimstoneRay.cs +++ b/Projectiles/Boss/BrimstoneRay.cs @@ -124,7 +124,7 @@ namespace CalamityMod.Projectiles.Boss Vector2 fireFrom = new Vector2(Main.npc[(int)Projectile.ai[1]].Center.X + (Main.npc[(int)Projectile.ai[1]].spriteDirection > 0 ? 34f : -34f), Main.npc[(int)Projectile.ai[1]].Center.Y - 74f) + velocity * distanceBetweenProjectiles; int projectileAmt = (int)(Projectile.localAI[1] / distanceBetweenProjectiles); int type = ModContent.ProjectileType(); - int damage = Projectile.GetProjectileDamage(ModContent.NPCType()); + int damage = (int)Math.Round(Projectile.damage * 0.6); float projectileVelocityToPass = 12f; for (int i = 0; i < projectileAmt; i++) diff --git a/Projectiles/Boss/DarkEnergyBall.cs b/Projectiles/Boss/DarkEnergyBall.cs index 85a46e55e9..b9e79f2352 100644 --- a/Projectiles/Boss/DarkEnergyBall.cs +++ b/Projectiles/Boss/DarkEnergyBall.cs @@ -94,10 +94,8 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.Opacity == 1f) { - int debufftype = Main.zenithWorld ? BuffID.Obstructed : BuffID.VortexDebuff; - int duration = Main.zenithWorld ? 30 : 60; - if (info.Damage > 0) - target.AddBuff(debufftype, duration, true); + if (Main.zenithWorld) + target.AddBuff(BuffID.Obstructed, 30, true); } } diff --git a/Projectiles/Boss/DarkEnergyBall2.cs b/Projectiles/Boss/DarkEnergyBall2.cs index 8cf3a9e8b2..7ad6d26771 100644 --- a/Projectiles/Boss/DarkEnergyBall2.cs +++ b/Projectiles/Boss/DarkEnergyBall2.cs @@ -92,10 +92,8 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.Opacity == 1f) { - int debufftype = Main.zenithWorld ? BuffID.Obstructed : BuffID.VortexDebuff; - int duration = Main.zenithWorld ? 30 : 60; - if (info.Damage > 0) - target.AddBuff(debufftype, duration, true); + if (Main.zenithWorld) + target.AddBuff(BuffID.Obstructed, 30, true); } } diff --git a/Projectiles/Boss/HolyBlast.cs b/Projectiles/Boss/HolyBlast.cs index 6736fc4ea1..d6e09c41fd 100644 --- a/Projectiles/Boss/HolyBlast.cs +++ b/Projectiles/Boss/HolyBlast.cs @@ -58,6 +58,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/HolyBomb.cs b/Projectiles/Boss/HolyBomb.cs index 7bdb4af478..15ff7a1b48 100644 --- a/Projectiles/Boss/HolyBomb.cs +++ b/Projectiles/Boss/HolyBomb.cs @@ -47,6 +47,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/HolyBurnOrb.cs b/Projectiles/Boss/HolyBurnOrb.cs index 7509889518..b7bdb2c51b 100644 --- a/Projectiles/Boss/HolyBurnOrb.cs +++ b/Projectiles/Boss/HolyBurnOrb.cs @@ -41,6 +41,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/HolyFire.cs b/Projectiles/Boss/HolyFire.cs index 72a76cb870..0a19097430 100644 --- a/Projectiles/Boss/HolyFire.cs +++ b/Projectiles/Boss/HolyFire.cs @@ -42,6 +42,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/HolyFire2.cs b/Projectiles/Boss/HolyFire2.cs index d694d1753f..8e8c50642e 100644 --- a/Projectiles/Boss/HolyFire2.cs +++ b/Projectiles/Boss/HolyFire2.cs @@ -42,6 +42,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/HolyFlare.cs b/Projectiles/Boss/HolyFlare.cs index ce8b652245..1208b849ad 100644 --- a/Projectiles/Boss/HolyFlare.cs +++ b/Projectiles/Boss/HolyFlare.cs @@ -42,6 +42,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/HolySpear.cs b/Projectiles/Boss/HolySpear.cs index 03116c57ea..697dfa6c2a 100644 --- a/Projectiles/Boss/HolySpear.cs +++ b/Projectiles/Boss/HolySpear.cs @@ -61,6 +61,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/IceBomb.cs b/Projectiles/Boss/IceBomb.cs index d963860aff..ce60e05cb7 100644 --- a/Projectiles/Boss/IceBomb.cs +++ b/Projectiles/Boss/IceBomb.cs @@ -101,7 +101,9 @@ namespace CalamityMod.Projectiles.Boss { target.AddBuff(BuffID.Frostburn, 180, true); target.AddBuff(BuffID.Chilled, 90, true); - target.AddBuff(ModContent.BuffType(), 60); + + if (!target.Calamity().gState) + target.AddBuff(ModContent.BuffType(), 60); } } } diff --git a/Projectiles/Boss/InfernadoRevenge.cs b/Projectiles/Boss/InfernadoRevenge.cs index dfb8a4e429..bfc028fc5b 100644 --- a/Projectiles/Boss/InfernadoRevenge.cs +++ b/Projectiles/Boss/InfernadoRevenge.cs @@ -72,6 +72,8 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { + Main.spriteBatch.EnterShaderRegion(); + GameShaders.Misc["CalamityMod:Bordernado"].UseSaturation(-0.2f); GameShaders.Misc["CalamityMod:Bordernado"].SetShaderTexture(ModContent.Request("Terraria/Images/Misc/Perlin")); Vector2[] drawPoints = new Vector2[5]; @@ -86,6 +88,8 @@ namespace CalamityMod.Projectiles.Boss drawPoints[drawPoints.Length - 1] = bottom; PrimitiveRenderer.RenderTrail(drawPoints, new((_) => Projectile.width * 0.5f + 16f, ColorFunction, shader: GameShaders.Misc["CalamityMod:Bordernado"]), 85); + Main.spriteBatch.ExitShaderRegion(); + Texture2D vortexTexture = ModContent.Request("CalamityMod/Projectiles/Boss/OldDukeVortex").Value; for (int i = 0; i < 110; i++) { diff --git a/Projectiles/Boss/MoltenBlast.cs b/Projectiles/Boss/MoltenBlast.cs index f80225ae09..18ee564f3b 100644 --- a/Projectiles/Boss/MoltenBlast.cs +++ b/Projectiles/Boss/MoltenBlast.cs @@ -58,6 +58,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/MoltenBlob.cs b/Projectiles/Boss/MoltenBlob.cs index 2ff2619640..f0516d1376 100644 --- a/Projectiles/Boss/MoltenBlob.cs +++ b/Projectiles/Boss/MoltenBlob.cs @@ -39,6 +39,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/ProfanedSpear.cs b/Projectiles/Boss/ProfanedSpear.cs index 7187932d5e..f716020d87 100644 --- a/Projectiles/Boss/ProfanedSpear.cs +++ b/Projectiles/Boss/ProfanedSpear.cs @@ -1,6 +1,9 @@ using System; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; +using CalamityMod.NPCs.Providence; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -32,6 +35,17 @@ namespace CalamityMod.Projectiles.Boss { Lighting.AddLight(Projectile.Center, 0.45f, 0.35f, 0f); + if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } + if (Projectile.timeLeft < 510) Projectile.tileCollide = true; @@ -56,11 +70,14 @@ namespace CalamityMod.Projectiles.Boss public override Color? GetAlpha(Color lightColor) { - return new Color(250, 150, 0, Projectile.alpha); + return ProvUtils.GetProjectileColor(Projectile.maxPenetrate, Projectile.alpha); } public override bool PreDraw(ref Color lightColor) { + Texture2D texture = (Projectile.maxPenetrate == (int)Providence.BossMode.Day) ? Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value : ModContent.Request("CalamityMod/Projectiles/Boss/ProfanedSpearNight").Value; + Projectile.DrawBackglow(ProvUtils.GetProjectileColor(Projectile.maxPenetrate, Projectile.alpha, true), 4f, texture); + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, texture.Height / 2f), Projectile.scale, SpriteEffects.None, 0); CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); return false; } diff --git a/Projectiles/Boss/ProfanedSpearNight.png b/Projectiles/Boss/ProfanedSpearNight.png new file mode 100644 index 0000000000..712ed5b89d Binary files /dev/null and b/Projectiles/Boss/ProfanedSpearNight.png differ diff --git a/Projectiles/Boss/ProvidenceHolyRay.cs b/Projectiles/Boss/ProvidenceHolyRay.cs index 0a5609302b..fff9c36e64 100644 --- a/Projectiles/Boss/ProvidenceHolyRay.cs +++ b/Projectiles/Boss/ProvidenceHolyRay.cs @@ -55,6 +55,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/ShadeNimbusHostile.cs b/Projectiles/Boss/ShadeNimbusHostile.cs index 4c9005206e..9ebf0fb51a 100644 --- a/Projectiles/Boss/ShadeNimbusHostile.cs +++ b/Projectiles/Boss/ShadeNimbusHostile.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.ai[0] = 0f; int rainSpawnX = (int)(Projectile.position.X + 14f + (float)Main.rand.Next(Projectile.width - 28)); int rainSpawnY = (int)(Projectile.position.Y + (float)Projectile.height + 4f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)rainSpawnX, (float)rainSpawnY, 0f, 4f, ModContent.ProjectileType(), Projectile.damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)rainSpawnX, (float)rainSpawnY, 0f, 8f, ModContent.ProjectileType(), Projectile.damage, 0f, Main.myPlayer); } } } @@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Boss if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 360); + target.AddBuff(ModContent.BuffType(), 240); } } } diff --git a/Projectiles/Boss/ShaderainHostile.cs b/Projectiles/Boss/ShaderainHostile.cs index acb42b090b..8fd4a72096 100644 --- a/Projectiles/Boss/ShaderainHostile.cs +++ b/Projectiles/Boss/ShaderainHostile.cs @@ -9,19 +9,15 @@ namespace CalamityMod.Projectiles.Boss public class ShaderainHostile : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Boss"; + public override void SetDefaults() { Projectile.width = 4; Projectile.height = 40; Projectile.hostile = true; - Projectile.extraUpdates = 1; Projectile.penetrate = -1; Projectile.ignoreWater = true; Projectile.timeLeft = 300; - } - - public override void AI() - { Projectile.alpha = 50; } @@ -36,17 +32,14 @@ namespace CalamityMod.Projectiles.Boss dust.scale = 0.95f; } - public override Color? GetAlpha(Color lightColor) - { - return new Color(102, 255, 102, Projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(100, 255, 100, Projectile.alpha); public override void OnHitPlayer(Player target, Player.HurtInfo info) { if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 360); + target.AddBuff(ModContent.BuffType(), 120); } } } diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 45f9f892d1..27d65eacbf 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -603,7 +603,8 @@ namespace CalamityMod.Projectiles blood2.scale = 1.2f; blood2.position = projectile.Center + Main.rand.NextFloat() * projectile.velocity * 2f; - for (int j = 1; j < projectile.oldPos.Length && !(projectile.oldPos[j] == Vector2.Zero); j++) + int trailLength = projectile.oldPos.Length / 2; + for (int j = 1; j < trailLength && !(projectile.oldPos[j] == Vector2.Zero); j++) { if (Main.rand.NextBool(3)) { @@ -2153,8 +2154,8 @@ namespace CalamityMod.Projectiles int numDust = 5; int numDust2 = 5; int fadeInTime = 10; - int fadeOutGateValue = masterMode ? 80 : death ? 50 : 10; - float killGateValue = masterMode ? 90f : death ? 60f : 20f; + int fadeOutGateValue = masterMode ? 80 : death ? 50 : 25; + float killGateValue = masterMode ? 90f : death ? 60f : 35f; int maxFrames = 5; bool fadeIn = projectile.ai[0] < (float)fadeInTime; @@ -4280,7 +4281,7 @@ namespace CalamityMod.Projectiles if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { float fadeInTime = 10f; - float fadeOutGateValue = masterMode ? 80f : death ? 50f : 10f; + float fadeOutGateValue = masterMode ? 80f : death ? 50f : 25f; return (projectile.ai[0] >= fadeInTime && projectile.ai[0] < fadeOutGateValue); } break; @@ -4444,8 +4445,8 @@ namespace CalamityMod.Projectiles Vector2 origin12 = new Vector2(16f, value26.Height / 2); Color alpha5 = projectile.GetAlpha(lightColor); Vector2 vector39 = new Vector2(projectile.scale); - float fadeOutGateValue = masterMode ? 80f : death ? 50f : 10f; - float killGateValue = masterMode ? 90f : death ? 60f : 20f; + float fadeOutGateValue = masterMode ? 80f : death ? 50f : 25f; + float killGateValue = masterMode ? 90f : death ? 60f : 35f; float lerpValue5 = Utils.GetLerpValue(killGateValue, killGateValue - 10f, projectile.ai[0], clamped: true); vector39.Y *= lerpValue5; Vector4 vector40 = lightColor.ToVector4(); diff --git a/Projectiles/CalamityGlobalProjectileTweaks.cs b/Projectiles/CalamityGlobalProjectileTweaks.cs index 916a1412a8..d10155dc4f 100644 --- a/Projectiles/CalamityGlobalProjectileTweaks.cs +++ b/Projectiles/CalamityGlobalProjectileTweaks.cs @@ -116,7 +116,8 @@ namespace CalamityMod.Projectiles { ProjectileID.AdamantiteChainsaw, standardChainsawTweaks }, { ProjectileID.AdamantiteDrill, standardDrillTweaks }, { ProjectileID.Anchor, Do(ExtraUpdatesExact(1)) }, - { ProjectileID.Bee, Do(PiercingExact(2)) }, + { ProjectileID.Bee, Do(PiercingExact(2), ExtraUpdatesExact(2)) }, + { ProjectileID.BeeArrow, Do(PointBlank, ExtraUpdatesExact(1)) }, { ProjectileID.BlackCounterweight, counterweightTweaks }, { ProjectileID.BlueCounterweight, counterweightTweaks }, { ProjectileID.BlueMoon, Do(ExtraUpdatesExact(1)) }, @@ -153,7 +154,7 @@ namespace CalamityMod.Projectiles { ProjectileID.FlyingKnife, Do(ExtraUpdatesExact(1)) }, { ProjectileID.FrostBoltStaff, Do(ExtraUpdatesExact(1)) }, { ProjectileID.FruitcakeChakram, Do(ExtraUpdatesExact(1)) }, - { ProjectileID.GiantBee, Do(PiercingExact(2)) }, + { ProjectileID.GiantBee, Do(PiercingExact(2), ExtraUpdatesExact(2)) }, { ProjectileID.GoldenBullet, standardBulletTweaks }, { ProjectileID.GoldenShowerFriendly, Do(PiercingExact(2)) }, { ProjectileID.GreenCounterweight, counterweightTweaks }, @@ -209,6 +210,7 @@ namespace CalamityMod.Projectiles { ProjectileID.VenomFang, Do(LocalIFrames(10)) }, { ProjectileID.VortexDrill, standardDrillTweaks }, { ProjectileID.Wasp, Do(PiercingExact(2)) }, + { ProjectileID.WeatherPainShot, Do(ExtraUpdatesExact(2), TimeLeftExact(1400)) }, { ProjectileID.YellowCounterweight, counterweightTweaks }, #endregion @@ -251,7 +253,6 @@ namespace CalamityMod.Projectiles #endregion #region CATEGORY 4: Point Blank support - { ProjectileID.BeeArrow, pointBlank }, { ProjectileID.Blizzard, pointBlank }, // Blizzard Staff projectiles, re-used in Frostbite Blaster. { ProjectileID.BlueFlare, pointBlank }, { ProjectileID.BoneArrow, pointBlank }, @@ -268,8 +269,8 @@ namespace CalamityMod.Projectiles { ProjectileID.Flare, pointBlank }, { ProjectileID.FrostburnArrow, pointBlank }, { ProjectileID.Harpoon, pointBlank }, - { ProjectileID.HellfireArrow, pointBlank }, { ProjectileID.Hellwing, pointBlank }, + { ProjectileID.HellfireArrow, pointBlank }, { ProjectileID.HolyArrow, pointBlank }, { ProjectileID.IchorArrow, pointBlank }, { ProjectileID.JestersArrow, pointBlank }, diff --git a/Projectiles/Environment/Lilyglow.cs b/Projectiles/Environment/Lilyglow.cs new file mode 100644 index 0000000000..b984a03d89 --- /dev/null +++ b/Projectiles/Environment/Lilyglow.cs @@ -0,0 +1,61 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Environment +{ + public class Lilyglow : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public ref float Direction => ref Projectile.ai[0]; + + public override void SetDefaults() + { + Projectile.width = 360; + Projectile.height = 360; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.timeLeft = 600; + Projectile.penetrate = 1; + Projectile.scale = Main.rand?.NextFloat(0.02f, 0.035f) ?? 0.03f; + Projectile.Size /= Projectile.scale; + } + + public override void AI() + { + Projectile.Opacity = Utils.GetLerpValue(0f, 120f, Projectile.timeLeft, true) * Utils.GetLerpValue(600f, 540f, Projectile.timeLeft, true); + if (Projectile.timeLeft < 60f) + Projectile.scale *= 0.98f; + + // Oh? You're inside of blocks? DIEDIEDIEDIEDIEDIE + if (Collision.SolidCollision(Projectile.Center, 1, 1)) + Projectile.timeLeft -= 8; + + Projectile.Size = Vector2.One * 360f; + Projectile.hide = Projectile.Opacity < 0.15f; + + // Rotate around. + Projectile.velocity = Projectile.velocity.RotatedBy((float)Math.Cos(Projectile.timeLeft / 33f + Projectile.identity) * 0.0283f); + + Point left = (Projectile.Center - Vector2.UnitX * 24f).ToTileCoordinates(); + Point right = (Projectile.Center + Vector2.UnitX * 24f).ToTileCoordinates(); + Point top = (Projectile.Center - Vector2.UnitY * 24f).ToTileCoordinates(); + Point bottom = (Projectile.Center + Vector2.UnitY * 24f).ToTileCoordinates(); + + DelegateMethods.v3_1 = Projectile.GetAlpha(Color.White).ToVector3(); + Utils.PlotLine(left, right, DelegateMethods.CastLight); + Utils.PlotLine(top, bottom, DelegateMethods.CastLight); + } + + public override Color? GetAlpha(Color lightColor) + { + float fadeToPink = (float)Math.Pow(Projectile.identity % 8f / 8f, 0.93); + Color c = Color.Lerp(Color.Yellow, new Color(255, 110, 105), fadeToPink) * Projectile.Opacity; + c.A = (byte)Projectile.alpha; + return c; + } + } +} diff --git a/Projectiles/Environment/WaterAlgae.cs b/Projectiles/Environment/WaterAlgae.cs new file mode 100644 index 0000000000..d28cbb522b --- /dev/null +++ b/Projectiles/Environment/WaterAlgae.cs @@ -0,0 +1,66 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Environment +{ + public class WaterAlgae : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Misc"; + + public ref float Direction => ref Projectile.ai[0]; + public override void SetStaticDefaults() + { + Main.projFrames[Projectile.type] = 3; + ProjectileID.Sets.CanDistortWater[Projectile.type] = false; + } + + public override void SetDefaults() + { + Projectile.width = 12; + Projectile.height = 12; + Projectile.ignoreWater = true; + Projectile.timeLeft = 720; + Projectile.penetrate = 1; + Projectile.scale = Main.rand?.NextFloat(0.4f, 0.75f) ?? 1f; + Projectile.hide = true; + } + + public override void AI() + { + Projectile.Opacity = Utils.GetLerpValue(0f, 120f, Projectile.timeLeft, true) * Utils.GetLerpValue(720f, 660f, Projectile.timeLeft, true); + Projectile.hide = Projectile.Opacity < 0.2f; + if (Projectile.localAI[0] == 0f) + { + Projectile.frame = Main.rand.Next(Main.projFrames[Projectile.type]); + Projectile.localAI[0] = 1f; + } + + if (Collision.WetCollision(Projectile.position, Projectile.width, Projectile.height)) + { + if (Direction == 0f) + Direction = Projectile.identity % 2; + if (Collision.SolidCollision(Projectile.Center + Vector2.UnitX * Direction * 100f, 1, 1)) + Direction *= -1f; + + Projectile.velocity.X = MathHelper.Lerp(Projectile.velocity.X, Direction * MathHelper.Lerp(0.3f, 0.7f, Projectile.identity % 9f / 9f), 0.025f); + Projectile.velocity.Y = MathHelper.Clamp(Projectile.velocity.Y - 0.008f, -0.4f, 0.4f); + } + else + { + Projectile.velocity.X *= 0.985f; + Projectile.velocity.Y = MathHelper.Clamp(Projectile.velocity.Y + 0.1f, -1f, 5f); + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.velocity.X *= 0.5f; + if (Projectile.timeLeft > 210) + Projectile.timeLeft = 210; + + return false; + } + } +} diff --git a/Projectiles/Environment/WaterAlgae.png b/Projectiles/Environment/WaterAlgae.png new file mode 100644 index 0000000000..e6a4ac5636 Binary files /dev/null and b/Projectiles/Environment/WaterAlgae.png differ diff --git a/Projectiles/Healing/ManaPolarizerHealOrb.cs b/Projectiles/Healing/ManaPolarizerHealOrb.cs index 373c1b9518..c2dbdacf55 100644 --- a/Projectiles/Healing/ManaPolarizerHealOrb.cs +++ b/Projectiles/Healing/ManaPolarizerHealOrb.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 3f, 15f); + Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 4f, 15f); int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.SpectreStaff, 0f, 0f, 100); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 0f; diff --git a/Projectiles/Magic/AetherfluxCannonHoldout.cs b/Projectiles/Magic/AetherfluxCannonHoldout.cs index 94e57a3010..69891cace5 100644 --- a/Projectiles/Magic/AetherfluxCannonHoldout.cs +++ b/Projectiles/Magic/AetherfluxCannonHoldout.cs @@ -1,65 +1,53 @@ using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class AetherfluxCannonHoldout : ModProjectile + public class AetherfluxCannonHoldout : BaseGunHoldoutProjectile { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - private const int FramesPerFireRateIncrease = 36; - - private Player Owner => Main.player[Projectile.owner]; + public override int AssociatedItemID => ModContent.ItemType(); + public override float MaxOffsetLengthFromArm => 10f; + public override float OffsetXUpwards => -15f; + public override float OffsetXDownwards => 10f; + public override float BaseOffsetY => -15f; + public override float OffsetYUpwards => 8f; + public override float OffsetYDownwards => 15f; + public override string Texture => "CalamityMod/Projectiles/Magic/AetherfluxCannonHoldout"; private ref float DeployedFrames => ref Projectile.ai[0]; private ref float AnimationRate => ref Projectile.ai[1]; private ref float LastShootAttemptTime => ref Projectile.localAI[0]; private ref float LastAnimationTime => ref Projectile.localAI[1]; - public override void SetStaticDefaults() - { - Main.projFrames[Projectile.type] = 8; - } + public override void SetStaticDefaults() => Main.projFrames[Type] = 8; - public override void SetDefaults() + public override void KillHoldoutLogic() { - Projectile.width = 58; - Projectile.height = 94; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Magic; - } - - public override void AI() - { - Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); - Vector2 gunBarrelPos = armPosition + Projectile.velocity * Projectile.height * 0.4f; - - // If the player is unable to continue using the holdout, delete it. - if (Owner.CantUseHoldout() || !Owner.HasAmmo(Owner.ActiveItem())) - { + base.KillHoldoutLogic(); + bool actuallyShoot = DeployedFrames >= (HeldItem?.useAnimation ?? AetherfluxCannon.UseTime); + bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.ActiveItem()); + if (!manaOK) Projectile.Kill(); - return; - } + } + public override void HoldoutAI() + { // Play a sound frame 1. if (DeployedFrames <= 0f) - { SoundEngine.PlaySound(SoundID.DD2_DarkMageCastHeal with { Volume = SoundID.DD2_DarkMageCastHeal.Volume * 1.5f }, Projectile.Center); - } // Update damage based on curent magic damage stat (so Mana Sickness affects it) - Item weaponItem = Owner.ActiveItem(); - Projectile.damage = weaponItem is null ? 0 : Owner.GetWeaponDamage(weaponItem); + Projectile.damage = HeldItem is null ? 0 : Owner.GetWeaponDamage(HeldItem); // Get the original weapon's use time. - int itemUseTime = weaponItem?.useAnimation ?? AetherfluxCannon.UseTime; + int itemUseTime = HeldItem?.useAnimation ?? AetherfluxCannon.UseTime; // 36, base use time, will result in 5. Speed increasing reforges push it to 4. int framesPerShot = itemUseTime / 7; @@ -73,7 +61,7 @@ namespace CalamityMod.Projectiles.Magic if (DeployedFrames - LastAnimationTime >= AnimationRate) { LastAnimationTime = DeployedFrames; - Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Projectile.type]; + Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Type]; } // Once past the initial spin-up time, fire constantly as long as mana is available. @@ -89,7 +77,7 @@ namespace CalamityMod.Projectiles.Magic SoundEngine.PlaySound(SoundID.Item91, Projectile.Center); int projID = ModContent.ProjectileType(); - float shootSpeed = weaponItem.shootSpeed; + float shootSpeed = HeldItem.shootSpeed; Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.UnitY); Vector2 shootVelocity = shootDirection * shootSpeed; @@ -102,67 +90,24 @@ namespace CalamityMod.Projectiles.Magic for (int i = -1; i <= 1; i += 2) { - Vector2 laserStartPos = gunBarrelPos + i * perp + Main.rand.NextVector2CircularEdge(6f, 6f); + Vector2 laserStartPos = GunTipPosition + i * perp + Main.rand.NextVector2CircularEdge(6f, 6f); Vector2 dustOnlySpread = Main.rand.NextVector2Circular(shootSpeed, shootSpeed); Vector2 dustVelocity = shootVelocity + dustInaccuracy * dustOnlySpread; - if (actuallyShoot) - { - Projectile godRay = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), laserStartPos, shootVelocity, projID, Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - // Tell this Phased God Ray exactly which way it should be waving. - godRay.localAI[1] = i * 0.5f; - } - SpawnFiringDust(gunBarrelPos, dustVelocity); + if (actuallyShoot && Main.myPlayer == Projectile.owner) + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), laserStartPos, shootVelocity, projID, Projectile.damage, Projectile.knockBack, Projectile.owner, i * 0.5f); + SpawnFiringDust(GunTipPosition, dustVelocity); } } - - // Delete the laser gun if a mana cost cannot be paid. - else - { - Projectile.Kill(); - return; - } } - - UpdateProjectileHeldVariables(armPosition); - ManipulatePlayerVariables(); } - private void UpdateProjectileHeldVariables(Vector2 armPosition) - { - if (Main.myPlayer == Projectile.owner) - { - float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); - Vector2 oldVelocity = Projectile.velocity; - Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); - if (Projectile.velocity != oldVelocity) - { - Projectile.netSpam = 0; - Projectile.netUpdate = true; - } - } - - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - Projectile.Center = armPosition + Projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction) * 8f; - Projectile.spriteDirection = Projectile.direction; - Projectile.timeLeft = 2; - } - - private void ManipulatePlayerVariables() - { - Owner.ChangeDir(Projectile.direction); - Owner.heldProj = Projectile.whoAmI; - Owner.itemTime = 2; - Owner.itemAnimation = 2; - Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); - } - - private void SpawnFiringDust(Vector2 gunBarrelPos, Vector2 laserVelocity) + private void SpawnFiringDust(Vector2 GunTipPosition, Vector2 laserVelocity) { int dustID = 133; int dustRadius = 12; float dustRandomness = 11f; int dustDiameter = 2 * dustRadius; - Vector2 dustCorner = gunBarrelPos - Vector2.One * dustRadius; + Vector2 dustCorner = GunTipPosition - Vector2.One * dustRadius; for (int i = 0; i < 2; i++) { Vector2 dustVel = laserVelocity + Main.rand.NextVector2Circular(dustRandomness, dustRandomness); @@ -173,9 +118,18 @@ namespace CalamityMod.Projectiles.Magic } } - public override bool? CanDamage() => false; + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(verticalFrames: Main.projFrames[Type], frameY: Projectile.frame); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f) + MathHelper.PiOver2; + Vector2 rotationPoint = frame.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipVertically : SpriteEffects.None; - // prevents the item from appearing backwards frame 1 - public override bool PreDraw(ref Color lightColor) => FramesPerFireRateIncrease > 0f; + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + + return false; + } } } diff --git a/Projectiles/Magic/CauldronHoldout.cs b/Projectiles/Magic/CauldronHoldout.cs new file mode 100644 index 0000000000..80d327c3ef --- /dev/null +++ b/Projectiles/Magic/CauldronHoldout.cs @@ -0,0 +1,127 @@ +using System; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Projectiles.Magic +{ + public class CauldronHoldout : ModProjectile, ILocalizedModType + { + public override LocalizedText DisplayName => GetItemName(); + + public override string Texture => "CalamityMod/Items/Weapons/Magic/TheCauldron"; + + public static int FireRate = 60; + + public override void SetDefaults() + { + Projectile.width = 46; + Projectile.height = 46; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.DamageType = DamageClass.Magic; + Projectile.ignoreWater = true; + } + public override void AI() + { + Player player = Main.player[Projectile.owner]; + float rotoffset = MathHelper.PiOver4; + Vector2 playerpos = player.RotatedRelativePoint(player.MountedCenter, true); + bool shouldBeHeld = !player.CantUseHoldout(); + Projectile.damage = player.ActiveItem() is null ? 0 : player.GetWeaponDamage(player.ActiveItem()); + if (Projectile.ai[0] > 0f) + { + Projectile.ai[0] -= 1f; + } + if (Main.myPlayer == Projectile.owner) + { + if (shouldBeHeld) + { + float holdscale = player.ActiveItem().shootSpeed * Projectile.scale; + Vector2 playerpos2 = playerpos; + Vector2 going = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - Projectile.Center; + if (player.gravDir == -1f) + { + going.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - Projectile.Center.Y; + } + Vector2 normalizedgoing = Vector2.Normalize(going); + if (float.IsNaN(normalizedgoing.X) || float.IsNaN(normalizedgoing.Y)) + { + normalizedgoing = -Vector2.UnitY; + } + normalizedgoing *= holdscale; + if (normalizedgoing.X != Projectile.velocity.X || normalizedgoing.Y != Projectile.velocity.Y) + { + Projectile.netUpdate = true; + } + Projectile.velocity = normalizedgoing * 0.55f; + + if (Projectile.ai[0] <= 0) + { + bool manaCostPaid = player.CheckMana(player.ActiveItem(), -1, true, false); + if (manaCostPaid) + { + SoundEngine.PlaySound(SoundID.DD2_BetsyFireballShot, Projectile.Center); + + int projType = ModContent.ProjectileType(); + int projDamage = Projectile.damage; + float speedscale = 18f; + Vector2 shotSpeed = Vector2.Normalize(Projectile.velocity) * speedscale; + if (float.IsNaN(shotSpeed.X) || float.IsNaN(shotSpeed.Y)) + { + shotSpeed = -Vector2.UnitY; + } + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, shotSpeed, projType, projDamage, Projectile.knockBack, player.whoAmI); + + for (int i = 0; i < 6; i++) + { + Vector2 burstSpeed = (Projectile.rotation - rotoffset).ToRotationVector2().RotatedByRandom(MathHelper.ToRadians(45f)) * Main.rand.NextFloat(8f, 14f); + SquishyLightParticle energy = new(Projectile.Center + Projectile.rotation.ToRotationVector2() * 5, burstSpeed, Main.rand.NextFloat(0.2f, 0.3f), Color.Orange, Main.rand.Next(6, 11), 3, 1.5f); + GeneralParticleHandler.SpawnParticle(energy); + } + Projectile.ai[0] = FireRate; + } + else + { + Projectile.Kill(); + } + } + } + else + { + Projectile.Kill(); + } + } + Projectile.Center = player.RotatedRelativePoint(player.MountedCenter, true) - new Vector2(player.direction == 1 ? 6 : 0, 30); + Projectile.rotation = Projectile.velocity.ToRotation() + rotoffset; + Projectile.spriteDirection = Projectile.direction; + Projectile.timeLeft = 2; + player.ChangeDir(Projectile.direction); + player.heldProj = Projectile.whoAmI; + player.itemTime = 2; + player.itemAnimation = 2; + player.itemRotation = (float)Math.Atan2((double)(Projectile.velocity.Y * (float)Projectile.direction), (double)(Projectile.velocity.X * (float)Projectile.direction)); + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, MathHelper.Pi); + player.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, MathHelper.Pi); + } + + public override bool? CanDamage() => false; + + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = TextureAssets.Projectile[Type].Value; + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2, Projectile.scale, SpriteEffects.None, 0); + Main.EntitySpriteDraw(TheCauldron.Glow.Value, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, tex.Size() / 2, Projectile.scale, SpriteEffects.None, 0); + return false; + } + } +} diff --git a/Projectiles/Magic/CauldronProj.cs b/Projectiles/Magic/CauldronProj.cs new file mode 100644 index 0000000000..4c6b92ca08 --- /dev/null +++ b/Projectiles/Magic/CauldronProj.cs @@ -0,0 +1,105 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class CauldronProj : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + + public static Asset Glow; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 5; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + if (!Main.dedServ) + { + Glow = ModContent.Request(Texture + "Glow"); + } + } + + public override void SetDefaults() + { + Projectile.width = 28; + Projectile.height = 28; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.penetrate = 1; + Projectile.timeLeft = 180; + Projectile.DamageType = DamageClass.Magic; + } + public override void AI() + { + Projectile.ai[0] += 1f; + if (Projectile.ai[0] > 10f) + { + Projectile.ai[0] = 10f; + if (Projectile.velocity.Y == 0f && Projectile.velocity.X != 0f) + { + Projectile.velocity.X = Projectile.velocity.X * 0.97f; + if (Projectile.velocity.X > -0.01f && Projectile.velocity.X < 0.01f) + { + Projectile.velocity.X = 0f; + Projectile.netUpdate = true; + } + } + Projectile.velocity.Y += 0.4f; + } + Projectile.ai[1] += 1f; + if (Projectile.ai[1] > 3) + { + Projectile.tileCollide = true; + } + Projectile.rotation += Projectile.velocity.X * 0.05f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Torch, Scale: Main.rand.NextFloat(1f, 1.4f)); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0f; + } + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(SoundID.DD2_ExplosiveTrapExplode, Projectile.Center); + Projectile.ExpandHitboxBy(128); + Projectile.maxPenetrate = -1; + Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + Projectile.damage = (int)(Projectile.damage * 0.66f); + Projectile.Damage(); + if (Projectile.owner == Main.myPlayer) + { + for (int i = 0; i < 3; i++) + { + Vector2 smauldronSpeed = (Vector2.UnitY * Main.rand.NextFloat(-10f, -8f)).RotatedByRandom(MathHelper.ToRadians(30f)); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, smauldronSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 3f, Projectile.owner); // 33% damage + } + } + for (int i = 0; i < 40; i++) + { + int size = 16; + Vector2 position = Projectile.Center; + Vector2 velocity = Main.rand.NextVector2Circular(size, size); + SquishyLightParticle energy = new(position, velocity, Main.rand.NextFloat(0.2f, 0.3f), Color.Orange, Main.rand.Next(6, 9), 1, 1.5f); + GeneralParticleHandler.SpawnParticle(energy); + Dust dust = Dust.NewDustPerfect(position, DustID.Torch, velocity, 0, default, Main.rand.NextFloat(1f, 2f)); + dust.noGravity = true; + } + } + + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 2); + Vector2 origin = Glow.Value.Size() / 2f; + Main.EntitySpriteDraw(Glow.Value, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + return false; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.OnFire3, 90); + + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.OnFire3, 90); + } +} diff --git a/Projectiles/Magic/CauldronProj.png b/Projectiles/Magic/CauldronProj.png new file mode 100644 index 0000000000..f50600398a Binary files /dev/null and b/Projectiles/Magic/CauldronProj.png differ diff --git a/Projectiles/Magic/CauldronProjGlow.png b/Projectiles/Magic/CauldronProjGlow.png new file mode 100644 index 0000000000..41b8852012 Binary files /dev/null and b/Projectiles/Magic/CauldronProjGlow.png differ diff --git a/Projectiles/Magic/CauldronProjSmall.cs b/Projectiles/Magic/CauldronProjSmall.cs new file mode 100644 index 0000000000..e3d01d3509 --- /dev/null +++ b/Projectiles/Magic/CauldronProjSmall.cs @@ -0,0 +1,93 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class CauldronProjSmall : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + + public static Asset Glow; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 5; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + if (!Main.dedServ) + { + Glow = ModContent.Request(Texture + "Glow"); + } + } + + public override void SetDefaults() + { + Projectile.width = 14; + Projectile.height = 14; + Projectile.friendly = true; + Projectile.penetrate = 1; + Projectile.timeLeft = 120; + Projectile.DamageType = DamageClass.Magic; + } + public override void AI() + { + Projectile.ai[0] += 1f; + if (Projectile.ai[0] > 8f) + { + Projectile.ai[0] = 8f; + if (Projectile.velocity.Y == 0f && Projectile.velocity.X != 0f) + { + Projectile.velocity.X = Projectile.velocity.X * 0.97f; + if (Projectile.velocity.X > -0.01f && Projectile.velocity.X < 0.01f) + { + Projectile.velocity.X = 0f; + Projectile.netUpdate = true; + } + } + Projectile.velocity.Y += 0.38f; + } + Projectile.rotation += Projectile.velocity.X * 0.05f; + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Torch, Scale: Main.rand.NextFloat(0.6f, 0.8f)); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 0f; + } + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(SoundID.DD2_ExplosiveTrapExplode with { Pitch = 0.8f, Volume = 0.6f }, Projectile.Center); + Projectile.ExpandHitboxBy(46); + Projectile.maxPenetrate = -1; + Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + Projectile.damage /= 2; + Projectile.Damage(); + for (int i = 0; i < 10; i++) + { + int size = 10; + Vector2 position = Projectile.Center; + Vector2 velocity = Main.rand.NextVector2Circular(size, size); + SquishyLightParticle energy = new(position, velocity, Main.rand.NextFloat(0.1f, 0.2f), Color.Orange, Main.rand.Next(5, 8), 1, 1.5f); + GeneralParticleHandler.SpawnParticle(energy); + Dust dust = Dust.NewDustPerfect(position, DustID.Torch, velocity, 0, default, Main.rand.NextFloat(0.8f, 1.2f)); + dust.noGravity = true; + } + } + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 2); + Vector2 origin = Glow.Value.Size() / 2f; + Main.EntitySpriteDraw(Glow.Value, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + return false; + } + + public override bool? CanDamage() => Projectile.velocity.Y < 0f ? false : null; + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.OnFire3, 90); + + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.OnFire3, 90); + } +} diff --git a/Projectiles/Magic/CauldronProjSmall.png b/Projectiles/Magic/CauldronProjSmall.png new file mode 100644 index 0000000000..feac67f62f Binary files /dev/null and b/Projectiles/Magic/CauldronProjSmall.png differ diff --git a/Projectiles/Magic/CauldronProjSmallGlow.png b/Projectiles/Magic/CauldronProjSmallGlow.png new file mode 100644 index 0000000000..d9d146d319 Binary files /dev/null and b/Projectiles/Magic/CauldronProjSmallGlow.png differ diff --git a/Projectiles/Magic/GenesisBeam.cs b/Projectiles/Magic/GenesisBeam.cs index 9a2a2167fd..1290158ebd 100644 --- a/Projectiles/Magic/GenesisBeam.cs +++ b/Projectiles/Magic/GenesisBeam.cs @@ -2,8 +2,8 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; +using Terraria.WorldBuilding; namespace CalamityMod.Projectiles.Magic { @@ -11,11 +11,17 @@ namespace CalamityMod.Projectiles.Magic { public new string LocalizationCategory => "Projectiles.Magic"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public ref float time => ref Projectile.ai[0]; - public ref float isSplit => ref Projectile.ai[1]; - public bool splitShot = false; - public Color mainColor = Color.MediumSlateBlue; + public ref float Time => ref Projectile.ai[0]; + public ref float IsSplit => ref Projectile.ai[1]; + public bool SplitShot + { + get => Projectile.ai[2] == 1f; + set => Projectile.ai[2] = value == true ? 1f : 0f; + } + + public Color MainColor { get; set; } = Color.MediumSlateBlue; + public override void SetDefaults() { Projectile.width = 12; @@ -26,54 +32,57 @@ namespace CalamityMod.Projectiles.Magic Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 31; Projectile.penetrate = -1; - Projectile.extraUpdates = 75; + Projectile.extraUpdates = 10; Projectile.timeLeft = 20; } + public override void AI() { - if (isSplit == 0) + if (IsSplit == 0) + SplitShot = true; + + if (Time == 0) { - Projectile.netUpdate = true; - splitShot = true; - } - if (time == 0) - { - if (splitShot) + if (SplitShot) Projectile.penetrate = 1; else Projectile.timeLeft = 50; } - if (Projectile.timeLeft % 2 == 0 && (!splitShot && time > 2 || (splitShot && time > 3 && Projectile.timeLeft > 2))) + if (Projectile.timeLeft < (SplitShot ? 20 : 50)) { - Particle spark = new GlowSparkParticle(Projectile.Center, -Projectile.velocity * 0.05f, false, 17, 0.06f, mainColor, new Vector2(0.5f, 1.3f)); + Particle spark = new GlowSparkParticle(Projectile.Center, -Projectile.velocity * 0.05f, false, 17, 0.06f, MainColor, new Vector2(0.5f, 1.3f)); GeneralParticleHandler.SpawnParticle(spark); } Vector2 dustVel = new Vector2(2, 2).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.8f); Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel, Main.rand.NextBool(4) ? 264 : 66, dustVel, 0, default, Main.rand.NextFloat(0.9f, 1.2f)); dust.noGravity = true; - dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; + dust.color = Main.rand.NextBool() ? Color.Lerp(MainColor, Color.White, 0.5f) : MainColor; - time++; + Time++; } + public override void OnKill(int timeLeft) { int numProj = 2; float rotation = MathHelper.ToRadians(12); - if (splitShot) + if (SplitShot) { for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = Projectile.velocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 1f); - for (int k = 0; k < 3; k++) - { - Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, mainColor, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.5f, 0.4f, 35); - GeneralParticleHandler.SpawnParticle(blastRing); - Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.4f, 0.3f, 35); - GeneralParticleHandler.SpawnParticle(blastRing2); - } + + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 1f); + } + + for (int k = 0; k < 3; k++) + { + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, MainColor, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.5f, 0.4f, 35); + GeneralParticleHandler.SpawnParticle(blastRing); + Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.4f, 0.3f, 35); + GeneralParticleHandler.SpawnParticle(blastRing2); } for (int i = 0; i < 20; i++) @@ -81,7 +90,7 @@ namespace CalamityMod.Projectiles.Magic Vector2 dustVel = new Vector2(13, 13).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.8f); Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel, Main.rand.NextBool(4) ? 264 : 66, dustVel, 0, default, Main.rand.NextFloat(0.9f, 1.2f)); dust.noGravity = true; - dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; + dust.color = Main.rand.NextBool() ? Color.Lerp(MainColor, Color.White, 0.5f) : MainColor; } } else @@ -91,16 +100,18 @@ namespace CalamityMod.Projectiles.Magic Vector2 dustVel = Projectile.velocity * Main.rand.NextFloat(0.1f, 1.5f); Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel + Main.rand.NextVector2Circular(6, 6), Main.rand.NextBool(4) ? 264 : 66, dustVel, 0, default, Main.rand.NextFloat(0.9f, 1.2f)); dust.noGravity = true; - dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; + dust.color = Main.rand.NextBool() ? Color.Lerp(MainColor, Color.White, 0.5f) : MainColor; } } - } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - if (splitShot) // This is the sweet spot - { - modifiers.SourceDamage *= 1.5f; + Projectile.netSpam = 0; + Projectile.netUpdate = true; + } + + public void OnHitEffects() + { + if (SplitShot) // This is the sweet spot + { int points = 10; float radians = MathHelper.TwoPi / points; Vector2 spinningPoint = Vector2.Normalize(new Vector2(-1f, -1f)); @@ -108,13 +119,24 @@ namespace CalamityMod.Projectiles.Magic for (int k = 0; k < points; k++) { Vector2 velocity = spinningPoint.RotatedBy(radians * k).RotatedBy(-0.45f * rotRando); - Particle subTrail = new GlowSparkParticle(Projectile.Center + velocity * 10.5f, velocity * 5, false, 10, 0.045f, mainColor, new Vector2(2, 0.4f), true); + Particle subTrail = new GlowSparkParticle(Projectile.Center + velocity * 10.5f, velocity * 5, false, 10, 0.045f, MainColor, new Vector2(2, 0.4f), true); GeneralParticleHandler.SpawnParticle(subTrail); } SoundStyle fire = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeImpact"); SoundEngine.PlaySound(fire with { Volume = 1.25f, Pitch = 0.4f, PitchVariance = 0.15f }, Projectile.Center); } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => OnHitEffects(); + + public override void OnHitPlayer(Player target, Player.HurtInfo info) => OnHitEffects(); + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (SplitShot) + modifiers.SourceDamage *= 1.5f; + if (Projectile.numHits > 0) Projectile.damage = (int)(Projectile.damage * 0.95f); if (Projectile.damage < 1) diff --git a/Projectiles/Magic/GenesisHoldout.cs b/Projectiles/Magic/GenesisHoldout.cs index 65385f8a61..d0d83c08e1 100644 --- a/Projectiles/Magic/GenesisHoldout.cs +++ b/Projectiles/Magic/GenesisHoldout.cs @@ -34,23 +34,21 @@ namespace CalamityMod.Projectiles.Magic public override void KillHoldoutLogic() { if (HeldItem.type != Owner.ActiveItem().type || Owner.CantUseHoldout()) - { Projectile.Kill(); - Projectile.netUpdate = true; - } } public override void HoldoutAI() { if (ShootingTimer >= FireRate) { - if (Owner.CheckMana(Owner.ActiveItem(), -1, true, false)) + if (Owner.CheckMana(HeldItem, -1, true, false)) { + MaxFirerateShots++; + if (MaxFirerateShots == 6f) { FireYBeam = true; Windup = 60f; - Projectile.netUpdate = true; } if (FireYBeam) @@ -61,6 +59,8 @@ namespace CalamityMod.Projectiles.Magic else Shoot(false); + ShootingTimer = 0f; + if (Windup > 10f) { if (!FireYBeam) @@ -69,22 +69,19 @@ namespace CalamityMod.Projectiles.Magic else Windup = 10f; - MaxFirerateShots++; - ShootingTimer = 0f; FireYBeam = false; } else { SoundEngine.PlaySound(SoundID.MaxMana with { Pitch = -0.5f }, Projectile.Center); Projectile.Kill(); - Projectile.netUpdate = true; } } ShootingTimer++; } - private void Shoot(bool yBeam) + public void Shoot(bool yBeam) { Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero); @@ -99,7 +96,8 @@ namespace CalamityMod.Projectiles.Magic SoundStyle fire = new("CalamityMod/Sounds/Item/LanceofDestinyStrong"); SoundEngine.PlaySound(fire with { Volume = 0.35f, Pitch = 1f, PitchVariance = 0.15f }, Projectile.Center); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3, ModContent.ProjectileType(), Projectile.damage * 9, Projectile.knockBack, Projectile.owner, 0, 0); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3, ModContent.ProjectileType(), Projectile.damage * 9, Projectile.knockBack, Projectile.owner, 0, 0); Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, EffectsColor, new Vector2(1.7f, 0.8f), true); GeneralParticleHandler.SpawnParticle(pulse3); @@ -117,20 +115,22 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 4; i++) { firingVelocity3 = (shootDirection * 10).RotatedBy((0.05f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 1); + + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 1); } for (int i = 0; i < 4; i++) { firingVelocity3 = (shootDirection * 10).RotatedBy((-0.05f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 1); + + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 1); } Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, EffectsColor, new Vector2(1.7f, 0.8f), true); GeneralParticleHandler.SpawnParticle(pulse3); } - Projectile.netUpdate = true; - // Inside here go all the things that dedicated servers shouldn't spend resources on. // Like visuals and sounds. if (Main.dedServ) diff --git a/Projectiles/Magic/MeteorStar.cs b/Projectiles/Magic/MeteorStar.cs index e123f24b7b..c2292cb1bb 100644 --- a/Projectiles/Magic/MeteorStar.cs +++ b/Projectiles/Magic/MeteorStar.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -10,6 +11,8 @@ namespace CalamityMod.Projectiles.Magic public class MeteorStar : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; + public Player Owner => Main.player[Projectile.owner]; + public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Projectile.type] = 5; @@ -22,128 +25,80 @@ namespace CalamityMod.Projectiles.Magic Projectile.width = 42; Projectile.height = 34; Projectile.friendly = true; + Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Magic; Projectile.timeLeft = 361; } public override void AI() { - Player player = Main.player[Projectile.owner]; - bool flippedGravity = player.gravDir == -1f; - Projectile.frameCounter++; - if (Projectile.frameCounter > 6) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame >= Main.projFrames[Projectile.type]) - { - Projectile.frame = 0; - } - - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.15f / 255f); + Projectile.frame = Projectile.frameCounter / 6 % Main.projFrames[Projectile.type]; + Color LightYellow = new Color(255, 255, 76); + Lighting.AddLight(Projectile.Center, LightYellow.ToVector3() * Projectile.Opacity * 0.5f); bool explodingSoon = Projectile.timeLeft <= 120; if (Projectile.soundDelay <= 0) { - Projectile.soundDelay = 30 + Main.rand.Next(40); - if (explodingSoon) - Projectile.soundDelay -= 30; - if (Main.rand.NextBool(10) || explodingSoon) - { + Projectile.soundDelay = 30 + Main.rand.Next(explodingSoon ? 10 : 40); + if (Main.rand.NextBool(4) || explodingSoon) SoundEngine.PlaySound(SoundID.Item9, Projectile.Center); - } } - if ((Main.rand.NextBool(20) || explodingSoon) && Main.rand.NextBool(3) && Main.netMode != NetmodeID.Server) + if ((Main.rand.NextBool(12) || (explodingSoon && Main.rand.NextBool(3))) && Main.netMode != NetmodeID.Server) { - int idx = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, Projectile.velocity * 0.2f, Main.rand.Next(16, 18), 1f); - Main.gore[idx].velocity *= 0.66f; - Main.gore[idx].velocity += Projectile.velocity * 0.3f; + Gore star = Gore.NewGoreDirect(Projectile.GetSource_FromAI(), Projectile.Center, Projectile.velocity * 0.2f, Main.rand.Next(16, 18), 1f); + star.velocity *= 0.66f; + star.velocity += Projectile.velocity * 0.3f; } if (explodingSoon) { for (int i = 0; i < 3; i++) { - int smoke = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[smoke]; - dust.velocity *= 0.3f; - dust.position.X = Projectile.Center.X + 4f + Main.rand.NextFloat(-6f, 6f); - dust.position.Y = Projectile.Center.Y + Main.rand.NextFloat(-6f, 6f); - dust.noGravity = true; + Dust smoke = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default, 2f); + smoke.velocity *= 0.3f; + smoke.position.X = Projectile.Center.X + 4f + Main.rand.NextFloat(-6f, 6f); + smoke.position.Y = Projectile.Center.Y + Main.rand.NextFloat(-6f, 6f); + smoke.noGravity = true; } } if (Main.myPlayer == Projectile.owner) { - if (player.channel) + // Initialize position + if (Projectile.ai[2] != 1f) { - float speed = 14f; - float mouseDistX = (float)Main.mouseX + Main.screenPosition.X - Projectile.Center.X; - float mouseDistY = (float)Main.mouseY + Main.screenPosition.Y - Projectile.Center.Y; - if (player.gravDir == -1f) - { - mouseDistY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - Projectile.Center.Y; - } - Vector2 mouseVec = new Vector2(mouseDistX, mouseDistY); - float mouseDist = mouseVec.Length(); - if (mouseDist > speed) - { - mouseDist = speed / mouseDist; - mouseVec.X *= mouseDist; - mouseVec.Y *= mouseDist; - int mouseSpeedX = (int)(mouseVec.X * 1000f); - int projSpeedX = (int)(Projectile.velocity.X * 1000f); - int mouseSpeedY = (int)(mouseVec.Y * 1000f); - int projSpeedY = (int)(Projectile.velocity.Y * 1000f); - if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) - { - Projectile.netUpdate = true; - } - Projectile.velocity.X = mouseVec.X; - Projectile.velocity.Y = mouseVec.Y; - } + if (Owner.gravDir == -1f) + Projectile.Center = Owner.Top; else - { - int mouseSpeedX = (int)(mouseVec.X * 1000f); - int projSpeedX = (int)(Projectile.velocity.X * 1000f); - int mouseSpeedY = (int)(mouseVec.Y * 1000f); - int projSpeedY = (int)(Projectile.velocity.Y * 1000f); - if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) - { - Projectile.netUpdate = true; - } - Projectile.velocity.X = mouseVec.X; - Projectile.velocity.Y = mouseVec.Y; - } - player.ChangeDir((int)Projectile.velocity.X); - player.velocity = Projectile.velocity; - if (Projectile.velocity.Y > 16f) - { - Projectile.velocity.Y = 16f; - player.velocity.Y = 16f; - } - if (player.mount != null) - { - player.mount.Dismount(player); - } - if (!flippedGravity) - player.Bottom = Projectile.Center; + Projectile.Center = Owner.Bottom; + + Projectile.ai[2] = 1f; + Projectile.netUpdate = true; + Projectile.netSpam = 0; + } + if (Owner.channel) + { + Owner.mount?.Dismount(Owner); + Owner.RemoveAllGrapplingHooks(); + + Projectile.velocity = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld) * 14f; + Owner.velocity = Projectile.velocity; + Owner.ChangeDir(Math.Sign(Projectile.velocity.X) <= 0 ? -1 : 1); + + // Move the player to the projectile, allowing them to bypass platforms + if (Owner.gravDir == -1f) + Owner.Top = Projectile.Center; else - player.Top = Projectile.Center; + Owner.Bottom = Projectile.Center; } else - { Explode(true); - } } - Projectile.tileCollide = Projectile.velocity != Vector2.Zero && ++Projectile.ai[0] >= 5f; - // Die immediately if the owner of this projectile is clipping into tiles because of its movement. - if (Collision.SolidCollision(player.position, player.width, player.height) && Projectile.velocity != Vector2.Zero) + if (Collision.SolidCollision(Owner.position, Owner.width, Owner.height) && Projectile.velocity != Vector2.Zero) { - player.velocity.Y = 0f; + Owner.velocity.Y = 0f; Explode(); } @@ -155,27 +110,14 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitPlayer(Player target, Player.HurtInfo info) => Explode(); - public override bool OnTileCollide(Vector2 oldVelocity) - { - Explode(); - return base.OnTileCollide(oldVelocity); - } - public override bool PreDraw(ref Color lightColor) { CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); // Draw the main texture in fullbright Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - - int frameHeight = texture.Height / Main.projFrames[Projectile.type]; - int frameY = frameHeight * Projectile.frame; - float scale = Projectile.scale; - float rotation = Projectile.rotation; - - Rectangle rectangle = new Rectangle(0, frameY, texture.Width, frameHeight); - Vector2 origin = rectangle.Size() / 2f; - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), rectangle, Color.White, rotation, origin, scale, SpriteEffects.None, 0); + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, frame, Color.White, Projectile.rotation, frame.Size() * 0.5f, Projectile.scale, SpriteEffects.None); return false; } @@ -191,12 +133,12 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 10; i++) { - int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default, 1.2f); - Main.dust[idx].velocity *= 3f; + Dust smoke = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default, 1.2f); + smoke.velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[idx].scale = 0.5f; - Main.dust[idx].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + smoke.scale = 0.5f; + smoke.fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } if (Main.netMode != NetmodeID.Server) @@ -208,5 +150,11 @@ namespace CalamityMod.Projectiles.Magic } Projectile.Kill(); } + + public override void OnKill(int timeLeft) + { + Owner.velocity *= 0.8f; + Owner.fullRotation = 0f; + } } } diff --git a/Projectiles/Magic/NanoPurgeHoldout.cs b/Projectiles/Magic/NanoPurgeHoldout.cs index b68d0f826f..4127860c0a 100644 --- a/Projectiles/Magic/NanoPurgeHoldout.cs +++ b/Projectiles/Magic/NanoPurgeHoldout.cs @@ -1,57 +1,52 @@ -using CalamityMod.Items.Weapons.Magic; +using System; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class NanoPurgeHoldout : ModProjectile + public class NanoPurgeHoldout : BaseGunHoldoutProjectile { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public override int AssociatedItemID => ModContent.ItemType(); + public override string Texture => "CalamityMod/Projectiles/Magic/NanoPurgeHoldout"; + public override float MaxOffsetLengthFromArm => 10f; + public override float OffsetXUpwards => -15f; + public override float OffsetXDownwards => 5f; + public override float BaseOffsetY => -10f; + public override float OffsetYUpwards => 5f; + public override float OffsetYDownwards => 10f; + private const int FramesPerFireRateIncrease = 36; private static int[] LaserOffsetByAnimationFrame = { 4, 3, 0, 3 }; - private Player Owner => Main.player[Projectile.owner]; private ref float DeployedFrames => ref Projectile.ai[0]; private ref float ChargeTowardsNextShot => ref Projectile.ai[1]; - public override void SetStaticDefaults() - { - Main.projFrames[Projectile.type] = 4; - } + public override void SetStaticDefaults() => Main.projFrames[Type] = 4; - public override void SetDefaults() + public override void KillHoldoutLogic() { - Projectile.width = 34; - Projectile.height = 62; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Magic; - } - - public override void AI() - { - Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); - Vector2 gunBarrelPos = armPosition + Projectile.velocity * Projectile.height * 0.5f; - - // If the player is unable to continue using the holdout, delete it. - if (Owner.CantUseHoldout() || !Owner.HasAmmo(Owner.ActiveItem())) - { + base.KillHoldoutLogic(); + bool actuallyShoot = DeployedFrames >= (HeldItem?.useAnimation ?? NanoPurge.UseTime); + bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.ActiveItem()); + if (!manaOK) Projectile.Kill(); - return; - } + } + public override void HoldoutAI() + { // Update damage based on curent magic damage stat (so Mana Sickness affects it) - Item weaponItem = Owner.ActiveItem(); - Projectile.damage = weaponItem is null ? 0 : Owner.GetWeaponDamage(weaponItem); + Projectile.damage = HeldItem is null ? 0 : Owner.GetWeaponDamage(HeldItem); // Get the original weapon's use time. - int itemUseTime = weaponItem?.useAnimation ?? NanoPurge.UseTime; + int itemUseTime = HeldItem?.useAnimation ?? NanoPurge.UseTime; // Update time. DeployedFrames += 1f; @@ -76,7 +71,7 @@ namespace CalamityMod.Projectiles.Magic SoundEngine.PlaySound(SoundID.Item91, Projectile.Center); int projID = ModContent.ProjectileType(); - float shootSpeed = weaponItem.shootSpeed; + float shootSpeed = HeldItem.shootSpeed; float inaccuracyRatio = 0.045f; Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.UnitY); Vector2 perp = shootDirection.RotatedBy(MathHelper.PiOver2); @@ -86,59 +81,22 @@ namespace CalamityMod.Projectiles.Magic { Vector2 spread = Main.rand.NextVector2CircularEdge(shootSpeed, shootSpeed); Vector2 shootVelocity = shootDirection * shootSpeed + inaccuracyRatio * spread; - Vector2 splitBarrelPos = gunBarrelPos + i * LaserOffsetByAnimationFrame[Projectile.frame] * perp; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), splitBarrelPos, shootVelocity, projID, Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); + Vector2 splitBarrelPos = GunTipPosition + i * LaserOffsetByAnimationFrame[Projectile.frame] * perp; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), splitBarrelPos, shootVelocity, projID, Projectile.damage, Projectile.knockBack, Projectile.owner); SpawnFiringDust(splitBarrelPos, shootVelocity); } } - - // Delete the laser gun if a mana cost cannot be paid. - else - { - Projectile.Kill(); - return; - } } - UpdateProjectileHeldVariables(armPosition); - ManipulatePlayerVariables(); + ExtraBackArmRotation = Utils.Remap(Vector2.Dot(-Vector2.UnitY, Projectile.velocity.SafeNormalize(-Vector2.UnitY)), 0f, 1f, MathHelper.PiOver4, 0f); } - private void UpdateProjectileHeldVariables(Vector2 armPosition) - { - if (Main.myPlayer == Projectile.owner) - { - float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); - Vector2 oldVelocity = Projectile.velocity; - Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); - if (Projectile.velocity != oldVelocity) - { - Projectile.netSpam = 0; - Projectile.netUpdate = true; - } - } - - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - Projectile.Center = armPosition + Projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction) * 8f; - Projectile.spriteDirection = Projectile.direction; - Projectile.timeLeft = 2; - } - - private void ManipulatePlayerVariables() - { - Owner.ChangeDir(Projectile.direction); - Owner.heldProj = Projectile.whoAmI; - Owner.itemTime = 2; - Owner.itemAnimation = 2; - Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); - } - - private void SpawnFiringDust(Vector2 gunBarrelPos, Vector2 laserVelocity) + private void SpawnFiringDust(Vector2 GunTipPosition, Vector2 laserVelocity) { int dustID = 107; int dustRadius = 5; int dustDiameter = 2 * dustRadius; - Vector2 dustCorner = gunBarrelPos - Vector2.One * dustRadius; + Vector2 dustCorner = GunTipPosition - Vector2.One * dustRadius; for (int i = 0; i < 2; i++) { Vector2 dustVel = laserVelocity + Main.rand.NextVector2Circular(7f, 7f); @@ -149,9 +107,24 @@ namespace CalamityMod.Projectiles.Magic } } - public override bool? CanDamage() => false; + public override void OnSpawn(IEntitySource source) + { + base.OnSpawn(source); + FrontArmStretch = Player.CompositeArmStretchAmount.Quarter; + } - // prevents the item from appearing backwards frame 1 - public override bool PreDraw(ref Color lightColor) => DeployedFrames > 0f; + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(verticalFrames: Main.projFrames[Type], frameY: Projectile.frame); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f) + MathHelper.PiOver2; + Vector2 rotationPoint = frame.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipVertically : SpriteEffects.None; + + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + + return false; + } } } diff --git a/Projectiles/Magic/OmicronBeam.cs b/Projectiles/Magic/OmicronBeam.cs index e281affc55..2c12781212 100644 --- a/Projectiles/Magic/OmicronBeam.cs +++ b/Projectiles/Magic/OmicronBeam.cs @@ -1,8 +1,8 @@ -using CalamityMod.Particles; +using System.IO; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -11,13 +11,17 @@ namespace CalamityMod.Projectiles.Magic { public new string LocalizationCategory => "Projectiles.Magic"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float time => ref Projectile.ai[0]; - - public Color mainColor = Color.MediumVioletRed; - public bool HitDirect = false; - public ref float isSplit => ref Projectile.ai[1]; - public bool splitShot = false; + public bool splitShot + { + get => Projectile.ai[2] == 1f; + set => Projectile.ai[2] = value == true ? 1f : 0f; + } + public bool HitDirect { get; set; } + public Color mainColor { get; set; } = Color.MediumVioletRed; + public override void SetDefaults() { Projectile.width = 50; @@ -31,21 +35,25 @@ namespace CalamityMod.Projectiles.Magic Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 91; } + public override void AI() { if (isSplit == 0) { + Projectile.netSpam = 0; Projectile.netUpdate = true; splitShot = true; } Player Owner = Main.player[Projectile.owner]; float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + if (Projectile.timeLeft % 2 == 0 && time > 2 && targetDist < 1400f) { Particle spark = new GlowSparkParticle(Projectile.Center, -Projectile.velocity * 0.05f, false, 25, MathHelper.Clamp(0.34f - time * 0.07f, 0.085f, 0.34f), mainColor, new Vector2(0.5f, 1.3f)); GeneralParticleHandler.SpawnParticle(spark); } + if (Main.rand.NextBool()) { Vector2 trailPos = Projectile.Center; @@ -53,13 +61,21 @@ namespace CalamityMod.Projectiles.Magic Particle Trail = new SparkParticle(trailPos, Projectile.velocity * Main.rand.NextFloat(0.2f, 0.9f), false, Main.rand.Next(40, 50 + 1), trailScale, mainColor); GeneralParticleHandler.SpawnParticle(Trail); } + Vector2 dustVel = new Vector2(2, 2).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.8f); Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel, Main.rand.NextBool(4) ? 264 : 66, dustVel, 0, default, Main.rand.NextFloat(0.9f, 1.2f)); dust.noGravity = true; dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; time++; + + if (Projectile.numUpdates == 1) + { + Projectile.netSpam = 0; + Projectile.netUpdate = true; + } } + public override void OnKill(int timeLeft) { int numProj = 2; @@ -98,18 +114,21 @@ namespace CalamityMod.Projectiles.Magic dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; } } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { if (splitShot && time > 7 && !HitDirect) Projectile.Kill(); Player Owner = Main.player[Projectile.owner]; + for (int i = 0; i <= 8; i++) { Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(4) ? 264 : 66, (Projectile.velocity.SafeNormalize(Vector2.UnitY) * 15f).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(1.2f, 1.6f)); dust.noGravity = true; dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; } + if (time <= 7 && splitShot) // This is the sweet spot { modifiers.SourceDamage *= 5; @@ -144,6 +163,11 @@ namespace CalamityMod.Projectiles.Magic HitDirect = true; } } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, time <= 7 ? 90 : 20, targetHitbox); + + public override void SendExtraAI(BinaryWriter writer) => writer.Write(HitDirect); + + public override void ReceiveExtraAI(BinaryReader reader) => HitDirect = reader.ReadBoolean(); } } diff --git a/Projectiles/Magic/OmicronHoldout.cs b/Projectiles/Magic/OmicronHoldout.cs index 49c022c8a6..9d3aef3fb7 100644 --- a/Projectiles/Magic/OmicronHoldout.cs +++ b/Projectiles/Magic/OmicronHoldout.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Weapons.Magic; +using System.IO; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; @@ -6,6 +7,7 @@ using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using static CalamityMod.Items.Weapons.Magic.Omicron; namespace CalamityMod.Projectiles.Magic { @@ -18,50 +20,30 @@ namespace CalamityMod.Projectiles.Magic public override float BaseOffsetY => -5f; public override float OffsetYDownwards => 5f; - public Color StaticEffectsColor = Color.MediumVioletRed; + public ref float ShootingTimer => ref Projectile.ai[0]; + public ref float PostFireCooldown => ref Projectile.ai[1]; + public ref float MaxFireRateShots => ref Projectile.ai[2]; - public float FiringTime = 15; - public float Windup = 60; - public bool WindingUp = false; - public int time = 0; - public int PostFireCooldown = 0; - public bool fireYBeam = false; - public int maxFirerateShots = 0; - - private ref float ShootingTimer => ref Projectile.ai[0]; + public float Windup { get; set; } = StarterWinup; + public Color EffectsColor { get; set; } = Color.MediumVioletRed; public override void KillHoldoutLogic() { - if (Owner is null || !Owner.active || Owner.CCed || Owner.dead || Owner.noItems) - { - if (PostFireCooldown <= 0) - Projectile.Kill(); - Projectile.netUpdate = true; - } + if (Owner.CantUseHoldout() && PostFireCooldown <= 0) + Projectile.Kill(); } public override void HoldoutAI() { - Item heldItem = Owner.ActiveItem(); - - // Fire if the owner stops channeling or otherwise cannot use the weapon. - if (Owner.CantUseHoldout()) - { - if (PostFireCooldown <= 0) - Projectile.Kill(); - } - if (PostFireCooldown > 0) - { PostFiringCooldown(); - } if (Owner.Calamity().mouseRight && PostFireCooldown <= 0) { - if (Owner.CheckMana(Owner.ActiveItem(), (int)(heldItem.mana * Owner.manaCost) * 16, true, false)) + if (Owner.CheckMana(Owner.ActiveItem(), (int)(HeldItem.mana * Owner.manaCost) * 16, true, false)) { PostFireCooldown = 100; - Shoot(heldItem, true); + Shoot(true); ShootingTimer = 0; } else @@ -74,31 +56,26 @@ namespace CalamityMod.Projectiles.Magic } } } - else if (ShootingTimer >= FiringTime) + else if (ShootingTimer >= FireRate) { if (Owner.CheckMana(Owner.ActiveItem(), -1, true, false) && PostFireCooldown <= 0) { - maxFirerateShots++; + MaxFireRateShots++; - if (maxFirerateShots == 5) + if (MaxFireRateShots == 5) { Windup = 60; - maxFirerateShots = 1; + MaxFireRateShots = 1; } - Shoot(heldItem, false); + Shoot(false); ShootingTimer = 0; - if (Windup > 10) - { - if (maxFirerateShots > 0) - Windup -= 12; - } + if (Windup > 10 && MaxFireRateShots > 0) + Windup -= 12; else - { Windup = 10; - } } else if (PostFireCooldown <= 0) { @@ -107,14 +84,13 @@ namespace CalamityMod.Projectiles.Magic } } + ShootingTimer++; } - private void Shoot(Item item, bool yBeam) + + public void Shoot(bool yBeam) { Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero); - - // Spawns the projectile. - Vector2 firingVelocity1 = (shootDirection * 8).RotatedBy(0.1f * Utils.GetLerpValue(10, 55, Windup, true)); Vector2 firingVelocity2 = (shootDirection * 8).RotatedBy(-0.1f * Utils.GetLerpValue(10, 55, Windup, true)); Vector2 firingVelocity3 = (shootDirection * 10); @@ -126,7 +102,7 @@ namespace CalamityMod.Projectiles.Magic for (int k = 0; k < 6; k++) { - Particle pulse2 = new GlowSparkParticle(GunTipPosition, shootDirection * 28, false, 8, 0.087f, StaticEffectsColor, new Vector2(2.3f, 0.9f), true); + Particle pulse2 = new GlowSparkParticle(GunTipPosition, shootDirection * 28, false, 8, 0.087f, EffectsColor, new Vector2(2.3f, 0.9f), true); GeneralParticleHandler.SpawnParticle(pulse2); } @@ -135,7 +111,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 8; i++) { - SparkParticle spark2 = new SparkParticle(GunTipPosition + Main.rand.NextVector2Circular(10, 10), firingVelocity3 * Main.rand.NextFloat(0.7f, 1.3f), false, Main.rand.Next(20, 30), Main.rand.NextFloat(0.4f, 0.55f), StaticEffectsColor); + SparkParticle spark2 = new SparkParticle(GunTipPosition + Main.rand.NextVector2Circular(10, 10), firingVelocity3 * Main.rand.NextFloat(0.7f, 1.3f), false, Main.rand.Next(20, 30), Main.rand.NextFloat(0.4f, 0.55f), EffectsColor); GeneralParticleHandler.SpawnParticle(spark2); } } @@ -155,7 +131,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); } - Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, StaticEffectsColor, new Vector2(1.7f, 0.8f), true); + Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, EffectsColor, new Vector2(1.7f, 0.8f), true); GeneralParticleHandler.SpawnParticle(pulse3); } @@ -171,7 +147,7 @@ namespace CalamityMod.Projectiles.Magic Dust dust2 = Dust.NewDustPerfect(GunTipPosition, Main.rand.NextBool(4) ? 267 : 66, shootVel); dust2.scale = Main.rand.NextFloat(1.15f, 1.45f); dust2.noGravity = true; - dust2.color = Main.rand.NextBool() ? Color.Lerp(StaticEffectsColor, Color.White, 0.5f) : StaticEffectsColor; + dust2.color = Main.rand.NextBool() ? Color.Lerp(EffectsColor, Color.White, 0.5f) : EffectsColor; } // By decreasing the offset length of the gun from the arms, we give an effect of recoil. @@ -180,21 +156,26 @@ namespace CalamityMod.Projectiles.Magic else OffsetLengthFromArm -= 6f; } - private void PostFiringCooldown() + + public void PostFiringCooldown() { Owner.channel = true; if (PostFireCooldown > 0 && Main.rand.NextBool()) { Vector2 smokeVel = new Vector2(0, -8) * Main.rand.NextFloat(0.1f, 1.1f); - Particle smoke = new HeavySmokeParticle(GunTipPosition, smokeVel, StaticEffectsColor, Main.rand.Next(30, 50 + 1), Main.rand.NextFloat(0.1f, 0.4f), 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); + Particle smoke = new HeavySmokeParticle(GunTipPosition, smokeVel, EffectsColor, Main.rand.Next(30, 50 + 1), Main.rand.NextFloat(0.1f, 0.4f), 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); GeneralParticleHandler.SpawnParticle(smoke); Dust dust = Dust.NewDustPerfect(GunTipPosition, 303, smokeVel.RotatedByRandom(0.1f), 80, default, Main.rand.NextFloat(0.2f, 0.8f)); dust.noGravity = false; - dust.color = StaticEffectsColor; + dust.color = EffectsColor; } ShootingTimer = 0; PostFireCooldown--; } + + public override void SendExtraAIHoldout(BinaryWriter writer) => writer.Write(Windup); + + public override void ReceiveExtraAIHoldout(BinaryReader reader) => Windup = reader.ReadSingle(); } } diff --git a/Projectiles/Magic/OmicronWingman.cs b/Projectiles/Magic/OmicronWingman.cs index a932b15d32..9b830bea2a 100644 --- a/Projectiles/Magic/OmicronWingman.cs +++ b/Projectiles/Magic/OmicronWingman.cs @@ -1,19 +1,16 @@ using System; +using System.Collections.Generic; +using System.IO; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Particles; -using Humanizer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -using System.Collections.Generic; -using System.IO; -using CalamityMod.Graphics.Renderers; namespace CalamityMod.Projectiles.Magic { @@ -26,7 +23,6 @@ namespace CalamityMod.Projectiles.Magic private ref float ShootingTimer => ref Projectile.ai[0]; private float FiringTime = 10; private float PostFireCooldown = 0; - private Vector2 MovementOffset; public bool MovingUp = true; public float xOffset = 1; public float yOffset = 0; @@ -42,45 +38,48 @@ namespace CalamityMod.Projectiles.Magic public bool recharging = false; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 9; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + public override void SetDefaults() { Projectile.width = Projectile.height = 142; Projectile.tileCollide = false; Projectile.ignoreWater = true; Projectile.netImportant = true; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 9; - ProjectileID.Sets.TrailingMode[Projectile.type] = 2; Projectile.hide = true; } public override void AI() { + Owner ??= Main.player[Projectile.owner]; + if (time > 1 && Owner.ownedProjectileCounts[ModContent.ProjectileType()] < 1 && PostFireCooldown <= 0) Projectile.Kill(); + Lighting.AddLight(Projectile.Center, StaticEffectsColor.ToVector3() * 0.2f); + if (time == 0) - { - MovingUp = Projectile.ai[2] == 1 ? true : false; - } + MovingUp = Projectile.ai[2] == 1; + firingDelay--; Item heldItem = Owner.ActiveItem(); // Update damage based on curent magic damage stat (so Mana Sickness affects it) Projectile.damage = heldItem is null ? 0 : Owner.GetWeaponDamage(heldItem); - Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-0.05f * Projectile.direction) * 12f; // If there's no player, or the player is the server, or the owner's stunned, there'll be no holdout. if (PostFireCooldown == 0 && launchDelay == 0 && Owner.CantUseHoldout() || heldItem.type != ModContent.ItemType()) { - NetUpdate(); if (PostFireCooldown <= 0) Projectile.Kill(); } if (PostFireCooldown > 0) - { PostFiringCooldown(); - } if (launchDelay > 0 || (PostFireCooldown <= 0 && (Owner.Calamity().mouseRight || (firingDelay <= 0 && Projectile.ai[2] == 1 || Projectile.ai[2] == -1)))) { @@ -89,10 +88,10 @@ namespace CalamityMod.Projectiles.Magic { if (launchDelay < 50) launchDelay++; - + if (launchDelay >= 50 && (Owner.CheckMana(Owner.ActiveItem(), (int)(heldItem.mana * Owner.manaCost) * 2, true, false))) { - Shoot(heldItem, true); + Shoot(true); PostFireCooldown = 50; ShootingTimer = 0; launchDelay = 0; @@ -102,13 +101,11 @@ namespace CalamityMod.Projectiles.Magic { if (Owner.CheckMana(Owner.ActiveItem(), -1, false, false)) { - Shoot(heldItem, false); + Shoot(false); ShootingTimer = 0; } else if (PostFireCooldown <= 0) - { Projectile.Kill(); - } } } @@ -119,7 +116,7 @@ namespace CalamityMod.Projectiles.Magic Vector2 ownerToMouse = Owner.Calamity().mouseWorld - ownerPosition; // Deals with the holdout's rotation and direction, the owner's arms, etc. - ManageHoldout(ownerPosition, ownerToMouse); + ManagePlayerProjectileMembers(ownerToMouse); // When we change the distance of the gun from the arms for the recoil, // recover to the original position smoothly. @@ -127,82 +124,66 @@ namespace CalamityMod.Projectiles.Magic OffsetLength = MathHelper.Lerp(OffsetLength, MaxOffsetLength, 0.1f); ShootingTimer++; - - // Inside here go all the things that dedicated servers shouldn't spend resources on. - // Like visuals and sounds. - if (Main.dedServ) - return; - - Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero) * 20; time++; Projectile.soundDelay--; + + Projectile.netSpam = 0; + Projectile.netUpdate = true; } - private void ManageHoldout(Vector2 mountedCenter, Vector2 ownerToMouse) + private void ManagePlayerProjectileMembers(Vector2 ownerToMouse) { Vector2 rotationVector = Projectile.rotation.ToRotationVector2(); float velocityRotation = Projectile.velocity.ToRotation(); - float proximityLookingUpwards = Vector2.Dot(ownerToMouse.SafeNormalize(Vector2.Zero), -Vector2.UnitY); int direction = MathF.Sign(ownerToMouse.X); - - Vector2 armPosition = Owner.RotatedRelativePoint(mountedCenter, true); Vector2 lengthOffset = rotationVector * OffsetLength; - Vector2 armOffset = new Vector2(Utils.Remap(proximityLookingUpwards, -1f, 1f, 0f, -12f) * direction, -10f + Utils.Remap(MathF.Abs(proximityLookingUpwards), 0f, 1f, 0f, proximityLookingUpwards > 0f ? 15f : 0f)); if (time % 30 == 0) - { MovingUp = !MovingUp; - } //xOffset = MathHelper.Lerp(xOffset, placementOffset.X, 0.01f); yOffset = MathHelper.Lerp(yOffset, 150 * (MovingUp ? -1 : 1), (0.085f - (FiringTime * 0.0012f))); Vector2 placementOffset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * (yOffset); - Vector2 location = Owner.MountedCenter + placementOffset; Projectile.Center = lengthOffset + location; - - Projectile.velocity = velocityRotation.AngleTowards(ownerToMouse.ToRotation(), 0.2f).ToRotationVector2(); - Projectile.rotation = (Main.MouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX).ToRotation(); + Projectile.rotation = (Owner.Calamity().mouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX).ToRotation(); Projectile.timeLeft = 2; - - Owner.heldProj = Projectile.whoAmI; - Owner.itemTime = Owner.itemAnimation = 2; - Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); - Projectile.spriteDirection = Projectile.direction = direction; } - private void Shoot(Item item, bool isGrenade) + private void Shoot(bool isGrenade) { - Vector2 shootDirection = (Main.MouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX); + Vector2 shootDirection = (Owner.Calamity().mouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX); // The position of the tip of the gun. Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-0.05f * Projectile.direction) * 12f; - // Spawns the projectile. - Vector2 firingVelocity = shootDirection * 10; if (isGrenade) { SoundStyle fire = new("CalamityMod/Sounds/Item/DeadSunExplosion"); SoundEngine.PlaySound(fire with { Volume = 0.2f, Pitch = -0.4f, PitchVariance = 0.2f }, Projectile.Center); - Projectile bomb = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity, ModContent.ProjectileType(), Projectile.damage * 14, Projectile.knockBack * 5, Projectile.owner, 0, 2); - bomb.timeLeft = 530; - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity * 1.2f, ModContent.ProjectileType(), Projectile.damage * 14, Projectile.knockBack * 5, Projectile.owner, 0, 2); + if (Main.myPlayer == Projectile.owner) + { + Projectile bomb = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity, ModContent.ProjectileType(), Projectile.damage * 14, Projectile.knockBack * 5, Projectile.owner, 0, 2); + bomb.timeLeft = 530; + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity * 1.2f, ModContent.ProjectileType(), Projectile.damage * 14, Projectile.knockBack * 5, Projectile.owner, 0, 2); + } } else { SoundStyle fire = new("CalamityMod/Sounds/Item/MagnaCannonShot"); SoundEngine.PlaySound(fire with { Volume = 0.25f, Pitch = 1f, PitchVariance = 0.35f }, Projectile.Center); - - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity.RotatedBy(-0.05) * 0.85f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity.RotatedBy(0.05) * 0.85f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); - } - NetUpdate(); + if (Main.myPlayer == Projectile.owner) + { + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity.RotatedBy(-0.05) * 0.85f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity.RotatedBy(0.05) * 0.85f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); + } + } // Inside here go all the things that dedicated servers shouldn't spend resources on. // Like visuals and sounds. @@ -218,6 +199,7 @@ namespace CalamityMod.Projectiles.Magic dust2.noGravity = true; dust2.color = Main.rand.NextBool() ? Color.Lerp(StaticEffectsColor, Color.White, 0.5f) : StaticEffectsColor; } + Particle pulse = new GlowSparkParticle((tipPosition - shootDirection * 14), shootDirection * 20, false, Main.rand.Next(7, 11 + 1), 0.035f, StaticEffectsColor, new Vector2(1.5f, 0.9f), true); GeneralParticleHandler.SpawnParticle(pulse); @@ -227,6 +209,7 @@ namespace CalamityMod.Projectiles.Magic else OffsetLength -= 5f; } + private void PostFiringCooldown() { Owner.channel = true; @@ -242,23 +225,13 @@ namespace CalamityMod.Projectiles.Magic dust.noGravity = false; dust.color = StaticEffectsColor; } + ShootingTimer = 0; firingDelay = 15; PostFireCooldown--; } - private void NetUpdate() - { - Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; - } - - public override void OnSpawn(IEntitySource source) - { - Owner = Main.player[Projectile.owner]; - OffsetLength = MaxOffsetLength; - } + public override void OnSpawn(IEntitySource source) => OffsetLength = MaxOffsetLength; // Because we use the velocity as a direction, we don't need it to change its position. public override bool ShouldUpdatePosition() => false; @@ -270,8 +243,7 @@ namespace CalamityMod.Projectiles.Magic if (time <= 0) return false; - Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Magic/Wingman").Value; - + Texture2D texture; if (Projectile.ai[2] == 1) texture = ModContent.Request("CalamityMod/Projectiles/Magic/OmicronWingman").Value; else @@ -291,9 +263,29 @@ namespace CalamityMod.Projectiles.Magic return false; } - public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) => behindNPCs.Add(index); + + public override void SendExtraAI(BinaryWriter writer) { - behindNPCs.Add(index); + writer.Write(Projectile.rotation); + writer.Write(Projectile.spriteDirection); + writer.Write(OffsetLength); + writer.Write(time); + writer.Write(firingDelay); + writer.Write(launchDelay); + writer.Write(MovingUp); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + Projectile.rotation = reader.ReadSingle(); + Projectile.spriteDirection = reader.ReadInt32(); + OffsetLength = reader.ReadSingle(); + time = reader.ReadInt32(); + firingDelay = reader.ReadInt32(); + launchDelay = reader.ReadInt32(); + MovingUp = reader.ReadBoolean(); } } } diff --git a/Projectiles/Magic/PhasedGodRay.cs b/Projectiles/Magic/PhasedGodRay.cs index 97b300715c..633e74c335 100644 --- a/Projectiles/Magic/PhasedGodRay.cs +++ b/Projectiles/Magic/PhasedGodRay.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Projectiles.Magic // They are extremely carefully chosen and barely work as is! private const float WaveTheta = 0.09f; private const int WaveTwistFrames = 9; - private ref float WaveFrameState => ref Projectile.localAI[1]; + private ref float WaveFrameState => ref Projectile.ai[0]; public override string Texture => "CalamityMod/Projectiles/LaserProj"; @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Magic float waveSign = WaveFrameState < 0f ? -1f : 1f; - // Initialize waving. Setting localAI[1] to a number between -1 and 1 tells it which way to wave. + // Initialize waving. Setting ai[0] to a number between -1 and 1 tells it which way to wave. // Exactly 0 is a coinflip. if (Math.Abs(WaveFrameState) < 1f) { diff --git a/Projectiles/Magic/ShadeNimbusCloud.cs b/Projectiles/Magic/ShadeNimbusCloud.cs index 2556ed189a..a94a50d56c 100644 --- a/Projectiles/Magic/ShadeNimbusCloud.cs +++ b/Projectiles/Magic/ShadeNimbusCloud.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Magic Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Demonite, 0, 0, 0, default, 0.5f); } - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 120); } } } diff --git a/Projectiles/Magic/Shaderain.cs b/Projectiles/Magic/Shaderain.cs index c2c0650580..da5645ebb2 100644 --- a/Projectiles/Magic/Shaderain.cs +++ b/Projectiles/Magic/Shaderain.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Magic } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 180); } } } diff --git a/Projectiles/Magic/WingmanGrenade.cs b/Projectiles/Magic/WingmanGrenade.cs index fe6b7fb52a..d25fad5311 100644 --- a/Projectiles/Magic/WingmanGrenade.cs +++ b/Projectiles/Magic/WingmanGrenade.cs @@ -1,25 +1,31 @@ -using CalamityMod.Particles; -using CalamityMod.Projectiles.Summon; +using System.IO; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Magic { public class WingmanGrenade : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public int BounceHits = 0; - public Color mainColor = Color.White; - public bool exploding = false; - public float sizeBonus = 1; + + public bool exploding + { + get => Projectile.ai[0] == 1f; + set => Projectile.ai[0] = value == true ? 1f : 0f; + } + public float sizeBonus { get; set; } = 1f; + public Color mainColor { get; set; } = Color.White; + public override void SetStaticDefaults() { - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 14; - ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 14; + ProjectileID.Sets.TrailingMode[Type] = 2; } public override void SetDefaults() @@ -35,6 +41,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.localNPCHitCooldown = -1; } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, exploding ? 120 * sizeBonus : 20 * sizeBonus, targetHitbox); + public override void AI() { if (mainColor == Color.White) @@ -60,8 +68,10 @@ namespace CalamityMod.Projectiles.Magic if (exploding) { Projectile.velocity = Vector2.Zero; + if (Projectile.timeLeft > 65) Projectile.timeLeft = 65; + if (Projectile.timeLeft == 65) { Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, mainColor, "CalamityMod/Particles/HighResHollowCircleHardEdge", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.12f * sizeBonus, 15); @@ -71,6 +81,7 @@ namespace CalamityMod.Projectiles.Magic SoundStyle fire = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeImpact"); SoundEngine.PlaySound(fire with { Volume = 1.25f, Pitch = -0.2f, PitchVariance = 0.15f }, Projectile.Center); } + if (Projectile.timeLeft == 65) { Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, mainColor, "CalamityMod/Particles/HighResHollowCircleHardEdge", Vector2.One, Main.rand.NextFloat(-10, 10), 0.12f * sizeBonus, 0.135f * sizeBonus, 50); @@ -83,10 +94,11 @@ namespace CalamityMod.Projectiles.Magic GeneralParticleHandler.SpawnParticle(blastRing2); } } - Lighting.AddLight(Projectile.Center, mainColor.ToVector3() * 0.7f); - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - + Projectile.velocity *= 0.988f; + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + Lighting.AddLight(Projectile.Center, mainColor.ToVector3() * 0.7f); + if (Projectile.timeLeft % 2 == 0) { if (!exploding && Main.rand.NextBool() || exploding) @@ -97,51 +109,49 @@ namespace CalamityMod.Projectiles.Magic dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; } } - } - public override bool PreDraw(ref Color lightColor) - { - Texture2D texture = ModContent.Request("CalamityMod/Particles/Light").Value; - Vector2 drawPosition = Projectile.Center - Main.screenPosition; - Color drawColor = Projectile.GetAlpha(lightColor); - float drawRotation = Projectile.rotation; - Vector2 rotationPoint = texture.Size() * 0.5f; - if (!exploding) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], Color.Lerp(mainColor, Color.White, 0.5f) * 0.6f, 1); - Main.EntitySpriteDraw(texture, drawPosition, null, mainColor with { A = 0 }, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); - Main.EntitySpriteDraw(texture, drawPosition, null, Color.White with { A = 0 }, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); - - } - return false; + Projectile.netSpam = 0; + Projectile.netUpdate = true; } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { if (!exploding) - { exploding = true; - } + if (Projectile.numHits > 0) Projectile.damage = (int)(Projectile.damage * 0.80f); if (Projectile.damage < 1) Projectile.damage = 1; } - public override void OnKill(int timeLeft) - { - for (int i = 0; i <= 5; i++) - { - //Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(4) ? 264 : 66, (Projectile.velocity.SafeNormalize(Vector2.UnitY) * 15f).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(1.2f, 1.6f)); - //dust.noGravity = true; - //dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) { Projectile.tileCollide = false; exploding = true; return false; } - public override bool? CanDamage() => null; - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, exploding ? 120 * sizeBonus : 20 * sizeBonus, targetHitbox); + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request("CalamityMod/Particles/Light").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation; + Vector2 rotationPoint = texture.Size() * 0.5f; + + if (!exploding) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], Color.Lerp(mainColor, Color.White, 0.5f) * 0.6f, 1); + Main.EntitySpriteDraw(texture, drawPosition, null, mainColor with { A = 0 }, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); + Main.EntitySpriteDraw(texture, drawPosition, null, Color.White with { A = 0 }, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); + + } + + return false; + } + + public override void SendExtraAI(BinaryWriter writer) => writer.Write(sizeBonus); + + public override void ReceiveExtraAI(BinaryReader reader) => sizeBonus = reader.ReadSingle(); } } diff --git a/Projectiles/Magic/WingmanHoldout.cs b/Projectiles/Magic/WingmanHoldout.cs index bca2231d0b..c0a303c917 100644 --- a/Projectiles/Magic/WingmanHoldout.cs +++ b/Projectiles/Magic/WingmanHoldout.cs @@ -1,19 +1,16 @@ using System; +using System.Collections.Generic; +using System.IO; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Particles; -using Humanizer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -using System.Collections.Generic; -using System.IO; -using CalamityMod.Graphics.Renderers; namespace CalamityMod.Projectiles.Magic { @@ -24,22 +21,22 @@ namespace CalamityMod.Projectiles.Magic public Color StaticEffectsColor = Color.HotPink; private ref float ShootingTimer => ref Projectile.ai[0]; + private ref float PostFireCooldown => ref Projectile.ai[1]; + public float yOffset; + private float OffsetLength; private float FiringTime = 40; - private float PostFireCooldown = 0; - private Vector2 MovementOffset; - public bool MovingUp = true; - public float xOffset = 1; - public float yOffset = 0; - public int time = 0; + public int time; public int firingDelay = 45; - - private ref float OffsetLength => ref Projectile.localAI[0]; - + public bool MovingUp = true; private Player Owner; - private float MaxOffsetLength = 5f; + private static readonly float MaxOffsetLength = 5f; - public bool recharging = false; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 9; + ProjectileID.Sets.TrailingMode[Type] = 2; + } public override void SetDefaults() { @@ -47,19 +44,21 @@ namespace CalamityMod.Projectiles.Magic Projectile.tileCollide = false; Projectile.ignoreWater = true; Projectile.netImportant = true; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 9; - ProjectileID.Sets.TrailingMode[Projectile.type] = 2; Projectile.hide = true; } public override void AI() { + Owner ??= Main.player[Projectile.owner]; + Lighting.AddLight(Projectile.Center, StaticEffectsColor.ToVector3() * 0.2f); + if (time == 0) { MovingUp = Projectile.ai[2] == 1 ? true : false; } firingDelay--; + Item heldItem = Owner.ActiveItem(); // Update damage based on curent magic damage stat (so Mana Sickness affects it) @@ -72,9 +71,8 @@ namespace CalamityMod.Projectiles.Magic Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-0.05f * Projectile.direction) * 12f; // If there's no player, or the player is the server, or the owner's stunned, there'll be no holdout. - if (Owner.CantUseHoldout() || heldItem.type != ModContent.ItemType() ) + if (Owner.CantUseHoldout() || heldItem.type != ModContent.ItemType()) { - NetUpdate(); if (PostFireCooldown <= 0) Projectile.Kill(); } @@ -85,7 +83,7 @@ namespace CalamityMod.Projectiles.Magic { if ((Owner.CheckMana(Owner.ActiveItem(), (int)(heldItem.mana * Owner.manaCost) * 5, true, false))) { - Shoot(heldItem, true); + Shoot(true); PostFireCooldown = 35 + 55 * Utils.GetLerpValue(10, 40, FiringTime, true); ShootingTimer = 0; FiringTime = 40; @@ -102,9 +100,9 @@ namespace CalamityMod.Projectiles.Magic } else if (ShootingTimer >= FiringTime) { - if (Owner.CheckMana(Owner.ActiveItem(), -1, true, false)) + if (Owner.CheckMana(Owner.ActiveItem(), (int)(heldItem.mana * Owner.manaCost), true, false)) { - Shoot(heldItem, false); + Shoot(false); ShootingTimer = 0; if (FiringTime > 10) @@ -132,7 +130,7 @@ namespace CalamityMod.Projectiles.Magic Vector2 ownerToMouse = Owner.Calamity().mouseWorld - ownerPosition; // Deals with the holdout's rotation and direction, the owner's arms, etc. - ManageHoldout(ownerPosition, ownerToMouse); + ManageHoldout(ownerToMouse); // When we change the distance of the gun from the arms for the recoil, // recover to the original position smoothly. @@ -140,79 +138,60 @@ namespace CalamityMod.Projectiles.Magic OffsetLength = MathHelper.Lerp(OffsetLength, MaxOffsetLength, 0.1f); ShootingTimer++; - - // Inside here go all the things that dedicated servers shouldn't spend resources on. - // Like visuals and sounds. - if (Main.dedServ) - return; - - Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero) * 20; time++; Projectile.soundDelay--; + + Projectile.netSpam = 0; + Projectile.netUpdate = true; } - private void ManageHoldout(Vector2 mountedCenter, Vector2 ownerToMouse) + private void ManageHoldout(Vector2 ownerToMouse) { Vector2 rotationVector = Projectile.rotation.ToRotationVector2(); float velocityRotation = Projectile.velocity.ToRotation(); - float proximityLookingUpwards = Vector2.Dot(ownerToMouse.SafeNormalize(Vector2.Zero), -Vector2.UnitY); int direction = MathF.Sign(ownerToMouse.X); - - Vector2 armPosition = Owner.RotatedRelativePoint(mountedCenter, true); Vector2 lengthOffset = rotationVector * OffsetLength; - Vector2 armOffset = new Vector2(Utils.Remap(proximityLookingUpwards, -1f, 1f, 0f, -12f) * direction, -10f + Utils.Remap(MathF.Abs(proximityLookingUpwards), 0f, 1f, 0f, proximityLookingUpwards > 0f ? 15f : 0f)); if (time % 40 == 0) - { MovingUp = !MovingUp; - } //xOffset = MathHelper.Lerp(xOffset, placementOffset.X, 0.01f); yOffset = MathHelper.Lerp(yOffset, 150 * (MovingUp ? -1 : 1), (0.085f - (FiringTime * 0.0012f))); Vector2 placementOffset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * (yOffset); - Vector2 location = Owner.MountedCenter + placementOffset; Projectile.Center = lengthOffset + location; - - Projectile.velocity = velocityRotation.AngleTowards(ownerToMouse.ToRotation(), 0.2f).ToRotationVector2(); - Projectile.rotation = (Main.MouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX).ToRotation(); + Projectile.rotation = (Owner.Calamity().mouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX).ToRotation(); Projectile.timeLeft = 2; + Projectile.spriteDirection = Projectile.direction = direction; + Owner.ChangeDir(direction); + Owner.heldProj = Projectile.whoAmI; Owner.itemTime = Owner.itemAnimation = 2; Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); - Projectile.spriteDirection = Projectile.direction = direction; - Owner.ChangeDir(direction); - float armRotation = (Projectile.rotation - MathHelper.PiOver2); // -Pi/2 because the arms rotation starts with arms pointing down. if (Projectile.ai[2] == 1) - { - Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Quarter, armRotation); - } + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, armRotation); else - { Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, armRotation); - } } - private void Shoot(Item item, bool isGrenade) + private void Shoot(bool isGrenade) { - Vector2 shootDirection = (Main.MouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX); + Vector2 shootDirection = (Owner.Calamity().mouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX); // The position of the tip of the gun. Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-0.05f * Projectile.direction) * 12f; - // Spawns the projectile. - Vector2 firingVelocity = shootDirection * 10; if (isGrenade) { SoundStyle fire = new("CalamityMod/Sounds/Item/DeadSunExplosion"); SoundEngine.PlaySound(fire with { Volume = 0.35f, Pitch = -0.4f, PitchVariance = 0.2f }, Projectile.Center); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, (firingVelocity * 2) * Utils.GetLerpValue(60, 10, FiringTime, true), ModContent.ProjectileType(), (int)(Projectile.damage * 6), Projectile.knockBack * 5, Projectile.owner, 0); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, (firingVelocity * 1.3f) * Utils.GetLerpValue(60, 10, FiringTime, true), ModContent.ProjectileType(), (int)(Projectile.damage * 6), Projectile.knockBack * 5, Projectile.owner, 0); } else { @@ -221,8 +200,6 @@ namespace CalamityMod.Projectiles.Magic Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity * Utils.GetLerpValue(80, 10, FiringTime, true), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0); } - NetUpdate(); - // Inside here go all the things that dedicated servers shouldn't spend resources on. // Like visuals and sounds. if (Main.dedServ) @@ -246,6 +223,7 @@ namespace CalamityMod.Projectiles.Magic else OffsetLength -= 5f; } + private void PostFiringCooldown() { Owner.channel = true; @@ -266,18 +244,7 @@ namespace CalamityMod.Projectiles.Magic PostFireCooldown--; } - private void NetUpdate() - { - Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; - } - - public override void OnSpawn(IEntitySource source) - { - Owner = Main.player[Projectile.owner]; - OffsetLength = MaxOffsetLength; - } + public override void OnSpawn(IEntitySource source) => OffsetLength = MaxOffsetLength; // Because we use the velocity as a direction, we don't need it to change its position. public override bool ShouldUpdatePosition() => false; @@ -289,8 +256,7 @@ namespace CalamityMod.Projectiles.Magic if (time <= 0 && !Main.dedServ) return false; - Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Magic/Wingman").Value; - + Texture2D texture; if (Projectile.ai[2] == 1) texture = ModContent.Request("CalamityMod/Items/Weapons/Magic/Wingman").Value; else @@ -309,9 +275,31 @@ namespace CalamityMod.Projectiles.Magic return false; } - public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) => behindNPCs.Add(index); + + public override void SendExtraAI(BinaryWriter writer) { - behindNPCs.Add(index); + writer.Write(Projectile.rotation); + writer.Write(Projectile.spriteDirection); + writer.Write(OffsetLength); + writer.Write(FiringTime); + writer.Write(time); + writer.Write(firingDelay); + writer.Write(MovingUp); + writer.Write(yOffset); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + Projectile.rotation = reader.ReadSingle(); + Projectile.spriteDirection = reader.ReadInt32(); + OffsetLength = reader.ReadSingle(); + FiringTime = reader.ReadSingle(); + time = reader.ReadInt32(); + firingDelay = reader.ReadInt32(); + MovingUp = reader.ReadBoolean(); + yOffset = reader.ReadSingle(); } } } diff --git a/Projectiles/Melee/BansheeHookBoom.cs b/Projectiles/Melee/BansheeHookBoom.cs index 98a6105057..033293a215 100644 --- a/Projectiles/Melee/BansheeHookBoom.cs +++ b/Projectiles/Melee/BansheeHookBoom.cs @@ -1,4 +1,5 @@ using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,8 +9,11 @@ namespace CalamityMod.Projectiles.Melee public class BansheeHookBoom : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + private const int TimeLeft = 5; + public override void SetDefaults() { Projectile.width = 8; @@ -18,8 +22,8 @@ namespace CalamityMod.Projectiles.Melee Projectile.DamageType = DamageClass.Melee; Projectile.alpha = 255; Projectile.ignoreWater = true; - Projectile.timeLeft = 6; Projectile.tileCollide = false; + Projectile.timeLeft = TimeLeft; Projectile.penetrate = -1; Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 10; @@ -27,49 +31,46 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - Projectile.ai[1] += 0.01f; - Projectile.scale = Projectile.ai[1]; - Projectile.ai[0] += 1f; - Projectile.alpha -= 63; - if (Projectile.alpha < 0) - { - Projectile.alpha = 0; - } Lighting.AddLight(Projectile.Center, 1.5f, 0f, 0.15f); - if (Projectile.ai[0] == 1f) + + Projectile.ai[0] += 1f; + if (Projectile.ai[0] >= TimeLeft) { Projectile.position = Projectile.Center; Projectile.width = Projectile.height = (int)(52f * Projectile.scale); Projectile.Center = Projectile.position; - Projectile.Damage(); + for (int i = 0; i < 2; i++) { int bansheeDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RedTorch, 0f, 0f, 100, default, 1.5f); - Main.dust[bansheeDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + Main.dust[bansheeDust].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; } + for (int j = 0; j < 5; j++) { int bansheeDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RedTorch, 0f, 0f, 200, default, 2.7f); - Main.dust[bansheeDust2].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + Main.dust[bansheeDust2].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; Main.dust[bansheeDust2].noGravity = true; Main.dust[bansheeDust2].velocity *= 3f; bansheeDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 60, 0f, 0f, 100, default, 1.5f); - Main.dust[bansheeDust2].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + Main.dust[bansheeDust2].position = Projectile.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; Main.dust[bansheeDust2].velocity *= 2f; Main.dust[bansheeDust2].noGravity = true; Main.dust[bansheeDust2].fadeIn = 2.5f; } + for (int k = 0; k < 2; k++) { int bansheeDust3 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 60, 0f, 0f, 0, default, 2.7f); - Main.dust[bansheeDust3].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; + Main.dust[bansheeDust3].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(Math.PI).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; Main.dust[bansheeDust3].noGravity = true; Main.dust[bansheeDust3].velocity *= 3f; } + for (int l = 0; l < 5; l++) { int spiritDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 180, 0f, 0f, 0, default, 1.5f); - Main.dust[spiritDust].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; + Main.dust[spiritDust].position = Projectile.Center + Vector2.UnitX.RotatedByRandom(Math.PI).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 2f; Main.dust[spiritDust].noGravity = true; Main.dust[spiritDust].velocity *= 3f; } diff --git a/Projectiles/Melee/BansheeHookScythe.cs b/Projectiles/Melee/BansheeHookScythe.cs index 18dc5b5112..36677f7cf3 100644 --- a/Projectiles/Melee/BansheeHookScythe.cs +++ b/Projectiles/Melee/BansheeHookScythe.cs @@ -2,11 +2,13 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Melee { public class BansheeHookScythe : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; + public override void SetDefaults() { Projectile.width = 38; @@ -24,7 +26,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.penetrate = -1; Projectile.timeLeft = 90; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; + Projectile.localNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Melee/Cyclone.cs b/Projectiles/Melee/Cyclone.cs index e079ace083..0a14bde12d 100644 --- a/Projectiles/Melee/Cyclone.cs +++ b/Projectiles/Melee/Cyclone.cs @@ -1,10 +1,10 @@ -using System; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; +using System; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using Terraria.Audio; namespace CalamityMod.Projectiles.Melee { @@ -20,8 +20,8 @@ namespace CalamityMod.Projectiles.Melee public override void SetDefaults() { - Projectile.width = 36; - Projectile.height = 36; + Projectile.width = 56; + Projectile.height = 56; Projectile.alpha = 255; Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Melee for (int i = 1; i <= 6; i++) { Vector2 dustspeed = new Vector2(3f, 3f).RotatedBy(MathHelper.ToRadians(dustvortex)); - int d = Dust.NewDust(Projectile.Center, Projectile.width / 2, Projectile.height / 2, DustID.Smoke, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.3f); + int d = Dust.NewDust(Projectile.Center, Projectile.width / 2, Projectile.height / 2, 31, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.3f); Main.dust[d].noGravity = true; Main.dust[d].velocity = dustspeed; dustvortex += 60; @@ -63,18 +63,20 @@ namespace CalamityMod.Projectiles.Melee Projectile.ai[1] = 0; } } - float projX = Projectile.Center.X; - float projY = Projectile.Center.Y; - foreach (var npc in Main.ActiveNPCs) + float num472 = Projectile.Center.X; + float num473 = Projectile.Center.Y; + float num474 = 600f; + for (int num475 = 0; num475 < Main.maxNPCs; num475++) { + NPC npc = Main.npc[num475]; if (npc.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, npc.Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) { float npcCenterX = npc.position.X + (float)(npc.width / 2); float npcCenterY = npc.position.Y + (float)(npc.height / 2); - float npcDistance = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY); - if (npcDistance < 600f) + float num478 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY); + if (num478 < num474) { - if (npc.position.X < projX) + if (npc.position.X < num472) { npc.velocity.X += 0.05f; } @@ -82,7 +84,7 @@ namespace CalamityMod.Projectiles.Melee { npc.velocity.X -= 0.05f; } - if (npc.position.Y < projY) + if (npc.position.Y < num473) { npc.velocity.Y += 0.05f; } @@ -113,7 +115,7 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i <= 360; i += 3) { Vector2 dustspeed = new Vector2(3f, 3f).RotatedBy(MathHelper.ToRadians(i)); - int d = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, DustID.Smoke, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.4f); + int d = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 31, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.4f); Main.dust[d].noGravity = true; Main.dust[d].position = Projectile.Center; Main.dust[d].velocity = dustspeed; diff --git a/Projectiles/Melee/DarkMasterClone.cs b/Projectiles/Melee/DarkMasterClone.cs index d225c57331..be519e6b44 100644 --- a/Projectiles/Melee/DarkMasterClone.cs +++ b/Projectiles/Melee/DarkMasterClone.cs @@ -15,25 +15,32 @@ namespace CalamityMod.Projectiles.Melee public new string LocalizationCategory => "Projectiles.Melee"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + public Player clone; + public override void SetDefaults() { Projectile.width = 20; Projectile.height = 42; Projectile.friendly = true; Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Melee; - Projectile.timeLeft = 300; - Projectile.penetrate = -1; Projectile.tileCollide = false; + Projectile.DamageType = DamageClass.Melee; + Projectile.ContinuouslyUpdateDamageStats = true; } public override void AI() { + // if the player isn't holding the sword, DIE. + if (Owner.HeldItem.type != ModContent.ItemType() || !Owner.active || Owner.CCed || Owner == null) + { + Projectile.Kill(); + return; + } // if the velocity is not zero, the visuals get offset weirdly Projectile.velocity = Vector2.Zero; - Player owner = Main.player[Projectile.owner]; // how far the clone should move from the player - Vector2 moveTo = new Vector2(0, -160); + Vector2 moveTo = Vector2.UnitY * -160f; switch (Projectile.ai[0]) { case 1: @@ -43,39 +50,34 @@ namespace CalamityMod.Projectiles.Melee moveTo = new Vector2(180, 120); break; default: - moveTo = new Vector2(0, -160); break; } - // if the player isn't holding the sword, DIE. - if (owner.HeldItem.type != ModContent.ItemType() || !owner.active || owner.CCed || owner == null) - { - Projectile.Kill(); - } // if all conditions above aren't met, the clone can stick around forever - Projectile.timeLeft = 30; + Projectile.timeLeft = 2; // move the clone to the desired position - Projectile.Center = Vector2.Lerp(Projectile.Center, owner.Center + moveTo, 0.4f); + Projectile.Center = Vector2.Lerp(Projectile.Center, Owner.Center + moveTo, 0.4f); // produce smoke during initial move - if (Projectile.Distance(owner.Center + moveTo) < 16) + if (Projectile.Distance(Owner.Center + moveTo) < 16) { Projectile.ai[2] = 1; } if (Projectile.ai[2] == 0) { - float angle = MathHelper.TwoPi * Main.rand.NextFloat(0f, 1f); + float angle = Main.rand.NextFloat(0f, MathHelper.TwoPi); Vector2 angleVec = angle.ToRotationVector2(); Particle smoke = new HeavySmokeParticle(Projectile.Center, angleVec * Main.rand.NextFloat(1f, 2f), Color.Black, 30, Main.rand.NextFloat(0.25f, 1f), 0.5f, 0.1f); GeneralParticleHandler.SpawnParticle(smoke); } // shoot beams while the player is left clicking - if (owner.itemTime == owner.itemTimeMax && owner.altFunctionUse != 2 && owner.HeldItem.type == ModContent.ItemType()) + if (Projectile.ai[1] > 0) { + Projectile.ai[1] = 0; Vector2 direction = Projectile.Center.DirectionTo(Main.MouseWorld); Projectile.direction = Math.Sign(direction.X); if (Projectile.owner == Main.myPlayer) { // ai[1] not being 0 determines if the projectile should always ignore tiles - Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center, direction * owner.HeldItem.shootSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4f), Projectile.knockBack, Projectile.owner, 1, 1); + Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center, direction * Owner.HeldItem.shootSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4f), Projectile.knockBack, Projectile.owner, 1, 1); } } } @@ -86,7 +88,7 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < 8; i++) { - float angle = MathHelper.TwoPi * Main.rand.NextFloat(0f, 1f); + float angle = Main.rand.NextFloat(0f, MathHelper.TwoPi); Vector2 angleVec = angle.ToRotationVector2(); Particle smoke = new HeavySmokeParticle(Projectile.Center, angleVec * Main.rand.NextFloat(2f, 4f), Color.Black, 60, Main.rand.NextFloat(0.45f, 1.22f), 0.6f, 0.1f); GeneralParticleHandler.SpawnParticle(smoke); @@ -96,58 +98,51 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { // make a player visual clone. it inherits the player's hair type and clothes style and is otherwise all black with red pupils - Main.playerVisualClone[Projectile.owner] ??= new(); - Player owner = Main.player[Projectile.owner]; - - Player player = Main.playerVisualClone[Projectile.owner]; - player.CopyVisuals(Main.player[Projectile.owner]); - player.hair = owner.hair; - player.skinVariant = owner.skinVariant; - player.skinColor = Color.Black; - player.shirtColor = Color.Black; - player.underShirtColor = Color.Black; - player.pantsColor = Color.Black; - player.shoeColor = Color.Black; - player.hairColor = Color.Black; - player.eyeColor = Color.Red; + // Main.playerVisualClone[Projectile.owner] will throw stack trace errors on reloads + clone ??= new Player(); + clone.CopyVisuals(Owner); + clone.skinColor = Color.Black; + clone.shirtColor = Color.Black; + clone.underShirtColor = Color.Black; + clone.pantsColor = Color.Black; + clone.shoeColor = Color.Black; + clone.hairColor = Color.Black; + clone.eyeColor = Color.Red; // become one with the shadows - for (int i = 0; i < player.dye.Length; i++) + for (int i = 0; i < clone.dye.Length; i++) { - if (player.dye[i].type != ItemID.ShadowDye) + if (clone.dye[i].type != ItemID.ShadowDye) { - player.dye[i].SetDefaults(ItemID.ShadowDye); + clone.dye[i].SetDefaults(ItemID.ShadowDye); } } // update everything for our little dummy player - player.ResetEffects(); - player.ResetVisibleAccessories(); - player.DisplayDollUpdate(); - player.UpdateSocialShadow(); - player.UpdateDyes(); - player.PlayerFrame(); + clone.ResetEffects(); + clone.ResetVisibleAccessories(); + clone.DisplayDollUpdate(); + clone.UpdateSocialShadow(); + clone.UpdateDyes(); + clone.PlayerFrame(); // copy the player's arm movements while swinging, otherwise idle - if (owner.ItemAnimationActive && owner.altFunctionUse != 2) - player.bodyFrame = owner.bodyFrame; + if (Owner.ItemAnimationActive && Owner.altFunctionUse != 2) + clone.bodyFrame = Owner.bodyFrame; else - player.bodyFrame.Y = 0; + clone.bodyFrame.Y = 0; // legs never jump or walk - player.legFrame.Y = 0; + clone.legFrame.Y = 0; // face towards the player's cursor - player.direction = Math.Sign(Projectile.DirectionTo(Main.MouseWorld).X); - Main.PlayerRenderer.DrawPlayer(Main.Camera, player, Projectile.position, 0f, player.fullRotationOrigin, 0f, 1f); + clone.direction = Math.Sign(Projectile.DirectionTo(Main.MouseWorld).X); + Main.PlayerRenderer.DrawPlayer(Main.Camera, clone, Projectile.position, 0f, clone.fullRotationOrigin, 0f, 1f); // draw the sword - if (owner.ItemAnimationActive && owner.altFunctionUse != 2) + if (Owner.ItemAnimationActive && Owner.altFunctionUse != 2) { Texture2D Sword = ModContent.Request("CalamityMod/Items/Weapons/Melee/TheDarkMaster").Value; - Vector2 distToPlayer = Projectile.position - owner.position; - Main.EntitySpriteDraw(Sword, (Vector2)owner.HandPosition + distToPlayer - Main.screenPosition, null, lightColor, owner.direction == player.direction ? owner.itemRotation : -owner.itemRotation, new Vector2(player.direction == 1 ? 0 : Sword.Width, Sword.Height), 1f, player.direction == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally); + Vector2 distToPlayer = Projectile.position - Owner.position; + Main.EntitySpriteDraw(Sword, (Vector2)Owner.HandPosition + distToPlayer - Main.screenPosition, null, lightColor, Owner.direction == clone.direction ? Owner.itemRotation : -Owner.itemRotation, new Vector2(clone.direction == 1 ? 0 : Sword.Width, Sword.Height), 1f, clone.direction == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally); } return false; } - public override bool? CanDamage() - { - return false; - } + public override bool? CanDamage() => false; } } diff --git a/Projectiles/Melee/DarklightGreatswordSlash.cs b/Projectiles/Melee/DarklightGreatswordSlash.cs index 240b16bdc5..f745eabf07 100644 --- a/Projectiles/Melee/DarklightGreatswordSlash.cs +++ b/Projectiles/Melee/DarklightGreatswordSlash.cs @@ -1,4 +1,6 @@ using System; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -34,6 +36,11 @@ namespace CalamityMod.Projectiles.Melee { Projectile.rotation = Projectile.velocity.ToRotation(); Projectile.Opacity = Projectile.timeLeft / 35f; + if (Projectile.timeLeft == 34) + { + Particle spark2 = new GlowSparkParticle(Projectile.Center, new Vector2(0.1f, 0.1f).RotatedByRandom(100), false, 12, Main.rand.NextFloat(0.03f, 0.05f), Main.rand.NextBool() ? Color.Pink : Color.Cyan, new Vector2(2, 0.5f), true); + GeneralParticleHandler.SpawnParticle(spark2); + } } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.RotatingHitboxCollision(targetHitbox.TopLeft(), targetHitbox.Size()); @@ -44,30 +51,6 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - if (Projectile.timeLeft >= 34f) - return false; - - Main.spriteBatch.SetBlendState(BlendState.Additive); - - float progress = (33f - Projectile.timeLeft) / 33f; - - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Texture2D bloomTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; - - Vector2 drawPosition = Projectile.Center - Main.screenPosition; - Vector2 origin = texture.Size() * 0.5f; - Vector2 scale = new Vector2(MathHelper.Lerp(0.8f, 1.25f, (float)Math.Pow(progress, 0.45)), MathHelper.Lerp(0.6f, 0.24f, (float)Math.Pow(progress, 0.4))) * Projectile.scale; - - // Draw an inner bloom circle to signify power at the center of the strike along with two thinner lines. - Vector2 bloomScale = Projectile.Size / bloomTexture.Size() * new Vector2(1f, 2f); - Vector2 bloomOrigin = bloomTexture.Size() * 0.5f; - Color outerSlashColor = Projectile.ai[2] == 0f ? Color.DarkBlue : Color.DarkRed; - Color innerSlashColor = Projectile.ai[2] == 0f ? Color.Cyan : Color.Pink; - Main.spriteBatch.Draw(bloomTexture, drawPosition, null, outerSlashColor * Projectile.Opacity, Projectile.rotation, bloomOrigin, bloomScale, 0, 0f); - Main.spriteBatch.Draw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, scale, 0, 0f); - Main.spriteBatch.Draw(texture, drawPosition, null, innerSlashColor * Projectile.Opacity, Projectile.rotation, origin, scale * new Vector2(1f, 0.6f), 0, 0f); - - Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); return false; } } diff --git a/Projectiles/Melee/DepthCrusherProjectile.cs b/Projectiles/Melee/DepthCrusherProjectile.cs index 8e65dbcd00..d0b0e7f55d 100644 --- a/Projectiles/Melee/DepthCrusherProjectile.cs +++ b/Projectiles/Melee/DepthCrusherProjectile.cs @@ -105,7 +105,7 @@ namespace CalamityMod.Projectiles.Melee } Projectile.rotation += (0.4f * (MathF.Abs(Projectile.velocity.Y) * 0.2f + 0.6f)) * Projectile.direction; - if (Projectile.velocity.Y < 20) + if (Projectile.velocity.Y < 16) Projectile.velocity.Y += Projectile.numHits >= 3 ? 0.7f : 0.4f; if (Projectile.numHits >= 3) { @@ -119,7 +119,7 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.velocity.Y > 0) Projectile.velocity.X *= 0.975f; - if (Collision.SolidCollision(Projectile.Center, 15, 15)) + if (Collision.SolidCollision(Projectile.Center, 25, 25)) { Projectile.tileCollide = true; } @@ -133,9 +133,9 @@ namespace CalamityMod.Projectiles.Melee if (!setDamage) { if (Projectile.velocity.Y > 0) - Projectile.velocity.Y = -9; + Projectile.velocity.Y -= 6; else - Projectile.velocity.Y = -7; + Projectile.velocity.Y = -6; } for (int i = 0; i < 15; i++) @@ -195,7 +195,7 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(HitSound, Projectile.Center); for (int i = 0; i < 3; i++) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, new Vector2(0, -5).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.9f, 1.1f), ModContent.ProjectileType(), startDamage / 4, Projectile.knockBack / 4, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Bottom, new Vector2(0, -5).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.9f, 1.1f), ModContent.ProjectileType(), (int)(startDamage * 0.3f), Projectile.knockBack / 4, Projectile.owner); } Projectile.Kill(); } diff --git a/Projectiles/Melee/DepthCrusherSplitProjectile.cs b/Projectiles/Melee/DepthCrusherSplitProjectile.cs index 5c2b6ef338..4da528c2f8 100644 --- a/Projectiles/Melee/DepthCrusherSplitProjectile.cs +++ b/Projectiles/Melee/DepthCrusherSplitProjectile.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Melee } if (Time > 20 && Time < (randTimer - 70)) { - CalamityUtils.HomeInOnNPC(Projectile, true, 280f, MathHelper.Clamp(1f + Time * 0.06f, 1, 10), 20f); + CalamityUtils.HomeInOnNPC(Projectile, true, 384f, MathHelper.Clamp(1f + Time * 0.12f, 1, 11), 20f); } else if (Time >= (randTimer - 70)) { diff --git a/Projectiles/Melee/ExobeamSlash.cs b/Projectiles/Melee/ExobeamSlash.cs index 556a8b8b79..c93a8ee983 100644 --- a/Projectiles/Melee/ExobeamSlash.cs +++ b/Projectiles/Melee/ExobeamSlash.cs @@ -1,5 +1,7 @@ using System; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -32,6 +34,11 @@ namespace CalamityMod.Projectiles.Melee { Projectile.rotation = Projectile.velocity.ToRotation(); Projectile.Opacity = Projectile.timeLeft / 35f; + if (Projectile.timeLeft == 34) + { + Particle spark2 = new GlowSparkParticle(Projectile.Center, new Vector2(0.1f, 0.1f).RotatedByRandom(100), false, 12, Main.rand.NextFloat(0.05f, 0.09f), (Main.rand.NextBool() ? Color.Cyan : Main.rand.NextBool() ? Color.LightGoldenrodYellow : Color.Lime) * 0.7f, new Vector2(2, 0.5f), true); + GeneralParticleHandler.SpawnParticle(spark2); + } } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) @@ -55,28 +62,6 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - if (Projectile.timeLeft > 33) - return false; - - Main.spriteBatch.SetBlendState(BlendState.Additive); - - float progress = (33 - Projectile.timeLeft) / 33f; - - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Texture2D bloomTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; - - Vector2 drawPosition = Projectile.Center - Main.screenPosition; - Vector2 origin = texture.Size() * 0.5f; - Vector2 scale = new Vector2(0.5f + 0.7f * (float)Math.Pow(progress, 0.45), 0.55f - 0.3f * (float)Math.Pow(progress, 0.4)) * Projectile.scale; - - - Vector2 bloomScale = Projectile.Size / bloomTexture.Size() * new Vector2(1f, 2f); - Vector2 bloomOrigin = bloomTexture.Size() * 0.5f; - Main.spriteBatch.Draw(bloomTexture, drawPosition, null, Color.White * Projectile.Opacity, Projectile.rotation, bloomOrigin, bloomScale, 0, 0f); - Main.spriteBatch.Draw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, scale, 0, 0f); - Main.spriteBatch.Draw(texture, drawPosition, null, Color.White * Projectile.Opacity, Projectile.rotation, origin, scale * new Vector2(1f, 0.6f), 0, 0f); - - Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); return false; } } diff --git a/Projectiles/Melee/ExobladeProj.cs b/Projectiles/Melee/ExobladeProj.cs index 028976e98e..c754b6d14e 100644 --- a/Projectiles/Melee/ExobladeProj.cs +++ b/Projectiles/Melee/ExobladeProj.cs @@ -363,6 +363,10 @@ namespace CalamityMod.Projectiles.Melee Projectile.velocity = Owner.MountedCenter.DirectionTo(Owner.Calamity().mouseWorld); Projectile.oldPos = new Vector2[Projectile.oldPos.Length]; + + // Prevent zeroed out garbage from messing up the trail rendering. + for (int i = 0; i < Projectile.oldPos.Length; ++i) + Projectile.oldPos[i] = Projectile.position; } // Do the dash. @@ -418,8 +422,6 @@ namespace CalamityMod.Projectiles.Melee Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4 * Direction; } - - public float SlashWidthFunction(float completionRatio) => SquishAtProgress(RealProgressionAtTrailCompletion(completionRatio)) * Projectile.scale * 60.5f; public Color SlashColorFunction(float completionRatio) => Color.Lime * Utils.GetLerpValue(0.9f, 0.4f, completionRatio, true) * Projectile.Opacity; @@ -487,7 +489,6 @@ namespace CalamityMod.Projectiles.Melee Main.spriteBatch.EnterShaderRegion(); - Color mainColor = MulticolorLerp((Main.GlobalTimeWrappedHourly * 2f) % 1, Color.Cyan, Color.Lime, Color.GreenYellow, Color.Goldenrod, Color.Orange); Color secondaryColor = MulticolorLerp((Main.GlobalTimeWrappedHourly * 2f + 0.2f) % 1, Color.Cyan, Color.Lime, Color.GreenYellow, Color.Goldenrod, Color.Orange); @@ -500,7 +501,13 @@ namespace CalamityMod.Projectiles.Melee GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(mainColor); GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(secondaryColor); GameShaders.Misc["CalamityMod:ExobladePierce"].Apply(); - PrimitiveRenderer.RenderTrail(Projectile.oldPos.Take(51).ToArray(), new(PierceWidthFunction, PierceColorFunction, (_) => trailOffset, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 53); + + // Exoblade tracks 120 positions in oldPos. + // Provide 60 points for smoothing, but only render 30 + int numPointsRendered = 30; + int numPointsProvided = 60; + var positionsToUse = Projectile.oldPos.Take(numPointsProvided).ToArray(); + PrimitiveRenderer.RenderTrail(positionsToUse, new(PierceWidthFunction, PierceColorFunction, (_) => trailOffset, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), numPointsRendered); Main.spriteBatch.ExitShaderRegion(); } diff --git a/Projectiles/Melee/Feather.cs b/Projectiles/Melee/Feather.cs index fade5444c1..507f59ee20 100644 --- a/Projectiles/Melee/Feather.cs +++ b/Projectiles/Melee/Feather.cs @@ -23,6 +23,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.penetrate = 1; Projectile.timeLeft = TimeLeft; Projectile.aiStyle = ProjAIStyleID.Arrow; + Projectile.extraUpdates = 1; } public override void AI() diff --git a/Projectiles/Melee/JudgementProj.cs b/Projectiles/Melee/JudgementProj.cs index 49de81f947..0137b32032 100644 --- a/Projectiles/Melee/JudgementProj.cs +++ b/Projectiles/Melee/JudgementProj.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Projectiles.Melee public new string LocalizationCategory => "Projectiles.Melee"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - int whiteLightTimer = 5; + int whiteLightTimer = 15; public override void SetDefaults() { @@ -20,7 +20,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.penetrate = -1; - Projectile.timeLeft = 60; + Projectile.timeLeft = 90; Projectile.DamageType = DamageClass.Melee; Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 10; @@ -41,15 +41,15 @@ namespace CalamityMod.Projectiles.Melee for (i = 0; i < 1; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - int projectile1 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - int projectile2 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); + int projectile1 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack * 0.5f, Projectile.owner); + int projectile2 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack * 0.5f, Projectile.owner); Main.projectile[projectile1].velocity.X *= 0.1f; Main.projectile[projectile1].velocity.Y *= 0.1f; Main.projectile[projectile2].velocity.X *= 0.1f; Main.projectile[projectile2].velocity.Y *= 0.1f; } } - whiteLightTimer = 5; + whiteLightTimer = 15; } Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f); @@ -62,16 +62,14 @@ namespace CalamityMod.Projectiles.Melee Main.dust[shinyDust].velocity += Projectile.velocity * 0.1f; } - CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 9f, 20f); + CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 10f, 20f); } public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item122, Projectile.position); if (Projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y - 100, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - } + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y - 100, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); } } } diff --git a/Projectiles/Melee/PrismTooth.cs b/Projectiles/Melee/PrismTooth.cs index d7a1981016..27b738b95c 100644 --- a/Projectiles/Melee/PrismTooth.cs +++ b/Projectiles/Melee/PrismTooth.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Graphics.Primitives; using Microsoft.Xna.Framework; @@ -22,7 +23,7 @@ namespace CalamityMod.Projectiles.Melee public override void SetStaticDefaults() { ProjectileID.Sets.TrailingMode[Projectile.type] = 2; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 36; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 90; } public override void SetDefaults() @@ -42,6 +43,14 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { + // Frame 1 effect: Prevent zeroed out garbage from messing up the trail rendering. + if (Projectile.localAI[1] == 0f) + { + Projectile.localAI[1] = 1f; + for (int i = 0; i < Projectile.oldPos.Length; ++i) + Projectile.oldPos[i] = Projectile.position; + } + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.Pi * Time / Lifetime; Vector2 baseDirection = (MathHelper.TwoPi * Time / Lifetime - MathHelper.PiOver2).ToRotationVector2(); @@ -128,7 +137,12 @@ namespace CalamityMod.Projectiles.Melee Main.spriteBatch.EnterShaderRegion(); GameShaders.Misc["CalamityMod:PrismaticStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + generalOffset, shader: GameShaders.Misc["CalamityMod:PrismaticStreak"]), 65); + // Photon Ripper tracks 90 positions in oldPos. + // Provide 60 points for smoothing, but only render 12 + int numPointsRendered = 12; + int numPointsProvided = 60; + var positionsToUse = Projectile.oldPos.Take(numPointsProvided).ToArray(); + PrimitiveRenderer.RenderTrail(positionsToUse, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + generalOffset, shader: GameShaders.Misc["CalamityMod:PrismaticStreak"], smoothen: false), numPointsRendered); Main.spriteBatch.ExitShaderRegion(); return true; } diff --git a/Projectiles/Melee/PrismaticBeam.cs b/Projectiles/Melee/PrismaticBeam.cs index e043fec076..34a62917e7 100644 --- a/Projectiles/Melee/PrismaticBeam.cs +++ b/Projectiles/Melee/PrismaticBeam.cs @@ -61,8 +61,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.width = 6; Projectile.height = 6; Projectile.friendly = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.DamageType = DamageClass.Melee; + Projectile.DamageType = MeleeRangedHybridDamageClass.Instance; Projectile.scale = 1.5f; Projectile.penetrate = -1; Projectile.tileCollide = false; diff --git a/Projectiles/Melee/PrismaticWave.cs b/Projectiles/Melee/PrismaticWave.cs index 582a55ff9b..532d89d457 100644 --- a/Projectiles/Melee/PrismaticWave.cs +++ b/Projectiles/Melee/PrismaticWave.cs @@ -50,8 +50,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.height = 36; Projectile.friendly = true; Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.DamageType = DamageClass.Melee; + Projectile.DamageType = MeleeRangedHybridDamageClass.Instance; Projectile.penetrate = 2; Projectile.timeLeft = 360; Projectile.tileCollide = false; diff --git a/Projectiles/Melee/RespiteblockBlood.cs b/Projectiles/Melee/RespiteblockBlood.cs new file mode 100644 index 0000000000..ef683feae8 --- /dev/null +++ b/Projectiles/Melee/RespiteblockBlood.cs @@ -0,0 +1,78 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using SteelSeries.GameSense; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Melee +{ + public class RespiteblockBlood : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Color mainColor = Color.White; + public int time = 0; + + public override void SetDefaults() + { + Projectile.width = 45; + Projectile.height = 45; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; // Because it has a large hitbox it has custom tile kill + Projectile.penetrate = -1; + Projectile.timeLeft = 900; + Projectile.extraUpdates = 7; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.DamageType = DamageClass.Melee; + } + public override void AI() + { + if (mainColor == Color.White) + { + mainColor = Main.rand.NextBool() ? Color.Green : Color.Purple; + } + + if (Collision.SolidCollision(Projectile.Center, 5, 5)) + Projectile.Kill(); + + Lighting.AddLight(Projectile.Center, Color.Lerp(mainColor, Color.White, 0.5f).ToVector3()); + + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); //used for some drawing prevention for when it's offscreen since it makes a fuck load of particles + if (Projectile.timeLeft % 2 == 0 && time >= 1f && targetDist < 1400f) + { + Particle spark = new WaterFlavoredParticle(Projectile.Center, -Projectile.velocity * 0.05f, false, 6, 0.8f, (mainColor * 0.65f) * Utils.GetLerpValue(0, 90, time, true)); + GeneralParticleHandler.SpawnParticle(spark); + } + if (Main.rand.NextBool(4)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, mainColor == Color.Green ? 89 : 86, -Projectile.velocity * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.8f, 1.1f)); + dust.noGravity = true; + dust.noLight = true; + dust.noLightEmittence = true; + dust.alpha = 90; + } + + Projectile.velocity.X *= 0.998f; + Projectile.velocity.Y += 0.01f; + + time++; + } + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 4; i++) + { + Particle blood = new PointParticle(Projectile.Center, (-Projectile.velocity * 2).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.2f, 0.9f) + new Vector2(0, Main.rand.NextFloat(-5, -1 + 1)), true, 20, Main.rand.NextFloat(0.7f, 1.2f), mainColor * 0.5f, false); + GeneralParticleHandler.SpawnParticle(blood); + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 180); + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 45, targetHitbox); + } +} diff --git a/Projectiles/Melee/RespiteblockHoldout.cs b/Projectiles/Melee/RespiteblockHoldout.cs new file mode 100644 index 0000000000..63838d7431 --- /dev/null +++ b/Projectiles/Melee/RespiteblockHoldout.cs @@ -0,0 +1,203 @@ +using System; +using CalamityMod.Particles; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent.Achievements; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class RespiteblockHoldout : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public Player Owner => Main.player[Projectile.owner]; + public ref float Time => ref Projectile.ai[0]; + + public override void SetStaticDefaults() => Main.projFrames[Type] = 4; + + public override void SetDefaults() + { + Projectile.width = 108; + Projectile.height = 40; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.DamageType = DamageClass.Melee; + Projectile.ownerHitCheck = true; + // No reason to ID-static the chainsaw -- multiple players can true melee simultaneously! + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 4; + Projectile.noEnchantmentVisuals = true; + Projectile.ArmorPenetration = 15; + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, direction, 0); + return false; + } + + public override void AI() + { + // Recalculate damage every frame for balance reasons, as this is a long-lasting holdout. + // This is important because you could start using it while benefitting from Auric Tesla standstill bonus, for example. + Projectile.damage = Owner.ActiveItem() is null ? 0 : Owner.GetWeaponDamage(Owner.ActiveItem()); + + PlayChainsawSounds(); + + // Determines the owner's position whilst incorporating their fullRotation field. + // It uses vector transformation on a Z rotation matrix based on said rotation under the hood. + // This is essentially just the pure mathematical definition of the RotatedBy method. + Vector2 playerRotatedPosition = Owner.RotatedRelativePoint(Owner.MountedCenter); + if (Main.myPlayer == Projectile.owner) + { + if (!Owner.CantUseHoldout() && Owner.active && !Owner.dead) + HandleChannelMovement(playerRotatedPosition); + else + Projectile.Kill(); + } + + Lighting.AddLight(Projectile.Center, Color.White.ToVector3()); + + for (int i = 0; i <= 3; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + (Projectile.velocity.RotatedBy(MathHelper.ToRadians(45f * Projectile.direction)) * 10) + Main.rand.NextVector2Circular(13, 13), Main.rand.NextBool() ? 89 : 86, (Projectile.velocity * 30).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.05f, 0.9f), 0, default, Main.rand.NextFloat(0.4f, 0.95f)); + dust.noGravity = true; + dust.noLight = true; + dust.noLightEmittence = true; + dust.alpha = 90; + } + if (Time % 4 == 0) + { + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center + (Projectile.velocity.RotatedBy(MathHelper.ToRadians(45f * Projectile.direction)) * 10) + Main.rand.NextVector2Circular(13, 13) + Projectile.velocity * Main.rand.Next(10, 20 + 1), Projectile.velocity.RotatedBy(Main.rand.NextFloat(-0.01f, -0.25f) * Projectile.direction) * 4, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4f), Projectile.knockBack, Projectile.owner, 0); + } + + DetermineVisuals(playerRotatedPosition); + ManipulatePlayerValues(); + + // Prevent the projectile from dying normally. However, if anything for whatever reason + // goes wrong it will immediately be destroyed on the next frame. + Projectile.timeLeft = 2; + + Time++; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 500); + + Player player = Main.player[Projectile.owner]; + Vector2 spawnPos = Projectile.Center + (Projectile.velocity.RotatedBy(MathHelper.ToRadians(45f * Projectile.direction)) * 10) + Main.rand.NextVector2Circular(13, 13); + for (int i = 0; i <= 3; i++) + { + spawnPos = Projectile.Center + (Projectile.velocity.RotatedBy(MathHelper.ToRadians(45f * Projectile.direction)) * 10) + Main.rand.NextVector2Circular(13, 13); + Particle blood = new PointParticle(spawnPos, (Projectile.velocity * 30).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.2f, 0.9f) + new Vector2(0, Main.rand.NextFloat(-7, -2 + 1)), true, 25, Main.rand.NextFloat(0.7f, 1.2f), (Main.rand.NextBool() ? Color.Green : Color.Purple) * 0.5f, false); + GeneralParticleHandler.SpawnParticle(blood); + + Dust dust = Dust.NewDustPerfect(spawnPos, 263, (Projectile.velocity * 50).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.05f, 0.9f), 0, default, Main.rand.NextFloat(0.6f, 0.95f)); + dust.noGravity = true; + dust.color = Color.White; + } + + SoundStyle fire = new("CalamityMod/Sounds/Item/WulfrumKnifeTileHit", 2); + SoundEngine.PlaySound(fire with { Volume = 0.55f, Pitch = 0.3f }, Projectile.Center); + + if (player.moonLeech || player.lifeSteal <= 0f || target.lifeMax <= 5) + return; + + int heal = Main.rand.NextBool(4) ? 2 : 1; + player.lifeSteal -= heal; + player.statLife += heal; + player.HealEffect(heal); + if (player.statLife > player.statLifeMax2) + player.statLife = player.statLifeMax2; + } + + public void PlayChainsawSounds() + { + if (Projectile.soundDelay <= 0) + { + SoundEngine.PlaySound(SoundID.Item22 with { Pitch = 0.3f}, Projectile.Center); + Projectile.soundDelay = 6; + } + } + public void DetermineVisuals(Vector2 playerRotatedPosition) + { + float directionAngle = Projectile.velocity.ToRotation(); + Projectile.rotation = directionAngle; + + int oldDirection = Projectile.spriteDirection; + if (oldDirection == -1) + Projectile.rotation += MathHelper.Pi; + + Projectile.direction = Projectile.spriteDirection = (Math.Cos(directionAngle) > 0).ToDirectionInt(); + + // If the direction differs from what it originaly was, undo the previous 180 degree turn. + // If this is not done, the chainsaw will have 1 frame of rotational "jitter" when the direction changes based on the + // original angle. This effect looks very strange in-game. + if (Projectile.spriteDirection != oldDirection) + Projectile.rotation -= MathHelper.Pi; + + // Positioning close to the player's arm. + Projectile.position = playerRotatedPosition - Projectile.Size * 0.5f + (directionAngle.ToRotationVector2().RotatedBy(MathHelper.ToRadians(-45f * Projectile.direction)) * 10f) + directionAngle.ToRotationVector2() * 30; + + // Update the position a tiny bit every frame at random to make it look like the saw is vibrating. + // It is reset on the next frame. + Projectile.position += Main.rand.NextVector2Circular(1.4f, 1.4f); + + Projectile.frameCounter += 33; + if (Projectile.frameCounter >= 32) + { + Projectile.frame = (Projectile.frame + 1) % 4; + Projectile.frameCounter = 0; + } + } + + public void HandleChannelMovement(Vector2 playerRotatedPosition) + { + Vector2 idealAimDirection = (Main.MouseWorld - playerRotatedPosition).SafeNormalize(Vector2.UnitX * Owner.direction); + + float angularAimVelocity = 0.15f; + float directionAngularDisparity = Projectile.velocity.AngleBetween(idealAimDirection) / MathHelper.Pi; + + // Increase the turn speed if close to the ideal direction, since successive linear interpolations + // are asymptotic. + angularAimVelocity += MathHelper.Lerp(0f, 0.25f, Utils.GetLerpValue(0.28f, 0.08f, directionAngularDisparity, true)); + + if (directionAngularDisparity > 0.02f) + Projectile.velocity = Vector2.Lerp(Projectile.velocity, idealAimDirection, angularAimVelocity); + else + Projectile.velocity = idealAimDirection; + + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction); + } + + public void ManipulatePlayerValues() + { + Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.ChangeDir(Projectile.direction); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + // Collision is done as a line to bypass the fact that hitboxes cannot rotate and that + // this projectile is notably flat in terms of sprite shape. + float _ = 0f; + float width = Projectile.scale * 36f; + Vector2 start = Projectile.Center; + Vector2 end = Projectile.Center + Projectile.velocity * 60f; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, width, ref _); + } + } +} diff --git a/Projectiles/Melee/RespiteblockHoldout.png b/Projectiles/Melee/RespiteblockHoldout.png new file mode 100644 index 0000000000..fa4fc9b55e Binary files /dev/null and b/Projectiles/Melee/RespiteblockHoldout.png differ diff --git a/Projectiles/Melee/Spears/BansheeHookProj.cs b/Projectiles/Melee/Spears/BansheeHookProj.cs index d78dc5d844..f93eefbdd9 100644 --- a/Projectiles/Melee/Spears/BansheeHookProj.cs +++ b/Projectiles/Melee/Spears/BansheeHookProj.cs @@ -13,6 +13,7 @@ namespace CalamityMod.Projectiles.Melee.Spears public class BansheeHookProj : BaseSpearProjectile { public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public override void SetDefaults() { Projectile.width = 40; @@ -38,8 +39,9 @@ namespace CalamityMod.Projectiles.Melee.Spears Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + Projectile.velocity * 0.5f, Projectile.velocity * 0.8f, ModContent.ProjectileType(), - Projectile.damage, Projectile.knockBack * 0.85f, Projectile.owner, 0f, 0f); + (int)(Projectile.damage * 0.85f), Projectile.knockBack * 0.85f, Projectile.owner); }; + public override void ExtraBehavior() { Player player = Main.player[Projectile.owner]; @@ -123,13 +125,7 @@ namespace CalamityMod.Projectiles.Melee.Spears public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if (Projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), - target.Center, Vector2.Zero, - ModContent.ProjectileType(), (int)(hit.Damage * 0.25), - 10f, Projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - } + Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(hit.Damage * 0.25), hit.Knockback * 0.25f, Projectile.owner); } } } diff --git a/Projectiles/Melee/Spears/StreamGougeProj.cs b/Projectiles/Melee/Spears/StreamGougeProj.cs index 1f7d7b90fa..49a36ff07b 100644 --- a/Projectiles/Melee/Spears/StreamGougeProj.cs +++ b/Projectiles/Melee/Spears/StreamGougeProj.cs @@ -111,20 +111,16 @@ namespace CalamityMod.Projectiles.Melee.Spears // Black portal. Color color = Color.Lerp(baseColor, Color.Black, 0.55f).MultiplyRGB(Color.DarkGray) * opacity; - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, -rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); - - Main.spriteBatch.SetBlendState(BlendState.Additive); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, -rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); // Cyan portal. color = Color.Lerp(baseColor, Color.Cyan, 0.55f) * opacity * 1.6f; - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, rotation * 0.6f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, rotation * 0.6f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); // Magenta portal. color = Color.Lerp(baseColor, Color.Fuchsia, 0.55f) * opacity * 1.6f; - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, rotation * -0.6f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); - - Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, rotation * -0.6f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); } public override bool PreDraw(ref Color lightColor) @@ -134,8 +130,6 @@ namespace CalamityMod.Projectiles.Melee.Spears { Texture2D smear = ModContent.Request("CalamityMod/Particles/SemiCircularSmear").Value; - Main.spriteBatch.EnterShaderRegion(BlendState.Additive); - float rotation = Projectile.rotation - MathHelper.Pi / 5f; if (SpinDirection == -1f) rotation += MathHelper.Pi; @@ -143,7 +137,7 @@ namespace CalamityMod.Projectiles.Melee.Spears Color smearColor = Color.Fuchsia * CalamityUtils.Convert01To010(SpinCompletion) * 0.9f; Vector2 smearOrigin = smear.Size() * 0.5f; - Main.EntitySpriteDraw(smear, Owner.Center - Main.screenPosition, null, smearColor, rotation, smearOrigin, Projectile.scale * 1.45f, 0, 0); + Main.EntitySpriteDraw(smear, Owner.Center - Main.screenPosition, null, smearColor with { A = 0 }, rotation, smearOrigin, Projectile.scale * 1.45f, 0, 0); Main.spriteBatch.ExitShaderRegion(); } diff --git a/Projectiles/Melee/StreamGougePortal.cs b/Projectiles/Melee/StreamGougePortal.cs index eaccceee17..12c3f98945 100644 --- a/Projectiles/Melee/StreamGougePortal.cs +++ b/Projectiles/Melee/StreamGougePortal.cs @@ -59,6 +59,7 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { + Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Melee/StreamGouge").Value; Vector2 spearDrawPosition = SpearCenter - Main.screenPosition; Vector2 spearOrigin = texture.Size() * 0.5f; @@ -76,19 +77,17 @@ namespace CalamityMod.Projectiles.Melee // Black portal. Color color = Color.Lerp(baseColor, Color.Black, 0.55f).MultiplyRGB(Color.DarkGray) * Projectile.Opacity; - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, -rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); - - Main.spriteBatch.SetBlendState(BlendState.Additive); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, -rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); // Cyan portal. color = Color.Lerp(baseColor, Color.Cyan, 0.55f) * Projectile.Opacity * 1.4f; - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, rotation * 0.6f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, rotation * 0.6f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); // Magenta portal. color = Color.Lerp(baseColor, Color.Fuchsia, 0.55f) * Projectile.Opacity * 1.4f; - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, rotation * -0.7f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); - Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, rotation * -0.7f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); + return false; } diff --git a/Projectiles/Melee/TerratomereExplosion.cs b/Projectiles/Melee/TerratomereExplosion.cs index ecb1d3d4f6..6082d67ae7 100644 --- a/Projectiles/Melee/TerratomereExplosion.cs +++ b/Projectiles/Melee/TerratomereExplosion.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.Melee // Play an explosion sound on the first frame of this projectile's existence. if (Projectile.localAI[0] == 0f) { - SoundEngine.PlaySound(SubsumingVortex.ExplosionSound, Projectile.Center); + SoundEngine.PlaySound(SubsumingVortex.ExplosionSound with { Volume = 0.6f }, Projectile.Center); Projectile.localAI[0] = 1f; } @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.frameCounter++; if (Projectile.frameCounter % 5 == 4) Projectile.frame++; - if (Projectile.frame >= 18) + if (Projectile.frame >= 17) Projectile.Kill(); // Exponentially accelerate. @@ -60,14 +60,15 @@ namespace CalamityMod.Projectiles.Melee Vector2 drawPosition = Projectile.Center - Main.screenPosition; Vector2 origin = frame.Size() * 0.5f; - for (int i = 0; i < 36; i++) + for (int i = 0; i < 2; i++) { Vector2 lightDrawPosition = drawPosition + (MathHelper.TwoPi * i / 36f + Main.GlobalTimeWrappedHourly * 5f).ToRotationVector2() * Projectile.scale * 12f; Color lightBurstColor = CalamityUtils.MulticolorLerp(Projectile.timeLeft / 144f, Terratomere.TerraColor1, Terratomere.TerraColor2); - lightBurstColor = Color.Lerp(lightBurstColor, Color.White, 0.4f) * Projectile.Opacity * 0.184f; + lightBurstColor = Color.Lerp(lightBurstColor, Color.White, 0.4f) * Projectile.Opacity * 0.24f; Main.spriteBatch.Draw(lightTexture, lightDrawPosition, null, lightBurstColor, 0f, lightTexture.Size() * 0.5f, Projectile.scale * 1.32f, SpriteEffects.None, 0); } - Main.spriteBatch.Draw(texture, drawPosition, frame, Color.White, 0f, origin, 1.6f, SpriteEffects.None, 0); + if (Projectile.timeLeft < 149) + Main.spriteBatch.Draw(texture, drawPosition, frame, Color.White, 0f, origin, 1.6f, SpriteEffects.None, 0); } } } diff --git a/Projectiles/Melee/TerratomereHoldoutProj.cs b/Projectiles/Melee/TerratomereHoldoutProj.cs index 9861f0ab15..95ff843ca5 100644 --- a/Projectiles/Melee/TerratomereHoldoutProj.cs +++ b/Projectiles/Melee/TerratomereHoldoutProj.cs @@ -169,21 +169,21 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < totalBeams; i++) { Vector2 randomVelocity = Main.rand.NextVector2CircularEdge(randomVelocityLimit, randomVelocityLimit); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center - bigSlashVelocity * 0.4f, bigSlashVelocity + randomVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center - bigSlashVelocity * 0.4f, bigSlashVelocity + randomVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); } } - // This is a slash, not a beam. + // Close range slash effect if (Main.myPlayer == Projectile.owner && Time == (int)(Terratomere.SwingTime * RecoveryCompletionRatio) + 5f) { Vector2 bigSlashVelocity = InitialRotation.ToRotationVector2() * Owner.ActiveItem().shootSpeed / 6f; Vector2 bigSlashSpawnPosition = Projectile.Center + bigSlashVelocity.SafeNormalize(Vector2.UnitY) * 64f; - int slash = Projectile.NewProjectile(Projectile.GetSource_FromThis(), bigSlashSpawnPosition, bigSlashVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + int slash = Projectile.NewProjectile(Projectile.GetSource_FromThis(), bigSlashSpawnPosition, bigSlashVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); if (Main.projectile.IndexInRange(slash)) { Main.projectile[slash].ai[0] = (Direction == 1f).ToInt(); - Main.projectile[slash].ModProjectile().ControlPoints = GenerateSlashPoints().ToArray(); + Main.projectile[slash].ModProjectile().ControlPoints = GenerateSlashPoints().ToArray(); } } } diff --git a/Projectiles/Melee/TerratomereBeam.cs b/Projectiles/Melee/TerratomereMeleeSlash.cs similarity index 86% rename from Projectiles/Melee/TerratomereBeam.cs rename to Projectiles/Melee/TerratomereMeleeSlash.cs index e25ce01dd4..1f95774c5f 100644 --- a/Projectiles/Melee/TerratomereBeam.cs +++ b/Projectiles/Melee/TerratomereMeleeSlash.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class TerratomereBeam : ModProjectile, ILocalizedModType + public class TerratomereMeleeSlash : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; public Vector2[] ControlPoints; @@ -54,8 +54,8 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < ControlPoints.Length; i++) points.Add(ControlPoints[i] + ControlPoints[i].SafeNormalize(Vector2.Zero) * (Projectile.scale - 1f) * 40f); - for (int i = 0; i < 3; i++) - PrimitiveRenderer.RenderTrail(points, new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Center, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 65); + // 17MAY2024: Ozzatron: remove Terratomere rendering its trails multiple times + PrimitiveRenderer.RenderTrail(points, new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Center, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 65); Main.spriteBatch.ExitShaderRegion(); return false; diff --git a/Projectiles/Melee/TerratomereBeam.png b/Projectiles/Melee/TerratomereMeleeSlash.png similarity index 100% rename from Projectiles/Melee/TerratomereBeam.png rename to Projectiles/Melee/TerratomereMeleeSlash.png diff --git a/Projectiles/Melee/TerratomereSlash.cs b/Projectiles/Melee/TerratomereSlash.cs index eb7bdb2e23..56677a094d 100644 --- a/Projectiles/Melee/TerratomereSlash.cs +++ b/Projectiles/Melee/TerratomereSlash.cs @@ -1,4 +1,6 @@ using System; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -33,6 +35,11 @@ namespace CalamityMod.Projectiles.Melee { Projectile.rotation = Projectile.velocity.ToRotation(); Projectile.Opacity = Projectile.timeLeft / 35f; + if (Projectile.timeLeft == 34) + { + Particle spark2 = new GlowSparkParticle(Projectile.Center, new Vector2(0.1f, 0.1f).RotatedByRandom(100), false, 12, Main.rand.NextFloat(0.05f, 0.09f), Main.rand.NextBool() ? Terratomere.TerraColor1 : Terratomere.TerraColor2, new Vector2(2, 0.5f), true); + GeneralParticleHandler.SpawnParticle(spark2); + } } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) @@ -46,28 +53,6 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - if (Projectile.timeLeft >= 34f) - return false; - - Main.spriteBatch.SetBlendState(BlendState.Additive); - - float progress = (33f - Projectile.timeLeft) / 33f; - - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Texture2D bloomTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; - - Vector2 drawPosition = Projectile.Center - Main.screenPosition; - Vector2 origin = texture.Size() * 0.5f; - Vector2 scale = new Vector2(MathHelper.Lerp(0.8f, 1.25f, (float)Math.Pow(progress, 0.45)), MathHelper.Lerp(0.6f, 0.24f, (float)Math.Pow(progress, 0.4))) * Projectile.scale; - - // Draw an inner bloom circle to signify power at the center of the strike along with two thinner lines. - Vector2 bloomScale = Projectile.Size / bloomTexture.Size() * new Vector2(1f, 2f); - Vector2 bloomOrigin = bloomTexture.Size() * 0.5f; - Main.spriteBatch.Draw(bloomTexture, drawPosition, null, Color.White * Projectile.Opacity, Projectile.rotation, bloomOrigin, bloomScale, 0, 0f); - Main.spriteBatch.Draw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, scale, 0, 0f); - Main.spriteBatch.Draw(texture, drawPosition, null, Color.White * Projectile.Opacity, Projectile.rotation, origin, scale * new Vector2(1f, 0.6f), 0, 0f); - - Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); return false; } } diff --git a/Projectiles/Melee/TerratomereBigSlash.cs b/Projectiles/Melee/TerratomereSwordBeam.cs similarity index 79% rename from Projectiles/Melee/TerratomereBigSlash.cs rename to Projectiles/Melee/TerratomereSwordBeam.cs index 0e339a35e8..1343fe2c9f 100644 --- a/Projectiles/Melee/TerratomereBigSlash.cs +++ b/Projectiles/Melee/TerratomereSwordBeam.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class TerratomereBigSlash : ModProjectile, ILocalizedModType + public class TerratomereSwordBeam : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; public int TargetIndex = -1; @@ -39,13 +39,21 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - CalamityUtils.HomeInOnNPC(Projectile, true, 600f, 24f, 20f); + CalamityUtils.HomeInOnNPC(Projectile, true, 400f, 24f, 20f); Projectile.scale = Utils.GetLerpValue(0f, 8f, Projectile.timeLeft, true); + + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(5) ? 131 : 294, -Projectile.velocity * Main.rand.NextFloat(0.05f, 0.3f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.75f, 0.95f); + if (dust.type == 131) + dust.scale = Main.rand.NextFloat(0.55f, 0.75f); + else + dust.fadeIn = 0.5f; } public float SlashWidthFunction(float _) => Projectile.width * Projectile.scale * Utils.GetLerpValue(0f, 0.1f, _, true); - public Color SlashColorFunction(float _) => Color.Lime * Projectile.Opacity; + public Color SlashColorFunction(float _) => Color.Turquoise; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { @@ -72,8 +80,8 @@ namespace CalamityMod.Projectiles.Melee GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(Terratomere.TerraColor1); GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(Terratomere.TerraColor2); - for (int i = 0; i < 4; i++) - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); + // 17MAY2024: Ozzatron: remove Terratomere rendering its trails multiple times + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); return false; } diff --git a/Projectiles/Melee/ViolenceThrownProjectile.cs b/Projectiles/Melee/ViolenceThrownProjectile.cs index 345883e0f8..393fc828d1 100644 --- a/Projectiles/Melee/ViolenceThrownProjectile.cs +++ b/Projectiles/Melee/ViolenceThrownProjectile.cs @@ -215,7 +215,12 @@ namespace CalamityMod.Projectiles.Melee drawPoints[i] -= (Projectile.oldRot[i] + MathHelper.PiOver4).ToRotationVector2() * Projectile.height * 0.5f; if (Time > Projectile.oldPos.Length) - PrimitiveRenderer.RenderTrail(drawPoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 88); + { + // Violence trakcs 36 positions in oldPos. + // Provide all 36 points for smoothing, but only render 24. + int numPointsRendered = 24; + PrimitiveRenderer.RenderTrail(drawPoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"], smoothen: true), numPointsRendered); + } Vector2 drawPosition = Projectile.Center - Main.screenPosition; for (int i = 0; i < 6; i++) diff --git a/Projectiles/Melee/WhiteBoltAura.cs b/Projectiles/Melee/WhiteBoltAura.cs index d361a79873..f6778cd633 100644 --- a/Projectiles/Melee/WhiteBoltAura.cs +++ b/Projectiles/Melee/WhiteBoltAura.cs @@ -43,8 +43,9 @@ namespace CalamityMod.Projectiles.Melee } } } + Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] >= 10f) + if (Projectile.localAI[0] >= 20f) { Projectile.localAI[0] = 0f; int projTimer = 0; @@ -70,5 +71,7 @@ namespace CalamityMod.Projectiles.Melee } } } + + public override bool? CanDamage() => false; } } diff --git a/Projectiles/Melee/WhiteOrb.cs b/Projectiles/Melee/WhiteOrb.cs index 84ae9ebcf4..75df233253 100644 --- a/Projectiles/Melee/WhiteOrb.cs +++ b/Projectiles/Melee/WhiteOrb.cs @@ -25,13 +25,11 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Lighting.AddLight(Projectile.Center, 0.2f, 0.2f, 0.2f); - for (int i = 0; i < 2; i++) - { - int shiny = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GemDiamond, 0f, 0f, 100, default, 1.25f); - Main.dust[shiny].noGravity = true; - Main.dust[shiny].velocity *= 0.5f; - Main.dust[shiny].velocity += Projectile.velocity * 0.1f; - } + + int shiny = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.GemDiamond, 0f, 0f, 100, default, 1.25f); + Main.dust[shiny].noGravity = true; + Main.dust[shiny].velocity *= 0.5f; + Main.dust[shiny].velocity += Projectile.velocity * 0.1f; } } } diff --git a/Projectiles/Melee/Whiterain.cs b/Projectiles/Melee/Whiterain.cs index 6e7978918c..0bf0617dfa 100644 --- a/Projectiles/Melee/Whiterain.cs +++ b/Projectiles/Melee/Whiterain.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.ai[1] == 0f) { Projectile.ai[1] = 1f; - SoundEngine.PlaySound(SoundID.Item125, Projectile.Center); + SoundEngine.PlaySound(SoundID.Item125 with { Volume = 0.7f }, Projectile.Center); } Lighting.AddLight(Projectile.Center, 0.2f, 0.2f, 0.2f); @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Melee Main.dust[shiny].velocity += Projectile.velocity * 0.1f; } - CalamityUtils.HomeInOnNPC(Projectile, true, 200f, 12f, 20f); + CalamityUtils.HomeInOnNPC(Projectile, true, 320f, 14f, 20f); } } } diff --git a/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs b/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs index 4475b6d6b5..f43f41c800 100644 --- a/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs +++ b/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override void SetStaticDefaults() { ProjectileID.Sets.YoyosLifeTimeMultiplier[Projectile.type] = 30f * MaxUpdates; - ProjectileID.Sets.YoyosMaximumRange[Projectile.type] = 320f; + ProjectileID.Sets.YoyosMaximumRange[Projectile.type] = 330f; ProjectileID.Sets.YoyosTopSpeed[Projectile.type] = 32f / MaxUpdates; ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4; diff --git a/Projectiles/Melee/Yoyos/AortaYoyo.cs b/Projectiles/Melee/Yoyos/AortaYoyo.cs index 50fc877468..64dd6c5d35 100644 --- a/Projectiles/Melee/Yoyos/AortaYoyo.cs +++ b/Projectiles/Melee/Yoyos/AortaYoyo.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override void SetStaticDefaults() { ProjectileID.Sets.YoyosLifeTimeMultiplier[Projectile.type] = 24f * MaxUpdates; - ProjectileID.Sets.YoyosMaximumRange[Projectile.type] = 320f; + ProjectileID.Sets.YoyosMaximumRange[Projectile.type] = 330f; ProjectileID.Sets.YoyosTopSpeed[Projectile.type] = 25f / MaxUpdates; ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4; diff --git a/Projectiles/Ranged/AdamantiteAcceleratorHoldout.cs b/Projectiles/Ranged/AdamantiteAcceleratorHoldout.cs index 57f572b000..3af7722d96 100644 --- a/Projectiles/Ranged/AdamantiteAcceleratorHoldout.cs +++ b/Projectiles/Ranged/AdamantiteAcceleratorHoldout.cs @@ -1,59 +1,59 @@ -using System; +using System.IO; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using static CalamityMod.CalamityUtils; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Ranged { - public class AdamantiteAcceleratorHoldout : ModProjectile + public class AdamantiteAcceleratorHoldout : BaseGunHoldoutProjectile { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public override string Texture => "CalamityMod/Items/Weapons/Ranged/AdamantiteParticleAccelerator"; - const float maxTimeAnim = 35; - public Player Owner => Main.player[Projectile.owner]; - public float Timer => maxTimeAnim - Projectile.timeLeft; + public override int AssociatedItemID => ItemType(); + public override Vector2 GunTipPosition => Owner.MountedCenter + Projectile.rotation.ToRotationVector2() * 70f + (Vector2.UnitY * -12f * Owner.direction).RotatedBy(Projectile.rotation); + public override float MaxOffsetLengthFromArm => base.MaxOffsetLengthFromArm; + public override float OffsetXUpwards => base.OffsetXUpwards; + public override float OffsetXDownwards => base.OffsetXDownwards; + public override float BaseOffsetY => base.BaseOffsetY; + public override float OffsetYUpwards => base.OffsetYUpwards; + public override float OffsetYDownwards => base.OffsetYDownwards; + public ref float ChargeTimer => ref Projectile.ai[0]; public ref float DelayTimer => ref Projectile.ai[1]; public ref float ChargeRate => ref Projectile.localAI[0]; public ref float BounceBackPower => ref Projectile.localAI[1]; - public Vector2 NuzzlePosition => Owner.MountedCenter + Projectile.rotation.ToRotationVector2() * 70f + (Vector2.UnitY * -12f * Owner.direction).RotatedBy(Projectile.rotation); private SlotId ChargeupSoundSlot; - public override void SetDefaults() + public override void KillHoldoutLogic() { - Projectile.width = 54; - Projectile.height = 52; - // This projectile has no hitboxes and no damage type. - Projectile.friendly = false; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.timeLeft = 900; - Projectile.velocity = Vector2.Zero; + int maxTime = AdamantiteParticleAccelerator.ChargeFrames + AdamantiteParticleAccelerator.CooldownFrames; + if (ChargeTimer > maxTime) + { + if (!Owner.CantUseHoldout()) + ResetToStart(); + else + { + Projectile.Kill(); + return; + } + } } // ChargeTimer is a time-dilated frame counter. DelayTimer is the frame counter for when the beams are fired. // ChargeRate is the rate at which the "frame" counter increases. BounceBackPower is there for the visuals of the gun recoiling in the players hands. - public override void AI() + public override void HoldoutAI() { - Player player = Main.player[Projectile.owner]; - Vector2 rrp = player.RotatedRelativePoint(player.MountedCenter, true); - - Projectile.rotation = Owner.MountedCenter.AngleTo(Owner.Calamity().mouseWorld); - // Calculate how quickly the gun should charge. Charge increases by some number close to 1 every frame. // Speed increasing reforges make this number greater than 1. Slowing reforges make it smaller than 1. if (ChargeRate == 0f) - ChargeRate = 44f / player.ActiveItem().useTime; + ChargeRate = 44f / HeldItem.useTime; if (ChargeTimer == 0f) ChargeupSoundSlot = SoundEngine.PlaySound(SoundID.DD2_WitherBeastAuraPulse with { Volume = SoundID.DD2_WitherBeastAuraPulse.Volume * 1.6f }, Projectile.Center); @@ -69,24 +69,10 @@ namespace CalamityMod.Projectiles.Ranged // Increment the timer for the gun. If the timer has passed 44, destroy it. ChargeTimer += ChargeRate; - int maxTime = AdamantiteParticleAccelerator.ChargeFrames + AdamantiteParticleAccelerator.CooldownFrames; - if (ChargeTimer > maxTime) - { - if (Owner.channel) - ResetToStart(); - else - { - Projectile.Kill(); - return; - } - } // Compute the weapon's charge. float chargeLevel = MathHelper.Clamp(Projectile.ai[0] / AdamantiteParticleAccelerator.ChargeFrames, 0f, 1f); - // Common code among holdouts to keep the holdout projectile directly in the player's hand - UpdatePlayerVisuals(player, rrp); - // Firing or charging? if (chargeLevel >= 1f) { @@ -96,8 +82,8 @@ namespace CalamityMod.Projectiles.Ranged FiringEffects(new Color(235, 40, 121)); if (Projectile.owner == Main.myPlayer) { - Projectile redLaser = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), NuzzlePosition, Projectile.rotation.ToRotationVector2(), ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 120); - redLaser.Center = NuzzlePosition; + Projectile redLaser = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.rotation.ToRotationVector2(), ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 120); + redLaser.Center = GunTipPosition; } } @@ -107,8 +93,8 @@ namespace CalamityMod.Projectiles.Ranged FiringEffects(new Color(49, 161, 246)); if (Projectile.owner == Main.myPlayer) { - Projectile blueLaser = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), NuzzlePosition, Projectile.rotation.ToRotationVector2(), ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, -120); - blueLaser.Center = NuzzlePosition; + Projectile blueLaser = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.rotation.ToRotationVector2(), ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, -120); + blueLaser.Center = GunTipPosition; } } DelayTimer += 1f; @@ -124,27 +110,12 @@ namespace CalamityMod.Projectiles.Ranged public CurveSegment oversquish = new CurveSegment(SineBumpEasing, 0.7f, 0f, -0.6f); internal float RecoilSquish => PiecewiseAnimation(1 - MathHelper.Clamp(BounceBackPower * 2f, 0f, 1f), new CurveSegment[] { unsquish, oversquish }); - private void UpdatePlayerVisuals(Player player, Vector2 rrp) - { - // Place the projectile directly into the player's hand at all times - Projectile.Center = rrp; - - // The gun is a holdout projectile, so change the player's variables to reflect that - player.ChangeDir(Math.Sign(Projectile.rotation.ToRotationVector2().X)); - player.heldProj = Projectile.whoAmI; - player.itemTime = 2; - player.itemAnimation = 2; - - player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, Projectile.rotation - MathHelper.PiOver2); - - } - private void FiringEffects(Color color) { - SoundEngine.PlaySound(SoundID.Item92, NuzzlePosition); - SoundEngine.PlaySound(SoundID.Item60, NuzzlePosition); + SoundEngine.PlaySound(SoundID.Item92, GunTipPosition); + SoundEngine.PlaySound(SoundID.Item60, GunTipPosition); - Particle pulse = new DirectionalPulseRing(NuzzlePosition + Projectile.rotation.ToRotationVector2() * 5f, Vector2.Zero, color, new Vector2(0.5f, 1f), Projectile.rotation, 0.05f, 0.34f + Main.rand.NextFloat(0.3f), 30); + Particle pulse = new DirectionalPulseRing(GunTipPosition + Projectile.rotation.ToRotationVector2() * 5f, Vector2.Zero, color, new Vector2(0.5f, 1f), Projectile.rotation, 0.05f, 0.34f + Main.rand.NextFloat(0.3f), 30); GeneralParticleHandler.SpawnParticle(pulse); if (Owner == Main.LocalPlayer && Owner.Calamity().GeneralScreenShakePower < 5) @@ -174,7 +145,7 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreKill(int timeLeft) { - if (Owner.channel) + if (!Owner.CantUseHoldout()) { ResetToStart(); return false; @@ -185,9 +156,20 @@ namespace CalamityMod.Projectiles.Ranged public void ResetToStart() { - Projectile.timeLeft = 900; ChargeTimer = 0f; DelayTimer = 0f; } + + public override void SendExtraAIHoldout(BinaryWriter writer) + { + writer.Write(ChargeRate); + writer.Write(BounceBackPower); + } + + public override void ReceiveExtraAIHoldout(BinaryReader reader) + { + ChargeRate = reader.ReadSingle(); + BounceBackPower = reader.ReadSingle(); + } } } diff --git a/Projectiles/Ranged/Aquashard.cs b/Projectiles/Ranged/Aquashard.cs index 4194e268b6..b07fbb4dd9 100644 --- a/Projectiles/Ranged/Aquashard.cs +++ b/Projectiles/Ranged/Aquashard.cs @@ -18,6 +18,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = 1; Projectile.timeLeft = 300; Projectile.aiStyle = ProjAIStyleID.Arrow; + Projectile.extraUpdates = 1; Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } @@ -35,7 +36,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < projAmt; i++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4), 0f, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.6), 0f, Projectile.owner); } } } diff --git a/Projectiles/Ranged/AquashardSplit.cs b/Projectiles/Ranged/AquashardSplit.cs index f044a6e80b..0fc3c0e6eb 100644 --- a/Projectiles/Ranged/AquashardSplit.cs +++ b/Projectiles/Ranged/AquashardSplit.cs @@ -17,18 +17,19 @@ namespace CalamityMod.Projectiles.Ranged Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 1; - Projectile.timeLeft = 180; + Projectile.timeLeft = 300; + Projectile.extraUpdates = 1; Projectile.aiStyle = ProjAIStyleID.Arrow; } - public override bool? CanHitNPC(NPC target) => Projectile.timeLeft < 150 && target.CanBeChasedBy(Projectile); + public override bool? CanHitNPC(NPC target) => Projectile.timeLeft < 280 && target.CanBeChasedBy(Projectile); public override void AI() { Projectile.velocity.X *= 0.9995f; Projectile.velocity.Y += 0.01f; - if (Projectile.timeLeft < 150) + if (Projectile.timeLeft < 280) CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 450f, Projectile.ai[1] == 1f ? 8f : 6f, 20f); } diff --git a/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs b/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs index bc886a28f8..bfda144189 100644 --- a/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs +++ b/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs @@ -24,19 +24,16 @@ namespace CalamityMod.Projectiles.Ranged public static float BulletSpeed = 12f; public SlotId NovaChargeSlot; - private ref float CurrentChargingFrames => ref Projectile.ai[0]; - private ref float ShotsLoaded => ref Projectile.ai[1]; - private ref float ShootRecoilTimer => ref Projectile.ai[2]; // Dual functions for rapid fire shooting cooldown and recoil - private bool ChargeLV1 => CurrentChargingFrames >= ArcNovaDiffuser.Charge1Frames; - private bool ChargeLV2 => CurrentChargingFrames >= ArcNovaDiffuser.Charge2Frames; + public ref float CurrentChargingFrames => ref Projectile.ai[0]; + public ref float ShotsLoaded => ref Projectile.ai[1]; + public ref float ShootRecoilTimer => ref Projectile.ai[2]; // Dual functions for rapid fire shooting cooldown and recoil + public bool ChargeLV1 => CurrentChargingFrames >= ArcNovaDiffuser.Charge1Frames; + public bool ChargeLV2 => CurrentChargingFrames >= ArcNovaDiffuser.Charge2Frames; public override void KillHoldoutLogic() { - if (HeldItem.type != Owner.ActiveItem().type || Owner is null || !Owner.active || Owner.CCed || Owner.dead || Owner.noItems) - { + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) Projectile.Kill(); - Projectile.netUpdate = true; - } } public override void HoldoutAI() @@ -74,8 +71,6 @@ namespace CalamityMod.Projectiles.Ranged ShotsLoaded = 0; ShootRecoilTimer = 24f; OffsetLengthFromArm -= 25f; - Projectile.netSpam = 0; - Projectile.netUpdate = true; } // Retracting recoil else if (ShootRecoilTimer > 0) @@ -107,8 +102,6 @@ namespace CalamityMod.Projectiles.Ranged ShotsLoaded--; ShootRecoilTimer = 16f; OffsetLengthFromArm -= 5f; - Projectile.netSpam = 0; - Projectile.netUpdate = true; } } // Retracting any remaining recoil diff --git a/Projectiles/Ranged/BloodBoilerFire.cs b/Projectiles/Ranged/BloodBoilerFire.cs index 52af9cd48f..6f18a4673f 100644 --- a/Projectiles/Ranged/BloodBoilerFire.cs +++ b/Projectiles/Ranged/BloodBoilerFire.cs @@ -186,7 +186,7 @@ namespace CalamityMod.Projectiles.Ranged { if (!Main.player[Projectile.owner].moonLeech) { - int bonusHeal = Main.rand.NextBool(3) ? 6 : 4; + int bonusHeal = Main.rand.NextBool(3) ? 5 : 3; int heal = improvedHeal ? bonusHeal : 2; if (Main.player[Main.myPlayer].lifeSteal <= 0f) diff --git a/Projectiles/Ranged/BloodClotFriendly.cs b/Projectiles/Ranged/BloodClotFriendly.cs index 82c8855ae5..1d96edd43d 100644 --- a/Projectiles/Ranged/BloodClotFriendly.cs +++ b/Projectiles/Ranged/BloodClotFriendly.cs @@ -43,9 +43,9 @@ namespace CalamityMod.Projectiles.Ranged } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 90); + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 90); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 240); public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Ranged/BloodfireArrowProj.cs b/Projectiles/Ranged/BloodfireArrowProj.cs index 822774e748..69a3118522 100644 --- a/Projectiles/Ranged/BloodfireArrowProj.cs +++ b/Projectiles/Ranged/BloodfireArrowProj.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.localAI[0] == 0) { - player.statLife -= Main.player[Main.myPlayer].lifeSteal <= 0f ? 0 : 1; + player.statLife -= 1; if (player.statLife <= 0) { PlayerDeathReason pdr = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BloodFireArrow" + Main.rand.Next(1, 2 + 1)).Format(player.name)); @@ -100,7 +100,7 @@ namespace CalamityMod.Projectiles.Ranged if (player.moonLeech) return; - if (Main.player[Main.myPlayer].lifeSteal <= 0f || target.lifeMax <= 5) + if (target.lifeMax <= 5) return; float lifeRatio = (float)player.statLife / player.statLifeMax2; diff --git a/Projectiles/Ranged/BloodfireBulletProj.cs b/Projectiles/Ranged/BloodfireBulletProj.cs index e4373bbc82..e45df960a2 100644 --- a/Projectiles/Ranged/BloodfireBulletProj.cs +++ b/Projectiles/Ranged/BloodfireBulletProj.cs @@ -81,8 +81,8 @@ namespace CalamityMod.Projectiles.Ranged // Returns the amount of bonus damage that should be dealt. Boosts life regeneration appropriately as a side effect. private int OnHitEffect(Player owner) { - // Adds 2 frames to lifeRegenTime on every hit. This increased value is used for the damage calculation. - owner.lifeRegenTime += 2; + // Adds 3 frames to lifeRegenTime on every hit. This increased value is used for the damage calculation. + owner.lifeRegenTime += 3; // Deals (1.00 + (0.1 * current lifeRegen))% of current lifeRegenTime as flat bonus damage on hit. // For example, at 0 life regen, you get 1% of lifeRegenTime as bonus damage. @@ -91,15 +91,16 @@ namespace CalamityMod.Projectiles.Ranged int regenForCalc = owner.lifeRegen > 0 ? owner.lifeRegen : 0; float regenDamageRatio = (1f + 0.1f * regenForCalc) / 100f; - // For the sake of bonus damage, life regen time caps at 3600, aka 60 seconds. This is its natural cap in vanilla. This then gets divided by 2 for computing final damage. - int regenTimeForCalc = (int)MathHelper.Clamp(owner.lifeRegenTime, 0f, 3600f) / 2; + // For the sake of bonus damage, life regen time caps at 3600, aka 60 seconds. This is its natural cap in vanilla. 75% of this is taken for computing the final damage. + int regenTimeForCalc = (int)(MathHelper.Clamp(owner.lifeRegenTime, 0f, 3600f) * 0.75f); int finalDamageBoost = (int)(regenDamageRatio * regenTimeForCalc); - // Damage boost has a cap of 25 to prevent it from getting too crazy. - if (finalDamageBoost > 25) - finalDamageBoost = 25; + // Damage boost has a cap of 35 to prevent it from getting too crazy. + int damageCap = 35; + if (finalDamageBoost > damageCap) + finalDamageBoost = damageCap; - if (finalDamageBoost == 25) // Special hit visual if youre at max bonus damage + if (finalDamageBoost == damageCap) // Special hit visual if the bonus damage is at the cap. { for (int k = 0; k < 3; k++) { diff --git a/Projectiles/Ranged/BrimstoneFireFriendly.cs b/Projectiles/Ranged/BrimstoneFireFriendly.cs index 60828b0eef..e419809b56 100644 --- a/Projectiles/Ranged/BrimstoneFireFriendly.cs +++ b/Projectiles/Ranged/BrimstoneFireFriendly.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Projectiles.Ranged public override string Texture => "CalamityMod/Projectiles/FireProj"; public static int Lifetime => 60; - public static int Fadetime => 80; + public static int Fadetime => 50; public ref float Time => ref Projectile.ai[0]; public int MistType = -1; diff --git a/Projectiles/Ranged/ButcherGun.cs b/Projectiles/Ranged/ButcherGun.cs deleted file mode 100644 index ea90fbc25e..0000000000 --- a/Projectiles/Ranged/ButcherGun.cs +++ /dev/null @@ -1,164 +0,0 @@ -using System; -using CalamityMod.Items.Weapons.Ranged; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - public class ButcherGun : ModProjectile - { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public override string Texture => "CalamityMod/Items/Weapons/Ranged/Butcher"; - - public override void SetDefaults() - { - Projectile.width = 66; - Projectile.height = 32; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Ranged; - Projectile.ignoreWater = true; - } - - public override void AI() - { - Player player = Main.player[Projectile.owner]; - Projectile.ai[0] += 1f; - int incrementAmt = 0; - float spreadMult = 0.15f; - if (Projectile.ai[0] >= 80f) - { - incrementAmt++; - spreadMult = 0.13f; - } - if (Projectile.ai[0] >= 160f) - { - incrementAmt++; - spreadMult = 0.11f; - } - if (Projectile.ai[0] >= 240f) - { - incrementAmt++; - spreadMult = 0.09f; - } - if (Projectile.ai[0] >= 320f) - { - incrementAmt++; - spreadMult = 0.07f; - } - if (Projectile.ai[0] >= 400f) - { - incrementAmt++; - spreadMult = 0.05f; - } - if (Projectile.ai[0] >= 480f) - { - incrementAmt++; - spreadMult = 0.04f; - } - if (Projectile.ai[0] >= 560f) - { - incrementAmt++; - spreadMult = 0.03f; - } - if (Projectile.ai[0] >= 640f) //8 - { - incrementAmt++; - spreadMult = 0.02f; - } - int shootDelayBase = 40; - int incrementMult = 3; - Projectile.ai[1] -= 1f; - bool willShoot = false; - if (Projectile.ai[1] <= 0f) - { - Projectile.ai[1] = (float)(shootDelayBase - incrementMult * incrementAmt); - willShoot = true; - } - bool canShoot = !player.CantUseHoldout() && player.HasAmmo(player.ActiveItem()); - if (Projectile.localAI[0] > 0f) - { - Projectile.localAI[0] -= 1f; - } - if (Projectile.soundDelay <= 0 && canShoot) - { - Projectile.soundDelay = shootDelayBase - incrementMult * incrementAmt; - if (Projectile.ai[0] != 1f) - { - SoundEngine.PlaySound(SoundID.Item38, Projectile.position); - } - Projectile.localAI[0] = 12f; - } - Vector2 source = player.RotatedRelativePoint(player.MountedCenter, true); - if (willShoot && Main.myPlayer == Projectile.owner) - { - int projType = ProjectileID.Bullet; - float speedMult = 14f; - int damage = player.GetWeaponDamage(player.ActiveItem()); - float kback = player.ActiveItem().knockBack; - if (canShoot) - { - player.PickAmmo(player.ActiveItem(), out projType, out speedMult, out damage, out kback, out _); - kback = player.GetWeaponKnockback(player.ActiveItem(), kback); - float speed = player.ActiveItem().shootSpeed * Projectile.scale; - Vector2 targetPos = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - source; - if (player.gravDir == -1f) - { - targetPos.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - source.Y; - } - Vector2 velMult = Vector2.Normalize(targetPos); - if (float.IsNaN(velMult.X) || float.IsNaN(velMult.Y)) - { - velMult = -Vector2.UnitY; - } - velMult *= speed; - if (velMult.X != Projectile.velocity.X || velMult.Y != Projectile.velocity.Y) - { - Projectile.netUpdate = true; - } - Projectile.velocity = velMult * 0.55f; - int randomBulletCount = Main.rand.Next(3, 5); //3 to 4 bullets - for (int projIndex = 0; projIndex < randomBulletCount; projIndex++) - { - Vector2 bulletVel = Vector2.Normalize(Projectile.velocity) * speedMult * (0.6f + Main.rand.NextFloat() * spreadMult); - if (float.IsNaN(bulletVel.X) || float.IsNaN(bulletVel.Y)) - { - bulletVel = -Vector2.UnitY; - } - source += Utils.RandomVector2(Main.rand, -5f, 5f); - bulletVel.X += (float)Main.rand.Next(-15, 16) * spreadMult; - bulletVel.Y += (float)Main.rand.Next(-15, 16) * spreadMult; - int bullet = Projectile.NewProjectile(Projectile.GetSource_FromThis(), source, bulletVel, projType, damage, kback, Projectile.owner, 0f, 0f); - Main.projectile[bullet].noDropItem = true; - Main.projectile[bullet].extraUpdates += incrementAmt / 2; //0 to 4 - } - } - else - { - Projectile.Kill(); - } - } - Projectile.position = player.RotatedRelativePoint(player.MountedCenter, true) - Projectile.Size / 2f; - float rotationAmt = 0f; - if (Projectile.spriteDirection == -1) - { - rotationAmt = MathHelper.Pi; - } - Projectile.rotation = Projectile.velocity.ToRotation() + rotationAmt; - Projectile.spriteDirection = Projectile.direction; - Projectile.timeLeft = 2; - player.ChangeDir(Projectile.direction); - player.heldProj = Projectile.whoAmI; - player.itemTime = 2; - player.itemAnimation = 2; - player.itemRotation = (float)Math.Atan2((double)(Projectile.velocity.Y * (float)Projectile.direction), (double)(Projectile.velocity.X * (float)Projectile.direction)); - } - - public override bool? CanDamage() => false; - } -} diff --git a/Projectiles/Ranged/BuzzkillHoldout.cs b/Projectiles/Ranged/BuzzkillHoldout.cs new file mode 100644 index 0000000000..a0e818b0f7 --- /dev/null +++ b/Projectiles/Ranged/BuzzkillHoldout.cs @@ -0,0 +1,261 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using ReLogic.Utilities; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class BuzzkillHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ModContent.ItemType(); + public override float RecoilResolveSpeed => 0.05f; + public override float MaxOffsetLengthFromArm => 30f; + public override float OffsetXUpwards => -10f; + public override float OffsetXDownwards => 5f; + public override float BaseOffsetY => -10f; + public override float OffsetYDownwards => 10f; + public override Vector2 GunTipPosition => Projectile.Center + Vector2.UnitX.RotatedBy(Projectile.rotation) * Projectile.width * 0.28f; + + public ref float Time => ref Projectile.ai[0]; + public const float ChargeupTime = 120f; + public SlotId ChargeIdle; + + // Controls the saw visually disappearing from the holdout when it fires. + public bool NoSawOnHoldout = false; + + public static Asset Holdout; + public static Asset SmallSlash; + public static Asset LargeSlash; + + public override void SetStaticDefaults() + { + Main.projFrames[Projectile.type] = 5; + } + + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + + public override void KillHoldoutLogic() + { + if (HeldItem.type != Owner.ActiveItem().type) + { + Projectile.Kill(); + Projectile.netUpdate = true; + } + } + + public override void HoldoutAI() + { + Time++; + float SawPower = MathHelper.Clamp(Time / ChargeupTime, 0f, 1f); + + if (SoundEngine.TryGetActiveSound(ChargeIdle, out var Idle) && Idle.IsPlaying) + Idle.Position = GunTipPosition; + + if (Owner.CantUseHoldout()) + { + if (Projectile.ai[1] < 1f) + { + KeepRefreshingLifetime = false; + Idle?.Stop(); + + Projectile.ai[1] = 1f; + Projectile.timeLeft = Owner.ActiveItem().useAnimation; + SoundStyle ShootSound = new("CalamityMod/Sounds/Item/SawShot", 2) { PitchVariance = 0.1f, Volume = 0.4f + SawPower * 0.5f }; + SoundEngine.PlaySound(ShootSound, GunTipPosition); + + float sawDamageMult = MathHelper.Lerp(1f, 5f, SawPower) / 1.5f; // The damage must be divided by 1.5 to offset the holdout having 1.5x base damage. + int sawPierce = (int)MathHelper.Lerp(2f, 6f, SawPower); + int sawLevel = (SawPower >= 1f).ToInt() + (SawPower >= 0.25f).ToInt(); + + Projectile buzzsaw = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * Owner.ActiveItem().shootSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * sawDamageMult), (int)(Projectile.knockBack * (sawDamageMult / 2)), Main.myPlayer, sawLevel); + buzzsaw.penetrate = sawPierce; + buzzsaw.rotation = Main.rand.NextFloat(0f, MathHelper.TwoPi); + + NoSawOnHoldout = true; + OffsetLengthFromArm -= 4f + 12f * SawPower; + + int sparkPairCount = 3 + 2 * sawLevel; + for (int s = 0; s < sparkPairCount; s++) + { + float velocityMult = Main.rand.NextFloat(5f, 8f) + Main.rand.NextFloat(4f, 7f) * sawLevel; + float scale = Main.rand.NextFloat(0.6f, 0.8f) + Main.rand.NextFloat(0.3f, 0.5f) * sawLevel; + + Vector2 sparkVelocity = Projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * velocityMult; + Particle weaponShootSparks = new AltLineParticle(GunTipPosition, sparkVelocity, false, 40, scale, new Color(250, 250, 107)); + GeneralParticleHandler.SpawnParticle(weaponShootSparks); + + // re-randomize rotation for the alternate particle + sparkVelocity = Projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * velocityMult; + Particle weaponShootSparks2 = new AltSparkParticle(GunTipPosition, sparkVelocity, false, 40, scale, new Color(250, 250, 107)); + GeneralParticleHandler.SpawnParticle(weaponShootSparks2); + } + } + } + + if (NoSawOnHoldout) + { + Projectile.frame = 4; + return; + } + else + { + Projectile.frameCounter++; + if (Projectile.frameCounter >= 3) + { + Projectile.frameCounter = 0; + Projectile.frame++; + if (Projectile.frame > 3) + Projectile.frame = 1; + } + } + + if (Time > 30f) + { + if (Time % 3 == 0) + { + Vector2 sparkVel = Main.rand.NextVector2CircularEdge(1f, 1f); + sparkVel.SafeNormalize(Vector2.Zero); + sparkVel *= Main.rand.NextFloat(3f, 4.5f) + (SawPower * 4); + + Particle buzzsawSparks = new AltLineParticle(GunTipPosition, sparkVel, false, 10, Utils.GetLerpValue(0.05f, 0.65f, SawPower, true), new Color(250, 250, 107)); + GeneralParticleHandler.SpawnParticle(buzzsawSparks); + } + } + + if (Time < ChargeupTime) + { + if (Time == 30f) + ChargeIdle = SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/BuzzsawCharge") { Volume = 0.3f }, GunTipPosition); + + if (Time > 30f && Projectile.frame == 0) + Projectile.frame = 1; + } + else + { + if ((Time + 240) % 360 == 0) + ChargeIdle = SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/BuzzsawIdle"), GunTipPosition); + + if (Time % 3 == 0) + { + Vector2 smokeVelocity = Vector2.UnitY * Main.rand.NextFloat(-7f, -12f); + smokeVelocity = smokeVelocity.RotatedByRandom(MathHelper.Pi / 8f); + Particle fullChargeSmoke = new HeavySmokeParticle(GunTipPosition + Main.rand.NextVector2CircularEdge(3f, 3f), smokeVelocity, Color.Gray, 30, 0.65f, 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), true); + GeneralParticleHandler.SpawnParticle(fullChargeSmoke); + } + } + } + + public override void OnSpawn(IEntitySource source) + { + base.OnSpawn(source); + ExtraBackArmRotation = MathHelper.ToRadians(15f); + } + + // Failsafe because apparently the sound doesn't stop sometimes + public override void OnKill(int timeLeft) + { + if (SoundEngine.TryGetActiveSound(ChargeIdle, out var Idle)) + Idle?.Stop(); + } + + // The holdout can deal damage; you're literally spinning up a buzzsaw at the end, after all. + public override bool? CanDamage() => !NoSawOnHoldout; + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 240); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/SwiftSlice") { Volume = 0.7f }, GunTipPosition); + + int SawLevel = (Time / ChargeupTime >= 1f).ToInt() + (Time / ChargeupTime >= 0.25f).ToInt(); + int bloodCount = 4 + 3 * SawLevel; + for (int p = 0; p < bloodCount; p++) + { + float radius = Main.rand.NextFloat(6f, 10f) + Main.rand.NextFloat(4f, 10f) * SawLevel; + Vector2 velocity = Main.rand.NextVector2CircularEdge(radius, radius); + float scale = Main.rand.NextFloat(0.3f, 0.5f) + Main.rand.NextFloat(0.1f, 0.4f) * SawLevel; + Particle hitSparks = new AltLineParticle(target.Center, velocity, false, 20, scale, new Color(112, 16, 16)); + GeneralParticleHandler.SpawnParticle(hitSparks); + } + } + + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + hitbox = new Rectangle((int)GunTipPosition.X - 19, (int)GunTipPosition.Y - 20, 38, 40); + + if (Time / ChargeupTime >= 1f) + hitbox.Inflate(65, 65); + else if (Time / ChargeupTime >= 0.25f) + hitbox.Inflate(28, 28); + } + + public override bool PreDraw(ref Color lightColor) + { + Holdout ??= ModContent.Request("CalamityMod/Projectiles/Ranged/BuzzkillHoldout"); + Texture2D holdoutTexture = Holdout.Value; + LargeSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/BuzzkillSawLargeSlash"); + Texture2D largeSlashTexture = LargeSlash.Value; + SmallSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/BuzzkillSawSmallSlash"); + Texture2D smallSlashTexture = SmallSlash.Value; + Color slashColor = new Color(200, 200, 200, 100); + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = holdoutTexture.Frame(verticalFrames: Main.projFrames[Type], frameY: Projectile.frame); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = frame.Size() * 0.5f; + SpriteEffects flipSprite = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + if (!NoSawOnHoldout) + { + float shake = Utils.Remap(Time, 0f, ChargeupTime, 0f, 3f); + drawPosition += Main.rand.NextVector2Circular(shake, shake); + } + + Main.EntitySpriteDraw(holdoutTexture, drawPosition, frame, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale, flipSprite); + + if (Time > 30f && !NoSawOnHoldout) + { + if (Time / ChargeupTime >= 1f) + Main.EntitySpriteDraw(largeSlashTexture, GunTipPosition - Main.screenPosition, null, slashColor, Time * -MathHelper.ToRadians(42f), largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time / ChargeupTime >= 0.25f) + Main.EntitySpriteDraw(smallSlashTexture, GunTipPosition - Main.screenPosition, null, slashColor, Time * MathHelper.ToRadians(42f), smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (!CalamityConfig.Instance.Afterimages) + return false; + + // Special afterimage drawing for the slashes only + for (int i = 1; i < 3; i++) + { + float intensity = MathHelper.Lerp(0.05f, 0.25f, 1f - i / 3f); + + if (Time / ChargeupTime >= 1f) + Main.EntitySpriteDraw(largeSlashTexture, GunTipPosition - Main.screenPosition, null, slashColor * intensity, (Time - i) * -MathHelper.ToRadians(42f), largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time / ChargeupTime >= 0.25f) + Main.EntitySpriteDraw(smallSlashTexture, GunTipPosition - Main.screenPosition, null, slashColor * intensity, (Time - i) * MathHelper.ToRadians(42f), smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + } + } + + return false; + } + } +} diff --git a/Projectiles/Ranged/BuzzkillHoldout.png b/Projectiles/Ranged/BuzzkillHoldout.png new file mode 100644 index 0000000000..f878df53d2 Binary files /dev/null and b/Projectiles/Ranged/BuzzkillHoldout.png differ diff --git a/Projectiles/Ranged/BuzzkillSaw.cs b/Projectiles/Ranged/BuzzkillSaw.cs new file mode 100644 index 0000000000..c4ef59e32b --- /dev/null +++ b/Projectiles/Ranged/BuzzkillSaw.cs @@ -0,0 +1,214 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class BuzzkillSaw : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + + public static readonly SoundStyle TileCollideGFB = new("CalamityMod/Sounds/Custom/MetalPipeFalling"); + + public ref float SawLevel => ref Projectile.ai[0]; + public ref float Time => ref Projectile.ai[1]; + + public static Asset SmallSlash; + public static Asset LargeSlash; + + public override void SetStaticDefaults() + { + Main.projFrames[Projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 6; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 40; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.timeLeft = 480; + Projectile.penetrate = 1; // Saw pierce is set when the saw is spawned, due to it being dynamic based on charge. + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; + } + + public override void AI() + { + Time++; + Projectile.rotation += MathHelper.ToRadians(6f + 18f * SawLevel); + + if (Projectile.frame < 1) + Projectile.frame = 1; + Projectile.frameCounter++; + if (Projectile.frameCounter >= 3) + { + Projectile.frameCounter = 0; + Projectile.frame++; + if (Projectile.frame > 3) + Projectile.frame = 1; + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + int sparkCount = 6 + 5 * (int)SawLevel; + for (int s = 0; s < sparkCount; s++) + { + Vector2 sparkVelocity = new Vector2(); + if (Projectile.velocity.X != oldVelocity.X && oldVelocity.X < 0) + sparkVelocity = Vector2.UnitX * 6.5f; + else if (Projectile.velocity.X != oldVelocity.X && oldVelocity.X >= 0) + sparkVelocity = Vector2.UnitX * -6.5f; + else if (Projectile.velocity.Y != oldVelocity.Y && oldVelocity.Y < 0) + sparkVelocity = Vector2.UnitY * 6.5f; + else if (Projectile.velocity.Y != oldVelocity.Y && oldVelocity.Y >= 0) + sparkVelocity = Vector2.UnitY * -6.5f; + + Vector2 sparkLocation = sparkVelocity.X > 0f ? Projectile.Left : (sparkVelocity.X < 0f ? Projectile.Right : (sparkVelocity.Y > 0f ? Projectile.Top : Projectile.Bottom)); + sparkVelocity = sparkVelocity.RotatedByRandom(MathHelper.PiOver2) * (Main.rand.NextFloat(0.8f, 1.2f) + (Main.rand.NextFloat(0.2f, 0.6f) * SawLevel)); + float scale = Main.rand.NextFloat(0.5f, 0.8f) + Main.rand.NextFloat(0.2f, 0.6f) * SawLevel; + Particle collisionSparks = new AltLineParticle(sparkLocation, sparkVelocity, false, 30, scale, new Color(250, 250, 107)); + GeneralParticleHandler.SpawnParticle(collisionSparks); + } + + Projectile.penetrate--; + Projectile.numHits++; + if (Projectile.penetrate <= 0) + { + Projectile.Kill(); + } + else + { + SoundEngine.PlaySound(Main.zenithWorld ? TileCollideGFB : SoundID.Item178 with { Pitch = 0.15f * Projectile.numHits }, Projectile.Center); // Placeholder sound + + if (Projectile.velocity.X != oldVelocity.X) + Projectile.velocity.X = -oldVelocity.X; + if (Projectile.velocity.Y != oldVelocity.Y) + Projectile.velocity.Y = -oldVelocity.Y; + } + + return false; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 150); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/SwiftSlice") with { Pitch = 0.15f * Projectile.numHits }, Projectile.Center); + + int bloodCount = 6 + 10 * (int)SawLevel; + for (int p = 0; p < bloodCount; p++) + { + Vector2 velocity = Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * (Main.rand.NextFloat(0.4f, 0.6f) + (Main.rand.NextFloat(0.2f, 0.6f) * SawLevel)); + float scale = Main.rand.NextFloat(0.5f, 0.8f) + Main.rand.NextFloat(0.2f, 0.8f) * SawLevel; + Particle hitSparks = new AltLineParticle(target.Center, velocity, false, 30, scale, new Color(112, 16, 16)); + GeneralParticleHandler.SpawnParticle(hitSparks); + } + } + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/CeramicImpact", 2), Projectile.Center); + + // TODO - Change this dust + for (int d = 0; d < 8; d++) + { + Vector2 dustVel = Main.rand.NextVector2CircularEdge(1f, 1f); + dustVel.SafeNormalize(Vector2.Zero); + dustVel *= Main.rand.NextFloat(5f, 9f); + + Dust collisionDust = Dust.NewDustPerfect(Projectile.Center, 84, dustVel); + collisionDust.noGravity = true; + } + + int goreToExclude = Main.rand.Next(3); + switch (goreToExclude) + { + case 0: + Gore.NewGore(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2Circular(4f, 4f), Mod.Find("BuzzkillSaw2").Type, 0.8f); + Gore.NewGore(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2Circular(4f, 4f), Mod.Find("BuzzkillSaw3").Type, 0.8f); + break; + case 1: + Gore.NewGore(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2Circular(4f, 4f), Mod.Find("BuzzkillSaw1").Type, 0.8f); + Gore.NewGore(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2Circular(4f, 4f), Mod.Find("BuzzkillSaw3").Type, 0.8f); + break; + case 2: + Gore.NewGore(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2Circular(4f, 4f), Mod.Find("BuzzkillSaw1").Type, 0.8f); + Gore.NewGore(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2Circular(4f, 4f), Mod.Find("BuzzkillSaw2").Type, 0.8f); + break; + } + } + + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + if (SawLevel >= 2f) + hitbox.Inflate(65, 65); + else if (SawLevel >= 1f) + hitbox.Inflate(28, 28); + } + + public override bool PreDraw(ref Color lightColor) + { + LargeSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/BuzzkillSawLargeSlash"); + Texture2D largeSlashTexture = LargeSlash.Value; + SmallSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/BuzzkillSawSmallSlash"); + Texture2D smallSlashTexture = SmallSlash.Value; + Color slashColor = new Color(200, 200, 200, 100); + + if (SawLevel >= 2f) + { + Main.EntitySpriteDraw(largeSlashTexture, Projectile.Center - Main.screenPosition, null, slashColor, -Projectile.rotation, largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time % 4 == 0) + { + Vector2 randomParticleOffset = new Vector2(Main.rand.NextFloat(-Projectile.width * 1.75f, Projectile.width * 1.75f), Main.rand.NextFloat(-Projectile.width * 1.75f, Projectile.width * 1.75f)); + float randomParticleScale = Main.rand.NextFloat(0.65f, 0.95f); + Particle bloomCircle = new BloomParticle(Projectile.Center + randomParticleOffset, Projectile.velocity, Main.rand.NextBool() ? Color.White : new Color(112, 16, 16), randomParticleScale, randomParticleScale, 4, false); + GeneralParticleHandler.SpawnParticle(bloomCircle); + } + } + if (SawLevel >= 1f) + { + Main.EntitySpriteDraw(smallSlashTexture, Projectile.Center - Main.screenPosition, null, slashColor, Projectile.rotation, smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time % 4 == 0) + { + Vector2 randomParticleOffset = new Vector2(Main.rand.NextFloat(-Projectile.width, Projectile.width), Main.rand.NextFloat(-Projectile.width, Projectile.width)); + float randomParticleScale = Main.rand.NextFloat(0.35f, 0.65f); + Particle bloomCircle = new BloomParticle(Projectile.Center + randomParticleOffset, Projectile.velocity, Main.rand.NextBool() ? Color.White : new Color(112, 16, 16), randomParticleScale, randomParticleScale, 4, false); + GeneralParticleHandler.SpawnParticle(bloomCircle); + } + } + + if (!CalamityConfig.Instance.Afterimages) + return true; + + // Special afterimage drawing to include the slashes + Texture2D buzzsawTexture = TextureAssets.Projectile[Projectile.type].Value; + Rectangle frame = buzzsawTexture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + for (int i = 1; i < Projectile.oldPos.Length; i++) + { + float afterimageRot = Projectile.oldRot[i]; + Vector2 drawPos = Projectile.oldPos[i] + frame.Size() * 0.5f - Main.screenPosition; + float intensity = MathHelper.Lerp(0.1f, 0.6f, 1f - i / (float)Projectile.oldPos.Length); + + Main.EntitySpriteDraw(buzzsawTexture, drawPos, frame, lightColor * intensity, afterimageRot, frame.Size() * 0.5f, 1f, SpriteEffects.None); + + if (SawLevel >= 2f) + Main.EntitySpriteDraw(largeSlashTexture, drawPos, null, slashColor * intensity, -afterimageRot, largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + if (SawLevel >= 1f) + Main.EntitySpriteDraw(smallSlashTexture, drawPos, null, slashColor * intensity, afterimageRot, smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + } + return true; + } + } +} diff --git a/Projectiles/Ranged/BuzzkillSaw.png b/Projectiles/Ranged/BuzzkillSaw.png new file mode 100644 index 0000000000..26e13051ee Binary files /dev/null and b/Projectiles/Ranged/BuzzkillSaw.png differ diff --git a/Projectiles/Ranged/BuzzkillSawLargeSlash.png b/Projectiles/Ranged/BuzzkillSawLargeSlash.png new file mode 100644 index 0000000000..98981fa415 Binary files /dev/null and b/Projectiles/Ranged/BuzzkillSawLargeSlash.png differ diff --git a/Projectiles/Ranged/BuzzkillSawSmallSlash.png b/Projectiles/Ranged/BuzzkillSawSmallSlash.png new file mode 100644 index 0000000000..8ee31d89e0 Binary files /dev/null and b/Projectiles/Ranged/BuzzkillSawSmallSlash.png differ diff --git a/Projectiles/Ranged/ChargedBlast.cs b/Projectiles/Ranged/ChargedBlast.cs index caacfc330d..30a3a8ef6f 100644 --- a/Projectiles/Ranged/ChargedBlast.cs +++ b/Projectiles/Ranged/ChargedBlast.cs @@ -1,4 +1,7 @@ -using Microsoft.Xna.Framework; +using System; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -10,7 +13,14 @@ namespace CalamityMod.Projectiles.Ranged { public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/LaserProj"; - + public Color baseColor = Color.White; + public bool outOfTime = false; + public Vector2 baseVel; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 15; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } public override void SetDefaults() { Projectile.width = 5; @@ -18,43 +28,78 @@ namespace CalamityMod.Projectiles.Ranged Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 1; - Projectile.MaxUpdates = 2; - Projectile.alpha = 255; + Projectile.extraUpdates = 6; Projectile.timeLeft = 360; Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() { - if (Projectile.alpha > 0) - Projectile.alpha -= 25; - if (Projectile.alpha < 0) - Projectile.alpha = 0; + bool Shredder = Projectile.ai[2] == 0; + bool Infinity = Projectile.ai[2] == 1; + bool Svant = Projectile.ai[2] == 2 || Projectile.ai[2] == 3 || Projectile.ai[2] == 4; - float lightScale = 1f - Projectile.alpha / 255f; - Projectile.ai[2] = lightScale; - Lighting.AddLight(Projectile.Center, 0f, 0.3f * lightScale, 0.7f * lightScale); + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); - float beamLength = 60f; - float beamLengthGrowth = 1f; - Projectile.localAI[0] += beamLengthGrowth; - if (Projectile.localAI[0] > beamLength) - Projectile.localAI[0] = beamLength; - } - - public override Color? GetAlpha(Color lightColor) => new Color(100, 100, 255, 0) * Projectile.ai[2]; - - public override bool PreDraw(ref Color lightColor) => Projectile.DrawBeam(100f, 3f, lightColor); - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item62, Projectile.position); - int projectiles = 2; - if (Projectile.owner == Main.myPlayer) + if (baseColor == Color.White) { - for (int k = 0; k < projectiles; k++) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2CircularEdge(5f, 5f), ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), Projectile.knockBack * 0.8f, Main.myPlayer); + baseColor = (Infinity ? new Color(229, 49, 39) : Svant ? Color.DarkViolet : Color.DodgerBlue); + if (Projectile.ai[2] == 3) + { + baseColor = Color.DarkOrchid; + } + if (Projectile.ai[2] == 4) + { + baseColor = Color.MediumOrchid; + } + baseVel = Projectile.velocity; + if (Svant) + Projectile.ArmorPenetration = 100; + if (Infinity) + Projectile.ArmorPenetration = 25; + } + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + if (Projectile.timeLeft == 2) + outOfTime = true; + if ((Svant || Infinity) && Projectile.timeLeft % 2 == 0 && targetDist < 1400f && Projectile.timeLeft < 340) + { + Particle spark = new LineParticle(Projectile.Center - Projectile.velocity * 3, -Projectile.velocity * 0.05f, false, 5, 2f, baseColor * 0.65f); + GeneralParticleHandler.SpawnParticle(spark); } } + public override void OnKill(int timeLeft) + { + if (!outOfTime) + { + SoundEngine.PlaySound(SoundID.Item62, Projectile.Center); + int projectiles = 2; + if (Projectile.owner == Main.myPlayer) + { + for (int k = 0; k < projectiles; k++) + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, -baseVel.RotatedByRandom(0.9f) * Main.rand.NextFloat(0.6f, 0.7f), ModContent.ProjectileType(), (int)(Projectile.damage * (Projectile.ai[2] > 0 ? 0.3f : 0.5f)), Projectile.knockBack * 0.8f, Main.myPlayer, 0, 0, Projectile.ai[2]); + } + for (int k = 0; k < 3; k++) + { + Particle spark2 = new LineParticle(Projectile.Center, (-baseVel * 4).RotatedByRandom(0.9f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(25, 32 + 1), Main.rand.NextFloat(1.5f, 2f), baseColor); + GeneralParticleHandler.SpawnParticle(spark2); + } + if (Projectile.ai[2] == 1) + { + Particle spark2 = new LineParticle(Projectile.Center, (-baseVel * 5).RotatedByRandom(0.9f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(35, 48 + 1), Main.rand.NextFloat(2.3f, 3f), baseColor); + GeneralParticleHandler.SpawnParticle(spark2); + } + } + } + public override bool PreDraw(ref Color lightColor) + { + if (baseColor == Color.White) + return false; + Texture2D texture = ModContent.Request("CalamityMod/Particles/DrainLineBloom").Value; + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], (baseColor * 0.7f) with { A = 0 }, 1, texture); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, baseColor with { A = 0 }, Projectile.rotation, texture.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); + return false; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 20, targetHitbox); } } diff --git a/Projectiles/Ranged/ChargedBlast2.cs b/Projectiles/Ranged/ChargedBlast2.cs deleted file mode 100644 index 89318cc187..0000000000 --- a/Projectiles/Ranged/ChargedBlast2.cs +++ /dev/null @@ -1,79 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - public class ChargedBlast2 : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/LaserProj"; - - public override void SetDefaults() - { - Projectile.width = 5; - Projectile.height = 5; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 3; - Projectile.MaxUpdates = 2; - Projectile.alpha = 255; - Projectile.timeLeft = 180; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - } - - public override void AI() - { - if (Projectile.timeLeft < 60) - { - Projectile.alpha += 5; - if (Projectile.alpha >= 255) - Projectile.Kill(); - } - else - { - if (Projectile.alpha > 0) - Projectile.alpha -= 25; - if (Projectile.alpha < 0) - Projectile.alpha = 0; - } - - float lightScale = 1f - Projectile.alpha / 255f; - Projectile.ai[2] = lightScale; - Lighting.AddLight(Projectile.Center, 0f, 0.3f * lightScale, 0.7f * lightScale); - - float beamLength = 30f; - float beamLengthGrowth = 0.5f; - Projectile.localAI[0] += beamLengthGrowth; - if (Projectile.localAI[0] > beamLength) - Projectile.localAI[0] = beamLength; - } - - public override Color? GetAlpha(Color lightColor) => new Color(100, 100, 255, 0) * Projectile.ai[2]; - - public override bool PreDraw(ref Color lightColor) => Projectile.DrawBeam(100f, 3f, lightColor); - - public override bool OnTileCollide(Vector2 oldVelocity) - { - SoundEngine.PlaySound(SoundID.Item10, Projectile.position); - - Projectile.penetrate--; - if (Projectile.penetrate <= 0) - { - Projectile.Kill(); - } - else - { - if (Projectile.velocity.X != oldVelocity.X) - Projectile.velocity.X = -oldVelocity.X; - if (Projectile.velocity.Y != oldVelocity.Y) - Projectile.velocity.Y = -oldVelocity.Y; - } - - return false; - } - } -} diff --git a/Projectiles/Ranged/ChargedBlastSplit.cs b/Projectiles/Ranged/ChargedBlastSplit.cs new file mode 100644 index 0000000000..fb72db7217 --- /dev/null +++ b/Projectiles/Ranged/ChargedBlastSplit.cs @@ -0,0 +1,143 @@ +using System; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Utilities.Terraria.Utilities; + +namespace CalamityMod.Projectiles.Ranged +{ + public class ChargedBlastSplit : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/LaserProj"; + public Color baseColor = Color.White; + public int tileHits = 4; + public Vector2 startVel; + public bool goToMouse = true; + bool direction; + public float homeSpeed; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 15; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + public override void SetDefaults() + { + Projectile.width = 5; + Projectile.height = 5; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = 3; + Projectile.extraUpdates = 5; + Projectile.timeLeft = 240; + Projectile.scale = 0.7f; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 15; + } + + public override void AI() + { + Player player = Main.player[Projectile.owner]; + bool Shredder = Projectile.ai[2] == 0; + bool Infinity = Projectile.ai[2] == 1; + bool Svant = Projectile.ai[2] == 2 || Projectile.ai[2] == 3 || Projectile.ai[2] == 4; + + if (baseColor == Color.White) + { + baseColor = (Infinity ? new Color(229, 49, 39) : Svant ? Color.DarkViolet : Color.DodgerBlue); + if (Projectile.ai[2] == 3) + baseColor = Color.DarkOrchid; + if (Projectile.ai[2] == 4) + baseColor = Color.MediumOrchid; + startVel = Projectile.velocity; + if (Infinity) + { + Projectile.timeLeft = 340; + Projectile.ArmorPenetration = 25; + } + if (Svant) + { + Projectile.timeLeft = 640; + Projectile.ArmorPenetration = 100; + } + direction = Main.rand.NextBool(); + homeSpeed = Main.rand.NextFloat(5, 8); + } + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + if (Projectile.timeLeft < 290 && Infinity) + { + Projectile.velocity.X = MathHelper.Lerp(Projectile.velocity.X, -startVel.X, 0.02f); + Projectile.velocity.Y = MathHelper.Lerp(Projectile.velocity.Y, -startVel.Y, 0.02f); + } + if (Projectile.timeLeft <= 500 && Svant && goToMouse && Projectile.timeLeft % Projectile.extraUpdates == 0) + { + Vector2 mouseSpot = (player.Calamity().mouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX) * homeSpeed; + Projectile.velocity.X = MathHelper.Lerp(Projectile.velocity.X, mouseSpot.X, 0.085f); + Projectile.velocity.Y = MathHelper.Lerp(Projectile.velocity.Y, mouseSpot.Y, 0.085f); + if (Vector2.Distance(Projectile.Center, player.Calamity().mouseWorld) < 80) + { + Projectile.timeLeft = 300; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * homeSpeed / 2; + goToMouse = false; + } + } + if (!goToMouse) + { + float sine = (float)Math.Sin(Projectile.timeLeft * 0.175f / MathHelper.Pi) * 1.2f; + Vector2 offset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * sine * (direction ? 1 : -1); + Projectile.Center += offset; + } + if (Infinity || Svant) + { + Projectile.tileCollide = false; + Projectile.penetrate = -1; + } + } + public override void OnKill(int timeLeft) + { + bool Svant = Projectile.ai[2] == 2 || Projectile.ai[2] == 3 || Projectile.ai[2] == 4; + for (int k = 0; k < (Svant ? 2 : 3); k++) + { + Particle spark2 = new LineParticle(Projectile.Center, (Projectile.velocity * 5).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.8f, 1.2f), false, Main.rand.Next(8, 11 + 1), Main.rand.NextFloat(0.5f, 1f), baseColor); + GeneralParticleHandler.SpawnParticle(spark2); + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + + } + public override bool PreDraw(ref Color lightColor) + { + if (baseColor == Color.White) + return false; + Texture2D texture = ModContent.Request("CalamityMod/Particles/DrainLineBloom").Value; + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], (baseColor * 0.7f) with { A = 0 }, 1, texture); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, baseColor with { A = 0 }, Projectile.rotation, texture.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); + return false; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 10, targetHitbox); + + public override bool OnTileCollide(Vector2 oldVelocity) + { + tileHits--; + if (tileHits <= 0) + { + Projectile.Kill(); + } + else + { + if (Projectile.velocity.X != oldVelocity.X) + Projectile.velocity.X = -oldVelocity.X; + if (Projectile.velocity.Y != oldVelocity.Y) + Projectile.velocity.Y = -oldVelocity.Y; + } + + return false; + } + } +} diff --git a/Projectiles/Ranged/CinderArrowProj.cs b/Projectiles/Ranged/CinderArrowProj.cs index 1933630860..cfd82c1257 100644 --- a/Projectiles/Ranged/CinderArrowProj.cs +++ b/Projectiles/Ranged/CinderArrowProj.cs @@ -102,13 +102,13 @@ namespace CalamityMod.Projectiles.Ranged for (int b = 0; b < 3; b++) { Vector2 velocity = Vector2.UnitY.RotatedByRandom(0.8f) * Main.rand.NextFloat(-3.5f, -3f); - Projectile shrapnel = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1f), 0f, Projectile.owner, ai2: 1f); + Projectile shrapnel = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.06f), 0f, Projectile.owner, ai2: 1f); shrapnel.timeLeft = 300; shrapnel.arrow = false; shrapnel.MaxUpdates = 4; } - Projectile.damage = (int)(Projectile.damage * 0.5f); + Projectile.damage = (int)(Projectile.damage * 0.4f); Projectile.penetrate = -1; Projectile.ExpandHitboxBy(110); Projectile.Damage(); diff --git a/Projectiles/Ranged/CondemnationHoldout.cs b/Projectiles/Ranged/CondemnationHoldout.cs index 04693f2c48..adb6c6d397 100644 --- a/Projectiles/Ranged/CondemnationHoldout.cs +++ b/Projectiles/Ranged/CondemnationHoldout.cs @@ -1,18 +1,20 @@ -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Sounds; +using System.IO; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class CondemnationHoldout : ModProjectile + public class CondemnationHoldout : BaseGunHoldoutProjectile { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - private Player Owner => Main.player[Projectile.owner]; + public override int AssociatedItemID => ModContent.ItemType(); + public override float MaxOffsetLengthFromArm => 25f; + public override float OffsetXUpwards => -5f; + public override float BaseOffsetY => -5f; private ref float CurrentChargingFrames => ref Projectile.ai[0]; private ref float ArrowsLoaded => ref Projectile.ai[1]; @@ -22,24 +24,8 @@ namespace CalamityMod.Projectiles.Ranged public const float velocityMultiplier = 1.2f; public bool homing = false; - public override string Texture => "CalamityMod/Items/Weapons/Ranged/Condemnation"; - - public override void SetDefaults() + public override void KillHoldoutLogic() { - Projectile.width = 130; - Projectile.height = 42; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Ranged; - Projectile.ignoreWater = true; - } - - public override void AI() - { - Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); - Vector2 tipPosition = armPosition + Projectile.velocity * Projectile.width * 0.5f; - // Fire arrows if the owner stops channeling or otherwise cannot use the weapon. if (Owner.CantUseHoldout()) { @@ -51,65 +37,61 @@ namespace CalamityMod.Projectiles.Ranged } // Fire one charged arrow every frame until you're out of arrows. - ShootProjectiles(tipPosition, homing); + ShootProjectiles(homing); --ArrowsLoaded; if (ArrowsLoaded == 0 && homing == true) homing = false; } - else + } + + public override void HoldoutAI() + { + // Frame 1 effects: Record how fast the Condemnation item being used is, to determine how fast to load arrows. + if (FramesToLoadNextArrow == 0f) { + SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); + FramesToLoadNextArrow = HeldItem.useAnimation; + } - // Frame 1 effects: Record how fast the Condemnation item being used is, to determine how fast to load arrows. - if (FramesToLoadNextArrow == 0f) + // If no arrows are loaded, spawn a bit of dust to indicate it's not ready yet. + // Spawn the same dust if the max number of arrows have been loaded or the player ran out of ammos to load. + if (ArrowsLoaded <= 0f || ArrowsLoaded >= Condemnation.MaxLoadedArrows || !Owner.HasAmmo(Owner.ActiveItem())) + SpawnCannotLoadArrowsDust(GunTipPosition); + + if (Owner.HasAmmo(HeldItem)) + { + // Actually make progress towards loading more arrows. + ++CurrentChargingFrames; + + // If it is time to load an arrow, produce a pulse of dust and add an arrow. + // Also accelerate charging, because it's fucking awesome. + // Take the ammo here as well + if (CurrentChargingFrames >= FramesToLoadNextArrow && ArrowsLoaded < Condemnation.MaxLoadedArrows) { - SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); - FramesToLoadNextArrow = Owner.ActiveItem().useAnimation; - } + // Save the stats here for later + Owner.PickAmmo(HeldItem, out _, out float shootSpeed, out int damage, out float knockback, out _); + Projectile.damage = damage; + Projectile.knockBack = knockback; + storedVelocity = shootSpeed * velocityMultiplier; - // If no arrows are loaded, spawn a bit of dust to indicate it's not ready yet. - // Spawn the same dust if the max number of arrows have been loaded or the player ran out of ammos to load. - if (ArrowsLoaded <= 0f || ArrowsLoaded >= Condemnation.MaxLoadedArrows || !Owner.HasAmmo(Owner.ActiveItem())) - SpawnCannotLoadArrowsDust(tipPosition); + SpawnArrowLoadedDust(); + CurrentChargingFrames = 0f; + ++ArrowsLoaded; + --FramesToLoadNextArrow; - if (Owner.HasAmmo(Owner.ActiveItem())) - { - // Actually make progress towards loading more arrows. - ++CurrentChargingFrames; + // Play a sound for additional notification that an arrow has been loaded. + var loadSound = SoundEngine.PlaySound(SoundID.Item108 with { Volume = SoundID.Item108.Volume * 0.3f }); - // If it is time to load an arrow, produce a pulse of dust and add an arrow. - // Also accelerate charging, because it's fucking awesome. - // Take the ammo here as well - if (CurrentChargingFrames >= FramesToLoadNextArrow && ArrowsLoaded < Condemnation.MaxLoadedArrows) + if (ArrowsLoaded >= Condemnation.MaxLoadedArrows) { - // Save the stats here for later - Item heldItem = Owner.ActiveItem(); - Owner.PickAmmo(heldItem, out _, out float shootSpeed, out int damage, out float knockback, out _); - Projectile.damage = damage; - Projectile.knockBack = knockback; - storedVelocity = shootSpeed * velocityMultiplier; - - SpawnArrowLoadedDust(tipPosition); - CurrentChargingFrames = 0f; - ++ArrowsLoaded; - --FramesToLoadNextArrow; - - // Play a sound for additional notification that an arrow has been loaded. - var loadSound = SoundEngine.PlaySound(SoundID.Item108 with { Volume = SoundID.Item108.Volume * 0.3f }); - - if (ArrowsLoaded >= Condemnation.MaxLoadedArrows) - { - SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/AbilitySounds/BrimflameRecharge")); - homing = true; - } + SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/AbilitySounds/BrimflameRecharge")); + homing = true; } } } - - UpdateProjectileHeldVariables(armPosition); - ManipulatePlayerVariables(); } - public void SpawnArrowLoadedDust(Vector2 tipPosition) + public void SpawnArrowLoadedDust() { if (Main.dedServ) return; @@ -126,7 +108,7 @@ namespace CalamityMod.Projectiles.Ranged Vector2 end = nextAngle.ToRotationVector2(); for (int j = 0; j < 40; j++) { - Dust starDust = Dust.NewDustPerfect(tipPosition, 267); + Dust starDust = Dust.NewDustPerfect(GunTipPosition, 267); starDust.scale = 2.5f; starDust.velocity = Vector2.Lerp(start, end, j / 40f) * 16f; starDust.color = Color.Crimson; @@ -138,7 +120,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 36; i++) { - Dust chargeMagic = Dust.NewDustPerfect(tipPosition, 267); + Dust chargeMagic = Dust.NewDustPerfect(GunTipPosition, 267); chargeMagic.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * 5f + Owner.velocity; chargeMagic.scale = Main.rand.NextFloat(1f, 1.5f); chargeMagic.color = Color.Violet; @@ -146,62 +128,43 @@ namespace CalamityMod.Projectiles.Ranged } } - public void SpawnCannotLoadArrowsDust(Vector2 tipPosition) + public void SpawnCannotLoadArrowsDust(Vector2 GunTipPosition) { if (Main.dedServ) return; for (int i = 0; i < 2; i++) { - Dust chargeMagic = Dust.NewDustPerfect(tipPosition + Main.rand.NextVector2Circular(20f, 20f), 267); - chargeMagic.velocity = (tipPosition - chargeMagic.position) * 0.1f + Owner.velocity; + Dust chargeMagic = Dust.NewDustPerfect(GunTipPosition + Main.rand.NextVector2Circular(20f, 20f), 267); + chargeMagic.velocity = (GunTipPosition - chargeMagic.position) * 0.1f + Owner.velocity; chargeMagic.scale = Main.rand.NextFloat(1f, 1.5f); chargeMagic.color = Projectile.GetAlpha(Color.White); chargeMagic.noGravity = true; } } - public void ShootProjectiles(Vector2 tipPosition, bool homing) + public void ShootProjectiles(bool homing) { if (Main.myPlayer != Projectile.owner) return; Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * storedVelocity; int ArrowType = homing ? ModContent.ProjectileType() : ModContent.ProjectileType(); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, shootVelocity, ArrowType, Projectile.damage, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ArrowType, Projectile.damage, Projectile.knockBack, Projectile.owner); } - private void UpdateProjectileHeldVariables(Vector2 armPosition) + public override void SendExtraAIHoldout(BinaryWriter writer) { - if (Main.myPlayer == Projectile.owner) - { - float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); - Vector2 oldVelocity = Projectile.velocity; - Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); - if (Projectile.velocity != oldVelocity) - { - Projectile.netSpam = 0; - Projectile.netUpdate = true; - } - } - - Projectile.position = armPosition - Projectile.Size * 0.5f; - Projectile.rotation = Projectile.velocity.ToRotation(); - if (Projectile.spriteDirection == -1) - Projectile.rotation += MathHelper.Pi; - Projectile.spriteDirection = Projectile.direction; - Projectile.timeLeft = 2; + writer.Write(FramesToLoadNextArrow); + writer.Write(storedVelocity); + writer.Write(homing); } - private void ManipulatePlayerVariables() + public override void ReceiveExtraAIHoldout(BinaryReader reader) { - Owner.ChangeDir(Projectile.direction); - Owner.heldProj = Projectile.whoAmI; - Owner.itemTime = 2; - Owner.itemAnimation = 2; - Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + FramesToLoadNextArrow = reader.ReadSingle(); + storedVelocity = reader.ReadSingle(); + homing = reader.ReadBoolean(); } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Ranged/DryadsTearMain.cs b/Projectiles/Ranged/DryadsTearMain.cs index 5676aded04..2002b27fe6 100644 --- a/Projectiles/Ranged/DryadsTearMain.cs +++ b/Projectiles/Ranged/DryadsTearMain.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Ranged for (int b = 0; b < 2; b++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.3), 0f, Projectile.owner, 0f, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1), 0f, Projectile.owner, 0f, 0f); } for (int i = 0; i < 3; i++) { diff --git a/Projectiles/Ranged/DryadsTearSplit.cs b/Projectiles/Ranged/DryadsTearSplit.cs index 92d247019b..6b712b70a2 100644 --- a/Projectiles/Ranged/DryadsTearSplit.cs +++ b/Projectiles/Ranged/DryadsTearSplit.cs @@ -27,6 +27,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.timeLeft = 210; Projectile.extraUpdates = 1; Projectile.tileCollide = false; + Projectile.ArmorPenetration = 10; AIType = ProjectileID.Bullet; } diff --git a/Projectiles/Ranged/ElementalEruptionHouldout.cs b/Projectiles/Ranged/ElementalEruptionHouldout.cs index e3c445aa01..bb8f4c68f1 100644 --- a/Projectiles/Ranged/ElementalEruptionHouldout.cs +++ b/Projectiles/Ranged/ElementalEruptionHouldout.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Weapons.Ranged; +using System.IO; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Terraria; @@ -17,19 +18,16 @@ namespace CalamityMod.Projectiles.Ranged public override float BaseOffsetY => -5f; public override float OffsetYDownwards => 10f; - private ref float ShotCooldown => ref Projectile.ai[0]; - private ref float ShotsFired => ref Projectile.ai[1]; - private ref float ShootTimer => ref Projectile.ai[2]; - public int FireBlobs = 0; + public ref float ShotCooldown => ref Projectile.ai[0]; + public ref float ShotsFired => ref Projectile.ai[1]; + public ref float ShootTimer => ref Projectile.ai[2]; + public int FireBlobs { get; set; } public override void KillHoldoutLogic() { base.KillHoldoutLogic(); if (ShotsFired >= 24) - { Projectile.Kill(); - Projectile.netUpdate = true; - } } public override void HoldoutAI() @@ -91,5 +89,9 @@ namespace CalamityMod.Projectiles.Ranged base.OnSpawn(source); SoundEngine.PlaySound(SoundID.Item73 with { Volume = 0.7f }, Projectile.Center); } + + public override void SendExtraAIHoldout(BinaryWriter writer) => writer.Write(FireBlobs); + + public override void ReceiveExtraAIHoldout(BinaryReader reader) => FireBlobs = reader.ReadInt32(); } } diff --git a/Projectiles/Ranged/EmesisGore.cs b/Projectiles/Ranged/EmesisGore.cs index 94fdf0e318..05d52851f7 100644 --- a/Projectiles/Ranged/EmesisGore.cs +++ b/Projectiles/Ranged/EmesisGore.cs @@ -1,7 +1,11 @@ -using System.IO; +using System; +using System.IO; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -10,77 +14,83 @@ namespace CalamityMod.Projectiles.Ranged public class EmesisGore : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public int HurtCounter = 0; - public const int HurtTimeIncrement = 10; + public bool setStats = true; + public int rotDirection = 1; public override void SetDefaults() { Projectile.width = 12; Projectile.height = 12; Projectile.friendly = true; - Projectile.penetrate = 10; - Projectile.timeLeft = 600; + Projectile.penetrate = 1; + Projectile.tileCollide = false; + Projectile.extraUpdates = 4; + Projectile.timeLeft = 800; Projectile.DamageType = DamageClass.Ranged; Projectile.ignoreWater = true; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 6; - } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(HurtCounter); - } - public override void ReceiveExtraAI(BinaryReader reader) - { - HurtCounter = reader.ReadInt32(); + Projectile.localNPCHitCooldown = -1; } public override void AI() { - Projectile.StickyProjAI(15); - - // Override the default DOT used in the method above. - if (Projectile.ai[0] == 1f) + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + if (setStats) { - Projectile.localAI[0] = 5f; - Projectile.velocity = Vector2.Zero; - HurtCounter++; - if (HurtCounter % HurtTimeIncrement == 0) + rotDirection = (Main.rand.NextBool() ? -1 : 1); + Projectile.rotation = Main.rand.NextFloat(-20, 20); + setStats = false; + } + Projectile.rotation += 0.01f * rotDirection * Utils.GetLerpValue(0, 800, Projectile.timeLeft); + Projectile.velocity *= 0.9975f; + if (Projectile.ai[0] < 20 && Projectile.timeLeft > 695 && Projectile.timeLeft < 785) + Projectile.velocity = Projectile.velocity.RotatedBy(0.0017f * Projectile.ai[0]); + Projectile.alpha = (int)(Utils.Remap(Projectile.timeLeft, 70, 0, 0, 255, true)); + if (targetDist < 1400f && Projectile.timeLeft > 70 && Projectile.timeLeft < 790) + { + if (Projectile.timeLeft % 6 == 0) { - Main.npc[(int)Projectile.ai[1]].HitEffect(0, 50.0); + Particle spark = new LineParticle(Projectile.Center - Projectile.velocity + Main.rand.NextVector2Circular(20, 20), -Projectile.velocity * Main.rand.NextFloat(0.2f, 1.8f), false, Main.rand.Next(9, 20 + 1), Main.rand.NextFloat(0.8f, 1.2f), Color.Chartreuse * Main.rand.NextFloat(0.15f, 0.5f)); + GeneralParticleHandler.SpawnParticle(spark); } - } - else - { - Projectile.rotation += (Projectile.velocity.X > 0).ToDirectionInt() * MathHelper.ToRadians(8f); - } - if (Projectile.timeLeft % 12 == 11) - { - for (int i = 0; i < (Projectile.ai[0] == 1f ? 3 : 1); i++) + if (Main.rand.NextBool(6)) { - Dust dust = Dust.NewDustDirect(Projectile.position, 10, 10, DustID.Shadowflame); - dust.velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(20, 20), 75, -Projectile.velocity.RotatedByRandom(0.1) * Main.rand.NextFloat(0.1f, 0.3f), 0, default, Main.rand.NextFloat(0.5f, 1.2f)); dust.noGravity = true; } } } - - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => Projectile.ModifyHitNPCSticky(8); - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - if (targetHitbox.Width > 8 && targetHitbox.Height > 8) - { - targetHitbox.Inflate(-targetHitbox.Width / 8, -targetHitbox.Height / 8); - } - return null; - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(ModContent.BuffType(), 420); + for (int k = 0; k < 15; k++) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(5) ? 28 : 215, new Vector2(11, 11).RotatedByRandom(100) * Main.rand.NextFloat(0.05f, 0.8f)); + dust2.scale = Main.rand.NextFloat(0.75f, 1.25f); + dust2.noGravity = false; + Particle spark = new LineParticle(Projectile.Center, new Vector2(11, 11).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), true, Main.rand.Next(23, 35 + 1), Main.rand.NextFloat(0.8f, 1.2f), Color.Chartreuse * Main.rand.NextFloat(0.15f, 0.5f)); + GeneralParticleHandler.SpawnParticle(spark); + } + SoundStyle splode = new("CalamityMod/Sounds/NPCKilled/PerfLargeDeath"); + SoundEngine.PlaySound(splode with { Volume = 0.6f }, Projectile.Center); } public override void OnHitPlayer(Player target, Player.HurtInfo info) { - target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(ModContent.BuffType(), 420); } + public override bool PreDraw(ref Color lightColor) + { + + Texture2D texture = ModContent.Request("CalamityMod/Projectiles/Boss/OldDukeGore").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Color drawColor = Projectile.GetAlpha(lightColor); + float drawRotation = Projectile.rotation; + Vector2 rotationPoint = texture.Size() * 0.5f; + + + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); + return false; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 20, targetHitbox); } } diff --git a/Projectiles/Ranged/FetidEmesisHoldout.cs b/Projectiles/Ranged/FetidEmesisHoldout.cs new file mode 100644 index 0000000000..86819620eb --- /dev/null +++ b/Projectiles/Ranged/FetidEmesisHoldout.cs @@ -0,0 +1,151 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ModLoader; +using Terraria.ID; + +namespace CalamityMod.Projectiles.Ranged +{ + public class FetidEmesisHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ModContent.ItemType(); + public override float MaxOffsetLengthFromArm => 24f; + public override float OffsetXUpwards => -5f; + public override float BaseOffsetY => -5f; + public override float OffsetYDownwards => 5f; + + public ref float revFrames => ref Projectile.ai[0]; + public ref float cooldownTimer => ref Projectile.ai[1]; + public ref float shootingTimer => ref Projectile.ai[2]; // Dual functions for rapid fire shooting cooldown and recoil + public bool isTired => cooldownTimer > 0; + public float revSpeed = 1; + + public override void KillHoldoutLogic() + { + if ( !isTired && (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type)) + Projectile.Kill(); + } + + public override void HoldoutAI() + { + if (!isTired && (Owner.CantUseHoldout() || HeldItem.type != Owner.ActiveItem().type)) + cooldownTimer = (int)(Utils.Remap(revFrames, 0, 350, 40, 180, true)); + if (isTired) + { + PostFiringCooldown(); + return; + } + + revSpeed = Utils.Remap(revFrames, 0, 200, 1, 20, true); + if (shootingTimer >= 60) + { + Owner.PickAmmo(Owner.ActiveItem(), out int bulletAMMO, out float SpeedNoUse, out int bulletDamage, out float kBackNoUse, out _, !Main.rand.NextBool(4)); + + SoundStyle fire = new("CalamityMod/Sounds/Item/GunShotSmallAlt"); + SoundEngine.PlaySound(fire with { Volume = 0.7f }, Projectile.Center); + + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 19; + float spread = 0.045f * Utils.GetLerpValue(0, 300, revFrames, true); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedByRandom(spread), bulletAMMO, Projectile.damage, Projectile.knockBack, Projectile.owner); + + for (int i = 0; i <= 3; i++) + { + Dust dust = Dust.NewDustPerfect(GunTipPosition - Projectile.velocity * 5, Main.rand.NextBool(5) ? 28 : 215, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.2f, 1.5f), 0, default, Main.rand.NextFloat(0.6f, 1.4f)); + dust.noGravity = true; + } + GenericSparkle sparker = new GenericSparkle(GunTipPosition, Vector2.Zero, Color.DarkGoldenrod, Color.Gold, Main.rand.NextFloat(1.1f, 1.8f), 2, Main.rand.NextFloat(-0.01f, 0.01f), 2.68f); + GeneralParticleHandler.SpawnParticle(sparker); + + OffsetLengthFromArm -= 5f; + shootingTimer = 0; + } + + shootingTimer += revSpeed; + revFrames++; + if (revFrames >= 300 && !isTired) + { + Owner.Calamity().GeneralScreenShakePower = 6.5f; + OffsetLengthFromArm -= 35f; + cooldownTimer = 180; + SoundStyle bigShot = new("CalamityMod/Sounds/Custom/Perforator/PerfHiveIchorShoot"); + SoundStyle bigShotGun = new("CalamityMod/Sounds/Item/FlakKrakenShoot"); + SoundEngine.PlaySound(bigShot with { Pitch = -0.2f, Volume = 0.6f }, Projectile.Center); + SoundEngine.PlaySound(bigShotGun with { Volume = 0.6f }, Projectile.Center); + + int chunkDamage = (int)(Projectile.damage * 2.5f); + Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 13; + for (int i = 0; i <= 5; i++) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedBy(-0.03f * i) * (1 - i * 0.08f), ModContent.ProjectileType(), chunkDamage, Projectile.knockBack * 3, Projectile.owner, -i); + } + for (int j = 0; j <= 5; j++) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedBy(0.03f * j) * (1 - j * 0.08f), ModContent.ProjectileType(), chunkDamage, Projectile.knockBack * 3, Projectile.owner, j); + } + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), chunkDamage, Projectile.knockBack * 3, Projectile.owner, 20); + + for (int i = 0; i <= 18; i++) + { + Dust dust = Dust.NewDustPerfect(GunTipPosition, 66, shootVelocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 1.5f), 0, default, Main.rand.NextFloat(0.6f, 1.4f)); + dust.noGravity = true; + dust.color = Color.Chartreuse; + } + Particle pulse = new GlowSparkParticle(GunTipPosition - shootVelocity, shootVelocity, false, 12, 0.035f, Color.Chartreuse, new Vector2(2.5f, 0.9f), true); + GeneralParticleHandler.SpawnParticle(pulse); + } + } + private void PostFiringCooldown() + { + Owner.channel = true; + + if (cooldownTimer > 1) + { + Vector2 smokeVel = Projectile.velocity.SafeNormalize(Vector2.UnitY) * 5; + + if (cooldownTimer % 40 == 0) + { + SoundStyle tired = new("CalamityMod/Sounds/Custom/OldDukeHuff"); + SoundEngine.PlaySound(tired with { Pitch = -0.2f }, Projectile.Center); + for (int i = 0; i <= 12; i++) + { + Dust dust = Dust.NewDustPerfect(GunTipPosition, 303, smokeVel.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.2f, 1f), 80, default, Main.rand.NextFloat(0.4f, 1.3f)); + dust.noGravity = false; + dust.color = Color.White; + } + for (int i = 0; i < 5; i++) + { + Particle smoke = new HeavySmokeParticle(GunTipPosition, smokeVel.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.2f, 1f), Color.White, Main.rand.Next(40, 60 + 1), Main.rand.NextFloat(0.2f, 0.4f), 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + } + else + { + Projectile.Kill(); + } + + cooldownTimer--; + } + + public override bool PreDraw(ref Color lightColor) + { + if (revFrames < 2) + return false; + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + return false; + } + } +} diff --git a/Projectiles/Ranged/FlakKrakenHoldout.cs b/Projectiles/Ranged/FlakKrakenHoldout.cs index 2eaeff6f2a..362c7e66a2 100644 --- a/Projectiles/Ranged/FlakKrakenHoldout.cs +++ b/Projectiles/Ranged/FlakKrakenHoldout.cs @@ -134,8 +134,6 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/FlakKrakenShoot") { Volume = 0.6f }, GunTipPosition); } - - NetUpdate(); } // When it has shot all the projectiles in the burst, reset all the variables and back to shooting. @@ -143,7 +141,6 @@ namespace CalamityMod.Projectiles.Ranged { ShootingTimer = 0f; TimerBetweenBursts = 0f; - NetUpdate(); } } @@ -155,12 +152,5 @@ namespace CalamityMod.Projectiles.Ranged base.OnSpawn(source); FrontArmStretch = Player.CompositeArmStretchAmount.ThreeQuarters; } - - public void NetUpdate() - { - Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; - } } } diff --git a/Projectiles/Ranged/FlakKrakenProjectile.cs b/Projectiles/Ranged/FlakKrakenProjectile.cs index 962a9ba3c5..98db63bb3b 100644 --- a/Projectiles/Ranged/FlakKrakenProjectile.cs +++ b/Projectiles/Ranged/FlakKrakenProjectile.cs @@ -61,6 +61,8 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + Owner ??= Main.player[Projectile.owner]; + // Enforces the gravity. if (IsShrapnel) { @@ -124,15 +126,9 @@ namespace CalamityMod.Projectiles.Ranged trailDust.noGravity = true; trailDust.noLight = true; trailDust.alpha = (int)Utils.Remap(Projectile.timeLeft, 30f, 0f, 127f, 0f); - - Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * (IsShrapnel ? 0.3f : 1f)); } - public override void OnSpawn(IEntitySource source) - { - Owner = Main.player[Projectile.owner]; - Projectile.scale = 1.5f; - } + public override void OnSpawn(IEntitySource source) => Projectile.scale = 1.5f; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { @@ -169,7 +165,7 @@ namespace CalamityMod.Projectiles.Ranged { bool usedClusterRockets = RocketID == ItemID.ClusterRocketI || RocketID == ItemID.ClusterRocketII; int flakAmount = usedClusterRockets ? ClusterShrapnelAmount : ShrapnelAmount; - for (int i = 0; i < flakAmount; i++) + for (int i = 0; i < flakAmount && Main.myPlayer == Projectile.owner; i++) { Projectile shrapnel = Projectile.NewProjectileDirect( Projectile.GetSource_FromThis(), diff --git a/Projectiles/Ranged/FlakToxicannonHoldout.cs b/Projectiles/Ranged/FlakToxicannonHoldout.cs index 05b47dfeeb..1bf6ce82a7 100644 --- a/Projectiles/Ranged/FlakToxicannonHoldout.cs +++ b/Projectiles/Ranged/FlakToxicannonHoldout.cs @@ -135,7 +135,7 @@ namespace CalamityMod.Projectiles.Ranged } ShootingTimer = 0f; - Projectile.netUpdate = true; + } ShootingTimer++; diff --git a/Projectiles/Ranged/FlakToxicannonProjectile.cs b/Projectiles/Ranged/FlakToxicannonProjectile.cs index 01b0f9336b..a01cdd3535 100644 --- a/Projectiles/Ranged/FlakToxicannonProjectile.cs +++ b/Projectiles/Ranged/FlakToxicannonProjectile.cs @@ -59,6 +59,8 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + Owner ??= Main.player[Projectile.owner]; + // Enforces the gravity. if (IsShrapnel) { @@ -119,11 +121,7 @@ namespace CalamityMod.Projectiles.Ranged Lighting.AddLight(Projectile.Center, Color.GreenYellow.ToVector3() * (IsShrapnel ? 1.5f : 2.5f)); } - public override void OnSpawn(IEntitySource source) - { - Owner = Main.player[Projectile.owner]; - Projectile.scale = 1.5f; - } + public override void OnSpawn(IEntitySource source) => Projectile.scale = 1.5f; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { @@ -160,7 +158,7 @@ namespace CalamityMod.Projectiles.Ranged { bool usedClusterRockets = RocketID == ItemID.ClusterRocketI || RocketID == ItemID.ClusterRocketII; int flakAmount = usedClusterRockets ? ClusterShrapnelAmount : ShrapnelAmount; - for (int i = 0; i < flakAmount; i++) + for (int i = 0; i < flakAmount && Main.myPlayer == Projectile.owner; i++) { Projectile shrapnel = Projectile.NewProjectileDirect( Projectile.GetSource_FromThis(), diff --git a/Projectiles/Ranged/HailstormBulletProj.cs b/Projectiles/Ranged/HailstormBulletProj.cs index 66721fffd5..ac240f4e5d 100644 --- a/Projectiles/Ranged/HailstormBulletProj.cs +++ b/Projectiles/Ranged/HailstormBulletProj.cs @@ -1,4 +1,5 @@ -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; @@ -59,7 +60,7 @@ namespace CalamityMod.Projectiles.Ranged rotIncrease += 0.1f * (rotDirection ? -1 : 1); - Projectile.velocity *= 0.982f; + Projectile.velocity *= 0.984f; if (Projectile.localAI[0] > 100f && Projectile.localAI[0] < 300 && Projectile.localAI[0] % 9 == 0) { @@ -71,12 +72,15 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { Player Owner = Main.player[Projectile.owner]; - target.AddBuff(BuffID.Frostburn, 120); + target.AddBuff(BuffID.Frostburn2, 120); if (hit.Crit) { SoundStyle crit = new("CalamityMod/Sounds/NPCHit/CryogenPhaseTransitionCrack"); SoundEngine.PlaySound(crit with { Volume = 0.35f, Pitch = 1f }, Projectile.Center); - target.AddBuff(BuffID.Frostburn2, 300); + + if (!target.boss) + target.AddBuff(ModContent.BuffType(), 120); + int points = 6; float radians = MathHelper.TwoPi / points; Vector2 spinningPoint = Vector2.Normalize(new Vector2(-1f, -1f)); @@ -88,7 +92,7 @@ namespace CalamityMod.Projectiles.Ranged WaterFlavoredParticle subTrail = new WaterFlavoredParticle(Projectile.Center + velocity * 4.5f + addedPlacement, velocity * 7, false, 6, 0.65f, Color.SkyBlue); GeneralParticleHandler.SpawnParticle(subTrail); } - int onHitDamage = Owner.CalcIntDamage(0.36f * Projectile.damage); + int onHitDamage = (int)(Projectile.damage * 0.5f); Owner.ApplyDamageToNPC(target, onHitDamage, 0f, 0, false); } } diff --git a/Projectiles/Ranged/HolyFireBulletProj.cs b/Projectiles/Ranged/HolyFireBulletProj.cs index 97da541fc2..501562259e 100644 --- a/Projectiles/Ranged/HolyFireBulletProj.cs +++ b/Projectiles/Ranged/HolyFireBulletProj.cs @@ -81,12 +81,14 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { - // Spawn an on-hit explosion which deals 75% of the projectile's damage. + // Spawn an on-hit explosion which deals 30% of the projectile's damage. if (Projectile.owner == Main.myPlayer) { Projectile.damage = (int)(Projectile.damage * HolyFireBullet.ExplosionMultiplier); Projectile.penetrate = -1; Projectile.ExpandHitboxBy((25 * SizeVariance) * SizeBonus); + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; Projectile.Damage(); } SoundEngine.PlaySound(HolyFireBullet.Explosion with { Pitch = -0.15f, Volume = 0.3f }, Projectile.Center); diff --git a/Projectiles/Ranged/HyperiusBulletProj.cs b/Projectiles/Ranged/HyperiusBulletProj.cs index 8a5405821b..0399e05bd4 100644 --- a/Projectiles/Ranged/HyperiusBulletProj.cs +++ b/Projectiles/Ranged/HyperiusBulletProj.cs @@ -108,7 +108,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int b = 0; b < 3; b++) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, -oldVelocity.RotatedByRandom(0.5f) * 0.7f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.35), 0f, Projectile.owner, 0f, 0f, Main.rand.Next(0, 4 + 1)); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, -oldVelocity.RotatedByRandom(0.5f) * 0.7f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1), 0f, Projectile.owner, 0f, 0f, Main.rand.Next(0, 4 + 1)); } } return true; @@ -130,7 +130,7 @@ namespace CalamityMod.Projectiles.Ranged for (int b = 0; b < 3; b++) { Vector2 velocity = Projectile.velocity.RotatedByRandom(0.5f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity * 0.7f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.15), Projectile.knockBack * 2f, Projectile.owner, 0f, 0f, Main.rand.Next(0, 4 + 1)); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity * 0.7f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1), Projectile.knockBack * 2f, Projectile.owner, 0f, 0f, Main.rand.Next(0, 4 + 1)); } } } diff --git a/Projectiles/Ranged/IcicleArrowProj.cs b/Projectiles/Ranged/IcicleArrowProj.cs index 45dc5b612d..8e49752c80 100644 --- a/Projectiles/Ranged/IcicleArrowProj.cs +++ b/Projectiles/Ranged/IcicleArrowProj.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.extraUpdates = 6; Projectile.timeLeft = 1000; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 15 * Projectile.extraUpdates; + Projectile.localNPCHitCooldown = 15 * Projectile.MaxUpdates; Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } @@ -119,10 +119,10 @@ namespace CalamityMod.Projectiles.Ranged public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { if (falling) - modifiers.SourceDamage *= 1.35f; + modifiers.SourceDamage *= 1.1f; if (Projectile.numHits > 1 && falling) - Projectile.damage = (int)(Projectile.damage * 0.6f); + Projectile.damage = (int)(Projectile.damage * 0.5f); if (Projectile.damage < 1) Projectile.damage = 1; } @@ -149,6 +149,7 @@ namespace CalamityMod.Projectiles.Ranged dust2.noGravity = false; } Projectile.velocity = new Vector2(0, -6.5f).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.75f, 1.1f); + Projectile.tileCollide = false; return false; } else diff --git a/Projectiles/Ranged/KingsbaneHoldout.cs b/Projectiles/Ranged/KingsbaneHoldout.cs index 7d27d3545b..09d7d84584 100644 --- a/Projectiles/Ranged/KingsbaneHoldout.cs +++ b/Projectiles/Ranged/KingsbaneHoldout.cs @@ -99,9 +99,12 @@ namespace CalamityMod.Projectiles.Ranged //recoil Owner.velocity += -Projectile.velocity * fullRevShots * (Main.zenithWorld ? 0.028f : 0.013f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition + Projectile.velocity * 5 + Main.rand.NextVector2Circular(7, 7), shootVelocity.RotatedByRandom(MathHelper.ToRadians(4f)), ModContent.ProjectileType(), (int)(Projectile.damage * 0.9f), Projectile.knockBack, Projectile.owner); - SoundEngine.PlaySound(SoundID.Item40 with { PitchVariance = 0.4f }, Projectile.Center); + SoundStyle fire = new("CalamityMod/Sounds/Item/GunShotSmall"); + if (fullRevShots % 2 == 0) + SoundEngine.PlaySound(fire with { Volume = 0.8f }, Projectile.Center); + //SoundEngine.PlaySound(SoundID.Item40 with { PitchVariance = 0.4f }, Projectile.Center); Owner.channel = true; - //SoundEngine.PlaySound(Kingsbane.AuricFire with { PitchVariance = 0.4f }, Projectile.Center); + fullRevShots--; } } @@ -129,7 +132,8 @@ namespace CalamityMod.Projectiles.Ranged dust3.scale = Main.rand.NextFloat(0.9f, 1.6f); } Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center, shootVelocity.RotatedByRandom(MathHelper.ToRadians(1.5f)), bulletAMMO, Projectile.damage, Projectile.knockBack, Projectile.owner); - SoundEngine.PlaySound(SoundID.Item41 with { Volume = 0.75f }, Projectile.Center); + SoundStyle fire = new("CalamityMod/Sounds/Item/GunShotMid"); + SoundEngine.PlaySound(fire with { Volume = 0.6f }, Projectile.Center); framesBetweenShots = 3; } if (framesBetweenShots > 0) diff --git a/Projectiles/Ranged/MagnaCannonHoldout.cs b/Projectiles/Ranged/MagnaCannonHoldout.cs index 46cd0b8502..ef4ea8c38e 100644 --- a/Projectiles/Ranged/MagnaCannonHoldout.cs +++ b/Projectiles/Ranged/MagnaCannonHoldout.cs @@ -1,67 +1,48 @@ -using System; -using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; using Terraria; using Terraria.Audio; -using Terraria.Localization; +using Terraria.GameContent; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class MagnaCannonHoldout : ModProjectile + public class MagnaCannonHoldout : BaseGunHoldoutProjectile { - // Take the name and texture from the weapon - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public override string Texture => "CalamityMod/Items/Weapons/Ranged/MagnaCannon"; - - public static int FramesPerLoad = 9; - public static int MaxLoadableShots = 20; - public static float BulletSpeed = 12f; - - private Player Owner => Main.player[Projectile.owner]; - public SlotId MagnaChargeSlot; + public override int AssociatedItemID => ModContent.ItemType(); + public override float MaxOffsetLengthFromArm => 20f; + public override float OffsetXUpwards => -5f; + public override float BaseOffsetY => -5f; private ref float CurrentChargingFrames => ref Projectile.ai[0]; private ref float ShotsLoaded => ref Projectile.ai[1]; private ref float ShootTimer => ref Projectile.ai[2]; private bool FullyCharged => CurrentChargingFrames >= MagnaCannon.FullChargeFrames; - public int Time = 0; + public SlotId MagnaChargeSlot; + public static int FramesPerLoad = 9; + public static int MaxLoadableShots = 20; + public static float BulletSpeed = 12f; - public override void SetDefaults() + public override void KillHoldoutLogic() { - Projectile.width = 58; - Projectile.height = 30; - Projectile.friendly = true; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Ranged; - Projectile.ignoreWater = true; + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) + Projectile.Kill(); } - public override void AI() + public override void HoldoutAI() { - Time++; - if (Time == 1) - Projectile.alpha = 255; - else - Projectile.alpha = 0; - - if (Owner.dead) // destroy the holdout if the player dies - { - Projectile.Kill(); - return; - } - - Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); - Vector2 tipPosition = armPosition + Projectile.velocity * Projectile.width * 0.9f; - if (SoundEngine.TryGetActiveSound(MagnaChargeSlot, out var ChargeSound) && ChargeSound.IsPlaying) ChargeSound.Position = Projectile.Center; // Fire if the owner stops channeling or otherwise cannot use the weapon. if (Owner.CantUseHoldout()) { + KeepRefreshingLifetime = false; + if (ShotsLoaded > 0) { // While bullets are remaining, refresh the lifespan; it will not refresh again after bullets run out @@ -75,24 +56,19 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(MagnaCannon.Fire, Projectile.position); Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, shootVelocity.RotatedByRandom(MathHelper.ToRadians(9f)), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * (FullyCharged ? 3 : 1), Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedByRandom(MathHelper.ToRadians(9f)), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * (FullyCharged ? 3 : 1), Projectile.owner); for (int i = 0; i <= 3; i++) { - Dust dust = Dust.NewDustPerfect(tipPosition, 187, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.9f, 1.2f), 0, default, Main.rand.NextFloat(1.5f, 2.3f)); + Dust dust = Dust.NewDustPerfect(GunTipPosition, 187, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.9f, 1.2f), 0, default, Main.rand.NextFloat(1.5f, 2.3f)); dust.noGravity = true; } ShotsLoaded--; - ShootTimer = (FullyCharged ? 4f : 5f); - Projectile.netSpam = 0; - Projectile.netUpdate = true; + ShootTimer = FullyCharged ? 4f : 5f; } } else { - // While channeled, keep refreshing the projectile lifespan - Projectile.timeLeft = 2; - // Loads shots until maxed out if (ShotsLoaded < MaxLoadableShots && CurrentChargingFrames % FramesPerLoad == 0) ShotsLoaded++; @@ -116,13 +92,13 @@ namespace CalamityMod.Projectiles.Ranged { if (!FullyCharged) { - Particle streak = new ManaDrainStreak(Owner, Main.rand.NextFloat(0.06f + (CurrentChargingFrames / 180), 0.08f + (CurrentChargingFrames / 180)), Main.rand.NextVector2CircularEdge(2f, 2f) * Main.rand.NextFloat(0.3f * CurrentChargingFrames, 0.3f * CurrentChargingFrames), 0f, Color.White, Color.Aqua, 7, tipPosition); + Particle streak = new ManaDrainStreak(Owner, Main.rand.NextFloat(0.06f + (CurrentChargingFrames / 180), 0.08f + (CurrentChargingFrames / 180)), Main.rand.NextVector2CircularEdge(2f, 2f) * Main.rand.NextFloat(0.3f * CurrentChargingFrames, 0.3f * CurrentChargingFrames), 0f, Color.White, Color.Aqua, 7, GunTipPosition); GeneralParticleHandler.SpawnParticle(streak); } float orbScale = MathHelper.Clamp(CurrentChargingFrames, 0f, MagnaCannon.FullChargeFrames); - Particle orb = new GenericBloom(tipPosition, Projectile.velocity, Color.DarkBlue, orbScale / 135f, 2); + Particle orb = new GenericBloom(GunTipPosition, Projectile.velocity, Color.DarkBlue, orbScale / 135f, 2); GeneralParticleHandler.SpawnParticle(orb); - Particle orb2 = new GenericBloom(tipPosition, Projectile.velocity, Color.Aqua, orbScale / 200f, 2); + Particle orb2 = new GenericBloom(GunTipPosition, Projectile.velocity, Color.Aqua, orbScale / 200f, 2); GeneralParticleHandler.SpawnParticle(orb2); } @@ -131,49 +107,38 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i < 36; i++) { - Dust chargefull = Dust.NewDustPerfect(tipPosition, 160); + Dust chargefull = Dust.NewDustPerfect(GunTipPosition, 160); chargefull.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * 18f + Owner.velocity; chargefull.scale = Main.rand.NextFloat(1f, 1.5f); chargefull.noGravity = true; } } } - UpdateProjectileHeldVariables(armPosition); - ManipulatePlayerVariables(); } - private void UpdateProjectileHeldVariables(Vector2 armPosition) - { - if (Main.myPlayer == Projectile.owner) - { - float interpolant = Utils.GetLerpValue(5f, 40f, Projectile.Distance(Main.MouseWorld), true); - Vector2 oldVelocity = Projectile.velocity; - Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); - } - Projectile.Center = armPosition + Projectile.velocity * 20; - Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); - Projectile.spriteDirection = Projectile.direction; - - // Rumble (only while channeling) - float rumble = MathHelper.Clamp(CurrentChargingFrames, 0f, MagnaCannon.FullChargeFrames); - if (!Owner.CantUseHoldout()) - Projectile.position += Main.rand.NextVector2Circular(rumble / 43f, rumble / 43f); - } - - private void ManipulatePlayerVariables() - { - Owner.ChangeDir(Projectile.direction); - Owner.heldProj = Projectile.whoAmI; - Owner.itemTime = 2; - Owner.itemAnimation = 2; - Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); - } public override void OnKill(int timeLeft) { if (SoundEngine.TryGetActiveSound(MagnaChargeSlot, out var ChargeSound)) ChargeSound?.Stop(); } - public override bool? CanDamage() => false; + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + if (!Owner.CantUseHoldout()) + { + float rumble = MathHelper.Clamp(CurrentChargingFrames, 0f, MagnaCannon.FullChargeFrames); + drawPosition += Main.rand.NextVector2Circular(rumble / 43f, rumble / 43f); + } + + Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + + return false; + } } } diff --git a/Projectiles/Ranged/NullShot.cs b/Projectiles/Ranged/NullShot.cs index b0b6881f10..2ec483b36b 100644 --- a/Projectiles/Ranged/NullShot.cs +++ b/Projectiles/Ranged/NullShot.cs @@ -1,4 +1,6 @@ -using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.CalPlayer; +using CalamityMod.NPCs; +using CalamityMod.NPCs.NormalNPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -47,40 +49,40 @@ namespace CalamityMod.Projectiles.Ranged { return; } - int nullBuff = Main.rand.Next(7); + + int randAmt = (CalamityPlayer.areThereAnyDamnBosses || CalamityLists.AquaticScourgeIDs.Contains(target.type)) ? 6 : 8; + int nullBuff = Main.rand.Next(randAmt); if (!target.boss) { - if (nullBuff == 0) + switch (nullBuff) { - target.scale *= 2f; - } - else if (nullBuff == 1) - { - target.scale *= 0.5f; - } - else if (nullBuff == 2 && target.type != ModContent.NPCType()) - { - target.damage += 10; - } - else if (nullBuff == 3) - { - target.damage -= 10; - } - else if (nullBuff == 4) - { - target.knockBackResist = 0f; - } - else if (nullBuff == 5) - { - target.knockBackResist = 1f; - } - else if (nullBuff == 6) - { - target.defense += 5; - } - else - { - target.defense -= 5; + case 0: + if (target.type != ModContent.NPCType()) + target.damage += 10; + break; + case 1: + target.damage -= 10; + break; + case 2: + target.knockBackResist = 0f; + break; + case 3: + target.knockBackResist = 1f; + break; + case 4: + target.defense += 5; + break; + case 5: + target.defense -= 5; + break; + case 6: + target.scale *= 2f; + break; + case 7: + target.scale *= 0.5f; + break; + default: + break; } } } diff --git a/Projectiles/Ranged/NullShot2.cs b/Projectiles/Ranged/NullShot2.cs index 7342465df3..d24185b9d0 100644 --- a/Projectiles/Ranged/NullShot2.cs +++ b/Projectiles/Ranged/NullShot2.cs @@ -1,4 +1,5 @@ -using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.CalPlayer; +using CalamityMod.NPCs.NormalNPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -48,48 +49,46 @@ namespace CalamityMod.Projectiles.Ranged { return; } - int nullBuff = Main.rand.Next(10); + + int randAmt = (CalamityPlayer.areThereAnyDamnBosses || CalamityLists.AquaticScourgeIDs.Contains(target.type)) ? 8 : 10; + int nullBuff = Main.rand.Next(randAmt); if (!target.boss) { - if (nullBuff == 0) + switch (nullBuff) { - target.scale *= 5f; - } - else if (nullBuff == 1) - { - target.scale *= 0.1f; - } - else if (nullBuff == 2 && target.type != ModContent.NPCType()) - { - target.damage += 20; - } - else if (nullBuff == 3) - { - target.damage -= 20; - } - else if (nullBuff == 4) - { - target.knockBackResist = 0f; - } - else if (nullBuff == 5) - { - target.knockBackResist = 1f; - } - else if (nullBuff == 6) - { - target.defense += 10; - } - else if (nullBuff == 7) - { - target.defense -= 10; - } - else if (nullBuff == 8) - { - target.velocity.Y = Main.rand.NextBool() ? 30f : -30f; - } - else - { - target.velocity.X = Main.rand.NextBool() ? 30f : -30f; + case 0: + if (target.type != ModContent.NPCType()) + target.damage += 20; + break; + case 1: + target.damage -= 20; + break; + case 2: + target.knockBackResist = 0f; + break; + case 3: + target.knockBackResist = 1f; + break; + case 4: + target.defense += 10; + break; + case 5: + target.defense -= 10; + break; + case 6: + target.velocity.Y = Main.rand.NextBool() ? 30f : -30f; + break; + case 7: + target.velocity.X = Main.rand.NextBool() ? 30f : -30f; + break; + case 8: + target.scale *= 5f; + break; + case 9: + target.scale *= 0.1f; + break; + default: + break; } } } diff --git a/Projectiles/Ranged/OpalStrikerHoldout.cs b/Projectiles/Ranged/OpalStrikerHoldout.cs index afc3cb7b6d..7a42eabdbf 100644 --- a/Projectiles/Ranged/OpalStrikerHoldout.cs +++ b/Projectiles/Ranged/OpalStrikerHoldout.cs @@ -1,92 +1,71 @@ -using System; -using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; using Terraria; using Terraria.Audio; -using Terraria.Localization; +using Terraria.GameContent; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class OpalStrikerHoldout : ModProjectile + public class OpalStrikerHoldout : BaseGunHoldoutProjectile { - // Take the name and texture from the weapon - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public override string Texture => "CalamityMod/Items/Weapons/Ranged/OpalStriker"; + public override int AssociatedItemID => ModContent.ItemType(); + public override float MaxOffsetLengthFromArm => 15f; + public override float OffsetXUpwards => -5f; + public override float BaseOffsetY => -5f; + private ref float CurrentChargingFrames => ref Projectile.ai[0]; + private bool FullyCharged => CurrentChargingFrames >= OpalStriker.FullChargeFrames; + public SlotId OpalChargeSlot; public static float ChargedDamageMult = 5f; public static float ChargedKBMult = 3f; public static float BulletSpeed = 12f; - private Player Owner => Main.player[Projectile.owner]; - public SlotId OpalChargeSlot; - - private ref float CurrentChargingFrames => ref Projectile.ai[0]; - private bool FullyCharged => CurrentChargingFrames >= OpalStriker.FullChargeFrames; - public int Time = 0; - - public override void SetDefaults() + public override void KillHoldoutLogic() { - Projectile.width = 46; - Projectile.height = 30; - Projectile.friendly = true; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Ranged; - Projectile.ignoreWater = true; + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) + Projectile.Kill(); } - public override void AI() + public override void HoldoutAI() { - Time++; - if (Time == 1) - Projectile.alpha = 255; - else - Projectile.alpha = 0; - - if (Owner.dead) // destroy the holdout if the player dies - { - Projectile.Kill(); - return; - } - - Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); - Vector2 tipPosition = (armPosition + Projectile.velocity * Projectile.width * 0.85f) + (Projectile.velocity * 4).RotatedBy(-0.3f * Projectile.direction); - if (SoundEngine.TryGetActiveSound(OpalChargeSlot, out var ChargeSound) && ChargeSound.IsPlaying) ChargeSound.Position = Projectile.Center; // Fire if the owner stops channeling or otherwise cannot use the weapon. if (Owner.CantUseHoldout()) { + KeepRefreshingLifetime = false; + if (Projectile.ai[1] != 1f) { + Projectile.timeLeft = OpalStriker.AftershotCooldownFrames; + ChargeSound?.Stop(); SoundEngine.PlaySound(FullyCharged ? OpalStriker.ChargedFire : OpalStriker.Fire, Projectile.Center); Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; if (FullyCharged) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, shootVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * ChargedDamageMult), Projectile.knockBack * ChargedKBMult, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * ChargedDamageMult), Projectile.knockBack * ChargedKBMult, Projectile.owner); for (int i = 0; i <= 10; i++) { - Dust dust = Dust.NewDustPerfect(tipPosition, 162, shootVelocity.RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(0.8f, 1.4f), 0, default, Main.rand.NextFloat(1.5f, 2.3f)); + Dust dust = Dust.NewDustPerfect(GunTipPosition, 162, shootVelocity.RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(0.8f, 1.4f), 0, default, Main.rand.NextFloat(1.5f, 2.3f)); dust.noGravity = true; } } else - Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, shootVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); Projectile.ai[1] = 1f; - Projectile.netSpam = 0; - Projectile.netUpdate = true; } } else { - // While channeled, keep refreshing the projectile lifespan to the amount when attacking - Projectile.timeLeft = OpalStriker.AftershotCooldownFrames; CurrentChargingFrames++; // Sounds @@ -103,14 +82,14 @@ namespace CalamityMod.Projectiles.Ranged { if (!FullyCharged) { - Particle streak = new ManaDrainStreak(Owner, Main.rand.NextFloat(0.06f + (CurrentChargingFrames / 180), 0.08f + (CurrentChargingFrames / 180)), Main.rand.NextVector2CircularEdge(2f, 2f) * Main.rand.NextFloat(0.3f * CurrentChargingFrames, 0.3f * CurrentChargingFrames), 0f, Color.Gold, Color.Orange, 7, tipPosition); + Particle streak = new ManaDrainStreak(Owner, Main.rand.NextFloat(0.06f + (CurrentChargingFrames / 180), 0.08f + (CurrentChargingFrames / 180)), Main.rand.NextVector2CircularEdge(2f, 2f) * Main.rand.NextFloat(0.3f * CurrentChargingFrames, 0.3f * CurrentChargingFrames), 0f, Color.Gold, Color.Orange, 7, GunTipPosition); GeneralParticleHandler.SpawnParticle(streak); } float orbScale = MathHelper.Clamp(CurrentChargingFrames, 0f, OpalStriker.FullChargeFrames); - Particle orb = new GenericBloom(tipPosition, Projectile.velocity, Color.OrangeRed, orbScale / 135f, 2); + Particle orb = new GenericBloom(GunTipPosition, Projectile.velocity, Color.OrangeRed, orbScale / 135f, 2); GeneralParticleHandler.SpawnParticle(orb); - Particle orb2 = new GenericBloom(tipPosition, Projectile.velocity, Color.Coral, orbScale / 200f, 2); + Particle orb2 = new GenericBloom(GunTipPosition, Projectile.velocity, Color.Coral, orbScale / 200f, 2); GeneralParticleHandler.SpawnParticle(orb2); } @@ -119,50 +98,38 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i < 36; i++) { - Dust chargefull = Dust.NewDustPerfect(tipPosition, 162); + Dust chargefull = Dust.NewDustPerfect(GunTipPosition, 162); chargefull.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * 13f + Owner.velocity; chargefull.scale = Main.rand.NextFloat(2f, 2.5f); chargefull.noGravity = true; } } } - - UpdateProjectileHeldVariables(armPosition); - ManipulatePlayerVariables(); } - private void UpdateProjectileHeldVariables(Vector2 armPosition) - { - if (Main.myPlayer == Projectile.owner) - { - float interpolant = Utils.GetLerpValue(5f, 35f, Projectile.Distance(Main.MouseWorld), true); - Vector2 oldVelocity = Projectile.velocity; - Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); - } - Projectile.Center = armPosition + Projectile.velocity * 15 + new Vector2(0, 3); - Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); - Projectile.spriteDirection = Projectile.direction; - - // Rumble (only while channeling) - float rumble = MathHelper.Clamp(CurrentChargingFrames, 0f, OpalStriker.FullChargeFrames); - if (!Owner.CantUseHoldout()) - Projectile.position += Main.rand.NextVector2Circular(rumble / 30f, rumble / 30f); - } - - private void ManipulatePlayerVariables() - { - Owner.ChangeDir(Projectile.direction); - Owner.heldProj = Projectile.whoAmI; - Owner.itemTime = 2; - Owner.itemAnimation = 2; - Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); - } public override void OnKill(int timeLeft) { if (SoundEngine.TryGetActiveSound(OpalChargeSlot, out var ChargeSound)) ChargeSound?.Stop(); } - public override bool? CanDamage() => false; + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + if (!Owner.CantUseHoldout()) + { + float rumble = MathHelper.Clamp(CurrentChargingFrames, 0f, OpalStriker.FullChargeFrames); + drawPosition += Main.rand.NextVector2Circular(rumble / 30f, rumble / 30f); + } + + Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + + return false; + } } } diff --git a/Projectiles/Ranged/RainbowBlast.cs b/Projectiles/Ranged/RainbowBlast.cs deleted file mode 100644 index 4fe0111b80..0000000000 --- a/Projectiles/Ranged/RainbowBlast.cs +++ /dev/null @@ -1,64 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Ranged -{ - public class RainbowBlast : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10; - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 10; - Projectile.height = 10; - Projectile.friendly = true; - Projectile.penetrate = 1; - Projectile.extraUpdates = 1; - Projectile.DamageType = DamageClass.Ranged; - Projectile.timeLeft = 300; - } - - public override void AI() - { - //Rotation - Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); - Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi); - - Lighting.AddLight(Projectile.Center, new Vector3(Main.DiscoR, Main.DiscoG, Main.DiscoB) * (1.5f / 255)); - - Projectile.localAI[0]++; - if (Projectile.localAI[0] > 5f) - { - Vector2 dspeed = -Projectile.velocity * 0.5f; - int rainbowDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowTorch, dspeed.X, dspeed.Y, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.1f); - Main.dust[rainbowDust].noGravity = true; - Main.dust[rainbowDust].velocity = dspeed; - } - - CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 12f, 20f); - } - - public override Color? GetAlpha(Color lightColor) - { - Color color = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); - return color; - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); - return false; - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 60); - } - } -} diff --git a/Projectiles/Ranged/RainbowBlast.png b/Projectiles/Ranged/RainbowBlast.png deleted file mode 100644 index 80909384b5..0000000000 Binary files a/Projectiles/Ranged/RainbowBlast.png and /dev/null differ diff --git a/Projectiles/Ranged/RealmRavagerBullet.cs b/Projectiles/Ranged/RealmRavagerBullet.cs index f0dc66f4ef..64d52761a0 100644 --- a/Projectiles/Ranged/RealmRavagerBullet.cs +++ b/Projectiles/Ranged/RealmRavagerBullet.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; - Projectile.damage /= 2; + Projectile.damage /= 3; Projectile.Damage(); } } diff --git a/Projectiles/Ranged/ScorpioHoldout.cs b/Projectiles/Ranged/ScorpioHoldout.cs index c18f942a5d..36669dd5f8 100644 --- a/Projectiles/Ranged/ScorpioHoldout.cs +++ b/Projectiles/Ranged/ScorpioHoldout.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Ranged // It'll carry over to the projectiles that it shoots. public static int DustEffectsID { get; set; } public static Color EffectsColor { get; set; } - public static Color StaticEffectsColor = Color.Turquoise; + public static Color StaticEffectsColor { get; set; } = Color.Turquoise; public override void HoldoutAI() { @@ -58,7 +58,6 @@ namespace CalamityMod.Projectiles.Ranged { ShootingTimer = 0f; TimerBetweenBursts = 0f; - NetUpdate(); } } @@ -155,8 +154,6 @@ namespace CalamityMod.Projectiles.Ranged rocketType, projSpeed); - NetUpdate(); - // Inside here go all the things that dedicated servers shouldn't spend resources on. // Like visuals and sounds. if (Main.dedServ) @@ -195,13 +192,6 @@ namespace CalamityMod.Projectiles.Ranged GeneralParticleHandler.SpawnParticle(shootPulse); } - public void NetUpdate() - { - Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; - } - public override bool PreDraw(ref Color lightColor) { Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; diff --git a/Projectiles/Ranged/ShadeFire.cs b/Projectiles/Ranged/ShadeFire.cs index 0bb282dd6b..805fe68972 100644 --- a/Projectiles/Ranged/ShadeFire.cs +++ b/Projectiles/Ranged/ShadeFire.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.MaxUpdates = 3; Projectile.timeLeft = Lifetime; // 20 effectively Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 15; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Ranged/SproutingArrowMain.cs b/Projectiles/Ranged/SproutingArrowMain.cs index 93fbb6180f..c67de8f3a6 100644 --- a/Projectiles/Ranged/SproutingArrowMain.cs +++ b/Projectiles/Ranged/SproutingArrowMain.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Ranged { if (Projectile.ai[0] == 0) { - Projectile.damage = (int)(Projectile.damage * 0.18f); + Projectile.damage = (int)(Projectile.damage * 0.3f); Projectile.velocity *= 0.25f; LineParticle spark = new LineParticle(Projectile.Center + Projectile.velocity * 4, Projectile.velocity * 4.95f, false, 9, 2.4f, Color.LimeGreen); GeneralParticleHandler.SpawnParticle(spark); @@ -51,8 +51,8 @@ namespace CalamityMod.Projectiles.Ranged Vector2 vel1 = (Projectile.velocity * 0.4f).RotatedBy(Main.rand.NextFloat(0.015f, 0.04f)); Vector2 vel2 = (Projectile.velocity * 0.4f).RotatedBy(Main.rand.NextFloat(-0.015f, -0.04f)); - int split1 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel1 * Main.rand.NextFloat(0.95f, 1.05f), ModContent.ProjectileType(), (int)(Projectile.damage * 3), 0f, Projectile.owner, 0f, hitDirect ? 1f : 0f); - int split2 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel2 * Main.rand.NextFloat(0.95f, 1.05f), ModContent.ProjectileType(), (int)(Projectile.damage * 3), 0f, Projectile.owner, 0f, hitDirect ? 1f : 0f); + int split1 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel1 * Main.rand.NextFloat(0.95f, 1.05f), ModContent.ProjectileType(), (int)(Projectile.damage * 2), 0f, Projectile.owner, 0f, hitDirect ? 1f : 0f); + int split2 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel2 * Main.rand.NextFloat(0.95f, 1.05f), ModContent.ProjectileType(), (int)(Projectile.damage * 2), 0f, Projectile.owner, 0f, hitDirect ? 1f : 0f); if (Projectile.Calamity().allProjectilesHome) // Allows the split arrows to home when using Arterial Assault as well { Main.projectile[split1].Calamity().allProjectilesHome = true; diff --git a/Projectiles/Ranged/SuperradiantBolt.cs b/Projectiles/Ranged/SuperradiantBolt.cs new file mode 100644 index 0000000000..00e2a11ccd --- /dev/null +++ b/Projectiles/Ranged/SuperradiantBolt.cs @@ -0,0 +1,95 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SuperradiantBolt : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + + public ref float Time => ref Projectile.ai[0]; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 20; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 22; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = 1; + Projectile.timeLeft = 120; + Projectile.tileCollide = false; + Projectile.scale = 0.85f; + } + + public override void AI() + { + Time++; + + // Solid homing + NPC potentialTarget = Projectile.Center.ClosestNPCAt(480f); + if (potentialTarget != null && Time >= 15f) + { + Vector2 idealVelocity = Projectile.SafeDirectionTo(potentialTarget.Center) * 24f; + Projectile.velocity = (Projectile.velocity * 29f + idealVelocity) / 30f; + Projectile.velocity = Projectile.velocity.MoveTowards(idealVelocity, 3f); + } + else if (Time >= 30f) + { + // Projectile decays a lot faster if there's no enemy in sight + Projectile.timeLeft -= 2; + } + + Projectile.rotation = Projectile.velocity.ToRotation(); + + // Emit light + DelegateMethods.v3_1 = Color.Lerp(Color.Lime, Color.White, 0.55f).ToVector3() * 0.35f; + Utils.PlotTileLine(Projectile.Center - Projectile.velocity * 0.5f, Projectile.Center + Projectile.velocity * 0.5f, 16f, DelegateMethods.CastLightOpen); + } + + public override bool? CanDamage() => Time >= 15f; + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 45); + + internal float WidthFunction(float completionRatio) => (1f - completionRatio) * Projectile.scale * 20f; + internal Color ColorFunction(float completionRatio) + { + float hue = 0.4f + 0.2f * completionRatio * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f); + Color trailColor = Main.hslToRgb(hue, 1f, 0.8f); + return trailColor * Projectile.Opacity; + } + + public override bool PreDraw(ref Color lightColor) + { + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 20); + Texture2D glow = TextureAssets.Projectile[Projectile.type].Value; + Main.EntitySpriteDraw(glow, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, glow.Size() * 0.5f, Projectile.scale, SpriteEffects.None); + return false; + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 2; i++) + { + Vector2 sparkVel = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(MathHelper.ToRadians(24f)) * Main.rand.NextFloat(6f, 10f); + Color color = Main.hslToRgb(Main.rand.NextFloat(0.3f, 0.5f), 1f, 0.8f); + SparkParticle spark = new(Projectile.Center, sparkVel, false, 30, 1.3f, color); + GeneralParticleHandler.SpawnParticle(spark); + } + } + } +} diff --git a/Projectiles/Ranged/SuperradiantBolt.png b/Projectiles/Ranged/SuperradiantBolt.png new file mode 100644 index 0000000000..77ecaadda2 Binary files /dev/null and b/Projectiles/Ranged/SuperradiantBolt.png differ diff --git a/Projectiles/Ranged/SuperradiantSaw.cs b/Projectiles/Ranged/SuperradiantSaw.cs new file mode 100644 index 0000000000..023582e299 --- /dev/null +++ b/Projectiles/Ranged/SuperradiantSaw.cs @@ -0,0 +1,387 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Cooldowns; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SuperradiantSaw : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public static readonly SoundStyle TileCollideGFB = new("CalamityMod/Sounds/Custom/MetalPipeFalling"); + + public ref float SawLevel => ref Projectile.ai[0]; + public ref float Time => ref Projectile.ai[1]; + public ref float PierceBeforeReturn => ref Projectile.ai[2]; + + // Hitstop timer. + public int HitstopTimer = 0; + + // Controls if the saw is returning to the player. + public bool Returning = false; + public int ReturnTimer = 0; + public const int ReturnDelay = 90; + public const int MaxBoltPairs = 7; // No more than 7 pairs per saw + + // Whether the saw is empowered by right click. + public bool Empowered = false; + + public Particle SmallSlashSmear; + public Particle LargeSlashSmear; + public static Asset SawOutline; + public static Asset SmallSlash; + public static Asset LargeSlash; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 46; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.timeLeft = 600; + Projectile.penetrate = -1; // Saws only pierce a certain number of times before returning, and don't deal direct damage while returning + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; + } + + public override void AI() + { + // Deadshot Brooch makes me die inside + if (Projectile.MaxUpdates > 1) + Projectile.MaxUpdates = 1; + + // Timer and rotation + Time++; + Projectile.rotation += MathHelper.ToRadians(6f + 18f * SawLevel); + + // Hitstop timer + if (HitstopTimer > 0) + { + HitstopTimer--; + if (HitstopTimer == 0) + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * SuperradiantSlaughterer.ShootSpeed; + } + + // Control the saw being empowered or not + Player Owner = Main.player[Projectile.owner]; + Empowered = Owner.HasCooldown(SuperradiantSawBoost.ID); + + // While empowered, the saws will slightly home in on the cursor + if (Empowered && !Returning && Time > 30) + { + float homingTurnSpeed = 0.2f; + Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.SafeDirectionTo(Main.MouseWorld).ToRotation(), homingTurnSpeed).ToRotationVector2() * SuperradiantSlaughterer.ShootSpeed; + } + + // Saws automatically return 2 seconds after hitting an enemy + if (ReturnTimer > 0 && ReturnTimer < ReturnDelay) + { + ReturnTimer++; + if (ReturnTimer == ReturnDelay) + Returning = true; + } + + if (Returning) + { + Projectile.tileCollide = false; + if (ReturnTimer < ReturnDelay) + ReturnTimer = ReturnDelay; + + ReturnTimer++; + if (ReturnTimer < ReturnDelay + 30) + Projectile.velocity *= 0.95f; + else + { + // Spawns a burst of homing bolts when it starts returning, based on how many tiles and enemies it hit + if (ReturnTimer == ReturnDelay + 30) + { + int boltCount = Math.Min(Projectile.numHits, MaxBoltPairs) * 2; + for (int b = 0; b < boltCount; b++) + { + Vector2 randBoltVelocity = Main.rand.NextVector2Unit() * 9f; + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, randBoltVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0f, Main.myPlayer); + } + + // Extra burst of sparks for cool points + float sparkCount = 6f + 5f * SawLevel; + for (float i = 0f; i < sparkCount; i++) + { + Vector2 velocity = Main.rand.NextVector2Unit() * (12f + 10f * SawLevel); + float sparkScale = 1f + 0.25f * SawLevel; // Bloom effect is double the spark's size + Particle sparkle = new CritSpark(Projectile.Center, velocity, Color.White, Color.Lime, sparkScale, 30, 0.1f, sparkScale, Main.rand.NextFloat(0f, 0.01f)); + GeneralParticleHandler.SpawnParticle(sparkle); + } + } + + // Continuously spawn homing bolts as it returns while empowered + if (ReturnTimer % 9 == 0 && Empowered) + { + Vector2 randVelocity = -Projectile.velocity.RotatedByRandom(MathHelper.Pi / 3f) * 0.5f; + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, randVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0f, Main.myPlayer); + } + + float returnSpeed = (SuperradiantSlaughterer.ShootSpeed * 0.6f) + (0.05f * (ReturnTimer - 120)); + Vector2 ownerDist = Owner.Center - Projectile.Center; + if (ownerDist.Length() > 3000f) + Projectile.Kill(); + + ownerDist.Normalize(); + ownerDist *= returnSpeed; + + // Home back in on the player; accelerates over time + if (Projectile.velocity.X < ownerDist.X) + Projectile.velocity.X = ownerDist.X; + else if (Projectile.velocity.X > ownerDist.X) + Projectile.velocity.X = ownerDist.X; + + if (Projectile.velocity.Y < ownerDist.Y) + Projectile.velocity.Y = ownerDist.Y; + else if (Projectile.velocity.Y > ownerDist.Y) + Projectile.velocity.Y = ownerDist.Y; + + // Delete the saw if it touches its owner + if (Main.myPlayer == Projectile.owner) + { + if (Projectile.Hitbox.Intersects(Owner.Hitbox)) + Projectile.Kill(); + } + } + } + else + { + // A bit of dust while travelling + if (Main.rand.NextBool()) + { + Color dustColor = Empowered ? Main.DiscoColor : new Color(Main.DiscoR, 255, 60); + Dust trail = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowTorch, Projectile.velocity.X * 0.05f, Projectile.velocity.Y * 0.05f, 150, dustColor, 1.2f); + trail.noGravity = true; + } + } + + // Rainbow smear particles which follow the path of the slashes + if (Empowered) + { + if (SawLevel >= 2f) + { + if (LargeSlashSmear == null) + { + LargeSlashSmear = new CircularSmearVFX(Projectile.Center, Color.Black, Time * -Projectile.rotation, 1.35f); + GeneralParticleHandler.SpawnParticle(LargeSlashSmear); + } + else + { + LargeSlashSmear.Rotation = -Projectile.rotation; + LargeSlashSmear.Time = 0; + LargeSlashSmear.Position = Projectile.Center; + LargeSlashSmear.Scale = 1.35f; + LargeSlashSmear.Color = Main.hslToRgb(0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f), 1f, 0.6f) * 0.8f; + } + } + if (SawLevel >= 1f) + { + if (SmallSlashSmear == null) + { + SmallSlashSmear = new CircularSmearVFX(Projectile.Center, Color.Black, Projectile.rotation, 0.8f); + GeneralParticleHandler.SpawnParticle(SmallSlashSmear); + } + else + { + SmallSlashSmear.Rotation = Projectile.rotation; + SmallSlashSmear.Time = 0; + SmallSlashSmear.Position = Projectile.Center; + SmallSlashSmear.Scale = 0.8f; + SmallSlashSmear.Color = Main.hslToRgb(0.5f + 0.5f * MathF.Cos(Main.GlobalTimeWrappedHourly * 5f), 1f, 0.6f) * 0.6f; + } + } + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + int sparkCount = 6 + 5 * (int)SawLevel; + for (int s = 0; s < sparkCount; s++) + { + Vector2 sparkVelocity = new Vector2(); + if (Projectile.velocity.X != oldVelocity.X && oldVelocity.X < 0) + sparkVelocity = Vector2.UnitX * 6.5f; + else if (Projectile.velocity.X != oldVelocity.X && oldVelocity.X >= 0) + sparkVelocity = Vector2.UnitX * -6.5f; + else if (Projectile.velocity.Y != oldVelocity.Y && oldVelocity.Y < 0) + sparkVelocity = Vector2.UnitY * 6.5f; + else if (Projectile.velocity.Y != oldVelocity.Y && oldVelocity.Y >= 0) + sparkVelocity = Vector2.UnitY * -6.5f; + + Vector2 sparkLocation = sparkVelocity.X > 0f ? Projectile.Left : (sparkVelocity.X < 0f ? Projectile.Right : (sparkVelocity.Y > 0f ? Projectile.Top : Projectile.Bottom)); + sparkVelocity = sparkVelocity.RotatedByRandom(MathHelper.PiOver2) * (Main.rand.NextFloat(0.8f, 1.2f) + (Main.rand.NextFloat(0.2f, 0.6f) * SawLevel)); + float scale = Main.rand.NextFloat(0.5f, 0.8f) + Main.rand.NextFloat(0.2f, 0.6f) * SawLevel; + Particle collisionSparks = new AltLineParticle(sparkLocation, sparkVelocity, false, 30, scale, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB)); + GeneralParticleHandler.SpawnParticle(collisionSparks); + } + + SoundEngine.PlaySound(Main.zenithWorld ? TileCollideGFB : SoundID.Item178 with { Pitch = 0.1f * Projectile.numHits }, Projectile.Center); // Placeholder sound + if (Projectile.velocity.X != oldVelocity.X) + Projectile.velocity.X = -oldVelocity.X; + if (Projectile.velocity.Y != oldVelocity.Y) + Projectile.velocity.Y = -oldVelocity.Y; + + if (PierceBeforeReturn > 0) + { + PierceBeforeReturn--; + Projectile.numHits++; + if (PierceBeforeReturn <= 0) + Returning = true; + } + + return false; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 90); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/SwiftSlice") with { Pitch = 0.1f * Projectile.numHits }, Projectile.Center); + + // SUPER COLORFUL PARTICLE EFFECTS YEAH + int onHitSparkAmount = 7 + 10 * (int)SawLevel; + for (int s = 0; s < onHitSparkAmount; s++) + { + Vector2 sparkVel = Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * (Main.rand.NextFloat(0.4f, 0.8f) + (Main.rand.NextFloat(0.4f, 0.6f) * SawLevel)); + float sparkSize = 0.4f + Main.rand.NextFloat(0.3f, 0.6f) * SawLevel; + Color sparkColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.8f); + + Particle sparked = new AltLineParticle(target.Center, sparkVel, false, 30, sparkSize, sparkColor); + GeneralParticleHandler.SpawnParticle(sparked); + } + for (int sq = 0; sq < 7; sq++) + { + Vector2 squareVel = Main.rand.NextVector2CircularEdge(1f, 1f)* (Main.rand.NextFloat(10f, 16f) + 5f * SawLevel); + float squareSize = 1.6f + Main.rand.NextFloat(1f, 1.6f) * SawLevel; + Color squareColor = Main.hslToRgb(Main.rand.NextFloat(), 0.6f, 0.8f); + + Particle squared = new SquareParticle(target.Center, squareVel, true, 30, squareSize, squareColor); + GeneralParticleHandler.SpawnParticle(squared); + } + + // Hitstop effect if the saw is not returning + if (!Returning && HitstopTimer == 0) + { + HitstopTimer = 5; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) / SuperradiantSlaughterer.ShootSpeed; + } + + if (Projectile.numHits < 1) + ReturnTimer = 1; + + if (PierceBeforeReturn > 0) + { + PierceBeforeReturn--; + if (PierceBeforeReturn <= 0) + Returning = true; + } + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + // The saw deals less damage while returning, to prevent its damage being too crazy + if (PierceBeforeReturn <= 0) + modifiers.SourceDamage *= 0.33f; + } + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/CeramicImpact", 2), Projectile.Center); + } + + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + if (SawLevel >= 2f) + hitbox.Inflate(72, 72); + else if (SawLevel >= 1f) + hitbox.Inflate(32, 32); + } + + public override bool PreDraw(ref Color lightColor) + { + LargeSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawLargeSlash"); + Texture2D largeSlashTexture = LargeSlash.Value; + SmallSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawSmallSlash"); + Texture2D smallSlashTexture = SmallSlash.Value; + Color slashColor = new Color(200, 200, 200, 100); + + if (SawLevel >= 2f) + { + Main.EntitySpriteDraw(largeSlashTexture, Projectile.Center - Main.screenPosition, null, slashColor, -Projectile.rotation, largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time % 4 == 0) + { + Vector2 randomParticleOffset = new Vector2(Main.rand.NextFloat(-Projectile.width * 1.75f, Projectile.width * 1.75f), Main.rand.NextFloat(-Projectile.width * 1.75f, Projectile.width * 1.75f)); + float randomParticleScale = Main.rand.NextFloat(0.65f, 0.95f); + Color bloomColor = Color.Lerp(new Color(29, 120, 30), new Color(56, 255, 59), MathF.Abs(MathF.Sin(Time))); + Particle bloomCircle = new BloomParticle(Projectile.Center + randomParticleOffset, Projectile.velocity, Main.rand.NextBool() ? Color.White : bloomColor, randomParticleScale, randomParticleScale, 4, false); + GeneralParticleHandler.SpawnParticle(bloomCircle); + } + } + if (SawLevel >= 1f) + { + Main.EntitySpriteDraw(smallSlashTexture, Projectile.Center - Main.screenPosition, null, slashColor, Projectile.rotation, smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time % 4 == 0) + { + Vector2 randomParticleOffset = new Vector2(Main.rand.NextFloat(-Projectile.width, Projectile.width), Main.rand.NextFloat(-Projectile.width, Projectile.width)); + float randomParticleScale = Main.rand.NextFloat(0.35f, 0.65f); + Color bloomColor = Color.Lerp(new Color(29, 120, 30), new Color(56, 255, 59), MathF.Abs(MathF.Cos(Time))); + Particle bloomCircle = new BloomParticle(Projectile.Center + randomParticleOffset, Projectile.velocity, Main.rand.NextBool() ? Color.White : bloomColor, randomParticleScale, randomParticleScale, 4, false); + GeneralParticleHandler.SpawnParticle(bloomCircle); + } + } + + // Draw the saw itself at full brightness + Texture2D buzzsawTexture = TextureAssets.Projectile[Projectile.type].Value; + Main.EntitySpriteDraw(buzzsawTexture, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, buzzsawTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Empowered) // Rainbow outline while empowered + { + SawOutline ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawOutline"); + Texture2D outline = SawOutline.Value; + Main.EntitySpriteDraw(outline, Projectile.Center - Main.screenPosition, null, Main.DiscoColor, Projectile.rotation, outline.Size() * 0.5f, 1f, SpriteEffects.None); + } + + if (!CalamityConfig.Instance.Afterimages) + return false; + + // Special afterimage drawing to include the slashes + for (int i = 1; i < Projectile.oldPos.Length; i++) + { + float afterimageRot = Projectile.oldRot[i]; + + Vector2 drawPos = Projectile.oldPos[i] + buzzsawTexture.Size() * 0.5f - Main.screenPosition; + float intensity = MathHelper.Lerp(0.1f, 0.6f, 1f - i / (float)Projectile.oldPos.Length); + + Main.EntitySpriteDraw(buzzsawTexture, drawPos, null, lightColor * intensity, afterimageRot, buzzsawTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (SawLevel >= 2f) + Main.EntitySpriteDraw(largeSlashTexture, drawPos, null, slashColor * intensity, -afterimageRot, largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + if (SawLevel >= 1f) + Main.EntitySpriteDraw(smallSlashTexture, drawPos, null, slashColor * intensity, afterimageRot, smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + } + return false; + } + } +} diff --git a/Projectiles/Ranged/SuperradiantSaw.png b/Projectiles/Ranged/SuperradiantSaw.png new file mode 100644 index 0000000000..319c5357b2 Binary files /dev/null and b/Projectiles/Ranged/SuperradiantSaw.png differ diff --git a/Projectiles/Ranged/SuperradiantSawLargeSlash.png b/Projectiles/Ranged/SuperradiantSawLargeSlash.png new file mode 100644 index 0000000000..37ebc6a896 Binary files /dev/null and b/Projectiles/Ranged/SuperradiantSawLargeSlash.png differ diff --git a/Projectiles/Ranged/SuperradiantSawLingering.cs b/Projectiles/Ranged/SuperradiantSawLingering.cs new file mode 100644 index 0000000000..e576590ff9 --- /dev/null +++ b/Projectiles/Ranged/SuperradiantSawLingering.cs @@ -0,0 +1,201 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SuperradiantSawLingering : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/Ranged/SuperradiantSaw"; + + public ref float Time => ref Projectile.ai[1]; + + public Particle SmallSlashSmear; + public Particle LargeSlashSmear; + public static Asset SawOutline; + public static Asset SmallSlash; + public static Asset LargeSlash; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + public override void SetDefaults() + { + Projectile.width = Projectile.height = 46; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.timeLeft = 270; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; + } + + public override void AI() + { + // dies from cringe (Deadshot Brooch moment) + if (Projectile.MaxUpdates > 1) + Projectile.MaxUpdates = 1; + + // Timer and rotation + Time++; + Projectile.rotation += MathHelper.ToRadians(42f); + + // Make it lose velocity as it travels + Projectile.velocity *= 0.955f; + + // Continously spawn homing bolts and small saws + if (Time % 12 == 0 && Time > 30) + { + Vector2 randVelocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(7.5f, 9f); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, randVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), 0f, Main.myPlayer); + } + + // Fade out at the end of its lifetime + if (Projectile.timeLeft <= 30) + { + Projectile.alpha += 8; + if (Projectile.alpha > 255) + Projectile.Kill(); + } + + // Rainbow smear particles which follow the path of the slashes + if (LargeSlashSmear == null) + { + LargeSlashSmear = new CircularSmearVFX(Projectile.Center, Color.Black, Time * -Projectile.rotation, 1.35f); + GeneralParticleHandler.SpawnParticle(LargeSlashSmear); + } + else + { + LargeSlashSmear.Rotation = -Projectile.rotation; + LargeSlashSmear.Time = 0; + LargeSlashSmear.Position = Projectile.Center; + LargeSlashSmear.Scale = 1.35f; + LargeSlashSmear.Color = Main.hslToRgb(0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f), 1f, 0.6f) * 0.8f * Projectile.Opacity; + } + if (SmallSlashSmear == null) + { + SmallSlashSmear = new CircularSmearVFX(Projectile.Center, Color.Black, Projectile.rotation, 0.8f); + GeneralParticleHandler.SpawnParticle(SmallSlashSmear); + } + else + { + SmallSlashSmear.Rotation = Projectile.rotation; + SmallSlashSmear.Time = 0; + SmallSlashSmear.Position = Projectile.Center; + SmallSlashSmear.Scale = 0.8f; + SmallSlashSmear.Color = Main.hslToRgb(0.5f + 0.5f * MathF.Cos(Main.GlobalTimeWrappedHourly * 5f), 1f, 0.6f) * 0.6f * Projectile.Opacity; + } + } + + public override bool? CanDamage() => Projectile.timeLeft > 30; + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 90); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/SwiftSlice"), Projectile.Center); + + // SUPER EPIC AND AWESOME PARTICLES + for (int s = 0; s < 12; s++) + { + Vector2 sparkVel = Main.rand.NextVector2CircularEdge(1f, 1f)* Main.rand.NextFloat(14f, 18f); + float sparkSize = Main.rand.NextFloat(1f, 1.4f); + Color sparkColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.8f); + + Particle sparked = new AltLineParticle(target.Center, sparkVel, false, 30, sparkSize, sparkColor); + GeneralParticleHandler.SpawnParticle(sparked); + } + for (int sq = 0; sq < 5; sq++) + { + Vector2 squareVel = Main.rand.NextVector2CircularEdge(1f, 1f)* Main.rand.NextFloat(10f, 16f); + float squareSize = Main.rand.NextFloat(3.2f, 4f); + Color squareColor = Main.hslToRgb(Main.rand.NextFloat(), 0.6f, 0.8f); + + Particle squared = new SquareParticle(target.Center, squareVel, true, 30, squareSize, squareColor); + GeneralParticleHandler.SpawnParticle(squared); + } + } + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/CeramicImpact", 2), Projectile.Center); + + for (int i = 0; i < 32; i++) + { + Vector2 velocity = ((MathHelper.TwoPi * i / 32f) - (MathHelper.Pi / 32f)).ToRotationVector2() * 32f; + Particle sparkle = new CritSpark(Projectile.Center, velocity, Color.White, Color.Lime, 1.5f, 30, 0.1f, 3f, Main.rand.NextFloat(0f, 0.01f)); + GeneralParticleHandler.SpawnParticle(sparkle); + } + } + + public override void ModifyDamageHitbox(ref Rectangle hitbox) => hitbox.Inflate(70, 70); + + public override bool PreDraw(ref Color lightColor) + { + LargeSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawLargeSlash"); + Texture2D largeSlashTexture = LargeSlash.Value; + SmallSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawSmallSlash"); + Texture2D smallSlashTexture = SmallSlash.Value; + Color slashColor = new Color(200, 200, 200, 100) * Projectile.Opacity; + + Main.EntitySpriteDraw(largeSlashTexture, Projectile.Center - Main.screenPosition, null, slashColor, -Projectile.rotation, largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time % 4 == 0) + { + Vector2 randomParticleOffset = new Vector2(Main.rand.NextFloat(-Projectile.width * 1.75f, Projectile.width * 1.75f), Main.rand.NextFloat(-Projectile.width * 1.75f, Projectile.width * 1.75f)); + float randomParticleScale = Main.rand.NextFloat(0.65f, 0.95f); + Color bloomColor = Color.Lerp(new Color(29, 120, 30), new Color(56, 255, 59), MathF.Abs(MathF.Sin(Time))); + Particle bloomCircle = new BloomParticle(Projectile.Center + randomParticleOffset, Projectile.velocity, Main.rand.NextBool() ? Color.White : bloomColor, randomParticleScale, randomParticleScale, 4, false); + GeneralParticleHandler.SpawnParticle(bloomCircle); + } + Main.EntitySpriteDraw(smallSlashTexture, Projectile.Center - Main.screenPosition, null, slashColor, Projectile.rotation, smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time % 4 == 0) + { + Vector2 randomParticleOffset = new Vector2(Main.rand.NextFloat(-Projectile.width, Projectile.width), Main.rand.NextFloat(-Projectile.width, Projectile.width)); + float randomParticleScale = Main.rand.NextFloat(0.35f, 0.65f); + Color bloomColor = Color.Lerp(new Color(29, 120, 30), new Color(56, 255, 59), MathF.Abs(MathF.Sin(Time))); + Particle bloomCircle = new BloomParticle(Projectile.Center + randomParticleOffset, Projectile.velocity, Main.rand.NextBool() ? Color.White : bloomColor, randomParticleScale, randomParticleScale, 4, false); + GeneralParticleHandler.SpawnParticle(bloomCircle); + } + + // Draw the saw itself at full brightness, glow and outline in rainbow + Texture2D buzzsawTexture = TextureAssets.Projectile[Projectile.type].Value; + Main.EntitySpriteDraw(buzzsawTexture, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, buzzsawTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + SawOutline ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawOutline"); + Texture2D outline = SawOutline.Value; + Main.EntitySpriteDraw(outline, Projectile.Center - Main.screenPosition, null, Main.DiscoColor, Projectile.rotation, outline.Size() * 0.5f, 1f, SpriteEffects.None); + + if (!CalamityConfig.Instance.Afterimages) + return false; + + // Special afterimage drawing to include the slashes + for (int i = 1; i < Projectile.oldPos.Length; i++) + { + float afterimageRot = Projectile.oldRot[i]; + Vector2 drawPos = Projectile.oldPos[i] + buzzsawTexture.Size() * 0.5f - Main.screenPosition; + float intensity = MathHelper.Lerp(0.1f, 0.6f, 1f - i / (float)Projectile.oldPos.Length); + + Main.EntitySpriteDraw(buzzsawTexture, drawPos, null, Color.White * intensity, afterimageRot, buzzsawTexture.Size() * 0.5f, 1f, SpriteEffects.None); + Main.EntitySpriteDraw(largeSlashTexture, drawPos, null, slashColor * intensity, -afterimageRot, largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + Main.EntitySpriteDraw(smallSlashTexture, drawPos, null, slashColor * intensity, afterimageRot, smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + } + return false; + } + } +} diff --git a/Projectiles/Ranged/SuperradiantSawOutline.png b/Projectiles/Ranged/SuperradiantSawOutline.png new file mode 100644 index 0000000000..87ec455489 Binary files /dev/null and b/Projectiles/Ranged/SuperradiantSawOutline.png differ diff --git a/Projectiles/Ranged/SuperradiantSawSmallSlash.png b/Projectiles/Ranged/SuperradiantSawSmallSlash.png new file mode 100644 index 0000000000..c8cf403c47 Binary files /dev/null and b/Projectiles/Ranged/SuperradiantSawSmallSlash.png differ diff --git a/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs b/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs new file mode 100644 index 0000000000..0306b7f797 --- /dev/null +++ b/Projectiles/Ranged/SuperradiantSlaughtererHoldout.cs @@ -0,0 +1,350 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Cooldowns; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using ReLogic.Utilities; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class SuperradiantSlaughtererHoldout : BaseGunHoldoutProjectile + { + public override int AssociatedItemID => ModContent.ItemType(); + public override float RecoilResolveSpeed => 0.05f; + public override float MaxOffsetLengthFromArm => 36f; + public override float BaseOffsetY => -5f; + public override float OffsetYUpwards => -5f; + public override float OffsetYDownwards => 5f; + public override Vector2 GunTipPosition => Projectile.Center + Vector2.UnitX.RotatedBy(Projectile.rotation) * Projectile.width * 0.25f; + + public ref float Time => ref Projectile.ai[0]; + public const float ChargeupTime = 120f; + public SlotId ChargeIdle; + + // Controls the saw visually disappearing from the holdout when it fires. + public bool NoSawOnHoldout = false; + + public Particle SmallSlashSmear; + public Particle LargeSlashSmear; + public static Asset Holdout; + public static Asset HoldoutGlow; + public static Asset MiniSaw; + public static Asset SmallSlash; + public static Asset LargeSlash; + + public override void SetStaticDefaults() + { + Main.projFrames[Projectile.type] = 5; + } + + public override void SetDefaults() + { + base.SetDefaults(); + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = -1; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + + public override void KillHoldoutLogic() + { + if (HeldItem.type != Owner.ActiveItem().type) + { + Projectile.Kill(); + Projectile.netUpdate = true; + } + } + + public override void HoldoutAI() + { + Time++; + float SawPower = MathHelper.Clamp(Time / ChargeupTime, 0f, 1f); + + if (SoundEngine.TryGetActiveSound(ChargeIdle, out var Idle) && Idle.IsPlaying) + Idle.Position = GunTipPosition; + + // Handle the right-click dash (holds priority over left-click) + if (Owner.Calamity().mouseRight && !Owner.HasCooldown(SuperradiantSawBoost.ID)) + { + Owner.AddCooldown(SuperradiantSawBoost.ID, SuperradiantSlaughterer.DashCooldown); + Owner.Calamity().sBlasterDashActivated = true; + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/MeatySlash"), GunTipPosition); + + // Throws a lingering saw at the cursor that deals 3x damage (since the holdout already deals 2x) + float mouseDist = Vector2.Distance(GunTipPosition, Owner.Calamity().mouseWorld) / 21f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * mouseDist, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5f), Projectile.knockBack, Projectile.owner); + + // Special case: right-clicking while not holding left-click + // This is to keep it friendly to use both fires at the same time, but end the animation early if not + if (Projectile.ai[1] >= 2f) + { + NoSawOnHoldout = true; + OffsetLengthFromArm -= 16f; + Projectile.timeLeft = Owner.ActiveItem().useAnimation; + KeepRefreshingLifetime = false; + Idle?.Stop(); + } + + // If moving, make particle effects when the dash activates + if (Owner.velocity != Vector2.Zero) + { + int particleAmt = 7; + for (int c = 0; c < particleAmt; c++) + { + Color sparkColor = Color.Lerp(new Color(122, 240, 58), new Color(32, 186, 171), c / (particleAmt - 1)); + Particle spark = new CritSpark(Owner.Center, Owner.velocity.RotatedByRandom(MathHelper.ToRadians(13f)) * Main.rand.NextFloat(-2.1f, -4.5f), Color.White, sparkColor, 2f, 45, 2.25f, 2f); + GeneralParticleHandler.SpawnParticle(spark); + } + for (int e = 0; e < particleAmt * 2; e++) + { + Color sparkColor2 = Color.Lerp(new Color(122, 240, 58), new Color(32, 186, 171), e / (particleAmt - 1)); + Particle spark2 = new NanoParticle(Owner.Center, Owner.velocity.RotatedByRandom(MathHelper.ToRadians(-MathHelper.PiOver4)) * Main.rand.NextFloat(2.5f, 4.5f), sparkColor2, 1f, 45, Main.rand.NextBool(3)); + GeneralParticleHandler.SpawnParticle(spark2); + } + } + } + else if (Owner.CantUseHoldout() && Projectile.ai[1] < 1f) + { + KeepRefreshingLifetime = false; + Idle?.Stop(); + + Projectile.ai[1] = 1f; + Projectile.timeLeft = Owner.ActiveItem().useAnimation; + SoundStyle ShootSound = new("CalamityMod/Sounds/Item/SawShot", 2) { PitchVariance = 0.1f, Volume = 0.4f + SawPower * 0.5f }; + SoundEngine.PlaySound(ShootSound, GunTipPosition); + + float sawDamageMult = MathHelper.Lerp(1f, 5f, SawPower) / 2f; // The damage must be divided by 2 to offset the holdout having 2x base damage. + int sawPierce = (int)MathHelper.Lerp(2f, 7f, SawPower); + int sawLevel = (SawPower >= 1f).ToInt() + (SawPower >= 0.25f).ToInt(); + + // ai[0] determines which slashes are drawn. ai[1] is the saw's timer variable. ai[2] stores the saw's pierce. + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitY) * SuperradiantSlaughterer.ShootSpeed, ModContent.ProjectileType(), (int)(Projectile.damage * sawDamageMult), Projectile.knockBack, Projectile.owner, sawLevel, 0f, sawPierce); + + NoSawOnHoldout = true; + OffsetLengthFromArm -= 4f + 12f * SawPower; + + int sparkPairCount = 3 + 2 * sawLevel; + for (int s = 0; s < sparkPairCount; s++) + { + float velocityMult = Main.rand.NextFloat(5f, 8f) + Main.rand.NextFloat(4f, 7f) * sawLevel; + float scale = Main.rand.NextFloat(0.6f, 0.8f) + Main.rand.NextFloat(0.3f, 0.5f) * sawLevel; + Color color = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.8f); + + Vector2 sparkVelocity = Projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * velocityMult; + Particle weaponShootSparks = new AltLineParticle(GunTipPosition, sparkVelocity, false, 40, scale, color); + GeneralParticleHandler.SpawnParticle(weaponShootSparks); + + // re-randomize rotation for the alternate particle + sparkVelocity = Projectile.velocity.RotatedByRandom(MathHelper.PiOver4) * velocityMult; + Particle weaponShootSparks2 = new AltSparkParticle(GunTipPosition, sparkVelocity, false, 40, scale, color); + GeneralParticleHandler.SpawnParticle(weaponShootSparks2); + } + } + + if (NoSawOnHoldout) + { + Projectile.frame = 4; + return; + } + else + { + Projectile.frameCounter++; + if (Projectile.frameCounter >= 3) + { + Projectile.frameCounter = 0; + Projectile.frame++; + if (Projectile.frame > 3) + Projectile.frame = 0; + } + } + + // Smear particles which follow the path of the slashes + if (SawPower >= 1f) + { + if (LargeSlashSmear == null) + { + LargeSlashSmear = new CircularSmearVFX(GunTipPosition, Color.Black, Time * -MathHelper.ToRadians(42f), 1.35f); + GeneralParticleHandler.SpawnParticle(LargeSlashSmear); + } + else + { + LargeSlashSmear.Rotation = Time * -MathHelper.ToRadians(42f); + LargeSlashSmear.Time = 0; + LargeSlashSmear.Position = GunTipPosition; + LargeSlashSmear.Scale = 1.35f; + LargeSlashSmear.Color = Main.hslToRgb(0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f), 1f, 0.6f) * 0.8f; + } + } + if (SawPower >= 0.25f) + { + if (SmallSlashSmear == null) + { + SmallSlashSmear = new CircularSmearVFX(GunTipPosition, Color.Black, Time * MathHelper.ToRadians(42f), 0.8f); + GeneralParticleHandler.SpawnParticle(SmallSlashSmear); + } + else + { + SmallSlashSmear.Rotation = Time * MathHelper.ToRadians(42f); + SmallSlashSmear.Time = 0; + SmallSlashSmear.Position = GunTipPosition; + SmallSlashSmear.Scale = 0.8f; + SmallSlashSmear.Color = Main.hslToRgb(0.5f + 0.5f * MathF.Cos(Main.GlobalTimeWrappedHourly * 5f), 1f, 0.6f) * 0.6f; + } + } + + if (Time < ChargeupTime) + { + if (Time == 30f && !NoSawOnHoldout) + ChargeIdle = SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/BuzzsawCharge") { Volume = 0.3f }, GunTipPosition); + } + else + { + if ((Time + 240) % 360 == 0) + ChargeIdle = SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/BuzzsawIdle"), GunTipPosition); + + if (Time % 3 == 0) + { + Vector2 smokeVelocity = Vector2.UnitY * Main.rand.NextFloat(-7f, -12f); + smokeVelocity = smokeVelocity.RotatedByRandom(MathHelper.Pi / 8f); + Color smokeColor = Main.rand.NextBool() ? Main.DiscoColor : Color.Gray; + Particle fullChargeSmoke = new HeavySmokeParticle(GunTipPosition + Main.rand.NextVector2CircularEdge(3f, 3f), smokeVelocity, smokeColor, 30, 0.65f, 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), true); + GeneralParticleHandler.SpawnParticle(fullChargeSmoke); + } + } + } + + public override void OnSpawn(IEntitySource source) + { + base.OnSpawn(source); + ExtraBackArmRotation = MathHelper.ToRadians(15f); + } + + // Failsafe because apparently the sound doesn't stop sometimes + public override void OnKill(int timeLeft) + { + if (SoundEngine.TryGetActiveSound(ChargeIdle, out var Idle)) + Idle?.Stop(); + } + + // The holdout can deal damage; you're literally spinning up a buzzsaw at the end, after all. + public override bool? CanDamage() => !NoSawOnHoldout; + + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + hitbox = new Rectangle((int)GunTipPosition.X - 23, (int)GunTipPosition.Y - 23, 46, 46); + + if (Time / ChargeupTime >= 1f) + hitbox.Inflate(72, 72); + else if (Time / ChargeupTime >= 0.25f) + hitbox.Inflate(32, 32); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 300); + target.AddBuff(ModContent.BuffType(), 150); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/SwiftSlice") { Volume = 0.7f }, GunTipPosition); + + // EPIC AND COOL RAINBOW PARTICLES WOOOO + int SawLevel = (Time / ChargeupTime >= 1f).ToInt() + (Time / ChargeupTime >= 0.25f).ToInt(); + int onHitSparkAmount = 4 + 4 * SawLevel; + for (int s = 0; s < onHitSparkAmount; s++) + { + Vector2 sparkVel = Main.rand.NextVector2CircularEdge(1f, 1f) * (Main.rand.NextFloat(6f, 10f) + 5f * SawLevel); + float sparkSize = 0.4f + Main.rand.NextFloat(0.3f, 0.6f) * SawLevel; + Color sparkColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.8f); + + Particle sparked = new AltLineParticle(target.Center, sparkVel, false, 20, sparkSize, sparkColor); + GeneralParticleHandler.SpawnParticle(sparked); + } + for (int sq = 0; sq < 5; sq++) + { + Vector2 squareVel = Main.rand.NextVector2CircularEdge(1f, 1f)* (Main.rand.NextFloat(6f, 10f) + 5f * SawLevel); + float squareSize = 1.6f + Main.rand.NextFloat(1f, 1.6f) * SawLevel; + Color squareColor = Main.hslToRgb(Main.rand.NextFloat(), 0.6f, 0.8f); + + Particle squared = new SquareParticle(target.Center, squareVel, true, 20, squareSize, squareColor); + GeneralParticleHandler.SpawnParticle(squared); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Holdout ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSlaughtererHoldout"); + Texture2D holdoutTexture = Holdout.Value; + LargeSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawLargeSlash"); + Texture2D largeSlashTexture = LargeSlash.Value; + SmallSlash ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSawSmallSlash"); + Texture2D smallSlashTexture = SmallSlash.Value; + Color slashColor = new Color(200, 200, 200, 100); + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = holdoutTexture.Frame(verticalFrames: Main.projFrames[Type], frameY: Projectile.frame); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = frame.Size() * 0.5f; + SpriteEffects flipSprite = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + if (!NoSawOnHoldout) + { + float shake = Utils.Remap(Time, 0f, ChargeupTime, 0f, 3f); + drawPosition += Main.rand.NextVector2Circular(shake, shake); + } + + // Mini saw drawn under the gun + MiniSaw ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSlaughtererHoldoutMiniSaw"); + Texture2D mini = MiniSaw.Value; + Vector2 verticalOffset = Vector2.UnitY.RotatedBy(Projectile.rotation); + if (Math.Cos(Projectile.rotation) < 0f) + verticalOffset *= -1f; + Vector2 miniSawPosition = drawPosition - Vector2.UnitX.RotatedBy(Projectile.rotation) * Projectile.width * 0.125f + verticalOffset * 6f; + Main.EntitySpriteDraw(mini, miniSawPosition, null, Color.White, Time * MathHelper.ToRadians(24f), mini.Size() * 0.5f, Projectile.scale, flipSprite); + + Main.EntitySpriteDraw(holdoutTexture, drawPosition, frame, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale, flipSprite); + + // Glowmask + HoldoutGlow ??= ModContent.Request("CalamityMod/Projectiles/Ranged/SuperradiantSlaughtererHoldoutGlow"); + Texture2D glow = HoldoutGlow.Value; + Main.EntitySpriteDraw(glow, drawPosition, frame, Color.White, drawRotation, rotationPoint, Projectile.scale, flipSprite); + + if (NoSawOnHoldout) + return false; + + if (Time > 30f) + { + if (Time / ChargeupTime >= 1f) + Main.EntitySpriteDraw(largeSlashTexture, GunTipPosition - Main.screenPosition, null, slashColor, Time * -MathHelper.ToRadians(42f), largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time / ChargeupTime >= 0.25f) + Main.EntitySpriteDraw(smallSlashTexture, GunTipPosition - Main.screenPosition, null, slashColor, Time * MathHelper.ToRadians(42f), smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (!CalamityConfig.Instance.Afterimages) + return false; + + // Special afterimage drawing for the slashes only + for (int i = 1; i < 3; i++) + { + float intensity = MathHelper.Lerp(0.05f, 0.25f, 1f - i / 3f); + + if (Time / ChargeupTime >= 1f) + Main.EntitySpriteDraw(largeSlashTexture, GunTipPosition - Main.screenPosition, null, slashColor * intensity, (Time - i) * -MathHelper.ToRadians(42f), largeSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + + if (Time / ChargeupTime >= 0.25f) + Main.EntitySpriteDraw(smallSlashTexture, GunTipPosition - Main.screenPosition, null, slashColor * intensity, (Time - i) * MathHelper.ToRadians(42f), smallSlashTexture.Size() * 0.5f, 1f, SpriteEffects.None); + } + } + + return false; + } + } +} diff --git a/Projectiles/Ranged/SuperradiantSlaughtererHoldout.png b/Projectiles/Ranged/SuperradiantSlaughtererHoldout.png new file mode 100644 index 0000000000..e5445246aa Binary files /dev/null and b/Projectiles/Ranged/SuperradiantSlaughtererHoldout.png differ diff --git a/Projectiles/Ranged/SuperradiantSlaughtererHoldoutGlow.png b/Projectiles/Ranged/SuperradiantSlaughtererHoldoutGlow.png new file mode 100644 index 0000000000..26c6b47fb4 Binary files /dev/null and b/Projectiles/Ranged/SuperradiantSlaughtererHoldoutGlow.png differ diff --git a/Projectiles/Ranged/SuperradiantSlaughtererHoldoutMiniSaw.png b/Projectiles/Ranged/SuperradiantSlaughtererHoldoutMiniSaw.png new file mode 100644 index 0000000000..5258525907 Binary files /dev/null and b/Projectiles/Ranged/SuperradiantSlaughtererHoldoutMiniSaw.png differ diff --git a/Projectiles/Ranged/TheHiveHoldout.cs b/Projectiles/Ranged/TheHiveHoldout.cs index f29cb26b3e..a282f52ad9 100644 --- a/Projectiles/Ranged/TheHiveHoldout.cs +++ b/Projectiles/Ranged/TheHiveHoldout.cs @@ -8,6 +8,7 @@ using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; +using static CalamityMod.Items.Weapons.Ranged.TheHive; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Ranged @@ -25,14 +26,18 @@ namespace CalamityMod.Projectiles.Ranged // It'll carry over to the projectiles that it shoots. public static int DustEffectsID { get; set; } public static Color EffectsColor { get; set; } - public static Color StaticEffectsColor = Color.Lime; + public static Color StaticEffectsColor { get; set; } = Color.Lime; - private ref float ShootingTimer => ref Projectile.ai[0]; - private bool FireNuke; - private float PostFireCooldown = 0; - private bool HasLetGo = false; - private SlotId HiveHum; - private const float MaxCharge = 90f; + public ref float ShootingTimer => ref Projectile.ai[0]; + public ref float PostFireCooldown => ref Projectile.ai[1]; + public bool HasLetGo + { + get => Projectile.ai[2] == 1f; + set => Projectile.ai[2] = value == true ? 1f : 0f; + } + + public bool FireNuke => ShootingTimer > MaxCharge; + public SlotId HiveHum { get; set; } public override void KillHoldoutLogic() { @@ -42,9 +47,6 @@ namespace CalamityMod.Projectiles.Ranged public override void HoldoutAI() { - - FireNuke = ShootingTimer > MaxCharge; - // If there's no player, or the player is the server, or the owner's stunned, there'll be no holdout. if (Owner.CantUseHoldout() && !HasLetGo) { @@ -54,7 +56,6 @@ namespace CalamityMod.Projectiles.Ranged } if (HeldItem.type == ItemType()) ShootRocket(); - NetUpdate(); HasLetGo = true; } @@ -102,7 +103,7 @@ namespace CalamityMod.Projectiles.Ranged } } - private void ShootRocket() + public void ShootRocket() { // We use the velocity of this projectile as its direction vector. Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero); @@ -173,8 +174,6 @@ namespace CalamityMod.Projectiles.Ranged PostFireCooldown = 30; } - NetUpdate(); - // Inside here go all the things that dedicated servers shouldn't spend resources on. // Like visuals and sounds. if (Main.dedServ) @@ -210,7 +209,7 @@ namespace CalamityMod.Projectiles.Ranged OffsetLengthFromArm -= FireNuke ? 16f : 6f; } - private void PostFiringCooldown() + public void PostFiringCooldown() { Owner.channel = true; if (PostFireCooldown > 0) @@ -227,21 +226,11 @@ namespace CalamityMod.Projectiles.Ranged else { if (SoundEngine.TryGetActiveSound(HiveHum, out var hum) && hum.IsPlaying) - { hum?.Stop(); - } Projectile.Kill(); - NetUpdate(); } } - private void NetUpdate() - { - Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; - } - public override void OnSpawn(IEntitySource source) { base.OnSpawn(source); diff --git a/Projectiles/Ranged/WildfireBloomHoldout.cs b/Projectiles/Ranged/WildfireBloomHoldout.cs index 6144e97939..dc4086d841 100644 --- a/Projectiles/Ranged/WildfireBloomHoldout.cs +++ b/Projectiles/Ranged/WildfireBloomHoldout.cs @@ -1,12 +1,10 @@ -using CalamityMod.Items.Weapons.Ranged; +using System.IO; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.DataStructures; -using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -22,19 +20,16 @@ namespace CalamityMod.Projectiles.Ranged public override float BaseOffsetY => -5f; public override float OffsetYDownwards => 5f; - private ref float ShotCooldown => ref Projectile.ai[0]; - private ref float ShotsFired => ref Projectile.ai[1]; - private ref float ShootTimer => ref Projectile.ai[2]; - public int FireBlobs = 0; + public ref float ShotCooldown => ref Projectile.ai[0]; + public ref float ShotsFired => ref Projectile.ai[1]; + public ref float ShootTimer => ref Projectile.ai[2]; + public int FireBlobs { get; set; } public override void KillHoldoutLogic() { base.KillHoldoutLogic(); if (ShotsFired >= 16) - { Projectile.Kill(); - Projectile.netUpdate = true; - } } public override void HoldoutAI() @@ -83,5 +78,9 @@ namespace CalamityMod.Projectiles.Ranged base.OnSpawn(source); SoundEngine.PlaySound(SoundID.Item73 with { Volume = 0.7f }, Projectile.Center); } + + public override void SendExtraAIHoldout(BinaryWriter writer) => writer.Write(FireBlobs); + + public override void ReceiveExtraAIHoldout(BinaryReader reader) => FireBlobs = reader.ReadInt32(); } } diff --git a/Projectiles/Rogue/BallisticPoisonBombProj.cs b/Projectiles/Rogue/BallisticPoisonBombProj.cs index 1085f9f558..6ef3ba74cc 100644 --- a/Projectiles/Rogue/BallisticPoisonBombProj.cs +++ b/Projectiles/Rogue/BallisticPoisonBombProj.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Rogue Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner); } - int cloudAmt = Projectile.Calamity().stealthStrike ? Main.rand.Next(8, 12+1) : Main.rand.Next(3, 5+1); + int cloudAmt = Projectile.Calamity().stealthStrike ? Main.rand.Next(7, 10+1) : Main.rand.Next(3, 5+1); for (int c = 0; c < cloudAmt; c++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 200f, 0.01f); diff --git a/Projectiles/Rogue/BallisticPoisonCloud.cs b/Projectiles/Rogue/BallisticPoisonCloud.cs index 47f612c1ef..df259e395b 100644 --- a/Projectiles/Rogue/BallisticPoisonCloud.cs +++ b/Projectiles/Rogue/BallisticPoisonCloud.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.height = 34; Projectile.friendly = true; Projectile.alpha = 255; - Projectile.penetrate = -1; + Projectile.penetrate = 5; Projectile.tileCollide = false; Projectile.ignoreWater = true; Projectile.timeLeft = 600; diff --git a/Projectiles/Rogue/ExorcismProj.cs b/Projectiles/Rogue/ExorcismProj.cs index ff5246efc9..79b74887d0 100644 --- a/Projectiles/Rogue/ExorcismProj.cs +++ b/Projectiles/Rogue/ExorcismProj.cs @@ -73,6 +73,20 @@ namespace CalamityMod.Projectiles.Rogue } } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + // Stars + if (Projectile.Calamity().stealthStrike) + { + for (int i = 0; i < 6; i++) + { + Vector2 pos = new Vector2(Projectile.Center.X + (float)Projectile.width * 0.5f + (float)Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + Vector2 starVelocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(pos, target, 30f, 2); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, starVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.75f), Projectile.knockBack * 0.5f, Projectile.owner, Main.rand.NextFloat(-3f, 3f), 0f); + } + } + } + public override bool PreDraw(ref Color lightColor) { Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; @@ -97,17 +111,6 @@ namespace CalamityMod.Projectiles.Rogue Main.projectile[p].rotation = Projectile.rotation; if (Projectile.Calamity().stealthStrike) Main.projectile[p].Calamity().stealthStrike = true; - // Stars - if (Projectile.Calamity().stealthStrike) - { - for (int i = 0; i < 6; i++) - { - Vector2 pos = new Vector2(Projectile.Center.X + (float)Projectile.width * 0.5f + (float)Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); - float speedX = (Projectile.Center.X - pos.X) / 20f; - float speedY = (Projectile.Center.Y - pos.Y) / 20f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos.X, pos.Y, speedX, speedY, ModContent.ProjectileType(), (int)(Projectile.damage * 0.75f), Projectile.knockBack * 0.5f, Projectile.owner, Main.rand.NextFloat(-3f, 3f), 0f); - } - } } } } diff --git a/Projectiles/Rogue/ExorcismStar.cs b/Projectiles/Rogue/ExorcismStar.cs index 1205f4d2c5..9c31376c1d 100644 --- a/Projectiles/Rogue/ExorcismStar.cs +++ b/Projectiles/Rogue/ExorcismStar.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.tileCollide = false; Projectile.ignoreWater = true; Projectile.timeLeft = 300; - Projectile.extraUpdates = 3; + Projectile.MaxUpdates = 2; Projectile.DamageType = RogueDamageClass.Instance; } diff --git a/Projectiles/Rogue/Honeycomb.cs b/Projectiles/Rogue/Honeycomb.cs index 5e3ca0a392..657b228b40 100644 --- a/Projectiles/Rogue/Honeycomb.cs +++ b/Projectiles/Rogue/Honeycomb.cs @@ -71,6 +71,11 @@ namespace CalamityMod.Projectiles.Rogue public void SpawnProjectiles() { + // If it's already spawned projectiles, don't do anything. Prevents it from spawning double the projectile amount when hitting enemies. + if (Projectile.ai[1] == 1f) + return; + + Projectile.ai[1] = 1f; Player player = Main.player[Main.myPlayer]; int fragAmt = 2; for (int i = 0; i < fragAmt; i++) diff --git a/Projectiles/Rogue/TurbulanceWindSlash.cs b/Projectiles/Rogue/TurbulanceWindSlash.cs index b3a9087d3e..59ecdedeb3 100644 --- a/Projectiles/Rogue/TurbulanceWindSlash.cs +++ b/Projectiles/Rogue/TurbulanceWindSlash.cs @@ -24,10 +24,10 @@ namespace CalamityMod.Projectiles.Rogue Projectile.alpha = 255; Projectile.ignoreWater = true; Projectile.DamageType = RogueDamageClass.Instance; - Projectile.timeLeft = 180; + Projectile.timeLeft = 240; } - public override bool? CanHitNPC(NPC target) => Projectile.timeLeft < 150 && target.CanBeChasedBy(Projectile); + public override bool? CanHitNPC(NPC target) => Projectile.timeLeft < 200 && target.CanBeChasedBy(Projectile); public override void AI() { diff --git a/Projectiles/Summon/FleshBlood.cs b/Projectiles/Summon/FleshBlood.cs index 1a850a0e03..cb94a352f8 100644 --- a/Projectiles/Summon/FleshBlood.cs +++ b/Projectiles/Summon/FleshBlood.cs @@ -22,6 +22,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.minion = true; Projectile.penetrate = 1; Projectile.timeLeft = LifeTime; + Projectile.extraUpdates = 1; Projectile.DamageType = DamageClass.Summon; } diff --git a/Projectiles/Summon/HarvestStaffMinion.cs b/Projectiles/Summon/HarvestStaffMinion.cs index c00e7bf69b..15842a6816 100644 --- a/Projectiles/Summon/HarvestStaffMinion.cs +++ b/Projectiles/Summon/HarvestStaffMinion.cs @@ -46,8 +46,6 @@ namespace CalamityMod.Projectiles.Summon } else if (value == AIState.Idle) Animation = AnimationState.Idle; - - NetUpdate(); } } @@ -127,8 +125,6 @@ namespace CalamityMod.Projectiles.Summon FramesUntilNextAnimationFrame = 5; break; } - - NetUpdate(); } } @@ -138,9 +134,10 @@ namespace CalamityMod.Projectiles.Summon public int AnimationFrames { get; set; } /// - /// The amount of time, in frames, that it'll take to go to the next frame of animation. + /// The amount of time, in frames, that it'll take to go to the next frame of animation.
+ /// Defaults to 1 so it doesn't divide by 0. ///
- public int FramesUntilNextAnimationFrame { get; set; } + public int FramesUntilNextAnimationFrame { get; set; } = 1; /// /// A convienent bool for when the animation has been completed.
@@ -214,18 +211,19 @@ namespace CalamityMod.Projectiles.Summon } } - public int NetUpdateTimer { get; set; } - #endregion #region AI and Collisions public override void AI() { - if (Animation == AnimationState.Grow && (MySentry is null || Projectile.Distance(MySentry.Center) > 600f)) + Owner ??= Main.player[Projectile.owner]; + Projectile.width = Projectile.height = Variant == 0 ? 28 : (Variant == 1 ? 22 : 20); + + if (Animation == AnimationState.Grow && (MySentry is null || Projectile.Distance(MySentry.Center) > 600f) && Main.myPlayer == Projectile.owner) { Projectile.Kill(); - NetUpdate(); + return; } Target = Projectile.Center.MinionHoming(State == AIState.Still ? PlantedEnemyDistanceDetection : NormalEnemyDistanceDetection, Owner, false); @@ -249,13 +247,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.timeLeft = 2; DoGravity(); DoAnimation(); - - NetUpdateTimer++; - if (NetUpdateTimer > 60) - { - NetUpdateTimer = 0; - NetUpdate(); - } + NetUpdate(); } public override bool OnTileCollide(Vector2 oldVelocity) @@ -300,9 +292,13 @@ namespace CalamityMod.Projectiles.Summon { if (State != AIState.Attack) return; - + Projectile.ExpandHitboxBy(4f); - Projectile.Damage(); + if (Main.myPlayer == Projectile.owner) + Projectile.Damage(); + + if (Main.dedServ) + return; for (int i = 0; i < (int)Utils.Remap(Variant, 0f, 2f, 4f, 2f); i++) { @@ -312,11 +308,6 @@ namespace CalamityMod.Projectiles.Summon gore.timeLeft = 15; } - NetUpdate(); - - if (Main.dedServ) - return; - for (int i = 0; i < 20; i++) { if (BirthdayParty.PartyIsUp) @@ -374,7 +365,6 @@ namespace CalamityMod.Projectiles.Summon { IdleWalkingTime = IdleWalkingTimer = Main.rand.Next(60, 180); IdleWalkingDirection = MySentry == null || Projectile.WithinRange(MySentry.Center, 960f) ? (Main.rand.NextBool() ? -1 : 1) : MathF.Sign(MySentry.Center.X - Projectile.Center.X); - NetUpdate(); } else if (IdleWalkingTimer != 0f) @@ -447,8 +437,6 @@ namespace CalamityMod.Projectiles.Summon Animation = AnimationState.Jump; SoundEngine.PlaySound(_jumpSound with { Pitch = Utils.Remap(Variant, 0f, 2f, -0.3f, 0.3f) }, Projectile.Center); - - NetUpdate(); } /// @@ -478,7 +466,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.velocity.Y = -MathF.Sqrt(-2f * PumpkinGravityStrength * (destination.Y - Projectile.Bottom.Y)); Animation = AnimationState.Jump; SoundEngine.PlaySound(_jumpSound with { Pitch = Utils.Remap(Variant, 0f, 2f, -0.3f, 0.3f) }, Projectile.Center); - NetUpdate(); } /// @@ -524,9 +511,10 @@ namespace CalamityMod.Projectiles.Summon return; Projectile.frameCounter++; - if (Projectile.frameCounter % FramesUntilNextAnimationFrame == 0) + if (Projectile.frameCounter >= FramesUntilNextAnimationFrame) { Projectile.frame = Math.Min(Projectile.frame + 1, AnimationFrames - 1); + Projectile.frameCounter = 0; // If it's the run animation, loop it. if (Animation == AnimationState.Run && CompletedAnimation) @@ -539,9 +527,8 @@ namespace CalamityMod.Projectiles.Summon /// public void NetUpdate() { + Projectile.netSpam = 0; Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; } #endregion @@ -566,34 +553,34 @@ namespace CalamityMod.Projectiles.Summon public override void SendExtraAI(BinaryWriter writer) { - writer.Write(IdleWalkingTime); - writer.Write(IdleWalkingTimer); - writer.Write(IdleJumpCount); - writer.Write(IdleJumpCooldown); - writer.Write(IdleWalkingDirection); - writer.Write(NetUpdateTimer); + writer.Write7BitEncodedInt(Direction); + writer.Write7BitEncodedInt(IdleWalkingTime); + writer.Write7BitEncodedInt(IdleWalkingTimer); + writer.Write7BitEncodedInt(IdleJumpCount); + writer.Write7BitEncodedInt(IdleJumpCooldown); + writer.Write7BitEncodedInt(IdleWalkingDirection); + writer.Write7BitEncodedInt(AnimationFrames); + writer.Write7BitEncodedInt(FramesUntilNextAnimationFrame); } public override void ReceiveExtraAI(BinaryReader reader) { - IdleWalkingTime = reader.ReadInt32(); - IdleWalkingTimer = reader.ReadInt32(); - IdleJumpCount = reader.ReadInt32(); - IdleJumpCooldown = reader.ReadInt32(); - IdleWalkingDirection = reader.ReadInt32(); - NetUpdateTimer = reader.ReadInt32(); + Direction = reader.Read7BitEncodedInt(); + IdleWalkingTime = reader.Read7BitEncodedInt(); + IdleWalkingTimer = reader.Read7BitEncodedInt(); + IdleJumpCount = reader.Read7BitEncodedInt(); + IdleJumpCooldown = reader.Read7BitEncodedInt(); + IdleWalkingDirection = reader.Read7BitEncodedInt(); + AnimationFrames = reader.Read7BitEncodedInt(); + FramesUntilNextAnimationFrame = reader.Read7BitEncodedInt(); } public override bool? CanDamage() => State == AIState.Attack ? null : false; - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => NetUpdate(); - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.SourceDamage *= Utils.Remap(Variant, 0f, 2f, 1.5f, 0.5f); public override void OnSpawn(IEntitySource source) { - Owner = Main.player[Projectile.owner]; - Projectile.width = Projectile.height = Variant == 0 ? 28 : (Variant == 1 ? 22 : 20); Direction = Main.rand.NextBool() ? -1 : 1; Animation = AnimationState.None; } diff --git a/Projectiles/Summon/LiliesOfFinalityAoE.cs b/Projectiles/Summon/LiliesOfFinalityAoE.cs index 8ea6e54e24..819d1308fb 100644 --- a/Projectiles/Summon/LiliesOfFinalityAoE.cs +++ b/Projectiles/Summon/LiliesOfFinalityAoE.cs @@ -2,7 +2,6 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ModLoader; using static CalamityMod.Items.Weapons.Summon.LiliesOfFinality; @@ -38,6 +37,8 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { + Ariane ??= Main.projectile[(int)ArianeID]; + if (Ariane != null && Ariane.active && Ariane.owner == Projectile.owner && Ariane.type == ModContent.ProjectileType() && Ariane.ModProjectile().State == LiliesOfFinalityAriane.AIState.Attack) Projectile.timeLeft = 2; @@ -100,8 +101,6 @@ namespace CalamityMod.Projectiles.Summon Timer++; } - public override void OnSpawn(IEntitySource source) => Ariane = Main.projectile[(int)ArianeID]; - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.SourceDamage *= Ariane_AoEDMGMultiplier; } } diff --git a/Projectiles/Summon/LiliesOfFinalityAriane.cs b/Projectiles/Summon/LiliesOfFinalityAriane.cs index 1da87b762c..a6e2b0c3bf 100644 --- a/Projectiles/Summon/LiliesOfFinalityAriane.cs +++ b/Projectiles/Summon/LiliesOfFinalityAriane.cs @@ -7,9 +7,6 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.DataStructures; -using Terraria.GameContent; -using Terraria.ID; using Terraria.ModLoader; using static System.MathF; using static CalamityMod.Items.Weapons.Summon.LiliesOfFinality; @@ -58,8 +55,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ProjectileType(), Projectile.damage, 0f, Projectile.owner, Projectile.whoAmI); Timer = 0f; - - NetUpdate(); } } @@ -128,23 +123,23 @@ namespace CalamityMod.Projectiles.Summon public override void CheckMinionExistence() { + if (Elster is null) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile p = Main.projectile[i]; + if (p == null || !p.active || p.owner != Projectile.owner || p.type != ProjectileType()) + continue; + Elster = p; + break; + } + } + Projectile.timeLeft = 2; if (Elster is null || !Elster.active || Elster.owner != Projectile.owner || Elster.type != ProjectileType()) Projectile.Kill(); } - public override void OnSpawn(IEntitySource source) - { - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile p = Main.projectile[i]; - if (p == null || !p.active || p.owner != Projectile.owner || p.type != ProjectileType()) - continue; - Elster = p; - break; - } - } - public override bool OnTileCollide(Vector2 oldVelocity) => false; public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) @@ -182,6 +177,9 @@ namespace CalamityMod.Projectiles.Summon Timer++; + Projectile.netSpam = 0; + Projectile.netUpdate = true; + // If on a dedicated server, don't bother running the visuals and sounds to save resources. if (Main.dedServ) return; @@ -297,7 +295,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.owner); Timer = 0f; - NetUpdate(); // If on a dedicated server, don't bother running the visuals and sounds to save resources. if (Main.dedServ) @@ -347,13 +344,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.spriteDirection = spriteDirection; } - private void NetUpdate() - { - Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; - } - #endregion #region Syncing diff --git a/Projectiles/Summon/LiliesOfFinalityElster.cs b/Projectiles/Summon/LiliesOfFinalityElster.cs index a34bfd5172..04baf4f098 100644 --- a/Projectiles/Summon/LiliesOfFinalityElster.cs +++ b/Projectiles/Summon/LiliesOfFinalityElster.cs @@ -7,8 +7,6 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.GameContent; -using Terraria.ID; using Terraria.ModLoader; using static System.MathF; using static CalamityMod.Items.Weapons.Summon.LiliesOfFinality; @@ -54,8 +52,6 @@ namespace CalamityMod.Projectiles.Summon // Because some states mess with the rotation, we reset it so it doesn't cause visual issues on the states that don't deal with rotation. Projectile.rotation = 0f; - - NetUpdate(); } } @@ -179,6 +175,9 @@ namespace CalamityMod.Projectiles.Summon } Timer++; + + Projectile.netSpam = 0; + Projectile.netUpdate = true; } private void IdleState() @@ -316,7 +315,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.owner); HasShotOnce = true; - NetUpdate(); // If on a dedicated server, don't bother running the visuals and sounds to save resources. if (Main.dedServ) @@ -368,13 +366,6 @@ namespace CalamityMod.Projectiles.Summon } } - private void NetUpdate() - { - Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; - } - #endregion #region Syncing diff --git a/Projectiles/Typeless/BasicPlagueBee.cs b/Projectiles/Typeless/BasicPlagueBee.cs index a3ea930c7b..6122f85d3a 100644 --- a/Projectiles/Typeless/BasicPlagueBee.cs +++ b/Projectiles/Typeless/BasicPlagueBee.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Projectiles.Typeless Projectile.penetrate = 2; Projectile.timeLeft = 300; Projectile.ignoreWater = true; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 5; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 12; } public override void AI() @@ -81,9 +81,8 @@ namespace CalamityMod.Projectiles.Typeless if (Main.rand.NextBool()) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, 303, -Projectile.velocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.2f, 0.6f), 0, default, Main.rand.NextFloat(0.35f, 0.55f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, 89, -Projectile.velocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.2f, 0.6f), 0, default, Main.rand.NextFloat(0.5f, 0.8f)); dust.noGravity = true; - dust.color = Color.Black; dust.alpha = Main.rand.Next(90, 220 + 1); } } @@ -125,7 +124,7 @@ namespace CalamityMod.Projectiles.Typeless center.X = Projectile.Center.X + Projectile.velocity.X * 100f; center.Y = Projectile.Center.Y + Projectile.velocity.Y * 100f; } - float speed = 10f; + float speed = 8f; float velocityTweak = 0.30f; Vector2 projPos = Projectile.Center; Vector2 velocity = center - projPos; @@ -202,7 +201,11 @@ namespace CalamityMod.Projectiles.Typeless } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), (int)(Projectile.ai[1])); + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), (int)(Projectile.ai[1])); + Projectile.ai[0] = 15; + } public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), (int)(Projectile.ai[1])); diff --git a/Projectiles/Typeless/CoralBubble.cs b/Projectiles/Typeless/CoralBubble.cs index 35ffc0fa32..c3218486a7 100644 --- a/Projectiles/Typeless/CoralBubble.cs +++ b/Projectiles/Typeless/CoralBubble.cs @@ -20,6 +20,11 @@ namespace CalamityMod.Projectiles.Typeless Projectile.penetrate = 1; } + public override bool? CanCutTiles() + { + return false; + } + public override void AI() { if (Projectile.localAI[0] > 2f) diff --git a/Projectiles/Typeless/CoralBubbleSmall.cs b/Projectiles/Typeless/CoralBubbleSmall.cs index 9732d39497..1ab46a05b0 100644 --- a/Projectiles/Typeless/CoralBubbleSmall.cs +++ b/Projectiles/Typeless/CoralBubbleSmall.cs @@ -23,6 +23,11 @@ namespace CalamityMod.Projectiles.Typeless Projectile.penetrate = 1; } + public override bool? CanCutTiles() + { + return false; + } + public override void AI() { if (Projectile.localAI[0] > 2f) diff --git a/Projectiles/Typeless/FlameLickedBarrage.cs b/Projectiles/Typeless/FlameLickedBarrage.cs index 9cf48e17df..494f9b6096 100644 --- a/Projectiles/Typeless/FlameLickedBarrage.cs +++ b/Projectiles/Typeless/FlameLickedBarrage.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Typeless Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.tileCollide = false; - Projectile.penetrate = -1; + Projectile.penetrate = 3; Projectile.timeLeft = 300; Projectile.localNPCHitCooldown = -1; Projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Typeless/FlameLickedHellblast.cs b/Projectiles/Typeless/FlameLickedHellblast.cs index b9e0ee19ff..d9071df464 100644 --- a/Projectiles/Typeless/FlameLickedHellblast.cs +++ b/Projectiles/Typeless/FlameLickedHellblast.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Typeless Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.tileCollide = false; - Projectile.penetrate = -1; + Projectile.penetrate = 5; Projectile.timeLeft = 255; Projectile.localNPCHitCooldown = -1; Projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Typeless/LeviAmberDash.cs b/Projectiles/Typeless/LeviAmberDash.cs index 7e9848ebc4..627a1b1aad 100644 --- a/Projectiles/Typeless/LeviAmberDash.cs +++ b/Projectiles/Typeless/LeviAmberDash.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.CalPlayer; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -34,11 +35,13 @@ namespace CalamityMod.Projectiles.Typeless public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if (!target.boss && target.IsAnEnemy(true, true)) + bool isAPillar = target.type == NPCID.LunarTowerSolar || target.type == NPCID.LunarTowerVortex || target.type == NPCID.LunarTowerNebula || target.type == NPCID.LunarTowerStardust; + if (!isAPillar && !target.boss && target.IsAnEnemy(true, true) && !CalamityPlayer.areThereAnyDamnBosses && target.CanBeChasedBy(Projectile, false)) { target.velocity.Y += -1.8f; target.velocity.X += 4.2f * Owner.direction; } + target.AddBuff(BuffID.Wet, 300); target.AddBuff(ModContent.BuffType(), 180); SoundEngine.PlaySound(SoundID.Item85 with { Volume = 0.4f, PitchVariance = 0.4f }, Projectile.Center); diff --git a/Projectiles/Typeless/PauldronDash.cs b/Projectiles/Typeless/PauldronDash.cs index 6a17b3d5f8..04613c3e65 100644 --- a/Projectiles/Typeless/PauldronDash.cs +++ b/Projectiles/Typeless/PauldronDash.cs @@ -27,8 +27,8 @@ namespace CalamityMod.Projectiles.Typeless Projectile.tileCollide = false; Projectile.penetrate = 1; Projectile.timeLeft = 4; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 22; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) diff --git a/Projectiles/Typeless/PlaguePulse.cs b/Projectiles/Typeless/PlaguePulse.cs new file mode 100644 index 0000000000..c9439dbd73 --- /dev/null +++ b/Projectiles/Typeless/PlaguePulse.cs @@ -0,0 +1,99 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using CalamityMod.Particles; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework.Graphics; +using SteelSeries.GameSense; +using CalamityMod.Buffs.DamageOverTime; +using Mono.Cecil; + +namespace CalamityMod.Projectiles.Typeless +{ + public class PlaguePulse : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float time => ref Projectile.ai[0]; + public ref float radius => ref Projectile.ai[1]; + public float maxRadius = 300; + public int startDamage; + public override void SetDefaults() + { + Projectile.width = 96; + Projectile.height = 96; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 60; + Projectile.extraUpdates = 1; + Projectile.ignoreWater = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + if (time == 0) + startDamage = Projectile.damage; + + Player player = Main.player[Projectile.owner]; + if (Projectile.ai[2] == 0) + Projectile.Center = player.MountedCenter; + if (Projectile.ai[2] == 1) + { + maxRadius = 200; + } + + if (Main.rand.NextBool(5)) + { + DirectionalPulseRing pulse = new DirectionalPulseRing(Projectile.Center + Main.rand.NextVector2Circular(radius, radius), Vector2.Zero, (Main.rand.NextBool(3) ? Color.LimeGreen : Color.Green) * 0.6f, new Vector2(1, 1), 0, Main.rand.NextFloat(0.07f, 0.23f), 0f, 20); + GeneralParticleHandler.SpawnParticle(pulse); + } + if (Main.rand.NextBool(3)) + { + for (int i = 0; i < 2; i++) + { + int DustID = 89; + Vector2 spawnPos = Projectile.Center + Main.rand.NextVector2Circular(radius, radius); + Dust dust2 = Dust.NewDustPerfect(spawnPos, DustID); + dust2.scale = Main.rand.NextFloat(0.5f, 0.9f); + dust2.velocity = (spawnPos - Projectile.Center).SafeNormalize(Vector2.UnitX) * Main.rand.NextFloat(5, 10); + dust2.noGravity = true; + } + } + + radius = Utils.Remap(time, 0, 60, 30, maxRadius, true); + time++; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.85f); + if (Projectile.damage < 1) + Projectile.damage = 1; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + Player player = Main.player[Projectile.owner]; + target.AddBuff(ModContent.BuffType(), 420); + + if (target.life <= 0) + { + player.Heal(10); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(startDamage * 0.8f), 0f, Projectile.owner, 0, 0, 1); + } + } + public override bool PreDraw(ref Color lightColor) + { + Player player = Main.player[Projectile.owner]; + + Texture2D rexture = ModContent.Request("CalamityMod/Particles/HighResHollowCircleHardEdge").Value; + Main.EntitySpriteDraw(rexture, Projectile.Center - Main.screenPosition, null, (Color.Green * Utils.Remap(time, 30, 60, 0.35f, 0, true)) with { A = 0 }, Projectile.rotation, rexture.Size() * 0.5f, (Utils.Remap(time, 0, 60, 1, 6, true) / 21) * (maxRadius == 300 ? 1 : 0.7f), SpriteEffects.None, 0); + return false; + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, radius, targetHitbox); + } +} diff --git a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs index d8d5974075..1c2161af35 100644 --- a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs +++ b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs @@ -176,11 +176,8 @@ namespace CalamityMod.Projectiles.Typeless // Adjust the player's held projectile type. if (player.heldProj == -1) player.heldProj = Projectile.whoAmI; - if (player.mount != null) - { - player.mount.Dismount(player); - } - player.ChangeDir((int)Projectile.velocity.X); + player.mount?.Dismount(player); + player.ChangeDir(Math.Sign(Projectile.velocity.X) <= 0 ? -1 : 1); // Generate dust if (Projectile.ai[0] % DustSpawnInterval == DustSpawnInterval - 1f) { diff --git a/Skies/AstralSurfaceCloseGlow.png b/Skies/AstralSurfaceCloseGlow.png new file mode 100644 index 0000000000..3fafef6c36 Binary files /dev/null and b/Skies/AstralSurfaceCloseGlow.png differ diff --git a/Skies/AstralSurfaceFrontGlow.png b/Skies/AstralSurfaceFrontGlow.png new file mode 100644 index 0000000000..6fca957aaa Binary files /dev/null and b/Skies/AstralSurfaceFrontGlow.png differ diff --git a/Skies/AstralSurfaceMiddleGlow.png b/Skies/AstralSurfaceMiddleGlow.png new file mode 100644 index 0000000000..30f1c4e6d6 Binary files /dev/null and b/Skies/AstralSurfaceMiddleGlow.png differ diff --git a/Sounds/Custom/AbilitySounds/ChaosStateOver.ogg b/Sounds/Custom/AbilitySounds/ChaosStateOver.ogg index 8019d05fd4..cef7b85009 100644 Binary files a/Sounds/Custom/AbilitySounds/ChaosStateOver.ogg and b/Sounds/Custom/AbilitySounds/ChaosStateOver.ogg differ diff --git a/Sounds/Custom/BrimstoneElemental/BrimstoneDartRing1.ogg b/Sounds/Custom/BrimstoneElemental/BrimstoneDartRing1.ogg new file mode 100644 index 0000000000..e47a3981b8 Binary files /dev/null and b/Sounds/Custom/BrimstoneElemental/BrimstoneDartRing1.ogg differ diff --git a/Sounds/Custom/BrimstoneElemental/BrimstoneDartRing2.ogg b/Sounds/Custom/BrimstoneElemental/BrimstoneDartRing2.ogg new file mode 100644 index 0000000000..bdcf995c2a Binary files /dev/null and b/Sounds/Custom/BrimstoneElemental/BrimstoneDartRing2.ogg differ diff --git a/Sounds/Custom/BrimstoneElemental/BrimstoneDartRing3.ogg b/Sounds/Custom/BrimstoneElemental/BrimstoneDartRing3.ogg new file mode 100644 index 0000000000..162b20869b Binary files /dev/null and b/Sounds/Custom/BrimstoneElemental/BrimstoneDartRing3.ogg differ diff --git a/Sounds/Custom/BrimstoneElemental/Hellfireball1.ogg b/Sounds/Custom/BrimstoneElemental/Hellfireball1.ogg new file mode 100644 index 0000000000..9f106291d5 Binary files /dev/null and b/Sounds/Custom/BrimstoneElemental/Hellfireball1.ogg differ diff --git a/Sounds/Custom/BrimstoneElemental/Hellfireball2.ogg b/Sounds/Custom/BrimstoneElemental/Hellfireball2.ogg new file mode 100644 index 0000000000..caf4530364 Binary files /dev/null and b/Sounds/Custom/BrimstoneElemental/Hellfireball2.ogg differ diff --git a/Sounds/Custom/BrimstoneElemental/Hellfireball3.ogg b/Sounds/Custom/BrimstoneElemental/Hellfireball3.ogg new file mode 100644 index 0000000000..510d175b2d Binary files /dev/null and b/Sounds/Custom/BrimstoneElemental/Hellfireball3.ogg differ diff --git a/Sounds/Custom/BrimstoneElemental/ShellProjectiles1.ogg b/Sounds/Custom/BrimstoneElemental/ShellProjectiles1.ogg new file mode 100644 index 0000000000..03dcfa13a6 Binary files /dev/null and b/Sounds/Custom/BrimstoneElemental/ShellProjectiles1.ogg differ diff --git a/Sounds/Custom/BrimstoneElemental/ShellProjectiles2.ogg b/Sounds/Custom/BrimstoneElemental/ShellProjectiles2.ogg new file mode 100644 index 0000000000..266378f492 Binary files /dev/null and b/Sounds/Custom/BrimstoneElemental/ShellProjectiles2.ogg differ diff --git a/Sounds/Custom/BrimstoneElemental/ShellProjectiles3.ogg b/Sounds/Custom/BrimstoneElemental/ShellProjectiles3.ogg new file mode 100644 index 0000000000..44809fbe6a Binary files /dev/null and b/Sounds/Custom/BrimstoneElemental/ShellProjectiles3.ogg differ diff --git a/Sounds/Custom/BrimstoneElemental/ShellTransform.ogg b/Sounds/Custom/BrimstoneElemental/ShellTransform.ogg new file mode 100644 index 0000000000..55d2e0e2d3 Binary files /dev/null and b/Sounds/Custom/BrimstoneElemental/ShellTransform.ogg differ diff --git a/Sounds/Custom/BrimstoneElemental/Teleport.ogg b/Sounds/Custom/BrimstoneElemental/Teleport.ogg new file mode 100644 index 0000000000..f9328c68ac Binary files /dev/null and b/Sounds/Custom/BrimstoneElemental/Teleport.ogg differ diff --git a/Sounds/Custom/BuzzsawCharge.ogg b/Sounds/Custom/BuzzsawCharge.ogg new file mode 100644 index 0000000000..92db8cca71 Binary files /dev/null and b/Sounds/Custom/BuzzsawCharge.ogg differ diff --git a/Sounds/Custom/BuzzsawIdle.ogg b/Sounds/Custom/BuzzsawIdle.ogg new file mode 100644 index 0000000000..a9deb63893 Binary files /dev/null and b/Sounds/Custom/BuzzsawIdle.ogg differ diff --git a/Sounds/Custom/MetalPipeFalling.ogg b/Sounds/Custom/MetalPipeFalling.ogg new file mode 100644 index 0000000000..eaddb019f3 Binary files /dev/null and b/Sounds/Custom/MetalPipeFalling.ogg differ diff --git a/Sounds/Custom/MossMine.ogg b/Sounds/Custom/MossMine.ogg new file mode 100644 index 0000000000..dc05fe4cb8 Binary files /dev/null and b/Sounds/Custom/MossMine.ogg differ diff --git a/Sounds/Item/GunShotBig.ogg b/Sounds/Item/GunShotBig.ogg new file mode 100644 index 0000000000..b3a4c111d6 Binary files /dev/null and b/Sounds/Item/GunShotBig.ogg differ diff --git a/Sounds/Item/GunShotHeavy.ogg b/Sounds/Item/GunShotHeavy.ogg new file mode 100644 index 0000000000..b5f0892a2c Binary files /dev/null and b/Sounds/Item/GunShotHeavy.ogg differ diff --git a/Sounds/Item/GunShotMid.ogg b/Sounds/Item/GunShotMid.ogg new file mode 100644 index 0000000000..45d9fa7160 Binary files /dev/null and b/Sounds/Item/GunShotMid.ogg differ diff --git a/Sounds/Item/GunShotSmall.ogg b/Sounds/Item/GunShotSmall.ogg new file mode 100644 index 0000000000..4efc70fb90 Binary files /dev/null and b/Sounds/Item/GunShotSmall.ogg differ diff --git a/Sounds/Item/GunShotSmallAlt.ogg b/Sounds/Item/GunShotSmallAlt.ogg new file mode 100644 index 0000000000..62a992bc97 Binary files /dev/null and b/Sounds/Item/GunShotSmallAlt.ogg differ diff --git a/Sounds/Item/GunShotSmallHeavy.ogg b/Sounds/Item/GunShotSmallHeavy.ogg new file mode 100644 index 0000000000..b23c4ff131 Binary files /dev/null and b/Sounds/Item/GunShotSmallHeavy.ogg differ diff --git a/Sounds/Item/Heartbeat.ogg b/Sounds/Item/Heartbeat.ogg index b0121df73c..f0a789db21 100644 Binary files a/Sounds/Item/Heartbeat.ogg and b/Sounds/Item/Heartbeat.ogg differ diff --git a/Sounds/Item/NormalityRelocator1.ogg b/Sounds/Item/NormalityRelocator1.ogg new file mode 100644 index 0000000000..3e6e9fe76d Binary files /dev/null and b/Sounds/Item/NormalityRelocator1.ogg differ diff --git a/Sounds/Item/NormalityRelocator2.ogg b/Sounds/Item/NormalityRelocator2.ogg new file mode 100644 index 0000000000..8eda0629e6 Binary files /dev/null and b/Sounds/Item/NormalityRelocator2.ogg differ diff --git a/Sounds/Item/NormalityRelocator3.ogg b/Sounds/Item/NormalityRelocator3.ogg new file mode 100644 index 0000000000..32a445ca10 Binary files /dev/null and b/Sounds/Item/NormalityRelocator3.ogg differ diff --git a/Sounds/Item/SawShot1.ogg b/Sounds/Item/SawShot1.ogg new file mode 100644 index 0000000000..668e88c1f0 Binary files /dev/null and b/Sounds/Item/SawShot1.ogg differ diff --git a/Sounds/Item/SawShot2.ogg b/Sounds/Item/SawShot2.ogg new file mode 100644 index 0000000000..bbbd158d76 Binary files /dev/null and b/Sounds/Item/SawShot2.ogg differ diff --git a/Systems/BiomeTileCounterSystem.cs b/Systems/BiomeTileCounterSystem.cs index 252b0236de..4c96f125a0 100644 --- a/Systems/BiomeTileCounterSystem.cs +++ b/Systems/BiomeTileCounterSystem.cs @@ -4,6 +4,7 @@ using CalamityMod.Tiles.Astral; using CalamityMod.Tiles.AstralDesert; using CalamityMod.Tiles.AstralSnow; using CalamityMod.Tiles.Crags; +using CalamityMod.Tiles.FloralParadise; using CalamityMod.Tiles.DraedonStructures; using CalamityMod.Tiles.Ores; using CalamityMod.Tiles.SunkenSea; @@ -16,10 +17,15 @@ namespace CalamityMod.Systems { public static int BrimstoneCragTiles = 0; public static int SulphurTiles = 0; - public static int AbyssTiles = 0; public static int AstralTiles = 0; public static int SunkenSeaTiles = 0; + public static int SunkenSeaShoresTiles = 0; + public static int SunkenSeaPolypTiles = 0; + public static int SunkenSeaReefsTiles = 0; + public static int SunkenSeaBurrowsTiles = 0; public static int ArsenalLabTiles = 0; + public static int AbyssTiles = 0; + public static int FloralParadiseTiles = 0; public static int Layer1Tiles = 0; public static int Layer2Tiles = 0; @@ -31,6 +37,10 @@ namespace CalamityMod.Systems BrimstoneCragTiles = 0; AstralTiles = 0; SunkenSeaTiles = 0; + SunkenSeaShoresTiles = 0; + SunkenSeaPolypTiles = 0; + SunkenSeaReefsTiles = 0; + SunkenSeaBurrowsTiles = 0; SulphurTiles = 0; AbyssTiles = 0; ArsenalLabTiles = 0; @@ -39,14 +49,20 @@ namespace CalamityMod.Systems Layer2Tiles = 0; Layer3Tiles = 0; Layer4Tiles = 0; + FloralParadiseTiles = 0; } public override void TileCountsAvailable(ReadOnlySpan tileCounts) { BrimstoneCragTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; - SunkenSeaTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; + SunkenSeaTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; + SunkenSeaShoresTiles = tileCounts[ModContent.TileType()] + + tileCounts[ModContent.TileType()]; + SunkenSeaPolypTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; + SunkenSeaReefsTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; + SunkenSeaBurrowsTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; AbyssTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; SulphurTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; + FloralParadiseTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; ArsenalLabTiles = tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()] + tileCounts[ModContent.TileType()]; Layer1Tiles = tileCounts[ModContent.TileType()]; diff --git a/Systems/DifficultyModeSystem.cs b/Systems/DifficultyModeSystem.cs index 514d003dd5..afbfc41794 100644 --- a/Systems/DifficultyModeSystem.cs +++ b/Systems/DifficultyModeSystem.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Systems public static void CalculateDifficultyData() { MostAlternateDifficulties = 1; - Difficulties.OrderBy(d => d.DifficultyScale); + Difficulties = Difficulties.OrderBy(d => d.DifficultyScale).ToList(); //Difficulties are arranged in "tiers". This is done so that multiple mods can add their own alternate difficulties sharing a tier with the base ones DifficultyTiers = new List(); diff --git a/Systems/MusicEventSystem.cs b/Systems/MusicEventSystem.cs new file mode 100644 index 0000000000..803a27df18 --- /dev/null +++ b/Systems/MusicEventSystem.cs @@ -0,0 +1,310 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; +using CalamityMod.NPCs; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; + +namespace CalamityMod.Systems +{ + public record class MusicEventEntry(string Id, int Song, TimeSpan Length, TimeSpan IntroSilence, TimeSpan OutroSilence, Func ShouldPlay, Func Enabled); + + public class MusicEventSystem : ModSystem + { + #region Statics + + public static MusicEventEntry CurrentEvent { get; set; } = null; + + public static DateTime? TrackStart { get; set; } = null; + + // This allows for some additional silence at the end of a track + public static DateTime? TrackEnd { get; set; } = null; + + public static int LastPlayedEvent { get; set; } = -1; + + public static TimeSpan? OutroSilence { get; set; } = null; + + // This allows skipping track fade in + public static bool NoFade { get; set; } = false; + + public static Thread EventTrackerThread { get; set; } = null; + + public static List PlayedEvents { get; set; } = []; + + public static List EventCollection { get; set; } = []; + + // This is to make sure that old worlds don't immediately queue a bunch of tracks on player entry + private static bool oldWorld { get; set; } = true; + + #endregion + + #region Events List + + public override void OnModLoad() + { + static void AddEntry(string eventId, string songName, TimeSpan length, Func shouldPlay, Func enabled, TimeSpan? introSilence = null, TimeSpan? outroSilence = null) + { + MusicEventEntry entry = new(eventId, CalamityMod.Instance.GetMusicFromMusicMod(songName).Value, length, introSilence ?? TimeSpan.Zero, outroSilence ?? TimeSpan.Zero, shouldPlay, enabled); + EventCollection.Add(entry); + } + + AddEntry("CloneDefeated", "Interlude1", TimeSpan.FromSeconds(214.577d), + () => DownedBossSystem.downedCalamitasClone, () => CalamityConfig.Instance.Interlude1); + + AddEntry("MLDefeated", "Interlude2", TimeSpan.FromSeconds(191.912d), () => NPC.downedMoonlord, + () => CalamityConfig.Instance.Interlude2, outroSilence: TimeSpan.FromSeconds(1f)); + + // Alternative Interlude 2 -> AddEntry("MLDefeated", "Interlude2_CutIntro", TimeSpan.FromSeconds(160.989d), + // () => NPC.downedMoonlord, () => CalamityConfig.Instance.Interlude2, + // outroSilence: TimeSpan.FromSeconds(1f)); + + AddEntry("YharonDefeated", "Interlude3", TimeSpan.FromSeconds(295.932d), + () => DownedBossSystem.downedYharon, () => CalamityConfig.Instance.Interlude3); + + AddEntry("DoGDefeated", "DevourerofGodsEulogy", TimeSpan.FromSeconds(203.620d), + () => DownedBossSystem.downedDoG, () => CalamityConfig.Instance.DevourerofGodsEulogy, + introSilence: TimeSpan.FromSeconds(7.5f)); + + // Acceptance is NOT toggleable in the config + AddEntry("ScalDefeated", "CalamitasDefeat_LongFade", TimeSpan.FromSeconds(58.689d), + () => CalamityGlobalNPC.SCalAcceptance != -1, () => true); + } + + public override void Unload() => EventCollection.Clear(); + + #endregion + + #region Event Handling + + public override void PostUpdateTime() + { + // If the player has already completed conditions to trigger certain music events, we don't + // want to queue a bunch of tracks to play as soon as they enter the world, so instead just mark them as played + if (oldWorld) + { + foreach (MusicEventEntry entry in EventCollection) + { + if (entry.ShouldPlay()) + PlayedEvents.Add(entry.Id); + } + + oldWorld = false; + } + + //PlayedEvents.Remove("MLDefeated"); + + // If the event has just finished, we want a little silence before fading back to normal + if (TrackEnd is not null) + { + // `silence` is the time after a track ends before music goes back to normal + TimeSpan silence = OutroSilence.Value; + TimeSpan postTrack = DateTime.Now - TrackEnd.Value; + + // Play silence for the time specified + if (postTrack < silence) + { + int silenceSlot = MusicLoader.GetMusicSlot(Mod, "Sounds/Music/Silence"); + Main.musicBox2 = silenceSlot; + } + + else + { + LastPlayedEvent = -1; + TrackEnd = null; + OutroSilence = null; + } + + return; + } + + // Only check for new events to play if none is currently playing + // This makes sure events always finish before a new one starts + if (CurrentEvent is null) + { + foreach (MusicEventEntry musicEvent in EventCollection) + { + // Make sure the event hasn't already played and SHOULD play + if (!PlayedEvents.Contains(musicEvent.Id) && musicEvent.ShouldPlay()) + { + // Even if an event isn't marked as enabled, it should be counted + // as "played" so it isn't played when the player doesn't expect it + PlayedEvents.Add(musicEvent.Id); + + // Events are always enabled on the server + if (Main.dedServ || musicEvent.Enabled()) + { + // Assign the current event and start time + CurrentEvent = musicEvent; + TrackStart = DateTime.Now + musicEvent.IntroSilence; + + // On clients, use a background thread to make sure the track always plays for exactly + // the specified length, regardless of if the game gets minimized, lags, or time becomes + // detangled from a consistent 60fps in any other way + if (!Main.dedServ) + { + EventTrackerThread = new(WatchMusicEvent); + EventTrackerThread.Start(); + } + + break; + } + } + } + } + + if (TrackStart is not null) + { + if (TrackStart > DateTime.Now) + { + int silenceSlot = MusicLoader.GetMusicSlot(Mod, "Sounds/Music/Silence"); + Main.musicBox2 = silenceSlot; + NoFade = true; + } + + else + { + Main.musicBox2 = CurrentEvent.Song; + + if (NoFade) + { + Main.musicFade[CurrentEvent.Song] = 1f; + NoFade = false; + } + + // If the event has finished playing, mark the end as now and clear the current event + if (DateTime.Now - TrackStart >= CurrentEvent.Length) + { + int silenceSlot = MusicLoader.GetMusicSlot(Mod, "Sounds/Music/Silence"); + Main.musicBox2 = silenceSlot; + Main.musicFade[CurrentEvent.Song] = 0f; + + TrackEnd = DateTime.Now; + LastPlayedEvent = CurrentEvent.Song; + OutroSilence = CurrentEvent.OutroSilence; + + TrackStart = null; + CurrentEvent = null; + } + } + } + } + + /// + /// Watches for the game minimizing at any point, and adjusts the amount of time to play the song for accordingly + /// + public static void WatchMusicEvent() + { + DateTime? minimized = null; + + while (CurrentEvent is not null) + { + bool musicPaused = !Main.instance.IsActive; + + if (musicPaused && !minimized.HasValue) + minimized = DateTime.Now; + + else if (!musicPaused && minimized.HasValue) + { + TrackStart += DateTime.Now - minimized.Value; + minimized = null; + } + } + + EventTrackerThread = null; + } + + #endregion + + #region Event Saving + + public override void SaveWorldData(TagCompound tag) + { + tag["calamityPlayedMusicEventCount"] = PlayedEvents.Count; + for (int i = 0; i < PlayedEvents.Count; i++) + tag[$"calamityPlayedMusicEvent{i}"] = PlayedEvents[i]; + } + + public override void LoadWorldData(TagCompound tag) + { + PlayedEvents.Clear(); + + if (tag.TryGet("calamityPlayedMusicEventCount", out int playedMusicEventCount)) + { + for (int i = 0; i < playedMusicEventCount; i++) + { + if (tag.TryGet($"calamityPlayedMusicEvent{i}", out string playedEvent)) + PlayedEvents.Add(playedEvent); + } + } + + oldWorld = false; + } + + public override void OnWorldUnload() + { + oldWorld = true; + TrackStart = null; + TrackEnd = null; + CurrentEvent = null; + PlayedEvents.Clear(); + NoFade = false; + LastPlayedEvent = -1; + } + + #endregion + + #region Event Syncing + + public static void SendSyncRequest() + { + ModPacket packet = CalamityMod.Instance.GetPacket(); + packet.Write((byte)CalamityModMessageType.MusicEventSyncRequest); + packet.Send(); + } + + public static void FulfillSyncRequest(int requester) + { + // Only fulfill requests as the server host + if (!Main.dedServ) + return; + + ModPacket packet = CalamityMod.Instance.GetPacket(); + packet.Write((byte)CalamityModMessageType.MusicEventSyncResponse); + + int trackCount = PlayedEvents.Count; + packet.Write(trackCount); + + for (int i = 0; i < trackCount; i++) + packet.Write(PlayedEvents[i]); + + packet.Send(toClient: requester); + } + + public static void ReceiveSyncResponse(BinaryReader reader) + { + // Only receive info on clients + if (Main.dedServ) + return; + + PlayedEvents.Clear(); + int trackCount = reader.ReadInt32(); + + for (int i = 0; i < trackCount; i++) + PlayedEvents.Add(reader.ReadString()); + } + + #endregion + } + + public class CalamityModMusicEventPlayer : ModPlayer + { + public override void OnEnterWorld() + { + if (Main.netMode == NetmodeID.MultiplayerClient && Player.whoAmI != Main.myPlayer) + MusicEventSystem.SendSyncRequest(); + } + } +} diff --git a/Systems/WorldMiscUpdateSystem.cs b/Systems/WorldMiscUpdateSystem.cs index 074ff42332..c172445a7b 100644 --- a/Systems/WorldMiscUpdateSystem.cs +++ b/Systems/WorldMiscUpdateSystem.cs @@ -269,7 +269,7 @@ namespace CalamityMod.Systems { Tile tile = Main.tile[x, y]; bool growTile = !tile.HasTile && tile.LiquidAmount >= 128; - bool isSunkenSeaTile = tileType == ModContent.TileType() || tileType == ModContent.TileType() || tileType == ModContent.TileType(); + bool isSunkenSeaTile = tileType == ModContent.TileType() || tileType == ModContent.TileType(); bool meetsAdditionalGrowConditions = tile.Slope == SlopeType.Solid && !tile.IsHalfBlock && tile.LiquidType != LiquidID.Lava; if (growTile && meetsAdditionalGrowConditions) diff --git a/Systems/WorldgenManagementSystem.cs b/Systems/WorldgenManagementSystem.cs index 822a6dac34..36a6baef26 100644 --- a/Systems/WorldgenManagementSystem.cs +++ b/Systems/WorldgenManagementSystem.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using CalamityMod.Items.SummonItems; using CalamityMod.World; +using CalamityMod.World.Minibiomes; using CalamityMod.World.Planets; using Microsoft.Xna.Framework; using Terraria; @@ -57,6 +58,14 @@ namespace CalamityMod.Systems CustomTemple.NewJungleTemple(); }); + // Floral Paradise Biome + tasks.Insert(JungleTempleIndex + 1, new PassLegacy("FloralParadise", (progress, config) => + { + progress.Message = "Growing a floral paradise underground"; + if (FloralParadiseMinibiome.SHOULD_GENERATE) + FloralParadiseMinibiome.GenerateInstances(); + })); + // Improved Golem arena int JungleTempleIndex2 = tasks.FindIndex(genpass => genpass.Name.Equals("Temple")); tasks[JungleTempleIndex2] = new PassLegacy("Temple", (progress, config) => @@ -116,18 +125,26 @@ namespace CalamityMod.Systems })); } - // Sunken sea - int SunkenSeaIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Settle Liquids Again")); + // sunken sea + int SunkenSeaIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Cactus, Palm Trees, & Coral")); if (SunkenSeaIndex != -1) { tasks.Insert(SunkenSeaIndex + 1, new PassLegacy("Sunken Sea", (progress, config) => { progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.SunkenSea").Value; - int sunkenSeaX = GenVars.UndergroundDesertLocation.Left; - int sunkenSeaY = Main.maxTilesY - 400; + int sunkenSeaX = (GenVars.UndergroundDesertLocation.Left + GenVars.UndergroundDesertLocation.Right) / 2; + int sunkenSeaY = Main.maxTilesY / 2; - SunkenSea.Place(new Point(sunkenSeaX, sunkenSeaY)); + //place each piece of the sunken sea based on the above positons + SunkenSea.PlaceRadiantReefs(sunkenSeaX - 100, sunkenSeaY + 75, true); + SunkenSea.PlaceRadiantReefs(sunkenSeaX + 100, sunkenSeaY + 75, false); + SunkenSea.PlacePolypForest(sunkenSeaX, sunkenSeaY + 75); + SunkenSea.PlaceBasaltGully(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4)); + SunkenSea.PlaceGleamingBurrows(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4) - 50); + SunkenSea.PlaceSunkenSeaAmbience(); + SunkenSea.BasaltGullyLavaCleanup(sunkenSeaX, sunkenSeaY + (Main.maxTilesY / 4)); + SunkenSea.PlaceTimelessShores(sunkenSeaX, sunkenSeaY); })); } @@ -135,8 +152,9 @@ namespace CalamityMod.Systems int FinalIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Final Cleanup")); if (FinalIndex != -1) { - // Reallocate gems so rarity corresponds to depth int currentFinalIndex = FinalIndex; + + // Reallocate gems so rarity corresponds to depth tasks.Insert(++currentFinalIndex, new PassLegacy("Gem Depth Adjustment", (progress, config) => { progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.GemAdjustment").Value; @@ -272,6 +290,7 @@ namespace CalamityMod.Systems { progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.Abyss").Value; Abyss.PlaceAbyss(); + Abyss.AbyssCleanup(); })); // Sulphurous Sea (Part 2, after Abyss) diff --git a/Tiles/Abyss/AbyssAmbient/AbyssKelp.cs b/Tiles/Abyss/AbyssAmbient/AbyssKelp.cs index 780c4f5224..cea4527b3c 100644 --- a/Tiles/Abyss/AbyssAmbient/AbyssKelp.cs +++ b/Tiles/Abyss/AbyssAmbient/AbyssKelp.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient Main.tileNoAttach[Type] = true; Main.tileNoFail[Type] = true; Main.tileLavaDeath[Type] = true; - Main.tileWaterDeath[Type] = true; + Main.tileWaterDeath[Type] = false; Main.tileFrameImportant[Type] = true; TileID.Sets.ReplaceTileBreakUp[Type] = true; TileID.Sets.SwaysInWindBasic[Type] = true; @@ -35,6 +35,26 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient base.SetStaticDefaults(); } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + Tile tileBelow = Framing.GetTileSafely(i, j + 1); + int type = -1; + + if (tileBelow.HasTile) + { + type = tileBelow.TileType; + } + + if (type == ModContent.TileType() || type == ModContent.TileType()) + { + return true; + } + + WorldGen.KillTile(i, j); + + return true; + } + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) { offsetY = -16; diff --git a/Tiles/Abyss/AbyssAmbient/PhoviamareHalm.cs b/Tiles/Abyss/AbyssAmbient/PhoviamareHalm.cs index df321133ff..4e4ed2bf49 100644 --- a/Tiles/Abyss/AbyssAmbient/PhoviamareHalm.cs +++ b/Tiles/Abyss/AbyssAmbient/PhoviamareHalm.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient Main.tileNoAttach[Type] = true; Main.tileNoFail[Type] = true; Main.tileLavaDeath[Type] = true; - Main.tileWaterDeath[Type] = true; + Main.tileWaterDeath[Type] = false; Main.tileFrameImportant[Type] = true; TileID.Sets.ReplaceTileBreakUp[Type] = true; TileID.Sets.SwaysInWindBasic[Type] = true; diff --git a/Tiles/Abyss/AbyssAmbient/SulphurTentacleCorals.cs b/Tiles/Abyss/AbyssAmbient/SulphurTentacleCorals.cs index 50f56211b8..c8d77c9451 100644 --- a/Tiles/Abyss/AbyssAmbient/SulphurTentacleCorals.cs +++ b/Tiles/Abyss/AbyssAmbient/SulphurTentacleCorals.cs @@ -34,6 +34,26 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient base.SetStaticDefaults(); } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + Tile tileBelow = Framing.GetTileSafely(i, j + 1); + int type = -1; + + if (tileBelow.HasTile) + { + type = tileBelow.TileType; + } + + if (type == ModContent.TileType()) + { + return true; + } + + WorldGen.KillTile(i, j); + + return true; + } + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) { offsetY = -30; diff --git a/Tiles/Abyss/AbyssAmbient/TenebrisRemnant.cs b/Tiles/Abyss/AbyssAmbient/TenebrisRemnant.cs index a5a676ba0f..e69543aebd 100644 --- a/Tiles/Abyss/AbyssAmbient/TenebrisRemnant.cs +++ b/Tiles/Abyss/AbyssAmbient/TenebrisRemnant.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient Main.tileNoAttach[Type] = true; Main.tileNoFail[Type] = true; Main.tileLavaDeath[Type] = true; - Main.tileWaterDeath[Type] = true; + Main.tileWaterDeath[Type] = false; Main.tileFrameImportant[Type] = true; TileID.Sets.ReplaceTileBreakUp[Type] = true; TileID.Sets.SwaysInWindBasic[Type] = true; @@ -35,6 +35,26 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient base.SetStaticDefaults(); } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + Tile tileBelow = Framing.GetTileSafely(i, j + 1); + int type = -1; + + if (tileBelow.HasTile) + { + type = tileBelow.TileType; + } + + if (type == ModContent.TileType()) + { + return true; + } + + WorldGen.KillTile(i, j); + + return true; + } + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) { offsetY = -30; diff --git a/Tiles/Abyss/AbyssCoral.cs b/Tiles/Abyss/AbyssCoral.cs new file mode 100644 index 0000000000..29a66b7009 --- /dev/null +++ b/Tiles/Abyss/AbyssCoral.cs @@ -0,0 +1,54 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; +using Microsoft.Xna.Framework.Graphics; +using System; + +namespace CalamityMod.Tiles.Abyss +{ + public class AbyssCoral : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + Main.tileLighted[Type] = true; + + TileID.Sets.HasSlopeFrames[Type] = true; + + TileID.Sets.ChecksForMerge[Type] = true; + HitSound = SoundID.Dig; + DustType = 119; + AddMapEntry(new Color(70, 115, 144)); + Main.tileShine2[Type] = true; + + TileID.Sets.CanBeDugByShovel[Type] = true; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (!Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile) + { + float brightness = 0.9f; + Color Color1 = new Color(52, 84, 107); + Color Color2 = new Color(29, 38, 56); + Color value = Color.Lerp(Color1, Color2, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); + Color value1 = Color.Lerp(Color1, Color2, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); + r = (value.R + value1.R) / 300f; + g = (value.G + value1.G) / 300f; + b = (value.B + value1.B) / 300f; + r *= brightness; + g *= brightness; + b *= brightness; + } + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/Abyss/AbyssCoral.png b/Tiles/Abyss/AbyssCoral.png new file mode 100644 index 0000000000..de7a2145b0 Binary files /dev/null and b/Tiles/Abyss/AbyssCoral.png differ diff --git a/Tiles/Abyss/AbyssGravel.cs b/Tiles/Abyss/AbyssGravel.cs index 1754b7fc58..04d2dd8bb0 100644 --- a/Tiles/Abyss/AbyssGravel.cs +++ b/Tiles/Abyss/AbyssGravel.cs @@ -9,13 +9,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class AbyssGravel : ModTile, IMergeableTile + public class AbyssGravel : ModTile { int animationFrameWidth = 234; public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/AbyssGravelMine", 3); - - List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { diff --git a/Tiles/Abyss/Atoxicoral.png b/Tiles/Abyss/Atoxicoral.png new file mode 100644 index 0000000000..e3037845a0 Binary files /dev/null and b/Tiles/Abyss/Atoxicoral.png differ diff --git a/Tiles/Abyss/HardenedSulphurousSandstone.cs b/Tiles/Abyss/HardenedSulphurousSandstone.cs index e7f7eeb788..f48079fad5 100644 --- a/Tiles/Abyss/HardenedSulphurousSandstone.cs +++ b/Tiles/Abyss/HardenedSulphurousSandstone.cs @@ -8,10 +8,8 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class HardenedSulphurousSandstone : ModTile, IMergeableTile + public class HardenedSulphurousSandstone : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Abyss/PlantyMush.cs b/Tiles/Abyss/PlantyMush.cs index f80d61113a..52fa770985 100644 --- a/Tiles/Abyss/PlantyMush.cs +++ b/Tiles/Abyss/PlantyMush.cs @@ -14,11 +14,9 @@ namespace CalamityMod.Tiles.Abyss { // Transforms any and all Tenebris in old worlds into planty mush. [LegacyName("Tenebris")] - public class PlantyMush : ModTile, IMergeableTile + public class PlantyMush : ModTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/PlantyMushMine", 3); - - List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { diff --git a/Tiles/Abyss/PyreMantle.cs b/Tiles/Abyss/PyreMantle.cs index 12d1cd6f9c..90da582ec4 100644 --- a/Tiles/Abyss/PyreMantle.cs +++ b/Tiles/Abyss/PyreMantle.cs @@ -11,12 +11,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class PyreMantle : ModTile, IMergeableTile + public class PyreMantle : ModTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3) { Volume = 0.4f }; - - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Abyss/PyreMantleMolten.cs b/Tiles/Abyss/PyreMantleMolten.cs index 74c659b73f..9fe87dc7c4 100644 --- a/Tiles/Abyss/PyreMantleMolten.cs +++ b/Tiles/Abyss/PyreMantleMolten.cs @@ -11,13 +11,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class PyreMantleMolten : ModTile, IMergeableTile + public class PyreMantleMolten : ModTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3) { Volume = 0.4f }; internal static Texture2D GlowTexture; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { if (!Main.dedServ) diff --git a/Tiles/Abyss/SulphurCoral.png b/Tiles/Abyss/SulphurCoral.png new file mode 100644 index 0000000000..5bd7eeb270 Binary files /dev/null and b/Tiles/Abyss/SulphurCoral.png differ diff --git a/Tiles/Abyss/SulphurousSand.cs b/Tiles/Abyss/SulphurousSand.cs index c0e83d585a..3dbc1957d9 100644 --- a/Tiles/Abyss/SulphurousSand.cs +++ b/Tiles/Abyss/SulphurousSand.cs @@ -16,10 +16,8 @@ namespace CalamityMod.Tiles.Abyss // It would create block swap issues with regular sulphurous sand and was rendered obsolete with the removal of this tile's water emission mechanic. // For compatibility reasons (including with schematics), however, that tile is converted into this one. [LegacyName("SulphurousSandNoWater")] - public class SulphurousSand : ModTile, IMergeableTile + public class SulphurousSand : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Abyss/SulphurousSandstone.cs b/Tiles/Abyss/SulphurousSandstone.cs index 5b2c948dfe..692a04edbc 100644 --- a/Tiles/Abyss/SulphurousSandstone.cs +++ b/Tiles/Abyss/SulphurousSandstone.cs @@ -8,10 +8,8 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class SulphurousSandstone : ModTile, IMergeableTile + public class SulphurousSandstone : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Abyss/SulphurousShale.cs b/Tiles/Abyss/SulphurousShale.cs index c4652868ac..dbd4219573 100644 --- a/Tiles/Abyss/SulphurousShale.cs +++ b/Tiles/Abyss/SulphurousShale.cs @@ -1,11 +1,6 @@ -//using CalamityMod.Tiles.Abyss.AbyssAmbient; -using System; -using System.Collections.Generic; -using CalamityMod.Tiles.Abyss.AbyssAmbient; +using CalamityMod.Tiles.Abyss.AbyssAmbient; using CalamityMod.World; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -13,14 +8,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class SulphurousShale : ModTile, IMergeableTile + public class SulphurousShale : ModTile { int animationFrameWidth = 234; public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/AbyssGravelMine", 3); - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Abyss/ViperVines.cs b/Tiles/Abyss/ViperVines.cs index 3e26bd5505..d3ce6d3043 100644 --- a/Tiles/Abyss/ViperVines.cs +++ b/Tiles/Abyss/ViperVines.cs @@ -61,48 +61,39 @@ namespace CalamityMod.Tiles.Abyss } public override void RandomUpdate(int i, int j) - { - if (Main.tile[i, j + 1] != null) + { + Tile tileBelow = Framing.GetTileSafely(i, j + 1); + if (WorldGen.genRand.NextBool(5) && !tileBelow.HasTile && tileBelow.LiquidType != LiquidID.Lava) { - if (!Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType != (ushort)ModContent.TileType()) + bool PlaceVine = false; + int Test = j; + while (Test > j - 10) { - if (Main.tile[i, j + 1].LiquidAmount >= 128 && Main.tile[i, j + 1].LiquidType != LiquidID.Lava) + Tile testTile = Framing.GetTileSafely(i, Test); + if (testTile.BottomSlope) { - bool canGrowVine = false; - for (int k = j; k > j - 10; j--) - { - if (Main.tile[i, k].BottomSlope) - { - canGrowVine = false; - break; - } - if (Main.tile[i, k].HasTile && !Main.tile[i, k].BottomSlope) - { - canGrowVine = true; - break; - } - } - if (canGrowVine) - { - int vineX = i; - int vineY = j + 1; - Main.tile[vineX, vineY].TileType = (ushort)ModContent.TileType(); - Main.tile[vineX, vineY].TileFrameX = (short)(WorldGen.genRand.Next(8) * 18); - Main.tile[vineX, vineY].TileFrameY = (short)(4 * 18); - Main.tile[vineX, vineY - 1].TileFrameX = (short)(WorldGen.genRand.Next(12) * 18); - Main.tile[vineX, vineY - 1].TileFrameY = (short)(WorldGen.genRand.Next(4) * 18); - Main.tile[vineX, vineY].Get().HasTile = true; - WorldGen.SquareTileFrame(vineX, vineY, true); - WorldGen.SquareTileFrame(vineX, vineY - 1, true); - if (Main.netMode == NetmodeID.Server) - { - NetMessage.SendTileSquare(-1, vineX, vineY, 3, TileChangeType.None); - NetMessage.SendTileSquare(-1, vineX, vineY - 1, 3, TileChangeType.None); - } - } - } - } - } - } + break; + } + else if (!testTile.HasTile || testTile.TileType != ModContent.TileType()) + { + Test--; + continue; + } + PlaceVine = true; + break; + } + + if (PlaceVine) + { + tileBelow.TileType = Type; + tileBelow.HasTile = true; + WorldGen.SquareTileFrame(i, j + 1, true); + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, i, j + 1, 3, TileChangeType.None); + } + } + } + } } } diff --git a/Tiles/Abyss/Voidstone.cs b/Tiles/Abyss/Voidstone.cs index 45f6f30719..8d859cad1f 100644 --- a/Tiles/Abyss/Voidstone.cs +++ b/Tiles/Abyss/Voidstone.cs @@ -11,12 +11,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class Voidstone : ModTile, IMergeableTile + public class Voidstone : ModTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3) { Volume = 0.4f }; internal static Texture2D GlowTexture; - - List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { diff --git a/Tiles/AerialiteBrick.cs b/Tiles/AerialiteBrick.cs index 73a3990d3f..d5df1c8c04 100644 --- a/Tiles/AerialiteBrick.cs +++ b/Tiles/AerialiteBrick.cs @@ -7,10 +7,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class AerialiteBrick : ModTile, IMergeableTile + public class AerialiteBrick : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Astral/AstralClay.cs b/Tiles/Astral/AstralClay.cs index d5afdd919e..b84e3de8ab 100644 --- a/Tiles/Astral/AstralClay.cs +++ b/Tiles/Astral/AstralClay.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { - public class AstralClay : ModTile, IMergeableTile + public class AstralClay : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Astral/AstralDirt.cs b/Tiles/Astral/AstralDirt.cs index 4cd269dab8..18ff19942a 100644 --- a/Tiles/Astral/AstralDirt.cs +++ b/Tiles/Astral/AstralDirt.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { - public class AstralDirt : ModTile, IMergeableTile + public class AstralDirt : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Astral/AstralMonolith.cs b/Tiles/Astral/AstralMonolith.cs index 9724660bfb..1ce58af87c 100644 --- a/Tiles/Astral/AstralMonolith.cs +++ b/Tiles/Astral/AstralMonolith.cs @@ -10,13 +10,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { - public class AstralMonolith : ModTile, IMergeableTile + public class AstralMonolith : ModTile { private static int sheetWidth = 216; private static int sheetHeight = 72; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Astral/AstralShortPlants.cs b/Tiles/Astral/AstralShortPlants.cs index 2aa49d66a1..33f5e65517 100644 --- a/Tiles/Astral/AstralShortPlants.cs +++ b/Tiles/Astral/AstralShortPlants.cs @@ -33,6 +33,26 @@ namespace CalamityMod.Tiles.Astral base.SetStaticDefaults(); } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + Tile tileBelow = Framing.GetTileSafely(i, j + 1); + int type = -1; + + if (tileBelow.HasTile) + { + type = tileBelow.TileType; + } + + if (type == ModContent.TileType()) + { + return true; + } + + WorldGen.KillTile(i, j); + + return true; + } + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) { offsetY = 2; diff --git a/Tiles/Astral/AstralStone.cs b/Tiles/Astral/AstralStone.cs index 5d4eb9f993..75f1648019 100644 --- a/Tiles/Astral/AstralStone.cs +++ b/Tiles/Astral/AstralStone.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { - public class AstralStone : ModTile, IMergeableTile + public class AstralStone : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Astral/NovaeSlag.cs b/Tiles/Astral/NovaeSlag.cs index 60fd932b1d..b8fda17830 100644 --- a/Tiles/Astral/NovaeSlag.cs +++ b/Tiles/Astral/NovaeSlag.cs @@ -11,10 +11,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { [LegacyName("AstralSilt")] - public class NovaeSlag : ModTile, IMergeableTile + public class NovaeSlag : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/AstralBrick.cs b/Tiles/AstralBrick.cs index 3af5cfe613..17921c8fcb 100644 --- a/Tiles/AstralBrick.cs +++ b/Tiles/AstralBrick.cs @@ -9,13 +9,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class AstralBrick : ModTile, IMergeableTile + public class AstralBrick : ModTile { private const short subsheetWidth = 324; private const short subsheetHeight = 90; - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/AstralDesert/AstralSand.cs b/Tiles/AstralDesert/AstralSand.cs index b93e3e27db..1d49d41226 100644 --- a/Tiles/AstralDesert/AstralSand.cs +++ b/Tiles/AstralDesert/AstralSand.cs @@ -11,10 +11,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralDesert { - public class AstralSand : ModTile, IMergeableTile + public class AstralSand : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/AstralDesert/AstralSandstone.cs b/Tiles/AstralDesert/AstralSandstone.cs index 026c0bf2df..12389f0650 100644 --- a/Tiles/AstralDesert/AstralSandstone.cs +++ b/Tiles/AstralDesert/AstralSandstone.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralDesert { - public class AstralSandstone : ModTile, IMergeableTile + public class AstralSandstone : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/AstralDesert/CelestialRemains.cs b/Tiles/AstralDesert/CelestialRemains.cs index 515e549546..984b7f9937 100644 --- a/Tiles/AstralDesert/CelestialRemains.cs +++ b/Tiles/AstralDesert/CelestialRemains.cs @@ -10,10 +10,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralDesert { [LegacyName("AstralFossil")] - public class CelestialRemains : ModTile, IMergeableTile + public class CelestialRemains : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/AstralDesert/HardenedAstralSand.cs b/Tiles/AstralDesert/HardenedAstralSand.cs index 0918cabd0a..1c2a7d92d0 100644 --- a/Tiles/AstralDesert/HardenedAstralSand.cs +++ b/Tiles/AstralDesert/HardenedAstralSand.cs @@ -8,10 +8,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralDesert { - public class HardenedAstralSand : ModTile, IMergeableTile + public class HardenedAstralSand : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/AstralSnow/AstralIce.cs b/Tiles/AstralSnow/AstralIce.cs index a339f14e98..767b6e94dd 100644 --- a/Tiles/AstralSnow/AstralIce.cs +++ b/Tiles/AstralSnow/AstralIce.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralSnow { - public class AstralIce : ModTile, IMergeableTile + public class AstralIce : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/AstralSnow/AstralSnow.cs b/Tiles/AstralSnow/AstralSnow.cs index 6ab01d8390..27b8b2a29e 100644 --- a/Tiles/AstralSnow/AstralSnow.cs +++ b/Tiles/AstralSnow/AstralSnow.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralSnow { - public class AstralSnow : ModTile, IMergeableTile + public class AstralSnow : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/BaseTiles/BranchDrawer.cs b/Tiles/BaseTiles/BranchDrawer.cs new file mode 100644 index 0000000000..9f331ddd07 --- /dev/null +++ b/Tiles/BaseTiles/BranchDrawer.cs @@ -0,0 +1,373 @@ +using Terraria; +using System.Linq; +using System.Collections.Generic; +using CalamityMod.DataStructures; +using Terraria.Utilities; +using Microsoft.Xna.Framework; +using System; +using Microsoft.Xna.Framework.Graphics; +using Terraria.ID; +using Terraria.DataStructures; +using Terraria.ObjectData; +using Terraria.Enums; + +namespace CalamityMod.Tiles.BaseTiles +{ + public class BranchDrawer + { + public class Branch + { + public BezierCurve Curve; + + public Vector2 EndOfCurve; + + public float Direction; + + public float CurveLength; + + public float StartingWidth; + + public float EndingWidth; + + public Branch PreviousBranch = null; + + public int Generation + { + get + { + int generation = 0; + var parent = PreviousBranch; + while (parent != null) + { + parent = parent.PreviousBranch; + generation++; + } + + return generation; + } + } + + public Branch(BezierCurve curve, Vector2 end, float length, float direction, float startWidth, float endWidth, Branch previousBranch = null) + { + Curve = curve; + EndOfCurve = end; + CurveLength = length; + Direction = direction; + StartingWidth = startWidth; + EndingWidth = endWidth; + PreviousBranch = previousBranch; + } + } + + internal BasicEffect basicShader = null; + + internal Point PreviousPoint; + + internal VertexPositionColorTexture[] vertexCache = Array.Empty(); + + internal short[] indexCache = Array.Empty(); + + internal UnifiedRandom RNG = new(0); + + public BasicEffect BasicShader + { + get + { + if (Main.netMode != NetmodeID.Server && basicShader is null) + { + basicShader = new BasicEffect(Main.instance.GraphicsDevice) + { + VertexColorEnabled = true, + TextureEnabled = true + }; + } + return basicShader; + } + } + + public static int GetSeed(int x, int y) => unchecked(x * 55867 + y * 49311329 + WorldGen.currentWorldSeed.GetHashCode()); + + public Texture2D BarkTexture; + + // The max amount that branches can travel. Once the distance of the branches reaches or exceeds this threshold, the tree is done growing. + public float MaxDistanceBeforeCutoff; + + public float DistanceUsedForTrunk; + + public float BranchMaxBendFactor; + + public float BranchTurnAngleVariance; + + // The shortest possible length a branch can have. + public float MinBranchLength; + + // The width of the trunk. Successive branches have a dynamic, random width, but the trunk should be static. + public float TrunkWidth; + + // Chance to create new branches instead of extending existing ones. + public float ChanceToCreateNewBranches; + + public float VerticalStretchFactor; + + public float DownwardBiasFactor; + + public float BranchGrowthWidthDecay; + + public int MaxCutoffBranchesPerBranch; + + public const int ControlPointCountPerBranch = 8; + + public virtual void DrawThingAtEndOfBranch(Branch branch) { } + + public Dictionary> GenerateBranches(Point p) + { + RNG = new(GetSeed(p.X, p.Y)); + float cutoffDistance = MaxDistanceBeforeCutoff; + float trunkDirection = RNG.NextFloatDirection() * BranchTurnAngleVariance * 0.1f - MathHelper.PiOver2; + float trunkSize = RNG.NextFloat(-8f, 8f) + DistanceUsedForTrunk; + float distanceTraversed = trunkSize; + Vector2 startOfTrunk = Vector2.UnitY * 10f; + Vector2 endOfTrunk = startOfTrunk + trunkDirection.ToRotationVector2() * trunkSize; + Branch trunk = GenerateBranchCurve(startOfTrunk, endOfTrunk, TrunkWidth, TrunkWidth); + Dictionary> existingBranches = new() + { + [trunk] = new() + }; + + void extendLengthOfBranch(Branch branch, float lengthToAdd) + { + branch.CurveLength += lengthToAdd; + branch.EndOfCurve += branch.Direction.ToRotationVector2() * lengthToAdd; + + // Add the new length to all branches that exist on the current one, ones extented to each of them, and so on. + foreach (Branch attachedBranch in existingBranches[branch]) + extendLengthOfBranch(attachedBranch, lengthToAdd); + } + + int tries = 0; + while (distanceTraversed < cutoffDistance) + { + // Prevent infinite loops if conditions do not permit the distance traveled to reach its maximum. + tries++; + if (tries >= 1500) + break; + + // Sometimes simply extend an existing branch instead of creating new ones. + if (RNG.NextFloat() > ChanceToCreateNewBranches) + { + List potentialBranchesToExtend = existingBranches.Where(b => b.Key.CurveLength < trunkSize * 0.4f && b.Key.CurveLength > MinBranchLength).Select(b => b.Key).ToList(); + if (potentialBranchesToExtend.Count <= 0) + continue; + + Branch branchToExtend = RNG.Next(potentialBranchesToExtend); + + float lengthToAdd = branchToExtend.CurveLength * 0.12f; + extendLengthOfBranch(branchToExtend, lengthToAdd); + distanceTraversed += lengthToAdd; + continue; + } + + // Pick a random branch to attach to and determine the properties of the potential next one. + List validBranches = existingBranches.Where(b => b.Value.Count < MaxCutoffBranchesPerBranch && b.Key.EndingWidth >= 6f).Select(b => b.Key).ToList(); + if (validBranches.Count <= 0) + continue; + + Branch branchToAttachTo = RNG.Next(validBranches); + float maxBranchAngleVariance = BranchTurnAngleVariance * (branchToAttachTo == trunk ? 2.1f : 1f); + float directionOfNextBranch = branchToAttachTo.Direction + RNG.NextFloatDirection() * maxBranchAngleVariance; + float downwardBiasFactor = DownwardBiasFactor; + float downwardBiasFromGeneration = Utils.Remap(branchToAttachTo.Generation, 0f, 5f, 0f, 0.8f); + downwardBiasFactor = MathHelper.Clamp(downwardBiasFactor + downwardBiasFromGeneration, 0f, 0.95f); + + if (downwardBiasFactor > 0f && branchToAttachTo != trunk) + { + float randomBias = RNG.NextFloat(0.67f, 1f) * downwardBiasFactor; + directionOfNextBranch = Vector2.Lerp(directionOfNextBranch.ToRotationVector2(), Vector2.UnitY, randomBias).ToRotation(); + } + + // Try not to create a branch with a direction very similar to other branches attached to the one that this one will attach to. + if (existingBranches[branchToAttachTo].Count >= 1 && + existingBranches[branchToAttachTo].Any(b => b.Direction.ToRotationVector2().AngleBetween(directionOfNextBranch.ToRotationVector2()) < 0.12f)) + { + continue; + } + + float lengthOfNextBranch = MathHelper.Max(MinBranchLength, branchToAttachTo.CurveLength * RNG.NextFloat(0.5f, 0.925f)); + + Vector2 start = branchToAttachTo.EndOfCurve; + Vector2 end = start + directionOfNextBranch.ToRotationVector2() * lengthOfNextBranch; + + // Try not to create branches in already crowded areas. + if (validBranches.Count(b => MathHelper.Distance(b.EndOfCurve.Y, end.Y) < 50f) >= 4f) + continue; + + Branch newBranch = GenerateBranchCurve(start, end, branchToAttachTo.EndingWidth, branchToAttachTo.EndingWidth * BranchGrowthWidthDecay, branchToAttachTo); + + // Create the new branch in the dictionary and make the old branch count count as having one extra branch attached. + existingBranches[branchToAttachTo].Add(newBranch); + existingBranches[newBranch] = new(); + + // Add to traversed distance. + distanceTraversed += lengthOfNextBranch; + } + + // Go back and make all end branches have a small end width. + foreach (Branch branch in existingBranches.Where(b => b.Value.Count <= 0).Select(b => b.Key)) + branch.EndingWidth = MathHelper.Min(3f, branch.EndingWidth); + + return existingBranches; + } + + public void GetVertexData(Point p, out List vertices, out List indices, out IEnumerable outwardmostBranches) + { + // Initialize vertex and index data. + vertices = new(); + indices = new(); + + // Determine branch data. + var branchData = GenerateBranches(p); + var branches = branchData.Select(b => b.Key); + outwardmostBranches = branchData.Where(b => b.Value.Count <= 0f).Select(b => b.Key); + + // Generate vertex data. + int batchIndex = 0; + Vector2 screenOffset = (p.ToWorldCoordinates() - Main.screenPosition).Floor(); + Texture2D barkTexture = BarkTexture; + foreach (Branch branch in branches.OrderBy(b => b.EndOfCurve.Y)) + { + int pointCount = 12; + List smoothenedPoints = branch.Curve.GetPoints(pointCount + 1); + Vector2? prevBottomLeft = null; + Vector2? prevBottomRight = null; + if (branch.PreviousBranch != null) + { + Vector2 previousOrthogonalDirection = (branch.PreviousBranch.Direction + MathHelper.PiOver2).ToRotationVector2(); + prevBottomLeft = branch.PreviousBranch.EndOfCurve + previousOrthogonalDirection * branch.PreviousBranch.EndingWidth * 0.5f; + prevBottomRight = branch.PreviousBranch.EndOfCurve - previousOrthogonalDirection * branch.PreviousBranch.EndingWidth * 0.5f; + } + + for (int i = 0; i < pointCount; i++) + { + Vector2 top = smoothenedPoints[i]; + Vector2 bottom = smoothenedPoints[i + 1]; + float topCompletionRatio = i / (float)pointCount; + float bottomCompletionRatio = (i + 1) / (float)pointCount; + if (i == pointCount - 1f) + { + topCompletionRatio = 1f; + bottomCompletionRatio = 1f; + bottom = branch.EndOfCurve; + } + + // Calculate frame coordinates. + // This sucked to make. + float topWidth = MathHelper.Lerp(branch.StartingWidth, branch.EndingWidth, topCompletionRatio); + float bottomWidth = MathHelper.Lerp(branch.StartingWidth, branch.EndingWidth, bottomCompletionRatio); + float topTexCoord = branch.CurveLength * topCompletionRatio / VerticalStretchFactor / barkTexture.Height; + float bottomTexCoord = branch.CurveLength * bottomCompletionRatio / VerticalStretchFactor / barkTexture.Height; + if (VerticalStretchFactor <= 0f) + { + topTexCoord = topWidth; + bottomTexCoord = bottomWidth; + } + float stretchedHorizontalCoordTop = topWidth / barkTexture.Width; + float stretchedHorizontalCoordBottom = bottomWidth / barkTexture.Width; + if (topWidth > barkTexture.Width * 0.5f) + stretchedHorizontalCoordTop = 1f; + if (bottomWidth > barkTexture.Width * 0.5f) + stretchedHorizontalCoordBottom = 1f; + + // Calculate texture coordinates. + Vector2 topLeftTexCoord = new(stretchedHorizontalCoordTop, topTexCoord); + Vector2 topRightTexCoord = new(0f, topTexCoord); + Vector2 bottomLeftTexCoord = new(stretchedHorizontalCoordBottom, bottomTexCoord); + Vector2 bottomRightTexCoord = new(0f, bottomTexCoord); + + // Calculate draw coordinates. + Vector2 orthogonalDirection = (bottom - top).SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.PiOver2); + Vector2 topLeft = prevBottomLeft ?? top + orthogonalDirection * topWidth * 0.5f; + Vector2 topRight = prevBottomRight ?? top - orthogonalDirection * topWidth * 0.5f; + Vector2 bottomLeft = bottom + orthogonalDirection * bottomWidth * 0.5f; + Vector2 bottomRight = bottom - orthogonalDirection * bottomWidth * 0.5f; + + // Calculate lighting colors. + Vector2 lightOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(-Main.offScreenRange); + Color topLeftColor = Lighting.GetColor((topLeft + p.ToWorldCoordinates() + lightOffset).ToTileCoordinates()); + Color topRightColor = Lighting.GetColor((topRight + p.ToWorldCoordinates() + lightOffset).ToTileCoordinates()); + Color bottomLeftColor = Lighting.GetColor((bottomLeft + p.ToWorldCoordinates() + lightOffset).ToTileCoordinates()); + Color bottomRightColor = Lighting.GetColor((bottomRight + p.ToWorldCoordinates() + lightOffset).ToTileCoordinates()); + + vertices.Add(new VertexPositionColorTexture(new Vector3(topLeft.Floor() + screenOffset, 0f), topLeftColor, topLeftTexCoord)); + vertices.Add(new VertexPositionColorTexture(new Vector3(topRight.Floor() + screenOffset, 0f), topRightColor, topRightTexCoord)); + vertices.Add(new VertexPositionColorTexture(new Vector3(bottomRight.Floor() + screenOffset, 0f), bottomRightColor, bottomRightTexCoord)); + vertices.Add(new VertexPositionColorTexture(new Vector3(bottomLeft.Floor() + screenOffset, 0f), bottomLeftColor, bottomLeftTexCoord)); + + indices.Add((short)(batchIndex * 4)); + indices.Add((short)(batchIndex * 4 + 1)); + indices.Add((short)(batchIndex * 4 + 2)); + indices.Add((short)(batchIndex * 4)); + indices.Add((short)(batchIndex * 4 + 2)); + indices.Add((short)(batchIndex * 4 + 3)); + + prevBottomLeft = bottomLeft; + prevBottomRight = bottomRight; + + batchIndex++; + } + } + } + + public void Draw(Point p) + { + // Declare the vertex cache. + GetVertexData(p, out var vertices, out var indices, out IEnumerable outwardmostBranches); + vertexCache = vertices.ToArray(); + indexCache = indices.ToArray(); + PreviousPoint = p; + + // Redefine the perspective matrices of the shader. + CalamityUtils.CalculatePerspectiveMatricies(out Matrix effectView, out Matrix effectProjection); + BasicShader.Texture = BarkTexture; + BasicShader.View = effectView; + BasicShader.Projection = effectProjection; + + // Draw the tree itself. + Main.instance.GraphicsDevice.Textures[0] = BarkTexture; + Main.instance.GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap; + Main.instance.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexCache, 0, vertexCache.Length, indexCache, 0, indexCache.Length / 3); + + // Draw things at the end of branches. + foreach (Branch outwardmostBranch in outwardmostBranches) + DrawThingAtEndOfBranch(outwardmostBranch); + } + + public void UseDefaultSize() + { + TileObjectData.newTile.Width = (int)Math.Ceiling(TrunkWidth / 16); + TileObjectData.newTile.Height = (int)Math.Ceiling(DistanceUsedForTrunk / 16); + TileObjectData.newTile.Origin = new Point16(TileObjectData.newTile.Width / 2, TileObjectData.newTile.Height - 1); + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateHeights = Enumerable.Repeat(16, TileObjectData.newTile.Height).ToArray(); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 2; + } + + public Branch GenerateBranchCurve(Vector2 start, Vector2 end, float startWidth, float endWidth, Branch previousBranch = null) + { + float distanceBetweenPoints = Vector2.Distance(start, end); + Vector2[] initialPoints = new Vector2[ControlPointCountPerBranch]; + Vector2 orthogonalDirection = (end - start).SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.PiOver2); + for (int i = 0; i < ControlPointCountPerBranch; i++) + initialPoints[i] = Vector2.Lerp(start, end, i / (float)(ControlPointCountPerBranch - 1f)); + + // Create a bend midway. + float bendFactor = (float)Math.Pow(RNG.NextFloat(), 0.66) * RNG.NextBool().ToDirectionInt() * BranchMaxBendFactor; + bendFactor = MathHelper.Lerp(bendFactor, Math.Sign(bendFactor) * BranchMaxBendFactor, Utils.GetLerpValue(DistanceUsedForTrunk * 0.4f, DistanceUsedForTrunk * 0.75f, distanceBetweenPoints, true)); + + initialPoints[ControlPointCountPerBranch / 2] += orthogonalDirection * RNG.NextFloatDirection() * distanceBetweenPoints * bendFactor; + + return new(new(initialPoints), end, distanceBetweenPoints, (end - start).ToRotation(), startWidth, endWidth, previousBranch); + } + } +} diff --git a/Tiles/BaseTiles/DynamicallyGrownTree.cs b/Tiles/BaseTiles/DynamicallyGrownTree.cs new file mode 100644 index 0000000000..e4a3882f33 --- /dev/null +++ b/Tiles/BaseTiles/DynamicallyGrownTree.cs @@ -0,0 +1,144 @@ +using Terraria; +using Terraria.ModLoader; +using System.Linq; +using Microsoft.Xna.Framework; +using System; +using Microsoft.Xna.Framework.Graphics; +using Terraria.ID; +using Terraria.DataStructures; +using Terraria.ObjectData; +using Terraria.Enums; +using ReLogic.Content; +using Terraria.Utilities; + +namespace CalamityMod.Tiles.BaseTiles +{ + public abstract class DynamicallyGrownTree : ModTile + { + public BranchDrawer BranchDrawer + { + get; + internal set; + } = null; + + public abstract float MaxDistanceBeforeCutoff { get; } + + public abstract float DistanceUsedForTrunk { get; } + + public abstract float BranchMaxBendFactor { get; } + + public abstract float BranchTurnAngleVariance { get; } + + public abstract float MinBranchLength { get; } + + public abstract float TrunkWidth { get; } + + public abstract float ChanceToCreateNewBranches { get; } + + public abstract float VerticalStretchFactor { get; } + + public abstract float DownwardBiasFactor { get; } + + public abstract float BranchGrowthWidthDecay { get; } + + public abstract int MaxCutoffBranchesPerBranch { get; } + + internal int ItemDrop; + + public const int ControlPointCountPerBranch = 8; + + public UnifiedRandom RNG => BranchDrawer.RNG; + + public override void Load() + { + BranchDrawer = new() + { + MaxDistanceBeforeCutoff = MaxDistanceBeforeCutoff, + DistanceUsedForTrunk = DistanceUsedForTrunk, + BranchMaxBendFactor = BranchMaxBendFactor, + BranchTurnAngleVariance = BranchTurnAngleVariance, + MinBranchLength = MinBranchLength, + TrunkWidth = TrunkWidth, + ChanceToCreateNewBranches = ChanceToCreateNewBranches, + VerticalStretchFactor = VerticalStretchFactor, + DownwardBiasFactor = DownwardBiasFactor, + BranchGrowthWidthDecay = BranchGrowthWidthDecay, + MaxCutoffBranchesPerBranch = MaxCutoffBranchesPerBranch + }; + + if (Main.netMode != NetmodeID.Server) + BranchDrawer.BarkTexture = ModContent.Request(Texture, AssetRequestMode.ImmediateLoad).Value; + } + + public virtual void DrawThingAtEndOfBranch(BranchDrawer.Branch branch) { } + + public void Draw(Point p) + { + // This is necessary to ensure that the primitives properly render. + TileID.Sets.DrawTileInSolidLayer[Type] = true; + BranchDrawer.Draw(p); + + // Determine branch data. + var branchData = BranchDrawer.GenerateBranches(p); + var branches = branchData.Select(b => b.Key); + var outwardmostBranches = branchData.Where(b => b.Value.Count <= 0f).Select(b => b.Key); + + // Draw things at the end of branches. + foreach (BranchDrawer.Branch outwardmostBranch in outwardmostBranches) + DrawThingAtEndOfBranch(outwardmostBranch); + } + + public void UseDefaultSize() + { + TileObjectData.newTile.Width = (int)Math.Ceiling(TrunkWidth / 16); + TileObjectData.newTile.Height = (int)Math.Ceiling(DistanceUsedForTrunk / 16); + TileObjectData.newTile.Origin = new Point16(TileObjectData.newTile.Width / 2, TileObjectData.newTile.Height - 1); + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateHeights = Enumerable.Repeat(16, TileObjectData.newTile.Height).ToArray(); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 2; + } + + public override bool CanDrop(int i, int j) => false; + + public override void KillMultiTile(int x, int y, int frameX, int frameY) + { + var branchData = BranchDrawer.GenerateBranches(new(x, y)); + var branches = branchData.Select(b => b.Key); + foreach (var branch in branches) + { + int totalWood = (int)Math.Ceiling(branch.CurveLength / 56f); + int totalDust = totalWood * 3; + int stack = Main.rand.Next(1, 3); + for (int i = 0; i < totalWood; i++) + { + Vector2 woodPosition = branch.Curve.Evaluate(i / (float)(totalWood - 1f)); + woodPosition += new Vector2(x, y).ToWorldCoordinates() + Main.rand.NextVector2Circular(10f, 10f); + woodPosition.Y += DistanceUsedForTrunk; + Item.NewItem(new EntitySource_TileBreak(x, y), woodPosition, ItemDrop); + } + + // Create dust. + for (int i = 0; i < totalDust; i++) + { + Vector2 dustPosition = branch.Curve.Evaluate(i / (float)(totalDust - 1f)); + dustPosition += new Vector2(x, y).ToWorldCoordinates() + Main.rand.NextVector2Circular(5f, 5f); + dustPosition.Y += DistanceUsedForTrunk; + Dust.NewDustDirect(dustPosition, 4, 4, DustType); + } + } + } + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + Tile t = CalamityUtils.ParanoidTileRetrieval(i, j); + if (t.TileFrameX != 0 || t.TileFrameY != ((int)Math.Ceiling(DistanceUsedForTrunk / 16) - 1) * 18) + return false; + + Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Draw(new(i + (int)screenOffset.X / 16, j + (int)screenOffset.Y / 16)); + return false; + } + } +} diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index d3bdbfd406..77280fa602 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -15,6 +15,7 @@ using CalamityMod.Tiles.DraedonStructures; using CalamityMod.Tiles.DraedonSummoner; using CalamityMod.Tiles.Furniture.CraftingStations; using CalamityMod.Tiles.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -54,6 +55,8 @@ namespace CalamityMod.Tiles { ModContent.TileType(), ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), ModContent.TileType() }; @@ -63,11 +66,6 @@ namespace CalamityMod.Tiles Main.tileOreFinderPriority[TileID.LunarOre] = 900; } - public override bool PreHitWire(int i, int j, int type) - { - return !BossRushEvent.BossRushActive; - } - public override bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak) { // Custom plant framing diff --git a/Tiles/CosmiliteBarTile.cs b/Tiles/CosmiliteBarTile.cs index ec0f584276..7ecfadf556 100644 --- a/Tiles/CosmiliteBarTile.cs +++ b/Tiles/CosmiliteBarTile.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria.ModLoader; namespace CalamityMod.Tiles @@ -18,5 +19,10 @@ namespace CalamityMod.Tiles type = ModContent.DustType(); return true; } + + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + return false; + } } } diff --git a/Tiles/Crags/BrimstoneSlab.cs b/Tiles/Crags/BrimstoneSlab.cs index 04d2cd4666..61ff7a8d59 100644 --- a/Tiles/Crags/BrimstoneSlab.cs +++ b/Tiles/Crags/BrimstoneSlab.cs @@ -9,13 +9,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags { - public class BrimstoneSlab : ModTile, IMergeableTile + public class BrimstoneSlab : ModTile { private int subsheetWidth = 450; private int subsheetHeight = 198; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Crags/BrimstoneSlag.cs b/Tiles/Crags/BrimstoneSlag.cs index 3a1a485968..b63f9e0daa 100644 --- a/Tiles/Crags/BrimstoneSlag.cs +++ b/Tiles/Crags/BrimstoneSlag.cs @@ -8,13 +8,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags { - public class BrimstoneSlag : ModTile, IMergeableTile + public class BrimstoneSlag : ModTile { private const short subsheetWidth = 450; private const short subsheetHeight = 198; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Crags/CinderBlossomTallPlants.cs b/Tiles/Crags/CinderBlossomTallPlants.cs index 4fb65d3700..77d71ff212 100644 --- a/Tiles/Crags/CinderBlossomTallPlants.cs +++ b/Tiles/Crags/CinderBlossomTallPlants.cs @@ -34,6 +34,26 @@ namespace CalamityMod.Tiles.Crags base.SetStaticDefaults(); } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + Tile tileBelow = Framing.GetTileSafely(i, j + 1); + int type = -1; + + if (tileBelow.HasTile) + { + type = tileBelow.TileType; + } + + if (type == ModContent.TileType()) + { + return true; + } + + WorldGen.KillTile(i, j); + + return true; + } + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) { offsetY = -30; diff --git a/Tiles/Crags/LavaPistil.cs b/Tiles/Crags/LavaPistil.cs index c026fb1293..8b2b419784 100644 --- a/Tiles/Crags/LavaPistil.cs +++ b/Tiles/Crags/LavaPistil.cs @@ -36,6 +36,26 @@ namespace CalamityMod.Tiles.Crags base.SetStaticDefaults(); } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + Tile tileBelow = Framing.GetTileSafely(i, j + 1); + int type = -1; + + if (tileBelow.HasTile) + { + type = tileBelow.TileType; + } + + if (type == ModContent.TileType()) + { + return true; + } + + WorldGen.KillTile(i, j); + + return true; + } + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) { offsetY = -128; diff --git a/Tiles/Crags/ScorchedBone.cs b/Tiles/Crags/ScorchedBone.cs index 9a875a0ff7..540a6774d7 100644 --- a/Tiles/Crags/ScorchedBone.cs +++ b/Tiles/Crags/ScorchedBone.cs @@ -8,13 +8,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags { - public class ScorchedBone : ModTile, IMergeableTile + public class ScorchedBone : ModTile { private int sheetWidth = 450; private int sheetHeight = 198; - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Crags/ScorchedRemains.cs b/Tiles/Crags/ScorchedRemains.cs index 74f47d6744..065de6ee5c 100644 --- a/Tiles/Crags/ScorchedRemains.cs +++ b/Tiles/Crags/ScorchedRemains.cs @@ -8,13 +8,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags { - public class ScorchedRemains : ModTile, IMergeableTile + public class ScorchedRemains : ModTile { private int sheetWidth = 234; private int sheetHeight = 90; - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Crags/ScorchedRemainsGrass.cs b/Tiles/Crags/ScorchedRemainsGrass.cs index a83fa18de3..5cf19faafc 100644 --- a/Tiles/Crags/ScorchedRemainsGrass.cs +++ b/Tiles/Crags/ScorchedRemainsGrass.cs @@ -10,15 +10,13 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags { - public class ScorchedRemainsGrass : ModTile, IMergeableTile + public class ScorchedRemainsGrass : ModTile { private const short subsheetWidth = 234; private const short subsheetHeight = 90; private int extraFrameHeight = 36; private int extraFrameWidth = 90; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/CryonicBrick.cs b/Tiles/CryonicBrick.cs index 96c010298a..cd7dbfeaa2 100644 --- a/Tiles/CryonicBrick.cs +++ b/Tiles/CryonicBrick.cs @@ -7,13 +7,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class CryonicBrick : ModTile, IMergeableTile + public class CryonicBrick : ModTile { int subsheetHeight = 90; int subsheetWidth = 234; - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/DraedonStructures/AgedReinforcedCrate.cs b/Tiles/DraedonStructures/AgedReinforcedCrate.cs index 6ff4190e16..826777407f 100644 --- a/Tiles/DraedonStructures/AgedReinforcedCrate.cs +++ b/Tiles/DraedonStructures/AgedReinforcedCrate.cs @@ -19,6 +19,7 @@ namespace CalamityMod.Tiles.DraedonStructures Main.tileNoAttach[Type] = true; Main.tileLavaDeath[Type] = false; Main.tileWaterDeath[Type] = false; + Main.tileTable[Type] = true; Main.tileSolidTop[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.newTile.LavaDeath = false; diff --git a/Tiles/DraedonStructures/LaboratoryPanels.cs b/Tiles/DraedonStructures/LaboratoryPanels.cs index 61724a0d54..d63549d56c 100644 --- a/Tiles/DraedonStructures/LaboratoryPanels.cs +++ b/Tiles/DraedonStructures/LaboratoryPanels.cs @@ -8,12 +8,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.DraedonStructures { - public class LaboratoryPanels : ModTile, IMergeableTile + public class LaboratoryPanels : ModTile { public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/DraedonStructures/LaboratoryPipePlating.cs b/Tiles/DraedonStructures/LaboratoryPipePlating.cs index 963d4ed162..d7ec964a52 100644 --- a/Tiles/DraedonStructures/LaboratoryPipePlating.cs +++ b/Tiles/DraedonStructures/LaboratoryPipePlating.cs @@ -8,12 +8,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.DraedonStructures { - public class LaboratoryPipePlating : ModTile, IMergeableTile + public class LaboratoryPipePlating : ModTile { public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/DraedonStructures/LaboratoryPlating.cs b/Tiles/DraedonStructures/LaboratoryPlating.cs index 9f6e1c8f72..c778e72cba 100644 --- a/Tiles/DraedonStructures/LaboratoryPlating.cs +++ b/Tiles/DraedonStructures/LaboratoryPlating.cs @@ -8,12 +8,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.DraedonStructures { - public class LaboratoryPlating : ModTile, IMergeableTile + public class LaboratoryPlating : ModTile { public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/DraedonStructures/ReinforcedCrate.cs b/Tiles/DraedonStructures/ReinforcedCrate.cs index 114871a032..06b9c32ffe 100644 --- a/Tiles/DraedonStructures/ReinforcedCrate.cs +++ b/Tiles/DraedonStructures/ReinforcedCrate.cs @@ -19,6 +19,7 @@ namespace CalamityMod.Tiles.DraedonStructures Main.tileNoAttach[Type] = true; Main.tileLavaDeath[Type] = false; Main.tileWaterDeath[Type] = false; + Main.tileTable[Type] = true; Main.tileSolidTop[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.newTile.LavaDeath = false; diff --git a/Tiles/DraedonStructures/RustedPlating.cs b/Tiles/DraedonStructures/RustedPlating.cs index 44eff8e23b..3dac585830 100644 --- a/Tiles/DraedonStructures/RustedPlating.cs +++ b/Tiles/DraedonStructures/RustedPlating.cs @@ -8,12 +8,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.DraedonStructures { - public class RustedPlating : ModTile, IMergeableTile + public class RustedPlating : ModTile { public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/FloralParadise/AlgalSlate.cs b/Tiles/FloralParadise/AlgalSlate.cs new file mode 100644 index 0000000000..da26933f6f --- /dev/null +++ b/Tiles/FloralParadise/AlgalSlate.cs @@ -0,0 +1,41 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class AlgalSlate : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileBrick[Type] = true; + TileID.Sets.Stone[Type] = true; + TileID.Sets.Conversion.Stone[Type] = true; + TileID.Sets.CanBeClearedDuringOreRunner[Type] = false; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithOres(Type); + CalamityUtils.MergeWithFloralParadise(Type); + + DustType = 78; + + HitSound = SoundID.Tink; + + AddMapEntry(new Color(33, 56, 27)); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + TileFraming.CustomMergeFrame(i, j, Type, TileID.Dirt, false, false, false, true); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FloralParadise/AlgalSlate.png b/Tiles/FloralParadise/AlgalSlate.png new file mode 100644 index 0000000000..86f7743da6 Binary files /dev/null and b/Tiles/FloralParadise/AlgalSlate.png differ diff --git a/Tiles/FloralParadise/BloodOrangePlant.cs b/Tiles/FloralParadise/BloodOrangePlant.cs new file mode 100644 index 0000000000..667236043e --- /dev/null +++ b/Tiles/FloralParadise/BloodOrangePlant.cs @@ -0,0 +1,41 @@ +using CalamityMod.Items.PermanentBoosters; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class BloodOrangePlant : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.addTile(Type); + + DustType = 6; + + AddMapEntry(new Color(250, 142, 4)); + } + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 16, 16, ModContent.ItemType()); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/FloralParadise/BloodOrangePlant.png b/Tiles/FloralParadise/BloodOrangePlant.png new file mode 100644 index 0000000000..c954393284 Binary files /dev/null and b/Tiles/FloralParadise/BloodOrangePlant.png differ diff --git a/Tiles/FloralParadise/LargeLogPiles.cs b/Tiles/FloralParadise/LargeLogPiles.cs new file mode 100644 index 0000000000..fefea2c7ea --- /dev/null +++ b/Tiles/FloralParadise/LargeLogPiles.cs @@ -0,0 +1,49 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class LargeLogPiles : ModTile + { + public const int Variants = 2; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.Width = 3; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(1, 2); + TileObjectData.newTile.CoordinateHeights = new int[] + { + 16, + 16, + 16 + }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + + TileObjectData.addTile(Type); + + DustType = 38; + + AddMapEntry(new Color(114, 72, 49)); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/FloralParadise/LargeLogPiles.png b/Tiles/FloralParadise/LargeLogPiles.png new file mode 100644 index 0000000000..e343f8254a Binary files /dev/null and b/Tiles/FloralParadise/LargeLogPiles.png differ diff --git a/Tiles/FloralParadise/LargeMossPiles.cs b/Tiles/FloralParadise/LargeMossPiles.cs new file mode 100644 index 0000000000..bc5e786f47 --- /dev/null +++ b/Tiles/FloralParadise/LargeMossPiles.cs @@ -0,0 +1,48 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class LargeMossPiles : ModTile + { + public const int Variants = 4; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.Width = 3; + TileObjectData.newTile.Height = 2; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new int[] + { + 16, + 16 + }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.RandomStyleRange = Variants; + TileObjectData.addTile(Type); + + DustType = 38; + + AddMapEntry(new Color(56, 56, 56)); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/FloralParadise/LargeMossPiles.png b/Tiles/FloralParadise/LargeMossPiles.png new file mode 100644 index 0000000000..ee20cf395a Binary files /dev/null and b/Tiles/FloralParadise/LargeMossPiles.png differ diff --git a/Tiles/FloralParadise/LargeSubterraneanGrass.cs b/Tiles/FloralParadise/LargeSubterraneanGrass.cs new file mode 100644 index 0000000000..d9b38f6785 --- /dev/null +++ b/Tiles/FloralParadise/LargeSubterraneanGrass.cs @@ -0,0 +1,48 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class LargeSubterraneanGrass : ModTile + { + public const int Variants = 5; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.Width = 3; + TileObjectData.newTile.Height = 2; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new int[] + { + 16, + 16 + }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.RandomStyleRange = Variants; + TileObjectData.addTile(Type); + + DustType = 39; + + AddMapEntry(new Color(106, 163, 74)); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/FloralParadise/LargeSubterraneanGrass.png b/Tiles/FloralParadise/LargeSubterraneanGrass.png new file mode 100644 index 0000000000..4069f95cae Binary files /dev/null and b/Tiles/FloralParadise/LargeSubterraneanGrass.png differ diff --git a/Tiles/FloralParadise/LargeWallFungi.cs b/Tiles/FloralParadise/LargeWallFungi.cs new file mode 100644 index 0000000000..e345cac254 --- /dev/null +++ b/Tiles/FloralParadise/LargeWallFungi.cs @@ -0,0 +1,43 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class LargeWallFungi : ModTile + { + public const int Variants = 3; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 2; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new int[] + { + 16, + 16 + }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; + TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, 2, 0); + TileObjectData.newTile.RandomStyleRange = Variants; + TileObjectData.addTile(Type); + DustType = 0; + + AddMapEntry(new Color(165, 126, 84)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FloralParadise/LargeWallFungi.png b/Tiles/FloralParadise/LargeWallFungi.png new file mode 100644 index 0000000000..89c0975133 Binary files /dev/null and b/Tiles/FloralParadise/LargeWallFungi.png differ diff --git a/Tiles/FloralParadise/LargeWallFungiLeft.cs b/Tiles/FloralParadise/LargeWallFungiLeft.cs new file mode 100644 index 0000000000..e2f84a907b --- /dev/null +++ b/Tiles/FloralParadise/LargeWallFungiLeft.cs @@ -0,0 +1,43 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class LargeWallFungiLeft : ModTile + { + public const int Variants = 3; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 2; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new int[] + { + 16, + 16 + }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; + TileObjectData.newTile.AnchorLeft = new AnchorData(AnchorType.SolidTile, 2, 0); + TileObjectData.newTile.RandomStyleRange = Variants; + TileObjectData.addTile(Type); + DustType = 0; + + AddMapEntry(new Color(165, 126, 84)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FloralParadise/LargeWallFungiLeft.png b/Tiles/FloralParadise/LargeWallFungiLeft.png new file mode 100644 index 0000000000..8e765ea7fd Binary files /dev/null and b/Tiles/FloralParadise/LargeWallFungiLeft.png differ diff --git a/Tiles/FloralParadise/LushVines.cs b/Tiles/FloralParadise/LushVines.cs new file mode 100644 index 0000000000..eeb8817853 --- /dev/null +++ b/Tiles/FloralParadise/LushVines.cs @@ -0,0 +1,95 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class LushVines : ModTile + { + public override void SetStaticDefaults() + { + Main.tileCut[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileFrameImportant[Type] = true; + AddMapEntry(new Color(47, 75, 32)); + HitSound = SoundID.Grass; + DustType = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + if (WorldGen.genRand.NextBool(2) && Main.player[(int)Player.FindClosest(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16)].cordage) + Item.NewItem(new EntitySource_TileBreak(i, j), new Vector2(i * 16 + 8f, j * 16 + 8f), ItemID.VineRope); + + if (Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType == Type) + { + WorldGen.KillTile(i, j + 1, false, false, false); + if (!Main.tile[i, j + 1].HasTile && Main.netMode != NetmodeID.SinglePlayer) + { + NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, (float)i, (float)j + 1, 0f, 0, 0, 0); + } + } + + if (Main.tile[i, j - 1].HasTile && Main.tile[i, j - 1].TileType == Type) + { + Main.tile[i, j - 1].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); + Main.tile[i, j - 1].TileFrameY = 54; + if (Main.netMode != NetmodeID.SinglePlayer) + NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, (float)i, (float)j + 1, 0f, 0, 0, 0); + } + } + + public override void RandomUpdate(int i, int j) + { + if (Main.tile[i, j + 1] != null) + { + if (!Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType != Type) + { + if (Main.tile[i, j + 1].LiquidAmount >= 128 && Main.tile[i, j + 1].LiquidType == LiquidID.Water) + { + bool canGrow = false; + for (int y = j; y > j - 10; j--) + { + if (Main.tile[i, y].BottomSlope) + { + canGrow = false; + break; + } + if (Main.tile[i, y].HasTile && !Main.tile[i, y].BottomSlope) + { + canGrow = true; + break; + } + } + if (canGrow) + { + int below = j + 1; + Main.tile[i, below].TileType = Type; + Main.tile[i, below].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); + Main.tile[i, below].TileFrameY = 54; + Main.tile[i, below - 1].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); + Main.tile[i, below - 1].TileFrameY = (short)(WorldGen.genRand.Next(3) * 18); + Main.tile[i, below].Get().HasTile = true; + WorldGen.SquareTileFrame(i, below, true); + WorldGen.SquareTileFrame(i, below - 1, true); + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, i, below, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, i, below - 1, 3, TileChangeType.None); + } + } + } + } + } + } + } +} diff --git a/Tiles/FloralParadise/LushVines.png b/Tiles/FloralParadise/LushVines.png new file mode 100644 index 0000000000..2ef0db6a25 Binary files /dev/null and b/Tiles/FloralParadise/LushVines.png differ diff --git a/Tiles/FloralParadise/MediumFloralPlants.cs b/Tiles/FloralParadise/MediumFloralPlants.cs new file mode 100644 index 0000000000..bd764bb33b --- /dev/null +++ b/Tiles/FloralParadise/MediumFloralPlants.cs @@ -0,0 +1,56 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class MediumFloralPlants : ModTile + { + public const int Variants = 8; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileCut[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 2; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new int[] + { + 16, + 16 + }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.RandomStyleRange = Variants; + TileObjectData.addTile(Type); + + HitSound = SoundID.Grass; + DustType = 2; + AddMapEntry(new Color(106, 135, 69)); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (CalamityUtils.ParanoidTileRetrieval(i, j).LiquidAmount > 64) + WorldGen.KillTile(i, j); + } + } +} diff --git a/Tiles/FloralParadise/MediumFloralPlants.png b/Tiles/FloralParadise/MediumFloralPlants.png new file mode 100644 index 0000000000..643c9e94cc Binary files /dev/null and b/Tiles/FloralParadise/MediumFloralPlants.png differ diff --git a/Tiles/FloralParadise/MediumLargeMossPiles.cs b/Tiles/FloralParadise/MediumLargeMossPiles.cs new file mode 100644 index 0000000000..7af71e6c7f --- /dev/null +++ b/Tiles/FloralParadise/MediumLargeMossPiles.cs @@ -0,0 +1,49 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class MediumLargeMossPiles : ModTile + { + public const int Variants = 4; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 2; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new int[] + { + 16, + 16 + }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.RandomStyleRange = Variants; + + TileObjectData.addTile(Type); + + DustType = 38; + + AddMapEntry(new Color(56, 56, 56)); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/FloralParadise/MediumLargeMossPiles.png b/Tiles/FloralParadise/MediumLargeMossPiles.png new file mode 100644 index 0000000000..cbf4ace032 Binary files /dev/null and b/Tiles/FloralParadise/MediumLargeMossPiles.png differ diff --git a/Tiles/FloralParadise/MediumMossPiles.cs b/Tiles/FloralParadise/MediumMossPiles.cs new file mode 100644 index 0000000000..5094b14dfa --- /dev/null +++ b/Tiles/FloralParadise/MediumMossPiles.cs @@ -0,0 +1,37 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class MediumMossPiles : ModTile + { + public const int Variants = 4; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.RandomStyleRange = Variants; + TileObjectData.addTile(Type); + + DustType = 38; + + AddMapEntry(new Color(56, 56, 56)); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/FloralParadise/MediumMossPiles.png b/Tiles/FloralParadise/MediumMossPiles.png new file mode 100644 index 0000000000..05ca5e1d5f Binary files /dev/null and b/Tiles/FloralParadise/MediumMossPiles.png differ diff --git a/Tiles/FloralParadise/Peat.cs b/Tiles/FloralParadise/Peat.cs new file mode 100644 index 0000000000..b65eba8b6d --- /dev/null +++ b/Tiles/FloralParadise/Peat.cs @@ -0,0 +1,39 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class Peat : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileBrick[Type] = true; + TileID.Sets.Stone[Type] = true; + TileID.Sets.Conversion.Stone[Type] = true; + TileID.Sets.CanBeClearedDuringOreRunner[Type] = false; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithOres(Type); + CalamityUtils.MergeWithFloralParadise(Type); + + DustType = 78; + + AddMapEntry(new Color(72, 91, 47)); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + TileFraming.CustomMergeFrame(i, j, Type, TileID.Dirt, false, false, false, true); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FloralParadise/Peat.png b/Tiles/FloralParadise/Peat.png new file mode 100644 index 0000000000..2ebbd88951 Binary files /dev/null and b/Tiles/FloralParadise/Peat.png differ diff --git a/Tiles/FloralParadise/PeatMoss.cs b/Tiles/FloralParadise/PeatMoss.cs new file mode 100644 index 0000000000..b92e58ecff --- /dev/null +++ b/Tiles/FloralParadise/PeatMoss.cs @@ -0,0 +1,116 @@ +using CalamityMod.Projectiles.Environment; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class PeatMoss : ModTile + { + public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/MossMine"); + + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileBrick[Type] = true; + + TileID.Sets.Grass[Type] = true; + TileID.Sets.NeedsGrassFraming[Type] = true; + TileID.Sets.NeedsGrassFramingDirt[Type] = ModContent.TileType(); + TileID.Sets.Conversion.Grass[Type] = true; + + CalamityUtils.SetMerge(Type, TileID.Dirt); + CalamityUtils.SetMerge(Type, TileID.Grass); + CalamityUtils.SetMerge(Type, TileID.CorruptGrass); + CalamityUtils.SetMerge(Type, TileID.HallowedGrass); + CalamityUtils.SetMerge(Type, TileID.CrimsonGrass); + CalamityUtils.MergeWithFloralParadise(Type); + + DustType = 39; + HitSound = MineSound; + + AddMapEntry(new Color(65, 142, 101)); + } + + 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].TileType = (ushort)ModContent.TileType(); + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (WorldGen.genRand.NextBool(60) && !Main.gamePaused && CalamityUtils.ParanoidTileRetrieval(i, j - 1).LiquidAmount >= 200) + { + Vector2 algaeVelocity = -Vector2.UnitY.RotatedByRandom(0.91f) * Main.rand.NextFloat(0.85f, 1.6f); + Projectile.NewProjectile(new EntitySource_WorldEvent(), new Vector2(i + 0.5f, j - 0.5f) * 16f, algaeVelocity, ModContent.ProjectileType(), 0, 0f); + } + } + + public override void RandomUpdate(int i, int j) + { + int num8 = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + Main.maxTilesY * 0.143)); + int nearbyVineCount = 0; + for (int x = i - 15; x <= i + 15; x++) + { + for (int y = j - 15; y <= j + 15; y++) + { + if (WorldGen.InWorld(x, y)) + { + if (CalamityUtils.ParanoidTileRetrieval(x, y).HasTile && + CalamityUtils.ParanoidTileRetrieval(x, y).TileType == (ushort)ModContent.TileType()) + { + nearbyVineCount++; + } + } + } + } + if (Main.tile[i, j + 1] != null && nearbyVineCount < 5) + { + if (!Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType != (ushort)ModContent.TileType()) + { + if (Main.tile[i, j + 1].LiquidAmount == 255 && + Main.tile[i, j + 1].LiquidType == LiquidID.Water) + { + bool growMoss = false; + for (int y = num8; y > num8 - 10; y--) + { + if (Main.tile[i, y].BottomSlope) + { + growMoss = false; + break; + } + if (Main.tile[i, y].HasTile && !Main.tile[i, y].BottomSlope) + { + growMoss = true; + break; + } + } + if (growMoss) + { + int belowY = j + 1; + Main.tile[i, belowY].TileType = (ushort)ModContent.TileType(); + Main.tile[i, belowY].Get().HasTile = true; + WorldGen.SquareTileFrame(i, belowY, true); + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, i, belowY, 3, TileChangeType.None); + } + } + Main.tile[i, j].Get().Slope = SlopeType.Solid; + Main.tile[i, j].Get().IsHalfBlock = false; + } + } + } + } + } +} diff --git a/Tiles/FloralParadise/PeatMoss.png b/Tiles/FloralParadise/PeatMoss.png new file mode 100644 index 0000000000..8a38476c20 Binary files /dev/null and b/Tiles/FloralParadise/PeatMoss.png differ diff --git a/Tiles/FloralParadise/PerennialTree.cs b/Tiles/FloralParadise/PerennialTree.cs new file mode 100644 index 0000000000..ae4c3d6aec --- /dev/null +++ b/Tiles/FloralParadise/PerennialTree.cs @@ -0,0 +1,114 @@ +using System; +using CalamityMod.DataStructures; +using CalamityMod.ILEditing; +using CalamityMod.Tiles.BaseTiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class PerennialTree : DynamicallyGrownTree + { + // The max amount that branches can travel. Once the distance of the branches reaches or exceeds this threshold, the tree is done growing. + public override float MaxDistanceBeforeCutoff => 2100f; + + public override float DistanceUsedForTrunk => 140f; + + public override float BranchMaxBendFactor => 0.7f; + + public override float BranchTurnAngleVariance => 0.4f; + + public override float MinBranchLength => 30f; + + public override float TrunkWidth => 16f; + + public override float ChanceToCreateNewBranches => 0.8f; + + public override float VerticalStretchFactor => 12f; + + public override float DownwardBiasFactor => 0.4f; + + public override float BranchGrowthWidthDecay => 0.61f; + + public override int MaxCutoffBranchesPerBranch => 5; + + public override void SetStaticDefaults() + { + Main.tileAxe[Type] = true; + Main.tileFrameImportant[Type] = true; + DustType = 7; + ItemDrop = ItemID.Wood; + UseDefaultSize(); + TileObjectData.addTile(Type); + + AddMapEntry(Color.SaddleBrown); + } + + public void DrawVine(Vector2 vineTop, Vector2 downwardBottom, int totalVinesToDraw, float swayFactor) + { + Texture2D vineTexture = ModContent.Request("CalamityMod/Tiles/PerennialTreeVines").Value; + + // Determine the initial points for the vines. + Vector2[] controlPoints = new Vector2[8]; + Vector2 lightOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(-Main.offScreenRange); + for (int i = 0; i < controlPoints.Length; i++) + { + float swayOffset = swayFactor; + controlPoints[i] = Vector2.Lerp(vineTop, downwardBottom, i / (float)(controlPoints.Length - 1f)); + + Point p = (controlPoints[i] + lightOffset + BranchDrawer.PreviousPoint.ToWorldCoordinates()).ToTileCoordinates(); + + // 02JUN2024: Ozzatron: directionY did not exist at the time of the creation of the Perennial Tree. As such, it is ignored here. + ILChanges.Windgrid.GetWindTime(p.X, p.Y, 40, out int windTimeLeft, out int direction, out _); + + float windInterpolant = windTimeLeft / 40f; + swayOffset += Utils.GetLerpValue(0f, 0.45f, windInterpolant, true) * Utils.GetLerpValue(1f, 0.55f, windInterpolant, true) * direction * 28f; + controlPoints[i].X += swayOffset * Utils.GetLerpValue(0f, controlPoints.Length - 1f, i, true); + controlPoints[i].Y -= 4f; + } + BezierCurve vineCurve = new(controlPoints); + + int drawCount = (int)(totalVinesToDraw * 2.4f); + for (int i = 0; i < drawCount - 1; i++) + { + Vector2 vineCenter = vineCurve.Evaluate(i / (float)(drawCount - 1f)); + Vector2 ahead = vineCurve.Evaluate((i + 1f) / (float)(drawCount - 1f)); + float rotation = (ahead - vineCenter).ToRotation() - MathHelper.PiOver2; + vineCenter += BranchDrawer.PreviousPoint.ToWorldCoordinates() - Main.screenPosition; + + // Calculate light values. + Vector2 lightPosition = vineCenter + lightOffset + Main.screenPosition; + + int frameX = 0; + int frameY = 0; + if (i > 0) + frameY = RNG.Next(1, 3); + if (i >= drawCount - 3) + { + frameY = 3; + frameX = RNG.Next(3); + } + if (i == drawCount - 2) + frameY = 4; + + Rectangle frame = vineTexture.Frame(3, 5, frameX, frameY, -2, -2); + Color color = Lighting.GetColor(lightPosition.ToTileCoordinates()); + + Main.spriteBatch.Draw(vineTexture, vineCenter, frame, color, rotation, frame.Size() * 0.5f, 1f, 0f, 0); + } + } + + public override void DrawThingAtEndOfBranch(BranchDrawer.Branch branch) + { + int totalVinesToDraw = RNG.Next(4, 7); + float swayFactor = Main.windSpeedCurrent + (float)Math.Sin(Main.GlobalTimeWrappedHourly * 1.87f + RNG.NextFloat(0.94f)) * 0.4f; + Vector2 top = branch.EndOfCurve + Vector2.UnitY * 12f; + Vector2 bottom = top + Vector2.UnitY * totalVinesToDraw * 30f; + DrawVine(top, bottom, totalVinesToDraw, swayFactor * 35f); + } + } +} diff --git a/Tiles/FloralParadise/PerennialTree.png b/Tiles/FloralParadise/PerennialTree.png new file mode 100644 index 0000000000..77e0372437 Binary files /dev/null and b/Tiles/FloralParadise/PerennialTree.png differ diff --git a/Tiles/FloralParadise/PinkFlower.cs b/Tiles/FloralParadise/PinkFlower.cs new file mode 100644 index 0000000000..9ce0123ad4 --- /dev/null +++ b/Tiles/FloralParadise/PinkFlower.cs @@ -0,0 +1,89 @@ +using CalamityMod.ILEditing; +using CalamityMod.Items.Placeables; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class PinkFlower : ModTile + { + public const int Variants = 2; + + public const int WindPushLifetime = 45; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 2; + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new int[] + { + 16, + 16 + }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.RandomStyleRange = Variants; + + TileObjectData.addTile(Type); + + HitSound = SoundID.Grass; + DustType = 44; + AddMapEntry(new Color(255, 155, 202)); + } + + public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + { + if (drawData.tileFrameX % 36 == 0 && drawData.tileFrameY == 0) + Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); + } + + public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch) + { + // 02JUN2024: Ozzatron: directionY did not exist at the time of the creation of this content. As such, it is ignored here. + ILChanges.Windgrid.GetWindTime(i, j, WindPushLifetime, out int windTimeLeft, out int direction, out _); + + float windInterpolant = windTimeLeft / (float)WindPushLifetime; + float windRotation = Utils.GetLerpValue(0f, 0.5f, windInterpolant, true) * Utils.GetLerpValue(1f, 0.5f, windInterpolant, true) * direction * 0.34f; + + int frameX = Main.tile[i, j].TileFrameX; + Color drawColor = Lighting.GetColor(i, j); + Texture2D stamenTexture = ModContent.Request("CalamityMod/Tiles/FloralParadise/PinkFlowerStamen").Value; + Rectangle stamenFrame = stamenTexture.Frame(2, 1, frameX > 36 ? 1 : 0, 0); + Vector2 stamenOrigin = stamenFrame.Size() * new Vector2(0.5f, 1f); + Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPos = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffset + new Vector2(17f, 24f); + + // Create some pollen dust. + if (!Main.gamePaused && windTimeLeft >= 2 && Main.rand.NextBool(6)) + { + Vector2 pollenVelocity = -Vector2.UnitY.RotatedByRandom(windRotation * 2.3f) * 3f; + Dust pollen = Dust.NewDustPerfect(drawPos + Main.screenPosition - drawOffset - Vector2.UnitY * 16f, 44); + pollen.velocity = pollenVelocity; + pollen.scale = 1.4f; + } + + Main.spriteBatch.Draw(stamenTexture, drawPos, stamenFrame, drawColor, windRotation, stamenOrigin, 1f, SpriteEffects.None, 0f); + } + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 48, ModContent.ItemType()); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/FloralParadise/PinkFlower.png b/Tiles/FloralParadise/PinkFlower.png new file mode 100644 index 0000000000..283ca92731 Binary files /dev/null and b/Tiles/FloralParadise/PinkFlower.png differ diff --git a/Tiles/FloralParadise/PinkFlowerBig.cs b/Tiles/FloralParadise/PinkFlowerBig.cs new file mode 100644 index 0000000000..ce416e6c8f --- /dev/null +++ b/Tiles/FloralParadise/PinkFlowerBig.cs @@ -0,0 +1,95 @@ +using System; +using CalamityMod.ILEditing; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class PinkFlowerBig : ModTile + { + public const int Variants = 2; + + public const int WindPushLifetime = 48; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + Main.tileLighted[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.Width = 4; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(2, 2); + TileObjectData.newTile.CoordinateHeights = new int[] + { + 16, + 16, + 16 + }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.RandomStyleRange = Variants; + + HitSound = SoundID.Grass; + TileObjectData.addTile(Type); + + DustType = 44; + AddMapEntry(new Color(255, 155, 202)); + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.5f; + g = 0.4f; + b = 0.16f; + } + + public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData) + { + if (drawData.tileFrameX % 72 == 0 && drawData.tileFrameY == 0) + Main.instance.TilesRenderer.AddSpecialLegacyPoint(i, j); + } + + public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch) + { + // 02JUN2024: Ozzatron: directionY did not exist at the time of the creation of this content. As such, it is ignored here. + ILChanges.Windgrid.GetWindTime(i, j, WindPushLifetime, out int windTimeLeft, out int direction, out _); + + float windInterpolant = windTimeLeft / (float)WindPushLifetime; + float windRotation = Utils.GetLerpValue(0f, 0.5f, windInterpolant, true) * Utils.GetLerpValue(1f, 0.5f, windInterpolant, true) * direction * 0.34f; + + int frameX = Main.tile[i, j].TileFrameX; + Color drawColor = Lighting.GetColor(i, j); + Texture2D stamenTexture = ModContent.Request("CalamityMod/Tiles/FloralParadise/PinkFlowerBigStamen").Value; + Rectangle stamenFrame = stamenTexture.Frame(2, 1, frameX > 72 ? 1 : 0, 0); + Vector2 stamenOrigin = stamenFrame.Size() * new Vector2(0.5f, 1f); + Vector2 drawOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 drawPos = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + drawOffset + new Vector2(31f, 38f); + if (frameX < 72) + drawPos.X += 4f; + + // Create some pollen dust. + if (!Main.gamePaused && windTimeLeft >= 2 && Main.rand.NextBool(4)) + { + Vector2 pollenVelocity = -Vector2.UnitY.RotatedByRandom(windRotation * 2.3f) * 3f; + Dust pollen = Dust.NewDustPerfect(drawPos + Main.screenPosition - drawOffset - Vector2.UnitY * 16f, 44); + pollen.velocity = pollenVelocity; + pollen.scale = 1.6f; + } + + Main.spriteBatch.Draw(stamenTexture, drawPos, stamenFrame, drawColor, windRotation, stamenOrigin, 1f, SpriteEffects.None, 0f); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/FloralParadise/PinkFlowerBig.png b/Tiles/FloralParadise/PinkFlowerBig.png new file mode 100644 index 0000000000..b8611c19c8 Binary files /dev/null and b/Tiles/FloralParadise/PinkFlowerBig.png differ diff --git a/Tiles/FloralParadise/PinkFlowerBigStamen.png b/Tiles/FloralParadise/PinkFlowerBigStamen.png new file mode 100644 index 0000000000..146950fb0d Binary files /dev/null and b/Tiles/FloralParadise/PinkFlowerBigStamen.png differ diff --git a/Tiles/FloralParadise/PinkFlowerStamen.png b/Tiles/FloralParadise/PinkFlowerStamen.png new file mode 100644 index 0000000000..9641dcb280 Binary files /dev/null and b/Tiles/FloralParadise/PinkFlowerStamen.png differ diff --git a/Tiles/FloralParadise/SmallFloralPlants.cs b/Tiles/FloralParadise/SmallFloralPlants.cs new file mode 100644 index 0000000000..79dcf79fa1 --- /dev/null +++ b/Tiles/FloralParadise/SmallFloralPlants.cs @@ -0,0 +1,45 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class SmallFloralPlants : ModTile + { + public const int Variants = 8; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileCut[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); + TileObjectData.newTile.RandomStyleRange = Variants; + TileObjectData.addTile(Type); + + HitSound = SoundID.Grass; + DustType = 2; + AddMapEntry(new Color(28, 216, 94)); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (CalamityUtils.ParanoidTileRetrieval(i, j).LiquidAmount > 64) + WorldGen.KillTile(i, j); + } + } +} diff --git a/Tiles/FloralParadise/SmallFloralPlants.png b/Tiles/FloralParadise/SmallFloralPlants.png new file mode 100644 index 0000000000..f16c30cd3a Binary files /dev/null and b/Tiles/FloralParadise/SmallFloralPlants.png differ diff --git a/Tiles/FloralParadise/SmallMossPiles.cs b/Tiles/FloralParadise/SmallMossPiles.cs new file mode 100644 index 0000000000..a927dcd5d1 --- /dev/null +++ b/Tiles/FloralParadise/SmallMossPiles.cs @@ -0,0 +1,48 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class SmallMossPiles : ModTile + { + public const int Variants = 4; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.Width = 1; + TileObjectData.newTile.Height = 1; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.CoordinateHeights = new int[] + { + 16 + }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.RandomStyleRange = Variants; + + TileObjectData.addTile(Type); + + DustType = 38; + + AddMapEntry(new Color(56, 56, 56)); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + } +} diff --git a/Tiles/FloralParadise/SmallMossPiles.png b/Tiles/FloralParadise/SmallMossPiles.png new file mode 100644 index 0000000000..78133c1a7d Binary files /dev/null and b/Tiles/FloralParadise/SmallMossPiles.png differ diff --git a/Tiles/FloralParadise/SmallVines.cs b/Tiles/FloralParadise/SmallVines.cs new file mode 100644 index 0000000000..8cdbfd28dd --- /dev/null +++ b/Tiles/FloralParadise/SmallVines.cs @@ -0,0 +1,95 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class SmallVines : ModTile + { + public override void SetStaticDefaults() + { + Main.tileCut[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileFrameImportant[Type] = true; + AddMapEntry(new Color(100, 151, 31)); + HitSound = SoundID.Grass; + DustType = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + if (WorldGen.genRand.NextBool(2) && Main.player[(int)Player.FindClosest(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16)].cordage) + Item.NewItem(new EntitySource_TileBreak(i, j), new Vector2(i * 16 + 8f, j * 16 + 8f), ItemID.VineRope); + + if (Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType == Type) + { + WorldGen.KillTile(i, j + 1, false, false, false); + if (!Main.tile[i, j + 1].HasTile && Main.netMode != NetmodeID.SinglePlayer) + { + NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, (float)i, (float)j + 1, 0f, 0, 0, 0); + } + } + + if (Main.tile[i, j - 1].HasTile && Main.tile[i, j - 1].TileType == Type) + { + Main.tile[i, j - 1].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); + Main.tile[i, j - 1].TileFrameY = 54; + if (Main.netMode != NetmodeID.SinglePlayer) + NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, (float)i, (float)j + 1, 0f, 0, 0, 0); + } + } + + public override void RandomUpdate(int i, int j) + { + if (Main.tile[i, j + 1] != null) + { + if (!Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType != Type) + { + if (Main.tile[i, j + 1].LiquidAmount >= 128 && Main.tile[i, j + 1].LiquidType == LiquidID.Water) + { + bool canGrow = false; + for (int y = j; y > j - 10; j--) + { + if (Main.tile[i, y].BottomSlope) + { + canGrow = false; + break; + } + if (Main.tile[i, y].HasTile && !Main.tile[i, y].BottomSlope) + { + canGrow = true; + break; + } + } + if (canGrow) + { + int below = j + 1; + Main.tile[i, below].TileType = Type; + Main.tile[i, below].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); + Main.tile[i, below].TileFrameY = 54; + Main.tile[i, below - 1].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); + Main.tile[i, below - 1].TileFrameY = (short)(WorldGen.genRand.Next(3) * 18); + Main.tile[i, below].Get().HasTile = true; + WorldGen.SquareTileFrame(i, below, true); + WorldGen.SquareTileFrame(i, below - 1, true); + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, i, below, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, i, below - 1, 3, TileChangeType.None); + } + } + } + } + } + } + } +} diff --git a/Tiles/FloralParadise/SmallVines.png b/Tiles/FloralParadise/SmallVines.png new file mode 100644 index 0000000000..6b64a467be Binary files /dev/null and b/Tiles/FloralParadise/SmallVines.png differ diff --git a/Tiles/FloralParadise/SmallWallFungi.cs b/Tiles/FloralParadise/SmallWallFungi.cs new file mode 100644 index 0000000000..0897ba3df2 --- /dev/null +++ b/Tiles/FloralParadise/SmallWallFungi.cs @@ -0,0 +1,42 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class SmallWallFungi : ModTile + { + public const int Variants = 3; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.Width = 1; + TileObjectData.newTile.Height = 1; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.CoordinateHeights = new int[] + { + 16 + }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; + TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, 1, 0); + TileObjectData.newTile.RandomStyleRange = Variants; + TileObjectData.addTile(Type); + DustType = 0; + + AddMapEntry(new Color(165, 126, 84)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FloralParadise/SmallWallFungi.png b/Tiles/FloralParadise/SmallWallFungi.png new file mode 100644 index 0000000000..de025416bc Binary files /dev/null and b/Tiles/FloralParadise/SmallWallFungi.png differ diff --git a/Tiles/FloralParadise/SmallWallFungiLeft.cs b/Tiles/FloralParadise/SmallWallFungiLeft.cs new file mode 100644 index 0000000000..5bf26a266e --- /dev/null +++ b/Tiles/FloralParadise/SmallWallFungiLeft.cs @@ -0,0 +1,42 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class SmallWallFungiLeft : ModTile + { + public const int Variants = 3; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.Width = 1; + TileObjectData.newTile.Height = 1; + TileObjectData.newTile.Origin = new Point16(0, 0); + TileObjectData.newTile.CoordinateHeights = new int[] + { + 16 + }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; + TileObjectData.newTile.AnchorLeft = new AnchorData(AnchorType.SolidTile, 1, 0); + TileObjectData.newTile.RandomStyleRange = Variants; + TileObjectData.addTile(Type); + DustType = 0; + + AddMapEntry(new Color(165, 126, 84)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FloralParadise/SmallWallFungiLeft.png b/Tiles/FloralParadise/SmallWallFungiLeft.png new file mode 100644 index 0000000000..55d42f575c Binary files /dev/null and b/Tiles/FloralParadise/SmallWallFungiLeft.png differ diff --git a/Tiles/FloralParadise/TallFloralPlants.cs b/Tiles/FloralParadise/TallFloralPlants.cs new file mode 100644 index 0000000000..ab4d00e0df --- /dev/null +++ b/Tiles/FloralParadise/TallFloralPlants.cs @@ -0,0 +1,55 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class TallFloralPlants : ModTile + { + public const int Variants = 12; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileCut[Type] = true; + Main.tileObsidianKill[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 1; + TileObjectData.newTile.Origin = new Point16(1, 0); + TileObjectData.newTile.CoordinateHeights = new int[] + { + 16 + }; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.RandomStyleRange = Variants; + TileObjectData.addTile(Type); + + HitSound = SoundID.Grass; + DustType = 2; + AddMapEntry(new Color(106, 135, 69)); + } + + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) + { + offsetY = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 4; + } + + public override void NearbyEffects(int i, int j, bool closer) + { + if (CalamityUtils.ParanoidTileRetrieval(i, j).LiquidAmount > 64) + WorldGen.KillTile(i, j); + } + } +} diff --git a/Tiles/FloralParadise/TallFloralPlants.png b/Tiles/FloralParadise/TallFloralPlants.png new file mode 100644 index 0000000000..45e35742a0 Binary files /dev/null and b/Tiles/FloralParadise/TallFloralPlants.png differ diff --git a/Tiles/FloralParadise/VineLoops.cs b/Tiles/FloralParadise/VineLoops.cs new file mode 100644 index 0000000000..f2350cc926 --- /dev/null +++ b/Tiles/FloralParadise/VineLoops.cs @@ -0,0 +1,39 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class VineLoops : ModTile + { + public const int Variants = 3; + + public override void SetStaticDefaults() + { + Main.tileCut[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileLavaDeath[Type] = true; + Main.tileNoFail[Type] = true; + Main.tileFrameImportant[Type] = true; + + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; + TileObjectData.newTile.AnchorTop = new(AnchorType.SolidTile, 2, 0); + TileObjectData.newTile.RandomStyleRange = Variants; + TileObjectData.addTile(Type); + + AddMapEntry(new Color(47, 75, 32)); + HitSound = SoundID.Grass; + DustType = 2; + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FloralParadise/VineLoops.png b/Tiles/FloralParadise/VineLoops.png new file mode 100644 index 0000000000..987e3b445d Binary files /dev/null and b/Tiles/FloralParadise/VineLoops.png differ diff --git a/Tiles/FloralParadise/WallLeaves.cs b/Tiles/FloralParadise/WallLeaves.cs new file mode 100644 index 0000000000..ac13b4b1e7 --- /dev/null +++ b/Tiles/FloralParadise/WallLeaves.cs @@ -0,0 +1,36 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class WallLeaves : ModTile + { + public const int Variants = 3; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; + TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, 2, 0); + TileObjectData.newTile.RandomStyleRange = Variants; + TileObjectData.addTile(Type); + + HitSound = SoundID.Grass; + DustType = 0; + + AddMapEntry(new Color(145, 170, 61)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FloralParadise/WallLeaves.png b/Tiles/FloralParadise/WallLeaves.png new file mode 100644 index 0000000000..2a9a284419 Binary files /dev/null and b/Tiles/FloralParadise/WallLeaves.png differ diff --git a/Tiles/FloralParadise/WallLeavesLeft.cs b/Tiles/FloralParadise/WallLeavesLeft.cs new file mode 100644 index 0000000000..2cfbb980bd --- /dev/null +++ b/Tiles/FloralParadise/WallLeavesLeft.cs @@ -0,0 +1,36 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class WallLeavesLeft : ModTile + { + public const int Variants = 3; + + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.AnchorBottom = AnchorData.Empty; + TileObjectData.newTile.AnchorLeft = new AnchorData(AnchorType.SolidTile, 2, 0); + TileObjectData.newTile.RandomStyleRange = Variants; + TileObjectData.addTile(Type); + + HitSound = SoundID.Grass; + DustType = 0; + + AddMapEntry(new Color(145, 170, 61)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) + { + num = fail ? 1 : 3; + } + } +} diff --git a/Tiles/FloralParadise/WallLeavesLeft.png b/Tiles/FloralParadise/WallLeavesLeft.png new file mode 100644 index 0000000000..a82df1d3ea Binary files /dev/null and b/Tiles/FloralParadise/WallLeavesLeft.png differ diff --git a/Tiles/FloralParadise/WaterfallCreator.cs b/Tiles/FloralParadise/WaterfallCreator.cs new file mode 100644 index 0000000000..ad070df5af --- /dev/null +++ b/Tiles/FloralParadise/WaterfallCreator.cs @@ -0,0 +1,42 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.FloralParadise +{ + public class WaterfallCreator : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = false; + Main.tileBlockLight[Type] = true; + Main.tileBrick[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithOres(Type); + CalamityUtils.MergeWithFloralParadise(Type); + + HitSound = SoundID.Tink; + + AddMapEntry(new Color(33, 56, 27)); + } + + public override void NearbyEffects(int i, int j, bool closer) + { + Tile tile = CalamityUtils.ParanoidTileRetrieval(i, j); + if (Main.netMode == NetmodeID.Server || !Main.rand.NextBool() || Main.gamePaused || tile.LiquidAmount > 0) + return; + + for (int k = 0; k < 16; k++) + { + Vector2 waterVelocity = -Vector2.UnitY.RotatedByRandom(0.29f) * Main.rand.NextFloat(1f, 2.4f); + float waterScale = Main.rand.NextFloat(0.08f, 0.12f); + Color waterColor = Color.Lerp(Color.Cyan, Color.SkyBlue, Main.rand.NextFloat()); + Vector2 particlePosition = new Vector2(i + 0.5f, j + 0.5f) * 16f + Vector2.UnitY * Main.rand.NextFloat(24f); + GeneralParticleHandler.SpawnParticle(new WaterFoamParticle(particlePosition, waterVelocity, 150, waterScale, waterColor)); + } + } + } +} diff --git a/Tiles/FloralParadise/WaterfallCreator.png b/Tiles/FloralParadise/WaterfallCreator.png new file mode 100644 index 0000000000..622533204a Binary files /dev/null and b/Tiles/FloralParadise/WaterfallCreator.png differ diff --git a/Tiles/Furniture/BlueCandle.cs b/Tiles/Furniture/BlueCandle.cs index e174008003..ae874cba1a 100644 --- a/Tiles/Furniture/BlueCandle.cs +++ b/Tiles/Furniture/BlueCandle.cs @@ -2,9 +2,9 @@ using CalamityMod.Items.Placeables.Furniture; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; +using Terraria.Audio; +using Terraria.GameContent.ObjectInteractions; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -12,6 +12,9 @@ namespace CalamityMod.Tiles.Furniture { public class BlueCandle : ModTile { + // TODO -- Unique sounds for each Cirrus Candle. + public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Item/LouderPhantomPhoenix2"); + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -22,9 +25,39 @@ namespace CalamityMod.Tiles.Furniture AdjTiles = new int[] { TileID.Candles }; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(238, 145, 105), CalamityUtils.GetItemName()); + TileID.Sets.HasOutlines[Type] = true; AnimationFrameHeight = 18; } + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override bool RightClick(int i, int j) + { + Player p = Main.LocalPlayer; + + // Forcibly remove all candle buffs. + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + + // 108000 is the duration used by Ammo Box. + p.AddBuff(ModContent.BuffType(), 108000); + + // Play a sound. + SoundEngine.PlaySound(ActivationSound, new Vector2(i * 16, j * 16)); + + return true; + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + public override void AnimateTile(ref int frame, ref int frameCounter) { frameCounter++; @@ -35,15 +68,6 @@ namespace CalamityMod.Tiles.Furniture } } - public override void NearbyEffects(int i, int j, bool closer) - { - Player player = Main.LocalPlayer; - if (player is null) - return; - if (!player.dead && player.active) - player.AddBuff(ModContent.BuffType(), 20); - } - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { r = 0.35f; diff --git a/Tiles/Furniture/BlueCandle_Highlight.png b/Tiles/Furniture/BlueCandle_Highlight.png new file mode 100644 index 0000000000..02427f1b60 Binary files /dev/null and b/Tiles/Furniture/BlueCandle_Highlight.png differ diff --git a/Tiles/Furniture/BossRelics/AstrumDeusRelic.png b/Tiles/Furniture/BossRelics/AstrumDeusRelic.png index 841e350f40..c5c314a84d 100644 Binary files a/Tiles/Furniture/BossRelics/AstrumDeusRelic.png and b/Tiles/Furniture/BossRelics/AstrumDeusRelic.png differ diff --git a/Tiles/Furniture/PinkCandle.cs b/Tiles/Furniture/PinkCandle.cs index fd4a947066..3ffb8dbfab 100644 --- a/Tiles/Furniture/PinkCandle.cs +++ b/Tiles/Furniture/PinkCandle.cs @@ -2,9 +2,9 @@ using CalamityMod.Items.Placeables.Furniture; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; +using Terraria.Audio; +using Terraria.GameContent.ObjectInteractions; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -12,6 +12,9 @@ namespace CalamityMod.Tiles.Furniture { public class PinkCandle : ModTile { + // TODO -- Unique sounds for each Cirrus Candle. + public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Item/LouderPhantomPhoenix2"); + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -22,9 +25,39 @@ namespace CalamityMod.Tiles.Furniture AdjTiles = new int[] { TileID.Candles }; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(238, 145, 105), CalamityUtils.GetItemName()); + TileID.Sets.HasOutlines[Type] = true; AnimationFrameHeight = 18; } + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override bool RightClick(int i, int j) + { + Player p = Main.LocalPlayer; + + // Forcibly remove all candle buffs. + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + + // 108000 is the duration used by Ammo Box. + p.AddBuff(ModContent.BuffType(), 108000); + + // Play a sound. + SoundEngine.PlaySound(ActivationSound, new Vector2(i * 16, j * 16)); + + return true; + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + public override void AnimateTile(ref int frame, ref int frameCounter) { frameCounter++; @@ -35,15 +68,6 @@ namespace CalamityMod.Tiles.Furniture } } - public override void NearbyEffects(int i, int j, bool closer) - { - Player player = Main.LocalPlayer; - if (player is null) - return; - if (!player.dead && player.active) - player.AddBuff(ModContent.BuffType(), 20); - } - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { r = 0.75f; diff --git a/Tiles/Furniture/PinkCandle_Highlight.png b/Tiles/Furniture/PinkCandle_Highlight.png new file mode 100644 index 0000000000..02427f1b60 Binary files /dev/null and b/Tiles/Furniture/PinkCandle_Highlight.png differ diff --git a/Tiles/Furniture/PurpleCandle.cs b/Tiles/Furniture/PurpleCandle.cs index 232603c410..31d1864cf7 100644 --- a/Tiles/Furniture/PurpleCandle.cs +++ b/Tiles/Furniture/PurpleCandle.cs @@ -2,9 +2,9 @@ using CalamityMod.Items.Placeables.Furniture; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; +using Terraria.Audio; +using Terraria.GameContent.ObjectInteractions; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -12,6 +12,9 @@ namespace CalamityMod.Tiles.Furniture { public class PurpleCandle : ModTile { + // TODO -- Unique sounds for each Cirrus Candle. + public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Item/LouderPhantomPhoenix2"); + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -22,9 +25,39 @@ namespace CalamityMod.Tiles.Furniture AdjTiles = new int[] { TileID.Candles }; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(238, 145, 105), CalamityUtils.GetItemName()); + TileID.Sets.HasOutlines[Type] = true; AnimationFrameHeight = 18; } + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override bool RightClick(int i, int j) + { + Player p = Main.LocalPlayer; + + // Forcibly remove all candle buffs. + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + + // 108000 is the duration used by Ammo Box. + p.AddBuff(ModContent.BuffType(), 108000); + + // Play a sound. + SoundEngine.PlaySound(ActivationSound, new Vector2(i * 16, j * 16)); + + return true; + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + public override void AnimateTile(ref int frame, ref int frameCounter) { frameCounter++; @@ -35,15 +68,6 @@ namespace CalamityMod.Tiles.Furniture } } - public override void NearbyEffects(int i, int j, bool closer) - { - Player player = Main.LocalPlayer; - if (player is null) - return; - if (!player.dead && player.active) - player.AddBuff(ModContent.BuffType(), 20); - } - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { r = 0.65f; diff --git a/Tiles/Furniture/PurpleCandle_Highlight.png b/Tiles/Furniture/PurpleCandle_Highlight.png new file mode 100644 index 0000000000..02427f1b60 Binary files /dev/null and b/Tiles/Furniture/PurpleCandle_Highlight.png differ diff --git a/Tiles/Furniture/YellowCandle.cs b/Tiles/Furniture/YellowCandle.cs index 54779eadf4..177df09292 100644 --- a/Tiles/Furniture/YellowCandle.cs +++ b/Tiles/Furniture/YellowCandle.cs @@ -2,6 +2,8 @@ using CalamityMod.Items.Placeables.Furniture; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; +using Terraria.GameContent.ObjectInteractions; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -10,6 +12,9 @@ namespace CalamityMod.Tiles.Furniture { public class YellowCandle : ModTile { + // TODO -- Unique sounds for each Cirrus Candle. + public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Item/LouderPhantomPhoenix2"); + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; @@ -19,9 +24,39 @@ namespace CalamityMod.Tiles.Furniture TileObjectData.addTile(Type); AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(238, 145, 105), CalamityUtils.GetItemName()); + TileID.Sets.HasOutlines[Type] = true; AnimationFrameHeight = 18; } + public override bool HasSmartInteract(int i, int j, SmartInteractScanSettings settings) => true; + + public override bool RightClick(int i, int j) + { + Player p = Main.LocalPlayer; + + // Forcibly remove all candle buffs. + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + p.ClearBuff(ModContent.BuffType()); + + // 108000 is the duration used by Ammo Box. + p.AddBuff(ModContent.BuffType(), 108000); + + // Play a sound. + SoundEngine.PlaySound(ActivationSound, new Vector2(i * 16, j * 16)); + + return true; + } + + public override void MouseOver(int i, int j) + { + Player player = Main.LocalPlayer; + player.noThrow = 2; + player.cursorItemIconEnabled = true; + player.cursorItemIconID = ModContent.ItemType(); + } + public override void AnimateTile(ref int frame, ref int frameCounter) { frameCounter++; @@ -32,29 +67,6 @@ namespace CalamityMod.Tiles.Furniture } } - public override void NearbyEffects(int i, int j, bool closer) - { - Player player = Main.LocalPlayer; - if (player == null || !player.active || player.dead) - return; - player.AddBuff(ModContent.BuffType(), 20); - - if (Main.netMode == NetmodeID.MultiplayerClient) - return; - - // All NPCs within a certain distance of the player get "Tagged" with Spite. - for (int m = 0; m < Main.maxNPCs; m++) - { - NPC npc = Main.npc[m]; - if (npc is null || !npc.active || npc.friendly) - continue; - - float dist2 = npc.DistanceSQ(player.Center); - if (dist2 < 23040000f) // 4800px range - Main.npc[m].AddBuff(ModContent.BuffType(), 20, false); - } - } - public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { r = 0.75f; diff --git a/Tiles/Furniture/YellowCandle_Highlight.png b/Tiles/Furniture/YellowCandle_Highlight.png new file mode 100644 index 0000000000..02427f1b60 Binary files /dev/null and b/Tiles/Furniture/YellowCandle_Highlight.png differ diff --git a/Tiles/FurnitureAuric/AuricReinforcedCrateTile.cs b/Tiles/FurnitureAuric/AuricReinforcedCrateTile.cs index 5c8fa7fa53..6fcdd98125 100644 --- a/Tiles/FurnitureAuric/AuricReinforcedCrateTile.cs +++ b/Tiles/FurnitureAuric/AuricReinforcedCrateTile.cs @@ -17,6 +17,7 @@ namespace CalamityMod.Tiles.FurnitureAuric Main.tileLavaDeath[Type] = false; Main.tileWaterDeath[Type] = false; Main.tileSolidTop[Type] = true; + Main.tileTable[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.newTile.LavaDeath = false; TileObjectData.addTile(Type); diff --git a/Tiles/FurnitureExo/ExoWorkBenchTile.cs b/Tiles/FurnitureExo/ExoWorkBenchTile.cs index 09264ba031..9347c89993 100644 --- a/Tiles/FurnitureExo/ExoWorkBenchTile.cs +++ b/Tiles/FurnitureExo/ExoWorkBenchTile.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -25,6 +26,11 @@ namespace CalamityMod.Tiles.FurnitureExo num = fail ? 1 : 3; } + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 16, ModContent.ItemType()); + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { int xFrameOffset = Main.tile[i, j].TileFrameX; diff --git a/Tiles/IMergeableTile.cs b/Tiles/IMergeableTile.cs deleted file mode 100644 index 9455c50bcc..0000000000 --- a/Tiles/IMergeableTile.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using Microsoft.Xna.Framework.Graphics; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles -{ - /// - /// Interface for tiles that specify custom universal merge data. - /// - internal interface IMergeableTile - { - List TileAdjacencies { get; } - } - - internal static class MergeableTile - { - private sealed class MergeableTileGlobalTile : GlobalTile - { - public override void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) - { - if (!TryGetMergeableTile(type, out var mergeableTile)) - return; - - TileFraming.DrawUniversalMergeFrames(i, j, mergeableTile.TileAdjacencies); - } - - public override bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak) - { - if (!TryGetMergeableTile(type, out var mergeableTile)) - return base.TileFrame(i, j, type, ref resetFrame, ref noBreak); - - foreach (var adjacency in mergeableTile.TileAdjacencies) - TileFraming.GetAdjacencyData(i, j, adjacency); - - return base.TileFrame(i, j, type, ref resetFrame, ref noBreak); - } - - private static bool TryGetMergeableTile(int type, [NotNullWhen(returnValue: true)] out IMergeableTile mergeableTile) - { - if (TileLoader.GetTile(type) is IMergeableTile theMergeableTile) - { - mergeableTile = theMergeableTile; - return true; - } - - mergeableTile = null; - return false; - } - } - - public static void RegisterUniversalMerge(this IMergeableTile mergeableTile, int tileId, string blendSheetPath) - { - if (mergeableTile is not ModTile tile) - throw new InvalidCastException($"{nameof(IMergeableTile)} is implemented on type {mergeableTile.GetType().FullName}; said type should inherit from {nameof(ModTile)}"); - - TileFraming.SetUpUniversalMerge(tile.Type, tileId, blendSheetPath, out var data); - mergeableTile.TileAdjacencies.Add(data); - } - } -} diff --git a/Tiles/MergeableTile.cs b/Tiles/MergeableTile.cs new file mode 100644 index 0000000000..86d6438fc6 --- /dev/null +++ b/Tiles/MergeableTile.cs @@ -0,0 +1,60 @@ +using System.Collections.Generic; +using Microsoft.Xna.Framework.Graphics; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles +{ + internal static class MergeableTile + { + // CIT 25MAY2024: This custom tile merging system was repeatedly crashing the mod with an out of memory exception. + // Because the person who made this system is no longer on the dev team, I am just going to disable it again. + + private sealed class MergeableTileGlobalTile : GlobalTile + { + /*public override void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) + { + TileFraming.DrawUniversalMergeFrames(i, j, GetOrCreateTileAdjacencies(type)); + } + + public override bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak) + { + foreach (var adjacency in GetOrCreateTileAdjacencies(type)) + TileFraming.GetAdjacencyData(i, j, adjacency); + + return base.TileFrame(i, j, type, ref resetFrame, ref noBreak); + }*/ + } + + private sealed class MergeableTileSystem : ModSystem + { + /*public override void PostSetupContent() + { + // Tomat: @heartplusup, you can add vanilla merges like so: + // RegisterUniversalMerge(TileID.Dirt, TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); - Already-merged tiles look weird; needs changes by someone else. + // RegisterUniversalMerge(TileID.WoodBlock, TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + }*/ + } + + private static readonly Dictionary> tileAdjacencyMap = []; + + public static void RegisterUniversalMerge(this ModTile tile, int mergeType, string blendSheetPath) + { + // RegisterUniversalMerge(tile.Type, mergeType, blendSheetPath); + } + + public static void RegisterUniversalMerge(int tileId, int mergeType, string blendSheetPath) + { + // TileFraming.SetUpUniversalMerge(tileId, mergeType, blendSheetPath, out var data); + // GetOrCreateTileAdjacencies(tileId).Add(data); + } + + /*private static List GetOrCreateTileAdjacencies(int tileId) + { + /*if (!tileAdjacencyMap.TryGetValue(tileId, out var adjacencies)) + tileAdjacencyMap[tileId] = adjacencies = []; + + return adjacencies; + }*/ + } +} diff --git a/Tiles/Ores/AerialiteOre.cs b/Tiles/Ores/AerialiteOre.cs index 427c90d2b2..4c0aeb9049 100644 --- a/Tiles/Ores/AerialiteOre.cs +++ b/Tiles/Ores/AerialiteOre.cs @@ -11,13 +11,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class AerialiteOre : ModTile, IMergeableTile + public class AerialiteOre : ModTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/MagicalRockMine", 3); internal static Texture2D GlowTexture; - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { if (!Main.dedServ) diff --git a/Tiles/Ores/AerialiteOreDisenchanted.cs b/Tiles/Ores/AerialiteOreDisenchanted.cs index 4780b063e0..bd6f41dac4 100644 --- a/Tiles/Ores/AerialiteOreDisenchanted.cs +++ b/Tiles/Ores/AerialiteOreDisenchanted.cs @@ -7,12 +7,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class AerialiteOreDisenchanted : ModTile, IMergeableTile + public class AerialiteOreDisenchanted : ModTile { private const int AnimationFrameWidth = 234; - - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileBlockLight[Type] = true; diff --git a/Tiles/Ores/AstralOre.cs b/Tiles/Ores/AstralOre.cs index c2e220d120..2b9da5ece9 100644 --- a/Tiles/Ores/AstralOre.cs +++ b/Tiles/Ores/AstralOre.cs @@ -10,10 +10,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class AstralOre : ModTile, IMergeableTile + public class AstralOre : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; diff --git a/Tiles/Ores/AuricOre.cs b/Tiles/Ores/AuricOre.cs index 8d5facedb2..bc4ad02243 100644 --- a/Tiles/Ores/AuricOre.cs +++ b/Tiles/Ores/AuricOre.cs @@ -14,14 +14,13 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.Ores { - public class AuricOre : ModTile, IMergeableTile + public class AuricOre : ModTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/AuricMine", 3); public static bool Animate; internal static Texture2D GlowTexture; - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { if (!Main.dedServ) diff --git a/Tiles/Ores/ExodiumOre.cs b/Tiles/Ores/ExodiumOre.cs index 41fc92d67f..298a81c0e1 100644 --- a/Tiles/Ores/ExodiumOre.cs +++ b/Tiles/Ores/ExodiumOre.cs @@ -10,10 +10,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class ExodiumOre : ModTile, IMergeableTile + public class ExodiumOre : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Ores/HallowedOre.cs b/Tiles/Ores/HallowedOre.cs index 049ca594f2..dfe58dd453 100644 --- a/Tiles/Ores/HallowedOre.cs +++ b/Tiles/Ores/HallowedOre.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class HallowedOre : ModTile, IMergeableTile + public class HallowedOre : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; diff --git a/Tiles/Ores/InfernalSuevite.cs b/Tiles/Ores/InfernalSuevite.cs index 4d00e3d10c..9c5aa5ff20 100644 --- a/Tiles/Ores/InfernalSuevite.cs +++ b/Tiles/Ores/InfernalSuevite.cs @@ -10,13 +10,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { [LegacyName("CharredOre")] - public class InfernalSuevite : ModTile, IMergeableTile + public class InfernalSuevite : ModTile { private int sheetWidth = 234; private int sheetHeight = 90; - - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Ores/PerennialOre.cs b/Tiles/Ores/PerennialOre.cs index 08d732e51e..bec39eb551 100644 --- a/Tiles/Ores/PerennialOre.cs +++ b/Tiles/Ores/PerennialOre.cs @@ -1,6 +1,7 @@  using System; using System.Collections.Generic; +using CalamityMod.Tiles.FloralParadise; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -11,12 +12,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class PerennialOre : ModTile, IMergeableTile + public class PerennialOre : ModTile { internal static Texture2D GlowTexture; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { if (!Main.dedServ) @@ -30,6 +29,7 @@ namespace CalamityMod.Tiles.Ores Main.tileShine2[Type] = true; CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithFloralParadise(Type); TileID.Sets.Ore[Type] = true; TileID.Sets.OreMergesWithMud[Type] = true; diff --git a/Tiles/Ores/ScoriaOre.cs b/Tiles/Ores/ScoriaOre.cs index 238f5f1cd4..fe8efcf707 100644 --- a/Tiles/Ores/ScoriaOre.cs +++ b/Tiles/Ores/ScoriaOre.cs @@ -12,10 +12,8 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { [LegacyName("ChaoticOre")] - public class ScoriaOre : ModTile, IMergeableTile + public class ScoriaOre : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; diff --git a/Tiles/Ores/UelibloomOre.cs b/Tiles/Ores/UelibloomOre.cs index 14ab406efd..b213b57d7b 100644 --- a/Tiles/Ores/UelibloomOre.cs +++ b/Tiles/Ores/UelibloomOre.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class UelibloomOre : ModTile, IMergeableTile + public class UelibloomOre : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/PerennialBrick.cs b/Tiles/PerennialBrick.cs index 9133c5f6cb..0b647557dc 100644 --- a/Tiles/PerennialBrick.cs +++ b/Tiles/PerennialBrick.cs @@ -8,10 +8,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class PerennialBrick : ModTile, IMergeableTile + public class PerennialBrick : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/PerennialTreeVines.png b/Tiles/PerennialTreeVines.png new file mode 100644 index 0000000000..19356dd5fe Binary files /dev/null and b/Tiles/PerennialTreeVines.png differ diff --git a/Tiles/Rubblemaker/SunkenSea/BrainCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/BrainCoralEcho.cs index 2f310a0da3..9de2a1b76e 100644 --- a/Tiles/Rubblemaker/SunkenSea/BrainCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/BrainCoralEcho.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea { public class BrainCoralEcho : ModTile { - public override string Texture => "CalamityMod/Tiles/SunkenSea/BrainCoral"; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/BrainCoral"; public override void SetStaticDefaults() { diff --git a/Tiles/Rubblemaker/SunkenSea/CoralPileLargeEcho.cs b/Tiles/Rubblemaker/SunkenSea/CoralPileLargeEcho.cs index cbfa9300c9..93a794a6bb 100644 --- a/Tiles/Rubblemaker/SunkenSea/CoralPileLargeEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/CoralPileLargeEcho.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea { public class CoralPileLargeEcho : ModTile { - public override string Texture => "CalamityMod/Tiles/SunkenSea/CoralPileLarge"; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/CoralPileLarge"; public override void SetStaticDefaults() { Main.tileLighted[Type] = true; diff --git a/Tiles/Rubblemaker/SunkenSea/FanCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/FanCoralEcho.cs index 4ee2a05729..621d2a1ccd 100644 --- a/Tiles/Rubblemaker/SunkenSea/FanCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/FanCoralEcho.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea { public class FanCoralEcho : ModTile { - public override string Texture => "CalamityMod/Tiles/SunkenSea/FanCoral"; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/FanCoral"; public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; diff --git a/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs index 2583c0c2f7..ce5b492050 100644 --- a/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea { public class MediumCoralEcho : ModTile { - public override string Texture => "CalamityMod/Tiles/SunkenSea/MediumCoral"; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/MediumCoral"; public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -34,6 +34,6 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea public class MediumCoral2Echo : MediumCoralEcho { - public override string Texture => "CalamityMod/Tiles/SunkenSea/MediumCoral2"; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/MediumCoral2"; } } diff --git a/Tiles/Rubblemaker/SunkenSea/SeaAnemoneEcho.cs b/Tiles/Rubblemaker/SunkenSea/SeaAnemoneEcho.cs index 57c7b8341e..11948f22aa 100644 --- a/Tiles/Rubblemaker/SunkenSea/SeaAnemoneEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/SeaAnemoneEcho.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea { public class SeaAnemoneEcho : ModTile { - public override string Texture => "CalamityMod/Tiles/SunkenSea/SeaAnemone"; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SeaAnemone"; public override void SetStaticDefaults() { AnimationFrameHeight = 36; diff --git a/Tiles/Rubblemaker/SunkenSea/SmallBrainCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/SmallBrainCoralEcho.cs index 7f5d890a8e..8eae4a37e7 100644 --- a/Tiles/Rubblemaker/SunkenSea/SmallBrainCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/SmallBrainCoralEcho.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea { public class SmallBrainCoralEcho : ModTile { - public override string Texture => "CalamityMod/Tiles/SunkenSea/SmallBrainCoral"; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SmallBrainCoral"; public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; diff --git a/Tiles/Rubblemaker/SunkenSea/SmallCoralsEcho.cs b/Tiles/Rubblemaker/SunkenSea/SmallCoralsEcho.cs index 65c88d8234..d9ab7f41dd 100644 --- a/Tiles/Rubblemaker/SunkenSea/SmallCoralsEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/SmallCoralsEcho.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea { public class SmallCoralsEcho : ModTile { - public override string Texture => "CalamityMod/Tiles/SunkenSea/SmallCorals"; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SmallCorals"; public override void SetStaticDefaults() { Main.tileLighted[Type] = false; @@ -18,7 +18,7 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea Main.tileNoAttach[Type] = true; Main.tileNoFail[Type] = true; Main.tileLavaDeath[Type] = true; - Main.tileWaterDeath[Type] = true; + Main.tileWaterDeath[Type] = false; Main.tileFrameImportant[Type] = true; TileID.Sets.ReplaceTileBreakUp[Type] = true; TileID.Sets.SwaysInWindBasic[Type] = false; diff --git a/Tiles/Rubblemaker/SunkenSea/SmallTubeCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/SmallTubeCoralEcho.cs index 6cf2e9c25e..74b3418a4f 100644 --- a/Tiles/Rubblemaker/SunkenSea/SmallTubeCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/SmallTubeCoralEcho.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea { public class SmallTubeCoralEcho : ModTile { - public override string Texture => "CalamityMod/Tiles/SunkenSea/SmallTubeCoral"; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SmallTubeCoral"; public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; diff --git a/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs index 61a47c4125..468e302c00 100644 --- a/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea { public class SmallWideCoralEcho : ModTile { - public override string Texture => "CalamityMod/Tiles/SunkenSea/SmallWideCoral"; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SmallWideCoral"; public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -29,6 +29,6 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea } public class SmallWideCoral2Echo : SmallWideCoralEcho { - public override string Texture => "CalamityMod/Tiles/SunkenSea/SmallWideCoral2"; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/SmallWideCoral2"; } } diff --git a/Tiles/Rubblemaker/SunkenSea/TableCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/TableCoralEcho.cs index 7bc07af392..d210666410 100644 --- a/Tiles/Rubblemaker/SunkenSea/TableCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/TableCoralEcho.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea { int subsheetHeight = 34; int subsheetWidth = 108; - public override string Texture => "CalamityMod/Tiles/SunkenSea/TableCoral"; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/TableCoral"; public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; diff --git a/Tiles/Rubblemaker/SunkenSea/TubeCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/TubeCoralEcho.cs index cf20f621f5..1ca9b428a7 100644 --- a/Tiles/Rubblemaker/SunkenSea/TubeCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/TubeCoralEcho.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea { public class TubeCoralEcho : ModTile { - public override string Texture => "CalamityMod/Tiles/SunkenSea/TubeCoral"; + public override string Texture => "CalamityMod/Tiles/SunkenSea/Ambient/TubeCoral"; public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; diff --git a/Tiles/ScoriaBrick.cs b/Tiles/ScoriaBrick.cs index 800e5d6d57..1509aa27f4 100644 --- a/Tiles/ScoriaBrick.cs +++ b/Tiles/ScoriaBrick.cs @@ -10,13 +10,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { [LegacyName("ChaoticBrick")] - public class ScoriaBrick : ModTile, IMergeableTile + public class ScoriaBrick : ModTile { int subsheetHeight = 72; internal static Texture2D GlowTexture; - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { if (!Main.dedServ) diff --git a/Tiles/SunkenSea/Ambient/BlueCoralTree.cs b/Tiles/SunkenSea/Ambient/BlueCoralTree.cs new file mode 100644 index 0000000000..eb6976e536 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/BlueCoralTree.cs @@ -0,0 +1,40 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class BlueCoralTree : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + TileObjectData.newTile.Width = 3; + TileObjectData.newTile.Height = 4; + TileObjectData.newTile.Origin = new Point16(1, 3); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(126, 80, 69)); + DustType = 155; + HitSound = SoundID.Dig; + } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 60f / 255f; + g = 110f / 255f; + b = 146f / 255f; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/BlueCoralTree.png b/Tiles/SunkenSea/Ambient/BlueCoralTree.png new file mode 100644 index 0000000000..852e9a8489 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/BlueCoralTree.png differ diff --git a/Tiles/SunkenSea/BrainCoral.cs b/Tiles/SunkenSea/Ambient/BrainCoral.cs similarity index 97% rename from Tiles/SunkenSea/BrainCoral.cs rename to Tiles/SunkenSea/Ambient/BrainCoral.cs index 0d45d6be8b..f3f73b002f 100644 --- a/Tiles/SunkenSea/BrainCoral.cs +++ b/Tiles/SunkenSea/Ambient/BrainCoral.cs @@ -7,7 +7,7 @@ using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.SunkenSea +namespace CalamityMod.Tiles.SunkenSea.Ambient { public class BrainCoral : ModTile { diff --git a/Tiles/SunkenSea/BrainCoral.png b/Tiles/SunkenSea/Ambient/BrainCoral.png similarity index 100% rename from Tiles/SunkenSea/BrainCoral.png rename to Tiles/SunkenSea/Ambient/BrainCoral.png diff --git a/Tiles/SunkenSea/Ambient/BrownCoral.cs b/Tiles/SunkenSea/Ambient/BrownCoral.cs new file mode 100644 index 0000000000..0e76768aa2 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/BrownCoral.cs @@ -0,0 +1,70 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Humanizer; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class BrownCoral1 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + TileObjectData.newTile.Width = 2; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(1, 2); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(113, 80, 28)); + DustType = 155; + HitSound = SoundID.Dig; + } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 244f / 450f; + g = 238f / 450f; + b = 162f / 450f; + } + } + + public class BrownCoral2 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + Main.tileLighted[Type] = true; + TileObjectData.newTile.Width = 4; + TileObjectData.newTile.Height = 4; + TileObjectData.newTile.Origin = new Point16(2, 3); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(113, 80, 28)); + DustType = 155; + HitSound = SoundID.Dig; + } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 244f / 400f; + g = 238f / 400f; + b = 162f / 400f; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/BrownCoral1.png b/Tiles/SunkenSea/Ambient/BrownCoral1.png new file mode 100644 index 0000000000..0462d340c0 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/BrownCoral1.png differ diff --git a/Tiles/SunkenSea/Ambient/BrownCoral2.png b/Tiles/SunkenSea/Ambient/BrownCoral2.png new file mode 100644 index 0000000000..dda7733164 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/BrownCoral2.png differ diff --git a/Tiles/SunkenSea/Ambient/CoralPileGiant.cs b/Tiles/SunkenSea/Ambient/CoralPileGiant.cs new file mode 100644 index 0000000000..3951a41547 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/CoralPileGiant.cs @@ -0,0 +1,33 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class CoralPileGiant : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.Width = 3; + TileObjectData.newTile.Height = 4; + TileObjectData.newTile.Origin = new Point16(2, 3); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(126, 80, 69)); + DustType = 155; + HitSound = SoundID.Dig; + } + } +} \ No newline at end of file diff --git a/Tiles/SunkenSea/Ambient/CoralPileGiant.png b/Tiles/SunkenSea/Ambient/CoralPileGiant.png new file mode 100644 index 0000000000..60bf132e5c Binary files /dev/null and b/Tiles/SunkenSea/Ambient/CoralPileGiant.png differ diff --git a/Tiles/SunkenSea/CoralPileLarge.cs b/Tiles/SunkenSea/Ambient/CoralPileLarge.cs similarity index 96% rename from Tiles/SunkenSea/CoralPileLarge.cs rename to Tiles/SunkenSea/Ambient/CoralPileLarge.cs index 22b5133821..72923bb43f 100644 --- a/Tiles/SunkenSea/CoralPileLarge.cs +++ b/Tiles/SunkenSea/Ambient/CoralPileLarge.cs @@ -6,7 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.SunkenSea +namespace CalamityMod.Tiles.SunkenSea.Ambient { public class CoralPileLarge : ModTile { diff --git a/Tiles/SunkenSea/CoralPileLarge.png b/Tiles/SunkenSea/Ambient/CoralPileLarge.png similarity index 100% rename from Tiles/SunkenSea/CoralPileLarge.png rename to Tiles/SunkenSea/Ambient/CoralPileLarge.png diff --git a/Tiles/SunkenSea/Ambient/DepthVines.cs b/Tiles/SunkenSea/Ambient/DepthVines.cs new file mode 100644 index 0000000000..faf1b14f81 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/DepthVines.cs @@ -0,0 +1,88 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class DepthVines : ModTile + { + public override void SetStaticDefaults() + { + Main.tileCut[Type] = true; + Main.tileSolid[Type] = false; + Main.tileNoFail[Type] = true; + Main.tileNoAttach[Type] = true; + TileID.Sets.IsVine[Type] = true; + TileID.Sets.VineThreads[Type] = true; + AddMapEntry(new Color(41, 97, 126)); + DustType = DustID.Grass; + HitSound = SoundID.Grass; + } + + public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) + { + Tile tile = Framing.GetTileSafely(i, j + 1); + if (tile.HasTile && tile.TileType == Type) + { + WorldGen.KillTile(i, j + 1); + } + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + Tile tileAbove = Framing.GetTileSafely(i, j - 1); + int type = -1; + if (tileAbove.HasTile && !tileAbove.BottomSlope) + { + type = tileAbove.TileType; + } + + if (type == ModContent.TileType() || type == Type) + { + return true; + } + + WorldGen.KillTile(i, j); + return true; + } + + public override void RandomUpdate(int i, int j) + { + Tile tileBelow = Framing.GetTileSafely(i, j + 1); + if (WorldGen.genRand.NextBool(5) && !tileBelow.HasTile && tileBelow.LiquidType != LiquidID.Lava) + { + bool PlaceVine = false; + int Test = j; + while (Test > j - 10) + { + Tile testTile = Framing.GetTileSafely(i, Test); + if (testTile.BottomSlope) + { + break; + } + else if (!testTile.HasTile || testTile.TileType != ModContent.TileType()) + { + Test--; + continue; + } + PlaceVine = true; + break; + } + + if (PlaceVine) + { + tileBelow.TileType = Type; + tileBelow.HasTile = true; + WorldGen.SquareTileFrame(i, j + 1, true); + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, i, j + 1, 3, TileChangeType.None); + } + } + } + } + } +} diff --git a/Tiles/SunkenSea/Ambient/DepthVines.png b/Tiles/SunkenSea/Ambient/DepthVines.png new file mode 100644 index 0000000000..63ed9cd2b4 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/DepthVines.png differ diff --git a/Tiles/SunkenSea/FanCoral.cs b/Tiles/SunkenSea/Ambient/FanCoral.cs similarity index 81% rename from Tiles/SunkenSea/FanCoral.cs rename to Tiles/SunkenSea/Ambient/FanCoral.cs index 9159a92307..26e5feed73 100644 --- a/Tiles/SunkenSea/FanCoral.cs +++ b/Tiles/SunkenSea/Ambient/FanCoral.cs @@ -1,11 +1,12 @@ -using Microsoft.Xna.Framework; +using System; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Enums; using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.SunkenSea +namespace CalamityMod.Tiles.SunkenSea.Ambient { public class FanCoral : ModTile { @@ -22,11 +23,10 @@ namespace CalamityMod.Tiles.SunkenSea base.SetStaticDefaults(); } - public override void NearbyEffects(int i, int j, bool closer) { if (!Main.dedServ) - Main.SceneMetrics.ActiveFountainColor = ModContent.Find("CalamityMod/SunkenSeaWater").Slot; + Main.SceneMetrics.ActiveFountainColor = ModContent.Find("CalamityMod/SunkenSeaBurrowsWater").Slot; } public override void NumDust(int i, int j, bool fail, ref int num) @@ -36,9 +36,9 @@ namespace CalamityMod.Tiles.SunkenSea public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - r = 0.3f; - g = 0.75f; - b = 0.75f; + r = 225f / 255f; + g = 255f / 255f; + b = 255f / 255f; } } } diff --git a/Tiles/SunkenSea/Ambient/FanCoral.png b/Tiles/SunkenSea/Ambient/FanCoral.png new file mode 100644 index 0000000000..9d6f7aa87d Binary files /dev/null and b/Tiles/SunkenSea/Ambient/FanCoral.png differ diff --git a/Tiles/SunkenSea/Ambient/GiantNavystone.cs b/Tiles/SunkenSea/Ambient/GiantNavystone.cs new file mode 100644 index 0000000000..5d55115998 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/GiantNavystone.cs @@ -0,0 +1,55 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class GiantNavystone1 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.Width = 5; + TileObjectData.newTile.Height = 5; + TileObjectData.newTile.Origin = new Point16(2, 4); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(0, 62, 84)); + DustType = 96; + HitSound = SoundID.Dig; + } + } + + public class GiantNavystone2 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileSolid[Type] = false; + TileObjectData.newTile.Width = 5; + TileObjectData.newTile.Height = 4; + TileObjectData.newTile.Origin = new Point16(2, 3); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; + TileObjectData.newTile.StyleWrapLimit = 36; + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.CoordinatePadding = 2; + TileObjectData.newTile.DrawYOffset = 3; + TileObjectData.addTile(Type); + AddMapEntry(new Color(0, 62, 84)); + DustType = 96; + HitSound = SoundID.Dig; + } + } +} \ No newline at end of file diff --git a/Tiles/SunkenSea/Ambient/GiantNavystone1.png b/Tiles/SunkenSea/Ambient/GiantNavystone1.png new file mode 100644 index 0000000000..30991cd306 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/GiantNavystone1.png differ diff --git a/Tiles/SunkenSea/Ambient/GiantNavystone2.png b/Tiles/SunkenSea/Ambient/GiantNavystone2.png new file mode 100644 index 0000000000..05d8cf79f8 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/GiantNavystone2.png differ diff --git a/Tiles/SunkenSea/Ambient/Kelp.png b/Tiles/SunkenSea/Ambient/Kelp.png new file mode 100644 index 0000000000..797e3a4875 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/Kelp.png differ diff --git a/Tiles/SunkenSea/MediumCoral.cs b/Tiles/SunkenSea/Ambient/MediumCoral.cs similarity index 54% rename from Tiles/SunkenSea/MediumCoral.cs rename to Tiles/SunkenSea/Ambient/MediumCoral.cs index 0b81d79d94..5c27fcdb6f 100644 --- a/Tiles/SunkenSea/MediumCoral.cs +++ b/Tiles/SunkenSea/Ambient/MediumCoral.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.SunkenSea +namespace CalamityMod.Tiles.SunkenSea.Ambient { public class MediumCoral : ModTile { @@ -14,6 +14,7 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; + Main.tileLighted[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); @@ -26,9 +27,31 @@ namespace CalamityMod.Tiles.SunkenSea { num = fail ? 1 : 2; } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 229f / 350f; + g = 137f / 350f; + b = 204f / 350f; + } } public class MediumCoral2 : MediumCoral { + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 60f / 400f; + g = 110f / 400f; + b = 146f / 400f; + } + } + + public class MediumCoral3 : MediumCoral + { + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 60f / 255f; + g = 110f / 255f; + b = 146f / 255f; + } } } diff --git a/Tiles/SunkenSea/MediumCoral.png b/Tiles/SunkenSea/Ambient/MediumCoral.png similarity index 100% rename from Tiles/SunkenSea/MediumCoral.png rename to Tiles/SunkenSea/Ambient/MediumCoral.png diff --git a/Tiles/SunkenSea/MediumCoral2.png b/Tiles/SunkenSea/Ambient/MediumCoral2.png similarity index 100% rename from Tiles/SunkenSea/MediumCoral2.png rename to Tiles/SunkenSea/Ambient/MediumCoral2.png diff --git a/Tiles/SunkenSea/Ambient/MediumCoral3.png b/Tiles/SunkenSea/Ambient/MediumCoral3.png new file mode 100644 index 0000000000..fdc4826321 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/MediumCoral3.png differ diff --git a/Tiles/SunkenSea/Ambient/NavystonePile.cs b/Tiles/SunkenSea/Ambient/NavystonePile.cs new file mode 100644 index 0000000000..9f98dc98a6 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/NavystonePile.cs @@ -0,0 +1,33 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.DataStructures; +using Terraria.Enums; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class NavystonePile1 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.addTile(Type); + AddMapEntry(new Color(0, 62, 84)); + DustType = 96; + HitSound = SoundID.Dig; + } + } + + public class NavystonePile2 : NavystonePile1 + { + } + + public class NavystonePile3 : NavystonePile1 + { + } +} \ No newline at end of file diff --git a/Tiles/SunkenSea/Ambient/NavystonePile1.png b/Tiles/SunkenSea/Ambient/NavystonePile1.png new file mode 100644 index 0000000000..45709a1865 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/NavystonePile1.png differ diff --git a/Tiles/SunkenSea/Ambient/NavystonePile2.png b/Tiles/SunkenSea/Ambient/NavystonePile2.png new file mode 100644 index 0000000000..a3ff914034 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/NavystonePile2.png differ diff --git a/Tiles/SunkenSea/Ambient/NavystonePile3.png b/Tiles/SunkenSea/Ambient/NavystonePile3.png new file mode 100644 index 0000000000..73fa4a8fa4 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/NavystonePile3.png differ diff --git a/Tiles/SunkenSea/Ambient/NavystonePileSmall1.png b/Tiles/SunkenSea/Ambient/NavystonePileSmall1.png new file mode 100644 index 0000000000..d4e121013f Binary files /dev/null and b/Tiles/SunkenSea/Ambient/NavystonePileSmall1.png differ diff --git a/Tiles/SunkenSea/Ambient/NavystonePileSmall2.png b/Tiles/SunkenSea/Ambient/NavystonePileSmall2.png new file mode 100644 index 0000000000..e47f6e8a47 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/NavystonePileSmall2.png differ diff --git a/Tiles/SunkenSea/Ambient/NavystonePileSmall3.png b/Tiles/SunkenSea/Ambient/NavystonePileSmall3.png new file mode 100644 index 0000000000..3892fee61c Binary files /dev/null and b/Tiles/SunkenSea/Ambient/NavystonePileSmall3.png differ diff --git a/Tiles/SunkenSea/SeaAnemone.cs b/Tiles/SunkenSea/Ambient/SeaAnemone.cs similarity index 95% rename from Tiles/SunkenSea/SeaAnemone.cs rename to Tiles/SunkenSea/Ambient/SeaAnemone.cs index c4f0fe6c6b..fe95a937cc 100644 --- a/Tiles/SunkenSea/SeaAnemone.cs +++ b/Tiles/SunkenSea/Ambient/SeaAnemone.cs @@ -4,7 +4,7 @@ using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.SunkenSea +namespace CalamityMod.Tiles.SunkenSea.Ambient { public class SeaAnemone : ModTile { diff --git a/Tiles/SunkenSea/SeaAnemone.png b/Tiles/SunkenSea/Ambient/SeaAnemone.png similarity index 100% rename from Tiles/SunkenSea/SeaAnemone.png rename to Tiles/SunkenSea/Ambient/SeaAnemone.png diff --git a/Tiles/SunkenSea/SmallBrainCoral.cs b/Tiles/SunkenSea/Ambient/SmallBrainCoral.cs similarity index 97% rename from Tiles/SunkenSea/SmallBrainCoral.cs rename to Tiles/SunkenSea/Ambient/SmallBrainCoral.cs index 458ca975ea..6013e6ac73 100644 --- a/Tiles/SunkenSea/SmallBrainCoral.cs +++ b/Tiles/SunkenSea/Ambient/SmallBrainCoral.cs @@ -7,7 +7,7 @@ using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.SunkenSea +namespace CalamityMod.Tiles.SunkenSea.Ambient { public class SmallBrainCoral : ModTile { diff --git a/Tiles/SunkenSea/SmallBrainCoral.png b/Tiles/SunkenSea/Ambient/SmallBrainCoral.png similarity index 100% rename from Tiles/SunkenSea/SmallBrainCoral.png rename to Tiles/SunkenSea/Ambient/SmallBrainCoral.png diff --git a/Tiles/SunkenSea/SmallCorals.cs b/Tiles/SunkenSea/Ambient/SmallCorals.cs similarity index 67% rename from Tiles/SunkenSea/SmallCorals.cs rename to Tiles/SunkenSea/Ambient/SmallCorals.cs index 6848dccbca..e430167287 100644 --- a/Tiles/SunkenSea/SmallCorals.cs +++ b/Tiles/SunkenSea/Ambient/SmallCorals.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.SunkenSea +namespace CalamityMod.Tiles.SunkenSea.Ambient { public class SmallCorals : ModTile { @@ -16,7 +16,7 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileNoAttach[Type] = true; Main.tileNoFail[Type] = true; Main.tileLavaDeath[Type] = true; - Main.tileWaterDeath[Type] = true; + Main.tileWaterDeath[Type] = false; Main.tileFrameImportant[Type] = true; TileID.Sets.ReplaceTileBreakUp[Type] = true; TileID.Sets.SwaysInWindBasic[Type] = false; @@ -29,10 +29,30 @@ namespace CalamityMod.Tiles.SunkenSea base.SetStaticDefaults(); } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + Tile tileBelow = Framing.GetTileSafely(i, j + 1); + int type = -1; + + if (tileBelow.HasTile) + { + type = tileBelow.TileType; + } + + if (type == ModContent.TileType()) + { + return true; + } + + WorldGen.KillTile(i, j); + + return true; + } + public override void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height, ref short tileFrameX, ref short tileFrameY) { - offsetY = -16; - height = 32; + offsetY = 0; + height = 16; } } } diff --git a/Tiles/SunkenSea/Ambient/SmallCorals.png b/Tiles/SunkenSea/Ambient/SmallCorals.png new file mode 100644 index 0000000000..1aa6601be7 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/SmallCorals.png differ diff --git a/Tiles/SunkenSea/SmallTubeCoral.cs b/Tiles/SunkenSea/Ambient/SmallTubeCoral.cs similarity index 93% rename from Tiles/SunkenSea/SmallTubeCoral.cs rename to Tiles/SunkenSea/Ambient/SmallTubeCoral.cs index 16d683138f..f37261d8d9 100644 --- a/Tiles/SunkenSea/SmallTubeCoral.cs +++ b/Tiles/SunkenSea/Ambient/SmallTubeCoral.cs @@ -4,7 +4,7 @@ using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.SunkenSea +namespace CalamityMod.Tiles.SunkenSea.Ambient { public class SmallTubeCoral : ModTile { diff --git a/Tiles/SunkenSea/SmallTubeCoral.png b/Tiles/SunkenSea/Ambient/SmallTubeCoral.png similarity index 100% rename from Tiles/SunkenSea/SmallTubeCoral.png rename to Tiles/SunkenSea/Ambient/SmallTubeCoral.png diff --git a/Tiles/SunkenSea/SmallWideCoral.cs b/Tiles/SunkenSea/Ambient/SmallWideCoral.cs similarity index 61% rename from Tiles/SunkenSea/SmallWideCoral.cs rename to Tiles/SunkenSea/Ambient/SmallWideCoral.cs index f0c524f145..5d7641c3f6 100644 --- a/Tiles/SunkenSea/SmallWideCoral.cs +++ b/Tiles/SunkenSea/Ambient/SmallWideCoral.cs @@ -4,7 +4,7 @@ using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.SunkenSea +namespace CalamityMod.Tiles.SunkenSea.Ambient { public class SmallWideCoral : ModTile { @@ -14,6 +14,7 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; + Main.tileLighted[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); @@ -22,8 +23,20 @@ namespace CalamityMod.Tiles.SunkenSea base.SetStaticDefaults(); } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 161f / 500f; + g = 183f / 500f; + b = 73f / 500f; + } } public class SmallWideCoral2 : SmallWideCoral { + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 229f / 700f; + g = 137f / 700f; + b = 204f / 700f; + } } } diff --git a/Tiles/SunkenSea/SmallWideCoral.png b/Tiles/SunkenSea/Ambient/SmallWideCoral.png similarity index 100% rename from Tiles/SunkenSea/SmallWideCoral.png rename to Tiles/SunkenSea/Ambient/SmallWideCoral.png diff --git a/Tiles/SunkenSea/SmallWideCoral2.png b/Tiles/SunkenSea/Ambient/SmallWideCoral2.png similarity index 100% rename from Tiles/SunkenSea/SmallWideCoral2.png rename to Tiles/SunkenSea/Ambient/SmallWideCoral2.png diff --git a/Tiles/SunkenSea/SunkenStalactite.cs b/Tiles/SunkenSea/Ambient/SunkenStalactite.cs similarity index 95% rename from Tiles/SunkenSea/SunkenStalactite.cs rename to Tiles/SunkenSea/Ambient/SunkenStalactite.cs index da6c615697..ab84ff433c 100644 --- a/Tiles/SunkenSea/SunkenStalactite.cs +++ b/Tiles/SunkenSea/Ambient/SunkenStalactite.cs @@ -9,7 +9,7 @@ using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.SunkenSea +namespace CalamityMod.Tiles.SunkenSea.Ambient { [LegacyName("SunkenStalactites")] public class SunkenStalactite1 : ModTile diff --git a/Tiles/SunkenSea/SunkenStalactite1.png b/Tiles/SunkenSea/Ambient/SunkenStalactite1.png similarity index 100% rename from Tiles/SunkenSea/SunkenStalactite1.png rename to Tiles/SunkenSea/Ambient/SunkenStalactite1.png diff --git a/Tiles/SunkenSea/SunkenStalactite2.png b/Tiles/SunkenSea/Ambient/SunkenStalactite2.png similarity index 100% rename from Tiles/SunkenSea/SunkenStalactite2.png rename to Tiles/SunkenSea/Ambient/SunkenStalactite2.png diff --git a/Tiles/SunkenSea/SunkenStalactite3.png b/Tiles/SunkenSea/Ambient/SunkenStalactite3.png similarity index 100% rename from Tiles/SunkenSea/SunkenStalactite3.png rename to Tiles/SunkenSea/Ambient/SunkenStalactite3.png diff --git a/Tiles/SunkenSea/SunkenStalactites.png b/Tiles/SunkenSea/Ambient/SunkenStalactites.png similarity index 100% rename from Tiles/SunkenSea/SunkenStalactites.png rename to Tiles/SunkenSea/Ambient/SunkenStalactites.png diff --git a/Tiles/SunkenSea/SunkenStalactitesSmall.cs b/Tiles/SunkenSea/Ambient/SunkenStalactitesSmall.cs similarity index 95% rename from Tiles/SunkenSea/SunkenStalactitesSmall.cs rename to Tiles/SunkenSea/Ambient/SunkenStalactitesSmall.cs index a8c2b84f4d..8200dfda84 100644 --- a/Tiles/SunkenSea/SunkenStalactitesSmall.cs +++ b/Tiles/SunkenSea/Ambient/SunkenStalactitesSmall.cs @@ -9,7 +9,7 @@ using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.SunkenSea +namespace CalamityMod.Tiles.SunkenSea.Ambient { public class SunkenStalactitesSmall : ModTile { diff --git a/Tiles/SunkenSea/SunkenStalactitesSmall.png b/Tiles/SunkenSea/Ambient/SunkenStalactitesSmall.png similarity index 100% rename from Tiles/SunkenSea/SunkenStalactitesSmall.png rename to Tiles/SunkenSea/Ambient/SunkenStalactitesSmall.png diff --git a/Tiles/SunkenSea/SunkenStalagmite.cs b/Tiles/SunkenSea/Ambient/SunkenStalagmite.cs similarity index 95% rename from Tiles/SunkenSea/SunkenStalagmite.cs rename to Tiles/SunkenSea/Ambient/SunkenStalagmite.cs index 9f2f977034..43fc2022a2 100644 --- a/Tiles/SunkenSea/SunkenStalagmite.cs +++ b/Tiles/SunkenSea/Ambient/SunkenStalagmite.cs @@ -9,7 +9,7 @@ using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.SunkenSea +namespace CalamityMod.Tiles.SunkenSea.Ambient { [LegacyName("SunkenStalagmites")] public class SunkenStalagmite1 : ModTile diff --git a/Tiles/SunkenSea/SunkenStalagmite1.png b/Tiles/SunkenSea/Ambient/SunkenStalagmite1.png similarity index 100% rename from Tiles/SunkenSea/SunkenStalagmite1.png rename to Tiles/SunkenSea/Ambient/SunkenStalagmite1.png diff --git a/Tiles/SunkenSea/SunkenStalagmite2.png b/Tiles/SunkenSea/Ambient/SunkenStalagmite2.png similarity index 100% rename from Tiles/SunkenSea/SunkenStalagmite2.png rename to Tiles/SunkenSea/Ambient/SunkenStalagmite2.png diff --git a/Tiles/SunkenSea/SunkenStalagmite3.png b/Tiles/SunkenSea/Ambient/SunkenStalagmite3.png similarity index 100% rename from Tiles/SunkenSea/SunkenStalagmite3.png rename to Tiles/SunkenSea/Ambient/SunkenStalagmite3.png diff --git a/Tiles/SunkenSea/SunkenStalagmitesSmall.cs b/Tiles/SunkenSea/Ambient/SunkenStalagmitesSmall.cs similarity index 93% rename from Tiles/SunkenSea/SunkenStalagmitesSmall.cs rename to Tiles/SunkenSea/Ambient/SunkenStalagmitesSmall.cs index 708499454c..e38fa0a231 100644 --- a/Tiles/SunkenSea/SunkenStalagmitesSmall.cs +++ b/Tiles/SunkenSea/Ambient/SunkenStalagmitesSmall.cs @@ -9,7 +9,7 @@ using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.SunkenSea +namespace CalamityMod.Tiles.SunkenSea.Ambient { public class SunkenStalagmitesSmall : ModTile { diff --git a/Tiles/SunkenSea/SunkenStalagmitesSmall.png b/Tiles/SunkenSea/Ambient/SunkenStalagmitesSmall.png similarity index 100% rename from Tiles/SunkenSea/SunkenStalagmitesSmall.png rename to Tiles/SunkenSea/Ambient/SunkenStalagmitesSmall.png diff --git a/Tiles/SunkenSea/TableCoral.cs b/Tiles/SunkenSea/Ambient/TableCoral.cs similarity index 72% rename from Tiles/SunkenSea/TableCoral.cs rename to Tiles/SunkenSea/Ambient/TableCoral.cs index 27ebb6385d..7cf5773531 100644 --- a/Tiles/SunkenSea/TableCoral.cs +++ b/Tiles/SunkenSea/Ambient/TableCoral.cs @@ -6,12 +6,10 @@ using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.SunkenSea +namespace CalamityMod.Tiles.SunkenSea.Ambient { public class TableCoral : ModTile { - int subsheetHeight = 34; - int subsheetWidth = 108; public override void SetStaticDefaults() { Main.tileFrameImportant[Type] = true; @@ -26,20 +24,19 @@ namespace CalamityMod.Tiles.SunkenSea TileObjectData.addTile(Type); DustType = 253; AddMapEntry(new Color(54, 69, 72)); - - base.SetStaticDefaults(); } public override void NumDust(int i, int j, bool fail, ref int num) { num = fail ? 1 : 3; } - public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) - { - int xPos = i % 1; - int yPos = j % 3; - frameXOffset = xPos * subsheetWidth; - frameYOffset = yPos * subsheetHeight; - } + } + + public class TableCoral2 : TableCoral + { + } + + public class TableCoral3 : TableCoral + { } } diff --git a/Tiles/SunkenSea/Ambient/TableCoral.png b/Tiles/SunkenSea/Ambient/TableCoral.png new file mode 100644 index 0000000000..45ea42abfd Binary files /dev/null and b/Tiles/SunkenSea/Ambient/TableCoral.png differ diff --git a/Tiles/SunkenSea/Ambient/TableCoral2.png b/Tiles/SunkenSea/Ambient/TableCoral2.png new file mode 100644 index 0000000000..90c37eaa63 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/TableCoral2.png differ diff --git a/Tiles/SunkenSea/Ambient/TableCoral3.png b/Tiles/SunkenSea/Ambient/TableCoral3.png new file mode 100644 index 0000000000..4b9b83df62 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/TableCoral3.png differ diff --git a/Tiles/SunkenSea/TubeCoral.cs b/Tiles/SunkenSea/Ambient/TubeCoral.cs similarity index 95% rename from Tiles/SunkenSea/TubeCoral.cs rename to Tiles/SunkenSea/Ambient/TubeCoral.cs index 31156612a1..e8a7b0fd81 100644 --- a/Tiles/SunkenSea/TubeCoral.cs +++ b/Tiles/SunkenSea/Ambient/TubeCoral.cs @@ -4,7 +4,7 @@ using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; -namespace CalamityMod.Tiles.SunkenSea +namespace CalamityMod.Tiles.SunkenSea.Ambient { public class TubeCoral : ModTile { diff --git a/Tiles/SunkenSea/TubeCoral.png b/Tiles/SunkenSea/Ambient/TubeCoral.png similarity index 100% rename from Tiles/SunkenSea/TubeCoral.png rename to Tiles/SunkenSea/Ambient/TubeCoral.png diff --git a/Tiles/SunkenSea/Ambient/WallCoral.cs b/Tiles/SunkenSea/Ambient/WallCoral.cs new file mode 100644 index 0000000000..634fe16177 --- /dev/null +++ b/Tiles/SunkenSea/Ambient/WallCoral.cs @@ -0,0 +1,72 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.Localization; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.SunkenSea.Ambient +{ + public class WallCoral1 : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileSolidTop[Type] = false; + Main.tileLighted[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.None, 0, 0); + TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile); + TileObjectData.newAlternate.AnchorLeft = new AnchorData(AnchorType.SolidTile, 2, 0); + TileObjectData.addAlternate(1); + TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, 2, 0); + TileObjectData.addTile(Type); + DustType = 253; + AddMapEntry(new Color(54, 69, 72)); + } + + 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 = 189f / 450f; + g = 72f / 450f; + b = 72f / 450f; + } + } + + public class WallCoral2 : WallCoral1 + { + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 96f / 450f; + g = 157f / 450f; + b = 187f / 450f; + } + } + + public class WallCoral3 : WallCoral1 + { + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 68f / 450f; + g = 154f / 450f; + b = 128f / 450f; + } + } + + public class WallCoral4 : WallCoral1 + { + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 206f / 450f; + g = 88f / 450f; + b = 174f / 450f; + } + } +} diff --git a/Tiles/SunkenSea/Ambient/WallCoral1.png b/Tiles/SunkenSea/Ambient/WallCoral1.png new file mode 100644 index 0000000000..5efc01eaec Binary files /dev/null and b/Tiles/SunkenSea/Ambient/WallCoral1.png differ diff --git a/Tiles/SunkenSea/Ambient/WallCoral2.png b/Tiles/SunkenSea/Ambient/WallCoral2.png new file mode 100644 index 0000000000..ab007eeb0f Binary files /dev/null and b/Tiles/SunkenSea/Ambient/WallCoral2.png differ diff --git a/Tiles/SunkenSea/Ambient/WallCoral3.png b/Tiles/SunkenSea/Ambient/WallCoral3.png new file mode 100644 index 0000000000..c5017e1401 Binary files /dev/null and b/Tiles/SunkenSea/Ambient/WallCoral3.png differ diff --git a/Tiles/SunkenSea/Ambient/WallCoral4.png b/Tiles/SunkenSea/Ambient/WallCoral4.png new file mode 100644 index 0000000000..901f50fcdb Binary files /dev/null and b/Tiles/SunkenSea/Ambient/WallCoral4.png differ diff --git a/Tiles/SunkenSea/Basalt.cs b/Tiles/SunkenSea/Basalt.cs new file mode 100644 index 0000000000..400d198569 --- /dev/null +++ b/Tiles/SunkenSea/Basalt.cs @@ -0,0 +1,61 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class Basalt : ModTile + { + private int sheetWidth = 234; + private int sheetHeight = 90; + + public byte[,] tileAdjacency; + public byte[,] secondTileAdjacency; + public byte[,] thirdTileAdjacency; + public byte[,] fourthTileAdjacency; + + public override void SetStaticDefaults() + { + TileID.Sets.GeneralPlacementTiles[Type] = false; + + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + Main.tileShine2[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithDesert(Type); + + DustType = 36; + HitSound = SoundID.Tink; + + AddMapEntry(new Color(58, 55, 70)); + + MinPick = 100; + + // 02JUN2024: Ozzatron: RuneSand has no merge + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); + this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); + this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); + this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); + } + + 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(100, 100, 100), 1f); + return false; + } + + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) + { + frameXOffset = i % 4 * sheetWidth; + frameYOffset = j % 4 * sheetHeight; + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + // 02JUN2024: Ozzatron: unclear if this is the correct framing strategy for Basalt + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/Basalt.png b/Tiles/SunkenSea/Basalt.png new file mode 100644 index 0000000000..05a9bf9830 Binary files /dev/null and b/Tiles/SunkenSea/Basalt.png differ diff --git a/Tiles/SunkenSea/BlackPearlPile.cs b/Tiles/SunkenSea/BlackPearlPile.cs new file mode 100644 index 0000000000..79329bcd99 --- /dev/null +++ b/Tiles/SunkenSea/BlackPearlPile.cs @@ -0,0 +1,42 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class BlackPearlPile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + TileID.Sets.HasSlopeFrames[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + + Main.tileShine[Type] = 3500; + Main.tileShine2[Type] = true; + + TileID.Sets.ChecksForMerge[Type] = true; + HitSound = SoundID.Shatter; + DustType = 82; + AddMapEntry(new Color(29, 33, 38)); + + TileID.Sets.CanBeDugByShovel[Type] = true; + + // 02JUN2024: Ozzatron: RuneSand has no merge + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); + // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/BlackPearlPile.png b/Tiles/SunkenSea/BlackPearlPile.png new file mode 100644 index 0000000000..9e0e102c2c Binary files /dev/null and b/Tiles/SunkenSea/BlackPearlPile.png differ diff --git a/Tiles/SunkenSea/CyanCoral.cs b/Tiles/SunkenSea/CyanCoral.cs new file mode 100644 index 0000000000..31182aeff1 --- /dev/null +++ b/Tiles/SunkenSea/CyanCoral.cs @@ -0,0 +1,66 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class CyanCoral : ModTile + { + public byte[,] tileAdjacency; + public byte[,] secondTileAdjacency; + public byte[,] thirdTileAdjacency; + public byte[,] fourthTileAdjacency; + + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + Main.tileLighted[Type] = true; + + TileID.Sets.HasSlopeFrames[Type] = true; + + TileID.Sets.ChecksForMerge[Type] = true; + HitSound = SoundID.Dig; + DustType = 119; + AddMapEntry(new Color(92, 168, 198)); + Main.tileShine2[Type] = true; + + TileID.Sets.CanBeDugByShovel[Type] = true; + + // 02JUN2024: Ozzatron: RuneSand has no merge + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); + // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (!Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile) + { + float brightness = 0.9f; + Color Color1 = new Color(130, 213, 247); + Color Color2 = new Color(26, 68, 85); + Color value = Color.Lerp(Color1, Color2, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); + Color value1 = Color.Lerp(Color1, Color2, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); + r = (value.R + value1.R) / 400f; + g = (value.G + value1.G) / 400f; + b = (value.B + value1.B) / 400f; + r *= brightness; + g *= brightness; + b *= brightness; + } + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/CyanCoral.png b/Tiles/SunkenSea/CyanCoral.png new file mode 100644 index 0000000000..318df78b1c Binary files /dev/null and b/Tiles/SunkenSea/CyanCoral.png differ diff --git a/Tiles/SunkenSea/Driftwood.cs b/Tiles/SunkenSea/Driftwood.cs new file mode 100644 index 0000000000..87238d3856 --- /dev/null +++ b/Tiles/SunkenSea/Driftwood.cs @@ -0,0 +1,43 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.Metadata; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class Driftwood : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileMergeDirt[Type] = false; + Main.tileBlockLight[Type] = true; + TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Wood"]); + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeDecorativeTiles(Type); + CalamityUtils.MergeWithDesert(Type); + + TileID.Sets.ChecksForMerge[Type] = true; + TileID.Sets.HasSlopeFrames[Type] = true; + HitSound = SoundID.Dig; + DustType = 121; + AddMapEntry(new Color(136, 129, 154)); + + // 02JUN2024: Ozzatron: RuneSand has no merge + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); + // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + + this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); + this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); + this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/Driftwood.png b/Tiles/SunkenSea/Driftwood.png new file mode 100644 index 0000000000..d128a364a4 Binary files /dev/null and b/Tiles/SunkenSea/Driftwood.png differ diff --git a/Tiles/SunkenSea/EutrophicSand.cs b/Tiles/SunkenSea/EutrophicSand.cs index c9ef48f1f5..88f3b3f72b 100644 --- a/Tiles/SunkenSea/EutrophicSand.cs +++ b/Tiles/SunkenSea/EutrophicSand.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using CalamityMod.Items.Placeables; +using CalamityMod.Tiles.SunkenSea.Ambient; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -10,12 +11,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea { - public class EutrophicSand : ModTile, IMergeableTile + public class EutrophicSand : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { + TileID.Sets.GeneralPlacementTiles[Type] = false; + Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; TileMaterials.SetForTileId(Type, TileMaterials._materialsByName["Sand"]); @@ -24,13 +25,13 @@ namespace CalamityMod.Tiles.SunkenSea CalamityUtils.MergeWithDesert(Type); // Tile blends with sandstone, which it is set to merge with here Main.tileShine[Type] = 1800; - Main.tileShine2[Type] = false; + Main.tileShine2[Type] = true; TileID.Sets.ChecksForMerge[Type] = true; TileID.Sets.CanBeDugByShovel[Type] = true; DustType = 108; - AddMapEntry(new Color(92, 145, 167)); + AddMapEntry(new Color(158, 203, 234)); this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); @@ -43,19 +44,76 @@ namespace CalamityMod.Tiles.SunkenSea Tile up = Main.tile[i, j - 1]; Tile up2 = Main.tile[i, j - 2]; - // Place SmallCorals - if (WorldGen.genRand.NextBool(8) && !up.HasTile && !up2.HasTile && up.LiquidAmount > 0 && up2.LiquidAmount > 0 && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) + if (!up.HasTile && !up2.HasTile && up.LiquidAmount > 0 && up2.LiquidAmount > 0 && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) { - up.TileType = (ushort)ModContent.TileType(); - up.HasTile = true; - up.TileFrameY = 0; + // Place corals + if (WorldGen.genRand.NextBool(3)) + { + up.TileType = (ushort)ModContent.TileType(); + up.HasTile = true; + up.TileFrameY = 0; - // 6 different frames, choose a random one - up.TileFrameX = (short)(WorldGen.genRand.Next(6) * 18); - WorldGen.SquareTileFrame(i, j - 1, true); + // 15 different frames, choose a random one + up.TileFrameX = (short)(WorldGen.genRand.Next(15) * 18); + WorldGen.SquareTileFrame(i, j - 1, true); - if (Main.netMode == NetmodeID.Server) - NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None); + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None); + } + } + + //multi-colored corals + if (WorldGen.genRand.NextBool(3)) + { + ushort[] ColoredCorals = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + ushort newObject = Main.rand.Next(ColoredCorals); + + WorldGen.PlaceObject(i, j - 1, newObject, true); + NetMessage.SendObjectPlacement(-1, i, j - 1, newObject, 0, 0, -1, -1); + } + + //blue coral trees + if (WorldGen.genRand.NextBool(6)) + { + ushort[] BlueCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + ushort newObject = Main.rand.Next(BlueCorals); + + WorldGen.PlaceObject(i, j - 1, newObject, true); + NetMessage.SendObjectPlacement(-1, i, j - 1, newObject, 0, 0, -1, -1); + } + + //brown coral trees + if (WorldGen.genRand.NextBool(6)) + { + ushort[] BrownCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + ushort newObject = Main.rand.Next(BrownCorals); + + WorldGen.PlaceObject(i, j - 1, newObject, true); + NetMessage.SendObjectPlacement(-1, i, j - 1, newObject, 0, 0, -1, -1); + } + + //fan coral + if (WorldGen.genRand.NextBool(10)) + { + WorldGen.PlaceObject(i, j - 1, (ushort)ModContent.TileType()); + } + + //misc corals + if (WorldGen.genRand.NextBool()) + { + ushort[] MiscCorals = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + ushort newObject = Main.rand.Next(MiscCorals); + + WorldGen.PlaceObject(i, j - 1, newObject, true); + NetMessage.SendObjectPlacement(-1, i, j - 1, newObject, 0, 0, -1, -1); + } } } diff --git a/Tiles/SunkenSea/FanCoral.png b/Tiles/SunkenSea/FanCoral.png deleted file mode 100644 index 0ffee8ecf3..0000000000 Binary files a/Tiles/SunkenSea/FanCoral.png and /dev/null differ diff --git a/Tiles/SunkenSea/HardenedEutrophicSand.cs b/Tiles/SunkenSea/HardenedEutrophicSand.cs index 209e0a22cd..df2fd299ba 100644 --- a/Tiles/SunkenSea/HardenedEutrophicSand.cs +++ b/Tiles/SunkenSea/HardenedEutrophicSand.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using CalamityMod.Items.Placeables; +using CalamityMod.Tiles.SunkenSea.Ambient; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -8,10 +10,8 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea { - public class HardenedEutrophicSand : ModTile, IMergeableTile + public class HardenedEutrophicSand : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -20,14 +20,14 @@ namespace CalamityMod.Tiles.SunkenSea CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithDesert(Type); - Main.tileShine[Type] = 2200; - Main.tileShine2[Type] = false; + Main.tileShine[Type] = 1800; + Main.tileShine2[Type] = true; TileID.Sets.ChecksForMerge[Type] = true; TileID.Sets.CanBeDugByShovel[Type] = true; DustType = 108; - AddMapEntry(new Color(67, 107, 143)); + AddMapEntry(new Color(61, 151, 194)); this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); @@ -45,5 +45,44 @@ namespace CalamityMod.Tiles.SunkenSea { return TileFraming.BrimstoneFraming(i, j, resetFrame); } + + public override void RandomUpdate(int i, int j) + { + Tile tile = Main.tile[i, j]; + Tile up = Main.tile[i, j - 1]; + Tile up2 = Main.tile[i, j - 2]; + + if (!up.HasTile && !up2.HasTile && up.LiquidAmount > 0 && up2.LiquidAmount > 0 && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) + { + //brain corals + if (WorldGen.genRand.NextBool(18)) + { + ushort[] BrainCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + ushort newObject = Main.rand.Next(BrainCorals); + + WorldGen.PlaceObject(i, j - 1, newObject, true); + NetMessage.SendObjectPlacement(-1, i, j - 1, newObject, 0, 0, -1, -1); + } + + //tube corals + if (WorldGen.genRand.NextBool(8)) + { + ushort[] TubeCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + ushort newObject = Main.rand.Next(TubeCorals); + + WorldGen.PlaceObject(i, j - 1, newObject, true); + NetMessage.SendObjectPlacement(-1, i, j - 1, newObject, 0, 0, -1, -1); + } + + //anemonie + if (WorldGen.genRand.NextBool(10)) + { + WorldGen.PlaceObject(i, j - 1, (ushort)ModContent.TileType(), true); + NetMessage.SendObjectPlacement(-1, i, j - 1, (ushort)ModContent.TileType(), 0, 0, -1, -1); + } + } + } } } diff --git a/Tiles/SunkenSea/LimeCoral.cs b/Tiles/SunkenSea/LimeCoral.cs new file mode 100644 index 0000000000..057dc93370 --- /dev/null +++ b/Tiles/SunkenSea/LimeCoral.cs @@ -0,0 +1,60 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class LimeCoral : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + Main.tileLighted[Type] = true; + + TileID.Sets.HasSlopeFrames[Type] = true; + + TileID.Sets.ChecksForMerge[Type] = true; + HitSound = SoundID.Dig; + DustType = 119; + AddMapEntry(new Color(139, 206, 56)); + Main.tileShine2[Type] = true; + + TileID.Sets.CanBeDugByShovel[Type] = true; + + // 02JUN2024: Ozzatron: RuneSand has no merge + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); + // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (!Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile) + { + float brightness = 0.9f; + Color Color1 = new Color(176, 242, 96); + Color Color2 = new Color(82, 113, 29); + Color value = Color.Lerp(Color1, Color2, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); + Color value1 = Color.Lerp(Color1, Color2, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); + r = (value.R + value1.R) / 300f; + g = (value.G + value1.G) / 300f; + b = (value.B + value1.B) / 300f; + r *= brightness; + g *= brightness; + b *= brightness; + } + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/LimeCoral.png b/Tiles/SunkenSea/LimeCoral.png new file mode 100644 index 0000000000..b7fb07b8d0 Binary files /dev/null and b/Tiles/SunkenSea/LimeCoral.png differ diff --git a/Tiles/SunkenSea/Limestone.cs b/Tiles/SunkenSea/Limestone.cs new file mode 100644 index 0000000000..d741e2ad16 --- /dev/null +++ b/Tiles/SunkenSea/Limestone.cs @@ -0,0 +1,38 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class Limestone : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + + TileID.Sets.HasSlopeFrames[Type] = true; + + TileID.Sets.ChecksForMerge[Type] = true; + HitSound = SoundID.Tink; + DustType = 22; + AddMapEntry(new Color(154, 119, 119)); + + // 02JUN2024: Ozzatron: RuneSand has no merge + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); + // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/Limestone.png b/Tiles/SunkenSea/Limestone.png new file mode 100644 index 0000000000..8663309de3 Binary files /dev/null and b/Tiles/SunkenSea/Limestone.png differ diff --git a/Tiles/SunkenSea/MagentaCoral.cs b/Tiles/SunkenSea/MagentaCoral.cs new file mode 100644 index 0000000000..80df31c297 --- /dev/null +++ b/Tiles/SunkenSea/MagentaCoral.cs @@ -0,0 +1,65 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class MagentaCoral : ModTile + { + public byte[,] tileAdjacency; + public byte[,] secondTileAdjacency; + public byte[,] thirdTileAdjacency; + public byte[,] fourthTileAdjacency; + + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + Main.tileLighted[Type] = true; + + TileID.Sets.HasSlopeFrames[Type] = true; + + TileID.Sets.ChecksForMerge[Type] = true; + HitSound = SoundID.Dig; + DustType = 119; + AddMapEntry(new Color(206, 56, 123)); + Main.tileShine2[Type] = true; + + TileID.Sets.CanBeDugByShovel[Type] = true; + + // 02JUN2024: Ozzatron: RuneSand has no merge + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); + // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (!Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile) + { + float brightness = 0.9f; + Color Color1 = new Color(242, 96, 161); + Color Color2 = new Color(156, 51, 83); + Color value = Color.Lerp(Color1, Color2, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); + Color value1 = Color.Lerp(Color1, Color2, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); + r = (value.R + value1.R) / 300f; + g = (value.G + value1.G) / 300f; + b = (value.B + value1.B) / 300f; + r *= brightness; + g *= brightness; + b *= brightness; + } + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/MagentaCoral.png b/Tiles/SunkenSea/MagentaCoral.png new file mode 100644 index 0000000000..e02ef96fce Binary files /dev/null and b/Tiles/SunkenSea/MagentaCoral.png differ diff --git a/Tiles/SunkenSea/Navystone.cs b/Tiles/SunkenSea/Navystone.cs index 8799172e30..e64618908a 100644 --- a/Tiles/SunkenSea/Navystone.cs +++ b/Tiles/SunkenSea/Navystone.cs @@ -1,28 +1,27 @@ -using System.Collections.Generic; +using CalamityMod.Tiles.SunkenSea.Ambient; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea { - public class Navystone : ModTile, IMergeableTile + public class Navystone : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { + TileID.Sets.GeneralPlacementTiles[Type] = false; + Main.tileSolid[Type] = true; Main.tileBlockLight[Type] = true; CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithDesert(Type); + Main.tileShine2[Type] = true; TileID.Sets.ChecksForMerge[Type] = true; DustType = 96; - AddMapEntry(new Color(31, 92, 114)); + AddMapEntry(new Color(17, 53, 77)); HitSound = SoundID.Tink; this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); @@ -40,5 +39,26 @@ namespace CalamityMod.Tiles.SunkenSea { return TileFraming.BrimstoneFraming(i, j, resetFrame); } + + public override void RandomUpdate(int i, int j) + { + Tile Tile = Framing.GetTileSafely(i, j); + Tile Below = Framing.GetTileSafely(i, j + 1); + Tile Above = Framing.GetTileSafely(i, j - 1); + + if (!Below.HasTile && Below.LiquidType <= 0 && !Tile.BottomSlope) + { + if (Main.rand.NextBool(10)) + { + Below.TileType = (ushort)ModContent.TileType(); + Below.HasTile = true; + WorldGen.SquareTileFrame(i, j + 1, true); + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, i, j + 1, 3, TileChangeType.None); + } + } + } + } } } diff --git a/Tiles/SunkenSea/OrangeCoral.cs b/Tiles/SunkenSea/OrangeCoral.cs new file mode 100644 index 0000000000..524eaa2a2c --- /dev/null +++ b/Tiles/SunkenSea/OrangeCoral.cs @@ -0,0 +1,60 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class OrangeCoral : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + Main.tileLighted[Type] = true; + + TileID.Sets.HasSlopeFrames[Type] = true; + + TileID.Sets.ChecksForMerge[Type] = true; + HitSound = SoundID.Dig; + DustType = 119; + AddMapEntry(Color.Orange); + Main.tileShine2[Type] = true; + + TileID.Sets.CanBeDugByShovel[Type] = true; + + // 02JUN2024: Ozzatron: RuneSand has no merge + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); + // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (!Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile) + { + float brightness = 0.9f; + Color Color1 = new Color(255, 177, 120); + Color Color2 = new Color(117, 23, 44); + Color value = Color.Lerp(Color1, Color2, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); + Color value1 = Color.Lerp(Color1, Color2, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); + r = (value.R + value1.R) / 300f; + g = (value.G + value1.G) / 300f; + b = (value.B + value1.B) / 300f; + r *= brightness; + g *= brightness; + b *= brightness; + } + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/OrangeCoral.png b/Tiles/SunkenSea/OrangeCoral.png new file mode 100644 index 0000000000..182cfa6a7d Binary files /dev/null and b/Tiles/SunkenSea/OrangeCoral.png differ diff --git a/Tiles/SunkenSea/PinkPearlPile.cs b/Tiles/SunkenSea/PinkPearlPile.cs new file mode 100644 index 0000000000..73dc8d3d12 --- /dev/null +++ b/Tiles/SunkenSea/PinkPearlPile.cs @@ -0,0 +1,42 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class PinkPearlPile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + + TileID.Sets.HasSlopeFrames[Type] = true; + + TileID.Sets.ChecksForMerge[Type] = true; + HitSound = SoundID.Shatter; + DustType = 119; + AddMapEntry(new Color(204, 143, 174)); + Main.tileShine[Type] = 3500; + Main.tileShine2[Type] = true; + + TileID.Sets.CanBeDugByShovel[Type] = true; + + // 02JUN2024: Ozzatron: RuneSand has no merge + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); + // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/PinkPearlPile.png b/Tiles/SunkenSea/PinkPearlPile.png new file mode 100644 index 0000000000..6fac3acc57 Binary files /dev/null and b/Tiles/SunkenSea/PinkPearlPile.png differ diff --git a/Tiles/SunkenSea/PolishedNavystoneBrick.cs b/Tiles/SunkenSea/PolishedNavystoneBrick.cs new file mode 100644 index 0000000000..f2395b02fe --- /dev/null +++ b/Tiles/SunkenSea/PolishedNavystoneBrick.cs @@ -0,0 +1,27 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class PolishedNavystoneBrick : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + CalamityUtils.MergeWithGeneral(Type); + TileID.Sets.HasSlopeFrames[Type] = true; + + HitSound = SoundID.Tink; + DustType = 96; + AddMapEntry(new Color(53, 99, 117)); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/PolishedNavystoneBrick.png b/Tiles/SunkenSea/PolishedNavystoneBrick.png new file mode 100644 index 0000000000..6707f33131 Binary files /dev/null and b/Tiles/SunkenSea/PolishedNavystoneBrick.png differ diff --git a/Tiles/SunkenSea/PolypSand.cs b/Tiles/SunkenSea/PolypSand.cs new file mode 100644 index 0000000000..a89bd0d3c6 --- /dev/null +++ b/Tiles/SunkenSea/PolypSand.cs @@ -0,0 +1,43 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class PolypSand : ModTile + { + public override void SetStaticDefaults() + { + TileID.Sets.GeneralPlacementTiles[Type] = false; + + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithDesert(Type); + + TileID.Sets.HasSlopeFrames[Type] = true; + TileID.Sets.ChecksForMerge[Type] = true; + TileID.Sets.CanBeDugByShovel[Type] = true; + Main.tileShine2[Type] = true; + + DustType = 147; + AddMapEntry(new Color(221, 180, 182)); + + this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); + this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); + this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); + } + + 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) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/PolypSand.png b/Tiles/SunkenSea/PolypSand.png new file mode 100644 index 0000000000..561c962c9e Binary files /dev/null and b/Tiles/SunkenSea/PolypSand.png differ diff --git a/Tiles/SunkenSea/RuneSand.cs b/Tiles/SunkenSea/RuneSand.cs new file mode 100644 index 0000000000..b477d06e0a --- /dev/null +++ b/Tiles/SunkenSea/RuneSand.cs @@ -0,0 +1,43 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class RuneSand : ModTile + { + public override void SetStaticDefaults() + { + TileID.Sets.GeneralPlacementTiles[Type] = false; + + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithDesert(Type); + + TileID.Sets.HasSlopeFrames[Type] = true; + TileID.Sets.ChecksForMerge[Type] = true; + TileID.Sets.CanBeDugByShovel[Type] = true; + Main.tileShine2[Type] = true; + + DustType = 147; + AddMapEntry(new Color(210, 124, 45)); + + this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); + this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); + this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); + } + + 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) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/RuneSand.png b/Tiles/SunkenSea/RuneSand.png new file mode 100644 index 0000000000..06514fde68 Binary files /dev/null and b/Tiles/SunkenSea/RuneSand.png differ diff --git a/Tiles/SunkenSea/Runestone.cs b/Tiles/SunkenSea/Runestone.cs new file mode 100644 index 0000000000..020cb14e1d --- /dev/null +++ b/Tiles/SunkenSea/Runestone.cs @@ -0,0 +1,43 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class Runestone : ModTile + { + public override void SetStaticDefaults() + { + TileID.Sets.GeneralPlacementTiles[Type] = false; + + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + + TileID.Sets.HasSlopeFrames[Type] = true; + + TileID.Sets.ChecksForMerge[Type] = true; + HitSound = SoundID.Tink; + DustType = 22; + AddMapEntry(new Color(152, 89, 78)); + Main.tileShine2[Type] = true; + + TileID.Sets.CanBeDugByShovel[Type] = true; + + // 02JUN2024: Ozzatron: RuneSand has no merge + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); + // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/Runestone.png b/Tiles/SunkenSea/Runestone.png new file mode 100644 index 0000000000..610bdefa21 Binary files /dev/null and b/Tiles/SunkenSea/Runestone.png differ diff --git a/Tiles/SunkenSea/SeaPrism.cs b/Tiles/SunkenSea/SeaPrism.cs index 83d6da7082..4ffb9390f8 100644 --- a/Tiles/SunkenSea/SeaPrism.cs +++ b/Tiles/SunkenSea/SeaPrism.cs @@ -1,20 +1,16 @@ -using System.Collections.Generic; +using System; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea { - public class SeaPrism : ModTile, IMergeableTile + public class SeaPrism : ModTile { private const short subsheetWidth = 450; private const short subsheetHeight = 198; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; @@ -22,13 +18,13 @@ namespace CalamityMod.Tiles.SunkenSea CalamityUtils.MergeWithGeneral(Type); CalamityUtils.MergeWithDesert(Type); - + Main.tileLighted[Type] = true; Main.tileShine[Type] = 3500; Main.tileShine2[Type] = true; TileID.Sets.ChecksForMerge[Type] = true; DustType = 33; - AddMapEntry(new Color(0, 150, 200)); + AddMapEntry(new Color(97, 212, 223)); HitSound = SoundID.Tink; Main.tileSpelunker[Type] = true; MinPick = 55; @@ -46,7 +42,21 @@ namespace CalamityMod.Tiles.SunkenSea frameXOffset = i % 2 * subsheetWidth; frameYOffset = j % 2 * subsheetHeight; } - + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + float brightness = 0.9f; + Color blue = new Color(67, 187, 204); + Color darkviolet = new Color(18, 67, 116); + Color value = Color.Lerp(blue, darkviolet, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); + Color value1 = Color.Lerp(blue, darkviolet, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); + r = (value.R + value1.R) / 900f; + g = (value.G + value1.G) / 900f; + b = (value.B + value1.B) / 900f; + r *= brightness; + g *= brightness; + b *= brightness; + } + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) { return TileFraming.BrimstoneFraming(i, j, resetFrame); diff --git a/Tiles/SunkenSea/SeaPrismCrystals.cs b/Tiles/SunkenSea/SeaPrismCrystals.cs index 9fa9ed36d7..45cd6ba00b 100644 --- a/Tiles/SunkenSea/SeaPrismCrystals.cs +++ b/Tiles/SunkenSea/SeaPrismCrystals.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Placeables; +using System; +using CalamityMod.Items.Placeables; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -16,7 +17,7 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileFrameImportant[Type] = true; Main.tileObsidianKill[Type] = true; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); - AddMapEntry(new Color(0, 150, 200), CalamityUtils.GetItemName()); + AddMapEntry(new Color(48, 201, 214), CalamityUtils.GetItemName()); HitSound = SoundID.Item27; DustType = 67; Main.tileSpelunker[Type] = true; @@ -35,21 +36,46 @@ namespace CalamityMod.Tiles.SunkenSea int xframe = tile.TileFrameX / 18; if (xframe > 7 && xframe < 14) { + //Purple + Color darkviolet = new Color(75, 54, 103); + Color violet = new Color(231, 205, 245); + Color value = Color.Lerp(darkviolet, violet, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.037f + i / 40f) + 1f) / 2f); + Color value1 = Color.Lerp(darkviolet, violet, (MathF.Sin((j - 120) / 50f + Main.GameUpdateCount * 0.014f + -i / 30f) + 1f) / 2f); r = lessLightDueToLowWater ? 0.36f : 0.48f; g = lessLightDueToLowWater ? 0.315f : 0.42f; b = lessLightDueToLowWater ? 0.405f : 0.54f; + r *= (value.R + value1.R) / 300f; + g *= (value.G + value1.G) / 300f; + b *= (value.B + value1.B) / 300f; + } else if (xframe >= 14) { + //Green + Color murkeygreen = new Color(28, 68, 54); + Color lightgreen = new Color(166, 234, 198); + Color value2 = Color.Lerp(murkeygreen, lightgreen, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.027f + i / 40f) + 1f) / 2f); + Color value3 = Color.Lerp(murkeygreen, lightgreen, (MathF.Sin((j - 80) / 50f + Main.GameUpdateCount * 0.034f + -i / 30f) + 1f) / 2f); r = lessLightDueToLowWater ? 0.225f : 0.3f; g = lessLightDueToLowWater ? 0.405f : 0.54f; b = lessLightDueToLowWater ? 0.315f : 0.42f; + r *= (value2.R + value3.R) / 300f; + g *= (value2.G + value3.G) / 300f; + b *= (value2.B + value3.B) / 300f; } else { + //Blue + Color blue = new Color(67, 187, 204); + Color darkviolet = new Color(18, 67, 116); + Color value = Color.Lerp(blue, darkviolet, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); + Color value1 = Color.Lerp(blue, darkviolet, (MathF.Sin((j - 10) / 50f + Main.GameUpdateCount * 0.064f + -i / 30f) + 1f) / 2f); r = lessLightDueToLowWater ? 0.27f : 0.36f; g = lessLightDueToLowWater ? 0.405f : 0.54f; b = lessLightDueToLowWater ? 0.405f : 0.54f; + r *= (value.R + value1.R) / 300f; + g *= (value.G + value1.G) / 300f; + b *= (value.B + value1.B) / 300f; } } diff --git a/Tiles/SunkenSea/Shellstone.cs b/Tiles/SunkenSea/Shellstone.cs new file mode 100644 index 0000000000..6cd502cd9c --- /dev/null +++ b/Tiles/SunkenSea/Shellstone.cs @@ -0,0 +1,40 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class Shellstone : ModTile + { + public override void SetStaticDefaults() + { + TileID.Sets.GeneralPlacementTiles[Type] = false; + + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + TileID.Sets.HasSlopeFrames[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithDesert(Type); + + TileID.Sets.HasSlopeFrames[Type] = true; + TileID.Sets.ChecksForMerge[Type] = true; + HitSound = SoundID.Tink; + DustType = 17; + AddMapEntry(new Color(113, 117, 160)); + + // 02JUN2024: Ozzatron: RuneSand has no merge + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); + + this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); + this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); + this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/Shellstone.png b/Tiles/SunkenSea/Shellstone.png new file mode 100644 index 0000000000..95d8bdd2d2 Binary files /dev/null and b/Tiles/SunkenSea/Shellstone.png differ diff --git a/Tiles/SunkenSea/ShellstoneSlab.cs b/Tiles/SunkenSea/ShellstoneSlab.cs new file mode 100644 index 0000000000..eac1a96c65 --- /dev/null +++ b/Tiles/SunkenSea/ShellstoneSlab.cs @@ -0,0 +1,28 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ID; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class ShellstoneSlab : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + TileID.Sets.HasSlopeFrames[Type] = true; + + HitSound = SoundID.Tink; + DustType = 17; + AddMapEntry(new Color(156, 191, 199)); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/ShellstoneSlab.png b/Tiles/SunkenSea/ShellstoneSlab.png new file mode 100644 index 0000000000..8266d74f7e Binary files /dev/null and b/Tiles/SunkenSea/ShellstoneSlab.png differ diff --git a/Tiles/SunkenSea/SmallCorals.png b/Tiles/SunkenSea/SmallCorals.png deleted file mode 100644 index 6a3fedcf13..0000000000 Binary files a/Tiles/SunkenSea/SmallCorals.png and /dev/null differ diff --git a/Tiles/SunkenSea/TableCoral.png b/Tiles/SunkenSea/TableCoral.png deleted file mode 100644 index 68804bea84..0000000000 Binary files a/Tiles/SunkenSea/TableCoral.png and /dev/null differ diff --git a/Tiles/SunkenSea/VolcanicSand.cs b/Tiles/SunkenSea/VolcanicSand.cs new file mode 100644 index 0000000000..49bdcd390b --- /dev/null +++ b/Tiles/SunkenSea/VolcanicSand.cs @@ -0,0 +1,42 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class VolcanicSand : ModTile + { + public override void SetStaticDefaults() + { + TileID.Sets.GeneralPlacementTiles[Type] = false; + + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + CalamityUtils.MergeWithDesert(Type); + + TileID.Sets.HasSlopeFrames[Type] = true; + TileID.Sets.ChecksForMerge[Type] = true; + TileID.Sets.CanBeDugByShovel[Type] = true; + + DustType = 147; + AddMapEntry(new Color(117, 79, 97)); + + this.RegisterUniversalMerge(TileID.Sandstone, "CalamityMod/Tiles/Merges/SandstoneMerge"); + this.RegisterUniversalMerge(TileID.Sand, "CalamityMod/Tiles/Merges/SandMerge"); + this.RegisterUniversalMerge(TileID.HardenedSand, "CalamityMod/Tiles/Merges/HardenedSandMerge"); + } + + 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) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/VolcanicSand.png b/Tiles/SunkenSea/VolcanicSand.png new file mode 100644 index 0000000000..a85b4c8dee Binary files /dev/null and b/Tiles/SunkenSea/VolcanicSand.png differ diff --git a/Tiles/SunkenSea/WhitePearlPile.cs b/Tiles/SunkenSea/WhitePearlPile.cs new file mode 100644 index 0000000000..5cacbe7df5 --- /dev/null +++ b/Tiles/SunkenSea/WhitePearlPile.cs @@ -0,0 +1,43 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class WhitePearlPile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + + TileID.Sets.HasSlopeFrames[Type] = true; + TileID.Sets.ChecksForMerge[Type] = true; + + Main.tileShine[Type] = 3500; + Main.tileShine2[Type] = true; + + HitSound = SoundID.Shatter; + DustType = 149; + AddMapEntry(new Color(217, 209, 213)); + + TileID.Sets.CanBeDugByShovel[Type] = true; + + // 02JUN2024: Ozzatron: RuneSand has no merge + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); + // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/WhitePearlPile.png b/Tiles/SunkenSea/WhitePearlPile.png new file mode 100644 index 0000000000..f138f2ab3a Binary files /dev/null and b/Tiles/SunkenSea/WhitePearlPile.png differ diff --git a/Tiles/SunkenSea/YellowCoral.cs b/Tiles/SunkenSea/YellowCoral.cs new file mode 100644 index 0000000000..1a7a29bbfb --- /dev/null +++ b/Tiles/SunkenSea/YellowCoral.cs @@ -0,0 +1,60 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles.SunkenSea +{ + public class YellowCoral : ModTile + { + public override void SetStaticDefaults() + { + Main.tileSolid[Type] = true; + Main.tileBlockLight[Type] = true; + + CalamityUtils.MergeWithGeneral(Type); + Main.tileLighted[Type] = true; + + TileID.Sets.HasSlopeFrames[Type] = true; + + TileID.Sets.ChecksForMerge[Type] = true; + HitSound = SoundID.Dig; + DustType = 119; + AddMapEntry(new Color(198, 169, 24)); + Main.tileShine2[Type] = true; + + TileID.Sets.CanBeDugByShovel[Type] = true; + + // 02JUN2024: Ozzatron: RuneSand has no merge + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out tileAdjacency); + // 02JUN2024: Ozzatron: Shellstone has no merge tile sheet defined + // TileFraming.SetUpUniversalMerge(Type, ModContent.TileType(), out secondTileAdjacency); + + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/EutrophicSandMerge"); + this.RegisterUniversalMerge(ModContent.TileType(), "CalamityMod/Tiles/Merges/NavystoneMerge"); + } + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + if (!Main.tile[i - 1, j].HasTile || !Main.tile[i + 1, j].HasTile || !Main.tile[i, j - 1].HasTile || !Main.tile[i, j + 1].HasTile) + { + float brightness = 0.9f; + Color Color1 = new Color(218, 203, 67); + Color Color2 = new Color(121, 76, 1); + Color value = Color.Lerp(Color1, Color2, (MathF.Sin(-j / 80f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); + Color value1 = Color.Lerp(Color1, Color2, (MathF.Sin((j - 100) / 50f + Main.GameUpdateCount * 0.004f + -i / 30f) + 1f) / 2f); + r = (value.R + value1.R) / 300f; + g = (value.G + value1.G) / 300f; + b = (value.B + value1.B) / 300f; + r *= brightness; + g *= brightness; + b *= brightness; + } + } + + public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) + { + return TileFraming.BetterGemsparkFraming(i, j, resetFrame); + } + } +} diff --git a/Tiles/SunkenSea/YellowCoral.png b/Tiles/SunkenSea/YellowCoral.png new file mode 100644 index 0000000000..ef005dc85b Binary files /dev/null and b/Tiles/SunkenSea/YellowCoral.png differ diff --git a/Tiles/UelibloomBrick.cs b/Tiles/UelibloomBrick.cs index ee453b6ab0..49b1e8e449 100644 --- a/Tiles/UelibloomBrick.cs +++ b/Tiles/UelibloomBrick.cs @@ -10,13 +10,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class UelibloomBrick : ModTile, IMergeableTile + public class UelibloomBrick : ModTile { private int extraFrameHeight = 36; private int extraFrameWidth = 90; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/VernalSoil.cs b/Tiles/VernalSoil.cs index eb4e766460..ebfd615be2 100644 --- a/Tiles/VernalSoil.cs +++ b/Tiles/VernalSoil.cs @@ -11,10 +11,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class VernalSoil : ModTile, IMergeableTile + public class VernalSoil : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/UI/DebuffSystem/ColdDebuffType.png b/UI/DebuffSystem/ColdDebuffType.png index eb0a88f11a..f64ac9f30b 100644 Binary files a/UI/DebuffSystem/ColdDebuffType.png and b/UI/DebuffSystem/ColdDebuffType.png differ diff --git a/UI/DebuffSystem/ElectricityDebuffType.png b/UI/DebuffSystem/ElectricityDebuffType.png index 30539636b2..e77f2d6947 100644 Binary files a/UI/DebuffSystem/ElectricityDebuffType.png and b/UI/DebuffSystem/ElectricityDebuffType.png differ diff --git a/UI/DebuffSystem/HeatDebuffType.png b/UI/DebuffSystem/HeatDebuffType.png index 8b25d715bb..d1c54b3e8d 100644 Binary files a/UI/DebuffSystem/HeatDebuffType.png and b/UI/DebuffSystem/HeatDebuffType.png differ diff --git a/UI/DebuffSystem/SicknessDebuffType.png b/UI/DebuffSystem/SicknessDebuffType.png index db56ba8449..8c498f6d77 100644 Binary files a/UI/DebuffSystem/SicknessDebuffType.png and b/UI/DebuffSystem/SicknessDebuffType.png differ diff --git a/UI/DebuffSystem/WaterDebuffType.png b/UI/DebuffSystem/WaterDebuffType.png index 1e41f4d471..66ee4d3800 100644 Binary files a/UI/DebuffSystem/WaterDebuffType.png and b/UI/DebuffSystem/WaterDebuffType.png differ diff --git a/UI/FlightBar/FlightBar.cs b/UI/FlightBar/FlightBar.cs index b78ed67fcd..60ec028cfb 100644 --- a/UI/FlightBar/FlightBar.cs +++ b/UI/FlightBar/FlightBar.cs @@ -31,7 +31,7 @@ namespace CalamityMod.UI private static Texture2D GetApplicableBorder(CalamityPlayer modPlayer) { - if (modPlayer.Player.equippedWings != null && modPlayer.Player.wingTimeMax == 0 && modPlayer.Player.mount._data.flightTimeMax == 0) + if (modPlayer.Player.equippedWings != null && modPlayer.Player.wingTimeMax == 0 && modPlayer.Player.mount.Active && modPlayer.Player.mount._data.flightTimeMax == 0) return disabledBarTexture; if ((modPlayer.infiniteFlight || RidingInfiniteFlightMount(modPlayer.Player)) && completedAnimation) return infiniteBarTexture; @@ -106,7 +106,7 @@ namespace CalamityMod.UI CalamityPlayer modPlayer = player.Calamity(); // If not drawing the flight bar, save its latest position to config and leave. - if (CalamityConfig.Instance.FlightBar && (player.wingsLogic > 0 || (player.mount.Active && player.mount._data.flightTimeMax > 0) || player.carpet && !player.canCarpet)) + if (CalamityConfig.Instance.FlightBar && ((player.wingsLogic > 0 && player.wingTimeMax > 0) || (player.mount.Active && player.mount._data.flightTimeMax > 0) || player.carpet && !player.canCarpet)) { DrawFlightBar(spriteBatch, modPlayer, screenPos); } diff --git a/UI/VanillaBossBars/ProfanedGuardianBossBar.cs b/UI/VanillaBossBars/ProfanedGuardianBossBar.cs new file mode 100644 index 0000000000..35afbb34b6 --- /dev/null +++ b/UI/VanillaBossBars/ProfanedGuardianBossBar.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using CalamityMod.NPCs.ProfanedGuardians; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.UI.BigProgressBar; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.UI.VanillaBossBars +{ + public class ProfanedGuardianBossBar : ModBossBar + { + // Used to determine the max health of a multi-segmented boss + public NPC FalseNPCSegment; + + public override Asset GetIconTexture(ref Rectangle? iconFrame) + { + // Icons are based on whoever should die first + if (NPC.AnyNPCs(NPCType())) + return TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCType()]]; + + if (NPC.AnyNPCs(NPCType())) + return TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCType()]]; + + return TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCType()]]; + } + + public override bool? ModifyInfo(ref BigProgressBarInfo info, ref float life, ref float lifeMax, ref float shield, ref float shieldMax) + { + NPC target = Main.npc[info.npcIndexToAimAt]; + + if (!target.active) + return false; + + // Get the commander's health + life = target.life; + lifeMax = target.lifeMax; + + // Add max health by feeding the data of false NPCs + FalseNPCSegment = new NPC(); + FalseNPCSegment.SetDefaults(NPCType(), target.GetMatchingSpawnParams()); + lifeMax += FalseNPCSegment.lifeMax; + FalseNPCSegment.SetDefaults(NPCType(), target.GetMatchingSpawnParams()); + lifeMax += FalseNPCSegment.lifeMax; + + // Determine the current health of all guardians + foreach (NPC guardian in Main.ActiveNPCs) + { + if (guardian.type == NPCType() || guardian.type == NPCType()) + life += guardian.life; + } + return true; + } + } +} diff --git a/Utilities/CalamityRecipes.cs b/Utilities/CalamityRecipes.cs index 81a27225f2..12fedcb4bd 100644 --- a/Utilities/CalamityRecipes.cs +++ b/Utilities/CalamityRecipes.cs @@ -45,6 +45,7 @@ namespace CalamityMod // Acidwood is Wood RecipeGroup wood = RecipeGroup.recipeGroups[RecipeGroupID.Wood]; wood.ValidItems.Add(ModContent.ItemType()); + wood.ValidItems.Add(ModContent.ItemType()); // Astral Monolith is decidedly not wood-like enough to be used as generic wood. } @@ -356,7 +357,8 @@ namespace CalamityMod ItemID.PalmWoodSword, ItemID.EbonwoodSword, ItemID.ShadewoodSword, - ItemID.PearlwoodSword + ItemID.PearlwoodSword, + ItemID.AshWoodSword }); AnyWoodenSword = RecipeGroup.RegisterGroup("AnyWoodenSword", group); diff --git a/Utilities/GenericAIUtils.cs b/Utilities/GenericAIUtils.cs index 265c83daf3..769978d9bb 100644 --- a/Utilities/GenericAIUtils.cs +++ b/Utilities/GenericAIUtils.cs @@ -505,7 +505,7 @@ namespace CalamityMod projectile.ai[1] = (float)npcIndex; //follow the NPC - projectile.velocity = (npc.Center - projectile.Center) * 0.75f; + projectile.velocity = (npc.Center - projectile.Center); projectile.netUpdate = true; diff --git a/Utilities/ItemUtils.cs b/Utilities/ItemUtils.cs index 88bb34ef06..acb0ed8438 100644 --- a/Utilities/ItemUtils.cs +++ b/Utilities/ItemUtils.cs @@ -132,11 +132,11 @@ namespace CalamityMod } // MELEE (includes tools and whips) - else if (item.CountsAsClass() || item.CountsAsClass()) + else if (item.CountsAsClass() || item.CountsAsClass() || item.CountsAsClass()) { // Terrarian (has its own special "Legendary" for marketing reasons) // Other items that want to use Legendary2 are also compatible - if (item.type == ItemID.Terrarian || PrefixLegacy.ItemSets.ItemsThatCanHaveLegendary2[item.type]) + if (PrefixLegacy.ItemSets.ItemsThatCanHaveLegendary2[item.type]) { int[][] terrarianReforgeTiers = new int[][] { @@ -148,26 +148,8 @@ namespace CalamityMod prefix = IteratePrefix(rand, terrarianReforgeTiers, currentPrefix); } - // Yoyos, Flails, Spears, etc. - // Spears actually work fine with Legendary, but vanilla doesn't give it to them, so we won't either. - // Rapiers, whips, and other specific vanilla weapons (ie. Zenith or Excalibur) are specifically excluded from this, so they get broadsword reforges despite not scaling with melee speed. - // - // 18FEB2024: Ozzatron: removed the (item.channel || item.noMelee) because vanilla lets Burning Sky get Legendary - // 12MAY2024: Shade: added item.useStyle != ItemUseStyleID.Shoot because vanilla lets Sahara Slicers and Death's Ascension get Legendary - else if (item.channel && item.useStyle != ItemUseStyleID.Rapier && !item.CountsAsClass() && !PrefixLegacy.ItemSets.SwordsHammersAxesPicks[item.type] && item.useStyle != ItemUseStyleID.Shoot) - { - int[][] meleeNoSpeedReforgeTiers = new int[][] - { - /* 0 */ new int[] { PrefixID.Keen, PrefixID.Forceful, PrefixID.Strong }, - /* 1 */ new int[] { PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous }, - /* 2 */ new int[] { PrefixID.Superior, PrefixID.Demonic }, - /* 3 */ new int[] { PrefixID.Godly } - }; - prefix = IteratePrefix(rand, meleeNoSpeedReforgeTiers, currentPrefix); - } - - // All other melee weapons - else + // Swords, Whips, Tools, other items that support the Legendary modifier + else if (PrefixLegacy.ItemSets.SwordsHammersAxesPicks[item.type] || (item.ModItem != null && item.ModItem.MeleePrefix())) { int[][] meleeReforgeTiers = new int[][] { @@ -180,7 +162,7 @@ namespace CalamityMod }; int[][] toolReforgeTiers = new int[][] { - /* 0 */ new int[] { PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Heavy, PrefixID.Light, PrefixID.Forceful, PrefixID.Strong }, + /* 0 */ new int[] { PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Heavy, PrefixID.Forceful, PrefixID.Strong }, /* 1 */ new int[] { PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixID.Pointy, PrefixID.Bulky }, /* 2 */ new int[] { PrefixID.Murderous, PrefixID.Agile, PrefixID.Large, PrefixID.Dangerous, PrefixID.Sharp }, /* 3 */ new int[] { PrefixID.Massive, PrefixID.Unpleasant, PrefixID.Savage, PrefixID.Superior }, @@ -191,6 +173,20 @@ namespace CalamityMod var tierListToUse = (item.pick > 0 || item.axe > 0 || item.hammer > 0) ? toolReforgeTiers : meleeReforgeTiers; prefix = IteratePrefix(rand, tierListToUse, currentPrefix); } + + // Yoyos, Flails, Spears, etc. + // Spears actually work fine with Legendary, but vanilla doesn't give it to them, so we won't either. + else + { + int[][] meleeNoSpeedReforgeTiers = new int[][] + { + /* 0 */ new int[] { PrefixID.Keen, PrefixID.Forceful, PrefixID.Strong }, + /* 1 */ new int[] { PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous }, + /* 2 */ new int[] { PrefixID.Superior, PrefixID.Demonic }, + /* 3 */ new int[] { PrefixID.Godly } + }; + prefix = IteratePrefix(rand, meleeNoSpeedReforgeTiers, currentPrefix); + } } // RANGED @@ -337,51 +333,6 @@ namespace CalamityMod tooltips.FindAndReplace("[KEY]", finalKey); } - // Original code lifted from Iban's extended armor tooltips. - /// - /// Performs standard edits to a list of tooltip lines to add more if the Left SHIFT key is held down.
- /// Optionally, hides the normal tooltip to replace it entirely. - ///
- /// The tooltip list provided to a ModifyTooltips TML hook. - /// An array of tooltip lines to add. Instantiate these yourself with C# elaborate new syntax. - /// Set to true to replace the normal tooltip when holding SHIFT. Otherwise both tooltips will show at once. - public static void HoldShiftTooltip(List tooltips, TooltipLine[] holdShiftTooltips, bool hideNormalTooltip = false) - { - // Only perform any changes while holding SHIFT. - if (!Main.keyState.IsKeyDown(Keys.LeftShift)) - return; - - // Get the first index, last index and total count of standard vanilla tooltip lines. - // The first index and count are used to delete all vanilla tooltips when holding SHIFT, if requested. - // The last index is used to insert the "Hold SHIFT" tooltips in the right position. - int firstTooltipIndex = -1; - int lastTooltipIndex = -1; - int standardTooltipCount = 0; - for (int i = 0; i < tooltips.Count; i++) - { - if (tooltips[i].Name.StartsWith("Tooltip")) - { - if (firstTooltipIndex == -1) - firstTooltipIndex = i; - lastTooltipIndex = i; - standardTooltipCount++; - } - } - - if (firstTooltipIndex != -1) - { - // If asked to, remove all standard tooltip lines. This moves the last tooltip index. - if (hideNormalTooltip) - { - tooltips.RemoveRange(firstTooltipIndex, standardTooltipCount); - lastTooltipIndex -= standardTooltipCount; - } - - // Append every "Hold SHIFT" tooltip at the end of standard tooltips. - tooltips.InsertRange(lastTooltipIndex + 1, holdShiftTooltips); - } - } - private const float WorldInsertionOffset = 15f; /// /// If the given item is outside the world, force it to be within the world boundaries. diff --git a/Utilities/NPCDebuffs.cs b/Utilities/NPCDebuffs.cs index c66dbc74d2..ff965a1105 100644 --- a/Utilities/NPCDebuffs.cs +++ b/Utilities/NPCDebuffs.cs @@ -168,9 +168,9 @@ namespace CalamityMod // Is this sorted... like... at all?? EnemyStats.DebuffImmunities = new SortedDictionary> { - { ModContent.NPCType(), immuneToEverything }, - { ModContent.NPCType(), immuneToEverything }, - { ModContent.NPCType(), immuneToEverything }, + { ModContent.NPCType(), immuneToEverything }, + { ModContent.NPCType(), immuneToEverything }, + { ModContent.NPCType(), immuneToEverything }, { NPCID.Deerclops, ice }, diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index 08c4955552..719631c115 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -1,15 +1,15 @@ -using System.Linq; -using System.Reflection; +using System; +using System.Linq; using CalamityMod.Balancing; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.DataStructures; +using CalamityMod.Enums; using CalamityMod.Events; using CalamityMod.NPCs; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.Providence; using CalamityMod.NPCs.SlimeGod; +using CalamityMod.NPCs.Yharon; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -24,8 +24,85 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod { + #region Calamity Targeting Parameters Struct + public struct CalamityTargetingParameters + { + // Vanilla argument to TargetClosest. Defaults to true as it does in vanilla. + // If true, the NPC will turn to face the target. + public bool faceTarget = true; + + // Vanilla argument to TargetClosestUpgraded. That function is never used, but the flexibility is implemented here. + // Allows targeting distance calculations to be measured from a different position than the NPC's center, if desired. + public Vector2? targetingCenter = null; + + // Hard maximum range to search for targets. Players outside this physical Manhattan distance will always be ignored. + // + // Vanilla always uses infinity for this, leading to behavior like Queen Bee crossing the world to spawncamp you. + // Calamity defaults to a very high but not infinite value. + public float maxSearchRange = 9600f; // 600 tiles + + // Targeting preference enum. + // Anyone = Target the "closest" player, no other considerations. Vanilla behavior. + // PreferSame = Always pick the same player if they're within the search range, even if another player is closer or has more aggro. + // ForceSwitch = Try to pick any other player but the current player, if possible. Similar to an "aggro drop" in MMOs. + // + // ForceSwitch intentionally does nothing in single player, because there is nobody to switch to. + public NPCTargetType targetType = NPCTargetType.Anyone; + + // The ratio at which to consider aggro bonuses from player gear. + // 1f is vanilla. Set to 0f to ignore aggro bonuses entirely. + // Set to a negative value to make the NPC intentionally avoid tanks and preferentially go after other players. + public float aggroRatio = 1f; + + // Whether or not players must have line of sight to the NPC to be considered valid targets. + // This is always line of sight to the NPC itself, even if a different targeting center for range finding is specified. + public bool requireLineOfSight = false; + + // If true, the targeting algorithm counts missing health as a gigantic boost to aggro. + // This makes for a "merciless" or "bloodthirsty" NPC which is focused on killing the lowest health players. + public bool finishThemOff = false; + internal const float FinishThemOff_MaxAggroBoost = 4000f; + + // If true, this NPC ignores the Stardust armor set bonus "JoJo Tank Minion" (or "Algalon the Observer" according to the wiki). + // + // This is set to false by default, because that's vanilla behavior. + // As Stardust armor is postgame in vanilla, no vanilla bosses ignore the Stardust Guardian. + // It is highly recommended to set this to true for all bosses, or their aggro can be abusively manipulated. + public bool ignoreTankMinions = false; + + // If true, this NPC ignores players who have less than zero net aggro and are not actively using items. + // + // This is set to true by default, because it's (undocumented) vanilla behavior. + // Bosses will automatically attack stealthed players anyway -- you don't need to set this to false for that to occur. + public bool ignoreStealthedPlayers = true; + + // If true, this targeting change forces a net update. + // In vanilla, targeting updates cause net updates if direction changed or the target player changed, + // but NEVER if the NPC has collideX or collideY set to true. + // + // Generally this doesn't need to be set to true, as bosses will never have collideX or collideY set to true. + public bool forceNetUpdate = false; + + public CalamityTargetingParameters() + { + } + + // Quick defaults for recommended boss settings. + public CalamityTargetingParameters(bool isBoss) + { + ignoreTankMinions = isBoss; + } + + public static CalamityTargetingParameters BossDefaults => new(true); + } + #endregion + + public static partial class CalamityUtils { + public static T ModNPC(this NPC npc) where T : ModNPC => npc.ModNPC as T; + + #region NPC Counting /// /// Efficiently counts the amount of existing enemies. May be used for multiple enemies. /// @@ -49,6 +126,22 @@ namespace CalamityMod return count; } + public static bool AnyBossNPCS(bool checkForMechs = false) + { + foreach (NPC npc in Main.ActiveNPCs) + { + if (npc.IsABoss()) + { + // Added due to the new mech boss ore progression, return true if any mech is alive and checkForMechs is true, reduces mech boss projectile damage if true. + if (checkForMechs) + return npc.type == NPCID.TheDestroyer || npc.type == NPCID.SkeletronPrime || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer; + return true; + } + } + return FindFirstProjectile(ProjectileType()) != -1; + } + #endregion + /// /// Hides an NPC from the bestiary. This should be called in SetStaticDefaults. /// @@ -62,23 +155,7 @@ namespace CalamityMod NPCID.Sets.NPCBestiaryDrawOffset.Add(n.Type, value); } - /// - /// Syncs position and velocity from a client to the server. This is to be used in contexts where these things are reliant on client-side information, such as . - /// - /// - public static void SyncMotionToServer(this NPC npc) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - return; - - var netMessage = CalamityMod.Instance.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.SyncNPCMotionDataToServer); - netMessage.Write(npc.whoAmI); - netMessage.WriteVector2(npc.Center); - netMessage.WriteVector2(npc.velocity); - netMessage.Send(); - } - + #region Stat Setting /// /// Allows you to set the lifeMax value of a NPC to different values based on the mode. Called instead of npc.lifeMax = X. /// @@ -123,7 +200,9 @@ namespace CalamityMod if (customDR.HasValue) npc.Calamity().customDR = true; } + #endregion + #region NPC Threat Classification // This function controls the behavior of Proximity Rage. // // TODO -- In multiplayer, with more than one player, all enemies are listed as statue spawned. @@ -171,39 +250,9 @@ namespace CalamityMod return npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType(); } + #endregion - public static bool AnyBossNPCS(bool checkForMechs = false) - { - foreach (NPC npc in Main.ActiveNPCs) - { - if (npc.IsABoss()) - { - // Added due to the new mech boss ore progression, return true if any mech is alive and checkForMechs is true, reduces mech boss projectile damage if true. - if (checkForMechs) - return npc.type == NPCID.TheDestroyer || npc.type == NPCID.SkeletronPrime || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer; - return true; - } - } - return FindFirstProjectile(ProjectileType()) != -1; - } - - /// - /// Syncs . This exists to sync the Destroyer's lasers so that the telegraphs and segment colors display properly. - /// - /// - public static void SyncDestroyerLaserColor(this NPC npc) - { - // Don't bother attempting to send packets in singleplayer. - if (Main.netMode == NetmodeID.SinglePlayer) - return; - - ModPacket packet = CalamityMod.Instance.GetPacket(); - packet.Write((byte)CalamityModMessageType.SyncDestroyerLaserColor); - packet.Write((byte)npc.whoAmI); - packet.Write(npc.Calamity().destroyerLaserColor); - packet.Send(); - } - + #region Net Synchronization /// /// Syncs . This exists specifically for AIs manipulated in a global context, as has no netUpdate related hooks. /// @@ -244,6 +293,257 @@ namespace CalamityMod packet.Send(); } + /// + /// Syncs position and velocity from a client to the server. This is to be used in contexts where these things are reliant on client-side information, such as . + /// + /// + public static void SyncMotionToServer(this NPC npc) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + return; + + var netMessage = CalamityMod.Instance.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.SyncNPCMotionDataToServer); + netMessage.Write(npc.whoAmI); + netMessage.WriteVector2(npc.Center); + netMessage.WriteVector2(npc.velocity); + netMessage.Send(); + } + + /// + /// Syncs . This exists to sync the Destroyer's lasers so that the telegraphs and segment colors display properly. + /// + /// + public static void SyncDestroyerLaserColor(this NPC npc) + { + // Don't bother attempting to send packets in singleplayer. + if (Main.netMode == NetmodeID.SinglePlayer) + return; + + ModPacket packet = CalamityMod.Instance.GetPacket(); + packet.Write((byte)CalamityModMessageType.SyncDestroyerLaserColor); + packet.Write((byte)npc.whoAmI); + packet.Write(npc.Calamity().destroyerLaserColor); + packet.Send(); + } + #endregion + + #region Smooth Movement + /// + /// Smoother movement for NPCs + /// + /// The NPC getting the movement change. + /// The distance where the NPC should stop moving once it's close enough to its destination. + /// How far the NPC is from its destination. + /// How quickly the NPC moves towards its destination. + /// Whether the NPC should use SimpleFlyMovement to make the movement more affected by acceleration. + public static void SmoothMovement(NPC npc, float movementDistanceGateValue, Vector2 distanceFromDestination, float baseVelocity, float acceleration, bool useSimpleFlyMovement) + { + // Inverse lerp returns the percentage of progress between A and B + float lerpValue = Utils.GetLerpValue(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); + + // Min velocity + float minVelocity = distanceFromDestination.Length(); + float minVelocityCap = baseVelocity; + if (minVelocity > minVelocityCap) + minVelocity = minVelocityCap; + + // Max velocity + Vector2 maxVelocity = distanceFromDestination / 24f; + float maxVelocityCap = minVelocityCap * 3f; + if (maxVelocity.Length() > maxVelocityCap) + maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap; + + // Set the velocity + Vector2 desiredVelocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue); + if (useSimpleFlyMovement) + npc.SimpleFlyMovement(desiredVelocity, acceleration); + else + npc.velocity = desiredVelocity; + } + #endregion + + #region Calamity Style Targeting + /// + /// Replacement and extension for vanilla's NPC.TargetClosest. Has very flexible behavior.
+ /// Like vanilla's function, this function does not return any value, but makes its changes in-place. + ///
+ /// Struct to specify all options. Refer to struct definition in NPCUtils for details. + /// The targeted player ID. + public static int CalamityTargeting(this NPC npc, CalamityTargetingParameters options) + { + float distance = 0f; + // float realDist = 0f; // Defined but not used by vanilla. Commented out here. + bool anyTargetAvailable = false; + int tankMinionProjectileID = -1; + + // The setup and initial loop is equivalent to vanilla NPC.TargetClosest, but optimized. + foreach (Player p in Main.ActivePlayers) + { + bool playerDead = p.dead || p.ghost; + if (playerDead) + continue; + + // ForceSwitch targeting. If the same player from last time is iterated over, just ignore them. + bool sameTargetAsLastTime = p.whoAmI == npc.oldTarget; + bool notSinglePlayer = Main.netMode != NetmodeID.SinglePlayer; + if (options.targetType == NPCTargetType.ForceSwitch && notSinglePlayer && sameTargetAsLastTime) + continue; + + // + // The below code is implemented in vanilla as a separate method. Here, it's inlined for efficiency. + // + + Vector2 pCenter = p.Center; + Vector2 targetCenter = options.targetingCenter ?? npc.Center; + float manhattanDist = Math.Abs(targetCenter.X - pCenter.X) + Math.Abs(targetCenter.Y - pCenter.Y); + + // Hard cutoff range specified in options. If the player is further, completely ignore them. + if (manhattanDist > options.maxSearchRange) + continue; + + // Line of sight requirement specified in options. Please don't use this without reducing the max search range. + if (options.requireLineOfSight && !Collision.CanHit(npc.Center, 1, 1, pCenter, 1, 1)) + continue; + + float aggroAdjustedDist = manhattanDist - options.aggroRatio * p.aggro; + + // Implementation of "Finish Them Off": Add enormous amounts of virtual aggro to low health players + if (options.finishThemOff) + { + float missingHPRatio = MathHelper.Clamp(1f - p.statLife / (float)p.statLifeMax2, 0f, 1f); + float bloodthirstAggro = MathHelper.Lerp(0f, CalamityTargetingParameters.FinishThemOff_MaxAggroBoost, missingHPRatio); + aggroAdjustedDist -= bloodthirstAggro; + } + + bool aggroDisabled = p.npcTypeNoAggro[npc.type]; + if (aggroDisabled && npc.direction != 0) + aggroAdjustedDist += 1000f; + + bool cancelTargeting = false; + + // PreferSame targeting. If the same player from last time is a valid target, even if not the "best" target, pick it anyway. + bool preferSameFound = options.targetType == NPCTargetType.PreferSame && sameTargetAsLastTime; + + // Standard targeting. If the adjusted distance is lower, or this is the first valid target, actually choose the new target. + bool standardTargetingRequirementsMet = !anyTargetAvailable || aggroAdjustedDist < distance; + + // If either targeting method succeeded, then this target is being engaged. + bool engageThisTarget = preferSameFound || standardTargetingRequirementsMet; + if (engageThisTarget) + { + anyTargetAvailable = true; + tankMinionProjectileID = -1; // Reset any Stardust Guardian aggro because a real player was found. + distance = aggroAdjustedDist; + npc.target = p.whoAmI; + + // If PreferSame targeting is active, and the same player was found, cancel further iteration. They are being chosen above all others. + if (preferSameFound) + cancelTargeting = true; + } + + // "Tank pet" accomodation, AKA the 1.4+ Stardust Guardian + // Basically, if the player would be targeted, give a chance to instead target their tank minion + // + // This behavior is not documented on the vanilla wiki. + if (p.tankPet >= 0 && !aggroDisabled && !options.ignoreTankMinions) + { + Projectile tankMinion = Main.projectile[p.tankPet]; + Vector2 tmCenter = tankMinion.Center; + float manhattanDistToTankMinion = Math.Abs(targetCenter.X - tmCenter.X) + Math.Abs(targetCenter.Y - tmCenter.Y); + + // The Stardust Guardian is considered to have a 200 aggro bonus by default. + // In Calamity this is scaled by the aggro ratio specified in options. + manhattanDistToTankMinion -= options.aggroRatio * 200f; + + // The Stardust Guardian only attracts the attention of NPCs within a very short distance + if (manhattanDistToTankMinion < distance && manhattanDistToTankMinion < 200f && Collision.CanHit(npc.Center, 1, 1, tmCenter, 1, 1)) + tankMinionProjectileID = p.tankPet; + } + + // If targeting has been short-circuited for any reason, cancel iteration over players. + if (cancelTargeting) + break; + } + + // If the NPC has been aggroed by a Stardust Guardian instead of an actual player, account for that + if (tankMinionProjectileID >= 0) + { + Projectile tankMinion = Main.projectile[tankMinionProjectileID]; + npc.targetRect = tankMinion.Hitbox; + + // Always set direction to a nonzero value. This NPC has been engaged in combat. + npc.direction = 1; + if (tankMinion.Center.X < npc.Center.X) + npc.direction = -1; + + npc.directionY = 1; + if (tankMinion.Center.Y < npc.Center.Y) + npc.directionY = -1; + } + + // Standard player aggro occurs here + else + { + bool shouldFaceTarget = options.faceTarget; + + // Sanitize targeted player index + if (npc.target < 0 || npc.target >= Main.maxPlayers) + npc.target = 0; + + Player targetPlayer = Main.player[npc.target]; + npc.targetRect = targetPlayer.Hitbox; + + // Do not switch facing to look at dead players. + if (targetPlayer.dead) + shouldFaceTarget = false; + + // If already engaged in combat, do not switch facing to look at players that ignore your aggro. + if (targetPlayer.npcTypeNoAggro[npc.type] && npc.direction != 0) + shouldFaceTarget = false; + + if (shouldFaceTarget) + { + bool oldTargetWasValid = npc.oldTarget >= 0 && npc.oldTarget < Main.maxPlayers; + + bool targetIsLowAggroNotUsingItem = targetPlayer.itemAnimation == 0 && targetPlayer.aggro < 0; + bool willIgnoreStealthedPlayers = !npc.boss && options.ignoreStealthedPlayers; + + // Regular NPCs (not bosses) will voluntarily ignore otherwise-valid player targets with less than zero aggro if they are not actively using an item. + // This ONLY WORKS if they already have another valid target, aka multiplayer. + // As such, having net less than zero aggro enables you to remain "stealthed" to regular enemies if you are not doing anything. + // This is undocumented vanilla behavior. + bool ignoreStealthedPlayer = willIgnoreStealthedPlayers && oldTargetWasValid && targetIsLowAggroNotUsingItem; + if (!ignoreStealthedPlayer) + { + // Always set direction to a nonzero value. This NPC has been engaged in combat. + npc.direction = 1; + if (targetPlayer.Center.X < npc.Center.X) + npc.direction = -1; + + npc.directionY = 1; + if (targetPlayer.Center.Y < npc.Center.Y) + npc.directionY = -1; + } + } + } + + // Confused enemies always run in the exact wrong direction, horizontally at least. + if (npc.confused) + npc.direction *= -1; + + // Apply net updates. + bool directionChange = npc.direction != npc.oldDirection || npc.directionY != npc.oldDirectionY; + bool targetChange = npc.target != npc.oldTarget; + bool shouldNetUpdate = (directionChange || targetChange) && !npc.collideX && !npc.collideY; + if (shouldNetUpdate || options.forceNetUpdate) + npc.netUpdate = true; + + return npc.target; + } + #endregion + + #region Minion Homing /// /// Detects nearby hostile NPCs from a given point /// @@ -306,6 +606,53 @@ namespace CalamityMod return closestTarget; } + /// + /// Detects the hostile NPC that is closest angle-wise to the rotation vector + /// + /// The position that will be used to find the rotation vector to NPCs + /// The rotation vector that the other rotation vectors to NPCs will be compared to + /// Maximum amount of pixels to check around the origin + /// When the angle between the rotation vector and the vector to the NPC is less than or equal to this, NPCs start getting ranked by distance. Set to 0 or less to ignore + /// Whether or not to ignore tiles when finding a target + /// The NPC that best fits the parameters. Null if no NPC is found + public static NPC ClosestNPCToAngle(this Vector2 origin, Vector2 checkRotationVector, float maxDistanceToCheck, float wantedHalfCone = 0.125f, bool ignoreTiles = true) + { + NPC closestTarget = null; + float distance = maxDistanceToCheck; + float angle = MathHelper.Pi; + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (!npc.CanBeChasedBy(null, false)) + continue; + + float checkDist = origin.Distance(npc.Center); + if (checkDist >= distance) // Immediately disqualify anything beyond the distance that must be beaten + continue; + + float angleBetween = checkRotationVector.AngleBetween(npc.Center - origin); + if (angleBetween > angle) // Narrow down to the closest npc to the angle + continue; + + if (!ignoreTiles && !Collision.CanHit(origin, 1, 1, npc.Center, 1, 1)) // Tile LoS check if wanted + continue; + + if (angle <= wantedHalfCone) + { + angle = wantedHalfCone; + distance = checkDist; // We are within the cone. Now npcs are further narrowed down by distance + closestTarget = npc; + } + else + { + angle = angleBetween; + closestTarget = npc; + } + } + + return closestTarget; + } + /// /// Detects nearby hostile NPCs from a given point with minion support /// @@ -329,39 +676,7 @@ namespace CalamityMod } return ClosestNPCAt(origin, maxDistanceToCheck, ignoreTiles); } - - /// - /// Smoother movement for NPCs - /// - /// The NPC getting the movement change. - /// The distance where the NPC should stop moving once it's close enough to its destination. - /// How far the NPC is from its destination. - /// How quickly the NPC moves towards its destination. - /// Whether the NPC should use SimpleFlyMovement to make the movement more affected by acceleration. - public static void SmoothMovement(NPC npc, float movementDistanceGateValue, Vector2 distanceFromDestination, float baseVelocity, float acceleration, bool useSimpleFlyMovement) - { - // Inverse lerp returns the percentage of progress between A and B - float lerpValue = Utils.GetLerpValue(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); - - // Min velocity - float minVelocity = distanceFromDestination.Length(); - float minVelocityCap = baseVelocity; - if (minVelocity > minVelocityCap) - minVelocity = minVelocityCap; - - // Max velocity - Vector2 maxVelocity = distanceFromDestination / 24f; - float maxVelocityCap = minVelocityCap * 3f; - if (maxVelocity.Length() > maxVelocityCap) - maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap; - - // Set the velocity - Vector2 desiredVelocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue); - if (useSimpleFlyMovement) - npc.SimpleFlyMovement(desiredVelocity, acceleration); - else - npc.velocity = desiredVelocity; - } + #endregion /// /// Check if an NPC is organic @@ -375,31 +690,13 @@ namespace CalamityMod target.HitSound != SoundID.NPCHit34 && target.HitSound != SoundID.NPCHit36 && target.HitSound != SoundID.NPCHit42 && target.HitSound != SoundID.NPCHit49 && target.HitSound != SoundID.NPCHit52 && target.HitSound != SoundID.NPCHit53 && target.HitSound != SoundID.NPCHit54 && target.HitSound != null) || target.type == NPCType() || - target.type == NPCType()) + target.type == NPCType() || target.type == NPCType()) { return true; } return false; } - /// - /// Shortcut for the generic boss summon message. - /// - /// The whoAmI index of the summoned npc. - public static void BossAwakenMessage(int npcIndex) - { - // TODO -- this should use MiscUtils DisplayLocalizedText. - string typeName = Main.npc[npcIndex].TypeName; - if (Main.netMode == NetmodeID.SinglePlayer) - { - Main.NewText(Language.GetTextValue("Announcement.HasAwoken", typeName), new Color(175, 75, 255)); - } - else if (Main.netMode == NetmodeID.Server) - { - ChatHelper.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", new object[] { Main.npc[npcIndex].GetTypeNetName() }), new Color(175, 75, 255)); - } - } - public static void Inflict246DebuffsNPC(NPC target, int buff, float timeBase = 2f) { if (Main.rand.NextBool(4)) @@ -416,8 +713,6 @@ namespace CalamityMod } } - public static T ModNPC(this NPC npc) where T : ModNPC => npc.ModNPC as T; - public static NPCShop AddWithCustomValue(this NPCShop shop, int itemType, int customValue, params Condition[] conditions) { var item = new Item(itemType) @@ -432,6 +727,38 @@ namespace CalamityMod return shop.AddWithCustomValue(ItemType(), customValue, conditions); } + public static void DrawBackglow(this NPC npc, Color backglowColor, float backglowArea, SpriteEffects spriteEffects, Rectangle frame, Vector2 screenPos, Texture2D overrideTexture = null) + { + Texture2D texture = overrideTexture is null ? TextureAssets.Npc[npc.type].Value : overrideTexture; + Vector2 drawPosition = npc.Center - screenPos; + Vector2 origin = frame.Size() * 0.5f; + Color backAfterimageColor = backglowColor * npc.Opacity; + for (int i = 0; i < 10; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 10f).ToRotationVector2() * backglowArea; + Main.spriteBatch.Draw(texture, drawPosition + drawOffset, frame, backAfterimageColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); + } + } + + #region Boss Spawning + /// + /// Shortcut for the generic boss summon message. + /// + /// The whoAmI index of the summoned npc. + public static void BossAwakenMessage(int npcIndex) + { + // TODO -- this should use MiscUtils DisplayLocalizedText. + string typeName = Main.npc[npcIndex].TypeName; + if (Main.netMode == NetmodeID.SinglePlayer) + { + Main.NewText(Language.GetTextValue("Announcement.HasAwoken", typeName), new Color(175, 75, 255)); + } + else if (Main.netMode == NetmodeID.Server) + { + ChatHelper.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", new object[] { Main.npc[npcIndex].GetTypeNetName() }), new Color(175, 75, 255)); + } + } + /// /// Summons a boss near a particular area depending on a specific spawn context. /// @@ -465,19 +792,6 @@ namespace CalamityMod return null; } - public static void DrawBackglow(this NPC npc, Color backglowColor, float backglowArea, SpriteEffects spriteEffects, Rectangle frame, Vector2 screenPos, Texture2D overrideTexture = null) - { - Texture2D texture = overrideTexture is null ? TextureAssets.Npc[npc.type].Value : overrideTexture; - Vector2 drawPosition = npc.Center - screenPos; - Vector2 origin = frame.Size() * 0.5f; - Color backAfterimageColor = backglowColor * npc.Opacity; - for (int i = 0; i < 10; i++) - { - Vector2 drawOffset = (MathHelper.TwoPi * i / 10f).ToRotationVector2() * backglowArea; - Main.spriteBatch.Draw(texture, drawPosition + drawOffset, frame, backAfterimageColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); - } - } - /// /// Spawns Old Duke on a player. Only works server side, and only works if the player owns a fishing bobber.
/// Old Duke will spawn above the fishing bobber if one is found. @@ -508,5 +822,6 @@ namespace CalamityMod int oldDuke = NPC.NewNPC(NPC.GetBossSpawnSource(playerIndex), (int)projectile.Center.X, (int)projectile.Center.Y + 100, NPCType()); BossAwakenMessage(oldDuke); } + #endregion } } diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index eab0501756..70e80b71ea 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -343,6 +343,8 @@ namespace CalamityMod public static bool InSulphur(this Player player) => player.Calamity().ZoneSulphur; + public static bool InFloralParadise(this Player player) => player.Calamity().ZoneFloralParadise; + public static bool InAstral(this Player player, int biome = 0) //1 is above ground, 2 is underground, 3 is desert { switch (biome) @@ -887,7 +889,7 @@ namespace CalamityMod ///
/// The player using the holdout. /// Returns if the player CAN'T use the item. - public static bool CantUseHoldout(this Player player) => player == null || !player.active || player.dead || !player.channel || player.CCed || player.noItems; + public static bool CantUseHoldout(this Player player, bool needsToHold = true) => player == null || !player.active || player.dead || (!player.channel && needsToHold) || player.CCed || player.noItems; /// /// Makes the given player send the given packet to all appropriate receivers.
diff --git a/Utilities/TileFraming.cs b/Utilities/TileFraming.cs index a657958050..38228f5e3f 100644 --- a/Utilities/TileFraming.cs +++ b/Utilities/TileFraming.cs @@ -10,6 +10,7 @@ using CalamityMod.Tiles.Crags; using CalamityMod.Tiles.FurnitureAshen; using CalamityMod.Tiles.Ores; using CalamityMod.Tiles.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; diff --git a/Utilities/TileUtils.cs b/Utilities/TileUtils.cs index 5b6b1e6d5b..b2ca81048b 100644 --- a/Utilities/TileUtils.cs +++ b/Utilities/TileUtils.cs @@ -7,6 +7,7 @@ using CalamityMod.Tiles.Astral; using CalamityMod.Tiles.AstralDesert; using CalamityMod.Tiles.AstralSnow; using CalamityMod.Tiles.Crags; +using CalamityMod.Tiles.FloralParadise; using CalamityMod.Tiles.FurnitureAbyss; using CalamityMod.Tiles.FurnitureAshen; using CalamityMod.Tiles.FurnitureEutrophic; @@ -335,6 +336,12 @@ namespace CalamityMod TileType(), TileType(), TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), TileType(), TileType(), TileType(), @@ -405,6 +412,15 @@ namespace CalamityMod TileType(), TileType(), // Sunken Sea + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), + TileType(), TileType(), TileType(), TileType(), @@ -461,6 +477,17 @@ namespace CalamityMod TileType(), }); + /// + /// Makes the tile merge with all the tile types that generate within various types of floral paradise tiles. + /// + /// The tile whose merging properties will be set. + public static void MergeWithFloralParadise(int type) => MergeWithSet(type, new int[] { + TileType(), + TileType(), + TileType(), + TileType(), + }); + /// /// Makes the tile merge with all the tile types that generate within various types of astral tiles /// diff --git a/Utilities/WorldgenUtils.cs b/Utilities/WorldgenUtils.cs index 1c18796fbb..9d3bac0ce1 100644 --- a/Utilities/WorldgenUtils.cs +++ b/Utilities/WorldgenUtils.cs @@ -12,6 +12,8 @@ namespace CalamityMod { public static partial class CalamityUtils { + public const int DefaultGenerationLoopLimit = 5000; + /// /// Generates clusters of ore across the world based on various requirements and with various strengths/frequencies. /// @@ -38,6 +40,57 @@ namespace CalamityMod } } + /// + /// Counts the amount of "cells" near a given range in a 2D boolean array. This is specifically used in conjunction with the

+ /// utility. + ///
+ /// The cell states. + /// The X position to count cells by. + /// The Y position to count cells by. + /// Whether to check for active cells ( values) or not ( values). + public static int CountCellsAtPosition(bool[,] map, int x, int y, bool checkForActiveCells) + { + int count = 0; + for (int dx = -1; dx <= 1; dx++) + { + for (int dy = -1; dy <= 1; dy++) + { + // Ignore the center position. + if (dx == 0 && dy == 0) + continue; + + // Ignore cells outside of the range of the map. + if (x + dx < 0 || x + dx >= map.GetLength(0) || y + dy < 0 || y + dy >= map.GetLength(1)) + continue; + + if ((map[x + dx, y + dy] && checkForActiveCells) || (!map[x + dx, y + dy] && !checkForActiveCells)) + count++; + } + } + return count; + } + + /// + /// Generates a cell map based on a cellular automata algorithm. The primary use-case for this is for creating smooth cave patterns,

+ /// with the cell's state representing whether a tile is active or not. + ///
+ /// The original cell states. + public static bool[,] SimulateCelluarAutomata(bool[,] originalMap) + { + bool[,] newMap = (bool[,])originalMap.Clone(); + for (int x = 0; x < originalMap.GetLength(0); x++) + { + for (int y = 0; y < originalMap.GetLength(1); y++) + { + if (originalMap[x, y] && CountCellsAtPosition(originalMap, x, y, true) <= 3) + newMap[x, y] = false; + else if (!originalMap[x, y] && CountCellsAtPosition(originalMap, x, y, true) >= 5) + newMap[x, y] = true; + } + } + return newMap; + } + public static void GrowVines(int VineX, int VineY, int numVines, ushort vineType, bool finished = false) { for (int Y = VineY; Y <= VineY + numVines && !finished; Y++) diff --git a/Walls/DriftwoodWall.cs b/Walls/DriftwoodWall.cs new file mode 100644 index 0000000000..247dc7e021 --- /dev/null +++ b/Walls/DriftwoodWall.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class DriftwoodWall : WallVisibleThroughWater + { + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = true; + + AddEntries(new Color(69, 56, 58)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/DriftwoodWall.png b/Walls/DriftwoodWall.png new file mode 100644 index 0000000000..f33778a6fe Binary files /dev/null and b/Walls/DriftwoodWall.png differ diff --git a/Walls/LimestoneWall.cs b/Walls/LimestoneWall.cs new file mode 100644 index 0000000000..1f57ec5c49 --- /dev/null +++ b/Walls/LimestoneWall.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class LimestoneWall : WallVisibleThroughWater + { + public override void SetStaticDefaults() + { + DustType = 22; + AddEntries(new Color(147, 92, 63)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/LimestoneWall.png b/Walls/LimestoneWall.png new file mode 100644 index 0000000000..4da1f5d3be Binary files /dev/null and b/Walls/LimestoneWall.png differ diff --git a/Walls/NavystoneWall.png b/Walls/NavystoneWall.png index 4d7669028b..3c3de52f96 100644 Binary files a/Walls/NavystoneWall.png and b/Walls/NavystoneWall.png differ diff --git a/Walls/NavystoneWallSafe.png b/Walls/NavystoneWallSafe.png index 4d7669028b..3c3de52f96 100644 Binary files a/Walls/NavystoneWallSafe.png and b/Walls/NavystoneWallSafe.png differ diff --git a/Walls/RunestoneWall.cs b/Walls/RunestoneWall.cs new file mode 100644 index 0000000000..84d11681f3 --- /dev/null +++ b/Walls/RunestoneWall.cs @@ -0,0 +1,19 @@ +using CalamityMod.Dusts.Furniture; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class RunestoneWall : WallVisibleThroughWater + { + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = true; + + AddEntries(new Color(122, 59, 48)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/RunestoneWall.png b/Walls/RunestoneWall.png new file mode 100644 index 0000000000..9a5db46bc6 Binary files /dev/null and b/Walls/RunestoneWall.png differ diff --git a/Walls/ShellstoneSlabWall.cs b/Walls/ShellstoneSlabWall.cs new file mode 100644 index 0000000000..2b28e7dec8 --- /dev/null +++ b/Walls/ShellstoneSlabWall.cs @@ -0,0 +1,19 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class ShellstoneSlabWall : WallVisibleThroughWater + { + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = true; + DustType = 24; + + AddEntries(new Color(100, 127, 137)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/ShellstoneSlabWall.png b/Walls/ShellstoneSlabWall.png new file mode 100644 index 0000000000..3d6e1f138f Binary files /dev/null and b/Walls/ShellstoneSlabWall.png differ diff --git a/Walls/ShellstoneWall.cs b/Walls/ShellstoneWall.cs new file mode 100644 index 0000000000..57edd3df61 --- /dev/null +++ b/Walls/ShellstoneWall.cs @@ -0,0 +1,19 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public class ShellstoneWall : WallVisibleThroughWater + { + public override void SetStaticDefaults() + { + Main.wallHouse[Type] = false; + DustType = 24; + + AddEntries(new Color(74, 71, 84)); + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + } +} diff --git a/Walls/ShellstoneWall.png b/Walls/ShellstoneWall.png new file mode 100644 index 0000000000..8e262e884f Binary files /dev/null and b/Walls/ShellstoneWall.png differ diff --git a/Walls/WallVisibleThroughWater.cs b/Walls/WallVisibleThroughWater.cs new file mode 100644 index 0000000000..839304cf49 --- /dev/null +++ b/Walls/WallVisibleThroughWater.cs @@ -0,0 +1,36 @@ +using Microsoft.Xna.Framework; +using Terraria.Localization; +using Terraria.Map; +using Terraria.ModLoader; + +namespace CalamityMod.Walls +{ + public abstract class WallVisibleThroughWater : ModWall + { + public const float WaterTransparency = 0.5f; + public static readonly Color WaterColor = new Color(9, 61, 191); + + public int WaterMapEntry { get; private set; } + + /// + /// Adds the map entry, and further entries for being covered in water. + /// Please use this over AddMapEntry in walls which utilize this base class. + /// + /// + /// + public void AddEntries(Color baseColor, LocalizedText text = null) + { + AddMapEntry(baseColor, text); + AddMapEntry(Color.Lerp(baseColor, WaterColor, WaterTransparency), text); + } + + public static void InitializeWaterMapEntryLookups() + { + foreach (var wall in CalamityMod.Instance.GetContent()) + { + int lookup = MapHelper.wallLookup[wall.Type]; + wall.WaterMapEntry = lookup + 1; + } + } + } +} diff --git a/Waterfalls/WaterfallRenderer.cs b/Waterfalls/WaterfallRenderer.cs new file mode 100644 index 0000000000..ec10d09101 --- /dev/null +++ b/Waterfalls/WaterfallRenderer.cs @@ -0,0 +1,105 @@ +using CalamityMod.Graphics.Primitives; +using CalamityMod.Tiles.FloralParadise; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ModLoader; + +namespace CalamityMod.Waterfalls +{ + public static class WaterfallRenderer + { + private static Vector2 currentWaterfallPosition; + + private static float currentWaterfallBrightness; + + private static float currentWaterfallHeight; + + internal static float PrimitiveWidthFunction(float completionRatio) + { + float baseWidth = MathHelper.Lerp(16f, 6f, Utils.GetLerpValue(36f, 216f, currentWaterfallHeight, true)); + float positionOffset = currentWaterfallPosition.X * 0.17f % 300f + currentWaterfallPosition.Y * 0.33f % 300f; + float x1Offset = (float)(Math.Sin(-Main.GlobalTimeWrappedHourly * 3f + completionRatio * 9f + positionOffset) * 0.5f + 0.5f) * baseWidth * 0.2f; + float x2Offset = (float)(Math.Sin(-Main.GlobalTimeWrappedHourly * 6f + completionRatio * 6f + positionOffset) * 0.5f + 0.5f) * baseWidth * 0.25f; + + if (completionRatio < 0.2f) + return MathHelper.SmoothStep(1f, baseWidth + x2Offset - x1Offset, Utils.GetLerpValue(0f, 0.2f, completionRatio, true)); + return baseWidth + x2Offset + MathHelper.SmoothStep(0f, baseWidth * 0.85f, Utils.GetLerpValue(0.84f, 0.96f, completionRatio, true)) - x1Offset; + } + + internal static Color PrimitiveColorFunction(float completionRatio) + { + Color c = Color.Lerp(Color.Cyan, new Color(1f, 1f, 1f, 0f), (float)Math.Pow(Utils.GetLerpValue(0.75f, 1f, completionRatio, true), 0.68)); + return c; + } + + public static IEnumerable FindNearbyWaterfallRenderers() + { + int waterfallGeneratorID = ModContent.TileType(); + Point center = Main.LocalPlayer.Center.ToTileCoordinates(); + for (int i = -Main.screenWidth / 16 - 10; i < Main.screenWidth / 16 + 10; i++) + { + for (int j = -Main.screenHeight / 16 - 10; j < Main.screenHeight / 16 + 10; j++) + { + Tile tile = CalamityUtils.ParanoidTileRetrieval(center.X + i, center.Y + j); + if (tile.TileType != waterfallGeneratorID || !tile.HasTile) + continue; + + yield return new Vector2(center.X + i, center.Y + j); + } + } + } + + public static void DrawWaterfalls() + { + foreach (Vector2 drawTilePosition in FindNearbyWaterfallRenderers()) + { + Vector2 drawPosition = drawTilePosition * 16f; + Vector2 bottom = drawPosition; + for (int i = 0; i < 16; i++) + { + if (CalamityUtils.ParanoidTileRetrieval((int)drawTilePosition.X, (int)drawTilePosition.Y + i).LiquidAmount > 0) + { + bottom.Y += i * 16f; + break; + } + } + + bottom.Y += 4f; + currentWaterfallHeight = MathHelper.Distance(bottom.Y, drawPosition.Y); + if (currentWaterfallHeight <= 20f) + continue; + + currentWaterfallBrightness = Lighting.Brightness((int)(drawPosition.X / 16f), (int)(drawPosition.Y / 16f)); + currentWaterfallPosition = drawPosition + Vector2.One * 8f; + + Vector2[] drawPoints = new Vector2[] + { + drawPosition, + Vector2.Lerp(drawPosition, bottom, 0.5f), + bottom + }; + + // Determine the position of the waterfall's ambience sound. + float distanceFromWaterfall = Main.LocalPlayer.Distance(drawPosition + Vector2.One * 8f); + float distanceFromOldWaterfall = 100000f; + if (Main.ambientWaterfallX != -1f && Main.ambientWaterfallY != -1f) + distanceFromOldWaterfall = Main.LocalPlayer.Distance(new Vector2(Main.ambientWaterfallX, Main.ambientWaterfallY)); + + if (distanceFromOldWaterfall > distanceFromWaterfall) + { + Main.ambientWaterfallX = drawPosition.X + 8f; + Main.ambientWaterfallY = drawPosition.Y + 8f; + Main.ambientWaterfallStrength = MathHelper.Max(Main.ambientWaterfallStrength, Utils.GetLerpValue(740f, 300f, distanceFromWaterfall, true)); + } + + GameShaders.Misc["CalamityMod:Waterfall"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/WorleyNoise")); + GameShaders.Misc["CalamityMod:Waterfall"].UseOpacity((float)Math.Pow(currentWaterfallBrightness, 0.62)); + PrimitiveRenderer.RenderTrail(drawPoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, shader: GameShaders.Misc["CalamityMod:Waterfall"]), 80); + } + } + } +} diff --git a/Waters/BasaltGullyWater.cs b/Waters/BasaltGullyWater.cs new file mode 100644 index 0000000000..6aa26ea180 --- /dev/null +++ b/Waters/BasaltGullyWater.cs @@ -0,0 +1,33 @@ +using Microsoft.Xna.Framework; +using Terraria.ModLoader; + +namespace CalamityMod.Waters +{ + public class BasaltGullyWater : ModWaterStyle + { + public static int Type; + public override void SetStaticDefaults() + { + Type = Slot; + } + public override int ChooseWaterfallStyle() + { + return ModContent.Find("CalamityMod/BasaltGullyWaterflow").Slot; + } + + public override int GetSplashDust() + { + return 33; + } + + public override int GetDropletGore() + { + return 713; + } + + public override Color BiomeHairColor() + { + return Color.DarkGray; + } + } +} diff --git a/Waters/BasaltGullyWater.png b/Waters/BasaltGullyWater.png new file mode 100644 index 0000000000..7ca076e041 Binary files /dev/null and b/Waters/BasaltGullyWater.png differ diff --git a/Waters/BasaltGullyWater_Block.png b/Waters/BasaltGullyWater_Block.png new file mode 100644 index 0000000000..d9af32df36 Binary files /dev/null and b/Waters/BasaltGullyWater_Block.png differ diff --git a/Waters/BasaltGullyWater_Slope.png b/Waters/BasaltGullyWater_Slope.png new file mode 100644 index 0000000000..bceca096bd Binary files /dev/null and b/Waters/BasaltGullyWater_Slope.png differ diff --git a/Waters/SunkenSeaWaterflow.cs b/Waters/BasaltGullyWaterflow.cs similarity index 56% rename from Waters/SunkenSeaWaterflow.cs rename to Waters/BasaltGullyWaterflow.cs index ae61284b07..545ff8daaf 100644 --- a/Waters/SunkenSeaWaterflow.cs +++ b/Waters/BasaltGullyWaterflow.cs @@ -1,8 +1,8 @@ using Terraria.ModLoader; + namespace CalamityMod.Waters { - public class SunkenSeaWaterflow : ModWaterfallStyle + public class BasaltGullyWaterflow : ModWaterfallStyle { - } } diff --git a/Waters/BasaltGullyWaterflow.png b/Waters/BasaltGullyWaterflow.png new file mode 100644 index 0000000000..c366e4d258 Binary files /dev/null and b/Waters/BasaltGullyWaterflow.png differ diff --git a/Waters/FloralParadiseWater.cs b/Waters/FloralParadiseWater.cs new file mode 100644 index 0000000000..9d67d11a46 --- /dev/null +++ b/Waters/FloralParadiseWater.cs @@ -0,0 +1,28 @@ +using Microsoft.Xna.Framework; +using Terraria.ModLoader; + +namespace CalamityMod.Waters +{ + public class FloralParadiseWater : ModWaterStyle + { + public override int ChooseWaterfallStyle() + { + return ModContent.Find("CalamityMod/FloralParadiseWaterflow").Slot; + } + + public override int GetSplashDust() + { + return 33; + } + + public override int GetDropletGore() + { + return 713; + } + + public override Color BiomeHairColor() + { + return Color.PaleTurquoise; + } + } +} diff --git a/Waters/FloralParadiseWater.png b/Waters/FloralParadiseWater.png new file mode 100644 index 0000000000..d8a0958b63 Binary files /dev/null and b/Waters/FloralParadiseWater.png differ diff --git a/Waters/FloralParadiseWaterWaterflow.cs b/Waters/FloralParadiseWaterWaterflow.cs new file mode 100644 index 0000000000..64a6ce4344 --- /dev/null +++ b/Waters/FloralParadiseWaterWaterflow.cs @@ -0,0 +1,9 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Waters +{ + public class FloralParadiseWaterflow : ModWaterfallStyle + { + + } +} diff --git a/Waters/FloralParadiseWater_Block.png b/Waters/FloralParadiseWater_Block.png new file mode 100644 index 0000000000..5fe701ea91 Binary files /dev/null and b/Waters/FloralParadiseWater_Block.png differ diff --git a/Waters/FloralParadiseWater_Slope.png b/Waters/FloralParadiseWater_Slope.png new file mode 100644 index 0000000000..a8a6fde86a Binary files /dev/null and b/Waters/FloralParadiseWater_Slope.png differ diff --git a/Waters/FloralParadiseWaterflow.png b/Waters/FloralParadiseWaterflow.png new file mode 100644 index 0000000000..aa0d689eb7 Binary files /dev/null and b/Waters/FloralParadiseWaterflow.png differ diff --git a/Waters/SunkenSeaWater.cs b/Waters/SunkenSeaBurrowsWater.cs similarity index 87% rename from Waters/SunkenSeaWater.cs rename to Waters/SunkenSeaBurrowsWater.cs index 62c32fbd4c..c7bd8974e5 100644 --- a/Waters/SunkenSeaWater.cs +++ b/Waters/SunkenSeaBurrowsWater.cs @@ -3,7 +3,7 @@ using Terraria.ModLoader; namespace CalamityMod.Waters { - public class SunkenSeaWater : ModWaterStyle + public class SunkenSeaBurrowsWater : ModWaterStyle { public static int Type; public override void SetStaticDefaults() @@ -12,7 +12,7 @@ namespace CalamityMod.Waters } public override int ChooseWaterfallStyle() { - return ModContent.Find("CalamityMod/SunkenSeaWaterflow").Slot; + return ModContent.Find("CalamityMod/SunkenSeaBurrowsWaterflow").Slot; } public override int GetSplashDust() diff --git a/Waters/SunkenSeaBurrowsWater.png b/Waters/SunkenSeaBurrowsWater.png new file mode 100644 index 0000000000..eab9dc5435 Binary files /dev/null and b/Waters/SunkenSeaBurrowsWater.png differ diff --git a/Waters/SunkenSeaBurrowsWater_Block.png b/Waters/SunkenSeaBurrowsWater_Block.png new file mode 100644 index 0000000000..975fbe6dee Binary files /dev/null and b/Waters/SunkenSeaBurrowsWater_Block.png differ diff --git a/Waters/SunkenSeaBurrowsWater_Slope.png b/Waters/SunkenSeaBurrowsWater_Slope.png new file mode 100644 index 0000000000..5598cc77c0 Binary files /dev/null and b/Waters/SunkenSeaBurrowsWater_Slope.png differ diff --git a/Waters/SunkenSeaBurrowsWaterflow.cs b/Waters/SunkenSeaBurrowsWaterflow.cs new file mode 100644 index 0000000000..79974dca2a --- /dev/null +++ b/Waters/SunkenSeaBurrowsWaterflow.cs @@ -0,0 +1,8 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Waters +{ + public class SunkenSeaBurrowsWaterflow : ModWaterfallStyle + { + } +} diff --git a/Waters/SunkenSeaBurrowsWaterflow.png b/Waters/SunkenSeaBurrowsWaterflow.png new file mode 100644 index 0000000000..4a4540f32f Binary files /dev/null and b/Waters/SunkenSeaBurrowsWaterflow.png differ diff --git a/Waters/SunkenSeaPolypWater.cs b/Waters/SunkenSeaPolypWater.cs new file mode 100644 index 0000000000..11a8967142 --- /dev/null +++ b/Waters/SunkenSeaPolypWater.cs @@ -0,0 +1,33 @@ +using Microsoft.Xna.Framework; +using Terraria.ModLoader; + +namespace CalamityMod.Waters +{ + public class SunkenSeaPolypWater : ModWaterStyle + { + public static int Type; + public override void SetStaticDefaults() + { + Type = Slot; + } + public override int ChooseWaterfallStyle() + { + return ModContent.Find("CalamityMod/SunkenSeaPolypWaterflow").Slot; + } + + public override int GetSplashDust() + { + return 33; + } + + public override int GetDropletGore() + { + return 713; + } + + public override Color BiomeHairColor() + { + return Color.Coral; + } + } +} diff --git a/Waters/SunkenSeaPolypWater.png b/Waters/SunkenSeaPolypWater.png new file mode 100644 index 0000000000..ff90d56704 Binary files /dev/null and b/Waters/SunkenSeaPolypWater.png differ diff --git a/Waters/SunkenSeaPolypWater_Block.png b/Waters/SunkenSeaPolypWater_Block.png new file mode 100644 index 0000000000..31eaa237d0 Binary files /dev/null and b/Waters/SunkenSeaPolypWater_Block.png differ diff --git a/Waters/SunkenSeaPolypWater_Slope.png b/Waters/SunkenSeaPolypWater_Slope.png new file mode 100644 index 0000000000..8c28641b1b Binary files /dev/null and b/Waters/SunkenSeaPolypWater_Slope.png differ diff --git a/Waters/SunkenSeaPolypWaterflow.cs b/Waters/SunkenSeaPolypWaterflow.cs new file mode 100644 index 0000000000..13c68fbe0b --- /dev/null +++ b/Waters/SunkenSeaPolypWaterflow.cs @@ -0,0 +1,8 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Waters +{ + public class SunkenSeaPolypWaterflow : ModWaterfallStyle + { + } +} diff --git a/Waters/SunkenSeaPolypWaterflow.png b/Waters/SunkenSeaPolypWaterflow.png new file mode 100644 index 0000000000..7632d15e9a Binary files /dev/null and b/Waters/SunkenSeaPolypWaterflow.png differ diff --git a/Waters/SunkenSeaReefsWater.cs b/Waters/SunkenSeaReefsWater.cs new file mode 100644 index 0000000000..b83f7f4b57 --- /dev/null +++ b/Waters/SunkenSeaReefsWater.cs @@ -0,0 +1,33 @@ +using Microsoft.Xna.Framework; +using Terraria.ModLoader; + +namespace CalamityMod.Waters +{ + public class SunkenSeaReefsWater : ModWaterStyle + { + public static int Type; + public override void SetStaticDefaults() + { + Type = Slot; + } + public override int ChooseWaterfallStyle() + { + return ModContent.Find("CalamityMod/SunkenSeaReefsWaterflow").Slot; + } + + public override int GetSplashDust() + { + return 33; + } + + public override int GetDropletGore() + { + return 713; + } + + public override Color BiomeHairColor() + { + return Color.SkyBlue; + } + } +} diff --git a/Waters/SunkenSeaReefsWater.png b/Waters/SunkenSeaReefsWater.png new file mode 100644 index 0000000000..fb72da6384 Binary files /dev/null and b/Waters/SunkenSeaReefsWater.png differ diff --git a/Waters/SunkenSeaReefsWater_Block.png b/Waters/SunkenSeaReefsWater_Block.png new file mode 100644 index 0000000000..e7ec1e6847 Binary files /dev/null and b/Waters/SunkenSeaReefsWater_Block.png differ diff --git a/Waters/SunkenSeaReefsWater_Slope.png b/Waters/SunkenSeaReefsWater_Slope.png new file mode 100644 index 0000000000..f817e2c784 Binary files /dev/null and b/Waters/SunkenSeaReefsWater_Slope.png differ diff --git a/Waters/SunkenSeaReefsWaterflow.cs b/Waters/SunkenSeaReefsWaterflow.cs new file mode 100644 index 0000000000..353e3e372e --- /dev/null +++ b/Waters/SunkenSeaReefsWaterflow.cs @@ -0,0 +1,8 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Waters +{ + public class SunkenSeaReefsWaterflow : ModWaterfallStyle + { + } +} diff --git a/Waters/SunkenSeaReefsWaterflow.png b/Waters/SunkenSeaReefsWaterflow.png new file mode 100644 index 0000000000..d2fe204180 Binary files /dev/null and b/Waters/SunkenSeaReefsWaterflow.png differ diff --git a/Waters/SunkenSeaShoresWater.cs b/Waters/SunkenSeaShoresWater.cs new file mode 100644 index 0000000000..5dd4c5e590 --- /dev/null +++ b/Waters/SunkenSeaShoresWater.cs @@ -0,0 +1,33 @@ +using Microsoft.Xna.Framework; +using Terraria.ModLoader; + +namespace CalamityMod.Waters +{ + public class SunkenSeaShoresWater : ModWaterStyle + { + public static int Type; + public override void SetStaticDefaults() + { + Type = Slot; + } + public override int ChooseWaterfallStyle() + { + return ModContent.Find("CalamityMod/SunkenSeaShoresWaterflow").Slot; + } + + public override int GetSplashDust() + { + return 33; + } + + public override int GetDropletGore() + { + return 713; + } + + public override Color BiomeHairColor() + { + return Color.OrangeRed; + } + } +} diff --git a/Waters/SunkenSeaShoresWater.png b/Waters/SunkenSeaShoresWater.png new file mode 100644 index 0000000000..d9ead26b53 Binary files /dev/null and b/Waters/SunkenSeaShoresWater.png differ diff --git a/Waters/SunkenSeaShoresWater_Block.png b/Waters/SunkenSeaShoresWater_Block.png new file mode 100644 index 0000000000..c828d653e2 Binary files /dev/null and b/Waters/SunkenSeaShoresWater_Block.png differ diff --git a/Waters/SunkenSeaShoresWater_Slope.png b/Waters/SunkenSeaShoresWater_Slope.png new file mode 100644 index 0000000000..179eb74a64 Binary files /dev/null and b/Waters/SunkenSeaShoresWater_Slope.png differ diff --git a/Waters/SunkenSeaShoresWaterflow.cs b/Waters/SunkenSeaShoresWaterflow.cs new file mode 100644 index 0000000000..67620e943c --- /dev/null +++ b/Waters/SunkenSeaShoresWaterflow.cs @@ -0,0 +1,8 @@ +using Terraria.ModLoader; + +namespace CalamityMod.Waters +{ + public class SunkenSeaShoresWaterflow : ModWaterfallStyle + { + } +} diff --git a/Waters/SunkenSeaShoresWaterflow.png b/Waters/SunkenSeaShoresWaterflow.png new file mode 100644 index 0000000000..3d605a0e35 Binary files /dev/null and b/Waters/SunkenSeaShoresWaterflow.png differ diff --git a/Waters/SunkenSeaWater.png b/Waters/SunkenSeaWater.png deleted file mode 100644 index cae58da0f0..0000000000 Binary files a/Waters/SunkenSeaWater.png and /dev/null differ diff --git a/Waters/SunkenSeaWater_Block.png b/Waters/SunkenSeaWater_Block.png deleted file mode 100644 index 3d86838967..0000000000 Binary files a/Waters/SunkenSeaWater_Block.png and /dev/null differ diff --git a/Waters/SunkenSeaWater_Slope.png b/Waters/SunkenSeaWater_Slope.png deleted file mode 100644 index 27f1769586..0000000000 Binary files a/Waters/SunkenSeaWater_Slope.png and /dev/null differ diff --git a/Waters/SunkenSeaWaterflow.png b/Waters/SunkenSeaWaterflow.png deleted file mode 100644 index c063dddf79..0000000000 Binary files a/Waters/SunkenSeaWaterflow.png and /dev/null differ diff --git a/World/Abyss.cs b/World/Abyss.cs index f70e99299c..7dd9c746a4 100644 --- a/World/Abyss.cs +++ b/World/Abyss.cs @@ -55,11 +55,11 @@ namespace CalamityMod.World int abyssMinX = AtLeftSideOfWorld ? 0 : abyssChasmX - 160; int abyssMaxX = AtLeftSideOfWorld ? abyssChasmX + 160 : x; - for (int abyssIndex = abyssMinX; abyssIndex < abyssMaxX; abyssIndex++) + for (int X = abyssMinX; X < abyssMaxX; X++) { - for (int abyssIndex2 = 0; abyssIndex2 < abyssChasmY + 50; abyssIndex2++) + for (int Y = 0; Y < abyssChasmY + 50; Y++) { - Tile tile = Framing.GetTileSafely(abyssIndex, abyssIndex2); + Tile tile = Framing.GetTileSafely(X, Y); if (tile.LiquidType == LiquidID.Lava && tile.LiquidAmount > 0) { @@ -74,43 +74,43 @@ namespace CalamityMod.World //i have at least left comments so people reading will know what does what if (Main.remixWorld) { - if (abyssIndex2 <= rockLayer) + if (Y <= rockLayer) { //replaces blocks wand walls that can be converted if (canConvert) { //layer 4 - if (abyssIndex2 <= rockLayer - (int)((y - 200) * 0.6f)) + if (Y <= rockLayer - (int)((y - 200) * 0.6f)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 3-4 dithering transition - else if (abyssIndex2 <= rockLayer - (int)((y - 200) * 0.59f) && WorldGen.genRand.NextBool(2)) + else if (Y <= rockLayer - (int)((y - 200) * 0.59f) && WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 3 - else if (abyssIndex2 <= rockLayer - (int)((y - 200) * 0.4f)) + else if (Y <= rockLayer - (int)((y - 200) * 0.4f)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 2-3 dithering transition - else if (abyssIndex2 <= rockLayer - (int)((y - 200) * 0.39f) && WorldGen.genRand.NextBool(2)) + else if (Y <= rockLayer - (int)((y - 200) * 0.39f) && WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 2 - else if (abyssIndex2 <= rockLayer - (int)((y - 200) * 0.2f)) + else if (Y <= rockLayer - (int)((y - 200) * 0.2f)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 1-2 dithering transition - else if (abyssIndex2 <= rockLayer - (int)((y - 200) * 0.19f)) + else if (Y <= rockLayer - (int)((y - 200) * 0.19f)) { if (WorldGen.genRand.NextBool(2)) { @@ -136,37 +136,37 @@ namespace CalamityMod.World tile.Get().HasTile = true; //layer 4 - if (abyssIndex2 <= rockLayer - (int)((y - 200) * 0.6f)) + if (Y <= rockLayer - (int)((y - 200) * 0.6f)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 3-4 dithering transition - else if (abyssIndex2 <= rockLayer - (int)((y - 200) * 0.59f) && WorldGen.genRand.NextBool(2)) + else if (Y <= rockLayer - (int)((y - 200) * 0.59f) && WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 3 - else if (abyssIndex2 <= rockLayer - (int)((y - 200) * 0.4f)) + else if (Y <= rockLayer - (int)((y - 200) * 0.4f)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 2-3 dithering transition - else if (abyssIndex2 <= rockLayer - (int)((y - 200) * 0.39f) && WorldGen.genRand.NextBool(2)) + else if (Y <= rockLayer - (int)((y - 200) * 0.39f) && WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 2 - else if (abyssIndex2 <= rockLayer - (int)((y - 200) * 0.2f)) + else if (Y <= rockLayer - (int)((y - 200) * 0.2f)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 1-2 dithering transition - else if (abyssIndex2 <= rockLayer - (int)((y - 200) * 0.19f)) + else if (Y <= rockLayer - (int)((y - 200) * 0.19f)) { if (WorldGen.genRand.NextBool(2)) { @@ -190,37 +190,37 @@ namespace CalamityMod.World } else { - if (abyssIndex2 > (rockLayer - Main.maxTilesY / 15) + 35) + if (Y > (rockLayer - Main.maxTilesY / 15) + 35) { - //replaces blocks wand walls that can be converted + //replaces blocks and walls that can be converted if (canConvert) { //layer 4 - if (abyssIndex2 > (rockLayer + y * 0.270)) + if (Y > (rockLayer + y * 0.270)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 3-4 dithering transition - else if (abyssIndex2 > (rockLayer + y * 0.268) && WorldGen.genRand.NextBool(2)) + else if (Y > (rockLayer + y * 0.268) && WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 3 - else if (abyssIndex2 > (rockLayer + y * 0.145)) + else if (Y > (rockLayer + y * 0.145)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 2-3 dithering transition - else if (abyssIndex2 > (rockLayer + y * 0.143) && WorldGen.genRand.NextBool(2)) + else if (Y > (rockLayer + y * 0.143) && WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 1-2 dithering transition - else if (abyssIndex2 >= rockLayer - 10 && abyssIndex2 <= rockLayer) + else if (Y >= rockLayer - 10 && Y <= rockLayer) { if (WorldGen.genRand.NextBool(2)) { @@ -234,7 +234,7 @@ namespace CalamityMod.World } } //layer 1 - else if (abyssIndex2 <= rockLayer - 10) + else if (Y <= rockLayer - 10) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); @@ -252,31 +252,31 @@ namespace CalamityMod.World tile.Get().HasTile = true; //layer 4 - if (abyssIndex2 > (rockLayer + y * 0.270)) + if (Y > (rockLayer + y * 0.270)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 3-4 dithering transition - else if (abyssIndex2 > (rockLayer + y * 0.268) && WorldGen.genRand.NextBool(2)) + else if (Y > (rockLayer + y * 0.268) && WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 3 - else if (abyssIndex2 > (rockLayer + y * 0.145)) + else if (Y > (rockLayer + y * 0.145)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 2-3 dithering transition - else if (abyssIndex2 > (rockLayer + y * 0.143) && WorldGen.genRand.NextBool(2)) + else if (Y > (rockLayer + y * 0.143) && WorldGen.genRand.NextBool(2)) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); } //layer 1-2 dithering transition - else if (abyssIndex2 >= rockLayer - 10 && abyssIndex2 <= rockLayer) + else if (Y >= rockLayer - 10 && Y <= rockLayer) { if (WorldGen.genRand.NextBool(2)) { @@ -290,7 +290,7 @@ namespace CalamityMod.World } } //layer 1 - else if (abyssIndex2 <= rockLayer - 10) + else if (Y <= rockLayer - 10) { tile.TileType = (ushort)ModContent.TileType(); tile.WallType = (ushort)ModContent.WallType(); @@ -527,27 +527,27 @@ namespace CalamityMod.World } //clean up - for (int abyssIndex = abyssMinX + 5; abyssIndex < abyssMaxX - 5; abyssIndex++) + for (int X = abyssMinX + 5; X < abyssMaxX - 5; X++) { - for (int abyssIndex2 = 5; abyssIndex2 < abyssChasmY; abyssIndex2++) + for (int Y = 5; Y < abyssChasmY; Y++) { - Tile tile = Main.tile[abyssIndex, abyssIndex2]; - Tile tileUp = Main.tile[abyssIndex, abyssIndex2 - 1]; - Tile tileDown = Main.tile[abyssIndex, abyssIndex2 + 1]; - Tile tileLeft = Main.tile[abyssIndex - 1, abyssIndex2]; - Tile tileRight = Main.tile[abyssIndex + 1, abyssIndex2]; + Tile tile = Main.tile[X, Y]; + Tile tileUp = Main.tile[X, Y - 1]; + Tile tileDown = Main.tile[X, Y + 1]; + Tile tileLeft = Main.tile[X - 1, Y]; + Tile tileRight = Main.tile[X + 1, Y]; if (tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType()) { //slope tiles - Tile.SmoothSlope(abyssIndex, abyssIndex2, true); + Tile.SmoothSlope(X, Y, true); //kill any individual floating tiles if (!tileUp.HasTile && !tileDown.HasTile && !tileLeft.HasTile && !tileRight.HasTile) { - WorldGen.KillTile(abyssIndex, abyssIndex2); + WorldGen.KillTile(X, Y); } } @@ -561,24 +561,24 @@ namespace CalamityMod.World //kill obsidian if (tile.TileType == TileID.Obsidian) { - WorldGen.KillTile(abyssIndex, abyssIndex2); + WorldGen.KillTile(X, Y); } } } //ambient tiles and pots - for (int abyssIndex = abyssMinX + 5; abyssIndex < abyssMaxX - 5; abyssIndex++) + for (int X = abyssMinX + 5; X < abyssMaxX - 5; X++) { - for (int abyssIndex2 = 0; abyssIndex2 < (Main.remixWorld ? rockLayer : Main.UnderworldLayer); abyssIndex2++) + for (int Y = 0; Y < (Main.remixWorld ? rockLayer : Main.UnderworldLayer); Y++) { - Tile tileToGrowVineOn = Main.tile[abyssIndex, abyssIndex2]; + Tile tileToGrowVineOn = Main.tile[X, Y]; - if (!Main.tile[abyssIndex, abyssIndex2].HasTile) + if (!Main.tile[X, Y].HasTile) { - Tile tile = Main.tile[abyssIndex, abyssIndex2 + 1]; + Tile tile = Main.tile[X, Y + 1]; //above the 4th layer - if (abyssIndex2 < (Main.remixWorld ? rockLayer : Main.UnderworldLayer) && WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1)) + if (Y < (Main.remixWorld ? rockLayer : Main.UnderworldLayer) && WorldGen.SolidTile(X, Y + 1)) { //sulphur shale stuff if (tile.TileType == ModContent.TileType()) @@ -586,7 +586,7 @@ namespace CalamityMod.World //tube coral if (WorldGen.genRand.NextBool(85)) { - WorldGen.PlaceObject(abyssIndex, abyssIndex2, (ushort)ModContent.TileType()); + WorldGen.PlaceObject(X, Y, (ushort)ModContent.TileType()); } //shale rock piles @@ -595,7 +595,7 @@ namespace CalamityMod.World ushort[] ShalePiles = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - WorldGen.PlaceObject(abyssIndex, abyssIndex2, WorldGen.genRand.Next(ShalePiles)); + WorldGen.PlaceObject(X, Y, WorldGen.genRand.Next(ShalePiles)); } //pire corals @@ -604,7 +604,7 @@ namespace CalamityMod.World ushort[] PireCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - WorldGen.PlaceObject(abyssIndex, abyssIndex2, WorldGen.genRand.Next(PireCorals)); + WorldGen.PlaceObject(X, Y, WorldGen.genRand.Next(PireCorals)); } //sulphur fossils @@ -613,7 +613,7 @@ namespace CalamityMod.World ushort[] SulphuricFossils = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - WorldGen.PlaceObject(abyssIndex, abyssIndex2, WorldGen.genRand.Next(SulphuricFossils)); + WorldGen.PlaceObject(X, Y, WorldGen.genRand.Next(SulphuricFossils)); } //ribs @@ -623,7 +623,7 @@ namespace CalamityMod.World (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - WorldGen.PlaceObject(abyssIndex, abyssIndex2, WorldGen.genRand.Next(Ribs)); + WorldGen.PlaceObject(X, Y, WorldGen.genRand.Next(Ribs)); } } @@ -635,17 +635,33 @@ namespace CalamityMod.World ushort[] PlantPiles = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - WorldGen.PlaceObject(abyssIndex, abyssIndex2, WorldGen.genRand.Next(PlantPiles)); + WorldGen.PlaceObject(X, Y, WorldGen.genRand.Next(PlantPiles)); } } //abyss gravel stuff if (tile.TileType == ModContent.TileType()) { + //place coral blobs + if (WorldGen.genRand.NextBool(125) && !Main.tile[X, Y - 1].HasTile) + { + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(3, 4)), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); + + WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.PlaceTile((ushort)ModContent.TileType()) + })); + } + //rare pearls if (WorldGen.genRand.NextBool(50)) { - WorldGen.PlaceObject(abyssIndex, abyssIndex2, (ushort)ModContent.TileType()); + WorldGen.PlaceObject(X, Y, (ushort)ModContent.TileType()); } //giant kelp on abyss gravel @@ -654,7 +670,7 @@ namespace CalamityMod.World ushort[] Kelps = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - WorldGen.PlaceObject(abyssIndex, abyssIndex2, WorldGen.genRand.Next(Kelps)); + WorldGen.PlaceObject(X, Y, WorldGen.genRand.Next(Kelps)); } //plany mush piles @@ -663,7 +679,7 @@ namespace CalamityMod.World ushort[] PlantPiles = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - WorldGen.PlaceObject(abyssIndex, abyssIndex2, WorldGen.genRand.Next(PlantPiles)); + WorldGen.PlaceObject(X, Y, WorldGen.genRand.Next(PlantPiles)); } //gravel rock piles @@ -672,7 +688,7 @@ namespace CalamityMod.World ushort[] GravelPiles = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - WorldGen.PlaceObject(abyssIndex, abyssIndex2, WorldGen.genRand.Next(GravelPiles)); + WorldGen.PlaceObject(X, Y, WorldGen.genRand.Next(GravelPiles)); } //abyss gravel vents @@ -681,7 +697,7 @@ namespace CalamityMod.World ushort[] Vents = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - WorldGen.PlaceObject(abyssIndex, abyssIndex2, WorldGen.genRand.Next(Vents)); + WorldGen.PlaceObject(X, Y, WorldGen.genRand.Next(Vents)); } //pirate crates @@ -690,7 +706,7 @@ namespace CalamityMod.World ushort[] PirateCrate = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - WorldGen.PlaceObject(abyssIndex, abyssIndex2, WorldGen.genRand.Next(PirateCrate)); + WorldGen.PlaceObject(X, Y, WorldGen.genRand.Next(PirateCrate)); } } @@ -704,7 +720,7 @@ namespace CalamityMod.World (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - WorldGen.PlaceObject(abyssIndex, abyssIndex2, WorldGen.genRand.Next(SpiderCorals)); + WorldGen.PlaceObject(X, Y, WorldGen.genRand.Next(SpiderCorals)); } //thermal vent @@ -713,7 +729,7 @@ namespace CalamityMod.World ushort[] Vents = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - WorldGen.PlaceObject(abyssIndex, abyssIndex2, WorldGen.genRand.Next(Vents)); + WorldGen.PlaceObject(X, Y, WorldGen.genRand.Next(Vents)); } } @@ -726,57 +742,57 @@ namespace CalamityMod.World ushort[] BulbTrees = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - WorldGen.PlaceObject(abyssIndex, abyssIndex2, WorldGen.genRand.Next(BulbTrees)); + WorldGen.PlaceObject(X, Y, WorldGen.genRand.Next(BulbTrees)); } } } //pots - if ((tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType() || - tile.TileType == ModContent.TileType()) && abyssIndex2 > (Main.remixWorld ? rockLayer - (int)((y - 200) * 0.8f) : rockLayer)) + if ((tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType() || + tile.TileType == ModContent.TileType()) && Y > (Main.remixWorld ? rockLayer - (int)((y - 200) * 0.8f) : rockLayer)) { if (WorldGen.genRand.NextBool(5)) { - WorldGen.PlacePot(abyssIndex, abyssIndex2, (ushort)ModContent.TileType()); - CalamityUtils.SafeSquareTileFrame(abyssIndex, abyssIndex2, true); + WorldGen.PlacePot(X, Y, (ushort)ModContent.TileType()); + CalamityUtils.SafeSquareTileFrame(X, Y, true); } } //sulphur pots - else if (tile.TileType == ModContent.TileType() && abyssIndex2 < (Main.remixWorld ? Main.UnderworldLayer : (int)Main.worldSurface)) + else if (tile.TileType == ModContent.TileType() && Y < (Main.remixWorld ? Main.UnderworldLayer : (int)Main.worldSurface)) { if (WorldGen.genRand.NextBool(3)) { - WorldGen.PlacePot(abyssIndex, abyssIndex2, (ushort)ModContent.TileType()); - CalamityUtils.SafeSquareTileFrame(abyssIndex, abyssIndex2, true); + WorldGen.PlacePot(X, Y, (ushort)ModContent.TileType()); + CalamityUtils.SafeSquareTileFrame(X, Y, true); } } } //esentially what this does is grow one vine on the bottom of a tile, then use the util to keep placing the vine until it decides to stop - if (tileToGrowVineOn.TileType == ModContent.TileType() && !Main.tile[abyssIndex, abyssIndex2 + 1].HasTile) + if (tileToGrowVineOn.TileType == ModContent.TileType() && Main.tile[X, Y].Slope == 0 && !Main.tile[X, Y + 1].HasTile) { if (WorldGen.genRand.NextBool(2)) { - WorldGen.PlaceTile(abyssIndex, abyssIndex2 + 1, (ushort)ModContent.TileType()); + WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); } } if (tileToGrowVineOn.TileType == ModContent.TileType()) { - CalamityUtils.GrowVines(abyssIndex, abyssIndex2, WorldGen.genRand.Next(1, 4), (ushort)ModContent.TileType()); + CalamityUtils.GrowVines(X, Y, WorldGen.genRand.Next(1, 4), (ushort)ModContent.TileType()); } //same as above but for sulphur vines - if (tileToGrowVineOn.TileType == ModContent.TileType() && !Main.tile[abyssIndex, abyssIndex2 + 1].HasTile) + if (tileToGrowVineOn.TileType == ModContent.TileType() && Main.tile[X, Y].Slope == 0 && !Main.tile[X, Y + 1].HasTile) { if (WorldGen.genRand.NextBool(5)) { - WorldGen.PlaceTile(abyssIndex, abyssIndex2 + 1, (ushort)ModContent.TileType()); + WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); } } if (tileToGrowVineOn.TileType == ModContent.TileType()) { - CalamityUtils.GrowVines(abyssIndex, abyssIndex2, WorldGen.genRand.Next(1, 4), (ushort)ModContent.TileType()); + CalamityUtils.GrowVines(X, Y, WorldGen.genRand.Next(1, 4), (ushort)ModContent.TileType()); } } } @@ -1192,5 +1208,73 @@ namespace CalamityMod.World UnlockChests = false; } + + //method to clean up small clumps of tiles + public static void AbyssCleanup() + { + List blockTileTypes = new() + { + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + }; + + void getAttachedPoints(int x, int y, List points) + { + Tile t = CalamityUtils.ParanoidTileRetrieval(x, y); + Point p = new(x, y); + + if (!blockTileTypes.Contains(t.TileType) || !t.HasTile || points.Count > 75 || points.Contains(p)) + { + return; + } + + points.Add(p); + + getAttachedPoints(x + 1, y, points); + getAttachedPoints(x - 1, y, points); + getAttachedPoints(x, y + 1, points); + getAttachedPoints(x, y - 1, points); + } + + for (int x = 20; x < Main.maxTilesX - 20; x++) + { + for (int y = 20; y < Main.maxTilesY - 20; y++) + { + List chunkPoints = new(); + getAttachedPoints(x, y, chunkPoints); + + int cutoffLimit = 75; + if (chunkPoints.Count >= 1 && chunkPoints.Count < cutoffLimit) + { + foreach (Point p in chunkPoints) + { + WorldUtils.Gen(p, new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(true), + new Actions.SetLiquid() + })); + } + } + + Tile tile = Main.tile[x, y]; + + if (blockTileTypes.Contains(tile.TileType)) + { + //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + bool OnlyRight = !Main.tile[x, y - 1].HasTile && !Main.tile[x, y + 1].HasTile && !Main.tile[x - 1, y].HasTile; + bool OnlyLeft = !Main.tile[x, y - 1].HasTile && !Main.tile[x, y + 1].HasTile && !Main.tile[x + 1, y].HasTile; + bool OnlyDown = !Main.tile[x, y - 1].HasTile && !Main.tile[x - 1, y].HasTile && !Main.tile[x + 1, y].HasTile; + bool OnlyUp = !Main.tile[x, y + 1].HasTile && !Main.tile[x - 1, y].HasTile && !Main.tile[x + 1, y].HasTile; + + if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) + { + WorldGen.KillTile(x, y); + } + } + } + } + } } } diff --git a/World/DraedonStructures.cs b/World/DraedonStructures.cs index f26257c70e..c6c1f1601c 100644 --- a/World/DraedonStructures.cs +++ b/World/DraedonStructures.cs @@ -325,61 +325,35 @@ namespace CalamityMod.World public static void PlaceSunkenSeaLab(out Point placementPoint, List workshopPoints, StructureMap structures) { - int tries = 0; string mapKey = SunkenSeaLabKey; PilePlacementMaps.TryGetValue(mapKey, out PilePlacementFunction pilePlacementFunction); SchematicMetaTile[,] schematic = TileMaps[mapKey]; int labWidth = schematic.GetLength(0); int labHeight = schematic.GetLength(1); - do - { - // Pick a location based on the Underground Desert, because the Sunken Sea is based on the Underground Desert - Rectangle ugDesert = GenVars.UndergroundDesertLocation; - int placementPositionX = -1; + int sunkenSeaX = (GenVars.UndergroundDesertLocation.Left + GenVars.UndergroundDesertLocation.Right) / 2; + int sunkenSeaY = Main.maxTilesY / 2; - // Desperation generation: if 75% of attempts failed, start generating literally anywhere in the Sunken Sea - if (tries >= 1500) - placementPositionX = WorldGen.genRand.Next(ugDesert.Left, ugDesert.Right - labWidth); - // 50% chance to be on either the left or the right. - // If it's on the right then shove it left because all schematics are placed based on their top left corner. - else if (WorldGen.genRand.NextBool()) - placementPositionX = WorldGen.genRand.Next(ugDesert.Left - 20, ugDesert.Left + 10); - else - placementPositionX = WorldGen.genRand.Next(ugDesert.Right - 10, ugDesert.Right + 20) - labWidth; + int placementPositionX = sunkenSeaX < Main.maxTilesX / 2 ? sunkenSeaX - 120 : sunkenSeaX + 120; + int placementPositionY = (sunkenSeaY + (Main.maxTilesY / 4) - 25) - labHeight; - int sunkenSeaY = 0; + placementPoint = new Point(placementPositionX, placementPositionY); + Vector2 schematicSize = new Vector2(schematic.GetLength(0), schematic.GetLength(1)); - //copied the desert position code from the sunken sea's generation so the lab always generates within the sunken sea properly - for (int y = Main.UnderworldLayer; y >= Main.worldSurface; y--) - { - if (Main.tile[placementPositionX, y].WallType == ModContent.WallType() || - Main.tile[placementPositionX, y].WallType == ModContent.WallType()) - { - sunkenSeaY = y - 80; //offset so it generates nicely - break; - } - } + /* + I do not think that this check needs to exist for now, no other structures exist in the sunken sea at the moment + Once other sunken sea structures are added, i will likely re-enable this and modify the generation so that it avoids protected areas again + This is just so i can have it generating in time for the patreon beta + */ - int placementPositionY = sunkenSeaY - labHeight; - - placementPoint = new Point(placementPositionX, placementPositionY); - Vector2 schematicSize = new Vector2(schematic.GetLength(0), schematic.GetLength(1)); - - if (structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y))) - { - bool hasPlacedLogAndSchematic = false; - PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref hasPlacedLogAndSchematic, new Action(FillSunkenSeaLaboratoryChest)); - CalamityUtils.AddProtectedStructure(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y), 20); - //Reverted changes to center point placement; the change caused it to not center like it should, offsetting the range at which the bio lab theme plays - CalamityWorld.SunkenSeaLabCenter = placementPoint.ToWorldCoordinates() + new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)) * 8f; - break; - } - //try again if the structure is colliding with a structure from another mod - else - tries++; - } - while (tries <= 2000); + //if (structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y))) + //{ + bool hasPlacedLogAndSchematic = false; + PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref hasPlacedLogAndSchematic, new Action(FillSunkenSeaLaboratoryChest)); + CalamityUtils.AddProtectedStructure(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y), 20); + //Reverted changes to center point placement; the change caused it to not center like it should, offsetting the range at which the bio lab theme plays + CalamityWorld.SunkenSeaLabCenter = placementPoint.ToWorldCoordinates() + new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)) * 8f; + //} } #endregion diff --git a/World/Minibiomes/FloralParadiseMinibiome.cs b/World/Minibiomes/FloralParadiseMinibiome.cs new file mode 100644 index 0000000000..511652ec56 --- /dev/null +++ b/World/Minibiomes/FloralParadiseMinibiome.cs @@ -0,0 +1,535 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Tiles.DraedonStructures; +using CalamityMod.Tiles.FloralParadise; +using CalamityMod.Tiles.SunkenSea; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using Terraria.Utilities; +using Terraria.WorldBuilding; + +namespace CalamityMod.World.Minibiomes +{ + public class FloralParadiseMinibiome + { + // 02JUN2024: Ozzatron: Disable generation of the Floral Paradise biome on the assumption that it will break horribly until tested. + internal static readonly bool SHOULD_GENERATE = false; + + // Constants pertaining to the more important details of the world-gen, to allow for ease-of-change. + // Certain numbers are hardcoded and not present here, but they tend to be in regards to things that either really shouldn't need changing or + // are extremely subtle details. + public const int TotalCavesInMediumWorld = 3; + + public const int MaxHorizontalDistanceFromWorldCenter = 1250; + + public const int MinSurfaceDepth = 250; + + public const int MaxSurfaceDepth = 420; + + public const int BlacklistedTileCheckArea = 50; + + public const float CaveOpennessFactor = 0.08f; + + public const float WallOpennessFactor = 0.135f; + + public const int TotalSecondaryDirtCreationPasses = 1; + + public const float SecondaryPassDirtCreationChance = 0.5f; + + public const int MinVigorousVineLength = 6; + + public const int MaxVigorousVineLength = 16; + + public const int MinSmallVineLength = 9; + + public const int MaxSmallVineLength = 17; + + public const int MinSmallVineCount = 45; + + public const int MaxSmallVineCount = 64; + + public const int MinPondWaterTileCount = 180; + + public const int MaxPondWaterTileCount = 210; + + public static int[] BlacklistedNearbyTiles => new int[] + { + TileID.Sand, + TileID.Sandstone, + TileID.HardenedSand, + TileID.DesertFossil, + TileID.SnowBlock, + TileID.IceBlock, + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + ModContent.TileType(), + }; + + public static void GenerateInstances() + { + float worldSize = Main.maxTilesX / 4200f; + int totalCaves = (int)(worldSize * TotalCavesInMediumWorld); + int infiniteLoopPreventerIncrement = 0; + List existingCaveAreas = new List(); + for (int i = 0; i < totalCaves - 1; i++) + { + // Use an emergency infinite loop increment. + // The placement loop is left if it exceeds an extremely large quantity. + // This exists primarily due to potential issues in small worlds. + // This will likely never be hit in typical circumstances, but it's better to be safe than sorry. + infiniteLoopPreventerIncrement++; + if (infiniteLoopPreventerIncrement >= 3000) + break; + + int x = Main.maxTilesX / 2 + WorldGen.genRand.Next(-MaxHorizontalDistanceFromWorldCenter, MaxHorizontalDistanceFromWorldCenter); + int y = (int)Main.worldSurface + WorldGen.genRand.Next(MinSurfaceDepth, MaxSurfaceDepth); + int width = (int)(WorldGen.genRand.Next(127, 140) * worldSize); + int height = (int)(WorldGen.genRand.Next(80, 104) * worldSize); + Rectangle caveArea = Utils.CenteredRectangle(new Vector2(x, y), new Vector2(width, height)); + + // Try again if this selected location is near blacklisted tiles. + // This is done to prevent logical consistencies/intrusion on unrelated biomes. + bool needsToTryAgain = false; + for (int dx = -BlacklistedTileCheckArea; dx < BlacklistedTileCheckArea; dx++) + { + for (int dy = -BlacklistedTileCheckArea; dy < BlacklistedTileCheckArea; dy++) + { + if (!needsToTryAgain) + { + Tile tile = CalamityUtils.ParanoidTileRetrieval(x + dx, y + dy); + needsToTryAgain = tile.HasTile && BlacklistedNearbyTiles.Contains(tile.TileType); + } + else + break; + } + } + + // If the blacklisted tile check was passed, check to see if the potential spot is near. + if (!needsToTryAgain) + needsToTryAgain = existingCaveAreas.Any(c => caveArea.Intersects(c)); + + if (needsToTryAgain) + { + i--; + continue; + } + + Place(caveArea); + existingCaveAreas.Add(caveArea); + } + + // Generate a single, special living tree on the surface with a floral paradise biome underneath. + for (int i = 0; i < 2000; i++) + { + int x = Main.maxTilesX / 2 + WorldGen.genRand.Next(330, MaxHorizontalDistanceFromWorldCenter) * WorldGen.genRand.NextBool().ToDirectionInt(); + int y = (int)Main.worldSurface - 120; + if (!FloralParadiseTree.Create(new(x, y))) + continue; + break; + } + } + + public static void Place(Rectangle placementArea) + { + int seed = WorldGen.genRand.Next(); + int pondCount = WorldGen.genRand.Next(3); + int smallVineCount = WorldGen.genRand.Next(MinSmallVineCount, MaxSmallVineCount); + int waterTileCount = WorldGen.genRand.Next(MinPondWaterTileCount, MaxPondWaterTileCount); + int smallFlowerCount = WorldGen.genRand.Next(150, 200); + int bigTreeCount = WorldGen.genRand.Next(2, 5); + + CutOutCave(placementArea, seed, out bool[,] grassDirtMap); + GenerateDirtBehindGrass(placementArea, grassDirtMap); + GenerateWalls(placementArea, unchecked(seed - 8)); + GenerateVines(placementArea, smallVineCount); + GeneratePonds(placementArea, waterTileCount, pondCount); + CreateScenicPlants(placementArea, smallFlowerCount); + CreateTrees(placementArea, bigTreeCount); + + // Place a blood orange. THIS IS FOR TESTING PURPOSES. + for (int i = 0; i < 1; i++) + { + int x = placementArea.X + WorldGen.genRand.Next(24, placementArea.Width - 24); + int y = placementArea.Y + WorldGen.genRand.Next(18, placementArea.Height - 18); + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + if (!WorldGen.SolidTile(x, y + 1) || !WorldGen.SolidTile(x + 1, y + 1) || tile.HasTile || tile.LiquidAmount > 0) + { + i--; + continue; + } + x--; + + for (int dx = 0; dx < 3; dx++) + { + for (int dy = 0; dy < 3; dy++) + { + Main.tile[x + dx, y + dy].TileType = (ushort)ModContent.TileType(); + Main.tile[x + dx, y + dy].TileFrameX = (short)(dx * 18); + Main.tile[x + dx, y + dy].TileFrameY = (short)(dy * 18); + Main.tile[x + dx, y + dy].Get().HasTile = true; + } + } + } + } + + public static void CutOutCave(Rectangle placementArea, int seed, out bool[,] grassDirtMap) + { + // Calculate the initial cell states with perlin noise. + // To be specific, it uses values near the midpoint of 0.5 as open caves. + // This helps solve the problem of having disconnected areas that using min/max threshold values causes. + bool[,] caveState = new bool[placementArea.Width, placementArea.Height]; + for (int i = 0; i < placementArea.Width; i++) + { + for (int j = 0; j < placementArea.Height; j++) + { + float noise = CalamityUtils.PerlinNoise2D(i / 240f, j / 180f, 3, seed) * 0.5f + 0.5f; + caveState[i, j] = MathHelper.Distance(noise, 0.56f) < CaveOpennessFactor; + if (WorldGen.genRand.NextBool(3)) + caveState[i, j] = WorldGen.genRand.NextBool(); + } + } + + // Repeatedly smoothen out the cave state with celluar automata. + for (int i = 0; i < 8; i++) + caveState = CalamityUtils.SimulateCelluarAutomata(caveState); + + // Reset tile states based on the above results. + ushort grassID = (ushort)ModContent.TileType(); + ushort stoneID = (ushort)ModContent.TileType(); + grassDirtMap = new bool[placementArea.Width, placementArea.Height]; + for (int x = placementArea.X; x < placementArea.X + placementArea.Width; x++) + { + for (int y = placementArea.Y; y < placementArea.Y + placementArea.Height; y++) + { + // Don't attempt to change tile data if a tile is outside of the world for some reason. + if (!WorldGen.InWorld(x, y, 1)) + continue; + + int arrayRelativeX = x - placementArea.X; + int arrayRelativeY = y - placementArea.Y; + Vector2 normalizedPosition = new Vector2(arrayRelativeX / (float)placementArea.Width, arrayRelativeY / (float)placementArea.Height); + float distanceFromCenter = Vector2.Distance(normalizedPosition, Vector2.One * 0.5f) * 1.75f; + if (distanceFromCenter > 1f) + distanceFromCenter = 1f; + + float ditherChance = Utils.GetLerpValue(0.97f, 0.72f, distanceFromCenter, true); + + Main.tile[x, y].WallType = WallID.None; + if (WorldGen.genRand.NextFloat() < ditherChance) + { + if (!caveState[arrayRelativeX, arrayRelativeY] && distanceFromCenter < 0.7f) + Main.tile[x, y].ClearEverything(); + else + { + bool useGrass = CalamityUtils.CountCellsAtPosition(caveState, arrayRelativeX, arrayRelativeY, false) >= 1 && distanceFromCenter < 0.72f; + grassDirtMap[arrayRelativeX, arrayRelativeY] = useGrass; + Main.tile[x, y].ClearEverything(); + Main.tile[x, y].ResetToType(useGrass ? grassID : stoneID); + WorldGen.SquareTileFrame(x, y); + } + } + } + } + } + + public static void GenerateDirtBehindGrass(Rectangle placementArea, bool[,] grassDirtMap) + { + ushort dirtID = (ushort)ModContent.TileType(); + ushort stoneID = (ushort)ModContent.TileType(); + ushort grassID = (ushort)ModContent.TileType(); + + // Perform secondary passes that overlay dirt behind grass. + for (int i = 0; i < TotalSecondaryDirtCreationPasses + 1; i++) + { + for (int x = placementArea.X; x < placementArea.X + placementArea.Width; x++) + { + for (int y = placementArea.Y; y < placementArea.Y + placementArea.Height; y++) + { + int arrayRelativeX = x - placementArea.X; + int arrayRelativeY = y - placementArea.Y; + bool nearbyGrassOrDirt = false; + if (arrayRelativeX - 1 >= 0 && grassDirtMap[arrayRelativeX - 1, arrayRelativeY]) + nearbyGrassOrDirt = true; + else if (arrayRelativeX + 1 < placementArea.Width && grassDirtMap[arrayRelativeX + 1, arrayRelativeY]) + nearbyGrassOrDirt = true; + else if (arrayRelativeY - 1 >= 0 && grassDirtMap[arrayRelativeX, arrayRelativeY - 1]) + nearbyGrassOrDirt = true; + else if (arrayRelativeY + 1 < placementArea.Height && grassDirtMap[arrayRelativeX, arrayRelativeY + 1]) + nearbyGrassOrDirt = true; + + // The first pass always generates dirt behind grass. + // However, successive passes only generate dirt with a specific probability. + // This makes the dirt feel more natural and connected to the underlying rock. + bool canPerformPlacement = i == 0 || WorldGen.genRand.NextFloat() < SecondaryPassDirtCreationChance; + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + if (canPerformPlacement && tile.HasTile && tile.TileType == stoneID && nearbyGrassOrDirt) + Main.tile[x, y].TileType = dirtID; + } + } + + // Reset the dirt/grass map for the next pass. + // This is skipped on the last pass for performance reasons, since the map won't be used after that point. + if (i >= TotalSecondaryDirtCreationPasses) + continue; + + for (int x = placementArea.X; x < placementArea.X + placementArea.Width; x++) + { + for (int y = placementArea.Y; y < placementArea.Y + placementArea.Height; y++) + { + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + int arrayRelativeX = x - placementArea.X; + int arrayRelativeY = y - placementArea.Y; + grassDirtMap[arrayRelativeX, arrayRelativeY] = tile.TileType == grassID || tile.TileType == dirtID; + } + } + } + } + + public static void GenerateWalls(Rectangle placementArea, int seed) + { + for (int x = placementArea.X; x < placementArea.X + placementArea.Width; x++) + { + for (int y = placementArea.Y; y < placementArea.Y + placementArea.Height; y++) + { + float noise = CalamityUtils.PerlinNoise2D(x / 160f, y / 160f, 3, seed) * 0.5f + 0.5f; + if (MathHelper.Distance(noise, 0.555f) < WallOpennessFactor) + Main.tile[x, y].WallType = WorldGen.genRand.NextBool(4) ? WallID.GrassUnsafe : WallID.FlowerUnsafe; + } + } + } + + public static void GenerateVines(Rectangle placementArea, int smallVineCount) + { + ushort[] vineIDs = new ushort[] + { + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + }; + + // Place small vines. + for (int i = 0; i < smallVineCount; i++) + { + int x = placementArea.X + WorldGen.genRand.Next(24, placementArea.Width - 24); + int y = placementArea.Y + WorldGen.genRand.Next(18, placementArea.Height - 18); + + // Ensure that the initial tile is empty and that there's a solid tile above for the vine to hang from. + // If these conditions are not met, try again. + if (CalamityUtils.ParanoidTileRetrieval(x, y).HasTile || !WorldGen.SolidTile(x, y - 1)) + { + i--; + continue; + } + + // Search to ensure that nothing is in the way of the vine's potential positions. + // If something is, try again. + int vineLength = WorldGen.genRand.Next(MinSmallVineLength, MaxSmallVineLength + 1); + bool neeedsToTryAgain = false; + for (int dy = 0; dy < vineLength; dy++) + { + if (CalamityUtils.ParanoidTileRetrieval(x, y + dy).HasTile) + { + neeedsToTryAgain = true; + break; + } + } + + if (neeedsToTryAgain) + { + i--; + continue; + } + + // Perform placement. + ushort vineID = WorldGen.genRand.Next(vineIDs); + for (int dy = 0; dy < vineLength; dy++) + { + Main.tile[x, y + dy].TileType = vineID; + if (dy == vineLength - 1) + { + Main.tile[x, y + dy].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); + Main.tile[x, y + dy].TileFrameY = 54; + } + else + { + Main.tile[x, y + dy].TileFrameX = (short)(WorldGen.genRand.Next(3) * 18); + Main.tile[x, y + dy].TileFrameY = (short)(WorldGen.genRand.Next(3) * 18); + } + Main.tile[x, y + dy].Get().HasTile = true; + WorldGen.SquareTileFrame(x, y, true); + } + } + } + + public static void GeneratePonds(Rectangle placementArea, int waterTileCount, int pondCount) + { + for (int i = 0; i < pondCount; i++) + { + int x = placementArea.X + WorldGen.genRand.Next(24, placementArea.Width - 24); + int y = placementArea.Y + WorldGen.genRand.Next(24, placementArea.Height - 24); + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + if (tile.HasTile || tile.LiquidAmount > 0) + { + i--; + continue; + } + + // Go upward once an open area is found. This is where water will be created. + Point waterSpawnPoint = new Point(x, y); + for (int dy = 0; dy < 100; dy++) + { + if (CalamityUtils.ParanoidTileRetrieval(x, y - dy).HasTile) + { + waterSpawnPoint.Y -= dy - 1; + break; + } + } + + // Create a predetermined quantity of water via recursion. + // This starts at the initial water spawn point and the expands outward in all four cardinal directions repeatedly until either no more locations + // are valid or the water limit has been reached. + int increment = 0; + RecursivelyFillAreaWithWater(x, y, waterTileCount, ref increment); + + // Settle water and create waterfalls. + Liquid.QuickWater(3); + WorldGen.WaterCheck(); + Liquid.quickSettle = true; + Liquid.UpdateLiquid(); + WorldGen.WaterCheck(); + Liquid.quickSettle = false; + + for (int dy = 0; dy < 50; dy++) + { + if (CalamityUtils.ParanoidTileRetrieval(x, y + dy).LiquidAmount > 0) + { + Main.tile[x, y + dy - 8].Get().HasTile = true; + Main.tile[x, y + dy - 8].TileType = (ushort)ModContent.TileType(); + break; + } + } + } + } + + public static void CreateScenicPlants(Rectangle placementArea, int smallFlowerCount) + { + for (int i = 0; i < smallFlowerCount; i++) + { + int x = placementArea.X + WorldGen.genRand.Next(16, placementArea.Width - 16); + int y = placementArea.Y + WorldGen.genRand.Next(12, placementArea.Height - 12); + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + if (tile.HasTile || tile.LiquidAmount > 0 || !WorldGen.SolidTile(x, y + 1)) + { + i--; + continue; + } + + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + Main.tile[x, y].TileFrameX = (short)(WorldGen.genRand.Next(8) * 18); + Main.tile[x, y].TileFrameY = 0; + Main.tile[x, y].Get().HasTile = true; + } + + // TODO -- Move this to another method. + int tries = 0; + WeightedRandom tileSelector = new(WorldGen.genRand); + tileSelector.Add(ModContent.TileType(), 0.66D); + tileSelector.Add(ModContent.TileType(), 0.66D); + tileSelector.Add(ModContent.TileType(), 0.66D); + tileSelector.Add(ModContent.TileType(), 0.66D); + tileSelector.Add(ModContent.TileType(), 0.66D); + tileSelector.Add(ModContent.TileType(), 1D); + tileSelector.Add(ModContent.TileType(), 1D); + tileSelector.Add(ModContent.TileType(), 1D); + tileSelector.Add(ModContent.TileType(), 1D); + tileSelector.Add(ModContent.TileType(), 0.5D); + tileSelector.Add(ModContent.TileType(), 1D); + tileSelector.Add(ModContent.TileType(), 1D); + tileSelector.Add(ModContent.TileType(), 1D); + tileSelector.Add(ModContent.TileType(), 1D); + tileSelector.Add(ModContent.TileType(), 1D); + tileSelector.Add(ModContent.TileType(), 1D); + tileSelector.Add(ModContent.TileType(), 1D); + + for (int i = 0; i < 2400; i++) + { + tries++; + if (tries >= 16000) + break; + + int x = placementArea.X + WorldGen.genRand.Next(16, placementArea.Width - 16); + int y = placementArea.Y + WorldGen.genRand.Next(12, placementArea.Height - 12); + if (WorldGen.genRand.NextBool() && WorldUtils.Find(new(x, y), Searches.Chain(new Searches.Down(400), new Conditions.IsSolid()), out Point result)) + y = result.Y - 1; + + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + if (tile.HasTile || tile.LiquidAmount > 0) + { + i--; + continue; + } + + int tileID = tileSelector.Get(); + WorldGen.PlaceTile(x, y, tileID, style: WorldGen.genRand.Next(TileObjectData.GetTileData(tileID, 0).RandomStyleRange)); + } + } + + public static void CreateTrees(Rectangle placementArea, int treeCount) + { + int tries = 0; + int treeID = ModContent.TileType(); + + for (int i = 0; i < treeCount; i++) + { + tries++; + + int x = placementArea.X + WorldGen.genRand.Next(16, placementArea.Width - 16); + int y = placementArea.Y + WorldGen.genRand.Next(12, placementArea.Height - 12); + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + Vector2 checkTopLeft = new Vector2(x, y).ToWorldCoordinates() - new Vector2(120f, 300f); + Vector2 checkArea = new Vector2(240f, 200f); + + if (tries >= 2500) + break; + + if (tile.HasTile || tile.LiquidAmount > 0 || !WorldGen.SolidTile(x, y + 1) || + !TileObject.CanPlace(x, y, treeID, 0, 0, out _, true, checkStay: true) || + Collision.SolidCollision(checkTopLeft, (int)checkArea.X, (int)checkArea.Y)) + { + i--; + continue; + } + + WorldGen.PlaceTile(x, y, treeID); + } + } + + #region Biome-Specific Utilities + + public static void RecursivelyFillAreaWithWater(int x, int y, int limit, ref int increment) + { + Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); + if (tile.HasTile || tile.LiquidAmount > 127) + return; + + increment++; + if (increment >= limit) + return; + + Main.tile[x, y].LiquidAmount = 255; + RecursivelyFillAreaWithWater(x + 1, y, limit, ref increment); + RecursivelyFillAreaWithWater(x - 1, y, limit, ref increment); + RecursivelyFillAreaWithWater(x, y + 1, limit, ref increment); + RecursivelyFillAreaWithWater(x, y - 1, limit, ref increment); + } + + #endregion Biome-Specific Utilities + } +} diff --git a/World/Minibiomes/FloralParadiseTree.cs b/World/Minibiomes/FloralParadiseTree.cs new file mode 100644 index 0000000000..4858ac842a --- /dev/null +++ b/World/Minibiomes/FloralParadiseTree.cs @@ -0,0 +1,139 @@ +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.GameContent.Generation; +using Terraria.ID; +using Terraria.WorldBuilding; + +namespace CalamityMod.World.Minibiomes +{ + public class FloralParadiseTree + { + public const int TrunkHeight = 220; + + public const int TrunkWidth = 10; + + public const int TrunkHollowSpace = 4; + + public const int RootCount = 5; + + public static bool Create(Point placementPosition) + { + float worldSize = Main.maxTilesX / 4200f; + if (!WorldUtils.Find(new Point(placementPosition.X - 3, placementPosition.Y), Searches.Chain(new Searches.Down(400), new GenCondition[] + { + new Conditions.IsSolid().AreaAnd(6, 1) + }), out Point ground)) + { + return false; + } + + ground.Y += (int)(TrunkHeight * 0.645f); + + // Get all tiles in a specific area. + Dictionary tileCounts = new Dictionary(); + WorldUtils.Gen(new Point(ground.X - TrunkHeight / 2, ground.Y - TrunkHeight / 2), new Shapes.Rectangle(TrunkHeight, TrunkHeight), new Actions.TileScanner(new ushort[] + { + TileID.Dirt, + TileID.Stone, + TileID.Mud, + TileID.JungleGrass, + TileID.SnowBlock, + TileID.Sand, + }).Output(tileCounts)); + + int overworldTileCount = tileCounts[TileID.Dirt] + tileCounts[TileID.Stone]; + int jungleTileCount = tileCounts[TileID.Mud] + tileCounts[TileID.JungleGrass]; + + // Avoid jungles, deserts, and snow biomes. + if (tileCounts[TileID.SnowBlock] > jungleTileCount || jungleTileCount > overworldTileCount || overworldTileCount < 50 || tileCounts[TileID.Sand] >= 50) + return false; + + float trunkRotation = WorldGen.genRand.NextFloatDirection() * 0.116f; + for (int i = 0; i < TrunkHeight; i += 2) + { + Point currentPoint = (ground.ToVector2() - Vector2.UnitY.RotatedBy(trunkRotation) * i).ToPoint(); + + // Create the trunk. + WorldUtils.Gen(currentPoint, new Shapes.Rectangle(TrunkWidth, TrunkWidth), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(), + new Actions.PlaceWall(WallID.LivingWood, true), + new Actions.PlaceTile(TileID.LivingMahogany) + })); + } + + // Generate roots. + for (int i = 0; i < RootCount; i++) + { + int rootLength = (int)(TrunkHeight * WorldGen.genRand.NextFloat(0.425f, 0.7f)); + float rootAngle = MathHelper.Lerp(-0.89f, 0.89f, i / (float)(RootCount - 1f)) + WorldGen.genRand.NextFloatDirection() * 0.074f + trunkRotation + MathHelper.PiOver2; + WorldUtils.Gen(ground, new ShapeRoot(rootAngle, rootLength, TrunkWidth - 1), Actions.Chain(new GenAction[] + { + new Actions.SetTile(TileID.LivingMahogany), + })); + } + + List branchEnds = new(); + Point topOfTrunk = (ground.ToVector2() - Vector2.UnitY.RotatedBy(trunkRotation) * (TrunkHeight - 4f)).ToPoint(); + + // Create side branches. + for (int i = 0; i < RootCount - 1; i++) + { + int branchLength = WorldGen.genRand.Next(26, 49); + float branchDirectionX = -WorldGen.genRand.NextFloat(1.25f, 4.5f) * WorldGen.genRand.NextBool().ToDirectionInt(); + float branchDirectionY = -2f; + Vector2 branchDirection = new Vector2(branchDirectionX, branchDirectionY).SafeNormalize(Vector2.UnitX); + Point branchStart = (ground.ToVector2() - Vector2.UnitY.RotatedBy(trunkRotation) * Main.rand.NextFloat(0.45f, 0.84f) * TrunkHeight).ToPoint(); + WorldUtils.Gen(branchStart, new ShapeBranch(branchDirection.ToRotation(), branchLength).OutputEndpoints(branchEnds), Actions.Chain(new GenAction[] + { + new Actions.SetTile(TileID.LivingMahogany), + })); + } + + // Create branch leaves. + using (List.Enumerator enumerator = branchEnds.GetEnumerator()) + { + while (enumerator.MoveNext()) + { + WorldUtils.Gen(enumerator.Current, new Shapes.Circle(4), Actions.Chain(new GenAction[] + { + new Modifiers.Blotches(4, 2, 0.3), + new Actions.SetTile(TileID.LivingMahoganyLeaves), + new Actions.SetFrames(true) + })); + } + } + + // Create leaves at the top of the trunk. + WorldUtils.Gen(topOfTrunk, new Shapes.Circle(TrunkWidth * 2), Actions.Chain(new GenAction[] + { + new Modifiers.Blotches(3, 2, 0.1), + new Actions.SetTile(TileID.LivingMahoganyLeaves), + new Actions.SetFrames(true) + })); + + // Generate a cave in the roots of the biome. + int width = (int)(WorldGen.genRand.Next(104, 120) * worldSize); + int height = (int)(WorldGen.genRand.Next(88, 110) * worldSize); + Vector2 cavePosition = ground.ToVector2() + Vector2.UnitY * height * 0.44f; + Rectangle caveArea = Utils.CenteredRectangle(cavePosition, new Vector2(width, height)); + FloralParadiseMinibiome.Place(caveArea); + + // Clear out the inner part of the tiles to create an open space in the tree. + for (int i = 0; i < TrunkHeight * 0.9f; i += 2) + { + Point currentPoint = (ground.ToVector2() - Vector2.UnitY.RotatedBy(trunkRotation) * i).ToPoint(); + Point center = (currentPoint.ToVector2() + Vector2.One * TrunkHollowSpace - Vector2.UnitX * 2f).ToPoint(); + WorldUtils.Gen(center, new Shapes.Rectangle(TrunkHollowSpace, TrunkHollowSpace), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(true), + new Actions.PlaceWall(WallID.LivingWood, true) + })); + } + + return true; + } + } +} diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index f020932486..361adf0026 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -211,9 +211,10 @@ namespace CalamityMod.World public static void SulphurSeaGenerationAfterAbyss() { - CreateBeachNearSea(); + CreateBeach(); ClearOutStrayTiles(); ClearAloneTiles(); + //PlaceSulphurReef(); var scrapPilePositions = PlaceScrapPiles(); GenerateColumnsInCaverns(); GenerateHardenedSandstone(); @@ -670,7 +671,149 @@ namespace CalamityMod.World } } - public static void CreateBeachNearSea() + /* + public static void PlaceSulphurReef() + { + int beachWidth = WorldGen.genRand.Next(150, 190 + 1); + int x = GetActualX(BiomeWidth - 10); + float xRatio = Utils.GetLerpValue(BiomeWidth - 10, BiomeWidth + beachWidth, x, true); + int depth = (int)(Math.Sin((1f - xRatio) * MathHelper.PiOver2) * BeachMaxDepth + 1f); + + int cavePerlinSeed = WorldGen.genRand.Next(); + int cavePerlinSeedWalls = WorldGen.genRand.Next(); + + Point origin = new Point(x + (x < Main.maxTilesX / 2 ? -35 : 35), YStart + depth + 80); + Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); + + float angle = MathHelper.Pi * 0.15f; + float otherAngle = MathHelper.PiOver2 - angle; + + int size = 80 + (Main.maxTilesX / 180); + float actualSize = size * 16f; + float constant = actualSize * 2f / (float)Math.Sin(angle); + + float fociSpacing = actualSize * (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; + + //first, place a basalt barrier around where the biome will be + for (int X = origin.X - size - 3; X <= origin.X + size + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckReefsCircle(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist)) + { + float percent = dist / constant; + float blurPercent = 0.98f; + + if (percent > blurPercent) + { + + } + else + { + //clear absolutely everything before generating the caverns + Main.tile[X, Y].ClearEverything(); + + //generate perlin noise caves + float horizontalOffsetNoise = CalamityUtils.PerlinNoise2D(X / 20f, Y / 20f, 5, unchecked(cavePerlinSeed + 1)) * 0.01f; + float cavePerlinValue = CalamityUtils.PerlinNoise2D(X / 1000f, Y / 350f, 5, cavePerlinSeed) + 0.5f + horizontalOffsetNoise; + float cavePerlinValue2 = CalamityUtils.PerlinNoise2D(X / 1000f, Y / 350f, 5, unchecked(cavePerlinSeed - 1)) + 0.5f; + float caveNoiseMap = (cavePerlinValue + cavePerlinValue2) * 0.5f; + float caveCreationThreshold = horizontalOffsetNoise * 3.5f + 0.235f; + + //kill or place tiles depending on the noise map + if (caveNoiseMap * caveNoiseMap > caveCreationThreshold) + { + WorldGen.KillTile(X, Y); + } + else + { + WorldGen.PlaceTile(X, Y, (ushort)ModContent.TileType()); + } + + Main.tile[X, Y].WallType = (ushort)ModContent.WallType(); + WorldGen.PlaceWall(X, Y, ModContent.WallType()); + + Main.tile[X, Y].Get().LiquidType = LiquidID.Water; + Main.tile[X, Y].LiquidAmount = byte.MaxValue; + } + } + } + } + + //place sand + for (int X = origin.X - size - 3; X <= origin.X + size + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckReefsCircle(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist)) + { + bool canPlaceSand = false; + + //place sand clumps on top of exposed navystone + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile) + { + canPlaceSand = true; + } + + if (canPlaceSand) + { + SunkenSea.PlaceSand(X, Y, 3, ModContent.TileType()); + } + } + } + } + + //cleanup + for (int X = origin.X - size - 3; X <= origin.X + size + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckReefsCircle(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist)) + { + //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; + bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + + if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) + { + WorldGen.KillTile(X, Y); + } + + //kill random single floating tiles + if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) + { + WorldGen.KillTile(X, Y); + } + + Tile.SmoothSlope(X, Y); + } + } + } + } + + public static bool CheckReefsCircle(Point tile, Vector2 focus1, Vector2 focus2, float distanceConstant, Vector2 center, out float distance) + { + Vector2 point = tile.ToWorldCoordinates(); + + float distY = center.Y - point.Y; + point.Y -= distY * 3f; + + float distance1 = Vector2.Distance(point, focus1); + float distance2 = Vector2.Distance(point, focus2); + distance = distance1 + distance2; + + return distance <= distanceConstant; + } + */ + + public static void CreateBeach() { int beachWidth = WorldGen.genRand.Next(150, 190 + 1); var searchCondition = Searches.Chain(new Searches.Down(3000), new Conditions.IsSolid()); diff --git a/World/SunkenSea.cs b/World/SunkenSea.cs index 20e6d1b40c..9459d720a1 100644 --- a/World/SunkenSea.cs +++ b/World/SunkenSea.cs @@ -1,10 +1,12 @@ using System; using System.Collections.Generic; using CalamityMod.Tiles.SunkenSea; +using CalamityMod.Tiles.SunkenSea.Ambient; using CalamityMod.Walls; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent.Generation; using Terraria.ID; using Terraria.ModLoader; using Terraria.WorldBuilding; @@ -13,825 +15,1322 @@ namespace CalamityMod.World { public class SunkenSea { - private struct Hub + /* + Dylandoe checklist: + + -Make ambient tiles naturally grow on sunken sea tiles/sands (only eutrophic sand is done) + -Add basalt slab block + -Add navystone brick wall + -Add the wall corals properly + -Make sunken sea walls produce water + */ + + public static void PlaceTimelessShores(int startPosX, int startPosY) { - public Vector2 Position; + int biomeSize = 250 + (Main.maxTilesX / 180); - public Hub(Vector2 position) + //place a box of circles to serve as the main "area" for the biome + for (int X = startPosX - biomeSize; X <= startPosX + biomeSize; X += 25) { - Position = position; - } - - public Hub(float x, float y) - { - Position = new Vector2(x, y); - } - } - - private class Cluster : List - { - } - - private class ClusterGroup : List - { - public int Width; - - public int Height; - - private void SearchForCluster(bool[,] hubMap, List pointCluster, int x, int y, int level = 2) - { - pointCluster.Add(new Point(x, y)); - hubMap[x, y] = false; - level--; - if (level == -1) + for (int Y = startPosY - 50; Y <= startPosY + 50; Y += 20) { - return; - } - if (x > 0 && hubMap[x - 1, y]) - { - SearchForCluster(hubMap, pointCluster, x - 1, y, level); - } - if (x < hubMap.GetLength(0) - 1 && hubMap[x + 1, y]) - { - SearchForCluster(hubMap, pointCluster, x + 1, y, level); - } - if (y > 0 && hubMap[x, y - 1]) - { - SearchForCluster(hubMap, pointCluster, x, y - 1, level); - } - if (y < hubMap.GetLength(1) - 1 && hubMap[x, y + 1]) - { - SearchForCluster(hubMap, pointCluster, x, y + 1, level); + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(25), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); + WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.Clear(), + new Actions.PlaceTile((ushort)ModContent.TileType()) + })); } } - private void AttemptClaim(int x, int y, int[,] clusterIndexMap, List> pointClusters, int index) //Attempts to create a cluster + //clear a smaller square out of the center where the biomes stuff will be + for (int X = startPosX - biomeSize + 35; X <= startPosX + biomeSize - 35; X++) { - int clusterPos = clusterIndexMap[x, y]; - if (clusterPos != -1 && clusterPos != index) + for (int Y = startPosY - 50; Y <= startPosY + 50; Y++) { - int clusterHeight = (WorldGen.genRand.NextBool(2)) ? -1 : index; - foreach (Point current in pointClusters[clusterPos]) + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(2, 5)), Actions.Chain(new GenAction[] { - clusterIndexMap[current.X, current.Y] = clusterHeight; - } + blotchMod.Output(circle) + })); + WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.Clear() + })); } } - public void Generate(int width, int height) //Creates clusters for cluster group + //place little islands + for (int MoundX = startPosX - biomeSize + 35; MoundX <= startPosX + biomeSize - 35; MoundX += WorldGen.genRand.Next(60, 120)) { - Width = width; - Height = height; - Clear(); - bool[,] array = new bool[width, height]; - int clusterPos = (width >> 1) - 1; - int clusterHeight = (height >> 1) - 1; - int clusterSize = (clusterPos + 1) * (clusterPos + 1); - Point point = new Point(clusterPos, clusterHeight); - for (int i = point.Y - clusterHeight; i <= point.Y + clusterHeight; i++) + int MoundY = startPosY + 60; + + ShapeData mound = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + WorldUtils.Gen(new Point(MoundX, MoundY), new Shapes.Mound(30, 45), Actions.Chain(new GenAction[] + { + blotchMod.Output(mound) + })); + WorldUtils.Gen(new Point(MoundX, MoundY), new ModShapes.All(mound), Actions.Chain(new GenAction[] + { + new Actions.Clear(), new Actions.PlaceTile((ushort)ModContent.TileType()) + })); + + //place a wall pillar above an island + PlaceShoresWallPillar(startPosY, MoundX); + } + + //clear the tops off of the mounds so they have flat surfaces the player can walk on + for (int MoundClearX = startPosX - biomeSize + 37; MoundClearX <= startPosX + biomeSize - 37; MoundClearX++) + { + for (int MoundClearY = startPosY - 35; MoundClearY <= startPosY + 35; MoundClearY++) { - float num4 = (float)clusterPos / (float)clusterHeight * (float)(i - point.Y); - int num5 = Math.Min(clusterPos, (int)Math.Sqrt((float)clusterSize - num4 * num4)); - for (int j = point.X - num5; j <= point.X + num5; j++) - { - array[j, i] = WorldGen.genRand.NextBool(2); - } + WorldGen.KillTile(MoundClearX, MoundClearY); } - List> list = new List>(); - for (int k = 0; k < array.GetLength(0); k++) + } + + //place water below the clear barrier for the islands so that theres water inbetween them + for (int WaterX = startPosX - biomeSize + 35; WaterX <= startPosX + biomeSize - 35; WaterX++) + { + for (int WaterY = startPosY + 37; WaterY <= startPosY + 50; WaterY++) { - for (int l = 0; l < array.GetLength(1); l++) - { - if (array[k, l] && WorldGen.genRand.NextBool(2)) - { - List list2 = new List(); - SearchForCluster(array, list2, k, l, 2); - if (list2.Count > 2) - { - list.Add(list2); - } - } - } + Main.tile[WaterX, WaterY].Get().LiquidType = LiquidID.Water; + Main.tile[WaterX, WaterY].LiquidAmount = byte.MaxValue; } - int[,] array2 = new int[array.GetLength(0), array.GetLength(1)]; - for (int m = 0; m < array2.GetLength(0); m++) + } + + //slope tiles + for (int X = startPosX - biomeSize; X <= startPosX + biomeSize; X++) + { + for (int Y = startPosY - 50; Y <= startPosY + 50; Y++) { - for (int n = 0; n < array2.GetLength(1); n++) - { - array2[m, n] = -1; - } + Tile.SmoothSlope(X, Y); } - for (int num6 = 0; num6 < list.Count; num6++) + } + + //place layer of sand on valid runestone blocks + for (int X = startPosX - biomeSize; X <= startPosX + biomeSize; X++) + { + for (int Y = startPosY - 50; Y <= startPosY + 50; Y++) { - foreach (Point current in list[num6]) + bool canPlaceSand = false; + + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile && + !Main.tile[X, Y - 3].HasTile && !Main.tile[X, Y - 4].HasTile && !Main.tile[X, Y - 5].HasTile) { - array2[current.X, current.Y] = num6; + canPlaceSand = true; } - } - for (int num7 = 0; num7 < list.Count; num7++) - { - foreach (Point point2 in list[num7]) + + if (canPlaceSand) { - int x = point2.X; - int y = point2.Y; - if (array2[x, y] == -1) - { - break; - } - int index = array2[x, y]; - if (x > 0) - { - AttemptClaim(x - 1, y, array2, list, index); - } - if (x < array2.GetLength(0) - 1) - { - AttemptClaim(x + 1, y, array2, list, index); - } - if (y > 0) - { - AttemptClaim(x, y - 1, array2, list, index); - } - if (y < array2.GetLength(1) - 1) - { - AttemptClaim(x, y + 1, array2, list, index); - } - } - } - using (List>.Enumerator enumerator2 = list.GetEnumerator()) - { - while (enumerator2.MoveNext()) - { - enumerator2.Current.Clear(); - } - } - for (int num8 = 0; num8 < array2.GetLength(0); num8++) - { - for (int num9 = 0; num9 < array2.GetLength(1); num9++) - { - if (array2[num8, num9] != -1) - { - list[array2[num8, num9]].Add(new Point(num8, num9)); - } - } - } - foreach (List current2 in list) - { - if (current2.Count < 4) - { - current2.Clear(); - } - } - foreach (List current3 in list) - { - Cluster cluster = new Cluster(); - if (current3.Count > 0) - { - foreach (Point current4 in current3) - { - cluster.Add(new Hub((float)current4.X + (WorldGen.genRand.NextFloat() - 0.5f) * 0.5f, (float)current4.Y + (WorldGen.genRand.NextFloat() - 0.5f) * 0.5f)); - } - Add(cluster); + PlaceSand(X, Y, 5, ModContent.TileType()); } } } } - // Generates clumps / clusters / chunks of general tiles in the Sunken Sea area - private static void PlaceClusters(ClusterGroup clusters, Point start, Vector2 terrainApplicationScaleVector) + //places a pillar of walls along the height of the timeless shores biome + public static void PlaceShoresWallPillar(int startPosY, int XPosition) { - int totalWidth = (int)(terrainApplicationScaleVector.X * clusters.Width); - int totalHeight = (int)(terrainApplicationScaleVector.Y * clusters.Height); - Vector2 totalScale = new Vector2(totalWidth, totalHeight); - Vector2 individualScale = new Vector2(clusters.Width, clusters.Height); - - //I was a bit worried about editing anything in this loop too drastically, so i just changed all instances of placing navystone to eutrophic sand - for (int i = -20; i < totalWidth + 20; i++) + for (int Y = startPosY - 55; Y <= startPosY + 50; Y++) { - for (int j = -20; j < totalHeight + 20; j++) + int RandomX = + WorldGen.genRand.Next(-8, 8); + + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + WorldUtils.Gen(new Point(XPosition + RandomX, Y), new Shapes.Circle(WorldGen.genRand.Next(3, 7)), Actions.Chain(new GenAction[] { - float num3 = 0f; - int clusterAmt = -1; - float num5 = 0f; - int num6 = i + start.X; - int num7 = j + start.Y; - Vector2 vector = new Vector2((float)i, (float)j) / totalScale * individualScale; - float num8 = (new Vector2((float)i, (float)j) / totalScale * 2f - Vector2.One).Length(); - for (int k = 0; k < clusters.Count; k++) + blotchMod.Output(circle) + })); + WorldUtils.Gen(new Point(XPosition + RandomX, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.PlaceWall((ushort)ModContent.WallType()) + })); + } + } + + //sides of the sunken sea (radiant reefs) + //LeftSideBarrier is used to make the barrier of basalt either on the left or right, since the sunken sea is meant to have barriers on both sides and the reefs is generated twice + public static void PlaceRadiantReefs(int startPosX, int startPosY, bool LeftSideBarrier) + { + int cavePerlinSeed = WorldGen.genRand.Next(); + int cavePerlinSeedWalls = WorldGen.genRand.Next(); + + Point origin = new Point(startPosX, startPosY); + Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); + + float angle = MathHelper.Pi * 0.15f; + float otherAngle = MathHelper.PiOver2 - angle; + + int biomeSize = 180 + (Main.maxTilesX / 180); + float actualSize = biomeSize * 16f; + float constant = actualSize * 2f / (float)Math.Sin(angle); + + float fociSpacing = actualSize * (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; + + //first, place a basalt barrier on the left and right of the biome + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, Y < origin.Y)) { - Cluster cluster = clusters[k]; - if (Math.Abs(cluster[0].Position.X - vector.X) <= 10f && Math.Abs(cluster[0].Position.Y - vector.Y) <= 10f) + float percent = dist / constant; + float blurPercent = 0.99f; + + if (percent > blurPercent) { - float num9 = 0f; - foreach (Hub current in cluster) + if (Y > origin.Y - 60) { - num9 += 1f / Vector2.DistanceSquared(current.Position, vector); - } - if (num9 > num3) - { - if (num3 > num5) + if (LeftSideBarrier) { - num5 = num3; + if (X <= origin.X && Main.tile[X - 40, Y].TileType != ModContent.TileType()) + { + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + + WorldUtils.Gen(new Point(X - 40, Y), new Shapes.Circle(60), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); + WorldUtils.Gen(new Point(X - 40, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.Clear(), + new Actions.PlaceTile((ushort)ModContent.TileType()) + })); + } + } + else + { + if (X >= origin.X && Main.tile[X + 40, Y].TileType != ModContent.TileType()) + { + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + + WorldUtils.Gen(new Point(X + 40, Y), new Shapes.Circle(60), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); + WorldUtils.Gen(new Point(X + 40, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.Clear(), + new Actions.PlaceTile((ushort)ModContent.TileType()) + })); + } } - num3 = num9; - clusterAmt = k; - } - else if (num9 > num5) - { - num5 = num9; } } } - float num10 = num3 + num5; - Tile tile = Main.tile[num6, num7]; - bool flag = num8 >= 0.8f; - if (num10 > 4.5f) //Adjust num10 for all cases if you want different tile frequencies; higher is less frequent, lower is more frequent + } + } + + //generate the actual caverns + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, Y < origin.Y)) { - tile.ClearEverything(); - tile.LiquidAmount = 192; - if (clusterAmt % 5 == 2) + float percent = dist / constant; + float blurPercent = 0.99f; + + if (percent > blurPercent) { - tile.ResetToType((ushort)ModContent.TileType()); - tile.Get().HasTile = true; - tile.LiquidAmount = 0; + //place smaller shellstone clumps infront of the basalt so the basalt isnt actually inside of the biome itself + WorldGen.TileRunner(X, Y, WorldGen.genRand.Next(8, 12), WorldGen.genRand.Next(8, 12), ModContent.TileType(), true, 0f, 0f, true, true); } - Tile.SmoothSlope(num6, num7, true); - } - else if (num10 > 1.8f) - { - tile.WallType = (ushort)ModContent.WallType(); - tile.LiquidAmount = 192; - if (!flag || tile.HasTile) + else { - tile.ResetToType((ushort)ModContent.TileType()); - tile.Get().HasTile = true; - Tile.SmoothSlope(num6, num7, true); - tile.LiquidAmount = 0; - } - } - else if (num10 > 0.7f || !flag) - { - tile.LiquidAmount = 192; - if (!flag || tile.HasTile) - { - tile.ResetToType((ushort)ModContent.TileType()); - tile.Get().HasTile = true; - Tile.SmoothSlope(num6, num7, true); - tile.LiquidAmount = 0; - } - tile.WallType = (ushort)ModContent.WallType(); - } - else if (num10 > 0.25f) - { - float num11 = (num10 - 0.25f) / 0.45f; - if (WorldGen.genRand.NextFloat() < num11) - { - if (tile.HasTile) + //clear absolutely everything before generating the caverns + Main.tile[X, Y].ClearEverything(); + + //generate perlin noise caves + float horizontalOffsetNoise = CalamityUtils.PerlinNoise2D(X / 80f, Y / 80f, 5, unchecked(cavePerlinSeed + 1)) * 0.01f; + float cavePerlinValue = CalamityUtils.PerlinNoise2D(X / 1000f, Y / 750f, 5, cavePerlinSeed) + 0.5f + horizontalOffsetNoise; + float cavePerlinValue2 = CalamityUtils.PerlinNoise2D(X / 1000f, Y / 750f, 5, unchecked(cavePerlinSeed - 1)) + 0.5f; + float caveNoiseMap = (cavePerlinValue + cavePerlinValue2) * 0.5f; + float caveCreationThreshold = horizontalOffsetNoise * 3.5f + 0.280f; + + //kill or place tiles depending on the noise map + if (caveNoiseMap * caveNoiseMap > caveCreationThreshold) { - tile.ResetToType((ushort)ModContent.TileType()); - tile.Get().HasTile = true; - Tile.SmoothSlope(num6, num7, true); - tile.WallType = (ushort)ModContent.WallType(); - tile.LiquidAmount = 0; + WorldGen.KillTile(X, Y); } else { - tile.WallType = (ushort)ModContent.WallType(); - tile.LiquidAmount = 192; + WorldGen.PlaceTile(X, Y, (ushort)ModContent.TileType()); } + + //place walls in the biome using a different "seed" so it differs from the cave generation + //this creates a neat effect where walls worm their way through the caverns while leaving openings for the background to show through + float horizontalOffsetNoiseWalls = CalamityUtils.PerlinNoise2D(X / 80f, Y / 80f, 5, unchecked(cavePerlinSeedWalls + 1)) * 0.01f; + float cavePerlinValueWalls = CalamityUtils.PerlinNoise2D(X / 1000f, Y / 750f, 5, cavePerlinSeedWalls) + 0.5f + horizontalOffsetNoiseWalls; + float cavePerlinValue2Walls = CalamityUtils.PerlinNoise2D(X / 1000f, Y / 750f, 5, unchecked(cavePerlinSeedWalls - 1)) + 0.5f; + float caveNoiseMapWalls = (cavePerlinValueWalls + cavePerlinValue2Walls) * 0.5f; + float caveCreationThresholdWalls = horizontalOffsetNoiseWalls * 3.5f + 0.280f; + + if (caveNoiseMapWalls * caveNoiseMapWalls > caveCreationThresholdWalls) + { + WorldGen.PlaceWall(X, Y, ModContent.WallType()); + } + + Main.tile[X, Y].Get().LiquidType = LiquidID.Water; + Main.tile[X, Y].LiquidAmount = byte.MaxValue; } } } } - //final cleanup loop - for (int i = -20; i < totalWidth + 20; i++) + //cleanup + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) { - for (int j = -20; j < totalHeight + 20; j++) + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) { - int x = i + start.X; - int y = j + start.Y; - - Tile tile = Main.tile[x, y]; - Tile tileUp = Main.tile[x, y - 1]; - Tile tileDown = Main.tile[x, y + 1]; - Tile tileDown2 = Main.tile[x, y + 2]; - Tile tileLeft = Main.tile[x - 1, y]; - Tile tileRight = Main.tile[x + 1, y]; - - //lava BEGONE - if (tile.WallType == ModContent.WallType() || tile.WallType == ModContent.WallType()) + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, Y < origin.Y)) { - if (tile.LiquidType == LiquidID.Lava && tile.LiquidAmount > 0) + //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; + bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + + if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) { - tile.LiquidType = LiquidID.Water; - tile.LiquidAmount = 255; + WorldGen.KillTile(X, Y); } - //also get rid of any annoying leftover obsidian - if (tile.TileType == TileID.Obsidian) + //kill random single floating tiles + if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) { - WorldGen.KillTile(x, y); + WorldGen.KillTile(X, Y); } } + } + } - //place extra caves throughout the biome for variance - if (WorldGen.genRand.NextBool(1000)&& tile != null && tile.HasTile && - (tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType())) + //place layer of sand blocks on valid surfaces + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, Y < origin.Y)) { - TileRunner runner = new TileRunner(new Vector2(x, y), new Vector2(0, 5), new Point16(-35, 35), - new Point16(-35, 35), 15f, WorldGen.genRand.Next(25, 50), 0, false, true); - runner.Start(); - } + bool canPlaceSand = false; - //kill any random floating tiles - if (tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType()) - { - //kill any individual floating tiles - if (!tileUp.HasTile && !tileDown.HasTile && !tileLeft.HasTile && !tileRight.HasTile) + //place sand clumps on top of exposed shellstone + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile && + !Main.tile[X, Y - 3].HasTile && !Main.tile[X, Y - 4].HasTile && !Main.tile[X, Y - 5].HasTile) { - WorldGen.KillTile(x, y); + canPlaceSand = true; + } + + if (canPlaceSand) + { + PlaceSand(X, Y, 5, ModContent.TileType()); } } + } + } - //kill any random clumps of navystone without eutrophic sand around them - if (tile.TileType == ModContent.TileType() && tileUp.TileType != ModContent.TileType() && - tileDown.TileType != ModContent.TileType() && tileLeft.TileType != ModContent.TileType() && - tileRight.TileType != ModContent.TileType()) + //cleanup again + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, Y < origin.Y)) { - WorldGen.KillTile(x, y); + //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; + bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + + if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) + { + WorldGen.KillTile(X, Y); + } + + //kill random single floating tiles + if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) + { + WorldGen.KillTile(X, Y); + } + + //if any sand is floating, put tiles below it + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y + 1].HasTile) + { + WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); + Main.tile[X, Y].TileType = (ushort)ModContent.TileType(); + } + + Tile.SmoothSlope(X, Y); } } } } - // Adds tile variation to generated tile clusters and generates open areas with sea prism ore called "Tits" - // Generates sea prism crystals on prism ore and occasionally on navystone - private static void AddGeodes(ClusterGroup clusters, Point start, Vector2 terrainApplicationScaleVector, float overallBiomeScale) + //middle of the sunken sea (polyp forest) + public static void PlacePolypForest(int startPosX, int startPosY) { - int totalClusterZoneWidth = (int)(terrainApplicationScaleVector.X * clusters.Width); - int totalClusterZoneHeight = (int)(terrainApplicationScaleVector.Y * clusters.Height); - bool genCentalHole = true; - Rectangle rectangle = default; + int cavePerlinSeed = WorldGen.genRand.Next(); + int cavePerlinSeedWalls = WorldGen.genRand.Next(); - // Radius of the generated hole - int radius = (int)(WorldGen.genRand.Next(24, 28) * overallBiomeScale); - int diameter = radius * 2; + Point origin = new Point(startPosX, startPosY); + Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); - // Where to place the giant hole? "Center of the Sunken Sea", defined as follows: - // Dead center horizontally, and 1/3 of the way down the area - Point point = new Point(start.X + totalClusterZoneWidth / 2, start.Y + (int)(totalClusterZoneHeight * 0.33f)); + float angle = MathHelper.Pi * 0.15f; + float otherAngle = MathHelper.PiOver2 - angle; - ShapeData holeShape = new ShapeData(); - float outerRadiusPercentage = WorldGen.genRand.Next(40, 56) * 0.01f; //Small radius for ore patch to fit inside holes + int biomeSize = 120 + (Main.maxTilesX / 180); + float actualSize = biomeSize * 16f; + float constant = actualSize * 2f / (float)Math.Sin(angle); - // Y coordinate of the "bottom" of the Sunken Sea, 70% of the way down. - int sunkenSeaBottom = start.Y + (int)(totalClusterZoneHeight * 0.7f); - int smallHoles = 0; + float fociSpacing = actualSize * (float)Math.Sin(otherAngle) / (float)Math.Sin(angle); + int verticalRadius = (int)(constant / 16f); - // Scale amount of holes with world size - // 4 on Small, 6 on Normal (rounds down), 8 on Large - int totalHoleCount = (int)(4f * overallBiomeScale); + Vector2 fociOffset = Vector2.UnitY * fociSpacing; + Vector2 topFoci = center - fociOffset; + Vector2 bottomFoci = center + fociOffset; - for (int i = -20; i < totalClusterZoneWidth + 20; i++) + //place the polyp forest caverns + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) { - for (int j = -20; j < totalClusterZoneHeight + 20; j++) + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) { - if (genCentalHole) + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, Y < origin.Y)) { - // Set the rectangle for the central hole - genCentalHole = false; - rectangle = new Rectangle(start.X + totalClusterZoneWidth / 2 - radius, start.Y + (int)(totalClusterZoneHeight * 0.33f) - radius, diameter, diameter); + float percent = dist / constant; + float blurPercent = 0.98f; - WorldUtils.Gen(point, new Shapes.Circle(radius), Actions.Chain(new GenAction[] + //biome "blending" on the edges (disabled for now) + if (percent > blurPercent) { - new Modifiers.Blotches(2, 0.6).Output(holeShape), //Adds uneven shape to the outer tiles - new Actions.ClearTile(true), //Clear all tiles - new Actions.SetLiquid(0, 192) //Leave some air pockets - })); + if (Main.tile[X, Y].HasTile && Main.tile[X, Y].TileType != ModContent.TileType()) + { + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(1, 3)), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); - WorldUtils.Gen(point, new ModShapes.OuterOutline(holeShape, true, true), Actions.Chain(new GenAction[] //Smooth the outer parts + WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(), new Actions.PlaceTile((ushort)ModContent.TileType()) + })); + } + } + else { - new CustomActions.DistanceFromOrigin(true, radius * 16f - 48), - new Modifiers.Conditions(new CustomConditions.RandomChance(4)), - new Actions.Smooth(), - new Actions.SetFrames(true) - })); + //clear absolutely everything before generating the caverns + Main.tile[X, Y].ClearEverything(); - WorldUtils.Gen(point, new Shapes.Circle((int)((float)radius * outerRadiusPercentage)), Actions.Chain(new GenAction[] //Smallest is 6 - { - new Modifiers.Blotches(2, 0.3).Output(holeShape), - new Actions.SetTile((ushort)ModContent.TileType(), true) //Place outer shell - })); + //generate perlin noise caves + float horizontalOffsetNoise = CalamityUtils.PerlinNoise2D(X / 80f, Y / 80f, 5, unchecked(cavePerlinSeed + 1)) * 0.01f; + float cavePerlinValue = CalamityUtils.PerlinNoise2D(X / 700f, Y / 650f, 5, cavePerlinSeed) + 0.5f + horizontalOffsetNoise; + float cavePerlinValue2 = CalamityUtils.PerlinNoise2D(X / 700f, Y / 650f, 5, unchecked(cavePerlinSeed - 1)) + 0.5f; + float caveNoiseMap = (cavePerlinValue + cavePerlinValue2) * 0.5f; + float caveCreationThreshold = horizontalOffsetNoise * 3.5f + 0.235f; - WorldUtils.Gen(point, new ModShapes.OuterOutline(holeShape, true, true), Actions.Chain(new GenAction[] //Smooth outer shell - { - new CustomActions.DistanceFromOrigin(true, radius * 16f - 48), - new Modifiers.Conditions(new CustomConditions.RandomChance(3)), - new Actions.Smooth(), - new Actions.SetFrames(true) - })); + //kill or place tiles depending on the noise map + if (caveNoiseMap * caveNoiseMap > caveCreationThreshold) + { + WorldGen.KillTile(X, Y); + } + else + { + WorldGen.PlaceTile(X, Y, (ushort)ModContent.TileType()); + } - WorldUtils.Gen(point, new Shapes.Circle((int)((float)radius * (outerRadiusPercentage * 0.6f))), Actions.Chain(new GenAction[] //Smallest is 4 - { - new Modifiers.Blotches(2, 0.3), - new Actions.SetTile((ushort)ModContent.TileType(), true) //Place prism - })); + //place walls in the biome using a different "seed" so it differs from the cave generation + //this creates a neat effect where walls worm their way through the caverns while leaving openings for the background to show through + float horizontalOffsetNoiseWalls = CalamityUtils.PerlinNoise2D(X / 80f, Y / 80f, 5, unchecked(cavePerlinSeedWalls + 1)) * 0.01f; + float cavePerlinValueWalls = CalamityUtils.PerlinNoise2D(X / 700f, Y / 650f, 5, cavePerlinSeedWalls) + 0.5f + horizontalOffsetNoiseWalls; + float cavePerlinValue2Walls = CalamityUtils.PerlinNoise2D(X / 700f, Y / 650f, 5, unchecked(cavePerlinSeedWalls - 1)) + 0.5f; + float caveNoiseMapWalls = (cavePerlinValueWalls + cavePerlinValue2Walls) * 0.5f; + float caveCreationThresholdWalls = horizontalOffsetNoiseWalls * 3.5f + 0.235f; - WorldUtils.Gen(point, new Shapes.Circle((int)((float)radius * (outerRadiusPercentage * 0.3f))), Actions.Chain(new GenAction[] //Smallest is 2 - { - new Modifiers.Blotches(2, 0.3).Output(holeShape), - new Actions.ClearTile(true), //Clear all tiles - new Actions.SetLiquid(0, 255) - })); + if (caveNoiseMapWalls * caveNoiseMapWalls > caveCreationThresholdWalls) + { + //temporarily use navystone + WorldGen.PlaceWall(X, Y, ModContent.WallType()); + } - WorldUtils.Gen(point, new ModShapes.OuterOutline(holeShape, true, true), Actions.Chain(new GenAction[] //Smooth inner shell - { - new CustomActions.DistanceFromOrigin(true, radius * 16f - 48), - new Modifiers.Conditions(new CustomConditions.RandomChance(2)), - new Actions.Smooth(), - new Actions.SetFrames(true) - })); + Main.tile[X, Y].Get().LiquidType = LiquidID.Water; + Main.tile[X, Y].LiquidAmount = byte.MaxValue; + } } + } + } - // Set the point for non-central holes - int smallHoleX = WorldGen.genRand.Next(start.X + 30, start.X + totalClusterZoneWidth - 30); - int smallHoleY = WorldGen.genRand.Next(start.Y + 20, sunkenSeaBottom); - point = new Point(smallHoleX, smallHoleY); - - if (smallHoles < totalHoleCount && WorldGen.genRand.NextBool(3)&& !rectangle.Contains(point)) + //cleanup + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, Y < origin.Y)) { - smallHoles++; - int radiusSmall = (int)(((float)WorldGen.genRand.Next(8, 11)) * overallBiomeScale); - WorldUtils.Gen(point, new Shapes.Circle(radiusSmall), Actions.Chain(new GenAction[] - { - new Modifiers.Blotches(2, 0.45).Output(holeShape), - new Actions.ClearTile(true), - new Actions.SetLiquid(0, 192) - })); + //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; + bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; - WorldUtils.Gen(point, new ModShapes.OuterOutline(holeShape, true, true), Actions.Chain(new GenAction[] + if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) { - new CustomActions.DistanceFromOrigin(true, radiusSmall * 16f - 48), - new Modifiers.Conditions(new CustomConditions.RandomChance(3)), - new Actions.Smooth(), - new Actions.SetFrames(true) - })); + WorldGen.KillTile(X, Y); + } - outerRadiusPercentage = (float)((double)WorldGen.genRand.Next(65, 81) * 0.01); - WorldUtils.Gen(point, new Shapes.Circle((int)((float)radiusSmall * outerRadiusPercentage)), Actions.Chain(new GenAction[] //Smallest is 4 + //kill random single floating tiles + if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) { - new Modifiers.Blotches(2, 0.3).Output(holeShape), - new Actions.SetTile((ushort)ModContent.TileType(), true) //Place outer shell - })); - - WorldUtils.Gen(point, new ModShapes.OuterOutline(holeShape, true, true), Actions.Chain(new GenAction[] //Smooth outer shell - { - new CustomActions.DistanceFromOrigin(true, radiusSmall * 16f - 48), - new Modifiers.Conditions(new CustomConditions.RandomChance(3)), - new Actions.Smooth(), - new Actions.SetFrames(true) - })); - - WorldUtils.Gen(point, new Shapes.Circle((int)((float)radiusSmall * (outerRadiusPercentage * 0.6f))), Actions.Chain(new GenAction[] //Smallest is 2 - { - new Modifiers.Blotches(2, 0.3), - new Actions.SetTile((ushort)ModContent.TileType(), true) //Place prism - })); - - WorldUtils.Gen(point, new Shapes.Circle((int)((float)radiusSmall * (outerRadiusPercentage * 0.3f))), Actions.Chain(new GenAction[] //Smallest is 1 - { - new Modifiers.Blotches(2, 0.3).Output(holeShape), - new Actions.ClearTile(true), //Clear center - new Actions.SetLiquid(0, 255) - })); - - WorldUtils.Gen(point, new ModShapes.OuterOutline(holeShape, true, true), Actions.Chain(new GenAction[] //Smooth inner shell - { - new CustomActions.DistanceFromOrigin(true, radius * 16f - 48), - new Modifiers.Conditions(new CustomConditions.RandomChance(2)), - new Actions.Smooth(), - new Actions.SetFrames(true) - })); + WorldGen.KillTile(X, Y); + } } + } + } - int num3 = i + start.X; - int num4 = j + start.Y; - Tile tile = Main.tile[num3, num4]; - Tile testTile = Main.tile[num3, num4 + 1]; - Tile testTile2 = Main.tile[num3, num4 + 2]; - if (tile.TileType == ModContent.TileType() && (!WorldGen.SolidTile(testTile) || !WorldGen.SolidTile(testTile2))) //Tile variation + //place extra tiles + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, Y < origin.Y)) { - tile.TileType = (ushort)ModContent.TileType(); + bool canPlaceSand = false; + + //place sand clumps on top of exposed limestone + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile && + !Main.tile[X, Y - 3].HasTile && !Main.tile[X, Y - 4].HasTile && !Main.tile[X, Y - 5].HasTile) + { + canPlaceSand = true; + } + + if (canPlaceSand) + { + PlaceSand(X, Y, 5, ModContent.TileType()); + } + } + } + } + + //cleanup again + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, Y < origin.Y)) + { + //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; + bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + + if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) + { + WorldGen.KillTile(X, Y); + } + + //kill random single floating tiles + if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) + { + WorldGen.KillTile(X, Y); + } + + //if any sand is floating, put tiles below it + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y + 1].HasTile) + { + WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); + Main.tile[X, Y].TileType = (ushort)ModContent.TileType(); + } + + Tile.SmoothSlope(X, Y); } } } } - private static void AddTileVariance(ClusterGroup clusters, Point start, Vector2 terrainApplicationScaleVector, float overallBiomeScale) + //bottom of the biome (gleaming burrows) + public static void PlaceGleamingBurrows(int startPosX, int startPosY) { - int totalClusterZoneWidth = (int)(terrainApplicationScaleVector.X * clusters.Width); - int totalClusterZoneHeight = (int)(terrainApplicationScaleVector.Y * clusters.Height); - for (int k = -20; k < totalClusterZoneWidth + 20; k++) + int cavePerlinSeed = WorldGen.genRand.Next(); + int cavePerlinSeedWalls = WorldGen.genRand.Next(); + + Point origin = new Point(startPosX, startPosY); + Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); + + float angle = MathHelper.Pi * 0.15f; + float otherAngle = MathHelper.PiOver2 - angle; + + int biomeSize = 220 + (Main.maxTilesX / 180); + float actualSize = biomeSize * 16f; + float constant = actualSize * 2f / (float)Math.Sin(angle); + + float fociSpacing = actualSize * (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; + + //place another barrier so the gleaming burrows doesnt just burst into the gully + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X += 10) { - for (int l = -20; l < totalClusterZoneHeight + 20; l++) + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y += 2) { - int num5 = k + start.X; - int num6 = l + start.Y; - Tile tile = Main.tile[num5, num6]; - if (tile.HasTile && (tile.TileType == ModContent.TileType() || - tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType())) + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) { - bool flag = true; - for (int m = -1; m >= -3; m--) + float percent = dist / constant; + float blurPercent = 0.98f; + + if (percent > blurPercent) { - if (Main.tile[num5, num6 + m].HasTile) + if (Y > origin.Y + 20) { - flag = false; - break; - } - } - bool flag2 = true; - for (int n = 1; n <= 3; n++) - { - if (Main.tile[num5, num6 + n].HasTile) - { - flag2 = false; - break; - } - } - bool flag3 = true; - for (int o = -1; o >= -3; o--) - { - if (Main.tile[num5 + o, num6].HasTile) - { - flag3 = false; - break; - } - } - bool flag4 = true; - for (int p = 1; p <= 3; p++) - { - if (Main.tile[num5 + p, num6].HasTile) - { - flag4 = false; - break; - } - } - if (tile.TileType == ModContent.TileType() || ((tile.TileType == ModContent.TileType() || - tile.TileType == ModContent.TileType()) && WorldGen.genRand.NextBool(8))) - { - if (flag3 ^ flag4) - { - if (tile.Slope == 0 && !tile.IsHalfBlock) + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + + WorldUtils.Gen(new Point(X, Y + 10), new Shapes.Circle(20), Actions.Chain(new GenAction[] { - Tile tile3 = Main.tile[num5 + (flag3 ? -1 : 1), num6]; - tile3.TileType = (ushort)ModContent.TileType(); - if (Main.tile[num5 - 1, num6].TileType == ModContent.TileType()) - { - Main.tile[num5 - 1, num6].TileFrameY = (short)(2 * 18); - } - else if (Main.tile[num5 + 1, num6].TileType == ModContent.TileType()) - { - Main.tile[num5 + 1, num6].TileFrameY = (short)(3 * 18); - } - tile3.TileFrameX = (short)(WorldGen.genRand.Next(18) * 18); - tile3.Get().HasTile = true; - } - } - if (flag ^ flag2) - { - if (tile.Slope == 0 && !tile.IsHalfBlock) + blotchMod.Output(circle) + })); + WorldUtils.Gen(new Point(X, Y + 10), new ModShapes.All(circle), Actions.Chain(new GenAction[] { - Tile tile3 = Main.tile[num5, num6 + (flag ? -1 : 1)]; - tile3.TileType = (ushort)ModContent.TileType(); - if (Main.tile[num5, num6 - 1].TileType == ModContent.TileType()) - { - Main.tile[num5, num6 - 1].TileFrameY = (short)(0 * 18); - } - else if (Main.tile[num5, num6 + 1].TileType == ModContent.TileType()) - { - Main.tile[num5, num6 + 1].TileFrameY = (short)(1 * 18); - } - tile3.TileFrameX = (short)(WorldGen.genRand.Next(18) * 18); - tile3.Get().HasTile = true; - } + new Actions.Clear(), + new Actions.PlaceTile((ushort)ModContent.TileType()) + })); } } } - if (tile.TileType == ModContent.TileType() || tile.TileType == ModContent.TileType()) + } + } + + //place the gleaming burrows caverns + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) { + float percent = dist / constant; + float blurPercent = 0.99f; + + if (percent > blurPercent) + { + if (Y > origin.Y - 50) + { + //place smaller navystone clumps infront of the basalt so the basalt isnt actually inside of the biome itself + WorldGen.TileRunner(X, Y, WorldGen.genRand.Next(8, 12), WorldGen.genRand.Next(8, 12), ModContent.TileType(), true, 0f, 0f, true, true); + } + + //place clean transition between the burrows and the other biomes + if (Y < origin.Y && Main.tile[X, Y].HasTile && Main.tile[X, Y].TileType != ModContent.TileType()) + { + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(1, 3)), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); + + WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(), new Actions.PlaceTile((ushort)ModContent.TileType()) + })); + } + } + else + { + //clear absolutely everything before generating the caverns + Main.tile[X, Y].ClearEverything(); + + //generate perlin noise caves + float horizontalOffsetNoise = CalamityUtils.PerlinNoise2D(X / 80, Y / 80, 5, unchecked(cavePerlinSeed + 1)) * 0.01f; + float cavePerlinValue = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, cavePerlinSeed) + 0.5f + horizontalOffsetNoise; + float cavePerlinValue2 = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, unchecked(cavePerlinSeed - 1)) + 0.5f; + float caveNoiseMap = (cavePerlinValue + cavePerlinValue2) * 0.5f; + float caveCreationThreshold = horizontalOffsetNoise * 3.5f + 0.235f; + + //kill or place tiles depending on the noise map + if (caveNoiseMap * caveNoiseMap > caveCreationThreshold) + { + WorldGen.KillTile(X, Y); + } + else + { + WorldGen.PlaceTile(X, Y, (ushort)ModContent.TileType()); + } + + //place walls in the biome using a different "seed" so it differs from the cave generation + //this creates a neat effect where walls worm their way through the caverns while leaving openings for the background to show through + float horizontalOffsetNoiseWalls = CalamityUtils.PerlinNoise2D(X / 80, Y / 80, 5, unchecked(cavePerlinSeedWalls + 1)) * 0.01f; + float cavePerlinValueWalls = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, cavePerlinSeedWalls) + 0.5f + horizontalOffsetNoiseWalls; + float cavePerlinValue2Walls = CalamityUtils.PerlinNoise2D(X / 375f, Y / 375f, 5, unchecked(cavePerlinSeedWalls - 1)) + 0.5f; + float caveNoiseMapWalls = (cavePerlinValueWalls + cavePerlinValue2Walls) * 0.5f; + float caveCreationThresholdWalls = horizontalOffsetNoiseWalls * 5.5f + 0.235f; + + if (caveNoiseMapWalls * caveNoiseMapWalls > caveCreationThresholdWalls) + { + WorldGen.PlaceWall(X, Y, ModContent.WallType()); + } + + Main.tile[X, Y].Get().LiquidType = LiquidID.Water; + Main.tile[X, Y].LiquidAmount = byte.MaxValue; + } + } + } + } + + //cleanup the perlin caves + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) + { + //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; + bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + + if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) + { + WorldGen.KillTile(X, Y); + } + + //kill random single floating tiles + if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) + { + WorldGen.KillTile(X, Y); + } + } + } + } + + //place extra tiles + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) + { + bool canPlaceSand = false; + + //place sand clumps on top of exposed navystone + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile && !Main.tile[X, Y - 3].HasTile) + { + canPlaceSand = true; + } + + if (canPlaceSand) + { + PlaceSand(X, Y, 4, ModContent.TileType()); + } + } + } + } + + //cleanup again, also place geodes + for (int X = origin.X - biomeSize - 3; X <= origin.X + biomeSize + 3; X++) + { + for (int Y = (int)(origin.Y - verticalRadius * 0.4f) - 3; Y <= origin.Y + verticalRadius + 3; Y++) + { + if (CheckInBiomeArea(new Point(X, Y), topFoci, bottomFoci, constant, center, out float dist, true)) + { + //place geodes + if (WorldGen.genRand.NextBool(800) && Main.tile[X, Y].TileType == ModContent.TileType()) + { + PlaceGeode(X, Y, WorldGen.genRand.Next(10, 17)); + } + + //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; + bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + + if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) + { + WorldGen.KillTile(X, Y); + } + + //kill random single floating tiles + if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) + { + WorldGen.KillTile(X, Y); + } + + //if any sand is floating, put tiles below it + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y + 1].HasTile) + { + WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); + Main.tile[X, Y].TileType = (ushort)ModContent.TileType(); + } + + Tile.SmoothSlope(X, Y); + } + } + } + } + + //basalt biome underneath the sunken sea + public static void PlaceBasaltGully(int startPosX, int startPosY) + { + int biomeSize = 230 + (Main.maxTilesX / 180); + + int XLeft = GenVars.UndergroundDesertLocation.Left; + int XRight = GenVars.UndergroundDesertLocation.Right; + + //place circles of basalt along the 2 edges of the area + for (int Y = startPosY - 30; Y <= Main.maxTilesY - 260; Y += 20) + { + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + + int radius = WorldGen.genRand.Next(30, 45); + int RandomX = Main.rand.Next(-25, 25); + + WorldUtils.Gen(new Point(XLeft, Y), new Shapes.Circle(radius), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); + + WorldUtils.Gen(new Point(XLeft, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.Clear(), + new Actions.PlaceTile((ushort)ModContent.TileType()), + new Actions.PlaceWall(WallID.LavaUnsafe1) + })); + + WorldUtils.Gen(new Point(XRight, Y), new Shapes.Circle(radius), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); + + WorldUtils.Gen(new Point(XRight, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.Clear(), + new Actions.PlaceTile((ushort)ModContent.TileType()), + new Actions.PlaceWall(WallID.LavaUnsafe1) + })); + } + + //place blocks of basalt all the way down to hell, here it just places one block and wall so it doesnt hurt preformance + for (int X = startPosX - biomeSize - 25; X <= startPosX + biomeSize + 25; X++) + { + for (int Y = startPosY - 30; Y <= Main.maxTilesY - 250; Y++) + { + Main.tile[X, Y].ClearEverything(); + WorldGen.PlaceTile(X, Y, (ushort)ModContent.TileType()); + WorldGen.PlaceWall(X, Y, WallID.LavaUnsafe1); + } + } + + //place another wall of circles along the bottom of the biome so it doesnt just end unnaturally + for (int X = startPosX - biomeSize; X <= startPosX + biomeSize; X += 20) + { + int Y = Main.maxTilesY - 250; + + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(25), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); + + WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.Clear(), + new Actions.PlaceTile((ushort)ModContent.TileType()), + new Actions.PlaceWall(WallID.LavaUnsafe1) + })); + } + + //place caverns and lava + for (int X = startPosX - biomeSize - (Main.maxTilesX / 25); X <= startPosX + biomeSize + (Main.maxTilesX / 25); X++) + { + for (int Y = startPosY; Y <= Main.maxTilesY - 210; Y++) + { + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + //place caves + if (WorldGen.genRand.NextBool(350)) + { + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(5, 12)), Actions.Chain(new Modifiers.Blotches( + WorldGen.genRand.Next(3, 5), WorldGen.genRand.Next(3, 5)), new Actions.ClearTile())); + } + + //place lava + if (WorldGen.genRand.NextBool(2000)) + { + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(5, 12)), Actions.Chain(new Modifiers.Blotches( + WorldGen.genRand.Next(3, 5), WorldGen.genRand.Next(3, 5)), new Actions.SetLiquid(LiquidID.Lava, 255))); + } + } + } + } + + //place sand blocks + for (int X = startPosX - biomeSize - (Main.maxTilesX / 25); X <= startPosX + biomeSize + (Main.maxTilesX / 25); X++) + { + for (int Y = startPosY; Y <= Main.maxTilesY - 210; Y++) + { + bool canPlaceSand = false; + + //place sand clumps on top of exposed basalt + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y - 2].HasTile) + { + canPlaceSand = true; + } + + if (canPlaceSand) + { + PlaceSand(X, Y, 3, ModContent.TileType()); + } + } + } + + //cleanup + for (int X = startPosX - biomeSize - (Main.maxTilesX / 25); X <= startPosX + biomeSize + (Main.maxTilesX / 25); X++) + { + for (int Y = startPosY; Y <= Main.maxTilesY - 210; Y++) + { + //clean tiles that are sticking out (aka tiles only attached to one tile on one side) + bool OnlyRight = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile; + bool OnlyLeft = !Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyDown = !Main.tile[X, Y - 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + bool OnlyUp = !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile; + + if (OnlyRight || OnlyLeft || OnlyDown || OnlyUp) + { + WorldGen.KillTile(X, Y); + } + + //kill random single floating tiles + if (!Main.tile[X, Y - 1].HasTile && !Main.tile[X, Y + 1].HasTile && !Main.tile[X - 1, Y].HasTile && !Main.tile[X + 1, Y].HasTile) + { + WorldGen.KillTile(X, Y); + } + + //if any sand is floating, put tiles below it + if (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y + 1].HasTile) + { + WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); + Main.tile[X, Y].TileType = (ushort)ModContent.TileType(); + } + } + } + } + + //cleanup is done separately because for whatever reason it keeps placing water inside of the gully if the cleanup is done before it + public static void BasaltGullyLavaCleanup(int startPosX, int startPosY) + { + int biomeSize = 230 + (Main.maxTilesX / 180); + + for (int X = startPosX - biomeSize - (Main.maxTilesX / 25); X <= startPosX + biomeSize + (Main.maxTilesX / 25); X++) + { + for (int Y = startPosY + 50; Y <= Main.maxTilesY - 200; Y++) + { + if (Main.tile[X, Y].WallType == WallID.LavaUnsafe1) + { + //get rid of water + if (Main.tile[X, Y].LiquidType == LiquidID.Water) + { + Main.tile[X, Y].Get().LiquidType = LiquidID.Lava; + } + + //get rid of obsidian blocks + if (Main.tile[X, Y].TileType == TileID.Obsidian) + { + WorldGen.KillTile(X, Y); + } + } + } + } + } + + //place all the ambient tiles in the sunken sea + public static void PlaceSunkenSeaAmbience() + { + //first clean up unnecessary chunks of tiles + CleanOutSmallClumps(); + + //just loop through the whole world and check for the specific tiles in the sunken sea because im lazy + for (int X = 20; X <= Main.maxTilesX - 20; X++) + { + for (int Y = 20; Y <= Main.maxTilesY - 20; Y++) + { + //place coral blobs in the radiant reefs + if (WorldGen.genRand.NextBool(100) && ((Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y - 1].HasTile) || + (Main.tile[X, Y].TileType == ModContent.TileType() && !Main.tile[X, Y + 1].HasTile))) + { + ushort[] Corals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + ShapeData circle = new ShapeData(); + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(WorldGen.genRand.Next(2, 4)), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle) + })); + + WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(), new Actions.PlaceTile(WorldGen.genRand.Next(Corals)) + })); + } + + //gleaming burrows ambient tiles + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + //brain coral if (WorldGen.genRand.NextBool(10)) { - WorldGen.PlaceTile(num5, num6 - 1, (ushort)ModContent.TileType(), true, false, -1, 0); + WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); } - if (WorldGen.genRand.NextBool(20)) + //small brain coral + if (WorldGen.genRand.NextBool(5)) { - WorldGen.PlaceTile(num5, num6 - 1, (ushort)ModContent.TileType(), true, false, -1, 0); + WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); } + + //tube coral + if (WorldGen.genRand.NextBool(12)) + { + WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); + } + //small tube coral if (WorldGen.genRand.NextBool(8)) { - WorldGen.PlaceTile(num5, num6 - 1, (ushort)ModContent.TileType(), true, false, -1, 0); - } - if (WorldGen.genRand.NextBool(30)) - { - WorldGen.PlaceTile(num5, num6 - 1, (ushort)ModContent.TileType(), true, false, -1, 0); - } - if (WorldGen.genRand.NextBool(30)) - { - WorldGen.PlaceTile(num5, num6 - 1, (ushort)ModContent.TileType(), true, false, -1, 0); - } - if (WorldGen.genRand.NextBool(20)) - { - WorldGen.PlaceTile(num5, num6 - 1, (ushort)ModContent.TileType(), true, false, -1, 0); + WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); } - //colorful corals - if (WorldGen.genRand.NextBool(20)) + //anemonies + if (WorldGen.genRand.NextBool(10)) { - WorldGen.PlaceTile(num5, num6 - 1, (ushort)ModContent.TileType(), true, false, -1, 0); - } - if (WorldGen.genRand.NextBool(20)) - { - WorldGen.PlaceTile(num5, num6 - 1, (ushort)ModContent.TileType(), true, false, -1, 0); + WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); } - if (WorldGen.genRand.NextBool(20)) + //giant navystone piles + if (WorldGen.genRand.NextBool(10)) { - WorldGen.PlaceTile(num5, num6 - 1, (ushort)ModContent.TileType(), true, false, -1, 0); + ushort[] GiantPiles = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(GiantPiles)); } - if (WorldGen.genRand.NextBool(20)) + //small navystone piles + if (WorldGen.genRand.NextBool(5)) { - WorldGen.PlaceTile(num5, num6 - 1, (ushort)ModContent.TileType(), true, false, -1, 0); - } + ushort[] Piles = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(Piles)); + } + } + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { //stalactites - if (WorldGen.genRand.NextBool(15)) + if (WorldGen.genRand.NextBool(10)) { ushort[] Stalactites = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - WorldGen.PlaceObject(num5, num6 + 2, WorldGen.genRand.Next(Stalactites)); + WorldGen.PlaceObject(X, Y + 2, WorldGen.genRand.Next(Stalactites)); } - if (WorldGen.genRand.NextBool(15)) + //small stalactites + if (WorldGen.genRand.NextBool(8)) { - WorldGen.PlaceTile(num5, num6 + 1, (ushort)ModContent.TileType(), true, false, -1, 0); + WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType(), true, false, -1, 0); } //stalagmites - if (WorldGen.genRand.NextBool(10)) + if (WorldGen.genRand.NextBool(12)) { ushort[] Stalagmites = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; - WorldGen.PlaceObject(num5, num6 - 2, WorldGen.genRand.Next(Stalagmites)); + WorldGen.PlaceObject(X, Y - 2, WorldGen.genRand.Next(Stalagmites)); } + //small stalagmites if (WorldGen.genRand.NextBool(10)) { - WorldGen.PlaceTile(num5, num6 - 1, (ushort)ModContent.TileType(), true, false, -1, 0); + WorldGen.PlaceTile(X, Y - 1, (ushort)ModContent.TileType(), true, false, -1, 0); + } + + //giant navystone piles + if (WorldGen.genRand.NextBool()) + { + ushort[] GiantPiles = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(GiantPiles)); + } + + //small navystone piles + if (WorldGen.genRand.NextBool()) + { + ushort[] Piles = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(Piles)); } } - if (!tile.HasTile) + + //radiant reefs ambient tiles + if (Main.tile[X, Y].TileType == ModContent.TileType()) { - if (tile.TileType == ModContent.TileType() || tile.WallType == ModContent.WallType()) + //multi-colored corals + if (WorldGen.genRand.NextBool(3)) { - if (WorldGen.genRand.NextBool(10)) + ushort[] ColoredCorals = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(ColoredCorals)); + } + + //blue coral trees + if (WorldGen.genRand.NextBool(4)) + { + ushort[] BlueCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(BlueCorals)); + } + + //brown coral trees + if (WorldGen.genRand.NextBool(4)) + { + ushort[] BrownCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(BrownCorals)); + } + + //fan coral + if (WorldGen.genRand.NextBool(10)) + { + WorldGen.PlaceObject(X, Y - 1, (ushort)ModContent.TileType()); + } + + //misc corals + if (WorldGen.genRand.NextBool()) + { + ushort[] MiscCorals = new ushort[] { (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceObject(X, Y - 1, WorldGen.genRand.Next(MiscCorals)); + } + } + + //grow depth vines on navystone + if (Main.tile[X, Y].TileType == ModContent.TileType() && Main.tile[X, Y].Slope == 0 && !Main.tile[X, Y + 1].HasTile && !Main.tile[X, Y + 2].HasTile) + { + if (WorldGen.genRand.NextBool(7)) + { + WorldGen.PlaceTile(X, Y + 1, (ushort)ModContent.TileType()); + } + } + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + CalamityUtils.GrowVines(X, Y, WorldGen.genRand.Next(1, 4), (ushort)ModContent.TileType()); + } + + //wall corals + if (Main.tile[X, Y].TileType == ModContent.TileType()) + { + if (WorldGen.genRand.NextBool(5) && !Main.tile[X + 1, Y].HasTile) + { + ushort[] WallCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceTile(X + 2, Y, WorldGen.genRand.Next(WallCorals), true, false, -1, 0); + } + + if (WorldGen.genRand.NextBool(5) && !Main.tile[X - 1, Y].HasTile) + { + ushort[] WallCorals = new ushort[] { (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), (ushort)ModContent.TileType() }; + + WorldGen.PlaceTile(X - 2, Y, WorldGen.genRand.Next(WallCorals), true, false, -1, 0); + } + } + } + } + } + + //check if theres enough tiles to place sand below + public static bool PlaceSand(int X, int Y, int height, int tileType) + { + for (int j = Y; j <= Y + height; j++) + { + if (Main.tile[X, j].HasTile && Main.tile[X, j + 1].HasTile && Main.tile[X, j + 2].HasTile && Main.tile[X, j + 3].HasTile && + Main.tile[X - 1, j + 3].HasTile && Main.tile[X + 1, j + 3].HasTile) + { + Main.tile[X, j].TileType = (ushort)tileType; + } + else + { + return false; + } + } + + return true; + } + + //placing sea prism geodes + public static bool PlaceGeode(int X, int Y, int radius) + { + int crystalNearby = 0; + + //check a 20 by 20 square for other geodes before placing + for (int i = X - 20; i < X + 20; i++) + { + for (int j = Y - 20; j < Y + 20; j++) + { + //dont allow geodes to place if another one is too close + if (Main.tile[i, j].HasTile && Main.tile[i, j].TileType == ModContent.TileType()) + { + crystalNearby++; + if (crystalNearby > 0) + { + return false; + } + } + } + } + + ShapeData circle1 = new ShapeData(); + ShapeData circle2 = new ShapeData(); + ShapeData circle3 = new ShapeData(); + + GenAction blotchMod = new Modifiers.Blotches(2, 0.4); + + //first circle of navystone + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(radius), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle1) + })); + WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle1), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(), + new Actions.PlaceTile((ushort)ModContent.TileType()) + })); + + //second circle of prisms + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(radius - 4), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle2) + })); + WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle2), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(), + new Actions.PlaceTile((ushort)ModContent.TileType()) + })); + + //clear out the middle of the circle + WorldUtils.Gen(new Point(X, Y), new Shapes.Circle(radius - 9), Actions.Chain(new GenAction[] + { + blotchMod.Output(circle3) + })); + WorldUtils.Gen(new Point(X, Y), new ModShapes.All(circle3), Actions.Chain(new GenAction[] + { + new Actions.ClearTile(), + new Actions.SetLiquid(), + new Actions.PlaceWall((ushort)ModContent.WallType()) + })); + + return true; + } + + //method to clean up small clumps of tiles (taken from the sulphur sea generation) + public static void CleanOutSmallClumps() + { + List blockTileTypes = new() + { + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + (ushort)ModContent.TileType(), + }; + + void getAttachedPoints(int x, int y, List points) + { + Tile t = CalamityUtils.ParanoidTileRetrieval(x, y); + Point p = new(x, y); + + if (!blockTileTypes.Contains(t.TileType) || !t.HasTile || points.Count > 75 || points.Contains(p)) + { + return; + } + + points.Add(p); + + getAttachedPoints(x + 1, y, points); + getAttachedPoints(x - 1, y, points); + getAttachedPoints(x, y + 1, points); + getAttachedPoints(x, y - 1, points); + } + + for (int x = 20; x < Main.maxTilesX - 20; x++) + { + for (int y = 20; y < Main.maxTilesY - 20; y++) + { + List chunkPoints = new(); + getAttachedPoints(x, y, chunkPoints); + + int cutoffLimit = 75; + if (chunkPoints.Count >= 1 && chunkPoints.Count < cutoffLimit) + { + foreach (Point p in chunkPoints) + { + WorldUtils.Gen(p, new Shapes.Rectangle(1, 1), Actions.Chain(new GenAction[] { - WorldGen.PlaceTile(num5, num6 + 1, (ushort)ModContent.TileType(), true, false, -1, 0); - } + new Actions.ClearTile(true), + new Actions.SetLiquid() + })); } } } } } - //added this to 100% make sure the sunken sea places where it is supposed to be - static bool foundValidPosition = false; - - public static bool Place(Point origin) + //method to make sure things only generate in each biome circle + public static bool CheckInBiomeArea(Point tile, Vector2 focus1, Vector2 focus2, float distanceConstant, Vector2 center, out float distance, bool collapse = false) { - for (int y = origin.Y; y >= (int)Main.worldSurface; y--) + Vector2 point = tile.ToWorldCoordinates(); + + if (collapse) { - //check for the desert biomes walls - if (Main.tile[origin.X, y].WallType == WallID.Sandstone || Main.tile[origin.X, y].WallType == WallID.HardenedSand) - { - origin.Y = y + 50; //offset so it doesnt generate weird - foundValidPosition = true; - break; - } + float distY = center.Y - point.Y; + point.Y -= distY * 4f; } - while (foundValidPosition) - { - // 1 on Small, 1.52 on Medium, 2 on Large - float scale = Main.maxTilesX / 4200f; - // Clamp scale to prevent problems on extra large worlds - scale = MathHelper.Clamp(scale, 1f, 2f); + float distance1 = Vector2.Distance(point, focus1); + float distance2 = Vector2.Distance(point, focus2); + distance = distance1 + distance2; - // 80 on Small, 121.6 on Medium, 160 on Large - int sunkenSeaAreaX = (int)(80f * scale); - // 84-102 on Small, 127.68-155.04 on Medium, 168-204 on Large - float baseVerticalSize = 60f * scale; - float verticalScaleFactor = 1.4f + WorldGen.genRand.NextFloat(0.3f); - int sunkenSeaAreaY = (int)(verticalScaleFactor * baseVerticalSize); - - // What the fuck is this and why is it used everywhere - // As far as I can tell, this just scales up the entire Sunken Sea to be 4x wider and 2x taller than what is listed above - Vector2 arbitrary42GodVector = new Vector2(4f, 2f); - - // Place the majority of the terrain as clusters - ClusterGroup clusterGroup = new ClusterGroup(); - clusterGroup.Generate(sunkenSeaAreaX, sunkenSeaAreaY); - PlaceClusters(clusterGroup, origin, arbitrary42GodVector); - - // Place Geodes - AddGeodes(clusterGroup, origin, arbitrary42GodVector, scale); - - // Re-frame everything in some arbitrary radius - int totalWidth = (int)(arbitrary42GodVector.X * clusterGroup.Width); - int totalHeight = (int)(arbitrary42GodVector.Y * clusterGroup.Height); - int frameExcessRadius = 40; - for (int i = -frameExcessRadius; i < totalWidth + frameExcessRadius; i++) - { - for (int j = -frameExcessRadius; j < totalHeight + frameExcessRadius; j++) - { - if (i + origin.X > 0 && i + origin.X < Main.maxTilesX - 1 && j + origin.Y > 0 && j + origin.Y < Main.maxTilesY - 1) - { - WorldGen.SquareWallFrame(i + origin.X, j + origin.Y, true); - WorldUtils.TileFrame(i + origin.X, j + origin.Y, true); - Tile.SmoothSlope(i + origin.X, j + origin.Y, true); - } - } - } - - // Add Tile Variance (sand, crystals, etc.) - AddTileVariance(clusterGroup, origin, arbitrary42GodVector, scale); - - return true; - } - - return false; + return distance <= distanceConstant; } - - /* - public static void PlaceTit(int x, int y, ushort type = 165) - { - if (WorldGen.SolidTile(x, y - 1) && !Main.tile[x, y].HasTile && !Main.tile[x, y + 1].HasTile) - { - if (Main.tile[x, y - 1].TileType == (ushort)ModContent.TileType()) - { - if (WorldGen.genRand.Next(2) == 0 || Main.tile[x, y + 2].HasTile) - { - int num2 = WorldGen.genRand.Next(3) * 18; - Main.tile[x, y].TileType = type; - Main.tile[x, y].Get().HasTile = true; - Main.tile[x, y].TileFrameX = (short)num2; - Main.tile[x, y].TileFrameY = 72; - } - else - { - int num3 = WorldGen.genRand.Next(3) * 18; - Main.tile[x, y].TileType = type; - Main.tile[x, y].Get().HasTile = true; - Main.tile[x, y].TileFrameX = (short)num3; - Main.tile[x, y].TileFrameY = 0; - Main.tile[x, y + 1].TileType = type; - Main.tile[x, y + 1].Get().HasTile = true; - Main.tile[x, y + 1].TileFrameX = (short)num3; - Main.tile[x, y + 1].TileFrameY = 18; - } - } - } - else - { - if (WorldGen.SolidTile(x, y + 1) && !Main.tile[x, y].HasTile && !Main.tile[x, y - 1].HasTile) - { - if (Main.tile[x, y + 1].TileType == (ushort)ModContent.TileType()) - { - if (WorldGen.genRand.Next(2) == 0 || Main.tile[x, y - 2].HasTile) - { - int num13 = WorldGen.genRand.Next(3) * 18; - Main.tile[x, y].TileType = type; - Main.tile[x, y].Get().HasTile = true; - Main.tile[x, y].TileFrameX = (short)num13; - Main.tile[x, y].TileFrameY = 90; - } - else - { - int num14 = WorldGen.genRand.Next(3) * 18; - Main.tile[x, y - 1].TileType = type; - Main.tile[x, y - 1].Get().HasTile = true; - Main.tile[x, y - 1].TileFrameX = (short)num14; - Main.tile[x, y - 1].TileFrameY = 36; - Main.tile[x, y].TileType = type; - Main.tile[x, y].Get().HasTile = true; - Main.tile[x, y].TileFrameX = (short)num14; - Main.tile[x, y].TileFrameY = 54; - } - } - } - } - } - */ } } diff --git a/build.txt b/build.txt index f6d015e792..cf9028fcf7 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = Fabsol and the Dev Team -version = 2.0.4.001 +version = 2.0.4.003 displayName = Calamity Mod modReferences = CalamityModMusic homepage = https://discord.gg/calamity