diff --git a/Buffs/StatDebuffs/DoGExtremeGravity.cs b/Buffs/StatDebuffs/DoGExtremeGravity.cs index dff7c395f3..1e72478486 100644 --- a/Buffs/StatDebuffs/DoGExtremeGravity.cs +++ b/Buffs/StatDebuffs/DoGExtremeGravity.cs @@ -1,4 +1,6 @@ -using Terraria; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -23,6 +25,18 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(Player player, ref int buffIndex) { player.Calamity().DoGExtremeGravity = true; + if (player.miscCounter % 10 == 0) + { + float halfWidth = player.width * 0.5f; + float halfHeight = player.height * 0.5f; + for (var i = 0; i < 1; i++) + { + var position = player.Center + new Vector2(Main.rand.NextFloat(-halfWidth, halfWidth), Main.rand.NextFloat(-halfHeight, halfHeight)); + Particle arrow = new StatChangeArrow(position, -(Vector2.UnitY * 5).RotatedByRandom(1f), MathHelper.PiOver2, Color.Fuchsia, Color.Fuchsia * 0f, 0.75f, 60); + ((StatChangeArrow)arrow).AffectedByGravity = true; + GeneralParticleHandler.SpawnParticle(arrow); + } + } } } } diff --git a/Buffs/StatDebuffs/Warped.cs b/Buffs/StatDebuffs/Warped.cs index fe16e114cf..56314f3682 100644 --- a/Buffs/StatDebuffs/Warped.cs +++ b/Buffs/StatDebuffs/Warped.cs @@ -1,4 +1,6 @@ -using Terraria; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -18,6 +20,18 @@ namespace CalamityMod.Buffs.StatDebuffs public override void Update(Player player, ref int buffIndex) { player.Calamity().warped = true; + if (player.miscCounter % 10 == 0) + { + float halfWidth = player.width * 0.5f; + float halfHeight = player.height * 0.5f; + for (var i = 0; i < 1; i++) + { + var position = player.Center + new Vector2(Main.rand.NextFloat(-halfWidth, halfWidth), Main.rand.NextFloat(-halfHeight, halfHeight)); + Particle arrow = new StatChangeArrow(position, -(Vector2.UnitY * 5).RotatedByRandom(1f), -MathHelper.PiOver2, Color.Cyan, Color.Cyan * 0f, 0.75f, 60); + ((StatChangeArrow)arrow).AffectedByGravity = true; + GeneralParticleHandler.SpawnParticle(arrow); + } + } } } } diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 8c9c0c7913..420c711fa9 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -194,6 +194,10 @@ namespace CalamityMod.CalPlayer public FishingMinigames SelectedFishingMinigame = FishingMinigames.None; public bool countsAsAnyWet => (Player.armor[0].type == ItemID.FishBowl || Player.wetCount > 0 || Player.wet || Player.honeyWet || Player.lavaWet); + public CombatText subtitletext = null; + public Color[] subtitleColors = new Color[] { Color.White, Color.White }; + public int DoGHeadHitCounter = 0; + public StatModifier TypelessDebuffMultiplier = new(); public StatModifier HeatDebuffMultiplier = new(); public StatModifier ColdDebuffMultiplier = new(); @@ -2011,6 +2015,10 @@ namespace CalamityMod.CalPlayer #region ResetEffects public override void ResetEffects() { + if (!areThereAnyDamnBosses) + { + DoGHeadHitCounter = 0; + } ViridVanguardActiveAttackerThisFrame = Main.projectile.Any(x => x.active && x.type == ModContent.ProjectileType() && x.owner == Player.whoAmI && x.ModProjectile().CurrentState == ViridVanguardBlade.ViridVanguardAIState.PhotonRipperZenithSlashes); ViridVanguardRotation = MathHelper.WrapAngle(ViridVanguardRotation + ViridVanguardRotationToAdd); ViridVanguardRotationToAdd = ViridVanguard.IdleCirclingSpeed; @@ -4512,6 +4520,20 @@ namespace CalamityMod.CalPlayer public override void PostUpdate() { + + if (subtitletext != null) + { + if (!subtitletext.active) + { + subtitletext = null; + } + else + { + subtitletext.position = Player.Center + new Vector2(-FontAssets.CombatText[subtitletext.crit ? 1 : 0].Value.MeasureString(subtitletext.text).X * 0.5f, 64); + subtitletext.color = Color.Lerp(subtitleColors[1], subtitleColors[0], subtitletext.lifeTime / 120f); + } + } + #region Managing time control if (Main.netMode != NetmodeID.Server && Player == Main.LocalPlayer) { diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index 3088a7dd21..ea3e75376b 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; @@ -7,6 +8,7 @@ using CalamityMod.CalPlayer.DrawLayers; using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.NPCs.DevourerofGods; using CalamityMod.Particles; using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems.Collections; @@ -65,6 +67,40 @@ namespace CalamityMod.CalPlayer CalamityPlayer calamityPlayer = Player.Calamity(); + //DoG Boss Cursor + DevourerofGodsHead DoG = null; + foreach (var item in Main.ActiveNPCs) + { + if (item.type == ModContent.NPCType()) { + DoG = item.ModNPC(); + break; + } + } + if (DoG != null && Main.mapStyle != 2) + { + Rectangle screen = new((int)Main.screenPosition.X, (int)Main.screenPosition.Y, Main.screenWidth, Main.screenHeight); + var rift = DoG.GetRiftLocation(); + if (rift != Vector2.Zero && !Main.zenithWorld) + { + var dist = Player.Distance(rift); + var tex = ModContent.Request("Terraria/Images/Extra_173").Value; + float scale = 1f; + Main.spriteBatch.Draw(tex, Player.Center + Player.DirectionTo(rift) * 196 * Math.Min(dist / 2400f, 2) - Main.screenPosition, null, Color.White * 0.9f * Math.Clamp(MathHelper.Lerp(0, 1, (dist - 300) / 600), 0, 1), 0, tex.Size() / 2f, scale * 0.9f, SpriteEffects.FlipHorizontally, 0); + } + else + { + var dis = Player.Distance(DoG.NPC.Center); + if ((DoG.NPC.ai[3] < 3 || !DoG.Phase2Started) && DoG.NPC.Opacity > 0.5f && !DoG.Dying) + { + string phase1IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead_Head_Boss"; + string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead_P2_Head_Boss"; + var tex = ModContent.Request((DoG.Phase2Started && DoG.NPC.localAI[2] < 300) ? phase2IconPath : phase1IconPath).Value; + Main.spriteBatch.Draw(tex, Player.Center + Player.DirectionTo(DoG.NPC.Center) * 196 * Math.Min(dis / 2400f, 2) - Main.screenPosition, null, Color.White * 0.9f * Math.Clamp(MathHelper.Lerp(0, 1, (dis - 600) / 300), 0, 1), DoG.NPC.rotation, tex.Size() / 2f, 1, SpriteEffects.None, 0); + } + } + + } + // Dust modifications while high. if (calamityPlayer.trippy) { diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index c2693cb4c4..120b127d3e 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -36,6 +36,7 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.NPCs; using CalamityMod.NPCs.Cryogen; +using CalamityMod.NPCs.DevourerofGods; using CalamityMod.NPCs.Other; using CalamityMod.NPCs.ProfanedGuardians; using CalamityMod.NPCs.Providence; @@ -510,6 +511,24 @@ namespace CalamityMod.CalPlayer damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.Norfleet").ToNetworkText(Player.name)); NorfleetCounter = 0; + if (damageSource.TryGetCausingEntity(out var Entity) && Entity is NPC && (Entity as NPC).type == ModContent.NPCType()) + { + var npc = Main.npc[damageSource.SourceNPCIndex]; + if (npc.ai[3] < 2) //Divinity Devourer + { + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.DivinityDevourer"+Main.rand.Next(1,4)).ToNetworkText(Player.name)); + } + else if (npc.ai[3] >= 3) + if (npc.life > npc.lifeMax / 4) //Dimensional Drive + { + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.DimensionalDrive").ToNetworkText(Player.name)); + } + else //Ultracosmic Maelstrom + { + damageSource = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.UltracosmicMaelstrom" + Main.rand.Next(1, 3)).ToNetworkText(Player.name)); + } + } + if (NPC.AnyNPCs(ModContent.NPCType())) { if (sCalDeathCount < 51) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index f13aad2cdd..f2b3cace1c 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -3769,7 +3769,7 @@ namespace CalamityMod.CalPlayer if ((warped || caribbeanRum) && !Player.slowFall && !Player.mount.Active) { - float velocityYMultiplier = (warped && Main.getGoodWorld) ? 1.02f : 1.01f; + float velocityYMultiplier = 1.01f; Player.velocity.Y *= velocityYMultiplier; } diff --git a/CalamityConfig.cs b/CalamityConfig.cs index 2145c5bca2..a135ce2a79 100644 --- a/CalamityConfig.cs +++ b/CalamityConfig.cs @@ -55,6 +55,10 @@ namespace CalamityMod [DefaultValue(true)] public bool SunkenSeaBackgroundDistortion { get; set; } + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + public bool FancyBackgroundVisuals { get; set; } + private const int MinParticleLimit = 500; private const int MaxParticleLimit = 10000; diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 285d9cc62f..83d6559fb6 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -225,6 +225,22 @@ namespace CalamityMod.Effects // The underwater rays seen at the top of the Sunken Sea Mod Menu. internal static Effect UnderwaterRaysShader; + + // The blowing wind-like effect seen in the background during DoG's fight. + internal static Effect DoGDistortionWindsShader; + + // The rolling fog clouds seen behind the Distortion Winds effect during DoG's fight. + internal static Effect DoGBackgroundFogShader; + + // Allows a texture to control its opacity from the edges to the center in the shape of a circle. + internal static Effect CircularOpacityShader; + + // The shader effect imposed onto the static crack textures seen during DoG's fight. Fades out the texture from its edges to its center and + // allows it to lerp between two colors depending on the brightness of individual pixels along the sampled texture. + internal static Effect DoGRealityCrackShader; + + // The distorted circular effect seen emanating from the distortion rift during DoG's fight. + internal static Effect DoGRiftAuraShader; #endregion internal static Asset SunkenSeaMenuLogoWater; @@ -450,6 +466,21 @@ namespace CalamityMod.Effects UnderwaterRaysShader = LoadShader("UnderwaterRaysShader"); RegisterMiscShader(UnderwaterRaysShader, "UnderwaterRayPass", "UnderwaterRays"); + + DoGDistortionWindsShader = LoadShader("DoGDistortionWindsShader"); + RegisterMiscShader(DoGDistortionWindsShader, "DistortionWindsPass", "DoGDistortionWinds"); + + DoGBackgroundFogShader = LoadShader("DoGBackgroundFogShader"); + RegisterMiscShader(DoGBackgroundFogShader, "DoGFogPass", "DoGBackgroundFog"); + + CircularOpacityShader = LoadShader("CircularOpacityShader"); + RegisterMiscShader(CircularOpacityShader, "CircularOpacityPass", "CircularOpacity"); + + DoGRealityCrackShader = LoadShader("DoGRealityCrackShader"); + RegisterMiscShader(DoGRealityCrackShader, "DoGRealityCrackPass", "DoGRealityCrack"); + + DoGRiftAuraShader = LoadShader("DoGRiftAuraShader"); + RegisterMiscShader(DoGRiftAuraShader, "DoGRiftAuraPass", "DoGRiftAura"); #endregion SunkenSeaMenuLogoWater = LoadShaderAsset("UI/SunkenSeaMenuLogoWater"); diff --git a/Effects/CircularOpacityShader.fx b/Effects/CircularOpacityShader.fx new file mode 100644 index 0000000000..64ca9b6163 --- /dev/null +++ b/Effects/CircularOpacityShader.fx @@ -0,0 +1,32 @@ +sampler baseTexture : register(s0); + +float opacityCutoffValue; +float fadeoutPower; +float overallOpacity; + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Convert the regular coordinates to polar coordinates to get a circle shape. + float2 centeredCoords = coords - 0.5; + float polarAngle = atan2(centeredCoords.y, centeredCoords.x) / 6.283; + float distanceToCenter = length(centeredCoords); + + float2 polarCoords = float2(polarAngle, distanceToCenter); + float4 color = tex2D(baseTexture, coords); + + // Fade out from the edges of the texture to the middle depending on the cutoff value. + // "fadeoutPower" values which vary from 1 will affect how strong the edges fade while also increasing the brightness of + // the non-faded parts of the image to the middle. Use this wisely. + if (-polarCoords.y < opacityCutoffValue) + color.rgba *= pow(-polarCoords.y / (polarCoords.y - opacityCutoffValue), -fadeoutPower); + + return color * sampleColor * overallOpacity; +} + +technique Technique1 +{ + pass CircularOpacityPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/CircularOpacityShader.xnb b/Effects/CircularOpacityShader.xnb new file mode 100644 index 0000000000..143430cf37 Binary files /dev/null and b/Effects/CircularOpacityShader.xnb differ diff --git a/Effects/DoGBackgroundFogShader.fx b/Effects/DoGBackgroundFogShader.fx new file mode 100644 index 0000000000..898dcfd1be --- /dev/null +++ b/Effects/DoGBackgroundFogShader.fx @@ -0,0 +1,67 @@ +sampler cloudsTexture : register(s0); +sampler distortionTexture : register(s1); +sampler erosionTexture : register(s2); + +float time; +float overallOpacity; +float distortionStrength; +float mainNoiseTextureScale; +float distortionTextureScale; +float erosionTextureScale; +float erosionMin; +float gradientPrecision; + +float2 pixelationFactor; +float2 worldOffset; + +float3 darkerPixelColor; +float3 brighterPixelColor; + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Pixelation. + coords = round(coords * pixelationFactor) / pixelationFactor; + + // Stretch the coords out to better mimic a blowing wind effect. + coords *= float2(0.95, 1.05); + + // Move with the player in the world. + coords += worldOffset; + + // Calculate the distortion that'll be applied to our base noise coordinates. + float2 distortedCoords = coords + float2(time * -0.03, time * -0.01) * distortionTextureScale; + float distortion = tex2D(distortionTexture, distortedCoords).r * distortionStrength; + + // Calculate the base noise colors. + float2 adjustedCoords = (coords + distortion) * mainNoiseTextureScale; + float4 scrollingNoise1 = tex2D(cloudsTexture, adjustedCoords + float2(time * -0.065, 0)); + float4 scrollingNoise2 = tex2D(cloudsTexture, adjustedCoords + float2(time * -0.015, 0)); + + // Multiply the red values of the noise maps together to get the horizontal brightness of both noise maps. + float combinedBrightness = scrollingNoise1.r * scrollingNoise2.r; + + // Lerp between the two colors based on the brightness of a pixel. + float3 colorFromBrightness = lerp(darkerPixelColor, brighterPixelColor, combinedBrightness); + + // Erode the final output to break up the entire effect slightly. + float erosionColor = tex2D(erosionTexture, adjustedCoords + float2(time * -0.07, time * -0.02) * erosionTextureScale); + float erosionMax = erosionMin + 1; + float erosion = smoothstep(erosionMin, erosionMax, erosionColor.r); + + float4 finalColor = (float4(colorFromBrightness, 1) * (scrollingNoise1 + scrollingNoise2)); + finalColor *= erosion; + + // Apply posterization. + finalColor = round(finalColor * gradientPrecision) / gradientPrecision; + + return finalColor * overallOpacity; + +} + +technique Technique1 +{ + pass DoGFogPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/DoGBackgroundFogShader.xnb b/Effects/DoGBackgroundFogShader.xnb new file mode 100644 index 0000000000..55719fcf22 Binary files /dev/null and b/Effects/DoGBackgroundFogShader.xnb differ diff --git a/Effects/DoGDisintegration.fx b/Effects/DoGDisintegration.fx index 7473ea481a..3e0f61e541 100644 --- a/Effects/DoGDisintegration.fx +++ b/Effects/DoGDisintegration.fx @@ -1,39 +1,35 @@ -sampler uImage0 : register(s0); -sampler uImage1 : register(s1); -float3 uColor; -float3 uSecondaryColor; -float uOpacity : register(C0); -float uSaturation; -float uRotation; -float uTime; -float4 uSourceRect; -float2 uWorldPosition; -float uDirection; -float3 uLightSource; -float2 uImageSize0; -float2 uImageSize1; -float4 uShaderSpecificData; +sampler baseTexture : register(s0); +sampler disintegrationTexture : register(s1); + +float disintegrationProgress : register(C0); +float disintegrationScale; +float2 worldPosition; +float2 pixelSize; // This shader is largely based on code used for ExampleMod's cool death animation thing; it is suprisingly useful for this use case. float4 PixelShaderFunction(float2 coords : TEXCOORD0) : COLOR0 { - float4 color = tex2D(uImage0, coords); + float4 color = tex2D(baseTexture, coords); if (!any(color)) return color; - float fade = pow(saturate(1 - uOpacity), 0.7); - float4 color1 = tex2D(uImage1, float2(coords.x, frac(coords.y + uSaturation * 0.11)) * 0.3); + coords += worldPosition; + coords = round(coords * pixelSize) / pixelSize; + + float disintegration = pow(saturate(1 - disintegrationProgress), 0.7); + float2 disintegrationCoords = coords * disintegrationScale; + float4 disintegrationColor = tex2D(disintegrationTexture, disintegrationCoords); - float readRed = fade * 1.05; - - if (color1.r > readRed) + float disappearThreshold = disintegration * 1.05; + if (disintegrationColor.r > disappearThreshold) { color.rgba = 0; } - else if (color1.b > fade) + else if (disintegrationColor.b > disintegration) { color = float4(1, 105.0 / 255, 180.0 / 255, 1); } + return color; } @@ -41,6 +37,6 @@ technique Technique1 { pass DisintegrationPass { - PixelShader = compile ps_2_0 PixelShaderFunction(); + PixelShader = compile ps_3_0 PixelShaderFunction(); } } \ No newline at end of file diff --git a/Effects/DoGDisintegration.xnb b/Effects/DoGDisintegration.xnb index bbc4f237f3..a841c844da 100644 Binary files a/Effects/DoGDisintegration.xnb and b/Effects/DoGDisintegration.xnb differ diff --git a/Effects/DoGDistortionWindsShader.fx b/Effects/DoGDistortionWindsShader.fx new file mode 100644 index 0000000000..85270ead68 --- /dev/null +++ b/Effects/DoGDistortionWindsShader.fx @@ -0,0 +1,76 @@ +sampler mainWindTexture : register(s0); +sampler windHighlightsTexture : register(s1); +sampler distortionTexture : register(s2); +sampler erosionTexture : register(s3); + +float time; +float overallOpacity; +float distortionStrength; +float mainNoiseTextureScale; +float distortionTextureScale; +float erosionTextureScale; +float erosionMin; +float gradientPrecision; + +float2 pixelationFactor; +float2 worldOffset; + +float3 darkerPixelColor; +float3 brighterPixelColor; +float3 highlightsColor; + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Pixelation. + coords = round(coords * pixelationFactor) / pixelationFactor; + + // Stretch the coords out to better mimic a blowing wind effect. + coords *= float2(0.25, 1.25); + + // Distort the coords in a sine wave so that they bend up and down. + coords.y += sin(coords.x * 10 + time) * 0.25; + + // Move with the player in the world. + coords += worldOffset; + + // Calculate the distortion that'll be applied to our base noise coordinates. + float2 distortedCoords = coords + float2(time * -0.18, 0) * distortionTextureScale; + float distortion = tex2D(distortionTexture, distortedCoords).r * distortionStrength; + + // Calculate the base noise colors. + float2 adjustedCoords = (coords + distortion) * mainNoiseTextureScale; + float4 scrollingNoise1 = tex2D(mainWindTexture, adjustedCoords + float2(time * -0.092, 0)); + float4 scrollingNoise2 = tex2D(mainWindTexture, adjustedCoords + float2(time * -0.031, 0)); + + // Multiply the red values of the noise maps together to get the horizontal brightness of both noise maps. + float combinedBrightness = scrollingNoise1.r * scrollingNoise2.r; + + // Lerp between the two colors based on the brightness of a pixel. + float3 colorFromBrightness = lerp(darkerPixelColor, brighterPixelColor, combinedBrightness); + + // Sample another texture to be used as highlights alongside the two noise textures. + float4 highlightNoise = tex2D(windHighlightsTexture, adjustedCoords + float2(time * -0.115, 0)); + float4 windHighlights = highlightNoise * float4(highlightsColor, 1); + + // Erode the final output to break up the entire effect slightly. + float erosionColor = tex2D(erosionTexture, adjustedCoords + float2(time * -0.087, 0) * erosionTextureScale); + float erosionMax = erosionMin + 1; + float erosion = smoothstep(erosionMin, erosionMax, erosionColor.r); + + float4 finalColor = (float4(colorFromBrightness, 1) * (scrollingNoise1 + scrollingNoise2)) + (windHighlights * 2.25); + finalColor *= erosion; + + // Apply posterization. + finalColor = round(finalColor * gradientPrecision) / gradientPrecision; + + return finalColor * overallOpacity; + +} + +technique Technique1 +{ + pass DistortionWindsPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/DoGDistortionWindsShader.xnb b/Effects/DoGDistortionWindsShader.xnb new file mode 100644 index 0000000000..d28e773884 Binary files /dev/null and b/Effects/DoGDistortionWindsShader.xnb differ diff --git a/Effects/DoGRealityCrackShader.fx b/Effects/DoGRealityCrackShader.fx new file mode 100644 index 0000000000..2c9f7b0c28 --- /dev/null +++ b/Effects/DoGRealityCrackShader.fx @@ -0,0 +1,54 @@ +sampler baseTexture : register(s0); + +float overallOpacity; +float opacityCutoffValue; +float fadeoutPower; +float minBrightnessValue; +float gradientPrecision; + +float3 brighterPixelColor; +float3 darkerPixelColor; + +float InverseLerp(float from, float to, float value) +{ + return (value - from) / (to - from); +} + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Convert the regular coordinates to polar coordinates to get a circle shape. + float2 centeredCoords = coords - 0.5; + float polarAngle = atan2(centeredCoords.y, centeredCoords.x) / 6.283; + float distanceToCenter = length(centeredCoords); + + float2 polarCoords = float2(polarAngle, distanceToCenter); + float4 color = tex2D(baseTexture, coords); + + // Get the horizontal brightness of the sampled texture and apply coloration. + float brightness = (color.r + color.g + color.b) / 3; + float brightnessRatio = InverseLerp(minBrightnessValue, 1, brightness); + float3 colorFromBrightness = lerp(darkerPixelColor, brighterPixelColor, brightnessRatio); + + float4 coloredSample = color * float4(colorFromBrightness, 1); + + // Fade out from the edges of the texture to the middle depending on the cutoff value. + // "fadeoutPower" values which vary from 1 will affect how strong the edges fade while also increasing the brightness of + // the non-faded parts of the image to the middle. Use this wisely. + if (-polarCoords.y < opacityCutoffValue) + coloredSample.rgba *= pow(-polarCoords.y / (polarCoords.y - opacityCutoffValue), -fadeoutPower); + + // Apply optional posterization. + /*if (gradientPrecision > 0) + finalColor = round(finalColor * gradientPrecision) / gradientPrecision; + */ + return coloredSample * sampleColor * overallOpacity; +} + +technique Technique1 +{ + pass DoGRealityCrackPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} + diff --git a/Effects/DoGRealityCrackShader.xnb b/Effects/DoGRealityCrackShader.xnb new file mode 100644 index 0000000000..fb989a9310 Binary files /dev/null and b/Effects/DoGRealityCrackShader.xnb differ diff --git a/Effects/DoGRiftAuraShader.fx b/Effects/DoGRiftAuraShader.fx new file mode 100644 index 0000000000..6d6439cf93 --- /dev/null +++ b/Effects/DoGRiftAuraShader.fx @@ -0,0 +1,62 @@ +sampler baseTexture : register(s0); +sampler distortionTexture : register(s1); + +float time; +float overallOpacity; +float distortionStrength; +float opacityCutoffValue; +float fadeoutPower; +float minBrightnessValue; +float gradientPrecision; +float2 pixelSize; +float3 brighterPixelColor; + +float InverseLerp(float from, float to, float value) +{ + return (value - from) / (to - from); +} + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Pixelate. + coords = round(coords * pixelSize) / pixelSize; + + // Convert the regular coordinates to polar coordinates to get a circle shape. + float2 centeredCoords = coords - 0.5; + float polarAngle = atan2(centeredCoords.y, centeredCoords.x) / 6.283; + float distanceToCenter = length(centeredCoords); + float2 polarCoords = float2(polarAngle, distanceToCenter); + + // Apply distortion to the main texture. + float distortion = tex2D(distortionTexture, polarCoords + float2(time * 0.017, time * -0.026)).r * distortionStrength; + float2 baseCoords = coords * distortion; + baseCoords *= 0.4; + float4 color = tex2D(baseTexture, baseCoords); + + // Get the horizontal brightness of the sampled texture and apply coloration. + float brightness = (color.r + color.g + color.b) / 3; + float brightnessRatio = InverseLerp(minBrightnessValue, 1, brightness); + float3 colorFromBrightness = lerp(float3(0, 0, 0), brighterPixelColor, brightnessRatio); + + float4 coloredSample = color * float4(colorFromBrightness, 1); + + // Fade out from the edges of the texture to the middle depending on the cutoff value. + // "fadeoutPower" values which vary from 1 will affect how strong the edges fade while also increasing/decreasing the brightness of + // the non-faded parts of the image to the middle. Use this wisely. + if (-polarCoords.y < opacityCutoffValue) + coloredSample.rgba *= pow(-polarCoords.y / (polarCoords.y - opacityCutoffValue), -fadeoutPower); + + // Apply optional posterization. + if (gradientPrecision > 0) + coloredSample = round(coloredSample * gradientPrecision) / gradientPrecision; + + return coloredSample * sampleColor * overallOpacity; +} + +technique Technique1 +{ + pass DoGRiftAuraPass + { + PixelShader = compile ps_3_0 PixelShaderFunction(); + } +} diff --git a/Effects/DoGRiftAuraShader.xnb b/Effects/DoGRiftAuraShader.xnb new file mode 100644 index 0000000000..1042c87024 Binary files /dev/null and b/Effects/DoGRiftAuraShader.xnb differ diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index 66689a2269..af1924434d 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -373,7 +373,7 @@ namespace CalamityMod.Events SoundEngine.PlaySound(DevourerofGodsHead.SpawnSound, player.Center); NPC.SpawnOnPlayer(ClosestPlayerToWorldCenter, type); - }, usesSpecialSound: true, permittedNPCs: new int[] { ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }), + }, usesSpecialSound: true, permittedNPCs: new int[] { ModContent.NPCType(), ModContent.NPCType() }), new Boss(ModContent.NPCType(), spawnContext: type => { diff --git a/ExtraTextures/CrackedGlass_Glowing.png b/ExtraTextures/CrackedGlass_Glowing.png new file mode 100644 index 0000000000..82f6aef934 Binary files /dev/null and b/ExtraTextures/CrackedGlass_Glowing.png differ diff --git a/ExtraTextures/GreyscaleGradients/RealisticClouds.png b/ExtraTextures/GreyscaleGradients/RealisticClouds.png new file mode 100644 index 0000000000..cb1edf311b Binary files /dev/null and b/ExtraTextures/GreyscaleGradients/RealisticClouds.png differ diff --git a/Graphics/Metaballs/DoGDistortionMetaball.cs b/Graphics/Metaballs/DoGDistortionMetaball.cs new file mode 100644 index 0000000000..173b2430ea --- /dev/null +++ b/Graphics/Metaballs/DoGDistortionMetaball.cs @@ -0,0 +1,106 @@ +using System.Collections.Generic; +using CalamityMod.Effects; +using CalamityMod.Projectiles.Boss; +using CalamityMod.Systems.Graphic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class DoGDistortionMetaball : Metaball + { + public class DistortionParticle(Vector2 center, Vector2 velocity, float size, bool square = false, float rotation = 0f) + { + public Vector2 Center = center; + + public Vector2 Velocity = velocity; + + public float Size = size; + + public bool Square = square; + + public float Rotation = rotation; + + public void Update() + { + Center += Velocity; + Velocity *= 0.96f; + Size *= 0.91f; + } + } + + public static List Particles { get; private set; } = []; + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override bool AnythingToDraw => Particles.Count > 0 || CalamityUtils.AnyProjectiles(ModContent.ProjectileType()); + + public override Color EdgeColor => new(136, 26, 186); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public static void SpawnParticle(Vector2 position, Vector2 velocity, float size, bool square = false, float rotation = 0f) => + Particles.Add(new(position, velocity, size, square, rotation)); + + public override void Update() + { + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + public override void PrepareShaderForTarget(int layerIndex) + { + var metaballShader = CalamityShaders.MetaballEdgeShader; + var gd = Main.instance.GraphicsDevice; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Vector2 layerScrollOffset = Main.screenPosition / screenSize + CalculateManualOffsetForLayer(layerIndex); + if (FixedToScreen) + layerScrollOffset = Vector2.Zero; + + metaballShader.Parameters["layerSize"]?.SetValue(DoGVisualsManager.DistortionForegroundContentsTarget.Target.Size()); + metaballShader.Parameters["screenSize"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(layerScrollOffset); + metaballShader.Parameters["edgeColor"]?.SetValue(EdgeColor.ToVector4()); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue((Main.screenLastPosition - Main.screenPosition) / screenSize); + + gd.Textures[1] = DoGVisualsManager.DistortionForegroundContentsTarget; + gd.SamplerStates[1] = SamplerState.LinearWrap; + + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public override void DrawInstances() + { + Texture2D metaballTexture = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + Texture2D squareTexture = ModContent.Request("CalamityMod/Particles/Square").Value; + + foreach (DistortionParticle particle in Particles) + { + Texture2D textureToUse = particle.Square ? squareTexture : metaballTexture; + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = textureToUse.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / textureToUse.Size(); + Main.spriteBatch.Draw(textureToUse, drawPosition, null, Color.White, particle.Rotation, origin, scale, SpriteEffects.None, 0f); + } + + foreach (Projectile proj in Main.ActiveProjectiles) + { + if (proj.type == ModContent.ProjectileType()) + { + Color lightColor = Color.White; + proj.ModProjectile.PreDraw(ref lightColor); + } + } + } + } +} diff --git a/Graphics/Primitives/PrimitiveRenderer.cs b/Graphics/Primitives/PrimitiveRenderer.cs index 66fa36a79d..2fcc1b9acf 100644 --- a/Graphics/Primitives/PrimitiveRenderer.cs +++ b/Graphics/Primitives/PrimitiveRenderer.cs @@ -125,7 +125,7 @@ namespace CalamityMod.Graphics.Primitives Matrix view; Matrix projection; - if (MainSettings.Pixelate) + if (MainSettings.Pixelate || MainSettings.UseUnscaledMatrices) CalcuatePixelatedPerspectiveMatrices(out view, out projection); else CalamityUtils.CalculatePerspectiveMatricies(out view, out projection); diff --git a/Graphics/Primitives/PrimitiveSettings.cs b/Graphics/Primitives/PrimitiveSettings.cs index bbee27c4a7..21ade8e9ca 100644 --- a/Graphics/Primitives/PrimitiveSettings.cs +++ b/Graphics/Primitives/PrimitiveSettings.cs @@ -57,6 +57,12 @@ namespace CalamityMod.Graphics.Primitives /// public readonly bool Pixelate; + /// + /// Whether to use unscaled perspective matrices when rendering the primitives. Recommended only when the system is being used outside of its typical context + /// i.e. rendering primitives in the background via a CustomSky. + /// + public readonly bool UseUnscaledMatrices; + /// /// The shader to apply when rendering. /// @@ -77,8 +83,9 @@ namespace CalamityMod.Graphics.Primitives /// Whether to use smoothening when generating the vertex positions from the provided ones. Recommended to be enabled. /// Whether to pixelate the primitives. Recommended to be enabled if the effect was designed with this in mind. /// The shader to apply when rendering the primitives. + /// Whether to use unscaled perspective matrices when rendering primitives. Recommended when using this system outside of its typical context; i.e. rendering primitives in the background via a CustomSky. /// An optional override to force the trail to use the provided positions as the side positions of the initial vertex. They are the left and right positions respectively and should be in screen space. - public PrimitiveSettings(VertexWidthFunction widthFunction, VertexColorFunction colorFunction, VertexOffsetFunction offsetFunction = null, bool smoothen = true, bool pixelate = false, MiscShaderData shader = null, (Vector2, Vector2)? initialVertexPositionsOverride = null) + public PrimitiveSettings(VertexWidthFunction widthFunction, VertexColorFunction colorFunction, VertexOffsetFunction offsetFunction = null, bool smoothen = true, bool pixelate = false, MiscShaderData shader = null, bool useUnscaledMatrices = false, (Vector2, Vector2)? initialVertexPositionsOverride = null) { WidthFunction = widthFunction; ColorFunction = colorFunction; @@ -86,6 +93,7 @@ namespace CalamityMod.Graphics.Primitives Smoothen = smoothen; Pixelate = pixelate; Shader = shader; + UseUnscaledMatrices = useUnscaledMatrices; InitialVertexPositionsOverride = initialVertexPositionsOverride; } } diff --git a/Graphics/Renderers/CalamityRenderers/DoGDeathAnimationRenderer.cs b/Graphics/Renderers/CalamityRenderers/DoGDeathAnimationRenderer.cs new file mode 100644 index 0000000000..a2205f9256 --- /dev/null +++ b/Graphics/Renderers/CalamityRenderers/DoGDeathAnimationRenderer.cs @@ -0,0 +1,110 @@ +using CalamityMod.NPCs; +using CalamityMod.NPCs.DevourerofGods; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Renderers.CalamityRenderers +{ + public class DoGDeathAnimationRenderer : BaseRenderer + { + private static DevourerofGodsHead DoGHead + { + get + { + if (!Main.npc.IndexInRange(CalamityGlobalNPC.DoGHead)) + return null; + + if (Main.npc[CalamityGlobalNPC.DoGHead].type != ModContent.NPCType()) + return null; + + if (Main.npc[CalamityGlobalNPC.DoGHead].ModNPC is not null && Main.npc[CalamityGlobalNPC.DoGHead].ModNPC is DevourerofGodsHead dogHead) + return dogHead; + + return null; + } + } + + /// + /// Used to determine whether the npc should return true in predraw or not, for exclusively drawing to the drawer target. + /// + public static bool ActuallyDoPreDraw + { + get; + private set; + } + + public override DrawLayer Layer => DrawLayer.NPC; + + public override bool ShouldDraw => !Main.gameMenu && CalamityGlobalNPC.DoGHead != -1 && Main.npc[CalamityGlobalNPC.DoGHead].active && DoGHead.DeathAnimationTimer > 0; + + public static bool ValidToDraw(NPC npc) + { + // Do not draw inactive npcs, or ones with weird MP types less than or equal to 0. + if (!npc.active || npc.type <= NPCID.None) + return false; + + // Don't consider any other NPCs besides the DoG NPCs valid. + if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) + return false; + + // Don't draw if DoG's Head cannot be found active. + if (DoGHead is null) + return false; + + // Don't draw if DoG hasn't started it's death animation yet. + if (DoGHead.DeathAnimationTimer <= 0) + return false; + + return true; + } + + public override void DrawToTarget(SpriteBatch spriteBatch) + { + // Indicate that DoG and his segments should draw. + ActuallyDoPreDraw = true; + + // Draw every npc to a single target that should have the disintegration visual. + foreach (NPC npc in Main.ActiveNPCs) + { + // Extra check to ensure that index errors will not occur. If not in range, something has gone wrong and the loop should terminate. + if (!Main.npc.IndexInRange(npc.whoAmI)) + break; + + // Draw the NPCs to the target once everything is valid and set the disintegration progress variable. + // Also ensure to indicate that the renderer should allow drawing the target here as well. + if (ValidToDraw(npc)) + Main.instance.DrawNPC(npc.whoAmI, npc.behindTiles); + } + + // Indicate that DoG and his segments should no longer draw. + ActuallyDoPreDraw = false; + } + + public override void DrawTarget(SpriteBatch spriteBatch) + { + var disintegrationShader = GameShaders.Misc["CalamityMod:DoGDisintegration"].Shader; + NPC npc = DoGHead.NPC; + if (npc == null || !npc.active) + return; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Vector2 worldPosition = Main.screenPosition / MainTarget.Size; + float disintegrationProgress = DoGHead.DeathAnimationTimer / 600f; + + disintegrationShader.Parameters["disintegrationProgress"].SetValue(disintegrationProgress); + disintegrationShader.Parameters["disintegrationScale"].SetValue(1.75f); + disintegrationShader.Parameters["worldPosition"].SetValue(new Vector2(worldPosition.X, worldPosition.Y)); + disintegrationShader.Parameters["pixelSize"].SetValue(screenSize * 0.5f); + + Main.instance.GraphicsDevice.Textures[1] = Main.Assets.Request("Images/Misc/Perlin").Value; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + disintegrationShader.Techniques[0].Passes[0].Apply(); + Main.spriteBatch.Draw(MainTarget, Vector2.Zero, Color.White); + } + } +} diff --git a/Items/SummonItems/CosmicWorm.cs b/Items/SummonItems/CosmicWorm.cs index 7b3e79c937..9f723088dd 100644 --- a/Items/SummonItems/CosmicWorm.cs +++ b/Items/SummonItems/CosmicWorm.cs @@ -5,6 +5,7 @@ using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.SummonItems @@ -40,11 +41,13 @@ namespace CalamityMod.Items.SummonItems public override bool? UseItem(Player player) { - string key = "Mods.CalamityMod.Status.Boss.EdgyBossText7"; + string key = "Mods.CalamityMod.Status.Boss.DoGSpawn"; Color messageColor = Color.Cyan; CalamityUtils.DisplayLocalizedText(key, messageColor); - - CalamityUtils.SpawnBossUsingItem(player, DevourerofGodsHead.SpawnSound); + var subtitle = Main.combatText[CombatText.NewText(player.Hitbox, messageColor, Language.GetTextValue(key), true)]; + player.Calamity().subtitletext = subtitle; + player.Calamity().subtitleColors = new Color[] { Color.Cyan, Color.Fuchsia }; + CalamityUtils.SpawnBossOnPosUsingItem(player, (int)player.Center.X, (int)player.Center.Y - 1600, DevourerofGodsHead.SpawnSound); return true; } diff --git a/Items/Weapons/Melee/MirrorBlade.cs b/Items/Weapons/Melee/MirrorBlade.cs index 684601d2fa..557ec7e81e 100644 --- a/Items/Weapons/Melee/MirrorBlade.cs +++ b/Items/Weapons/Melee/MirrorBlade.cs @@ -1,5 +1,6 @@ using System; using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using CalamityMod.Systems.Collections; @@ -68,8 +69,8 @@ namespace CalamityMod.Items.Weapons.Melee if (reflectTimer <= 50) { - float coneLength = 80f; - float maximumAngle = 0.8f; + float coneLength = 96f; + float maximumAngle = 1f; float coneRotation = player.DirectionTo(Main.MouseWorld).ToRotation(); var shardCount = 0; foreach (var proj in Main.projectile) @@ -81,19 +82,45 @@ namespace CalamityMod.Items.Weapons.Melee } foreach (var proj in Main.ActiveProjectiles) { - if (proj.hostile && proj.damage > 0 && proj.Hitbox.IntersectsConeSlowMoreAccurate(player.Center, coneLength, coneRotation, maximumAngle)) + if (proj.type == ModContent.ProjectileType() && proj.ModProjectile().time >= 29) { if (shardCount > 0) { SoundEngine.PlaySound(SeekingScorcher.LightShatterSound, player.Center); - SoundEngine.PlaySound(SoundID.DD2_WitherBeastDeath,player.Center); + SoundEngine.PlaySound(SoundID.DD2_WitherBeastDeath, player.Center); } if (shardCount >= 10) { player.SetImmuneTimeForAllTypes(player.longInvince ? 60 : 30); } - proj.Calamity().multiplicativeDR += shardCount / 10f; - proj.Calamity().multiplicativeDRTimer = 60; + proj.Calamity().multiplicativeDR += shardCount / 10f; + proj.Calamity().multiplicativeDRTimer = 60; + foreach (var proj2 in Main.projectile) + { + if (proj2.active && proj2.type == ModContent.ProjectileType() && proj2.owner == player.whoAmI && (proj2.ModProjectile as MirrorBlast).isShard) + { + proj2.damage = (int)(proj2.damage * (shardCount >= 10 ? 3f : 2f)); + (proj2.ModProjectile as MirrorBlast).shardShield = 0; + (proj2.ModProjectile as MirrorBlast).shardNum = 11; + proj2.netUpdate = true; + } + } + reflectTimer = 0; + return; + } else + if (proj.hostile && proj.damage > 0 && proj.Hitbox.IntersectsConeSlowMoreAccurate(player.Center, coneLength, coneRotation, maximumAngle)) + { + if (shardCount > 0) + { + SoundEngine.PlaySound(SeekingScorcher.LightShatterSound, player.Center); + SoundEngine.PlaySound(SoundID.DD2_WitherBeastDeath, player.Center); + } + if (shardCount >= 10) + { + player.SetImmuneTimeForAllTypes(player.longInvince ? 60 : 30); + } + proj.Calamity().multiplicativeDR += shardCount / 10f; + proj.Calamity().multiplicativeDRTimer = 60; foreach (var proj2 in Main.projectile) { if (proj2.active && proj2.type == ModContent.ProjectileType() && proj2.owner == player.whoAmI && (proj2.ModProjectile as MirrorBlast).isShard) diff --git a/Items/Weapons/Melee/TheLastMourning.cs b/Items/Weapons/Melee/TheLastMourning.cs index 8f59702b28..ee6e286544 100644 --- a/Items/Weapons/Melee/TheLastMourning.cs +++ b/Items/Weapons/Melee/TheLastMourning.cs @@ -35,8 +35,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { - bool isDoGSegment = target.type == ModContent.NPCType() || target.type == ModContent.NPCType(); - if (!isDoGSegment || Main.rand.NextBool(3)) + if (target.type != ModContent.NPCType() || Main.rand.NextBool(3)) { CalamityPlayer.HorsemansBladeOnHit(player, target.whoAmI, Item.damage, Item.knockBack, 0, ModContent.ProjectileType()); CalamityPlayer.HorsemansBladeOnHit(player, target.whoAmI, Item.damage, Item.knockBack, 1); diff --git a/Localization/en-US/Mods.CalamityMod.Configs.hjson b/Localization/en-US/Mods.CalamityMod.Configs.hjson index 7814bc313a..0b4b021b61 100644 --- a/Localization/en-US/Mods.CalamityMod.Configs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Configs.hjson @@ -123,6 +123,16 @@ CalamityClientConfig: { ''' } + FancyBackgroundVisuals: { + Label: "[i:CalamityMod/BlueDistortedMonolith] Toggle Fancy Background Visuals" + Tooltip: + ''' + Controls whether or not fancy background visuals will be displayed during certain parts of the game, such as boss fights. + When disabled, a simplified version of the main visual will be displayed in certain cases. + Recommended to have disabled if you struggle with visibility issues or low performance. + ''' + } + FasterFallHotkey: { Label: "[i:CalamityMod/BallAndChain] Enable Fast Falling" Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson index d633004aa0..a1842e2f15 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson @@ -51,9 +51,12 @@ DoGBeam.DisplayName: Portal Laser DoGBeamPortal.DisplayName: Beam Portal DoGDeath.DisplayName: Death Beam DoGDeathBoom.DisplayName: Cosmic Explosion -DoGFire.DisplayName: Death Fire +DoGFire.DisplayName: Faith Incinerator +DoGLaserWalls.DisplayName: God's Bane Doombeam Array +DoGLaserWallsBigBeam.DisplayName: Hyperdeath Rift Ripper DoGP1EndPortal.DisplayName: Portal -DoGTeleportRift.DisplayName: Rift +DoGRiftCrack.DisplayName: DoG Distortion Crack +DoGTeleportRift.DisplayName: DoG Distortion Rift DoGWingdings.DisplayName: Ramblings of Wing DoGster DraedonSummonLaser.DisplayName: Giant Fuck-off Deathray of Doom DyingSun.DisplayName: Dying Sun diff --git a/Localization/en-US/Mods.CalamityMod.Status.Boss.hjson b/Localization/en-US/Mods.CalamityMod.Status.Boss.hjson index 5b5cae9452..3b293f65f6 100644 --- a/Localization/en-US/Mods.CalamityMod.Status.Boss.hjson +++ b/Localization/en-US/Mods.CalamityMod.Status.Boss.hjson @@ -19,14 +19,30 @@ ProfanedBossText: Holy flames burn away at your wings... GhostBossText2: Wails echo through the dilapidated dungeon halls... GhostBossText3: Long-dead prisoners seek their zealous revenge... // Devourer of Gods -EdgyBossText: Don't get cocky! -EdgyBossText2: A fatal mistake! -EdgyBossText3: Delicious... -EdgyBossText4: Did that hurt? -EdgyBossText5: It's not over yet! -EdgyBossText6: A GOD DOES NOT FEAR DEATH! -EdgyBossText7: You are no god... but I shall feast upon your essence regardless! -EdgyBossText8: You think...you can butcher...ME!? +DoGSpawn: You are no god... but I shall feast upon your essence regardless! +DoGSubphase1: You've done better than most, but don't get cocky! +DoGPhase2: It's not over yet, kid! +DoGPhase3: A GOD DOES NOT FEAR DEATH! +DoGHead1: Fall to your knees, worm! +DoGHead2: Let's see how much longer you'll last... +DoGHead3: Getting tired yet? +DoGHead4: You'll fall, just like the others! +DoGHead5: Give up! It'll be easier for both of us! +DoGHead6: Let me end you already! +DoGHead7: This is starting to get ridiculous...! +DoGHead8: How are you doing this?! +DoGHead9: Are you playing me for a fool?! +DoGHead10: Why won't you DIE?! +DoGHead11: FALL! +DoGHead12: BEGONE! +DoGHead13: DIE! +DoGHeadDeath1: Tasteless slop. +DoGHeadDeath2: Delicious... A feast worthy of a god! +DoGHeadDeath3: And STAY dead! +DoGHeadDeath4: WEAK. +DoGHeadDeath5: PATHETIC. ALL THAT RUNNING JUST TO DIE TO A SINGLE TOUCH?! +DoGHeadRunning: You can't run forever! +DoGHeadRunning2: WHAT'S THE PROBLEM?! CAN'T RUN ANYMORE?! // Yharon FlameText: The air is getting warmer around you. // Draedon (introduction) diff --git a/Localization/en-US/Mods.CalamityMod.Status.Death.hjson b/Localization/en-US/Mods.CalamityMod.Status.Death.hjson index 693d421595..3e976e6542 100644 --- a/Localization/en-US/Mods.CalamityMod.Status.Death.hjson +++ b/Localization/en-US/Mods.CalamityMod.Status.Death.hjson @@ -58,13 +58,17 @@ Dragonfire1: "{0}'s ashes scatter in the wind." Dragonfire2: "{0}'s embers fade away in a warm glow." Dragonfire3: "{0} can no longer feel the heat of the dragonfire." Dragonfire4: This was a fight {0} could not win. +DimensionalDrive: "{0} was blasted apart into space dust by the Dimensional Drive." +DivinityDevourer1: "{0} fell victim to the Divinity Devourer." +DivinityDevourer2: "{0} was consumed by the Divinity Devourer." +DivinityDevourer3: "{0}'s essence was snuffed by the Divinity Devourer." ElementalMix1: "{0} was reduced to technicolor confetti." ElementalMix2: "{0} was blasted apart by a harmonized elemental onslaught." ElementalMix3: "{0} was overwhelmed by elemental turbulence." FlareGunOverheat: "{0}'s gun was simply too hot to handle." -GodSlayerInferno1: "{0} imploded into nothingness." -GodSlayerInferno2: "{0}'s body slipped into oblivion." -GodSlayerInferno3: "{0} ceased being a part of our universe." +GodSlayerInferno1: "{0}'s hopes and dreams were cremated." +GodSlayerInferno2: "{0}'s consciousness slipped into oblivion." +GodSlayerInferno3: "{0} ceased to be part of our universe." Goldfish: "{0} was once again impaled by Goldfish." HeavyBleeding1: "{0} expired from heavy internal bleeding." HeavyBleeding2: "{0} forgot that blood is supposed to stay inside the body." @@ -103,6 +107,8 @@ SulphuricPoisoning1: "{0} was melted by the toxic waste." SulphuricPoisoning2: "{0} ingested too many caustic chemicals." SulphuricPoisoning3: "{0} couldn't handle the industrial backwash." ThornBlossom: "{0} was violently pricked by a flower." +UltracosmicMaelstrom1: "{0} was sublimated by the Ultracosmic Maelstrom." +UltracosmicMaelstrom2: "{0} got cut down to size by the Ultracosmic Maelstrom." Vaporfied: "{0} vaporized into thin air." VermillionFlux1: "{0} burst apart in a shower of scarlet sparks." VermillionFlux2: "{0} went deathly stiff, still crackling with crimson." diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 163157712f..d5256ecdf6 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -7108,6 +7108,10 @@ namespace CalamityMod.NPCs // Only draw the NPC if told to by the miracle blight drawer. if (MiracleBlightRenderer.ValidToDraw(npc)) return MiracleBlightRenderer.ActuallyDoPreDraw; + + // Only draw DoG's death animation when told to by the renderer. + if (DoGDeathAnimationRenderer.ValidToDraw(npc)) + return DoGDeathAnimationRenderer.ActuallyDoPreDraw; } if (Main.zenithWorld) diff --git a/NPCs/DevourerofGods/CosmicGuardianBody.cs b/NPCs/DevourerofGods/CosmicGuardianBody.cs deleted file mode 100644 index 6188c4cf81..0000000000 --- a/NPCs/DevourerofGods/CosmicGuardianBody.cs +++ /dev/null @@ -1,221 +0,0 @@ -using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -namespace CalamityMod.NPCs.DevourerofGods -{ - [HasPierceResist] - [LongDistanceNetSync(SyncWith = typeof(CosmicGuardianHead))] - public class CosmicGuardianBody : ModNPC - { - public int invinceTime = 180; - public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.CosmicGuardianHead.DisplayName"); - - public static Asset GlowTexture; - - public override void SetStaticDefaults() - { - this.HideFromBestiary(); - if (!Main.dedServ) - { - GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - } - } - - public override void SetDefaults() - { - NPC.damage = 120; // 240 - NPC.width = 34; - NPC.height = 34; - NPC.defense = 60; - CalamityGlobalNPC global = NPC.Calamity(); - global.DR = 0.5f; - global.unbreakableDR = true; - NPC.lifeMax = 50000; - NPC.aiStyle = -1; - AIType = -1; - NPC.knockBackResist = 0f; - NPC.Opacity = 0f; - NPC.behindTiles = true; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.HitSound = SoundID.NPCHit4; - NPC.DeathSound = SoundID.NPCDeath14; - NPC.netAlways = true; - NPC.dontCountMe = true; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(NPC.dontTakeDamage); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - NPC.dontTakeDamage = reader.ReadBoolean(); - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } - - public override void AI() - { - if (invinceTime > 0) - { - invinceTime--; - NPC.damage = 0; - NPC.dontTakeDamage = true; - } - else - { - NPC.damage = NPC.defDamage; - NPC.dontTakeDamage = false; - } - - if (NPC.ai[2] > 0f) - NPC.realLife = (int)NPC.ai[2]; - - // Check if other segments are still alive, if not, die - bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); - if (!shouldDespawn) - { - if (NPC.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)NPC.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - NPC.life = 0; - NPC.HitEffect(0, 10.0); - NPC.checkDead(); - NPC.active = false; - } - - NPC.Opacity = Main.npc[(int)NPC.ai[2]].Opacity; - - Vector2 segmentPosition = NPC.Center; - float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); - float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); - targetX = (int)(targetX / 16f) * 16; - targetY = (int)(targetY / 16f) * 16; - segmentPosition.X = (int)(segmentPosition.X / 16f) * 16; - segmentPosition.Y = (int)(segmentPosition.Y / 16f) * 16; - targetX -= segmentPosition.X; - targetY -= segmentPosition.Y; - float targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); - if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) - { - try - { - segmentPosition = NPC.Center; - targetX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; - targetY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; - } - catch - { - } - NPC.rotation = (float)System.Math.Atan2(targetY, targetX) + 1.57f; - targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); - int segmentWidth = NPC.width; - targetDistance = (targetDistance - segmentWidth) / targetDistance; - targetX *= targetDistance; - targetY *= targetDistance; - NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + targetX; - NPC.position.Y = NPC.position.Y + targetY; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = TextureAssets.Npc[Type].Value; - Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[Type].Value.Width / 2), (float)(TextureAssets.Npc[Type].Value.Height / 2)); - - Vector2 drawLocation = NPC.Center - screenPos; - drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - texture2D15 = GlowTexture.Value; - Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - return false; - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = ImmunityCooldownID.Bosses; - return NPC.Opacity >= 1f && invinceTime <= 0; - } - - public override bool CheckActive() - { - return false; - } - - public override void HitEffect(NPC.HitInfo hit) - { - if (NPC.life <= 0) - { - if (!Main.dedServ) - { - float randomSpread = Main.rand.Next(-200, 201) / 100f; - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT2").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT3").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT4").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT5").Type, 1f); - } - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y + (float)(NPC.height / 2); - NPC.width = 50; - NPC.height = 50; - NPC.position.X = NPC.position.X - (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int i = 0; i < 10; i++) - { - int cosmiliteDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[cosmiliteDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[cosmiliteDust].scale = 0.5f; - Main.dust[cosmiliteDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 20; j++) - { - int cosmiliteDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[cosmiliteDust2].noGravity = true; - Main.dust[cosmiliteDust2].velocity *= 5f; - cosmiliteDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[cosmiliteDust2].velocity *= 2f; - } - } - } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 120); - } - } -} diff --git a/NPCs/DevourerofGods/CosmicGuardianBody.png b/NPCs/DevourerofGods/CosmicGuardianBody.png deleted file mode 100644 index 63c6a4c27c..0000000000 Binary files a/NPCs/DevourerofGods/CosmicGuardianBody.png and /dev/null differ diff --git a/NPCs/DevourerofGods/CosmicGuardianBodyGlow.png b/NPCs/DevourerofGods/CosmicGuardianBodyGlow.png deleted file mode 100644 index d5599ff746..0000000000 Binary files a/NPCs/DevourerofGods/CosmicGuardianBodyGlow.png and /dev/null differ diff --git a/NPCs/DevourerofGods/CosmicGuardianHead.cs b/NPCs/DevourerofGods/CosmicGuardianHead.cs deleted file mode 100644 index 378971f286..0000000000 --- a/NPCs/DevourerofGods/CosmicGuardianHead.cs +++ /dev/null @@ -1,440 +0,0 @@ -using System; -using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.GameContent; -using Terraria.GameContent.Bestiary; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.DevourerofGods -{ - [HasPierceResist] - [LongDistanceNetSync] - public class CosmicGuardianHead : ModNPC - { - private bool tail = false; - private const int minLength = 10; - private const int maxLength = 11; - private int invinceTime = 180; - - public static Asset GlowTexture; - public static Asset GlowTexture2; - - public override void SetStaticDefaults() - { - NPCID.Sets.BossBestiaryPriority.Add(Type); - NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() - { - Scale = 0.75f, - PortraitScale = 0.75f, - PortraitPositionXOverride = 40, - PortraitPositionYOverride = 40 - }; - value.Position.X += 62f; - value.Position.Y += 35f; - NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; - if (!Main.dedServ) - { - GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - GlowTexture2 = ModContent.Request(Texture + "Glow2", AssetRequestMode.AsyncLoad); - } - } - - public override void SetDefaults() - { - NPC.Calamity().canBreakPlayerDefense = true; - NPC.damage = 180; // 360 - NPC.width = 64; - NPC.height = 76; - NPC.defense = 40; - NPC.lifeMax = 50000; - NPC.aiStyle = -1; - AIType = -1; - NPC.knockBackResist = 0f; - NPC.Opacity = 0f; - NPC.behindTiles = true; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.HitSound = SoundID.NPCHit4; - NPC.DeathSound = SoundID.NPCDeath14; - NPC.netAlways = true; - } - - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - int associatedNPCType = ModContent.NPCType(); - bestiaryEntry.UIInfoProvider = new CommonEnemyUICollectionInfoProvider(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[associatedNPCType], quickUnlock: true); - - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] - { - new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.CosmicGuardian") - }); - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(NPC.dontTakeDamage); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - NPC.dontTakeDamage = reader.ReadBoolean(); - } - - public override void AI() - { - if (invinceTime > 0) - { - invinceTime--; - NPC.damage = 0; - NPC.dontTakeDamage = true; - } - else - { - NPC.damage = NPC.defDamage; - NPC.dontTakeDamage = false; - } - - Vector2 vector = NPC.Center; - - if (NPC.ai[2] > 0f) - NPC.realLife = (int)NPC.ai[2]; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!tail && NPC.ai[0] == 0f) - { - int Previous = NPC.whoAmI; - for (int segmentSpawn = 0; segmentSpawn < maxLength; segmentSpawn++) - { - int segment; - if (segmentSpawn >= 0 && segmentSpawn < minLength) - { - segment = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } - else - { - segment = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } - Main.npc[segment].realLife = NPC.whoAmI; - Main.npc[segment].ai[2] = NPC.whoAmI; - Main.npc[segment].ai[1] = Previous; - Main.npc[Previous].ai[0] = segment; - NPC.netUpdate = true; - Previous = segment; - } - tail = true; - } - if (!NPC.active && Main.dedServ) - { - NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, NPC.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } - } - - if (CalamityGlobalNPC.DoGHead < 0 || !Main.npc[CalamityGlobalNPC.DoGHead].active) - { - NPC.velocity.Y -= 4f; - - if ((double)NPC.position.Y < Main.topWorld + 16f) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } - } - return; - } - - Player player = Main.player[Main.npc[CalamityGlobalNPC.DoGHead].target]; - - bool increaseSpeed = Vector2.Distance(player.Center, vector) > CalamityGlobalNPC.CatchUpDistance200Tiles; - bool increaseSpeedMore = Vector2.Distance(player.Center, vector) > CalamityGlobalNPC.CatchUpDistance350Tiles; - - NPC.Opacity = Main.npc[CalamityGlobalNPC.DoGHead].Opacity; - - // Fly up and despawn if DoG enters phase 2 and isn't in the final Cosmic Guardian spawn phase. - bool flyAwayAndDespawn = (Main.npc[CalamityGlobalNPC.DoGHead].life / (float)Main.npc[CalamityGlobalNPC.DoGHead].lifeMax < 0.6f && Main.npc[CalamityGlobalNPC.DoGHead].life / (float)Main.npc[CalamityGlobalNPC.DoGHead].lifeMax > 0.2f) || Main.npc[CalamityGlobalNPC.DoGHead].life <= 1; - if (flyAwayAndDespawn) - { - // Prevents them from doing damage while despawning. - NPC.Opacity = 0.99f; - - NPC.velocity.Y -= 4f; - - if ((double)NPC.position.Y < Main.topWorld + 16f) - { - for (int a = 0; a < Main.maxNPCs; a++) - { - if (Main.npc[a].type == NPC.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) - Main.npc[a].active = false; - } - } - return; - } - - Vector2 segmentDirection = NPC.Center; - float dogHeadX = Main.npc[CalamityGlobalNPC.DoGHead].position.X + (Main.npc[CalamityGlobalNPC.DoGHead].width / 2); - float dogHeadY = Main.npc[CalamityGlobalNPC.DoGHead].position.Y + (Main.npc[CalamityGlobalNPC.DoGHead].height / 2); - float segmentVelocity = CalamityWorld.revenge ? 25f : 23f; - float velocityMult = CalamityWorld.revenge ? 0.75f : 0.23f; - float maxDistanceFromDoGHead = 160f; - - if (increaseSpeedMore) - velocityMult *= 4f; - else if (increaseSpeed) - velocityMult *= 2f; - - foreach (NPC n in Main.ActiveNPCs) - { - if ((n.type == NPC.type || n.type == ModContent.NPCType()) && n.whoAmI != NPC.whoAmI) - { - Vector2 distFromHead = n.Center - NPC.Center; - if (distFromHead.Length() < maxDistanceFromDoGHead) - { - distFromHead.Normalize(); - distFromHead *= maxDistanceFromDoGHead; - dogHeadX -= distFromHead.X; - dogHeadY -= distFromHead.Y; - } - } - } - - float higherMaxDistance = segmentVelocity * 1.3f; - float lowerMaxDistance = segmentVelocity * 0.7f; - float npcSpeed = NPC.velocity.Length(); - if (npcSpeed > 0f) - { - if (npcSpeed > higherMaxDistance) - { - NPC.velocity.Normalize(); - NPC.velocity *= higherMaxDistance; - } - else if (npcSpeed < lowerMaxDistance) - { - NPC.velocity.Normalize(); - NPC.velocity *= lowerMaxDistance; - } - } - - dogHeadX = (int)(dogHeadX / 16f) * 16; - dogHeadY = (int)(dogHeadY / 16f) * 16; - segmentDirection.X = (int)(segmentDirection.X / 16f) * 16; - segmentDirection.Y = (int)(segmentDirection.Y / 16f) * 16; - dogHeadX -= segmentDirection.X; - dogHeadY -= segmentDirection.Y; - float targetDistance = (float)Math.Sqrt(dogHeadX * dogHeadX + dogHeadY * dogHeadY); - float absoluteDoGX = Math.Abs(dogHeadX); - float absoluteDoGY = Math.Abs(dogHeadY); - float timeToReachTarget = segmentVelocity / targetDistance; - dogHeadX *= timeToReachTarget; - dogHeadY *= timeToReachTarget; - if ((NPC.velocity.X > 0f && dogHeadX > 0f) || (NPC.velocity.X < 0f && dogHeadX < 0f) || (NPC.velocity.Y > 0f && dogHeadY > 0f) || (NPC.velocity.Y < 0f && dogHeadY < 0f)) - { - if (NPC.velocity.X < dogHeadX) - { - NPC.velocity.X = NPC.velocity.X + velocityMult; - } - else - { - if (NPC.velocity.X > dogHeadX) - { - NPC.velocity.X = NPC.velocity.X - velocityMult; - } - } - if (NPC.velocity.Y < dogHeadY) - { - NPC.velocity.Y = NPC.velocity.Y + velocityMult; - } - else - { - if (NPC.velocity.Y > dogHeadY) - { - NPC.velocity.Y = NPC.velocity.Y - velocityMult; - } - } - if (Math.Abs(dogHeadY) < segmentVelocity * 0.2 && ((NPC.velocity.X > 0f && dogHeadX < 0f) || (NPC.velocity.X < 0f && dogHeadX > 0f))) - { - if (NPC.velocity.Y > 0f) - { - NPC.velocity.Y = NPC.velocity.Y + velocityMult * 2f; - } - else - { - NPC.velocity.Y = NPC.velocity.Y - velocityMult * 2f; - } - } - if (Math.Abs(dogHeadX) < segmentVelocity * 0.2 && ((NPC.velocity.Y > 0f && dogHeadY < 0f) || (NPC.velocity.Y < 0f && dogHeadY > 0f))) - { - if (NPC.velocity.X > 0f) - { - NPC.velocity.X = NPC.velocity.X + velocityMult * 2f; //changed from 2 - } - else - { - NPC.velocity.X = NPC.velocity.X - velocityMult * 2f; //changed from 2 - } - } - } - else - { - if (absoluteDoGX > absoluteDoGY) - { - if (NPC.velocity.X < dogHeadX) - { - NPC.velocity.X = NPC.velocity.X + velocityMult * 1.1f; //changed from 1.1 - } - else if (NPC.velocity.X > dogHeadX) - { - NPC.velocity.X = NPC.velocity.X - velocityMult * 1.1f; //changed from 1.1 - } - if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.5) - { - if (NPC.velocity.Y > 0f) - { - NPC.velocity.Y = NPC.velocity.Y + velocityMult; - } - else - { - NPC.velocity.Y = NPC.velocity.Y - velocityMult; - } - } - } - else - { - if (NPC.velocity.Y < dogHeadY) - { - NPC.velocity.Y = NPC.velocity.Y + velocityMult * 1.1f; - } - else if (NPC.velocity.Y > dogHeadY) - { - NPC.velocity.Y = NPC.velocity.Y - velocityMult * 1.1f; - } - if ((Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < segmentVelocity * 0.5) - { - if (NPC.velocity.X > 0f) - { - NPC.velocity.X = NPC.velocity.X + velocityMult; - } - else - { - NPC.velocity.X = NPC.velocity.X - velocityMult; - } - } - } - } - - NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - if (NPC.IsABestiaryIconDummy) - NPC.Opacity = 1f; - - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = TextureAssets.Npc[Type].Value; - Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[Type].Value.Width / 2), (float)(TextureAssets.Npc[Type].Value.Height / 2)); - - - if (NPC.IsABestiaryIconDummy) - { - return CalamityUtils.DrawAnimatedBestiaryWorm(spriteBatch, NPC, drawColor, texture2D15, TextureAssets.Npc[ModContent.NPCType()].Value, 8, 26, 0.2f, new Vector2(-10, 0), 4, 5); - } - - Vector2 distFromHead3 = NPC.Center - screenPos; - distFromHead3 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - distFromHead3 += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, distFromHead3, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - texture2D15 = GlowTexture.Value; - Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - - spriteBatch.Draw(texture2D15, distFromHead3, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - texture2D15 = GlowTexture2.Value; - glowmaskColor = Color.Lerp(Color.White, Color.Cyan, 0.5f); - - spriteBatch.Draw(texture2D15, distFromHead3, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - return false; - } - - public override void OnKill() - { - int heartAmt = Main.rand.Next(3) + 3; - for (int i = 0; i < heartAmt; i++) - Item.NewItem(NPC.GetSource_Loot(), (int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height, ItemID.Heart); - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = ImmunityCooldownID.Bosses; - return NPC.Opacity >= 1f && invinceTime <= 0; - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - scale = 1.5f; - return null; - } - - public override bool CheckActive() - { - return false; - } - - public override void HitEffect(NPC.HitInfo hit) - { - if (NPC.life <= 0) - { - if (!Main.dedServ) - { - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity, Mod.Find("DoT").Type, 1f); - } - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y + (float)(NPC.height / 2); - NPC.width = 50; - NPC.height = 50; - NPC.position.X = NPC.position.X - (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int i = 0; i < 15; i++) - { - int cosmiliteDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[cosmiliteDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[cosmiliteDust].scale = 0.5f; - Main.dust[cosmiliteDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 30; j++) - { - int cosmiliteDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[cosmiliteDust2].noGravity = true; - Main.dust[cosmiliteDust2].velocity *= 5f; - cosmiliteDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[cosmiliteDust2].velocity *= 2f; - } - } - } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 240); - } - } -} diff --git a/NPCs/DevourerofGods/CosmicGuardianHead.png b/NPCs/DevourerofGods/CosmicGuardianHead.png deleted file mode 100644 index 5a2e86f44a..0000000000 Binary files a/NPCs/DevourerofGods/CosmicGuardianHead.png and /dev/null differ diff --git a/NPCs/DevourerofGods/CosmicGuardianHeadGlow.png b/NPCs/DevourerofGods/CosmicGuardianHeadGlow.png deleted file mode 100644 index 54237b2004..0000000000 Binary files a/NPCs/DevourerofGods/CosmicGuardianHeadGlow.png and /dev/null differ diff --git a/NPCs/DevourerofGods/CosmicGuardianHeadGlow2.png b/NPCs/DevourerofGods/CosmicGuardianHeadGlow2.png deleted file mode 100644 index 06614ea355..0000000000 Binary files a/NPCs/DevourerofGods/CosmicGuardianHeadGlow2.png and /dev/null differ diff --git a/NPCs/DevourerofGods/CosmicGuardianTail.cs b/NPCs/DevourerofGods/CosmicGuardianTail.cs deleted file mode 100644 index ac3627b1c3..0000000000 --- a/NPCs/DevourerofGods/CosmicGuardianTail.cs +++ /dev/null @@ -1,218 +0,0 @@ -using System.IO; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using ReLogic.Content; -using Terraria; -using Terraria.GameContent; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -namespace CalamityMod.NPCs.DevourerofGods -{ - [HasPierceResist] - [LongDistanceNetSync(SyncWith = typeof(CosmicGuardianHead))] - public class CosmicGuardianTail : ModNPC - { - public int invinceTime = 180; - public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.CosmicGuardianHead.DisplayName"); - - public static Asset GlowTexture; - - public override void SetStaticDefaults() - { - this.HideFromBestiary(); - if (!Main.dedServ) - { - GlowTexture = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - } - } - - public override void SetDefaults() - { - NPC.damage = 90; // 180 - NPC.width = 30; - NPC.height = 50; - NPC.defense = 70; - NPC.lifeMax = 50000; - NPC.aiStyle = -1; - AIType = -1; - NPC.knockBackResist = 0f; - NPC.Opacity = 0f; - NPC.behindTiles = true; - NPC.noGravity = true; - NPC.noTileCollide = true; - NPC.HitSound = SoundID.NPCHit4; - NPC.DeathSound = SoundID.NPCDeath14; - NPC.netAlways = true; - NPC.dontCountMe = true; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(NPC.dontTakeDamage); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - NPC.dontTakeDamage = reader.ReadBoolean(); - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } - - public override void AI() - { - if (invinceTime > 0) - { - invinceTime--; - NPC.damage = 0; - NPC.dontTakeDamage = true; - } - else - { - NPC.damage = NPC.defDamage; - NPC.dontTakeDamage = false; - } - - if (NPC.ai[2] > 0f) - NPC.realLife = (int)NPC.ai[2]; - - // Check if other segments are still alive, if not, die - bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); - if (!shouldDespawn) - { - if (NPC.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)NPC.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - NPC.life = 0; - NPC.HitEffect(0, 10.0); - NPC.checkDead(); - NPC.active = false; - } - - NPC.Opacity = Main.npc[(int)NPC.ai[2]].Opacity; - - Vector2 segmentPosition = NPC.Center; - float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2); - float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2); - targetX = (int)(targetX / 16f) * 16; - targetY = (int)(targetY / 16f) * 16; - segmentPosition.X = (int)(segmentPosition.X / 16f) * 16; - segmentPosition.Y = (int)(segmentPosition.Y / 16f) * 16; - targetX -= segmentPosition.X; - targetY -= segmentPosition.Y; - float targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); - if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length) - { - try - { - segmentPosition = NPC.Center; - targetX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; - targetY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; - } - catch - { - } - NPC.rotation = (float)System.Math.Atan2(targetY, targetX) + 1.57f; - targetDistance = (float)System.Math.Sqrt(targetX * targetX + targetY * targetY); - int segmentWidth = NPC.width; - targetDistance = (targetDistance - segmentWidth) / targetDistance; - targetX *= targetDistance; - targetY *= targetDistance; - NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + targetX; - NPC.position.Y = NPC.position.Y + targetY; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = TextureAssets.Npc[Type].Value; - Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[Type].Value.Width / 2), (float)(TextureAssets.Npc[Type].Value.Height / 2)); - - Vector2 drawLocation = NPC.Center - screenPos; - drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - texture2D15 = GlowTexture.Value; - Color glowmaskColor = Color.Lerp(Color.White, Color.Cyan, 0.5f); - - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - return false; - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = ImmunityCooldownID.Bosses; - return NPC.Opacity >= 1f && invinceTime <= 0; - } - - public override void HitEffect(NPC.HitInfo hit) - { - if (NPC.life <= 0) - { - if (!Main.dedServ) - { - float randomSpread = Main.rand.Next(-200, 201) / 100f; - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT2").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT3").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT4").Type, 1f); - Gore.NewGore(NPC.GetSource_Death(), NPC.position, NPC.velocity * randomSpread * Main.rand.NextFloat(), Mod.Find("DoT5").Type, 1f); - } - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y + (float)(NPC.height / 2); - NPC.width = 50; - NPC.height = 50; - NPC.position.X = NPC.position.X - (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int i = 0; i < 10; i++) - { - int cosmiliteDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[cosmiliteDust].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[cosmiliteDust].scale = 0.5f; - Main.dust[cosmiliteDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 20; j++) - { - int cosmiliteDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[cosmiliteDust2].noGravity = true; - Main.dust[cosmiliteDust2].velocity *= 5f; - cosmiliteDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[cosmiliteDust2].velocity *= 2f; - } - } - } - - public override bool CheckActive() - { - return false; - } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - target.AddBuff(ModContent.BuffType(), 60, true); - } - } -} diff --git a/NPCs/DevourerofGods/CosmicGuardianTail.png b/NPCs/DevourerofGods/CosmicGuardianTail.png deleted file mode 100644 index e570d41a53..0000000000 Binary files a/NPCs/DevourerofGods/CosmicGuardianTail.png and /dev/null differ diff --git a/NPCs/DevourerofGods/CosmicGuardianTailGlow.png b/NPCs/DevourerofGods/CosmicGuardianTailGlow.png deleted file mode 100644 index 250a284fe7..0000000000 Binary files a/NPCs/DevourerofGods/CosmicGuardianTailGlow.png and /dev/null differ diff --git a/NPCs/DevourerofGods/DevourerofGodsBody.cs b/NPCs/DevourerofGods/DevourerofGodsBody.cs index 43dd699c66..6b71d81ddb 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody.cs @@ -4,6 +4,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; +using CalamityMod.Graphics.Renderers.CalamityRenderers; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Melee.Yoyos; using CalamityMod.World; @@ -27,7 +28,7 @@ namespace CalamityMod.NPCs.DevourerofGods public override void Load() { - string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyS_Head_Boss"; + string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsBody_P2_Head_Boss"; phase2IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); } @@ -41,9 +42,9 @@ namespace CalamityMod.NPCs.DevourerofGods public int SegmentIndex; public static Asset Texture_Glow; - public static Asset Phase2Texture; - public static Asset Phase2Texture_Glow; - public static Asset Phase2Texture_Glow2; + public static Asset TextureP2; + public static Asset TextureP2_Glow_Purple; + public static Asset TextureP2_Glow_Cyan; public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.DevourerofGodsHead.DisplayName"); @@ -52,16 +53,15 @@ namespace CalamityMod.NPCs.DevourerofGods this.HideFromBestiary(); if (!Main.dedServ) { - Texture_Glow = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - Phase2Texture = ModContent.Request(Texture + "S", AssetRequestMode.AsyncLoad); - Phase2Texture_Glow = ModContent.Request(Texture + "SGlow", AssetRequestMode.AsyncLoad); - Phase2Texture_Glow2 = ModContent.Request(Texture + "SGlow2", AssetRequestMode.AsyncLoad); + Texture_Glow = ModContent.Request(Texture + "_Glow", AssetRequestMode.AsyncLoad); + TextureP2 = ModContent.Request(Texture + "_P2", AssetRequestMode.AsyncLoad); + TextureP2_Glow_Purple = ModContent.Request(Texture + "_P2_Glow_Purple", AssetRequestMode.AsyncLoad); + TextureP2_Glow_Cyan = ModContent.Request(Texture + "_P2_Glow_Cyan", AssetRequestMode.AsyncLoad); } } public override void SetDefaults() { - NPC.Calamity().canBreakPlayerDefense = true; NPC.damage = 120; // 240 NPC.npcSlots = 5f; NPC.width = 56; @@ -74,7 +74,7 @@ namespace CalamityMod.NPCs.DevourerofGods global.unbreakableDR = true; NPC.chaseable = false; } - NPC.LifeMaxNERB(887500, 1065000, 1500000); // Phase 1 is 355000, Phase 2 is 532500 + NPC.LifeMaxNERB(760000, 910000, 1500000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -89,7 +89,7 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.dontCountMe = true; - if (Main.getGoodWorld) + if (Main.zenithWorld) NPC.scale *= 1.5f; } @@ -97,7 +97,7 @@ namespace CalamityMod.NPCs.DevourerofGods { NPC head = CalamityGlobalNPC.DoGHead >= 0 ? Main.npc[CalamityGlobalNPC.DoGHead] : null; DevourerofGodsHead modNPC = head?.ModNPC() ?? null; - if (head is null || modNPC.AwaitingPhase2Teleport || !modNPC.Phase2Started) + if (head is null || modNPC.AwaitingPhase2Teleport || !modNPC.Phase2Started || NPC.Opacity < 0.1f) { index = -1; return; @@ -149,19 +149,20 @@ namespace CalamityMod.NPCs.DevourerofGods if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; - if (NPC.life > Main.npc[(int)NPC.ai[1]].life) - NPC.life = Main.npc[(int)NPC.ai[1]].life; + NPC.life = Main.npc[(int)NPC.ai[2]].life; + NPC.lifeMax = Main.npc[(int)NPC.ai[2]].lifeMax;NPC.life = NPC.lifeMax; // Percent life remaining - float lifeRatio = NPC.life / (float)NPC.lifeMax; + float lifeRatio = Main.npc[(int)NPC.ai[2]].life / (float)Main.npc[(int)NPC.ai[2]].lifeMax; - bool phase2 = lifeRatio < 0.6f; + bool phase2 = lifeRatio < 0.65f; bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - if (phase2) + if (phase2 && !phase2Started && Main.npc[(int)NPC.ai[2]].localAI[2] <= 60) { + phase2Started = true; // Once before DoG spawns, set new size @@ -264,7 +265,7 @@ namespace CalamityMod.NPCs.DevourerofGods // Decide segment offset stuff. NPC.rotation = directionToNextSegment.ToRotation() + MathHelper.PiOver2; - NPC.Center = aheadSegment.Center - directionToNextSegment.SafeNormalize(Vector2.Zero) * NPC.scale * NPC.width; + NPC.Center = aheadSegment.Center - directionToNextSegment.SafeNormalize(Vector2.Zero) * NPC.scale * (phase2Started ? 80 : NPC.width ); NPC.spriteDirection = (directionToNextSegment.X > 0).ToDirectionInt(); // Velocity variables @@ -282,22 +283,12 @@ namespace CalamityMod.NPCs.DevourerofGods if (Main.npc[NPC.realLife].type != ModContent.NPCType()) return true; - float disintegrationFactor = Main.npc[NPC.realLife].ModNPC().DeathAnimationTimer / 640f; - if (disintegrationFactor > 0f) - { - spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(NPC.whoAmI); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage1("Images/Misc/Perlin"); - GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); - } - SpriteEffects spriteEffects = SpriteEffects.None; if (NPC.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; bool useOtherTextures = phase2Started && Main.npc[(int)NPC.ai[2]].localAI[2] <= 60f; - Texture2D texture2D15 = useOtherTextures ? Phase2Texture.Value : TextureAssets.Npc[Type].Value; + Texture2D texture2D15 = useOtherTextures ? TextureP2.Value : TextureAssets.Npc[Type].Value; Vector2 halfSizeTexture = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); Vector2 drawLocation = NPC.Center - screenPos; @@ -305,25 +296,21 @@ namespace CalamityMod.NPCs.DevourerofGods drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - if (!NPC.dontTakeDamage) + if (!Main.npc[(int)NPC.ai[2]].ModNPC().isInPassiveState && NPC.Opacity > 0.25f && useOtherTextures) { - if (useOtherTextures) - { - texture2D15 = Phase2Texture_Glow.Value; - Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + texture2D15 = TextureP2_Glow_Purple.Value; + Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - } - - texture2D15 = useOtherTextures ? Phase2Texture_Glow2.Value : Texture_Glow.Value; + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + } + if ((!Main.npc[(int)NPC.ai[2]].ModNPC().isInAgressiveState || !useOtherTextures) && NPC.Opacity > 0.25f) + { + texture2D15 = useOtherTextures ? TextureP2_Glow_Cyan.Value : Texture_Glow.Value; Color glowmaskColor2 = Color.Lerp(Color.White, Color.Cyan, 0.5f); spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskColor2, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } - if (disintegrationFactor > 0f) - spriteBatch.ExitShaderRegion(); - return false; } @@ -421,14 +408,5 @@ namespace CalamityMod.NPCs.DevourerofGods { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - { - target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 480); - } - } } } diff --git a/NPCs/DevourerofGods/DevourerofGodsBodyGlow.png b/NPCs/DevourerofGods/DevourerofGodsBody_Glow.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsBodyGlow.png rename to NPCs/DevourerofGods/DevourerofGodsBody_Glow.png diff --git a/NPCs/DevourerofGods/DevourerofGodsBodyS.png b/NPCs/DevourerofGods/DevourerofGodsBody_P2.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsBodyS.png rename to NPCs/DevourerofGods/DevourerofGodsBody_P2.png diff --git a/NPCs/DevourerofGods/DevourerofGodsBodySGlow2.png b/NPCs/DevourerofGods/DevourerofGodsBody_P2_Glow_Cyan.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsBodySGlow2.png rename to NPCs/DevourerofGods/DevourerofGodsBody_P2_Glow_Cyan.png diff --git a/NPCs/DevourerofGods/DevourerofGodsBodySGlow.png b/NPCs/DevourerofGods/DevourerofGodsBody_P2_Glow_Purple.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsBodySGlow.png rename to NPCs/DevourerofGods/DevourerofGodsBody_P2_Glow_Purple.png diff --git a/NPCs/DevourerofGods/DevourerofGodsBodyS_Head_Boss.png b/NPCs/DevourerofGods/DevourerofGodsBody_P2_Head_Boss.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsBodyS_Head_Boss.png rename to NPCs/DevourerofGods/DevourerofGodsBody_P2_Head_Boss.png diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index fee6b77511..87f2593c94 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -1,22 +1,22 @@ using System; using System.Collections.Generic; +using System.Diagnostics.Contracts; using System.IO; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.Potions; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; +using CalamityMod.Graphics.Renderers.CalamityRenderers; using CalamityMod.Fonts; using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; -using CalamityMod.Items.Mounts; using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Items.Placeables.Furniture.BossRelics; using CalamityMod.Items.Placeables.Furniture.DevPaintings; using CalamityMod.Items.Placeables.Furniture.Trophies; -using CalamityMod.Items.Placeables.FurnitureAbyss; using CalamityMod.Items.Placeables.FurnitureCosmilite; using CalamityMod.Items.Potions; using CalamityMod.Items.TreasureBags; @@ -26,10 +26,13 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.TownNPCs; +using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Melee.Yoyos; +using CalamityMod.Projectiles.Typeless; using CalamityMod.Sounds; using CalamityMod.World; +using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -39,7 +42,6 @@ using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.GameContent.Events; using Terraria.GameContent.ItemDropRules; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -52,16 +54,24 @@ namespace CalamityMod.NPCs.DevourerofGods public static int phase1IconIndex; public static int phase2IconIndex; - public static Asset Texture_Glow; - public static Asset Texture_Glow2; - public static Asset Phase2Texture; - public static Asset Phase2Texture_Glow; - public static Asset Phase2Texture_Glow2; + public static Asset Texture_Glow_Purple; + public static Asset Texture_Glow_Cyan; + public static Asset TextureP2; + public static Asset TextureP2_Glow_Purple; + public static Asset TextureP2_Glow_Cyan; + + public static Asset JawTexture; + public static Asset JawTexture_Glow; + public static Asset JawTextureP2; + public static Asset JawTextureP2_Glow; + public static Asset GodSlayerDashJawTexture; + + public static Asset TextureP2_Full; public override void Load() { string phase1IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead_Head_Boss"; - string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHeadS_Head_Boss"; + string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsHead_P2_Head_Boss"; phase1IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); phase2IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); @@ -72,22 +82,8 @@ namespace CalamityMod.NPCs.DevourerofGods // Phase 1 variables - // Enums - private enum LaserWallType - { - DiagonalRight = 0, - DiagonalLeft = 1, - DiagonalHorizontal = 2, - DiagonalCross = 3 - } - // Laser spread variables - private const int shotSpacingMax = 1440; - private int shotSpacing = shotSpacingMax; private const int totalShots = 10; - private const int spacingVar = shotSpacingMax / totalShots * 2; - private int laserWallType = 0; - private const float laserWallSpacingOffset = 16f; // Continuously reset variables public bool AttemptingToEnterPortal = false; @@ -115,53 +111,104 @@ namespace CalamityMod.NPCs.DevourerofGods FireLaserWalls = 1, End = 2 } - private enum LaserWallType_Phase2 - { - Normal = 0, - Offset = 1, - DiagonalHorizontal = 2, - MultiLayered = 3, - DiagonalVertical = 4 - } // Laser wall variables - private const int shotSpacingMax_Phase2 = 1440; - private int[] shotSpacing_Phase2 = new int[4] { shotSpacingMax_Phase2, shotSpacingMax_Phase2, shotSpacingMax_Phase2, shotSpacingMax_Phase2 }; - private const int spacingVar_Phase2 = 120; - private const int totalShots_Phase2 = 24; - private const int totalDiagonalShots = 6; - private const int diagonalSpacingVar = shotSpacingMax_Phase2 / totalDiagonalShots * 2; - private int laserWallType_Phase2 = 0; public int laserWallPhase = 0; // Phase variables private const int idleCounterMax = 300; private int idleCounter = idleCounterMax; - public const float LaserWallCooldown = 1200f; - private int postTeleportTimer = 0; - private int teleportTimer = -1; - private const int TimeBeforeTeleport_Death = 120; - private const int TimeBeforeTeleport_Revengeance = 140; + public const float LaserWallCooldown = 1800f; + public int postTeleportTimer = 0; + public int teleportTimer = -1; + private const int TimeBeforeTeleport_Death = 150; + private const int TimeBeforeTeleport_Revengeance = 150; private const int TimeBeforeTeleport_Expert = 160; private const int TimeBeforeTeleport_Normal = 180; private bool spawnedGuardians3 = false; - private const float AlphaGateValue = 1060f; + private const float AlphaGateValue = 1660f; public const float SkyColorTransitionTime = 90f; + public Vector2 PortalEntryLocation = Vector2.Zero; + public bool doTpFX = true; + public int dashes = 0; // Death animation variables public bool Dying; public int DeathAnimationTimer; public int DestroyedSegmentCount; + // Jaw related variables. + public float JawRotation; + public float JawChompDownProgress; + public float GodSlayerDashJawFadeProgress; + public float GodSlayerDashJawTimer; + public bool ShouldSpawnChompVFX; + // Sounds public static readonly SoundStyle SpawnSound = new("CalamityMod/Sounds/Custom/DevourerSpawn"); public static readonly SoundStyle AttackSound = new("CalamityMod/Sounds/Custom/DevourerAttack"); + public static readonly SoundStyle RiftOpenSound = new("CalamityMod/Sounds/Custom/DevourerRiftOpen"); + public static readonly SoundStyle RiftBuildingSound = new("CalamityMod/Sounds/Custom/DevourerRiftBuilding"); public static readonly SoundStyle HitSound = new("CalamityMod/Sounds/NPCHit/OtherworldlyHit"); public static readonly SoundStyle DeathAnimationSound = new("CalamityMod/Sounds/NPCKilled/DevourerDeath"); public static readonly SoundStyle DeathExplosionSound = new("CalamityMod/Sounds/NPCKilled/DevourerDeathImpact"); public static readonly SoundStyle DeathSegmentSound = new("CalamityMod/Sounds/NPCKilled/DevourerSegmentBreak", 4); public float extrapitch = 0; + public bool isInPassiveState + { + get + { + if (Phase2Started && NPC.ai[3] == 1) + return true; + if (!Phase2Started && NPC.ai[3] == 0) + return true; + return false; + } + } + + public bool isInAgressiveState + { + get + { + if (Phase2Started && NPC.ai[3] == 0) + return true; + if (!Phase2Started && NPC.ai[3] == 1) + return true; + return false; + } + } + + public bool isInLaserWallState + { + get + { + if (NPC.ai[3] == 2) + return true; + return false; + } + } + + public bool isInPostWallState + { + get + { + if (NPC.ai[3] > 2) + return true; + return false; + } + } + /// + /// This gets the player's center, adjusted for predictiveness on FTW + /// + /// + Vector2 AdjustedPlayerCenter(float predictiveness = 0) + { + Player player = Main.player[NPC.target]; + if (!(Main.getGoodWorld)) + return player.Center; + return player.Center + player.velocity * predictiveness; + } public override void SetStaticDefaults() { NPCID.Sets.BossBestiaryPriority.Add(Type); @@ -178,11 +225,20 @@ namespace CalamityMod.NPCs.DevourerofGods NPCID.Sets.MPAllowedEnemies[Type] = true; if (!Main.dedServ) { - Texture_Glow = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - Texture_Glow2 = ModContent.Request(Texture + "Glow2", AssetRequestMode.AsyncLoad); - Phase2Texture = ModContent.Request(Texture + "S", AssetRequestMode.AsyncLoad); - Phase2Texture_Glow = ModContent.Request(Texture + "SGlow", AssetRequestMode.AsyncLoad); - Phase2Texture_Glow2 = ModContent.Request(Texture + "SGlow2", AssetRequestMode.AsyncLoad); + Texture_Glow_Purple = ModContent.Request(Texture + "_Glow_Purple", AssetRequestMode.AsyncLoad); + Texture_Glow_Cyan = ModContent.Request(Texture + "_Glow_Cyan", AssetRequestMode.AsyncLoad); + TextureP2 = ModContent.Request(Texture + "_Jawless_P2", AssetRequestMode.AsyncLoad); + TextureP2_Glow_Purple = ModContent.Request(Texture + "_Jawless_P2_Glow_Purple", AssetRequestMode.AsyncLoad); + TextureP2_Glow_Cyan = ModContent.Request(Texture + "_Jawless_P2_Glow_Cyan", AssetRequestMode.AsyncLoad); + + JawTexture = ModContent.Request(Texture + "_Jaw", AssetRequestMode.AsyncLoad); + JawTexture_Glow = ModContent.Request(Texture + "_Jaw_Glow", AssetRequestMode.AsyncLoad); + JawTextureP2 = ModContent.Request(Texture + "_Jaw_P2", AssetRequestMode.AsyncLoad); + JawTextureP2_Glow = ModContent.Request(Texture + "_Jaw_P2_Glow", AssetRequestMode.AsyncLoad); + GodSlayerDashJawTexture = ModContent.Request("CalamityMod/NPCs/DevourerofGods/GodSlayerDashJaw", AssetRequestMode.AsyncLoad); + + // For bestiary. + TextureP2_Full = ModContent.Request(Texture + "_P2", AssetRequestMode.AsyncLoad); } } @@ -195,7 +251,8 @@ namespace CalamityMod.NPCs.DevourerofGods } public static int LaserWallDamage = 75; // 300 - public static int FireballDamage = 60; // 240; Also applies to Legendary Mode Ichor Blob + public static int LaserWallMiddleBeamDamage = 85; // 340 + public static int FireballDamage = 60; // 240 public override void SetDefaults() { @@ -205,8 +262,7 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.width = 104; NPC.height = 104; NPC.defense = 50; - NPC.LifeMaxNERB(887500, 1065000, 1500000); // Phase 1 is 355000, Phase 2 is 532500 - NPC.takenDamageMultiplier = 1.1f; + NPC.LifeMaxNERB(760000, 910000, 1500000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -217,15 +273,27 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.noGravity = true; NPC.noTileCollide = true; NPC.DeathSound = SoundID.NPCDeath14; + NPC.ai[3] = 1; NPC.netAlways = true; - - if (Main.getGoodWorld) + if (Main.rand.NextBool()) + NPC.velocity = new Vector2(-60, 0); + else + NPC.velocity = new Vector2(60, 0); + if (Main.zenithWorld) NPC.scale *= 1.5f; + if (Main.getGoodWorld) + NPC.takenDamageMultiplier = 2; + + + NPC.Calamity().VulnerableToElectricity = true; + NPC.Calamity().VulnerableToSickness = false; + + NPC.life = NPC.lifeMax; } public override void BossHeadSlot(ref int index) { - if (Phase2Started && (NPC.localAI[2] > 60f || AwaitingPhase2Teleport)) + if ((Phase2Started && (NPC.localAI[2] > 60f || AwaitingPhase2Teleport)) || NPC.Opacity < 0.1f) index = -1; else if (Phase2Started && !AwaitingPhase2Teleport) index = phase2IconIndex; @@ -255,8 +323,6 @@ namespace CalamityMod.NPCs.DevourerofGods writer.Write(hasCreatedPhase1Portal); writer.Write(AwaitingPhase2Teleport); writer.Write(spawnDoGCountdown); - writer.Write(shotSpacing); - writer.Write(laserWallType); writer.Write(PortalIndex); for (int i = 0; i < 4; i++) writer.Write(NPC.Calamity().newAI[i]); @@ -264,13 +330,8 @@ namespace CalamityMod.NPCs.DevourerofGods // Phase 2 syncs writer.Write(NPC.localAI[2]); writer.Write(NPC.localAI[3]); - writer.Write(shotSpacing_Phase2[0]); - writer.Write(shotSpacing_Phase2[1]); - writer.Write(shotSpacing_Phase2[2]); - writer.Write(shotSpacing_Phase2[3]); writer.Write(idleCounter); writer.Write(laserWallPhase); - writer.Write(laserWallType_Phase2); writer.Write(postTeleportTimer); writer.Write(teleportTimer); writer.Write(NPC.Opacity); @@ -280,6 +341,13 @@ namespace CalamityMod.NPCs.DevourerofGods writer.Write(DeathAnimationTimer); writer.Write(DestroyedSegmentCount); + // Jaw animation syncs + writer.Write(JawRotation); + writer.Write(JawChompDownProgress); + writer.Write(GodSlayerDashJawFadeProgress); + writer.Write(GodSlayerDashJawTimer); + writer.Write(ShouldSpawnChompVFX); + // Frame syncs writer.Write(NPC.frame.X); writer.Write(NPC.frame.Y); @@ -308,8 +376,6 @@ namespace CalamityMod.NPCs.DevourerofGods hasCreatedPhase1Portal = reader.ReadBoolean(); AwaitingPhase2Teleport = reader.ReadBoolean(); spawnDoGCountdown = reader.ReadInt32(); - shotSpacing = reader.ReadInt32(); - laserWallType = reader.ReadInt32(); PortalIndex = reader.ReadInt32(); for (int i = 0; i < 4; i++) NPC.Calamity().newAI[i] = reader.ReadSingle(); @@ -317,13 +383,8 @@ namespace CalamityMod.NPCs.DevourerofGods // Phase 2 syncs NPC.localAI[2] = reader.ReadSingle(); NPC.localAI[3] = reader.ReadSingle(); - shotSpacing_Phase2[0] = reader.ReadInt32(); - shotSpacing_Phase2[1] = reader.ReadInt32(); - shotSpacing_Phase2[2] = reader.ReadInt32(); - shotSpacing_Phase2[3] = reader.ReadInt32(); idleCounter = reader.ReadInt32(); laserWallPhase = reader.ReadInt32(); - laserWallType_Phase2 = reader.ReadInt32(); postTeleportTimer = reader.ReadInt32(); teleportTimer = reader.ReadInt32(); NPC.Opacity = reader.ReadSingle(); @@ -333,6 +394,13 @@ namespace CalamityMod.NPCs.DevourerofGods DeathAnimationTimer = reader.ReadInt32(); DestroyedSegmentCount = reader.ReadInt32(); + // Jaw animation syncs + JawRotation = reader.ReadSingle(); + JawChompDownProgress = reader.ReadSingle(); + GodSlayerDashJawFadeProgress = reader.ReadSingle(); + GodSlayerDashJawTimer = reader.ReadSingle(); + ShouldSpawnChompVFX = reader.ReadBoolean(); + // Misc syncs extrapitch = reader.ReadSingle(); @@ -344,6 +412,7 @@ namespace CalamityMod.NPCs.DevourerofGods public override void AI() { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); // whoAmI variable @@ -362,10 +431,20 @@ namespace CalamityMod.NPCs.DevourerofGods Player player = Main.player[NPC.target]; + // Use the shimmer background effect if fancy background visuals are disabled. + if (DeathAnimationTimer < 435 && !CalamityClientConfig.Instance.FancyBackgroundVisuals) + { + player.shimmerMonolithShader = true; + if (Main.shimmerDarken > 0.75f) + Main.shimmerDarken = 0.75f; + } + // Variables - bool flyUpDuringLaserWalls = laserWallPhase == (int)LaserWallPhase.FireLaserWalls || (laserWallPhase == (int)LaserWallPhase.End && teleportTimer > 0); - bool flies = NPC.ai[3] == 0f || flyUpDuringLaserWalls; - Vector2 destination = flyUpDuringLaserWalls ? (player.Center - Vector2.UnitY * 480f) : player.Center; + bool flies = NPC.ai[3] == 0f; + + if (Main.getGoodWorld) + flies = true; + Vector2 destination = AdjustedPlayerCenter(2); bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; @@ -374,30 +453,14 @@ namespace CalamityMod.NPCs.DevourerofGods float lifeRatio = NPC.life / (float)NPC.lifeMax; // Phase 1 phases - bool phase2 = lifeRatio < 0.9f; + bool phase2 = lifeRatio < 1f; bool phase3 = lifeRatio < 0.75f; - bool bigDaddyPhase2 = lifeRatio < 0.6f; + bool bigDaddyPhase2 = lifeRatio < 0.65f; // Phase 2 phases - bool phase4 = lifeRatio < 0.5f; - bool phase5 = lifeRatio < 0.4f; - bool phase6 = lifeRatio < 0.2f; - bool phase7 = lifeRatio < 0.15f; - - // Black sky timer - if (!death) - { - if (phase7) - { - if (NPC.localAI[3] < SkyColorTransitionTime) - NPC.localAI[3] += 1f; - } - else if (bigDaddyPhase2) - { - if (NPC.localAI[3] > 0f) - NPC.localAI[3] -= 1f; - } - } + bool phase4 = lifeRatio < 0.65f; + bool phase5 = lifeRatio < 0.5f; + bool phase6 = lifeRatio < 0.25f; // Sound pitch extrapitch = Main.zenithWorld ? 0.3f : 0f; @@ -405,7 +468,7 @@ namespace CalamityMod.NPCs.DevourerofGods // Velocity variables float segmentVelocity = death ? 17.5f : 16f; if (expertMode) - segmentVelocity += 4f * (1f - lifeRatio); + segmentVelocity += 4f * (1f - (lifeRatio * 0.75f + 0.25f)); float speed = death ? 16.5f : 15f; float turnSpeed = death ? 0.33f : 0.3f; @@ -414,50 +477,71 @@ namespace CalamityMod.NPCs.DevourerofGods if (expertMode) { - speed += 3f * (1f - lifeRatio); - turnSpeed += 0.06f * (1f - lifeRatio); - homingSpeed += 12f * (1f - lifeRatio); - homingTurnSpeed += 0.15f * (1f - lifeRatio); + speed += 3f * (1f - (lifeRatio * 0.75f + 0.25f)); + turnSpeed += 0.06f * (1f - (lifeRatio * 0.75f + 0.25f)); + homingSpeed += 12f * (1f - (lifeRatio * 0.75f + 0.25f)); + homingTurnSpeed += 0.15f * (1f - (lifeRatio * 0.75f + 0.25f)); } float groundPhaseTurnSpeed = death ? 0.24f : 0.18f; if (expertMode) - groundPhaseTurnSpeed += 0.1f * (1f - lifeRatio); + groundPhaseTurnSpeed += 0.1f * (1f - (lifeRatio * 0.75f + 0.25f)); groundPhaseTurnSpeed += Vector2.Distance(destination, NPC.Center) * 0.0002f; - if (Main.getGoodWorld) - { - segmentVelocity *= 1.1f; - speed *= 1.1f; - turnSpeed *= 1.1f; - homingSpeed *= 1.1f; - homingTurnSpeed *= 1.1f; - groundPhaseTurnSpeed *= 1.1f; - } + if (Vector2.Distance(destination, NPC.Center) < 320) + groundPhaseTurnSpeed *= 0.75f; // How long it takes before swapping phases - int phaseLimit = death ? 600 : 900; - if (expertMode && NPC.ai[3] == 0f) + int phaseLimit = 900; + if (spawnedGuardians3) + phaseLimit -= 180; + + if (Main.getGoodWorld) { - phaseLimit /= 1 + (int)((death ? 4f : 5f) * (1f - lifeRatio)); - if (phaseLimit < 180) - phaseLimit = 180; + homingSpeed *= 3f; + homingTurnSpeed *= NPC.Distance(destination) / 500f; + if (NPC.Distance(destination) > 1400) + NPC.ai[1] = 1; + if (NPC.ai[1] == -1) + { + NPC.ai[1] = 0; + } + else + if (NPC.ai[1] == 1) + { + homingTurnSpeed *= 5; + float ftwDotProduct = Vector2.Dot(NPC.DirectionTo(destination), NPC.velocity.SafeNormalize(Vector2.Zero)); + if (ftwDotProduct > 0.95f) + { + NPC.ai[1] = -1; + + } + } + else + Main.NewText(NPC.Distance(destination)); + speed *= 5; + if (NPC.ai[3] == 0) + phaseLimit += 600; + else + phaseLimit -= 600; + + if (lifeRatio < 0.1f && NPC.ai[3] <= 1f) + { + SpawnTeleportLocation(player); + } } // Continuously reset certain things. AttemptingToEnterPortal = false; - // Worm variable - if (NPC.ai[2] > 0f) - NPC.realLife = (int)NPC.ai[2]; // Despawn if (player.dead) { - NPC.ai[3] = 0f; - calamityGlobalNPC.newAI[2] = 0f; + NPC.ai[3] = 3f; + calamityGlobalNPC.newAI[2] = -1f; NPC.velocity.Y -= 4f; @@ -478,16 +562,7 @@ namespace CalamityMod.NPCs.DevourerofGods float distanceFromTarget = Vector2.Distance(destination, NPC.Center); bool increaseSpeed = distanceFromTarget > CalamityGlobalNPC.CatchUpDistance200Tiles; - bool increaseSpeedMore = distanceFromTarget > CalamityGlobalNPC.CatchUpDistance350Tiles; - - float takeLessDamageDistance = 1600f; - if (distanceFromTarget > takeLessDamageDistance) - { - float damageTakenScalar = MathHelper.Clamp(1f - ((distanceFromTarget - takeLessDamageDistance) / takeLessDamageDistance), 0f, 1f); - NPC.takenDamageMultiplier = MathHelper.Lerp(1f, 1.1f, damageTakenScalar); - } - else - NPC.takenDamageMultiplier = 1.1f; + bool increaseSpeedMore = distanceFromTarget > CalamityGlobalNPC.CatchUpDistance350Tiles * 2; // Close DoG's HP bar during P2 transition and decrement the countdown. if (NPC.localAI[2] > 0f) @@ -500,6 +575,7 @@ namespace CalamityMod.NPCs.DevourerofGods float timeWhenDoGShouldTeleportDuringPhase2Countdown = 61f; if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown + (death ? TimeBeforeTeleport_Death : CalamityWorld.revenge ? TimeBeforeTeleport_Revengeance : Main.expertMode ? TimeBeforeTeleport_Expert : TimeBeforeTeleport_Normal)) SpawnTeleportLocation(player, true); + if (NPC.localAI[2] == timeWhenDoGShouldTeleportDuringPhase2Countdown) Teleport(player, death, revenge, expertMode, phase5); @@ -515,7 +591,6 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.Opacity = 0f; NPC.dontTakeDamage = true; } - // Start phase 2, only run things that have to happen once in here if (bigDaddyPhase2) { @@ -554,15 +629,21 @@ namespace CalamityMod.NPCs.DevourerofGods // Dialogue the moment the second phase starts if (NPC.localAI[2] == 60f && !BossRushEvent.BossRushActive) { - string key = "Mods.CalamityMod.Status.Boss.EdgyBossText5"; + string key = "Mods.CalamityMod.Status.Boss.DoGPhase2"; Color messageColor = Color.Cyan; + var ctid = CombatText.NewText(NPC.Hitbox,messageColor, Language.GetTextValue(key),true); + if (ctid < Main.maxCombatText) + player.Calamity().subtitletext = Main.combatText[ctid]; + player.Calamity().subtitleColors = new Color[] { Color.Cyan, Color.Fuchsia }; CalamityUtils.DisplayLocalizedText(key, messageColor); } } // Begin phase 2 + #region Phase 2 if (Phase2Started) { + #region Transition // Go immune and invisible if (NPC.localAI[2] > 5f) { @@ -609,10 +690,12 @@ namespace CalamityMod.NPCs.DevourerofGods AttemptingToEnterPortal = true; } - + #endregion + // Phase 2 else { + #region Misc Stuff I Want To Be Able To Collapse // Immunity after teleport and when dying NPC.dontTakeDamage = postTeleportTimer > 0 || Dying; @@ -620,7 +703,6 @@ namespace CalamityMod.NPCs.DevourerofGods if (teleportTimer > 0) { teleportTimer--; - // Teleport if (teleportTimer == 0) Teleport(player, death, revenge, expertMode, phase5); @@ -642,19 +724,25 @@ namespace CalamityMod.NPCs.DevourerofGods return; } + #endregion // Laser walls - float adjustedAlphaGateValue = AlphaGateValue - (death ? 180f : 0f); - if (phase4 && !spawnedGuardians3 && postTeleportTimer <= 0) + #region Laser Walls + float adjustedAlphaGateValue = AlphaGateValue; + if (phase4 && postTeleportTimer <= 0) { if (laserWallPhase == (int)LaserWallPhase.SetUp) { // Enter laser wall phase very quickly when final phase starts - if (phase6 && calamityGlobalNPC.newAI[3] < adjustedAlphaGateValue) + if (phase6 && !spawnedGuardians3 && calamityGlobalNPC.newAI[3] < adjustedAlphaGateValue) + { + NPC.ai[3] = 2; calamityGlobalNPC.newAI[3] = adjustedAlphaGateValue; + } // Increment next laser wall phase timer - calamityGlobalNPC.newAI[3] += 1f; + if (NPC.ai[3] == 2 || (!spawnedGuardians3 && phase6)) + calamityGlobalNPC.newAI[3] += 1f; // Set alpha value prior to firing laser walls if (calamityGlobalNPC.newAI[3] > adjustedAlphaGateValue) @@ -662,18 +750,15 @@ namespace CalamityMod.NPCs.DevourerofGods // Disable teleports if (teleportTimer > 0) { - GetRiftLocation(false); + GetRiftLocation(true); teleportTimer = 0; } - - NPC.Opacity = 1f - (MathHelper.Clamp((calamityGlobalNPC.newAI[3] - adjustedAlphaGateValue) * 5f, 0f, 255f) / 255f); } // Fire laser walls every X seconds after a laser wall phase ends - float laserWallGateValue = LaserWallCooldown - (death ? 180f : 0f); + float laserWallGateValue = LaserWallCooldown; if (calamityGlobalNPC.newAI[3] >= laserWallGateValue) { - NPC.Opacity = 0f; // Reset laser wall timer to 0 calamityGlobalNPC.newAI[1] = 0f; @@ -688,9 +773,10 @@ namespace CalamityMod.NPCs.DevourerofGods idleCounter--; if (idleCounter <= 0) { - SpawnTeleportLocation(player); laserWallPhase = (int)LaserWallPhase.End; idleCounter = idleCounterMax; + NPC.ai[3] = 3; + calamityGlobalNPC.newAI[2] = 0; } } else if (laserWallPhase == (int)LaserWallPhase.End) @@ -717,19 +803,15 @@ namespace CalamityMod.NPCs.DevourerofGods // Anger message if (!BossRushEvent.BossRushActive) { - string key = "Mods.CalamityMod.Status.Boss.EdgyBossText6"; + string key = "Mods.CalamityMod.Status.Boss.DoGPhase3"; Color messageColor = Color.Cyan; + var ctid = CombatText.NewText(NPC.Hitbox, messageColor, Language.GetTextValue(key), true); + if (ctid < Main.maxCombatText) + player.Calamity().subtitletext = Main.combatText[ctid]; + player.Calamity().subtitleColors = new Color[] { Color.Cyan, Color.Fuchsia }; CalamityUtils.DisplayLocalizedText(key, messageColor); } - // Summon Cosmic Guardians - SoundEngine.PlaySound(AttackSound with { Pitch = AttackSound.Pitch + extrapitch }, player.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - for (int i = 0; i < 3; i++) - NPC.SpawnOnPlayer(NPC.FindClosestPlayer(), ModContent.NPCType()); - } - spawnedGuardians3 = true; } } @@ -740,8 +822,12 @@ namespace CalamityMod.NPCs.DevourerofGods // Set opacity after teleport if (postTeleportTimer > 0) { + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + postTeleportTimer--; NPC.Opacity = 1f - (postTeleportTimer / 255f); + if (NPC.ai[3] < 2) + calamityGlobalNPC.newAI[2] = 0; } else { @@ -752,256 +838,65 @@ namespace CalamityMod.NPCs.DevourerofGods } // Fireballs - // Check angle and distance to make sure it's realistic that they'd be fired - if (NPC.Opacity >= 1f && distanceFromTarget > 480f && (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) + if (isInPassiveState) { - calamityGlobalNPC.newAI[0] += 1f; - if (calamityGlobalNPC.newAI[0] >= (Main.getGoodWorld ? 30f : 150f) && calamityGlobalNPC.newAI[0] % (Main.getGoodWorld ? 30f : phase7 ? 30f : 60f) == 0f) - { - float fireballSpeed = 8f; - Vector2 fireballVelocity = Vector2.Normalize(player.Center - NPC.Center) * fireballSpeed + NPC.velocity * 0.5f; - - Vector2 dustVelocity = fireballVelocity * 2f; - for (int k = 0; k < 50; k++) - Dust.NewDust(NPC.Center, 52, 52, (int)CalamityDusts.PurpleCosmilite, dustVelocity.X, dustVelocity.Y); - - int type = ModContent.ProjectileType(); - int damage = FireballDamage; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, fireballVelocity, type, damage, 0f, Main.myPlayer); - - if (Main.zenithWorld) - { - for (int l = 0; l < 8; l++) - { - int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Ichor, 0f, 0f, 100, default, 1f); - float dustVelocityYAdd = Math.Abs(Main.dust[dust].velocity.Y) * 0.5f; - if (Main.dust[dust].velocity.Y < 0f) - Main.dust[dust].velocity.Y = 2f + dustVelocityYAdd; - if (Main.rand.NextBool()) - { - Main.dust[dust].scale = 0.25f; - Main.dust[dust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - int numBlobs = 4; - type = ModContent.ProjectileType(); - - for (int i = 0; i < numBlobs; i++) - { - Vector2 blobVelocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - blobVelocity.Normalize(); - blobVelocity *= Main.rand.Next(400, 801) * 0.01f; - blobVelocity *= Main.rand.NextFloat() + 1f; - - float blobVelocityYAdd = Math.Abs(blobVelocity.Y) * 0.5f; - if (blobVelocity.Y < 2f) - blobVelocity.Y = 2f + blobVelocityYAdd; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitY * 50f, blobVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); - } - } - } + ShootFireballs(player, distanceFromTarget, revenge); } - else if (distanceFromTarget < 240f) + else + { calamityGlobalNPC.newAI[0] = 0f; + } // Laser walls - if (!spawnedGuardians3 && laserWallPhase == (int)LaserWallPhase.FireLaserWalls) + if (laserWallPhase == (int)LaserWallPhase.FireLaserWalls) { - float spawnOffset = 1200f; - float divisor = 150f; - - if (calamityGlobalNPC.newAI[1] % divisor == 0f) + if (death && phase6) { - SoundEngine.PlaySound(SoundID.Item12, player.Center); - - // Side walls - float targetPosY = player.position.Y; - int type = ModContent.ProjectileType(); - int damage = LaserWallDamage; - int halfTotalDiagonalShots = totalDiagonalShots / 2; - Vector2 start = default; - Vector2 velocity = default; - Vector2 aim = expertMode ? player.Center + player.velocity * 20f : Vector2.Zero; - - switch (laserWallType_Phase2) - { - case (int)LaserWallType_Phase2.Normal: - - for (int x = 0; x < totalShots_Phase2; x++) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - shotSpacing_Phase2[0] -= spacingVar_Phase2; - } - - if (expertMode && Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; - - case (int)LaserWallType_Phase2.Offset: - - targetPosY += 50f; - for (int x = 0; x < totalShots_Phase2; x++) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - shotSpacing_Phase2[0] -= spacingVar_Phase2; - } - - if (expertMode && Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; - - case (int)LaserWallType_Phase2.DiagonalHorizontal: - - for (int x = 0; x < totalDiagonalShots + 1; x++) - { - start = new Vector2(player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0]); - aim.Y += laserWallSpacingOffset * (x - halfTotalDiagonalShots); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0]); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing_Phase2[0] -= diagonalSpacingVar; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X, targetPosY + spawnOffset, 0f, -laserVelocity, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center.X, targetPosY - spawnOffset, 0f, laserVelocity, type, damage, 0f, Main.myPlayer); - } - - break; - - case (int)LaserWallType_Phase2.MultiLayered: - - for (int x = 0; x < totalShots_Phase2; x++) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[0], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[0], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - shotSpacing_Phase2[0] -= spacingVar_Phase2; - } - - int totalBonusLasers = totalShots_Phase2 / 2; - for (int x = 0; x < totalBonusLasers; x++) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, targetPosY + shotSpacing_Phase2[3], -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, targetPosY + shotSpacing_Phase2[3], laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - shotSpacing_Phase2[3] -= Main.rand.NextBool() ? 215 : 235; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; - - case (int)LaserWallType_Phase2.DiagonalVertical: - - for (int x = 0; x < totalDiagonalShots + 1; x++) - { - start = new Vector2(player.position.X + shotSpacing_Phase2[0], targetPosY + spawnOffset); - aim.X += laserWallSpacingOffset * (x - halfTotalDiagonalShots); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X + shotSpacing_Phase2[0], targetPosY - spawnOffset); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing_Phase2[0] -= diagonalSpacingVar; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; - } - - // Pick a random laser wall phase in expert+ - if (expertMode) - { - int laserWallPhase; - int choices = revenge ? 5 : 3; - do laserWallPhase = Main.rand.Next(choices); - while (laserWallPhase == laserWallType_Phase2); - laserWallType_Phase2 = laserWallPhase; - } - else - laserWallType_Phase2 = laserWallType_Phase2 == (int)LaserWallType_Phase2.Normal ? (int)LaserWallType_Phase2.Offset : (int)LaserWallType_Phase2.Normal; - - // Lower wall - for (int x = 0; x < totalShots_Phase2; x++) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + shotSpacing_Phase2[1], player.position.Y + spawnOffset, 0f, -laserVelocity, type, damage, 0f, Main.myPlayer); - - shotSpacing_Phase2[1] -= spacingVar_Phase2; - } - - // Upper wall - for (int x = 0; x < totalShots_Phase2; x++) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + shotSpacing_Phase2[2], player.position.Y - spawnOffset, 0f, laserVelocity, type, damage, 0f, Main.myPlayer); - - shotSpacing_Phase2[2] -= spacingVar_Phase2; - } - - for (int i = 0; i < shotSpacing_Phase2.Length; i++) - shotSpacing_Phase2[i] = shotSpacingMax_Phase2; + float spacing = 320; + float miniInterval = 12; + float megaInterval = 120; + float time = 0.35f; + for (var i = 0; i < 3; i++) + if ((int)(calamityGlobalNPC.newAI[1] - miniInterval * i) % megaInterval == 0f) + { + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center + Main.rand.NextVector2CircularEdge(600, 600), Vector2.Zero, ModContent.ProjectileType(), LaserWallDamage, 0, Main.myPlayer, time, spacing, 2-i); + if (i == 2) + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center, Vector2.Zero, ModContent.ProjectileType(), LaserWallMiddleBeamDamage, 0, Main.myPlayer, time, 0, i); + else if (Main.zenithWorld) + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center + Main.rand.NextVector2CircularEdge(600, 600), Vector2.Zero, ModContent.ProjectileType(), LaserWallDamage, 0, Main.myPlayer, time, 240, 6); + } + calamityGlobalNPC.newAI[1] += 1f; } + else + { + float divisor = death ? 100f : 120f; + if (phase6) + divisor -= 15; - calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] % divisor == 0f) + { + float spacing = death ? 144 : 160; + if (divisor == 0) + spacing += 64; + if (phase6) + spacing += death ? 64 : 32; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int bType = Main.rand.Next(0, 5 + 1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center + Main.rand.NextVector2CircularEdge(600, 600), Vector2.Zero, ModContent.ProjectileType(), LaserWallDamage, 0, Main.myPlayer, 0.5f, spacing, bType); + if (phase6 || death) + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center, Vector2.Zero, ModContent.ProjectileType(), LaserWallMiddleBeamDamage, 0, Main.myPlayer, 0.5f, 0, bType); + + if (Main.zenithWorld) + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center + Main.rand.NextVector2CircularEdge(600, 600), Vector2.Zero, ModContent.ProjectileType(), LaserWallDamage, 0, Main.myPlayer, 0.5f, 120, 6); + } + } + calamityGlobalNPC.newAI[1] += 1f; + } } // Set flight time to max during laser walls - if (!spawnedGuardians3 && laserWallPhase == (int)LaserWallPhase.FireLaserWalls) + if (laserWallPhase == (int)LaserWallPhase.FireLaserWalls) { if (!Main.dedServ) { @@ -1009,6 +904,7 @@ namespace CalamityMod.NPCs.DevourerofGods Main.LocalPlayer.Calamity().infiniteFlight = true; } } + #endregion // Movement int tilePositionX = (int)(NPC.position.X / 16f) - 1; @@ -1030,13 +926,35 @@ namespace CalamityMod.NPCs.DevourerofGods else if (NPC.velocity.X > 0f) NPC.spriteDirection = 1; + var VelocityRotation = NPC.velocity.ToRotation(); + void TurnTowards(Vector2 goal, float offset = 0, float maxSpeed = 1) + { + float goal2 = (goal - NPC.Center).ToRotation() + offset; + maxSpeed *= (float)Math.PI / 180f; + var dif = MathF.Atan2(MathF.Sin(goal2 - VelocityRotation), MathF.Cos(goal2 - VelocityRotation)); + if (dif < 0) + { + if (-dif > maxSpeed) + VelocityRotation -= maxSpeed; + else + VelocityRotation += dif; + } else + { + if (dif > maxSpeed) + VelocityRotation += maxSpeed; + else + VelocityRotation += dif; + } + } + // Flight + #region Air AI if (NPC.ai[3] == 0f) { if (!Main.dedServ) { if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); + Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); } // Charge in a direction for a second until the timer is back at 0 @@ -1064,61 +982,17 @@ namespace CalamityMod.NPCs.DevourerofGods Vector2 npcCenter = NPC.Center; float targetX = destination.X; float targetY = destination.Y; - int flyYLevel = -1; int destinationTileX = (int)(destination.X / 16f); int destinationTileY = (int)(destination.Y / 16f); - - // Charge at target for 1.5 seconds - bool flyAtTarget = (!phase4 || spawnedGuardians3) && calamityGlobalNPC.newAI[2] > phaseLimit - 90 && revenge; - - for (int i = destinationTileX - 2; i <= destinationTileX + 2; i++) - { - for (int j = destinationTileY; j <= destinationTileY + 15; j++) - { - if (WorldGen.SolidTile2(i, j)) - { - flyYLevel = j; - break; - } - } - if (flyYLevel > 0) - break; - } - - if (!flyAtTarget && destination == player.Center) - { - if (flyYLevel > 0) - { - flyYLevel *= 16; - float chaseFlyLevel = flyYLevel - 800; - if (player.position.Y > chaseFlyLevel) - { - targetY = chaseFlyLevel; - if (Math.Abs(NPC.Center.X - destination.X) < 500f) - { - if (NPC.velocity.X > 0f) - targetX = destination.X + 600f; - else - targetX = destination.X - 600f; - } - } - } - } - else - { - speedCopy = homingSpeed; - turnSpeedCopy = homingTurnSpeed; - } + + + speedCopy = homingSpeed; + turnSpeedCopy = homingTurnSpeed; + speedCopy += Vector2.Distance(destination, NPC.Center) * 0.005f; turnSpeedCopy += Vector2.Distance(destination, NPC.Center) * 0.00025f; - if (Main.getGoodWorld) - { - if ((player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) - speedCopy *= 2f; - } - float fasterSpeedMult = speedCopy * 1.3f; float slowerSpeedMult = speedCopy * 0.7f; float npcSpeed = NPC.velocity.Length(); @@ -1135,7 +1009,6 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.velocity *= slowerSpeedMult; } } - targetX = (int)(targetX / 16f) * 16; targetY = (int)(targetY / 16f) * 16; npcCenter.X = (int)(npcCenter.X / 16f) * 16; @@ -1149,6 +1022,7 @@ namespace CalamityMod.NPCs.DevourerofGods targetX *= timeToReachTarget; targetY *= timeToReachTarget; + turnSpeedCopy *= NPC.Distance(destination) / ( death ? 800 : 1000f); if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f) || (NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f)) { if (NPC.velocity.X < targetX) @@ -1239,14 +1113,15 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.ForceNetUpdate(false); } } - + #endregion // Ground - else + #region Ground AI + else if (NPC.ai[3] == 1f) { if (!Main.dedServ) { if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); + Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); } // Charge in a direction for a second until the timer is back at 0 @@ -1271,12 +1146,7 @@ namespace CalamityMod.NPCs.DevourerofGods else if (increaseSpeed) groundPhaseTurnSpeed *= 2f; - if (Main.getGoodWorld) - { - if ((player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) - segmentVelocity *= 2f; - } - + #region Digging AI if (!flies) { for (int r = tilePositionX; r < tileWidthPosX; r++) @@ -1385,6 +1255,9 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.velocity.X = 0f; } } + #endregion + + #region Flying AI else { double maximumSpeed1 = death ? 0.46 : 0.4; @@ -1475,7 +1348,7 @@ namespace CalamityMod.NPCs.DevourerofGods } } } - + #endregion // Set velocity so that DoG cannot speed burst instantly at the start of a phase swap if (calamityGlobalNPC.velocityPriorToPhaseSwap > 0f) { @@ -1509,24 +1382,75 @@ namespace CalamityMod.NPCs.DevourerofGods if (calamityGlobalNPC.newAI[2] > phaseLimit) { + + calamityGlobalNPC.velocityPriorToPhaseSwap = NPC.velocity.Length(); NPC.ai[3] = 0f; calamityGlobalNPC.newAI[2] = 0f; + + if ((phase4)) + { + calamityGlobalNPC.newAI[3] = AlphaGateValue-120; + NPC.ai[3] = 2f; + + } NPC.TargetClosest(); NPC.ForceNetUpdate(false); } } + #endregion + + #region Laser Wall AI + else if (NPC.ai[3] == 2) + { + calamityGlobalNPC.newAI[2]++; + if (laserWallPhase != (int)LaserWallPhase.End) + { + var dogRotation = player.DirectionTo(NPC.Center).ToRotation(); + var DOGDIR = 1; + + var goalpos = player.Center + new Vector2(1000, 0).RotatedBy(dogRotation + 0.05f * DOGDIR); + + var currentVelLength = NPC.velocity.Length(); + var goalVel = NPC.DirectionTo(goalpos) * currentVelLength; + + TurnTowards(goalpos,maxSpeed: 6f * calamityGlobalNPC.newAI[2] / 120f); + NPC.velocity = VelocityRotation.ToRotationVector2() * (currentVelLength < 40 ? currentVelLength + 0.2f : currentVelLength > 42 ? currentVelLength - 0.2f : currentVelLength); + + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + } + } + #endregion + #region Portal AI + else + { + if (calamityGlobalNPC.newAI[2] == 0) + { + SpawnTeleportLocation(player); + } + NPC.velocity *= 1.02f; + calamityGlobalNPC.newAI[2]++; + + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + } + #endregion } } + #endregion + #region Phase 1 else { - // Spawn Guardians + // Spawn fireballs if (phase3) { - if (!death) + // Fireballs + if (isInPassiveState) { - if (NPC.localAI[3] < SkyColorTransitionTime) - NPC.localAI[3] += 1f; + ShootFireballs(player, distanceFromTarget, revenge); + } + else + { + calamityGlobalNPC.newAI[0] = 0f; } if (!spawnedGuardians) @@ -1536,28 +1460,18 @@ namespace CalamityMod.NPCs.DevourerofGods if (!BossRushEvent.BossRushActive) { - string key = "Mods.CalamityMod.Status.Boss.EdgyBossText"; + string key = "Mods.CalamityMod.Status.Boss.DoGSubphase1"; Color messageColor = Color.Cyan; + int ctid = CombatText.NewText(NPC.Hitbox, messageColor, Language.GetTextValue(key), true); + if (ctid < Main.maxCombatText) + player.Calamity().subtitletext = Main.combatText[ctid]; + player.Calamity().subtitleColors = new Color[] { Color.Cyan, Color.Fuchsia }; CalamityUtils.DisplayLocalizedText(key, messageColor); } NPC.TargetClosest(); spawnedGuardians = true; } - - if (spawnDoGCountdown > 0) - { - spawnDoGCountdown--; - if (spawnDoGCountdown == 0) - { - SoundEngine.PlaySound(AttackSound with { Pitch = AttackSound.Pitch + extrapitch }, player.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - for (int i = 0; i < 2; i++) - NPC.SpawnOnPlayer(NPC.FindClosestPlayer(), ModContent.NPCType()); - } - } - } } else if (phase2) { @@ -1569,21 +1483,10 @@ namespace CalamityMod.NPCs.DevourerofGods spawnedGuardians2 = true; } - if (spawnDoGCountdown > 0) - { - spawnDoGCountdown--; - if (spawnDoGCountdown == 0) - { - SoundEngine.PlaySound(AttackSound with { Pitch = AttackSound.Pitch + extrapitch }, player.Center); - - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(NPC.FindClosestPlayer(), ModContent.NPCType()); - } - } } // Laser barrage attack variables - float laserBarrageGateValue = death ? 1320f : 1440f; + float laserBarrageGateValue = 1440f; float laserBarrageShootGateValue = 240f; float laserBarragePhaseGateValue = laserBarrageGateValue - laserBarrageShootGateValue; @@ -1622,164 +1525,39 @@ namespace CalamityMod.NPCs.DevourerofGods if (phase2) { - float spawnOffset = 1200f; - - calamityGlobalNPC.newAI[1] += 1f; + if (NPC.ai[3] == 2) + calamityGlobalNPC.newAI[1] += 1f; if (calamityGlobalNPC.newAI[1] >= laserBarragePhaseGateValue) { + if (!Main.dedServ) + { + if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) + Main.LocalPlayer.Calamity().infiniteFlight = true; + } if (calamityGlobalNPC.newAI[1] >= laserBarrageGateValue) - calamityGlobalNPC.newAI[1] = 0f; - - if (calamityGlobalNPC.newAI[1] % (laserBarrageShootGateValue * 0.5f) == 0f && calamityGlobalNPC.newAI[1] > 0f) { - SoundEngine.PlaySound(SoundID.Item12, player.Center); + calamityGlobalNPC.newAI[1] = 0f; + NPC.ai[3] = 3; + calamityGlobalNPC.newAI[2] = 0; + NPC.velocity += player.DirectionTo(NPC.Center) * 15; + } - // Side walls - int type = ModContent.ProjectileType(); - int damage = LaserWallDamage; - Vector2 start = default; - Vector2 velocity = default; - Vector2 aim = expertMode ? player.Center + player.velocity * 20f : Vector2.Zero; - Vector2 aimClone = aim; - - switch (laserWallType) + if (calamityGlobalNPC.newAI[1] % (int)(laserBarrageShootGateValue * (death ? 0.33f : 0.5f)) == 0f && calamityGlobalNPC.newAI[1] > 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) { - case (int)LaserWallType.DiagonalRight: + int bType = Main.rand.Next(0, 5 + 1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center + Main.rand.NextVector2CircularEdge(600, 600), Vector2.Zero, ModContent.ProjectileType(), LaserWallDamage, 0, Main.myPlayer, 0.45f, 170, bType); - for (int x = 0; x < totalShots + 1; x++) - { - start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing -= spacingVar; - } - - if (expertMode && Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - - break; - - case (int)LaserWallType.DiagonalLeft: - - for (int x = 0; x < totalShots + 1; x++) - { - start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing -= spacingVar; - } - - if (expertMode && Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - - break; - - case (int)LaserWallType.DiagonalHorizontal: - - for (int x = 0; x < totalShots + 1; x++) - { - start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - shotSpacing -= spacingVar; - } - - if (expertMode && Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; - - case (int)LaserWallType.DiagonalCross: - - int randomLaserGap = Main.rand.Next(3) + 3; // 3, 4, 5, 6 - for (int x = 0; x < totalShots + 1; x++) - { - if (x != randomLaserGap && x != randomLaserGap + 1) - { - start = new Vector2(player.position.X + spawnOffset, player.position.Y + shotSpacing); - aim.Y += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X - spawnOffset, player.position.Y + shotSpacing); - velocity = Vector2.Normalize(aim - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X + shotSpacing, player.position.Y + spawnOffset); - aimClone.X += laserWallSpacingOffset * (x - 3); - velocity = Vector2.Normalize(aimClone - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - - start = new Vector2(player.position.X + shotSpacing, player.position.Y - spawnOffset); - velocity = Vector2.Normalize(aimClone - start) * laserVelocity; - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), start, velocity, type, damage, 0f, Main.myPlayer); - } - - shotSpacing -= spacingVar; - } - - if (expertMode && Main.netMode != NetmodeID.MultiplayerClient) - { - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X + spawnOffset, player.Center.Y, -laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(NPC.GetSource_FromAI(), player.position.X - spawnOffset, player.Center.Y, laserVelocity, 0f, type, damage, 0f, Main.myPlayer); - } - - break; + if (Main.zenithWorld) + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center + Main.rand.NextVector2CircularEdge(600, 600), Vector2.Zero, ModContent.ProjectileType(), LaserWallDamage, 0, Main.myPlayer, 0.45f, 120, 6); } - - // Pick a random laser wall phase in expert+ - if (expertMode) - { - int laserWallPhase; - int choices = revenge ? 4 : 3; - do laserWallPhase = Main.rand.Next(choices); - while (laserWallPhase == laserWallType); - laserWallType = laserWallPhase; - } - else - laserWallType = laserWallType == (int)LaserWallType.DiagonalRight ? (int)LaserWallType.DiagonalLeft : (int)LaserWallType.DiagonalRight; - - shotSpacing = shotSpacingMax; } } } // Opacity - if (phase2 && calamityGlobalNPC.newAI[1] >= laserBarragePhaseGateValue) - { - // Adjust opacity upon entering laser barrage phase - NPC.Opacity = 1f - (MathHelper.Clamp((calamityGlobalNPC.newAI[1] - laserBarragePhaseGateValue) * 5f, 0f, 255f) / 255f); - } - else + if (!(phase2 && calamityGlobalNPC.newAI[1] >= laserBarragePhaseGateValue) && !bigDaddyPhase2) { // 2 seconds to become fully visible again NPC.Opacity += 0.0083f; @@ -1807,13 +1585,36 @@ namespace CalamityMod.NPCs.DevourerofGods else if (NPC.velocity.X > 0f) NPC.spriteDirection = 1; + var VelocityRotation = NPC.velocity.ToRotation(); + void TurnTowards(Vector2 goal, float offset = 0, float maxSpeed = 1) + { + float goal2 = (goal - NPC.Center).ToRotation() + offset; + maxSpeed *= (float)Math.PI / 180f; + var dif = MathF.Atan2(MathF.Sin(goal2 - VelocityRotation), MathF.Cos(goal2 - VelocityRotation)); + if (dif < 0) + { + if (-dif > maxSpeed) + VelocityRotation -= maxSpeed; + else + VelocityRotation += dif; + } + else + { + if (dif > maxSpeed) + VelocityRotation += maxSpeed; + else + VelocityRotation += dif; + } + } + // Flight - if (NPC.ai[3] == 0f) + #region Phase 1 Air AI + if (NPC.ai[3] == 1f) { if (!Main.dedServ) { if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); + Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); } // Flying movement @@ -1826,58 +1627,15 @@ namespace CalamityMod.NPCs.DevourerofGods Vector2 npcCenter = NPC.Center; float targetX = player.position.X + (player.width / 2); float targetY = player.position.Y + (player.height / 2); - int flyYLevel = -1; - int destinationTileX = (int)(destination.X / 16f); - int destinationTileY = (int)(destination.Y / 16f); - - for (int i = destinationTileX - 2; i <= destinationTileX + 2; i++) - { - for (int j = destinationTileY; j <= destinationTileY + 15; j++) - { - if (WorldGen.SolidTile2(i, j)) - { - flyYLevel = j; - break; - } - } - if (flyYLevel > 0) - break; - } - - if (flyYLevel > 0) - { - flyYLevel *= 16; - float chaseFlyLevel = flyYLevel - 800; - if (player.position.Y > chaseFlyLevel) - { - targetY = chaseFlyLevel; - if (Math.Abs(NPC.Center.X - destination.X) < 500f) - { - if (NPC.velocity.X > 0f) - targetX = destination.X + 600f; - else - targetX = destination.X - 600f; - } - } - } - else - { - speedCopy = homingSpeed; - turnSpeedCopy = homingTurnSpeed; - } + + speedCopy = homingSpeed; + turnSpeedCopy = homingTurnSpeed; if (expertMode) { speedCopy += distanceFromTarget * 0.005f * (1f - lifeRatio); turnSpeedCopy += distanceFromTarget * 0.0001f * (1f - lifeRatio); } - - if (Main.getGoodWorld) - { - if ((player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) - speedCopy *= 2f; - } - float fasterSpeedMult = speedCopy * 1.3f; float slowerSpeedMult = speedCopy * 0.7f; float npcSpeed = NPC.velocity.Length(); @@ -1908,6 +1666,7 @@ namespace CalamityMod.NPCs.DevourerofGods targetX *= timeToReachTarget; targetY *= timeToReachTarget; + turnSpeedCopy *= NPC.Distance(destination) / (death ? 800 : 1000); if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f) || (NPC.velocity.Y > 0f && targetY > 0f) || (NPC.velocity.Y < 0f && targetY < 0f)) { if (NPC.velocity.X < targetX) @@ -1992,20 +1751,26 @@ namespace CalamityMod.NPCs.DevourerofGods if (calamityGlobalNPC.newAI[2] > phaseLimit) { calamityGlobalNPC.velocityPriorToPhaseSwap = NPC.velocity.Length(); - NPC.ai[3] = 1f; - calamityGlobalNPC.newAI[2] = 0f; + NPC.ai[3] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + if (phase2) + { + NPC.ai[3] = 2; + calamityGlobalNPC.newAI[1] = laserBarragePhaseGateValue - 120; + } NPC.TargetClosest(); NPC.ForceNetUpdate(false); } } - + #endregion // Ground - else + #region Phase 1 Ground AI + else if (NPC.ai[3] == 0) { if (!Main.dedServ) { if (!Main.LocalPlayer.dead && Main.LocalPlayer.active && Vector2.Distance(Main.LocalPlayer.Center, NPC.Center) < CalamityGlobalNPC.CatchUpDistance350Tiles) - Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); + Main.LocalPlayer.AddBuff(ModContent.BuffType(), 2); } calamityGlobalNPC.newAI[2] += 1f; @@ -2016,12 +1781,6 @@ namespace CalamityMod.NPCs.DevourerofGods else if (increaseSpeed) groundPhaseTurnSpeed *= 2f; - if (Main.getGoodWorld) - { - if ((player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) - segmentVelocity *= 2f; - } - if (!flies) { for (int r = tilePositionX; r < tileWidthPosX; r++) @@ -2255,47 +2014,212 @@ namespace CalamityMod.NPCs.DevourerofGods if (calamityGlobalNPC.newAI[2] > phaseLimit) { calamityGlobalNPC.velocityPriorToPhaseSwap = NPC.velocity.Length(); - NPC.ai[3] = 0f; + NPC.ai[3] = 1f; calamityGlobalNPC.newAI[2] = 0f; NPC.TargetClosest(); NPC.netUpdate = true; } } + #endregion + + #region Laser Wall AI + else if (NPC.ai[3] == 2) + { + calamityGlobalNPC.newAI[2]++; + if (laserWallPhase != (int)LaserWallPhase.End) + { + var dogRotation = player.DirectionTo(NPC.Center).ToRotation(); + var DOGDIR = 1; + + var goalpos = player.Center + new Vector2(1000, 0).RotatedBy(dogRotation + 0.05f * DOGDIR); + + var currentVelLength = NPC.velocity.Length(); + var goalVel = NPC.DirectionTo(goalpos) * currentVelLength; + + TurnTowards(goalpos, maxSpeed: 6f * calamityGlobalNPC.newAI[2] / 120f); + NPC.velocity = VelocityRotation.ToRotationVector2() * (currentVelLength < 40 ? currentVelLength + 0.2f : currentVelLength); + + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + } + } + #endregion + + #region Decoil AI + else + { + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; + calamityGlobalNPC.newAI[2]++; + if (calamityGlobalNPC.newAI[2] >= 45) + { + NPC.ai[3] = 0; + calamityGlobalNPC.newAI[2] = 0; + } + } + #endregion } + #endregion // There is no escape... - if (NPC.Distance(player.Center) > 2400f) - NPC.velocity += (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; + if (NPC.Distance(destination) > 2400f) + NPC.velocity += (destination - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; + // Jaw movement. + float targetRotationReset = ((Phase2Started || phase3) && isInPassiveState) ? MathHelper.ToRadians(10f) : 0f; + float targetRotationOpenJaw = MathHelper.ToRadians(Phase2Started ? 32f : 22f); + float targetRotationChompDown = MathHelper.ToRadians(Phase2Started ? -25f : -15f); + float dotProduct = Vector2.Dot(NPC.DirectionTo(destination), NPC.velocity.SafeNormalize(Vector2.Zero)); + bool rotatedTowardsPlayer = dotProduct > 0.8f; + + // Reset slowly at all times. + JawRotation = MathHelper.Lerp(JawRotation, targetRotationReset, 0.08f); + + // Chomp down when close enough to the player. + if (distanceFromTarget < 110f) + { + JawRotation = MathHelper.Lerp(JawRotation, targetRotationChompDown, JawChompDownProgress); + JawChompDownProgress = MathHelper.Clamp(JawChompDownProgress + 0.28f, 0f, 1f); + + // Spawn some particle effects when chomping down + if (JawChompDownProgress >= 0.94f && ShouldSpawnChompVFX) + { + Vector2 jawChompPosition = (NPC.Center - Vector2.UnitY.RotatedBy(NPC.rotation) * 36f) + (NPC.velocity * 1.45f); + Color jawParticleColor = isInPassiveState ? Color.Cyan : Color.Purple; + for (int i = 0; i < 20; i++) + { + Vector2 sparkVelocity = NPC.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(26f, 32f); + int sparkLifetime = Main.rand.Next(20, 30); + float sparkScale = Main.rand.NextFloat(1.4f, 1.8f); + Color sparkColor = Color.Lerp(jawParticleColor, Color.White, Main.rand.NextFloat(0f, 0.3f)); + + SparkParticle chompSpark = new(jawChompPosition, sparkVelocity, false, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(chompSpark); + } + + // Play a sound and add some screenshake with it if you're close enough too. + float shakeStrength = Phase2Started ? 14f : 8f; + CalamityUtils.AddScreenshakeAt(jawChompPosition, shakeStrength, 100f); + SoundEngine.PlaySound(HitSound with { Pitch = -0.45f }, jawChompPosition); + ShouldSpawnChompVFX = false; + NPC.netUpdate = true; + } + } + // Only open up when DoG is facing the player. + else if (distanceFromTarget < 480f && rotatedTowardsPlayer) + { + JawRotation = MathHelper.Lerp(JawRotation, targetRotationOpenJaw, 0.28f); + if (!ShouldSpawnChompVFX) + ShouldSpawnChompVFX = true; + } + + // Fade out the special jaw texture during rift dashes. + GodSlayerDashJawTimer--; + if (GodSlayerDashJawTimer <= 0f) + { + GodSlayerDashJawFadeProgress = MathHelper.Lerp(GodSlayerDashJawFadeProgress, 0f, 0.15f); + if (GodSlayerDashJawTimer < 0f) + GodSlayerDashJawTimer = 0f; + } if (NPC.life > Main.npc[(int)NPC.ai[0]].life) NPC.life = Main.npc[(int)NPC.ai[0]].life; } + private void ShootFireballs(Player player, float distanceFromTarget, bool revenge) + { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + Vector2 mouthPosition = NPC.Center - Vector2.UnitY.RotatedBy(NPC.rotation) * (Phase2Started ? 28f : -16f); + + calamityGlobalNPC.newAI[0] += 1f; + if (NPC.Opacity >= 1f && (distanceFromTarget > (revenge ? 320f : 480f))) + { + float dotProduct = Vector2.Dot(NPC.DirectionTo(AdjustedPlayerCenter()), NPC.velocity.SafeNormalize(Vector2.Zero)); + if (dotProduct > 0.8f) + { + if (calamityGlobalNPC.newAI[0] > 75f) + { + // Flame and cinder particles from the mouth. + for (int i = 0; i < 18; i++) + { + Vector2 flameVelocity = NPC.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(32f, 44f); + int flameLifetime = Main.rand.Next(45, 60); + float flameScale = Main.rand.NextFloat(0.6f, 0.9f); + float flameOpacity = Main.rand.NextFloat(0.7f, 0.9f); + Color flameColor = Color.Lerp(Color.Cyan, Color.White, Main.rand.NextFloat(0f, 0.4f)); + + HeavySmokeParticle fireballFlames = new(mouthPosition, flameVelocity, flameColor, flameLifetime, flameScale, flameOpacity, 0.01f, true); + GeneralParticleHandler.SpawnParticle(fireballFlames); + } + + for (int i = 0; i < 10; i++) + { + Vector2 cinderVelocity = NPC.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(36f, 48f); + float cinderScale = Main.rand.NextFloat(0.3f, 0.5f); + Color cinderColor = Color.Lerp(Color.Cyan, Color.White, Main.rand.NextFloat(0.2f, 0.6f)); + int cinderLifetime = Main.rand.Next(45, 60); + + SquishyLightParticle cinder = new(mouthPosition, cinderVelocity, cinderScale, cinderColor, cinderLifetime); + GeneralParticleHandler.SpawnParticle(cinder); + } + + // Open DoG's mouth a bit everytime a fireball is fired. + JawRotation = MathHelper.ToRadians(22f); + + float fireballSpeed = 8f; + Vector2 fireballVelocity = Vector2.Normalize(AdjustedPlayerCenter() - NPC.Center) * (fireballSpeed + NPC.velocity.Length() * 0.5f); + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(NPC.GetSource_FromAI(), mouthPosition, fireballVelocity, ModContent.ProjectileType(), FireballDamage, 0f, Main.myPlayer, 2f); + + calamityGlobalNPC.newAI[0] = 0f; + NPC.ForceNetUpdate(false); + } + } + } + + } + private void SpawnTeleportLocation(Player player, bool phase2Transition = false) { if (teleportTimer > 0 || player.dead || !player.active) return; - if (!phase2Transition) - teleportTimer = (CalamityWorld.death || BossRushEvent.BossRushActive) ? TimeBeforeTeleport_Death : CalamityWorld.revenge ? TimeBeforeTeleport_Revengeance : Main.expertMode ? TimeBeforeTeleport_Expert : TimeBeforeTeleport_Normal; + if (NPC.ai[3] < 2) + NPC.ai[3] = 3; - SoundEngine.PlaySound(SoundID.Item109, player.Center); + int baseTeleportTime = ((CalamityWorld.death || BossRushEvent.BossRushActive) ? TimeBeforeTeleport_Death : CalamityWorld.revenge ? TimeBeforeTeleport_Revengeance : Main.expertMode ? TimeBeforeTeleport_Expert : TimeBeforeTeleport_Normal); + if ((CalamityWorld.death || BossRushEvent.BossRushActive) && NPC.life / (float)NPC.lifeMax < 0.25f && NPC.ai[3] < 8 && NPC.ai[3] > 3) + baseTeleportTime -= 45; + + if (!phase2Transition) + teleportTimer = baseTeleportTime; + + SoundEngine.PlaySound(RiftOpenSound with {Volume = 1.5f}, player.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { int randomRange = Main.zenithWorld ? 960 : 48; float distance = 500f; + if ((CalamityWorld.death || BossRushEvent.BossRushActive) && NPC.life / (float)NPC.lifeMax < 0.25f && NPC.ai[3] < 8) + { + distance += 450; //More breathing room for rapid dash + } Vector2 targetVector = player.Center + player.velocity.SafeNormalize(Vector2.UnitX) * distance + new Vector2(Main.rand.Next(-randomRange, randomRange + 1), Main.rand.Next(-randomRange, randomRange + 1)); - Projectile.NewProjectile(NPC.GetSource_FromAI(), targetVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, NPC.whoAmI); + int rift = Projectile.NewProjectile(NPC.GetSource_FromAI(), targetVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, NPC.whoAmI); + if (Main.projectile.IndexInRange(rift)) + Main.projectile[rift].ModProjectile().RiftLifetime = baseTeleportTime; + // GFB, spawn a ton of fake rifts alongside the real one. if (Main.zenithWorld) { - // Fake portals galore randomRange = 2000; for (int k = 0; k < 35; k++) { targetVector = player.Center + player.velocity.SafeNormalize(Vector2.UnitX) * distance + new Vector2(Main.rand.Next(-randomRange, randomRange + 1), Main.rand.Next(-randomRange, randomRange + 1)); - Projectile.NewProjectile(NPC.GetSource_FromAI(), targetVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, NPC.whoAmI, ai2: 1f); + int faker = Projectile.NewProjectile(NPC.GetSource_FromAI(), targetVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, NPC.whoAmI); + if (Main.projectile.IndexInRange(faker)) + { + Main.projectile[faker].ModProjectile().FakeRift = true; + Main.projectile[faker].ModProjectile().RiftLifetime = baseTeleportTime; + } } } } @@ -2307,19 +2231,18 @@ namespace CalamityMod.NPCs.DevourerofGods if ((!AwaitingPhase2Teleport && (player.dead || !player.active)) || newPosition == default) return; + bool phase6 = NPC.life / (float)NPC.lifeMax < 0.25f; - if (phase5) - { - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient && !(death && phase6 && NPC.ai[3] < 7)) // 4 dashes on Death phase 3 without fireballs { - int type = ModContent.ProjectileType(); - int damage = FireballDamage; - float finalVelocity = 10f; + float finalVelocity = death ? 12f : 10f; int totalSpreads = revenge ? 6 : 3; float mult = revenge ? 1.5f : 3f; for (int i = 0; i < totalSpreads; i++) { - int totalProjectiles = Main.getGoodWorld ? 30 : 12; + if (!death && i % 3 == 2) + continue; + int totalProjectiles = 12; float radians = MathHelper.TwoPi / totalProjectiles; float newVelocity = finalVelocity - i * mult; float velocityMult = 1f + ((finalVelocity - newVelocity) / (newVelocity * 2f) / 100f); @@ -2331,24 +2254,40 @@ namespace CalamityMod.NPCs.DevourerofGods for (int k = 0; k < totalProjectiles; k++) { Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(NPC.GetSource_FromAI(), newPosition, vector255, type, damage, 0f, Main.myPlayer, velocityMult, finalVelocity - finalVelocityReduction); + Projectile.NewProjectile(NPC.GetSource_FromAI(), newPosition, vector255, ModContent.ProjectileType(), FireballDamage, 0f, Main.myPlayer, velocityMult, finalVelocity - finalVelocityReduction); } } } - } NPC.TargetClosest(); NPC.position = newPosition; float chargeVelocity = death ? 26f : revenge ? 24f : expertMode ? 22f : 20f; - float maxChargeDistance = 1600f; + chargeVelocity *= (death) ? (!(phase6 && NPC.ai[3] < 7)) ? 2.5f : 3 : 2.25f; + float maxChargeDistance = 1800f; postTeleportTimer = (int)Math.Round(maxChargeDistance / chargeVelocity); + int phase6dashcount = death ? 5 : 3; + if (phase6 && NPC.ai[3] < 2 + phase6dashcount) + { + if (NPC.ai[3] < 3) + NPC.ai[3] = 3; + NPC.ai[3]++; + // On FTW the final 10% is infinite portal dashing + if (Main.getGoodWorld && NPC.life / (float)NPC.lifeMax < 0.1f) + { + NPC.ai[3] = 4; + NPC.SimpleStrikeNPC(10000,1); + } + } + else + { + NPC.ai[3] = 0; + } + NPC.Calamity().newAI[2] = 0; AwaitingPhase2Teleport = false; NPC.Opacity = 1f - (postTeleportTimer / 255f); - // Prediction is Death Mode only for now because it's weird without the line telegraph that Shayy spoke about - Vector2 predictionVector = death ? player.velocity * 40f : Vector2.Zero; - NPC.velocity = Vector2.Normalize(player.Center + predictionVector - NPC.Center) * chargeVelocity; + NPC.velocity = Vector2.Normalize(AdjustedPlayerCenter(10) - NPC.Center) * chargeVelocity; NPC.ForceNetUpdate(false); - + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; foreach (NPC n in Main.ActiveNPCs) { if (n.type == ModContent.NPCType() || n.type == ModContent.NPCType()) @@ -2362,7 +2301,11 @@ namespace CalamityMod.NPCs.DevourerofGods } } + GodSlayerDashJawFadeProgress = 1f; + GodSlayerDashJawTimer = 60f; SoundEngine.PlaySound(AttackSound with { Pitch = AttackSound.Pitch + extrapitch }, player.Center); + if (Main.getGoodWorld) + NPC.Calamity().velocityPriorToPhaseSwap = 20; } public void DoDeathAnimation() @@ -2466,22 +2409,21 @@ namespace CalamityMod.NPCs.DevourerofGods DeathAnimationTimer++; } - private Vector2 GetRiftLocation(bool spawnDust) + public Vector2 GetRiftLocation(bool activateRift = false) { - Vector2 realSpot = default; + Vector2 realSpot = Vector2.Zero; foreach (Projectile proj in Main.ActiveProjectiles) { if (proj.type == ModContent.ProjectileType()) { - if (!spawnDust) - proj.ai[0] = -1f; + if (proj.ModProjectile is DoGTeleportRift rift && !rift.FakeRift) + { + realSpot = proj.Center; - proj.Kill(); - - if (proj.ai[2] == 1f) - continue; - - realSpot = proj.Center; + // Safeguard for if the rift doesn't activate at its designated time. + if (activateRift) + proj.ModProjectile().SwitchAIStates(); + } } } return realSpot; @@ -2489,51 +2431,65 @@ namespace CalamityMod.NPCs.DevourerofGods public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { + bool actuallyInPhaseTwo = (Phase2Started && NPC.localAI[2] <= 60f); + Texture2D mainTexture = actuallyInPhaseTwo ? TextureP2.Value : TextureAssets.Npc[Type].Value; + Texture2D mainGlowTexture = actuallyInPhaseTwo ? TextureP2_Glow_Purple.Value : Texture_Glow_Purple.Value; + Texture2D mainJawTexture = actuallyInPhaseTwo ? JawTextureP2.Value : JawTexture.Value; + Texture2D mainJawGlowTexture = actuallyInPhaseTwo ? JawTextureP2_Glow.Value : JawTexture_Glow.Value; + + // Draw the custom worm bestiary sprite separately. if (NPC.IsABestiaryIconDummy) + { NPC.Opacity = 1f; - - float disintegrationFactor = DeathAnimationTimer / 800f; - if (disintegrationFactor > 0f) - { - spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(NPC.whoAmI); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage0("Images/Misc/Perlin"); - GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); + return CalamityUtils.DrawAnimatedBestiaryWorm(spriteBatch, NPC, drawColor, TextureP2_Full.Value, DevourerofGodsBody.TextureP2.Value, 4, 26, 0.5f, new Vector2(30, 10), 2, 20); } - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + SpriteEffects spriteEffects = (NPC.spriteDirection == 1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 halfSizeTexture = mainTexture.Size() * 0.5f; - bool useOtherTextures = (Phase2Started && NPC.localAI[2] <= 60f) || NPC.IsABestiaryIconDummy; - Texture2D texture2D15 = useOtherTextures ? Phase2Texture.Value : TextureAssets.Npc[Type].Value; - Vector2 halfSizeTexture = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); - if (NPC.IsABestiaryIconDummy) + Vector2 drawPosition = NPC.Center - screenPos; + drawPosition -= new Vector2(mainTexture.Width, mainTexture.Height) * NPC.scale / 2f; + drawPosition += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + + // Draw DoG's mouth and its glow masks. + Vector2 jawOrigin = mainJawTexture.Size() * 0.5f; + for (int i = -1; i <= 1; i += 2) { - return CalamityUtils.DrawAnimatedBestiaryWorm(spriteBatch, NPC, drawColor, texture2D15, DevourerofGodsBody.Phase2Texture.Value, 4, 26, 0.5f, new Vector2(30, 10), 2, 20); + float jawBaseOffset = actuallyInPhaseTwo ? 42f : 28f; + SpriteEffects jawSpriteEffect = (i == 1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Vector2 jawDrawPosition = drawPosition; + jawDrawPosition += Vector2.UnitX.RotatedBy(NPC.rotation + JawRotation * i) * i * (jawBaseOffset + MathF.Sin(JawRotation) * 24f); + jawDrawPosition -= Vector2.UnitY.RotatedBy(NPC.rotation) * ((actuallyInPhaseTwo ? 44f : 8f) + MathF.Sin(JawRotation) * (actuallyInPhaseTwo ? 30f : -6f)); + + spriteBatch.Draw(mainJawTexture, jawDrawPosition, null, NPC.GetAlpha(drawColor), NPC.rotation + JawRotation * i, jawOrigin, NPC.scale, jawSpriteEffect, 0f); + spriteBatch.Draw(mainJawGlowTexture, jawDrawPosition, null, NPC.GetAlpha(Color.White), NPC.rotation + JawRotation * i, jawOrigin, NPC.scale, jawSpriteEffect, 0f); + + // Draw the additional special jaw textures above these for the Rift Dash attack. + if (GodSlayerDashJawFadeProgress > 0.02f && !DoGDeathAnimationRenderer.ValidToDraw(NPC)) + { + spriteBatch.SafeBegin(SpriteSortMode.Deferred, BatchSetting.Additive, null, Main.GameViewMatrix.TransformationMatrix, () => + { + Vector2 godSlayerJawOrigin = GodSlayerDashJawTexture.Size() * 0.5f; + float godSlayerJawOpacity = GodSlayerDashJawFadeProgress; + + spriteBatch.Draw(GodSlayerDashJawTexture.Value, jawDrawPosition, null, NPC.GetAlpha(Color.Fuchsia) * godSlayerJawOpacity, NPC.rotation + JawRotation * i, godSlayerJawOrigin, NPC.scale * 1.6f, jawSpriteEffect, 0f); + spriteBatch.Draw(GodSlayerDashJawTexture.Value, jawDrawPosition, null, NPC.GetAlpha(Color.Cyan) * godSlayerJawOpacity, NPC.rotation + JawRotation * i, godSlayerJawOrigin, NPC.scale * 1.3f, jawSpriteEffect, 0f); + }); + } } - Vector2 drawLocation = NPC.Center - screenPos; - drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height) * NPC.scale / 2f; - drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); + // Draw the main head. + spriteBatch.Draw(mainTexture, drawPosition, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - if (!NPC.dontTakeDamage) - { - texture2D15 = useOtherTextures ? Phase2Texture_Glow.Value : Texture_Glow.Value; - Color glowmaskLerp = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + // Draw the head glow masks. There are two glow mask textures for each head which are split between purple and cyan highlights. + // Each color is exaggerated by a similar color slightly when drawn to make them pop out more. + Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + spriteBatch.Draw(mainGlowTexture, drawPosition, NPC.frame, NPC.GetAlpha(glowmaskColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - texture2D15 = useOtherTextures ? Phase2Texture_Glow2.Value : Texture_Glow2.Value; - glowmaskLerp = Color.Lerp(Color.White, Color.Cyan, 0.5f); - - spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, glowmaskLerp, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - } - - if (disintegrationFactor > 0f) - spriteBatch.ExitShaderRegion(); + mainGlowTexture = actuallyInPhaseTwo ? TextureP2_Glow_Cyan.Value : Texture_Glow_Cyan.Value; + glowmaskColor = Color.Lerp(Color.White, Color.Cyan, 0.5f); + spriteBatch.Draw(mainGlowTexture, drawPosition, NPC.frame, NPC.GetAlpha(glowmaskColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -2676,6 +2632,8 @@ namespace CalamityMod.NPCs.DevourerofGods // Can only hit the target if within certain distance public override bool CanHitPlayer(Player target, ref int cooldownSlot) { + if (Phase2Started && NPC.localAI[2] > 60f) + return false; cooldownSlot = ImmunityCooldownID.Bosses; Rectangle targetHitbox = target.Hitbox; @@ -2704,7 +2662,7 @@ namespace CalamityMod.NPCs.DevourerofGods // viable???, done here since it's conditional if (Main.zenithWorld && projectile.type == ModContent.ProjectileType()) { - modifiers.SourceDamage *= 40f; + modifiers.SourceDamage *= 10f; } } @@ -2782,21 +2740,66 @@ namespace CalamityMod.NPCs.DevourerofGods { if (hurtInfo.Damage <= 0) return; - - target.AddBuff(ModContent.BuffType(), 300); - target.AddBuff(ModContent.BuffType(), 600); - + if (target.Calamity().dogTextCooldown <= 0 && !BossRushEvent.BossRushActive) { - string text = Utils.SelectRandom(Main.rand, new string[] + string[] headHitKeys = new string[] { - "Mods.CalamityMod.Status.Boss.EdgyBossText2", - "Mods.CalamityMod.Status.Boss.EdgyBossText3", - "Mods.CalamityMod.Status.Boss.EdgyBossText4" - }); + "Mods.CalamityMod.Status.Boss.DoGHead1", + "Mods.CalamityMod.Status.Boss.DoGHead2", + "Mods.CalamityMod.Status.Boss.DoGHead3", + "Mods.CalamityMod.Status.Boss.DoGHead4", + "Mods.CalamityMod.Status.Boss.DoGHead5", + "Mods.CalamityMod.Status.Boss.DoGHead6", + "Mods.CalamityMod.Status.Boss.DoGHead7", + "Mods.CalamityMod.Status.Boss.DoGHead8", + "Mods.CalamityMod.Status.Boss.DoGHead9", + "Mods.CalamityMod.Status.Boss.DoGHead10", + "Mods.CalamityMod.Status.Boss.DoGHead11", + "Mods.CalamityMod.Status.Boss.DoGHead12", + "Mods.CalamityMod.Status.Boss.DoGHead13", + + + }; Color messageColor = Color.Cyan; Rectangle location = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - + var counter = target.Calamity().DoGHeadHitCounter; + string text = headHitKeys[Main.rand.Next(10, 13)]; + if (target.statLife - hurtInfo.Damage <= 0) + { + if (counter == 0) + if (NPC.GetLifePercent() <= 0.25f) + text = "Mods.CalamityMod.Status.Boss.DoGHeadDeath5"; //All that running just to die to a single touch? + else + text = "Mods.CalamityMod.Status.Boss.DoGHeadDeath1"; //Tasteless slop. + else if (NPC.GetLifePercent() <= 0.25f || counter >= 10) + text = "Mods.CalamityMod.Status.Boss.DoGHeadDeath4"; //WEAK. + else if (Phase2Started) + text = "Mods.CalamityMod.Status.Boss.DoGHeadDeath3"; //And STAY dead! + else if (!spawnedGuardians) + text = "Mods.CalamityMod.Status.Boss.DoGHeadDeath1"; //Tasteless slop. + else + text = "Mods.CalamityMod.Status.Boss.DoGHeadDeath2"; //A feast worthy of a god! + } else + { + if (counter == 0 && Phase2Started) + { + if (NPC.GetLifePercent() <= 0.25f) + text = "Mods.CalamityMod.Status.Boss.DoGHeadRunning2"; //WHAT'S THE PROBLEM?! CAN'T RUN ANYMORE?! + else + text = "Mods.CalamityMod.Status.Boss.DoGHeadRunning"; //You can't run forever! + } else + { + if (counter > 9) + text = headHitKeys[Main.rand.Next(10, 13)]; //DogHead11-13 + else if (counter == 9) + text = headHitKeys[9]; //DogHead10 + else if (counter > 4) + text = headHitKeys[Main.rand.Next(4, 9)]; //DogHead5-9 + else + text = headHitKeys[Main.rand.Next(0, 4)]; //DogHead1-4 + } + } // Speak in Wingdings if the Punch Card is equipped if (target.Transformation().Type == ModContent.ItemType() && FontAssetSystem.Fonts["Wingdings"] != null && System.Environment.OSVersion.Platform == PlatformID.Win32NT && !GameCulture.FromCultureName(GameCulture.CultureName.Chinese).IsActive && !GameCulture.FromCultureName(GameCulture.CultureName.Russian).IsActive) { @@ -2809,20 +2812,23 @@ namespace CalamityMod.NPCs.DevourerofGods positionY = (float)location.Y + (float)location.Height * 0.75f + vector.Y * 0.5f; } // Spawn a projectile that mimmicks combat text behaviour - int p = Projectile.NewProjectile(NPC.GetSource_FromThis(), new Vector2(positionX, positionY), new Vector2((float)Main.rand.Next(-25, 26) * 0.05f , - 14f * target.gravDir), ModContent.ProjectileType(), 0, 0, -1, -1); - Projectile proj = Main.projectile[p]; + Projectile proj = Projectile.NewProjectileDirect(NPC.GetSource_FromThis(), new Vector2(positionX, positionY), new Vector2((float)Main.rand.Next(-25, 26) * 0.05f, -14f * target.gravDir), ModContent.ProjectileType(), 0, 0, -1, -1); proj.rotation = proj.velocity.X < 0 ? -0.06f : 0.06f; // Pass the spoken dialogue into it - DoGWingdings wingdings = Main.projectile[p].ModProjectile(); + DoGWingdings wingdings = proj.ModProjectile(); wingdings.dialogue = Language.GetTextValue(text); } else { - CombatText.NewText(location, messageColor, Language.GetTextValue(text), true); + var ctid = CombatText.NewText(location, messageColor, Language.GetTextValue(text), true); + if (ctid < Main.maxCombatText) + target.Calamity().subtitletext = Main.combatText[ctid]; + target.Calamity().subtitleColors = new Color[] { Color.Cyan, Color.Fuchsia }; } target.Calamity().dogTextCooldown = 60; } + target.Calamity().DoGHeadHitCounter++; } } } diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.png b/NPCs/DevourerofGods/DevourerofGodsHead.png index e41c65844d..b6513e7905 100644 Binary files a/NPCs/DevourerofGods/DevourerofGodsHead.png and b/NPCs/DevourerofGods/DevourerofGodsHead.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadGlow.png b/NPCs/DevourerofGods/DevourerofGodsHeadGlow.png deleted file mode 100644 index d4883adc06..0000000000 Binary files a/NPCs/DevourerofGods/DevourerofGodsHeadGlow.png and /dev/null differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadGlow2.png b/NPCs/DevourerofGods/DevourerofGodsHead_Glow_Cyan.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsHeadGlow2.png rename to NPCs/DevourerofGods/DevourerofGodsHead_Glow_Cyan.png diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Glow_Purple.png b/NPCs/DevourerofGods/DevourerofGodsHead_Glow_Purple.png new file mode 100644 index 0000000000..2d049b02ae Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Glow_Purple.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Jaw.png b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw.png new file mode 100644 index 0000000000..1f2b5d3e16 Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_Glow.png b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_Glow.png new file mode 100644 index 0000000000..f26d1e9d13 Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_Glow.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_P2.png b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_P2.png new file mode 100644 index 0000000000..2546b70428 Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_P2.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_P2_Glow.png b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_P2_Glow.png new file mode 100644 index 0000000000..36d17aa322 Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Jaw_P2_Glow.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2.png b/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2.png new file mode 100644 index 0000000000..ff7808dee5 Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2_Glow_Cyan.png b/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2_Glow_Cyan.png new file mode 100644 index 0000000000..5b571069e2 Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2_Glow_Cyan.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2_Glow_Purple.png b/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2_Glow_Purple.png new file mode 100644 index 0000000000..f7a489c784 Binary files /dev/null and b/NPCs/DevourerofGods/DevourerofGodsHead_Jawless_P2_Glow_Purple.png differ diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadS.png b/NPCs/DevourerofGods/DevourerofGodsHead_P2.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsHeadS.png rename to NPCs/DevourerofGods/DevourerofGodsHead_P2.png diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadSGlow2.png b/NPCs/DevourerofGods/DevourerofGodsHead_P2_Glow_Cyan.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsHeadSGlow2.png rename to NPCs/DevourerofGods/DevourerofGodsHead_P2_Glow_Cyan.png diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadSGlow.png b/NPCs/DevourerofGods/DevourerofGodsHead_P2_Glow_Purple.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsHeadSGlow.png rename to NPCs/DevourerofGods/DevourerofGodsHead_P2_Glow_Purple.png diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadS_Head_Boss.png b/NPCs/DevourerofGods/DevourerofGodsHead_P2_Head_Boss.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsHeadS_Head_Boss.png rename to NPCs/DevourerofGods/DevourerofGodsHead_P2_Head_Boss.png diff --git a/NPCs/DevourerofGods/DevourerofGodsTail.cs b/NPCs/DevourerofGods/DevourerofGodsTail.cs index 64e31b8cae..7e785a3b8e 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail.cs @@ -3,6 +3,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; +using CalamityMod.Graphics.Renderers.CalamityRenderers; using CalamityMod.Projectiles.Melee.Yoyos; using CalamityMod.Sounds; using CalamityMod.World; @@ -25,16 +26,16 @@ namespace CalamityMod.NPCs.DevourerofGods public static int phase1IconIndex; public static int phase2IconIndex; - public static Asset Texture_Glow; - public static Asset Texture_Glow2; - public static Asset Phase2Texture; - public static Asset Phase2Texture_Glow; - public static Asset Phase2Texture_Glow2; + public static Asset Texture_Glow_Purple; + public static Asset Texture_Glow_Cyan; + public static Asset TextureP2; + public static Asset TextureP2_Glow_Purple; + public static Asset TextureP2_Glow_Cyan; public override void Load() { string phase1IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsTail_Head_Boss"; - string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailS_Head_Boss"; + string phase2IconPath = "CalamityMod/NPCs/DevourerofGods/DevourerofGodsTail_P2_Head_Boss"; phase1IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase1IconPath, -1); phase2IconIndex = CalamityMod.Instance.AddBossHeadTexture(phase2IconPath, -1); @@ -49,11 +50,11 @@ namespace CalamityMod.NPCs.DevourerofGods this.HideFromBestiary(); if (!Main.dedServ) { - Texture_Glow = ModContent.Request(Texture + "Glow", AssetRequestMode.AsyncLoad); - Texture_Glow2 = ModContent.Request(Texture + "Glow2", AssetRequestMode.AsyncLoad); - Phase2Texture = ModContent.Request(Texture + "S", AssetRequestMode.AsyncLoad); - Phase2Texture_Glow = ModContent.Request(Texture + "SGlow", AssetRequestMode.AsyncLoad); - Phase2Texture_Glow2 = ModContent.Request(Texture + "SGlow2", AssetRequestMode.AsyncLoad); + Texture_Glow_Purple = ModContent.Request(Texture + "_Glow_Purple", AssetRequestMode.AsyncLoad); + Texture_Glow_Cyan = ModContent.Request(Texture + "_Glow_Cyan", AssetRequestMode.AsyncLoad); + TextureP2 = ModContent.Request(Texture + "_P2", AssetRequestMode.AsyncLoad); + TextureP2_Glow_Purple = ModContent.Request(Texture + "_P2_Glow_Purple", AssetRequestMode.AsyncLoad); + TextureP2_Glow_Cyan = ModContent.Request(Texture + "_P2_Glow_Cyan", AssetRequestMode.AsyncLoad); } } @@ -64,13 +65,12 @@ namespace CalamityMod.NPCs.DevourerofGods public override void SetDefaults() { - NPC.Calamity().canBreakPlayerDefense = true; NPC.damage = 100; // 200 NPC.npcSlots = 5f; NPC.width = 66; NPC.height = 66; NPC.defense = 50; - NPC.LifeMaxNERB(887500, 1065000, 1500000); // Phase 1 is 355000, Phase 2 is 532500 + NPC.LifeMaxNERB(760000, 910000, 1500000); NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; @@ -82,11 +82,13 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.netAlways = true; NPC.boss = true; NPC.BossBar = Main.BigBossProgressBar.NeverValid; - NPC.takenDamageMultiplier = 1.25f; NPC.dontCountMe = true; - if (Main.getGoodWorld) + if (Main.zenithWorld) NPC.scale *= 1.5f; + + if (Main.getGoodWorld) + NPC.takenDamageMultiplier = 2; } public override void BossHeadSlot(ref int index) @@ -95,7 +97,7 @@ namespace CalamityMod.NPCs.DevourerofGods DevourerofGodsHead modNPC = head?.ModNPC() ?? null; index = -1; - if (head is null) + if (head is null || NPC.Opacity < 0.1f) return; if (!modNPC.Phase2Started) @@ -150,30 +152,26 @@ namespace CalamityMod.NPCs.DevourerofGods if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; - if (NPC.life > Main.npc[(int)NPC.ai[1]].life) - NPC.life = Main.npc[(int)NPC.ai[1]].life; + NPC.life = Main.npc[(int)NPC.ai[2]].life; + NPC.lifeMax = Main.npc[(int)NPC.ai[2]].lifeMax; + // Percent life remaining - float lifeRatio = NPC.life / (float)NPC.lifeMax; + float lifeRatio = Main.npc[(int)NPC.ai[2]].life / (float)Main.npc[(int)NPC.ai[2]].lifeMax; - bool phase2 = lifeRatio < 0.6f; + bool phase2 = lifeRatio < 0.65f; bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - if (phase2) + if (phase2 && !phase2Started && Main.npc[(int)NPC.ai[2]].localAI[2] <= 60) { phase2Started = true; - - // Once before DoG spawns, set new size - if (Main.npc[(int)NPC.ai[2]].localAI[2] == 60f) - { NPC.position = NPC.Center; NPC.width = (int)(80 * NPC.scale); - NPC.height = (int)(140 * NPC.scale); + NPC.height = (int)(80 * NPC.scale); NPC.frame = new Rectangle(0, 0, 86, 148); NPC.position -= NPC.Size * 0.5f; NPC.ForceNetUpdate(false); - } } if (invinceTime > 0) @@ -193,16 +191,6 @@ namespace CalamityMod.NPCs.DevourerofGods Player player = Main.player[NPC.target]; - float distanceFromTarget = Vector2.Distance(player.Center, NPC.Center); - float takeLessDamageDistance = 1600f; - if (distanceFromTarget > takeLessDamageDistance) - { - float damageTakenScalar = MathHelper.Clamp(1f - ((distanceFromTarget - takeLessDamageDistance) / takeLessDamageDistance), 0f, 1f); - NPC.takenDamageMultiplier = MathHelper.Lerp(1f, 1.25f, damageTakenScalar); - } - else - NPC.takenDamageMultiplier = 1.25f; - // Check if other segments are still alive, if not, die bool shouldDespawn = !NPC.AnyNPCs(ModContent.NPCType()); if (!shouldDespawn) @@ -315,22 +303,12 @@ namespace CalamityMod.NPCs.DevourerofGods if (Main.npc[NPC.realLife].type != ModContent.NPCType()) return true; - float disintegrationFactor = Main.npc[NPC.realLife].ModNPC().DeathAnimationTimer / 640f; - if (disintegrationFactor > 0f) - { - spriteBatch.EnterShaderRegion(); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseOpacity(disintegrationFactor); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseSaturation(NPC.whoAmI); - GameShaders.Misc["CalamityMod:DoGDisintegration"].UseImage1("Images/Misc/Perlin"); - GameShaders.Misc["CalamityMod:DoGDisintegration"].Apply(); - } - SpriteEffects spriteEffects = SpriteEffects.None; if (NPC.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; bool useOtherTextures = phase2Started && Main.npc[(int)NPC.ai[2]].localAI[2] <= 60f; - Texture2D texture2D15 = useOtherTextures ? Phase2Texture.Value : TextureAssets.Npc[Type].Value; + Texture2D texture2D15 = useOtherTextures ? TextureP2.Value : TextureAssets.Npc[Type].Value; Vector2 halfSizeTexture = new Vector2(texture2D15.Width / 2, texture2D15.Height / 2); Vector2 drawPosition = NPC.Center - screenPos; @@ -338,22 +316,21 @@ namespace CalamityMod.NPCs.DevourerofGods drawPosition += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); spriteBatch.Draw(texture2D15, drawPosition, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - if (!NPC.dontTakeDamage) + if ((!Main.npc[(int)NPC.ai[2]].ModNPC().isInPassiveState || !useOtherTextures) && NPC.Opacity > 0.25f) { - texture2D15 = useOtherTextures ? Phase2Texture_Glow.Value : Texture_Glow.Value; + texture2D15 = useOtherTextures ? TextureP2_Glow_Purple.Value : Texture_Glow_Purple.Value; Color glowmaskColor = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); spriteBatch.Draw(texture2D15, drawPosition, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); - - texture2D15 = useOtherTextures ? Phase2Texture_Glow2.Value : Texture_Glow2.Value; - glowmaskColor = Color.Lerp(Color.White, Color.Cyan, 0.5f); + } + if (!Main.npc[(int)NPC.ai[2]].ModNPC().isInAgressiveState && NPC.Opacity > 0.25f) + { + texture2D15 = useOtherTextures ? TextureP2_Glow_Cyan.Value : Texture_Glow_Cyan.Value; + Color glowmaskColor = Color.Lerp(Color.White, Color.Cyan, 0.5f); spriteBatch.Draw(texture2D15, drawPosition, NPC.frame, glowmaskColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } - if (disintegrationFactor > 0f) - spriteBatch.ExitShaderRegion(); - return false; } @@ -457,14 +434,5 @@ namespace CalamityMod.NPCs.DevourerofGods { NPC.lifeMax = (int)(NPC.lifeMax * 0.8f * balance * bossAdjustment); } - - public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) - { - if (hurtInfo.Damage > 0) - { - target.AddBuff(ModContent.BuffType(), 120, true); - target.AddBuff(ModContent.BuffType(), 360, true); - } - } } } diff --git a/NPCs/DevourerofGods/DevourerofGodsTailGlow2.png b/NPCs/DevourerofGods/DevourerofGodsTail_Glow_Cyan.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsTailGlow2.png rename to NPCs/DevourerofGods/DevourerofGodsTail_Glow_Cyan.png diff --git a/NPCs/DevourerofGods/DevourerofGodsTailGlow.png b/NPCs/DevourerofGods/DevourerofGodsTail_Glow_Purple.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsTailGlow.png rename to NPCs/DevourerofGods/DevourerofGodsTail_Glow_Purple.png diff --git a/NPCs/DevourerofGods/DevourerofGodsTailS.png b/NPCs/DevourerofGods/DevourerofGodsTail_P2.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsTailS.png rename to NPCs/DevourerofGods/DevourerofGodsTail_P2.png diff --git a/NPCs/DevourerofGods/DevourerofGodsTailSGlow2.png b/NPCs/DevourerofGods/DevourerofGodsTail_P2_Glow_Cyan.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsTailSGlow2.png rename to NPCs/DevourerofGods/DevourerofGodsTail_P2_Glow_Cyan.png diff --git a/NPCs/DevourerofGods/DevourerofGodsTailSGlow.png b/NPCs/DevourerofGods/DevourerofGodsTail_P2_Glow_Purple.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsTailSGlow.png rename to NPCs/DevourerofGods/DevourerofGodsTail_P2_Glow_Purple.png diff --git a/NPCs/DevourerofGods/DevourerofGodsTailS_Head_Boss.png b/NPCs/DevourerofGods/DevourerofGodsTail_P2_Head_Boss.png similarity index 100% rename from NPCs/DevourerofGods/DevourerofGodsTailS_Head_Boss.png rename to NPCs/DevourerofGods/DevourerofGodsTail_P2_Head_Boss.png diff --git a/NPCs/DevourerofGods/DoGSky.cs b/NPCs/DevourerofGods/DoGSky.cs deleted file mode 100644 index 4fe73de101..0000000000 --- a/NPCs/DevourerofGods/DoGSky.cs +++ /dev/null @@ -1,148 +0,0 @@ -using CalamityMod.Events; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.GameContent; -using Terraria.Graphics.Effects; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.DevourerofGods -{ - public class DoGSky : CustomSky - { - private bool isActive = false; - private float intensity = 0f; - private int DoGIndex = -1; - - public override void Update(GameTime gameTime) - { - if (DoGIndex == -1) - { - UpdateDoGIndex(); - if (DoGIndex == -1 && Main.LocalPlayer.Calamity().monolithDevourerBShader <= 0 && Main.LocalPlayer.Calamity().monolithDevourerPShader <= 0) - isActive = false; - } - - if (isActive && intensity < 1f) - { - intensity += 0.01f; - } - else if (!isActive && intensity > 0f) - { - intensity -= 0.01f; - } - } - - private float GetIntensity() - { - if (UpdateDoGIndex()) - { - float x = 0f; - if (DoGIndex != -1) - x = Vector2.Distance(Main.LocalPlayer.Center, Main.npc[DoGIndex].Center); - - float intensityScalar = 0.5f; - return (1f - Utils.SmoothStep(3000f, 6000f, x)) * intensityScalar; - } - return 0f; - } - - public override Color OnTileColor(Color inColor) - { - float intensity = GetIntensity(); - return new Color(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - intensity)); - } - - private bool UpdateDoGIndex() - { - int DoGType = ModContent.NPCType(); - if (DoGIndex >= 0 && Main.npc[DoGIndex].active && Main.npc[DoGIndex].type == DoGType) - { - return true; - } - DoGIndex = -1; - foreach (NPC n in Main.ActiveNPCs) - { - if (n.type == DoGType) - { - DoGIndex = n.whoAmI; - break; - } - } - return DoGIndex != -1; - } - - public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) - { - if (maxDepth >= 0 && minDepth < 0) - { - if (DoGIndex != -1) - { - if (Main.npc[DoGIndex].active) - { - float intensity = GetIntensity(); - float lifeRatio = Main.npc[DoGIndex].life / (float)Main.npc[DoGIndex].lifeMax; - double blackScreenLife_GateValue = (lifeRatio < 0.6f && Main.npc[DoGIndex].localAI[2] <= 2f) ? 0.15 : 0.75; - - float timeToReachNextColor = DevourerofGodsHead.SkyColorTransitionTime; - float phaseTimer = Main.npc[DoGIndex].Calamity().newAI[2]; - float colorChangeProgress = phaseTimer / timeToReachNextColor; - if (colorChangeProgress > 1f) - colorChangeProgress = 1f; - - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; - Color regularSkyColor = (Main.npc[DoGIndex].ai[3] == 0f ? Color.Lerp(Color.Fuchsia, Color.Cyan, colorChangeProgress) : Color.Lerp(Color.Cyan, Color.Fuchsia, colorChangeProgress)) * intensity; - if (Main.npc[DoGIndex].life < Main.npc[DoGIndex].lifeMax * blackScreenLife_GateValue || death || Main.npc[DoGIndex].localAI[3] > 0f) - { - float blackSkyTransitionProgress = death ? 1f : Main.npc[DoGIndex].localAI[3] / timeToReachNextColor; - spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth * 2, Main.screenHeight * 2), Color.Lerp(regularSkyColor, Color.Black * (intensity + 0.5f), blackSkyTransitionProgress)); - } - else - spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth * 2, Main.screenHeight * 2), regularSkyColor); - } - } - else - { - if (Main.LocalPlayer.Calamity().monolithDevourerBShader > 0) - { - float intensity = MathHelper.Min(MathHelper.Lerp(0, 0.5f, (float)Main.LocalPlayer.Calamity().monolithDevourerBShader / 15), 0.45f); - Color regularSkyColor = Color.Cyan; - spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth * 2, Main.screenHeight * 2), regularSkyColor * intensity); - } - if (Main.LocalPlayer.Calamity().monolithDevourerPShader > 0) - { - float intensity = MathHelper.Min(MathHelper.Lerp(0, 0.5f, (float)Main.LocalPlayer.Calamity().monolithDevourerPShader / 15), 0.45f); - Color regularSkyColor = Color.Fuchsia; - spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth * 2, Main.screenHeight * 2), regularSkyColor * intensity); - } - } - } - } - - public override float GetCloudAlpha() - { - return 0f; - } - - public override void Activate(Vector2 position, params object[] args) - { - isActive = true; - } - - public override void Deactivate(params object[] args) - { - isActive = false; - } - - public override void Reset() - { - isActive = false; - } - - public override bool IsActive() - { - return isActive || intensity > 0f; - } - } -} diff --git a/NPCs/DevourerofGods/GodSlayerDashJaw.png b/NPCs/DevourerofGods/GodSlayerDashJaw.png new file mode 100644 index 0000000000..8791c0d42e Binary files /dev/null and b/NPCs/DevourerofGods/GodSlayerDashJaw.png differ diff --git a/Particles/LineThick.png b/Particles/LineThick.png new file mode 100644 index 0000000000..16eea2a19c Binary files /dev/null and b/Particles/LineThick.png differ diff --git a/Particles/StatDownArrow.cs b/Particles/StatChangeArrow.cs similarity index 69% rename from Particles/StatDownArrow.cs rename to Particles/StatChangeArrow.cs index 29624d1cd8..2658562659 100644 --- a/Particles/StatDownArrow.cs +++ b/Particles/StatChangeArrow.cs @@ -5,17 +5,19 @@ using Terraria.ModLoader; namespace CalamityMod.Particles { - public class StatDownArrow : Particle + public class StatChangeArrow : Particle { - public override string Texture => "CalamityMod/Particles/StatDownArrow"; + public override string Texture => "CalamityMod/Particles/StatChangeArrow"; public override bool UseAdditiveBlend => true; public override bool UseCustomDraw => true; public override bool SetLifetime => true; + public bool AffectedByGravity = false; + public Color StartColor; public Color EndColor; - public StatDownArrow(Vector2 position, Vector2 velocity, Color startColor, Color endColor, float scale, int lifetime) + public StatChangeArrow(Vector2 position, Vector2 velocity, float rotation, Color startColor, Color endColor, float scale, int lifetime) { Position = position; Velocity = velocity; @@ -24,24 +26,27 @@ namespace CalamityMod.Particles EndColor = endColor; Scale = scale; Lifetime = lifetime; - Rotation = 0; + Rotation = rotation; } public override void Update() { Color = Color.Lerp(StartColor, EndColor, LifetimeCompletion); Lighting.AddLight(Position, Color.ToVector3() * 0.2f); + if (Velocity.Length() < 12f && AffectedByGravity) + { + Velocity.X *= 0.94f; + Velocity.Y += 0.25f; + } } public override void CustomDraw(SpriteBatch spriteBatch) { Texture2D texture = ModContent.Request(Texture).Value; Vector2 DrawSize = new Vector2(Scale); - Vector2 Origin = new Vector2(texture.Width, texture.Height); + Vector2 Origin = new Vector2(texture.Width, texture.Height) /2f; - Vector2 PositionAdjust = new Vector2(-5, -11); - - spriteBatch.Draw(texture, Position - Main.screenPosition - PositionAdjust, null, Color, Rotation, Origin, DrawSize, SpriteEffects.None, 0); + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, Origin, DrawSize, SpriteEffects.None, 0); } } } diff --git a/Particles/StatChangeArrow.png b/Particles/StatChangeArrow.png new file mode 100644 index 0000000000..58af425b64 Binary files /dev/null and b/Particles/StatChangeArrow.png differ diff --git a/Particles/StatDownArrow.png b/Particles/StatDownArrow.png deleted file mode 100644 index 1119f1534b..0000000000 Binary files a/Particles/StatDownArrow.png and /dev/null differ diff --git a/Projectiles/Boss/DoGDeath.cs b/Projectiles/Boss/DoGDeath.cs index 4245e1eeb9..3cc8b99d2f 100644 --- a/Projectiles/Boss/DoGDeath.cs +++ b/Projectiles/Boss/DoGDeath.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.tileCollide = false; Projectile.Opacity = 0f; Projectile.penetrate = -1; - Projectile.timeLeft = 480; + Projectile.timeLeft = 300; CooldownSlot = ImmunityCooldownID.Bosses; } diff --git a/Projectiles/Boss/DoGFire.cs b/Projectiles/Boss/DoGFire.cs index 315a98ac61..7ef4d96d03 100644 --- a/Projectiles/Boss/DoGFire.cs +++ b/Projectiles/Boss/DoGFire.cs @@ -1,25 +1,37 @@ using System; +using System.Linq; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.DataStructures; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.DataStructures; using Terraria; using Terraria.Audio; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class DoGFire : ModProjectile, ILocalizedModType + public class DoGFire : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer { - public new string LocalizationCategory => "Projectiles.Boss"; - public override void SetStaticDefaults() + public bool IsAPassiveFireball { - Main.projFrames[Type] = 6; - ProjectileID.Sets.TrailCacheLength[Type] = 3; - ProjectileID.Sets.TrailingMode[Type] = 0; + get => Projectile.ai[0] == 2f; + set => Projectile.ai[0] = value.ToInt(); } + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 14; + ProjectileID.Sets.TrailingMode[Type] = 2; + } public override void SetDefaults() { - Projectile.Calamity().DealsDefenseDamage = true; Projectile.width = 34; Projectile.height = 34; Projectile.hostile = true; @@ -27,129 +39,134 @@ namespace CalamityMod.Projectiles.Boss Projectile.tileCollide = false; Projectile.extraUpdates = 1; Projectile.penetrate = -1; - Projectile.timeLeft = 480; + Projectile.timeLeft = 300; CooldownSlot = ImmunityCooldownID.Bosses; } + public override void OnSpawn(IEntitySource source) + { + if (IsAPassiveFireball) + SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); + } + public override void AI() { - if (Projectile.localAI[0] == 0f && Projectile.ai[1] == 0f) + Projectile.rotation = Projectile.velocity.ToRotation(); + if (Main.rand.NextBool(12)) { - Projectile.localAI[0] = 1f; - SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); + for (int i = 0; i < 2; i++) + { + Vector2 dustSpawnPosition = Projectile.Center + Main.rand.NextVector2Circular(6f, 6f); + Vector2 dustVelocity = Projectile.velocity * -1.2f; + float dustScale = Main.rand.NextFloat(0.6f, 0.8f); + Color dustColor = Color.Lerp(Color.White, IsAPassiveFireball ? Color.SkyBlue : Color.Purple, Main.rand.NextFloat(0.5f, 1f)); + + Dust dust = Dust.NewDustDirect(dustSpawnPosition, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, dustColor, dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = false; + } } - Projectile.frameCounter++; - if (Projectile.frameCounter > 4) + if (Main.rand.NextBool(2)) { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame > 5) - Projectile.frame = 0; + for (int i = 0; i < 3; i++) + { + Vector2 smokeVelocity = -Projectile.velocity * 0.7f + Main.rand.NextVector2Circular(1f, 1f) * 0.65f; + int smokeLifetime = Main.rand.Next(20, 30); + float smokeScale = Main.rand.NextFloat(0.25f, 0.45f); + float smokeOpacity = Main.rand.NextFloat(0.7f, 0.9f); + Color flameColor = Color.Lerp(Color.White, IsAPassiveFireball ? Color.SkyBlue : Color.Purple, Main.rand.NextFloat(0.5f, 1f)); - int dust = Dust.NewDust(new Vector2(Projectile.position.X + Projectile.velocity.X, Projectile.position.Y + Projectile.velocity.Y), Projectile.width, Projectile.height, DustID.ShadowbeamStaff, Projectile.velocity.X, Projectile.velocity.Y, 100, default, 0.8f); - Main.dust[dust].noGravity = true; - - Projectile.rotation = (float)Math.Atan2(Projectile.velocity.Y, Projectile.velocity.X) + MathHelper.PiOver2; - - if (Projectile.ai[1] > 0f) - { - if (Projectile.velocity.Length() < Projectile.ai[1]) - Projectile.velocity *= Projectile.ai[0]; + HeavySmokeParticle ghastlySmoke = new(Projectile.Center + Main.rand.NextVector2Circular(8f, 8f), smokeVelocity, flameColor, smokeLifetime, smokeScale, smokeOpacity, 0.02f, true); + GeneralParticleHandler.SpawnParticle(ghastlySmoke); + } } } - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - - public override Color? GetAlpha(Color lightColor) => new Color(255, 255, 255, 0); - public override void OnHitPlayer(Player target, Player.HurtInfo info) { if (info.Damage <= 0) return; - target.AddBuff(ModContent.BuffType(), 160); + target.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(5)); } public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item74, Projectile.Center); - Projectile.position = Projectile.Center; - Projectile.width = Projectile.height = 64; - Projectile.position.X = Projectile.position.X - Projectile.width / 2; - Projectile.position.Y = Projectile.position.Y - Projectile.height / 2; - for (int i = 0; i < 5; i++) + // Spawn a burst of dust at the center. + for (int i = 0; i < 12; i++) { - int godSlay = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.ShadowbeamStaff, 0f, 0f, 100, default, 2f); - Main.dust[godSlay].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[godSlay].scale = 0.5f; - Main.dust[godSlay].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - for (int j = 0; j < 10; j++) - { - int godSlay2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.ShadowbeamStaff, 0f, 0f, 100, default, 3f); - Main.dust[godSlay2].noGravity = true; - Main.dust[godSlay2].velocity *= 5f; - godSlay2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.ShadowbeamStaff, 0f, 0f, 100, default, 2f); - Main.dust[godSlay2].velocity *= 2f; - } - for (int k = 0; k < 200; k++) - { - float dustScale = 12f; - if (k < 150) - dustScale = 9f; - if (k < 100) - dustScale = 6f; - if (k < 50) - dustScale = 3f; + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f; + float dustScale = Main.rand.NextFloat(3f, 5f); + Color dustColor = Color.Lerp(Color.White, IsAPassiveFireball ? Color.SkyBlue : Color.Purple, Main.rand.NextFloat(0.5f, 1f)); - int scalingDust = Dust.NewDust(Projectile.Center, 6, 6, DustID.ShadowbeamStaff, 0f, 0f, 100, default, 1f); - float scalingDustVelX = Main.dust[scalingDust].velocity.X; - float scalingDustVelY = Main.dust[scalingDust].velocity.Y; - - if (scalingDustVelX == 0f && scalingDustVelY == 0f) - scalingDustVelX = 1f; - - float scalingDustVelocity = (float)Math.Sqrt(scalingDustVelX * scalingDustVelX + scalingDustVelY * scalingDustVelY); - scalingDustVelocity = dustScale / scalingDustVelocity; - scalingDustVelX *= scalingDustVelocity; - scalingDustVelY *= scalingDustVelocity; - - float scale = 1f; - switch ((int)dustScale) - { - case 4: - scale = 1.2f; - break; - case 8: - scale = 1.1f; - break; - case 12: - scale = 1f; - break; - case 16: - scale = 0.9f; - break; - default: - break; - } - - Dust dust = Main.dust[scalingDust]; - dust.velocity *= 0.5f; - dust.velocity.X += scalingDustVelX; - dust.velocity.Y += scalingDustVelY; - dust.scale = scale; + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, dustColor, dustScale); dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = false; } Projectile.Damage(); } + + public override bool PreDraw(ref Color lightColor) => false; + + public float FireWidthFunction(float completion) + { + float width; + float maxBodyWidth = 72f * Projectile.scale; + float curveRatio = 0.2f; + + // Crop the tip of the trail into a conic shape. + if (completion < curveRatio) + width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + + // Pulse inwards and outwards over time. + float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f; + float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant); + return width + additionalPulseWidth; + } + + public Color FireColorFunction(float completion) + { + Color mainColor = IsAPassiveFireball ? Color.Cyan : Color.Purple * 1.3f; + Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + return Color.Lerp(mainColor, endColor, completion); + } + + public float FireCoreWidthFunction(float completion) + { + float width; + float maxBodyWidth = Projectile.scale * (IsAPassiveFireball ? 24f : 32f); + float curveRatio = 0.25f; + + if (completion < curveRatio) + width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + return width; + } + + public Color FireCoreColorFunction(float completion) + { + Color mainColor = IsAPassiveFireball ? Color.SkyBlue : Color.Fuchsia; + Color tipColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + Color fullBodyColor = Color.Lerp(mainColor, tipColor, completion); + return Color.Lerp(fullBodyColor, Color.White, 0.175f); + } + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch, PixelationPrimitiveLayer layer) + { + // Render the main trail for the body for the flame. + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(FireWidthFunction, FireColorFunction, (_) => Projectile.Size * 0.5f + Projectile.velocity.SafeNormalize(Vector2.Zero)*24f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length + 32); + + // Render a smaller, pure white trail in the same position to represent the glowing core of the flame. + Vector2[] fireCoreLength = Projectile.oldPos.Take(8).ToArray(); + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/SylvestaffStreak")); + PrimitiveRenderer.RenderTrail(fireCoreLength, new(FireCoreWidthFunction, FireCoreColorFunction, (_) => Projectile.Size * 0.5f + Projectile.velocity.SafeNormalize(Vector2.Zero) * 24f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), fireCoreLength.Length + 24); + } } } diff --git a/Projectiles/Boss/DoGFire.png b/Projectiles/Boss/DoGFire.png deleted file mode 100644 index a97abf9659..0000000000 Binary files a/Projectiles/Boss/DoGFire.png and /dev/null differ diff --git a/Projectiles/Boss/DoGLaserWalls.cs b/Projectiles/Boss/DoGLaserWalls.cs new file mode 100644 index 0000000000..98c0cee1f1 --- /dev/null +++ b/Projectiles/Boss/DoGLaserWalls.cs @@ -0,0 +1,204 @@ +using System; +using System.Net; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Particles; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using static System.Runtime.InteropServices.JavaScript.JSType; + +namespace CalamityMod.Projectiles.Boss +{ + public class DoGLaserWalls : ModProjectile, ILocalizedModType + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public new string LocalizationCategory => "Projectiles.Boss"; + public float time = 0; + public ref float attackSpeed => ref Projectile.ai[0]; // How fast the attack goes, higher is faster + public ref float laserDist => ref Projectile.ai[1]; // The spacing between lasers + public ref float laserType => ref Projectile.ai[2]; // The style of laser wall, ranging from 0 - 5 (6 for GFB circular variant) + public bool canDamage => doneAttack && laserFX >= 1f; + public bool doneAttack = false; + public int attackTime = 30; + public int laserCount => (int)(6000 / Math.Max(laserDist, 1)); + public float laserLength => laserDist * laserCount / 2; + public float laserFX = 0; + public float storedTime = 0; + public Color drawColor = Color.Cyan; + public float sine = 0; + public Vector2 storedTargetPos; + public Player targeted; + public Vector2 targetPos => (targeted == null ? Projectile.Center : targeted.Center); + public override void SetStaticDefaults() + { + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 10000; + } + public override void SetDefaults() + { + Projectile.width = 1; + Projectile.height = 1; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 6000; + } + public override void AI() + { + if (laserFX > 0) + laserFX = MathHelper.Lerp(laserFX, 0, time > 15 ? 0.12f : 0.01f); + sine = (float)Math.Sin(time * 4f / MathHelper.Pi); + + if (time == 0) + { + targeted = Main.player[Player.FindClosest(Projectile.Center, 1, 1)]; + // Some default values for if the projectile spawns without them set + if (attackSpeed == 0) + attackSpeed = 0.5f; + if (laserDist == 0) + laserDist = 250; + Projectile.velocity = Vector2.Zero; + laserFX = 1f; + + SoundStyle appear = new("CalamityMod/Sounds/Custom/DoGLaserWallSpawn"); + SoundEngine.PlaySound(appear with { Volume = 1f, Pitch = 0f, MaxInstances = -1 }, targetPos); + storedTargetPos = targetPos; + Projectile.ForceNetUpdate(); + } + if (time >= attackTime && !doneAttack) + { + SoundStyle attack = new("CalamityMod/Sounds/Custom/DoGLaserWallLightAttack"); + for (int i = 0; i < 2; i++) + SoundEngine.PlaySound(attack with { Volume = 0.9f, Pitch = 0, MaxInstances = -1 }, targetPos); + laserFX = 3; + doneAttack = true; + storedTime = time; + Projectile.ForceNetUpdate(); + } + float endTime = storedTime + 10; + if (time >= endTime && doneAttack) + { + Projectile.Kill(); + return; + } + else if (doneAttack) + { + drawColor = Color.Lerp(Color.Cyan, Color.Magenta, (float)Math.Pow(Utils.GetLerpValue(endTime, storedTime, time, true), 2)); + } + time += attackSpeed; + } + public override bool CanHitPlayer(Player target) + { + if (canDamage) + { + if (laserType == 6) + { + float distance = Vector2.Distance(Projectile.Center, target.Center); + float expand = MathF.Min(target.width, target.height); + if (distance < laserDist * 1.5f || distance > laserDist * 10f + 40f) + return false; + + if (distance % laserDist > (laserDist - Utils.Remap(distance, 240f, 1440f, 8f, 56f) - expand) || distance % laserDist < expand) + return true; + } + else + return true; + } + return false; + } + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + target.AddBuff(ModContent.BuffType(), 60); + base.OnHitPlayer(target, info); + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (!canDamage) + return false; + else if (laserType == 6) // Custom hit check through CanHitPlayer + return true; + else + { + float _ = float.NaN; + bool hit = false; + Vector2 X = Vector2.UnitX.RotatedBy((laserType == 1 || laserType == 3 || laserType == 5) ? MathHelper.PiOver4 : 0); + Vector2 Y = Vector2.UnitY.RotatedBy((laserType == 1 || laserType == 3 || laserType == 5) ? MathHelper.PiOver4 : 0); + for (int l = 0; l < 2; l++) + { + bool horizontal = (l != 0); + bool crossLasers = ((laserType == 2 && !horizontal) || (laserType == 3 && !horizontal) || (laserType == 4 && horizontal) || (laserType == 5 && horizontal)); + float length = laserLength * (horizontal ? 1f : 1f); + for (int i = 0; i < laserCount; i += (crossLasers ? 2 : 1)) + { + Vector2 startPoint = Projectile.Center - (horizontal ? Y : X) * (length); + Vector2 laserPoint = startPoint + (horizontal ? X : Y) * (laserDist * i) - (horizontal ? X : Y) * (laserDist * laserCount / 2); + Vector2 rot = laserPoint.DirectionTo(storedTargetPos); + + Vector2 start = laserPoint; + Vector2 end = laserPoint + (crossLasers ? rot : (horizontal ? Y : X)) * laserLength * 2; + + bool hitCheck = Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, 10, ref _); + if (hitCheck) + { + hit = true; + i = laserCount; + } + } + } + return hit; + } + } + public override bool PreDraw(ref Color lightColor) + { + if (laserFX == 0) + return false; + Texture2D beam = ModContent.Request("CalamityMod/Particles/BloomLineThick").Value; + Texture2D bBeam = ModContent.Request("CalamityMod/Particles/LineThick").Value; + Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + float opacity = (doneAttack ? 0.65f : 0.3f) * (float)Math.Pow(Math.Min(laserFX, 1), 2); + if (CalamityClientConfig.Instance.Photosensitivity) + opacity = 0.2f; + + Color beamColor = drawColor with { A = 0 }; + if (laserType == 6) + { + Texture2D ring = ModContent.Request("CalamityMod/Particles/BloomRingThinLarge").Value; + for (float scale = 0.25f * laserDist / 120f; scale < 1.25f; scale += 0.125f * laserDist / 120f) + Main.EntitySpriteDraw(ring, Projectile.Center - Main.screenPosition, null, beamColor * opacity, 0f, ring.Size() * 0.5f, scale, SpriteEffects.None); + return false; + } + + Vector2 X = Vector2.UnitX.RotatedBy((laserType == 1 || laserType == 3 || laserType == 5) ? MathHelper.PiOver4 : 0); + Vector2 Y = Vector2.UnitY.RotatedBy((laserType == 1 || laserType == 3 || laserType == 5) ? MathHelper.PiOver4 : 0); + for (int l = 0; l < 2; l++) + { + bool horizontal = (l != 0); + float length = laserLength; + bool crossLasers = ((laserType == 2 && !horizontal) || (laserType == 3 && !horizontal) || (laserType == 4 && horizontal) || (laserType == 5 && horizontal)); + for (int i = 0; i < laserCount; i += (crossLasers ? 2 : 1)) + { + Vector2 startPoint = Projectile.Center - (horizontal ? Y : X) * (length); + Vector2 laserPoint = startPoint + (horizontal ? X : Y) * (laserDist * i) - (horizontal ? X : Y) * (laserDist * laserCount / 2); + + for (int t = 0; t < (!doneAttack ? 1 : 5); t++) + { + bool black = (t > 0); + Texture2D usedTex = (black ? bBeam : beam); + + float beamThickness = 0.03f * (black ? (0.8f - 0.15f * t) : 1f) * (laserFX <= 1 ? (float)Math.Pow(Math.Min(laserFX, 1), 2) : laserFX) * Utils.Remap(sine, -1, 1, 0.8f, 1.1f); + float rot = (horizontal ? MathHelper.Pi : MathHelper.PiOver2) + ((laserType == 1 || laserType == 3 || laserType == 5) ? MathHelper.PiOver4 : 0); + if (crossLasers) + rot = laserPoint.DirectionTo(storedTargetPos).ToRotation() + (MathHelper.PiOver2); + Main.EntitySpriteDraw(usedTex, laserPoint - Main.screenPosition, null, (black ? Color.Black * opacity : beamColor * opacity) * (black ? (0.2f + 0.15f * t) : 1), rot, new Vector2(beam.Width / 2, beam.Height), new Vector2(beamThickness, length / 975) * Projectile.scale, SpriteEffects.None); + } + } + } + return false; + } + } +} diff --git a/Projectiles/Boss/DoGLaserWallsBigBeam.cs b/Projectiles/Boss/DoGLaserWallsBigBeam.cs new file mode 100644 index 0000000000..7c16de895c --- /dev/null +++ b/Projectiles/Boss/DoGLaserWallsBigBeam.cs @@ -0,0 +1,146 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Projectiles.Rogue; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class DoGLaserWallsBigBeam : ModProjectile, ILocalizedModType + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public new string LocalizationCategory => "Projectiles.Boss"; + public float time = 0; + public ref float attackSpeed => ref Projectile.ai[0]; + public ref float laserType => ref Projectile.ai[2]; + public bool canDamage => doneAttack && laserFX >= 1f; + public bool doneAttack = false; + public int attackTime = 30; + public float laserLength => 3000; + public float laserFX = 0; + public float storedTime = 0; + public Color drawColor = Color.Magenta; + public float sine = 0; + public float laserRot = 0; + Vector2 beamStart = Vector2.Zero; + Vector2 directionToTarget = Vector2.Zero; + public Player targeted; + public Vector2 targetPos => (targeted == null ? Projectile.Center : targeted.Center); + public override void SetStaticDefaults() + { + ProjectileID.Sets.DrawScreenCheckFluff[Type] = 10000; + } + public override void SetDefaults() + { + Projectile.width = 1; + Projectile.height = 1; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 6000; + Projectile.scale = 2; + } + public override void AI() + { + if (laserFX > 0) + laserFX = MathHelper.Lerp(laserFX, 0, time > 15 ? 0.07f : 0.01f); + sine = (float)Math.Sin(time * 4f / MathHelper.Pi); + if (time == 0) + { + targeted = Main.player[Player.FindClosest(Projectile.Center, 1, 1)]; + if (CalamityWorld.LegendaryMode) + Projectile.scale = 6; + laserRot = Main.rand.NextFloat(-0.4f, 0.4f); + + beamStart = targetPos + ((laserType == 0 || laserType == 4 || laserType == 5) ? Vector2.UnitX : Vector2.UnitY).RotatedBy(laserRot) * laserLength; + directionToTarget = beamStart.DirectionTo(targetPos); + + Projectile.Center += Main.rand.NextVector2CircularEdge(400, 400); + // Some default values for if the projectile spawns without them set + if (attackSpeed == 0) + attackSpeed = 0.5f; + Projectile.velocity = Vector2.Zero; + laserFX = 1f; + Projectile.ForceNetUpdate(); + } + if (time >= attackTime && !doneAttack) + { + if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 7f) + Main.LocalPlayer.Calamity().GeneralScreenShakePower = 7f; + SoundStyle attack = new("CalamityMod/Sounds/Custom/DoGLaserWallBigAttack2"); + for (int i = 0; i < 2; i++) + SoundEngine.PlaySound(attack with { Volume = 0.8f, Pitch = 0, MaxInstances = -1 }, targetPos); + laserFX = 2.5f; + doneAttack = true; + storedTime = time; + Projectile.ForceNetUpdate(); + } + float endTime = storedTime + 10; + if (time >= endTime && doneAttack) + { + Projectile.Kill(); + return; + } + else if (doneAttack) + { + drawColor = Color.Lerp(Color.Magenta, Color.Cyan, (float)Math.Pow(Utils.GetLerpValue(endTime, storedTime, time, true), 2)); + } + time += attackSpeed; + } + public override bool CanHitPlayer(Player target) + { + if (canDamage) + return true; + return false; + } + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + target.AddBuff(ModContent.BuffType(), 60); + base.OnHitPlayer(target, info); + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (!canDamage) + return false; + else + { + float _ = float.NaN; + Vector2 start = beamStart; + Vector2 end = beamStart + directionToTarget * laserLength * 2; + bool hitCheck = Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), start, end, 30 * Projectile.scale, ref _); + + return hitCheck; + } + } + public override bool PreDraw(ref Color lightColor) + { + if (laserFX == 0) + return false; + Texture2D beam = ModContent.Request("CalamityMod/Particles/BloomLineThick").Value; + Texture2D bBeam = ModContent.Request("CalamityMod/Particles/LineThick").Value; + Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + float opacity = (doneAttack ? 0.65f : 0.35f) * (float)Math.Pow(Math.Min(laserFX, 1), 2); + Color beamColor = drawColor with { A = 0 }; + + if (CalamityClientConfig.Instance.Photosensitivity) + opacity = 0.2f; + for (int t = 0; t < (!doneAttack ? 1 : 4 * Projectile.scale); t ++) + { + bool black = (t > 0 + (Projectile.scale - 1)); + if (black) + beam = bBeam; + + float beamThickness = 0.09f * (black ? (0.8f - 0.15f * t / Projectile.scale) : 1f) * (laserFX <= 1 ? (float)Math.Pow(Math.Min(laserFX, 1), 2) : laserFX) * Utils.Remap(sine, -1, 1, 0.8f, 1.1f); + Main.EntitySpriteDraw(beam, beamStart - Main.screenPosition, null, (black ? Color.Black * opacity : beamColor * (1 - t * 0.3f) * opacity) * (black ? (0.2f + 0.15f * t / Projectile.scale) : 1), directionToTarget.ToRotation() + MathHelper.PiOver2, new Vector2(beam.Width / 2, beam.Height), new Vector2(beamThickness, laserLength / 975) * Projectile.scale, SpriteEffects.None); + } + //Main.EntitySpriteDraw(bloom, Projectile.Center - Main.screenPosition, null, Color.Red with { A = 0 }, 0, bloom.Size() / 2, 0.3f, SpriteEffects.None); + return false; + } + } +} diff --git a/Projectiles/Boss/DoGRiftCrack.cs b/Projectiles/Boss/DoGRiftCrack.cs new file mode 100644 index 0000000000..54a6dd3427 --- /dev/null +++ b/Projectiles/Boss/DoGRiftCrack.cs @@ -0,0 +1,87 @@ +using System.Collections.Generic; +using CalamityMod.Graphics.Primitives; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class DoGRiftCrack : ModProjectile, ILocalizedModType + { + public Vector2[] CrackPoints; + + public ref float Timer => ref Projectile.ai[0]; + + public ref float MaxWidth => ref Projectile.ai[1]; + + public new string LocalizationCategory => "Projectiles.Boss"; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 30; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 30; + } + + public override void AI() + { + float minDistanceBetweenPoints = 25f; + float maxDistanceBetweenPoints = 50f; + if (CrackPoints is null) + { + CrackPoints = new Vector2[25]; + + Vector2 startingPosition = Projectile.Center; + for (int i = 0; i < CrackPoints.Length; i++) + { + // First point should always be the starting position. + if (i == 0) + { + CrackPoints[i] = startingPosition; + } + // Next point pivots away from the starting position in the direction of the velocity. + else if (i == 1) + { + Vector2 nextPointPosition = startingPosition + Projectile.velocity * Main.rand.NextFloat(0.8f, 1.2f) + Main.rand.NextVector2Circular(30f, 30f); + CrackPoints[i] = nextPointPosition; + } + // All other points follow after the last one with the same slight offset to resemble cracks. + else + { + Vector2 previousPoint = CrackPoints[i - 2]; + float distanceFromLastPoint = Main.rand.NextFloat(minDistanceBetweenPoints, maxDistanceBetweenPoints); + if (i == CrackPoints.Length - 1) + distanceFromLastPoint = Main.rand.NextFloat(minDistanceBetweenPoints, maxDistanceBetweenPoints) * 0.5f; + + Vector2 newPoint = CrackPoints[i - 1] + (previousPoint.DirectionTo(CrackPoints[i - 1]) * distanceFromLastPoint).RotatedBy(MathHelper.ToRadians(Main.rand.NextFloat(-5f, 5f) * i * 0.25f)); + CrackPoints[i] = newPoint; + } + + if (Main.rand.NextBool(9)) + CrackPoints[i] += Main.rand.NextVector2Circular(10f, 10f); + } + } + + Projectile.scale = MathHelper.Lerp(1f, 0f, Timer / 30f); + Timer++; + } + + public float CrackWidthFunction(float completion) => Projectile.scale * MathHelper.Lerp(MaxWidth, 0f, completion); + + public Color CrackColorFunction(float completion) => Projectile.GetAlpha(Color.White); + + public override bool PreDraw(ref Color lightColor) + { + if (CrackPoints is not null) + { + PrimitiveRenderer.RenderTrail(CrackPoints, new(CrackWidthFunction, CrackColorFunction, null, false)); + } + return false; + } + } +} diff --git a/Projectiles/Boss/DoGTeleportRift.cs b/Projectiles/Boss/DoGTeleportRift.cs index bf28c53f02..6758288007 100644 --- a/Projectiles/Boss/DoGTeleportRift.cs +++ b/Projectiles/Boss/DoGTeleportRift.cs @@ -1,8 +1,14 @@ using System; +using System.IO; using CalamityMod.Dusts; +using CalamityMod.Effects; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Particles; +using CalamityMod.Skies; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -10,124 +16,273 @@ namespace CalamityMod.Projectiles.Boss { public class DoGTeleportRift : ModProjectile, ILocalizedModType { + public static readonly SoundStyle CrackSound = new("CalamityMod/Sounds/NPCHit/CryogenHit", 3); + + public static readonly SoundStyle BreakSound = new("CalamityMod/Sounds/NPCHit/CryogenPhaseTransitionCrack"); + + // GFB exclusive; DoG can spawn fake rifts on that seed to confuse the player. + public bool FakeRift; + + public int RiftLifetime; + + public NPC DoGHead => Main.npc[(int)Projectile.ai[0]]; + + public ref float Timer => ref Projectile.ai[1]; + + public ref float CrackScale => ref Projectile.ai[2]; + + public ref float AIState => ref Projectile.localAI[0]; + + public ref float CrackExposure => ref Projectile.localAI[1]; + + public ref float MaxExposure => ref Projectile.localAI[2]; + public new string LocalizationCategory => "Projectiles.Boss"; - public override string Texture => "CalamityMod/Projectiles/StarProj"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetDefaults() { Projectile.width = Projectile.height = 30; - Projectile.scale = 2.5f; - Projectile.hostile = true; Projectile.ignoreWater = true; Projectile.tileCollide = false; Projectile.Opacity = 0f; + Projectile.scale = 0f; Projectile.penetrate = -1; - Projectile.timeLeft = 200; + Projectile.timeLeft = RiftLifetime; + } + + public override bool? CanDamage() => false; + + public override bool ShouldUpdatePosition() => false; + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(FakeRift); + writer.Write(RiftLifetime); + for (int i = 0; i < Projectile.localAI.Length; i++) + writer.Write(Projectile.localAI[i]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + FakeRift = reader.ReadBoolean(); + RiftLifetime = reader.ReadInt32(); + for (int i = 0; i < Projectile.localAI.Length; i++) + Projectile.localAI[i] = reader.ReadSingle(); } public override void AI() { - if (Projectile.ai[0] == -1f) - return; - - if (Projectile.timeLeft < 160) - Projectile.timeLeft = 160; - - if (!Main.npc[(int)Projectile.ai[0]].active) - Projectile.Kill(); - - Projectile.ai[1] += MathHelper.Pi / 30f; - Projectile.Opacity = MathHelper.Clamp(Projectile.ai[1], 0f, 1f); - - if (Projectile.Opacity == 1f && Main.rand.NextBool(15)) + if (DoGHead is null || !DoGHead.active) { - Dust dust = Main.dust[Dust.NewDust(Projectile.Top, 0, 0, DustID.RainbowMk2, 0f, 0f, 100, new Color(150, 100, 255, 255), 1f)]; - dust.velocity.X = 0f; - dust.noGravity = true; - dust.fadeIn = 1f; - dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * (4f * Main.rand.NextFloat() + 26f); - dust.scale = 0.5f; + Projectile.Kill(); + return; + } + + // Pre-explosion, charge-up. + if (AIState == 0f) + { + int riftCrackInterval = (int)(RiftLifetime / 3f); + if (Timer % riftCrackInterval == 0f) + { + // Increase the intensity of certain effects as the crack gets bigger. + float effectsLifetimeInterpolant = MathHelper.Lerp(1f, 2f, Timer / RiftLifetime); + + // Only let the real rift on GFB perform these additional effects. + if (!FakeRift) + { + float crackPitch = MathHelper.Lerp(-0.75f, 0f, Timer / RiftLifetime); + SoundEngine.PlaySound(CrackSound with { Pitch = crackPitch }, Projectile.Center); + + for (int i = 0; i < 12; i++) + { + Vector2 sparkVelocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(8f, 12f) * effectsLifetimeInterpolant * 0.7f; + float sparkScale = Main.rand.NextFloat(1.2f, 1.6f) * effectsLifetimeInterpolant * 0.62f; + Color sparkColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, DoGSky.DoGLightBlue, DoGSky.DoGTwlight), Color.White, 0.65f); + SparkParticle crackSpark = new(Projectile.Center, sparkVelocity, false, Main.rand.Next(30, 45), sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(crackSpark); + } + + for (int i = 0; i < 8; i++) + { + Vector2 lightVelocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(12f, 14f) * effectsLifetimeInterpolant * 0.5f; + float lightScale = Main.rand.NextFloat(1.2f, 1.6f) * effectsLifetimeInterpolant * 0.62f; + Color lightColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, DoGSky.DoGLightBlue, DoGSky.DoGTwlight), Color.White, 0.65f); + SquishyLightParticle crackLight = new(Projectile.Center, lightVelocity, lightScale, lightColor, Main.rand.Next(30, 45)); + GeneralParticleHandler.SpawnParticle(crackLight); + } + + CalamityUtils.AddScreenshakeAt(Projectile.Center, 6f * effectsLifetimeInterpolant * 0.8f); + } + + float brightnessMultiplier = FakeRift ? 0.75f : 1f; + CustomPulse shineExplosion2 = new(Projectile.Center, Vector2.Zero, Color.White * brightnessMultiplier, "CalamityMod/Particles/ShineExplosion2", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.5f * effectsLifetimeInterpolant, 45); + GeneralParticleHandler.SpawnParticle(shineExplosion2); + + // Increase the scale and exposure of the actual crack at each interval. + CrackScale += 0.525f * effectsLifetimeInterpolant * 0.75f; + MaxExposure = MathHelper.Clamp(MaxExposure + 0.25f * effectsLifetimeInterpolant, 0f, 0.95f); + } + + // Perform the explosion right at the point where DoG emerges. + if (Timer >= RiftLifetime) + SwitchAIStates(); + + if (Projectile.timeLeft < 45) + Projectile.timeLeft = 45; + + CrackExposure = MathHelper.Lerp(CrackExposure, MaxExposure, 0.075f); + Projectile.Opacity = MathHelper.Clamp(Projectile.Opacity + 0.05f, 0f, 1f); + Projectile.scale = MathHelper.Clamp(Projectile.scale + 0.02f, 0f, 1f); + } + + // Post-explosion, slowly fade out. + if (AIState == 1f) + { + Projectile.Opacity = MathHelper.Lerp(1f, 0f, Timer / 45f); + CrackExposure = MathHelper.Lerp(MaxExposure, 0f, Timer / 45f); + } + + Timer++; + } + + public void SwitchAIStates() + { + AIState = 1f; + Timer = 0f; + CrackScale += 3f; + Projectile.timeLeft = 30; + SpawnExplosionVisuals(); + Projectile.netUpdate = true; + } + + public void SpawnExplosionVisuals() + { + float brightnessMultiplier = CalamityClientConfig.Instance.Photosensitivity ? 0.6f : 1f; + if (!FakeRift) + { + // Spawn the rift cracks. + for (int i = 0; i < 25; i++) + { + Vector2 crackOffset = Vector2.UnitX.RotatedBy(i * MathHelper.TwoPi / 25) * Main.rand.NextFloat(20f, 80f); + Vector2 crackDestination = Projectile.Center + crackOffset; + Vector2 crackLength = crackDestination - Projectile.Center; + float riftWidth = Main.rand.NextFloat(20f, 30f); + Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center, crackLength, ModContent.ProjectileType(), 0, 0f, ai1: riftWidth); + } + + // Spawn a bunch of square-shaped metaballs at the impact zone as well. + for (int i = 0; i < 35; i++) + DoGDistortionMetaball.SpawnParticle(Projectile.Center + Main.rand.NextVector2Circular(25f, 25f), Vector2.Zero, 500f, true, Main.rand.NextFloat(MathHelper.TwoPi)); + + // More metaballs flying away from the impact zone for extra flavor. + int metaballAmount = Main.rand.Next(15, 21); + for (int i = 0; i < metaballAmount; i++) + DoGDistortionMetaball.SpawnParticle(Projectile.Center, Main.rand.NextVector2Unit() * Main.rand.NextFloat(25f, 35f), Main.rand.NextFloat(30f, 50f)); + + // Addtional particles and effects. + for (int i = 0; i < 25; i++) + { + Vector2 sparkVelocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(12f, 16f); + float sparkScale = Main.rand.NextFloat(1.8f, 2f); + Color sparkColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, DoGSky.DoGLightBlue, DoGSky.DoGTwlight), Color.White, 0.65f); + SparkParticle crackSpark = new(Projectile.Center, sparkVelocity, false, Main.rand.Next(30, 45), sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(crackSpark); + } + + for (int i = 0; i < 20; i++) + { + Vector2 lightVelocity = Vector2.UnitX.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(16f, 20f); + float lightScale = Main.rand.NextFloat(1.8f, 2f); + Color lightColor = Color.Lerp(Utils.SelectRandom(Main.rand, Color.Fuchsia, DoGSky.DoGLightBlue, DoGSky.DoGTwlight), Color.White, 0.65f); + SquishyLightParticle crackLight = new(Projectile.Center, lightVelocity, lightScale, lightColor, Main.rand.Next(30, 45)); + GeneralParticleHandler.SpawnParticle(crackLight); + } + + // Explosion visuals. + for (int i = 0; i < 3; i++) + { + CustomPulse plasmaExplosion = new(Projectile.Center, Vector2.Zero, DoGSky.DoGTwlight * 0.8f * brightnessMultiplier, "CalamityMod/Particles/PlasmaExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 1.25f + i * 0.05f, 45); + GeneralParticleHandler.SpawnParticle(plasmaExplosion); + } + + CustomPulse shineExplosion = new(Projectile.Center, Vector2.Zero, DoGSky.DoGTwlight * brightnessMultiplier, "CalamityMod/Particles/ShineExplosion1", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.75f, 45); + GeneralParticleHandler.SpawnParticle(shineExplosion); + CustomPulse shineExplosion2 = new(Projectile.Center, Vector2.Zero, Color.White * 0.6f * brightnessMultiplier, "CalamityMod/Particles/ShineExplosion2", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.5f, 45); + GeneralParticleHandler.SpawnParticle(shineExplosion2); + StrongBloom bloom = new(Projectile.Center, Vector2.Zero, Color.White * 0.8f * brightnessMultiplier, 8f, 30); + GeneralParticleHandler.SpawnParticle(bloom); + + SoundEngine.PlaySound(BreakSound, Projectile.Center); + CalamityUtils.AddScreenshakeAt(Projectile.Center, 14f); + } + else + { + for (int i = 0; i < 3; i++) + { + PulseRing fakerDeathRing = new(Projectile.Center, Vector2.Zero, Color.White * 0.45f * brightnessMultiplier, 0f, 3f + i * 0.1f, 30 + i * 15); + GeneralParticleHandler.SpawnParticle(fakerDeathRing); + } } } public override bool PreDraw(ref Color lightColor) { - float lerpMult = Utils.GetLerpValue(15f, 30f, Projectile.timeLeft, clamped: true) * Utils.GetLerpValue(240f, 200f, Projectile.timeLeft, clamped: true) * (1f + 0.2f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 30f / 0.5f * (MathHelper.Pi * 2f) * 3f)) * 0.8f; + Texture2D crackTexture = ModContent.Request("CalamityMod/ExtraTextures/CrackedGlass_Glowing").Value; + Texture2D starTexture = ModContent.Request("CalamityMod/Projectiles/StarProj").Value; + Texture2D bloomRingTexture = ModContent.Request("CalamityMod/Particles/BloomRing").Value; - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - Vector2 drawPos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); - Color baseColor = new Color(150, 100, 255, 255) * Projectile.Opacity; - baseColor *= 0.5f; - baseColor.A = 0; - Color colorA = baseColor; - Color colorB = baseColor * 0.5f; - colorA *= lerpMult; - colorB *= lerpMult; - Vector2 origin = texture.Size() / 2f; - Vector2 scale = new Vector2(3f, 9f) * Projectile.Opacity * lerpMult; + float chargeInterpolant = CalamityUtils.SineInOutEasing(Timer / RiftLifetime, 1); + float brightnessMultiplier = FakeRift ? 0.6f : 1f; - SpriteEffects spriteEffects = SpriteEffects.None; - if (Projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Vector2 verticalStarPartScale = new Vector2(1f, 8f) * chargeInterpolant * Projectile.scale * 3.25f; + Vector2 horizontalStarPartScale = new Vector2(1f, 5f) * chargeInterpolant * Projectile.scale * 3.25f; - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver2, origin, scale, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, 0f, origin, scale, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver2, origin, scale * 0.8f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, 0f, origin, scale * 0.8f, spriteEffects, 0); + Main.spriteBatch.SetBlendState(BlendState.Additive); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver2 + Projectile.ai[1] * 0.25f, origin, scale, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, Projectile.ai[1] * 0.25f, origin, scale, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver2 + Projectile.ai[1] * 0.5f, origin, scale * 0.8f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, Projectile.ai[1] * 0.5f, origin, scale * 0.8f, spriteEffects, 0); + // Draw the glowing star. + Main.EntitySpriteDraw(starTexture, drawPosition, null, Color.White * 0.7f * brightnessMultiplier * chargeInterpolant, 0f, starTexture.Size() * 0.5f, verticalStarPartScale, 0); + Main.EntitySpriteDraw(starTexture, drawPosition, null, Color.White * 0.7f * brightnessMultiplier * chargeInterpolant, MathHelper.PiOver2, starTexture.Size() * 0.5f, horizontalStarPartScale, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4, origin, scale * 0.4f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f, origin, scale * 0.4f, spriteEffects, 0); - - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4 + Projectile.ai[1] * 0.75f, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f + Projectile.ai[1] * 0.75f, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4 + Projectile.ai[1], origin, scale * 0.4f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f + Projectile.ai[1], origin, scale * 0.4f, spriteEffects, 0); - - return false; - } - - public override void OnKill(int timeLeft) - { - if (Projectile.ai[0] == -1f || Projectile.ai[2] == 1f) - return; - - int dustAmt = 50; - int random = 5; - - for (int j = 0; j < 10; j++) + // Draw a smaller, twlight colored star at the center if this isn't a fake rift. + if (!FakeRift) { - random += j * 2; - int dustAmtSpawned = 0; - int scale = random * 13; - float dustPositionX = Projectile.Center.X - (scale / 2); - float dustPositionY = Projectile.Center.Y - (scale / 2); - while (dustAmtSpawned < dustAmt) - { - float dustVelocityX = Main.rand.Next(-random, random); - float dustVelocityY = Main.rand.Next(-random, random); - float dustVelocityScalar = random * 2f; - float dustVelocity = (float)Math.Sqrt(dustVelocityX * dustVelocityX + dustVelocityY * dustVelocityY); - dustVelocity = dustVelocityScalar / dustVelocity; - dustVelocityX *= dustVelocity; - dustVelocityY *= dustVelocity; - int dust = Dust.NewDust(new Vector2(dustPositionX, dustPositionY), scale, scale, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 5f); - Main.dust[dust].noGravity = true; - Main.dust[dust].position.X = Projectile.Center.X; - Main.dust[dust].position.Y = Projectile.Center.Y; - Main.dust[dust].position.X += Main.rand.Next(-10, 11); - Main.dust[dust].position.Y += Main.rand.Next(-10, 11); - Main.dust[dust].velocity.X = dustVelocityX; - Main.dust[dust].velocity.Y = dustVelocityY; - dustAmtSpawned++; - } + Main.EntitySpriteDraw(starTexture, drawPosition, null, DoGSky.DoGTwlight * 0.9f * brightnessMultiplier * chargeInterpolant, 0f, starTexture.Size() * 0.5f, verticalStarPartScale * 0.8f, 0); + Main.EntitySpriteDraw(starTexture, drawPosition, null, DoGSky.DoGTwlight * 0.9f * brightnessMultiplier * chargeInterpolant, MathHelper.PiOver2, starTexture.Size() * 0.5f, horizontalStarPartScale * 0.8f, 0); } + + // Draw the crack. + Effect crackShader = CalamityShaders.DoGRealityCrackShader; + float crackOpcity = (AIState == 1f) ? Projectile.Opacity * 0.1f : 0.1f; + Color darkerPixelColor = FakeRift ? Color.White : DoGSky.DoGTwlight; + + crackShader.Parameters["opacityCutoffValue"].SetValue(CrackExposure); + crackShader.Parameters["fadeoutPower"].SetValue(1f); + crackShader.Parameters["overallOpacity"].SetValue(crackOpcity * brightnessMultiplier); + crackShader.Parameters["minBrightnessValue"].SetValue(0.75f); + crackShader.Parameters["darkerPixelColor"].SetValue(darkerPixelColor.ToVector3()); + crackShader.Parameters["brighterPixelColor"].SetValue(Color.White.ToVector3()); + Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, crackShader, Main.GameViewMatrix.TransformationMatrix, () => + { + int crackCount = FakeRift ? 1 : 3; + for (int i = 0; i < crackCount; i++) + { + float crackRotation = i * MathHelper.TwoPi / crackCount; + Main.EntitySpriteDraw(crackTexture, drawPosition + Vector2.UnitY * 8f, null, Color.White * Projectile.Opacity, crackRotation, crackTexture.Size() * 0.5f, CrackScale, 0); + } + }); + + if (AIState != 1f) + { + // Draw the bloom ring which closes inwards. + float ringScale = MathHelper.Lerp(8f, 0f, chargeInterpolant); + Color ringColor = FakeRift ? Color.White : Color.Lerp(Color.White, DoGSky.DoGTwlight, chargeInterpolant); + Main.EntitySpriteDraw(bloomRingTexture, drawPosition, null, ringColor * brightnessMultiplier * chargeInterpolant * 0.6f, 0f, bloomRingTexture.Size() * 0.5f, ringScale, 0); + } + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + return false; } } } diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 6e944b0b01..57002f0249 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -279,6 +279,8 @@ namespace CalamityMod.Projectiles public int BloodstoneOrbValue = 0; + public int HomingTarget = -1; + #region On Spawn public override void OnSpawn(Projectile projectile, IEntitySource source) { @@ -367,6 +369,8 @@ namespace CalamityMod.Projectiles { if (projectile.bobber && projectile.type != ModContent.ProjectileType() && RunFishingMinigames(projectile)) return false; + //Reset the Homing Target immediately before AI can re-set it on applicable projectiles + HomingTarget = -1; #region Vanilla Summons AI Changes // @@ -4732,6 +4736,13 @@ namespace CalamityMod.Projectiles } return true; } + + public override bool? CanHitNPC(Projectile projectile, NPC target) + { + if (target.Calamity().IsArmored() && HomingTarget > -1 && HomingTarget != target.whoAmI) + return false; + return null; + } #endregion #region Drawing diff --git a/Projectiles/Magic/ApotheosisWorm.cs b/Projectiles/Magic/ApotheosisWorm.cs index 3ca467c977..930ec49e1f 100644 --- a/Projectiles/Magic/ApotheosisWorm.cs +++ b/Projectiles/Magic/ApotheosisWorm.cs @@ -274,8 +274,8 @@ namespace CalamityMod.Projectiles.Magic Vector2 jawOrigin = jawTexture.Size() * 0.5f; // Segment drawing. - Texture2D bodyTexture = ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyS").Value; - Texture2D tailTexture = ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailS").Value; + Texture2D bodyTexture = ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBody_P2").Value; + Texture2D tailTexture = ModContent.Request("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTail_P2").Value; // Not white to differentiate itself slightly from regular DoG when fighting Boss Rush. Color baseColor = Color.Lerp(Color.White, Color.Fuchsia, 0.15f); diff --git a/Projectiles/Melee/MirrorBladeProjectile.cs b/Projectiles/Melee/MirrorBladeProjectile.cs index b2710900a3..9aa7f76830 100644 --- a/Projectiles/Melee/MirrorBladeProjectile.cs +++ b/Projectiles/Melee/MirrorBladeProjectile.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Boss; using CalamityMod.Sounds; using Microsoft.Xna.Framework; using Terraria; @@ -71,11 +72,20 @@ namespace CalamityMod.Projectiles.Melee if (!inStartup && !inCooldown) foreach (var proj in Main.ActiveProjectiles) { - if (proj.Hitbox.Intersects(Projectile.Hitbox) && proj.hostile && !reflectedProjectiles.Contains(proj.whoAmI)) + if (proj.type == ModContent.ProjectileType() && proj.ModProjectile().canDamage && !reflectedProjectiles.Contains(proj.whoAmI)) + { + reflectedProjectiles.Add(proj.whoAmI); + for (var i = 0; i < 3; i++) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), proj.Center, proj.velocity * -1, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner); + SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact, Projectile.Center); + } + } + else if (proj.Hitbox.Intersects(Projectile.Hitbox) && proj.hostile && !reflectedProjectiles.Contains(proj.whoAmI)) { reflectedProjectiles.Add(proj.whoAmI); Projectile.NewProjectile(Projectile.GetSource_FromThis(), proj.Center, proj.velocity * -1, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner); - SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact,Projectile.Center); + SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact, Projectile.Center); } } diff --git a/Projectiles/Melee/MirrorBlast.cs b/Projectiles/Melee/MirrorBlast.cs index 98cc282745..337004dc4b 100644 --- a/Projectiles/Melee/MirrorBlast.cs +++ b/Projectiles/Melee/MirrorBlast.cs @@ -142,6 +142,12 @@ namespace CalamityMod.Projectiles.Melee else { float homingStrength = 0.025f; // Adjust this value for stronger or weaker homing + if (Projectile.timeLeft < 1000) + homingStrength *= 2f; + if (Projectile.timeLeft < 800) + homingStrength *= 2f; + if (Projectile.timeLeft < 600) + homingStrength *= 2f; NPC target = FindClosestNPC(3200f); if (target != null) { diff --git a/Scenes/BossBackgroundScenes/DoGBackgroundScene.cs b/Scenes/BossBackgroundScenes/DoGBackgroundScene.cs index 3530af36a3..194d475201 100644 --- a/Scenes/BossBackgroundScenes/DoGBackgroundScene.cs +++ b/Scenes/BossBackgroundScenes/DoGBackgroundScene.cs @@ -1,5 +1,7 @@ -using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs; +using CalamityMod.NPCs.DevourerofGods; using Terraria; +using Terraria.Graphics.Effects; using Terraria.ModLoader; namespace CalamityMod.Systems @@ -8,11 +10,21 @@ namespace CalamityMod.Systems { public override SceneEffectPriority Priority => SceneEffectPriority.BossHigh; - public override bool IsSceneEffectActive(Player player) => NPC.AnyNPCs(ModContent.NPCType()); + public override bool IsSceneEffectActive(Player player) + { + bool monolithIsActive = Main.LocalPlayer.Calamity().monolithDevourerBShader > 0 || Main.LocalPlayer.Calamity().monolithDevourerPShader > 0; + bool dogIsAlive = NPC.AnyNPCs(ModContent.NPCType()); + + return dogIsAlive || monolithIsActive; + } public override void SpecialVisuals(Player player, bool isActive) { player.ManageSpecialBiomeVisuals("CalamityMod:DevourerofGodsHead", isActive); + if (isActive) + SkyManager.Instance.Activate("CalamityMod:DevourerofGodsHead"); + else + SkyManager.Instance.Deactivate("CalamityMod:DevourerofGodsHead"); } } } diff --git a/Scenes/MiscScenes/MonolithDistortionScene.cs b/Scenes/MiscScenes/MonolithDistortionScene.cs deleted file mode 100644 index 9396487fc8..0000000000 --- a/Scenes/MiscScenes/MonolithDistortionScene.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Systems -{ - public class MonolithDistortionScene : ModSceneEffect - { - public override SceneEffectPriority Priority => SceneEffectPriority.Environment; - - public override bool IsSceneEffectActive(Player player) => Main.LocalPlayer.Calamity().monolithDevourerBShader > 0 || Main.LocalPlayer.Calamity().monolithDevourerPShader > 0; - - public override void SpecialVisuals(Player player, bool isActive) - { - player.ManageSpecialBiomeVisuals("CalamityMod:DevourerofGodsHead", isActive); - } - } -} diff --git a/NPCs/DevourerofGods/DoGScreenShaderData.cs b/Skies/DoGScreenShaderData.cs similarity index 86% rename from NPCs/DevourerofGods/DoGScreenShaderData.cs rename to Skies/DoGScreenShaderData.cs index 78a58b4511..a44f2777b8 100644 --- a/NPCs/DevourerofGods/DoGScreenShaderData.cs +++ b/Skies/DoGScreenShaderData.cs @@ -1,10 +1,11 @@ -using Microsoft.Xna.Framework; +using CalamityMod.NPCs.DevourerofGods; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Graphics.Effects; using Terraria.Graphics.Shaders; using Terraria.ModLoader; -namespace CalamityMod.NPCs.DevourerofGods +namespace CalamityMod.Skies { public class DoGScreenShaderData : ScreenShaderData { @@ -17,13 +18,13 @@ namespace CalamityMod.NPCs.DevourerofGods private void UpdateDoGIndex() { - int DoGType = ModContent.NPCType(); + var DoGType = ModContent.NPCType(); if (DoGIndex >= 0 && Main.npc[DoGIndex].active && Main.npc[DoGIndex].type == DoGType) { return; } DoGIndex = -1; - foreach (NPC n in Main.ActiveNPCs) + foreach (var n in Main.ActiveNPCs) { if (n.type == DoGType) { @@ -54,6 +55,8 @@ namespace CalamityMod.NPCs.DevourerofGods { UseTargetPosition(Main.LocalPlayer.Center); } + + UseColor(DoGSky.DoGSkyColor); base.Apply(); } } diff --git a/Skies/DoGSky.cs b/Skies/DoGSky.cs new file mode 100644 index 0000000000..e13f82ae93 --- /dev/null +++ b/Skies/DoGSky.cs @@ -0,0 +1,501 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Dusts; +using CalamityMod.Effects; +using CalamityMod.Events; +using CalamityMod.Graphics; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Items.Placeables.FurnitureVoid; +using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.Systems.Graphic; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.Graphics.Effects; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Skies +{ + public class DoGSky : CustomSky + { + public class RealityCrack + { + public Vector2 Position; + + public float Depth; + + public float Scale; + + public float Rotation; + } + + public class DistortionRiftArm + { + public Vector2 ArmStartingPosition; + + public List ArmPoints; + + public float Depth; + + public float MaxWidth; + + public float MinDistanceBetweenPoints; + + public float MaxDistanceBetweenPoints; + + public float MinPointAngularVariance; + + public float MaxPointAngularVariance; + + public int TotalPoints; + } + + public static readonly Color DoGTwlight = new(147, 24, 204); + + public static readonly Color DoGLightBlue = new(0, 221, 250); + + public bool Initialized; + + public int DoGIndex; + + public List MainRiftCracks; + + public List OuterRiftCracks; + + public List RealityCracks; + + public List DistortionRiftArms; + + public static bool CanSkyBeActive { get; private set; } + + public static float SkyIntensity { get; private set; } + + public static Color DoGSkyColor { get; private set; } + + public override void Update(GameTime gameTime) + { + // Initialize the rift arms and background cracks. + GenerateRift(); + + DoGIndex = NPC.FindFirstNPC(ModContent.NPCType()); + GetCorrectDoGColor(); + + if (CanSkyBeActive) + SkyIntensity = MathHelper.Clamp(SkyIntensity + 0.05f, 0f, 1f); + else + SkyIntensity = MathHelper.Clamp(SkyIntensity - 0.05f, 0f, 1f); + } + + private void GenerateRift() + { + Vector2 riftSpawnLocation = Main.LocalPlayer.Center - Vector2.UnitY * 2000f + Main.rand.NextVector2Circular(2000f, 2000f); + + if (!Initialized) + { + MainRiftCracks = []; + OuterRiftCracks = []; + RealityCracks = []; + DistortionRiftArms = []; + + int crackCount = 3; + for (int i = 0; i < crackCount; i++) + { + RealityCrack realityCrack = new RealityCrack() + { + Position = riftSpawnLocation, + Depth = 30f, + Scale = 1.55f * Main.rand.NextFloat(0.9f, 1.1f), + Rotation = i * MathHelper.TwoPi / crackCount + }; + RealityCracks.Add(realityCrack); + } + + // Generate up to 30 arms for the rift. + // The first 14 are larger cracks to form the main hole at the impact point. + // The rest are longer, skinner cracks protruding outwards from it. + for (int i = 0; i < 14; i++) + { + DistortionRiftArm distortionRiftArm = new DistortionRiftArm() + { + ArmStartingPosition = riftSpawnLocation, + Depth = 30f, + TotalPoints = 8, + + MaxWidth = Main.rand.NextFloat(100f, 120f), + MinDistanceBetweenPoints = 100f, + MaxDistanceBetweenPoints = 140f, + MinPointAngularVariance = -6, + MaxPointAngularVariance = 6, + + ArmPoints = [], + }; + MainRiftCracks.Add(distortionRiftArm); + } + + int outerCracksAmount = Main.rand.Next(12, 17); + for (int i = 0; i < outerCracksAmount; i++) + { + DistortionRiftArm distortionRiftArm = new DistortionRiftArm() + { + ArmStartingPosition = riftSpawnLocation, + Depth = 30f, + TotalPoints = Main.rand.Next(6, 10), + + MaxWidth = Main.rand.NextFloat(6f, 9f), + MinDistanceBetweenPoints = 400f, + MaxDistanceBetweenPoints = 500f, + MinPointAngularVariance = Main.rand.Next(-10, -5), + MaxPointAngularVariance = Main.rand.Next(5, 10), + + ArmPoints = [], + }; + OuterRiftCracks.Add(distortionRiftArm); + } + + // Generate the points for each arm and add them all to the global arm list. + // Main cracks. + for (int i = 0; i < MainRiftCracks.Count; i++) + { + float minDistance = MainRiftCracks[i].MinDistanceBetweenPoints * MainRiftCracks[i].Depth * 0.1f; + float maxDistance = MainRiftCracks[i].MaxDistanceBetweenPoints * MainRiftCracks[i].Depth * 0.1f; + float minAngularVariance = MainRiftCracks[i].MinPointAngularVariance; + float maxAngularVariance = MainRiftCracks[i].MaxPointAngularVariance; + float placementAngle = i * MathHelper.TwoPi / MainRiftCracks.Count; + + if (MainRiftCracks[i].ArmPoints.Count <= 0) + MainRiftCracks[i].ArmPoints = GenerateDistortionRiftArmPoints(MainRiftCracks[i].ArmStartingPosition, MainRiftCracks[i].TotalPoints, minDistance, maxDistance, minAngularVariance, maxAngularVariance, placementAngle); + DistortionRiftArms.Add(MainRiftCracks[i]); + } + + // Outer cracks. + for (int i = 0; i < OuterRiftCracks.Count; i++) + { + float minDistance = OuterRiftCracks[i].MinDistanceBetweenPoints * OuterRiftCracks[i].Depth * 0.1f; + float maxDistance = OuterRiftCracks[i].MaxDistanceBetweenPoints * OuterRiftCracks[i].Depth * 0.1f; + float minAngularVariance = OuterRiftCracks[i].MinPointAngularVariance; + float maxAngularVariance = OuterRiftCracks[i].MaxPointAngularVariance; + float placementAngle = i * MathHelper.TwoPi / OuterRiftCracks.Count; + + if (OuterRiftCracks[i].ArmPoints.Count <= 0) + OuterRiftCracks[i].ArmPoints = GenerateDistortionRiftArmPoints(OuterRiftCracks[i].ArmStartingPosition, OuterRiftCracks[i].TotalPoints, minDistance, maxDistance, minAngularVariance, maxAngularVariance, placementAngle); + DistortionRiftArms.Add(OuterRiftCracks[i]); + } + + Initialized = true; + } + } + + private static List GenerateDistortionRiftArmPoints(Vector2 startingPosition, int totalPoints, float minDistanceBetweenPoints, float maxDistanceBetweenPoints, float minAngularVariance, float maxAngularVariance, float? optionalPointPlacementAngle = null) + { + // (Original code by Xyk; See TriactisHammerExplosion) + // -fryzahh + + List points = []; + for (int j = 0; j < totalPoints; j++) + { + // First point should always be the starting position. + if (j == 0) + { + points.Add(startingPosition); + } + // Next point should be a random location around the starting position. + // If the placement angle has a value then rotate towards that with a very slight offset. + else if (j == 1) + { + float distanceFromLastPoint = Main.rand.NextFloat(minDistanceBetweenPoints, maxDistanceBetweenPoints); + Vector2 nextPointPosition = startingPosition + Main.rand.NextVector2Unit() * distanceFromLastPoint; + if (optionalPointPlacementAngle != null) + nextPointPosition = startingPosition + Vector2.UnitX.RotatedBy(optionalPointPlacementAngle.Value) * distanceFromLastPoint; + points.Add(nextPointPosition); + } + // All other points follow after the last one with the same slight offset to resemble cracks. + else + { + Vector2 previousPoint = points[j - 2]; + float distanceFromLastPoint = Main.rand.NextFloat(minDistanceBetweenPoints, maxDistanceBetweenPoints); + if (j == totalPoints - 1) + distanceFromLastPoint = Main.rand.NextFloat(minDistanceBetweenPoints, maxDistanceBetweenPoints) * 0.5f; + + Vector2 newPoint = points[j - 1] + (previousPoint.DirectionTo(points[j - 1]) * distanceFromLastPoint).RotatedBy(MathHelper.ToRadians(Main.rand.NextFloat(minAngularVariance, maxAngularVariance) * j * 0.5f)); + points.Add(newPoint); + } + } + + return points; + } + + public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) + { + if (Main.gameMenu || !CalamityClientConfig.Instance.FancyBackgroundVisuals) + return; + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw the wind effect. + if (minDepth >= float.MinValue && maxDepth <= 5f) + DrawDistortionWinds(spriteBatch); + + // Draw the rolling fog effect. + if (minDepth >= 3f && maxDepth <= 10f) + DrawRollingBackgroundFog(spriteBatch); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw the rift aura. + if (minDepth >= 6f && maxDepth <= float.MaxValue) + DrawRiftAura(spriteBatch); + + // Draw the cracked glass textures. + if (minDepth >= 6f && maxDepth <= float.MaxValue) + DrawRealityCracks(spriteBatch); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw the rift to the Distortion over the cracked glass. + if (minDepth >= 6f && maxDepth <= float.MaxValue) + DrawDistortionRift(spriteBatch); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + } + + public void DrawRiftToRenderTarget() + { + if (DistortionRiftArms == null || DistortionRiftArms.Count == 0) + return; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Vector2 screenCenter = Main.screenPosition + (screenSize * 0.5f); + + for (int i = 0; i < DistortionRiftArms.Count; i++) + { + Vector2 depthFactor = new(1f / DistortionRiftArms[i].Depth, 0.9f / DistortionRiftArms[i].Depth); + List parallaxedPoints = []; + for (int j = 0; j < DistortionRiftArms[i].ArmPoints.Count; j++) + parallaxedPoints.Add((DistortionRiftArms[i].ArmPoints[j] - screenCenter) * depthFactor + screenCenter); + + PrimitiveRenderer.RenderTrail(parallaxedPoints, new((completion) => MathHelper.Lerp(0f, DistortionRiftArms[i].MaxWidth, 1f - completion) * SkyIntensity, (_) => Color.White * 1f, null, false, useUnscaledMatrices: true), DistortionRiftArms[i].TotalPoints + 16); + } + } + + private void DrawDistortionWinds(SpriteBatch spriteBatch) + { + Effect shader = CalamityShaders.DoGDistortionWindsShader; + Texture2D windsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2").Value; + Texture2D highlightsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/SharpNoise").Value; + Texture2D distortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/MeltyNoise").Value; + Texture2D erosionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Pebbles").Value; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + shader.Parameters["overallOpacity"].SetValue(SkyIntensity); + shader.Parameters["distortionStrength"].SetValue(0.3f); + shader.Parameters["mainNoiseTextureScale"].SetValue(0.8f); + shader.Parameters["distortionTextureScale"].SetValue(0.6f); + shader.Parameters["erosionTextureScale"].SetValue(2f); + shader.Parameters["erosionMin"].SetValue(0.38f * SkyIntensity); + shader.Parameters["gradientPrecision"].SetValue(20f); + + shader.Parameters["pixelationFactor"].SetValue(screenSize * 0.5f); + shader.Parameters["worldOffset"].SetValue(Main.screenPosition / windsTexture.Size() * 0.025f); + + shader.Parameters["darkerPixelColor"].SetValue(Color.Lerp(Color.DarkGray, Color.Black, 0.82f).ToVector3()); + shader.Parameters["brighterPixelColor"].SetValue(Color.Lerp(Color.Black, DoGSkyColor, 0.32f).ToVector3()); + shader.Parameters["highlightsColor"].SetValue(DoGSkyColor.ToVector3()); + + Main.instance.GraphicsDevice.Textures[1] = highlightsTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.PointWrap; + + Main.instance.GraphicsDevice.Textures[2] = distortionTexture; + Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearWrap; + + Main.instance.GraphicsDevice.Textures[3] = erosionTexture; + Main.instance.GraphicsDevice.SamplerStates[3] = SamplerState.LinearWrap; + + shader.CurrentTechnique.Passes[0].Apply(); + spriteBatch.Draw(windsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); + } + + private void DrawRollingBackgroundFog(SpriteBatch spriteBatch) + { + Effect shader = CalamityShaders.DoGBackgroundFogShader; + Texture2D cloudsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/RealisticClouds").Value; + Texture2D erosionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise").Value; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 3f); + shader.Parameters["overallOpacity"].SetValue(SkyIntensity * 0.25f); + shader.Parameters["distortionStrength"].SetValue(0.12f); + shader.Parameters["mainNoiseTextureScale"].SetValue(0.6f); + shader.Parameters["distortionTextureScale"].SetValue(0.8f); + shader.Parameters["erosionTextureScale"].SetValue(0.26f); + shader.Parameters["erosionMin"].SetValue(0.06f * SkyIntensity); + shader.Parameters["gradientPrecision"].SetValue(20f); + + shader.Parameters["pixelationFactor"].SetValue(screenSize * 0.5f); + shader.Parameters["worldOffset"].SetValue(Main.screenPosition / cloudsTexture.Size() * 0.005f); + + shader.Parameters["darkerPixelColor"].SetValue(Color.Lerp(Color.Black, Color.DarkGray, 0.75f).ToVector3()); + shader.Parameters["brighterPixelColor"].SetValue(Color.Lerp(Color.DarkGray, DoGSkyColor, 0.8f).ToVector3()); + + Main.instance.GraphicsDevice.Textures[1] = cloudsTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + Main.instance.GraphicsDevice.Textures[2] = erosionTexture; + Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearWrap; + + shader.CurrentTechnique.Passes[0].Apply(); + spriteBatch.Draw(cloudsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); + } + + private void DrawRiftAura(SpriteBatch spriteBatch) + { + if (RealityCracks == null || RealityCracks.Count == 0) + return; + + Effect shader = CalamityShaders.DoGRiftAuraShader; + Texture2D riftAuraTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Smudges").Value; + Texture2D distortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Swirls").Value; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Vector2 screenCenter = Main.screenPosition + (screenSize * 0.5f); + + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + shader.Parameters["pixelSize"].SetValue(screenSize * 0.5f); + shader.Parameters["distortionStrength"].SetValue(0.78f); + + shader.Parameters["opacityCutoffValue"].SetValue(0.675f * SkyIntensity); + shader.Parameters["fadeoutPower"].SetValue(1.25f); + shader.Parameters["overallOpacity"].SetValue(0.6f); + + shader.Parameters["minBrightnessValue"].SetValue(0f); + shader.Parameters["brighterPixelColor"].SetValue(DoGSkyColor.ToVector3()); + shader.Parameters["gradientPrecision"].SetValue(8f); + + Main.instance.GraphicsDevice.Textures[1] = distortionTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.PointWrap; + + shader.CurrentTechnique.Passes[0].Apply(); + + Vector2 depthFactor = new(1f / RealityCracks[0].Depth, 0.9f / RealityCracks[0].Depth); + Vector2 drawPosition = (RealityCracks[0].Position - screenCenter) * depthFactor + screenCenter - Main.screenPosition; + spriteBatch.Draw(riftAuraTexture, drawPosition, null, Color.White, Main.GlobalTimeWrappedHourly * MathHelper.TwoPi / 270f, riftAuraTexture.Size() * 0.5f, 1f, 0, 0f); + } + + private void DrawRealityCracks(SpriteBatch spriteBatch) + { + if (RealityCracks == null || RealityCracks.Count == 0) + return; + + Effect shader = CalamityShaders.DoGRealityCrackShader; + Texture2D cracksTexture = ModContent.Request("CalamityMod/ExtraTextures/CrackedGlass_Glowing").Value; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Vector2 screenCenter = Main.screenPosition + (screenSize * 0.5f); + + shader.Parameters["opacityCutoffValue"].SetValue(0.8f * SkyIntensity); + shader.Parameters["fadeoutPower"].SetValue(1f); + shader.Parameters["overallOpacity"].SetValue(0.1015f); + + shader.Parameters["minBrightnessValue"].SetValue(0.6f); + shader.Parameters["darkerPixelColor"].SetValue(DoGSkyColor.ToVector3()); + shader.Parameters["brighterPixelColor"].SetValue(Color.White.ToVector3()); + + shader.CurrentTechnique.Passes[0].Apply(); + + for (int i = 0; i < RealityCracks.Count; i++) + { + Vector2 depthFactor = new(1f / RealityCracks[i].Depth, 0.9f / RealityCracks[i].Depth); + Vector2 drawPosition = (RealityCracks[i].Position - screenCenter) * depthFactor + screenCenter - Main.screenPosition; + spriteBatch.Draw(cracksTexture, drawPosition, null, Color.White, RealityCracks[i].Rotation, cracksTexture.Size() * 0.5f, RealityCracks[i].Scale, 0, 0f); + } + } + + private void DrawDistortionRift(SpriteBatch spriteBatch) + { + // Impose the distortion rift contents onto the primitives via shader. + var metaballShader = CalamityShaders.MetaballEdgeShader; + Texture2D distortionRiftContents = DoGVisualsManager.DistortionRiftBackgroundContentsTarget; + Texture2D distortionRift = DoGVisualsManager.DistortionRiftPrimitivesTarget; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + metaballShader.Parameters["layerSize"]?.SetValue(distortionRiftContents.Size()); + metaballShader.Parameters["screenSize"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["edgeColor"]?.SetValue(Color.Lerp(Color.Lerp(DoGSkyColor, Color.White, 0.6f), Color.Black, 0.15f).ToVector4()); + + Main.instance.GraphicsDevice.Textures[1] = distortionRiftContents; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + metaballShader.CurrentTechnique.Passes[0].Apply(); + spriteBatch.Draw(distortionRift, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); + } + + private void GetCorrectDoGColor() + { + if (DoGIndex != -1) + { + var DoG = Main.npc[DoGIndex].ModNPC(); + Color goalSkyColor = Color.Black; + if (DoG.isInAgressiveState) + goalSkyColor = Color.Fuchsia; + if (DoG.isInPassiveState) + goalSkyColor = DoGLightBlue; + if (DoG.isInLaserWallState || DoG.isInPostWallState || DoG.postTeleportTimer > 0 || DoG.teleportTimer > 0 || DoG.NPC.localAI[2] < 180 && DoG.NPC.localAI[2] > 60) + goalSkyColor = DoGTwlight; + + DoGSkyColor = Color.Lerp(DoGSkyColor, goalSkyColor, 0.1f); + } + else + { + var goalSkyColor = Color.Black; + if (Main.LocalPlayer.Calamity().monolithDevourerPShader > 0) + goalSkyColor = Color.Fuchsia; + if (Main.LocalPlayer.Calamity().monolithDevourerBShader > 0) + goalSkyColor = DoGLightBlue; + + DoGSkyColor = Color.Lerp(DoGSkyColor, goalSkyColor, 0.1f); + } + } + + public override Color OnTileColor(Color inColor) => Color.Lerp(inColor, DoGSkyColor, SkyIntensity); + + public override float GetCloudAlpha() => 1f; + + public override void Activate(Vector2 position, params object[] args) => CanSkyBeActive = true; + + public override bool IsActive() => CanSkyBeActive || SkyIntensity > 0f; + + public override void Deactivate(params object[] args) + { + CanSkyBeActive = false; + if (SkyIntensity <= 0.1f) + { + Initialized = false; + DistortionRiftArms?.Clear(); + RealityCracks?.Clear(); + } + } + + public override void Reset() + { + CanSkyBeActive = false; + Initialized = false; + DistortionRiftArms?.Clear(); + RealityCracks?.Clear(); + } + } +} diff --git a/Sounds/Custom/DevourerRiftBuilding.ogg b/Sounds/Custom/DevourerRiftBuilding.ogg new file mode 100644 index 0000000000..1872e0b733 Binary files /dev/null and b/Sounds/Custom/DevourerRiftBuilding.ogg differ diff --git a/Sounds/Custom/DevourerRiftOpen.ogg b/Sounds/Custom/DevourerRiftOpen.ogg new file mode 100644 index 0000000000..3e5600b1b0 Binary files /dev/null and b/Sounds/Custom/DevourerRiftOpen.ogg differ diff --git a/Sounds/Custom/DoGLaserWallBigAttack.ogg b/Sounds/Custom/DoGLaserWallBigAttack.ogg new file mode 100644 index 0000000000..ee5be64033 Binary files /dev/null and b/Sounds/Custom/DoGLaserWallBigAttack.ogg differ diff --git a/Sounds/Custom/DoGLaserWallBigAttack2.ogg b/Sounds/Custom/DoGLaserWallBigAttack2.ogg new file mode 100644 index 0000000000..ab3c26aceb Binary files /dev/null and b/Sounds/Custom/DoGLaserWallBigAttack2.ogg differ diff --git a/Sounds/Custom/DoGLaserWallLightAttack.ogg b/Sounds/Custom/DoGLaserWallLightAttack.ogg new file mode 100644 index 0000000000..a409d56d6e Binary files /dev/null and b/Sounds/Custom/DoGLaserWallLightAttack.ogg differ diff --git a/Sounds/Custom/DoGLaserWallSpawn.ogg b/Sounds/Custom/DoGLaserWallSpawn.ogg new file mode 100644 index 0000000000..fc576f4395 Binary files /dev/null and b/Sounds/Custom/DoGLaserWallSpawn.ogg differ diff --git a/Systems/Collections/CalamityNPCSets.cs b/Systems/Collections/CalamityNPCSets.cs index 88f24502a4..9e653f588b 100644 --- a/Systems/Collections/CalamityNPCSets.cs +++ b/Systems/Collections/CalamityNPCSets.cs @@ -89,7 +89,7 @@ namespace CalamityMod.Systems.Collections NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), - NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), diff --git a/Systems/Graphic/DoGVisualsManager.cs b/Systems/Graphic/DoGVisualsManager.cs new file mode 100644 index 0000000000..c1a201f16c --- /dev/null +++ b/Systems/Graphic/DoGVisualsManager.cs @@ -0,0 +1,359 @@ +using CalamityMod.Effects; +using CalamityMod.Graphics; +using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.Skies; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using ReLogic.Content; +using Terraria.GameContent; +using Terraria.Graphics.Effects; +using Terraria; +using Terraria.ModLoader; +using System.Collections.Generic; +using Terraria.ID; +using System; +using CalamityMod.Graphics.Metaballs; +using System.Linq; + +namespace CalamityMod.Systems.Graphic +{ + public class DoGVisualsManager : ModSystem + { + public float FillProgress = 0; + + public float BackgroundLightningFill; + + public float BackgroundLightningMax; + + public float BackgroundLightningTimer; + + /// + /// Whether or not the background render targets should have their contents drawn to them. + /// + public static bool ShouldDrawToBackgroundTargets => DoGSky.SkyIntensity > 0f; + + /// + /// Whether or not the foreground render target should have its contents drawn to it. + /// + public static bool ShouldDrawToForegroundTarget => MetaballManager.metaballs.Any(m => m.AnythingToDraw && m is DoGDistortionMetaball); + + /// + /// The actual effects and contents seen inside the rift in the background of DoG's fight. + /// + public static ManagedRenderTarget DistortionRiftBackgroundContentsTarget { get; private set; } + + /// + /// The primitives used to make up the shape of the rift seen in the background of DoG's fight. + /// + public static ManagedRenderTarget DistortionRiftPrimitivesTarget { get; private set; } + + /// + /// The actual effects and contents seen inside of certain attacks used by DoG. Also used for DoG's distortion metaballs. + /// + public static ManagedRenderTarget DistortionForegroundContentsTarget { get; private set; } + + public override void OnModLoad() + { + if (Main.dedServ) + return; + + On_Main.DrawSunAndMoon += DiscardCelestialObjects; + } + + public override void PostSetupContent() + { + if (Main.dedServ) + return; + + Main.QueueMainThreadAction(() => + { + DistortionRiftBackgroundContentsTarget = new(true, ManagedRenderTarget.CreateScreenSizedTarget); + DistortionRiftPrimitivesTarget = new(true, ManagedRenderTarget.CreateScreenSizedTarget); + DistortionForegroundContentsTarget = new(true, ManagedRenderTarget.CreateScreenSizedTarget); + }); + RenderTargetManager.RenderTargetUpdateLoopEvent += PrepareTargets; + } + + public override void OnModUnload() + { + if (Main.dedServ) + return; + + On_Main.DrawSunAndMoon -= DiscardCelestialObjects; + RenderTargetManager.RenderTargetUpdateLoopEvent -= PrepareTargets; + } + + public override void PostUpdateEverything() + { + if (DoGSky.SkyIntensity > 0.1f) + { + // Disable ambient sky entities while DoG's background effects are active. + if (SkyManager.Instance["Ambience"].IsActive()) + SkyManager.Instance["Ambience"].Deactivate(); + + if (CalamityClientConfig.Instance.FancyBackgroundVisuals) + { + // Randomly flicker between different values to create a natural lightning effect in the background of the + // Distortion rift's clouds. + if (Main.rand.NextBool(200) && DoGSky.SkyIntensity > 0f && BackgroundLightningTimer <= 0f) + { + BackgroundLightningTimer = Main.rand.NextBool(10) ? Main.rand.Next(30, 45) : Main.rand.Next(5, 20); + BackgroundLightningMax = Main.rand.NextFloat(0.7f, 0.9f); + } + + if (BackgroundLightningTimer > 0f) + { + float minFill = BackgroundLightningMax * 0.5f; + BackgroundLightningFill = Main.rand.NextFloat(minFill, BackgroundLightningMax); + BackgroundLightningTimer--; + } + else + { + if (BackgroundLightningTimer < 0f) + BackgroundLightningTimer = 0f; + BackgroundLightningFill = MathHelper.Lerp(BackgroundLightningFill, 0f, 0.05f); + } + } + } + } + + public override void ModifySunLightColor(ref Color tileColor, ref Color backgroundColor) + { + if (DoGSky.SkyIntensity > 0f) + FillProgress += 0.05f; + else + FillProgress -= 0.05f; + + // Darken the lighting color of both the background and foreground. + FillProgress = MathHelper.Clamp(FillProgress, 0, 1); + if (FillProgress > 0) + { + Color colorToUse = DoGSky.DoGSkyColor; + float tileBrightness = CalamityClientConfig.Instance.FancyBackgroundVisuals ? 35f : 190f; + + backgroundColor.R = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.R, Color.White.R * 0.035f, FillProgress); + backgroundColor.G = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.G, Color.White.G * 0.035f, FillProgress); + backgroundColor.B = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.B, Color.White.B * 0.035f, FillProgress); + backgroundColor = new(backgroundColor.ToVector3() + colorToUse.ToVector3() * 0.025f * FillProgress); + + tileColor.R = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.R, tileBrightness, FillProgress); + tileColor.G = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.G, tileBrightness, FillProgress); + tileColor.B = (byte)MathHelper.Lerp(Main.ColorOfTheSkies.B, tileBrightness, FillProgress); + + float tileColorAdditive = CalamityClientConfig.Instance.FancyBackgroundVisuals ? 0.075f : 0.4f; + tileColor = new(tileColor.ToVector3() + colorToUse.ToVector3() * tileColorAdditive * FillProgress); + } + } + + private void DiscardCelestialObjects(On_Main.orig_DrawSunAndMoon orig, Main self, Main.SceneArea sceneArea, Color moonColor, Color sunColor, float tempMushroomInfluence) + { + // Fade out the sun and moon during DoG's fight. + if (DoGSky.SkyIntensity > 0f) + { + tempMushroomInfluence = DoGSky.SkyIntensity; + moonColor *= 1f - DoGSky.SkyIntensity; + } + + orig(self, sceneArea, moonColor, sunColor, tempMushroomInfluence); + } + + private void PrepareTargets() + { + // Determine when targets should have their contents drawn onto them in order to save on performance. + if (ShouldDrawToBackgroundTargets) + { + // Draw the background which'll be displayed inside the rift onto a render target. + DistortionRiftBackgroundContentsTarget.SwapTo(); + DrawDistortionRiftBackground(); + + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw the primitives which comprise the rift to another render target. + DistortionRiftPrimitivesTarget.SwapTo(); + if (SkyManager.Instance["CalamityMod:DevourerofGodsHead"].IsActive()) + (SkyManager.Instance["CalamityMod:DevourerofGodsHead"] as DoGSky).DrawRiftToRenderTarget(); + + Main.spriteBatch.End(); + } + + if (ShouldDrawToForegroundTarget) + { + // Draw the background which'll be displayed for all distortion-related effects done in the foreground (same layer as the player). + DistortionForegroundContentsTarget.SwapTo(); + DrawDistortionForeground(); + } + + // Reset the current render target at the end of the method once any targets are being drawn to. + if (ShouldDrawToForegroundTarget || ShouldDrawToBackgroundTargets) + Main.instance.GraphicsDevice.SetRenderTarget(null); + } + + #region Distortion Background Drawing + private void DrawDistortionRiftBackground() + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw a black tile behind everything since the shader used to generate the clouds will appear transparent with dark colors, thus revealing + // the sky and any of its effects under the rift. + DrawDistortionLightningBackdrop_Background(); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw the layer of rolling clouds in the background. + DrawDistortionClouds_Background(); + + Main.spriteBatch.End(); + } + + private void DrawDistortionLightningBackdrop_Background() + { + // Flicker between white and black for the lightning effect. + Color backdropColor = Color.Lerp(Color.Lerp(Color.Black, Color.White, BackgroundLightningFill), DoGSky.DoGSkyColor, 0.25f); + Main.spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), backdropColor); + } + + private void DrawDistortionClouds_Background() + { + Effect rollingCloudsShader = CalamityShaders.DoGBackgroundFogShader; + Texture2D cloudsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/RealisticClouds").Value; + Texture2D distortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2").Value; + Texture2D erosionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise").Value; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Color darkPixelColor = Color.Lerp(Color.Lerp(Color.Black, Color.DarkGray, 0.3f), Color.Black, BackgroundLightningFill * 0.8f); + Color brightPixelColor = Color.Lerp(Color.Lerp(Color.Black, DoGSky.DoGSkyColor, 0.6f), Color.Black, BackgroundLightningFill * 0.8f); + + rollingCloudsShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + rollingCloudsShader.Parameters["overallOpacity"].SetValue(1f); + rollingCloudsShader.Parameters["distortionStrength"].SetValue(0.24f); + rollingCloudsShader.Parameters["mainNoiseTextureScale"].SetValue(2f); + rollingCloudsShader.Parameters["distortionTextureScale"].SetValue(0.8f); + rollingCloudsShader.Parameters["erosionTextureScale"].SetValue(0.26f); + rollingCloudsShader.Parameters["erosionMin"].SetValue(0.06f); + rollingCloudsShader.Parameters["gradientPrecision"].SetValue(20f); + + rollingCloudsShader.Parameters["pixelationFactor"].SetValue(screenSize * 0.5f); + rollingCloudsShader.Parameters["worldOffset"].SetValue(Main.screenPosition / cloudsTexture.Size() * 0.001f); + + rollingCloudsShader.Parameters["darkerPixelColor"].SetValue(darkPixelColor.ToVector3()); + rollingCloudsShader.Parameters["brighterPixelColor"].SetValue(brightPixelColor.ToVector3()); + + Main.instance.GraphicsDevice.Textures[1] = distortionTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + Main.instance.GraphicsDevice.Textures[2] = erosionTexture; + Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearWrap; + + rollingCloudsShader.CurrentTechnique.Passes[0].Apply(); + Main.spriteBatch.Draw(cloudsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); + } + #endregion + + #region Distortion Foreground Drawing + private void DrawDistortionForeground() + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw a black tile for the same reasoning explained above for the background drawing. + Main.spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + // Draw a layer of rolling clouds in the background. + DrawDistortionClouds_Foreground(); + + // Draw the winds effect in front of everything. + DrawDistortionWinds_Foreground(); + + Main.spriteBatch.End(); + } + + private void DrawDistortionWinds_Foreground() + { + Effect windsShader = CalamityShaders.DoGDistortionWindsShader; + + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + Texture2D windsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2").Value; + Texture2D highlightsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/SharpNoise").Value; + Texture2D distortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/MeltyNoise").Value; + Texture2D erosionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Pebbles").Value; + + windsShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 1.075f); + windsShader.Parameters["overallOpacity"].SetValue(0.8f); + windsShader.Parameters["distortionStrength"].SetValue(0.3f); + windsShader.Parameters["mainNoiseTextureScale"].SetValue(1.6f); + windsShader.Parameters["distortionTextureScale"].SetValue(1.76f); + windsShader.Parameters["erosionTextureScale"].SetValue(2f); + windsShader.Parameters["erosionMin"].SetValue(0.5f); + windsShader.Parameters["gradientPrecision"].SetValue(20f); + + windsShader.Parameters["pixelationFactor"].SetValue(screenSize * 0.5f); + windsShader.Parameters["worldOffset"].SetValue(Main.screenPosition / windsTexture.Size() * 0.025f); + + windsShader.Parameters["darkerPixelColor"].SetValue(Color.Lerp(Color.DarkGray, Color.Black, 0.64f).ToVector3()); + windsShader.Parameters["brighterPixelColor"].SetValue(Color.Lerp(Color.DarkGray, Color.Black, 0.32f).ToVector3()); + windsShader.Parameters["highlightsColor"].SetValue(Color.Fuchsia.ToVector3()); + + Main.instance.GraphicsDevice.Textures[1] = highlightsTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.PointWrap; + + Main.instance.GraphicsDevice.Textures[2] = distortionTexture; + Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearWrap; + + Main.instance.GraphicsDevice.Textures[3] = erosionTexture; + Main.instance.GraphicsDevice.SamplerStates[3] = SamplerState.LinearWrap; + + // Fuchsia highlights. + windsShader.CurrentTechnique.Passes[0].Apply(); + Main.spriteBatch.Draw(windsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); + + windsShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 0.8f); + windsShader.Parameters["overallOpacity"].SetValue(0.7f); + windsShader.Parameters["distortionStrength"].SetValue(0.6f); + windsShader.Parameters["mainNoiseTextureScale"].SetValue(1.24f); + windsShader.Parameters["distortionTextureScale"].SetValue(0.46f); + windsShader.Parameters["erosionTextureScale"].SetValue(3f); + windsShader.Parameters["erosionMin"].SetValue(0.75f); + windsShader.Parameters["highlightsColor"].SetValue(new Color(0, 221, 250).ToVector3()); + + // Cyan highlights. + windsShader.CurrentTechnique.Passes[0].Apply(); + Main.spriteBatch.Draw(windsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); + } + + private void DrawDistortionClouds_Foreground() + { + Effect rollingCloudsShader = CalamityShaders.DoGBackgroundFogShader; + Texture2D cloudsTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/RealisticClouds").Value; + Texture2D erosionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise").Value; + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + rollingCloudsShader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 2f); + rollingCloudsShader.Parameters["overallOpacity"].SetValue(1f); + rollingCloudsShader.Parameters["distortionStrength"].SetValue(0.12f); + rollingCloudsShader.Parameters["mainNoiseTextureScale"].SetValue(1f); + rollingCloudsShader.Parameters["distortionTextureScale"].SetValue(0.8f); + rollingCloudsShader.Parameters["erosionTextureScale"].SetValue(0.26f); + rollingCloudsShader.Parameters["erosionMin"].SetValue(0.06f); + rollingCloudsShader.Parameters["gradientPrecision"].SetValue(20f); + + rollingCloudsShader.Parameters["pixelationFactor"].SetValue(screenSize * 0.5f); + rollingCloudsShader.Parameters["worldOffset"].SetValue(Main.screenPosition / cloudsTexture.Size() * 0.025f); + + rollingCloudsShader.Parameters["darkerPixelColor"].SetValue(Color.Lerp(Color.Black, new(0, 221, 250), 0.25f).ToVector3()); + rollingCloudsShader.Parameters["brighterPixelColor"].SetValue(Color.Lerp(Color.Black, Color.Fuchsia, 0.25f).ToVector3()); + + Main.instance.GraphicsDevice.Textures[1] = cloudsTexture; + Main.instance.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + Main.instance.GraphicsDevice.Textures[2] = erosionTexture; + Main.instance.GraphicsDevice.SamplerStates[2] = SamplerState.LinearWrap; + + rollingCloudsShader.CurrentTechnique.Passes[0].Apply(); + Main.spriteBatch.Draw(cloudsTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White); + } + #endregion + } +} diff --git a/Systems/Graphic/SkyEffectLoaderSystem.cs b/Systems/Graphic/SkyEffectLoaderSystem.cs index 8e8588063f..ccd19af7ed 100644 --- a/Systems/Graphic/SkyEffectLoaderSystem.cs +++ b/Systems/Graphic/SkyEffectLoaderSystem.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Systems { public override void Load() { - Filters.Scene["CalamityMod:DevourerofGodsHead"] = new Filter(new DoGScreenShaderData("FilterMiniTower").UseColor(0.4f, 0.1f, 1.0f).UseOpacity(0.5f), EffectPriority.VeryHigh); + Filters.Scene["CalamityMod:DevourerofGodsHead"] = new Filter(new DoGScreenShaderData("FilterMiniTower").UseOpacity(0.025f), EffectPriority.VeryHigh); SkyManager.Instance["CalamityMod:DevourerofGodsHead"] = new DoGSky(); Filters.Scene["CalamityMod:CalamitasRun3"] = new Filter(new CalScreenShaderData("FilterMiniTower").UseColor(1.1f, 0.3f, 0.3f).UseOpacity(0.6f), EffectPriority.VeryHigh); diff --git a/Utilities/NPCDebuffs.cs b/Utilities/NPCDebuffs.cs index ec5d8be588..ad67fc4a9b 100644 --- a/Utilities/NPCDebuffs.cs +++ b/Utilities/NPCDebuffs.cs @@ -278,12 +278,8 @@ namespace CalamityMod { ModContent.NPCType(), sulphur }, { ModContent.NPCType(), sulphur }, - { ModContent.NPCType(), immuneToEverything }, { ModContent.NPCType(), immuneToEverything }, { ModContent.NPCType(), immuneToEverything }, - { ModContent.NPCType(), immuneToEverything }, - { ModContent.NPCType(), immuneToEverything }, - { ModContent.NPCType(), immuneToEverything }, { ModContent.NPCType(), new(GeneralImmunityStatus.None, new int[] { BuffID.OnFire, ModContent.BuffType() }) }, diff --git a/Utilities/ProjectileUtils.cs b/Utilities/ProjectileUtils.cs index 20c28a596a..d085ac3e9e 100644 --- a/Utilities/ProjectileUtils.cs +++ b/Utilities/ProjectileUtils.cs @@ -211,7 +211,8 @@ namespace CalamityMod // Home in on the target. Vector2 homeDirection = (destination - projectile.Center).SafeNormalize(Vector2.UnitY); projectile.velocity = (projectile.velocity * inertia + homeDirection * homingVelocity) / (inertia + 1f); - } + projectile.Calamity().HomingTarget = index; + } else { // Set amount of extra updates to default amount.