From ea4d61068c0598b0043d732f48411eb99a475b98 Mon Sep 17 00:00:00 2001 From: Dominic Date: Tue, 23 Aug 2022 15:38:15 -0500 Subject: [PATCH 1/3] Start of SSV rework --- Effects/CalamityShaders.cs | 6 + Effects/ExoVortexShader.fx | 35 +++ Effects/ExoVortexShader.xnb | Bin 0 -> 2440 bytes Effects/SideStreakTrail.fx | 72 ++++++ Effects/SideStreakTrail.xnb | Bin 0 -> 3360 bytes Items/Weapons/Magic/SubsumingVortex.cs | 7 +- Projectiles/Magic/EnormousConsumingVortex.cs | 234 ++++++++---------- Projectiles/Magic/EnormousConsumingVortex.png | Bin 1313 -> 0 bytes Projectiles/Magic/ExoVortex.cs | 136 ++++++++++ Projectiles/Magic/SubsumingTentacle.cs | 159 ------------ Projectiles/Magic/SubsumingTentacle.png | Bin 2903 -> 0 bytes Projectiles/Magic/Vortex.cs | 163 ------------ Projectiles/Magic/Vortex.png | Bin 1412 -> 0 bytes Utilities/ProjectileUtils.cs | 1 + 14 files changed, 359 insertions(+), 454 deletions(-) create mode 100644 Effects/ExoVortexShader.fx create mode 100644 Effects/ExoVortexShader.xnb create mode 100644 Effects/SideStreakTrail.fx create mode 100644 Effects/SideStreakTrail.xnb delete mode 100644 Projectiles/Magic/EnormousConsumingVortex.png create mode 100644 Projectiles/Magic/ExoVortex.cs delete mode 100644 Projectiles/Magic/SubsumingTentacle.cs delete mode 100644 Projectiles/Magic/SubsumingTentacle.png delete mode 100644 Projectiles/Magic/Vortex.cs delete mode 100644 Projectiles/Magic/Vortex.png diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index afced4394c..dfc98e0074 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -38,6 +38,8 @@ namespace CalamityMod.Effects public static Effect ArtemisLaserShader; public static Effect ExobladeSlashShader; public static Effect ExobladePierceShader; + public static Effect ExoVortexShader; + public static Effect SideStreakTrailShader; public static Effect BaseFusableParticleEdgeShader; public static Effect AdditiveFusableParticleEdgeShader; @@ -79,6 +81,8 @@ namespace CalamityMod.Effects ArtemisLaserShader = CalamityMod.Instance.Assets.Request("Effects/ArtemisLaserShader", AssetRequestMode.ImmediateLoad).Value; ExobladeSlashShader = CalamityMod.Instance.Assets.Request("Effects/ExobladeSlashShader", AssetRequestMode.ImmediateLoad).Value; ExobladePierceShader = CalamityMod.Instance.Assets.Request("Effects/ExobladePierceShader", AssetRequestMode.ImmediateLoad).Value; + ExoVortexShader = CalamityMod.Instance.Assets.Request("Effects/ExoVortexShader", AssetRequestMode.ImmediateLoad).Value; + SideStreakTrailShader = CalamityMod.Instance.Assets.Request("Effects/SideStreakTrail", AssetRequestMode.ImmediateLoad).Value; BaseFusableParticleEdgeShader = CalamityMod.Instance.Assets.Request("Effects/ParticleFusion/BaseFusableParticleEdgeShader", AssetRequestMode.ImmediateLoad).Value; AdditiveFusableParticleEdgeShader = CalamityMod.Instance.Assets.Request("Effects/ParticleFusion/AdditiveFusableParticleEdgeShader", AssetRequestMode.ImmediateLoad).Value; @@ -117,6 +121,8 @@ namespace CalamityMod.Effects GameShaders.Misc["CalamityMod:ArtemisLaser"] = new MiscShaderData(new Ref(ArtemisLaserShader), "TrailPass"); GameShaders.Misc["CalamityMod:ExobladeSlash"] = new MiscShaderData(new Ref(ExobladeSlashShader), "TrailPass"); GameShaders.Misc["CalamityMod:ExobladePierce"] = new MiscShaderData(new Ref(ExobladePierceShader), "PiercePass"); + GameShaders.Misc["CalamityMod:ExoVortex"] = new MiscShaderData(new Ref(ExoVortexShader), "VortexPass"); + GameShaders.Misc["CalamityMod:SideStreakTrail"] = new MiscShaderData(new Ref(SideStreakTrailShader), "TrailPass"); GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"] = new MiscShaderData(new Ref(BaseFusableParticleEdgeShader), "ParticlePass"); GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"] = new MiscShaderData(new Ref(AdditiveFusableParticleEdgeShader), "ParticlePass"); diff --git a/Effects/ExoVortexShader.fx b/Effects/ExoVortexShader.fx new file mode 100644 index 0000000000..a56cd1b0c0 --- /dev/null +++ b/Effects/ExoVortexShader.fx @@ -0,0 +1,35 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +float4 uShaderSpecificData; + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Calculate the swirl coordinates. + float2 centeredCoords = coords - 0.5; + float swirlRotation = length(centeredCoords) * 17.2 - uTime * 6; + float swirlColorFade = 1 - saturate(length(centeredCoords) * 1.8); + float swirlSine = sin(swirlRotation); + float swirlCosine = sin(swirlRotation + 1.5707); + float2x2 swirlRotationMatrix = float2x2(swirlCosine, -swirlSine, swirlSine, swirlCosine); + float2 swirlCoordinates = mul(centeredCoords, swirlRotationMatrix) + 0.5; + return tex2D(uImage0, swirlCoordinates) * sampleColor * swirlColorFade; +} +technique Technique1 +{ + pass VortexPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/ExoVortexShader.xnb b/Effects/ExoVortexShader.xnb new file mode 100644 index 0000000000000000000000000000000000000000..2a3c3b1e0e3fe943a177bf01b003ac3b58ab4257 GIT binary patch literal 2440 zcmbVNO>7%g5T4yQ#U-wcpobnJbwMB%WLZu~kRuYD#%XATp&?F+1&3<8d9GJ=yk@;8R**keuL~zw750Yk zbJkJpcYV9vaGg%hx+wgP>$T>l@&*3nta8{4LSM|aL>TyXGiR-Ymz%Ehp4eXVu8P)N zaca`37cYy64KZDqo_>>9j6c#u_r{*wenGe zNO9(e-dH*0Oc19tumX*vY?_Il0|?7r)AMNhI#j^pEbKZT{_43t>~uvf4e8ty{>Uc;Gpny# z=PT8U6<+|W>}|H)rtqzq{N!8tnd!;=WN~VW22qVxR?k%pv$iydULDr-37-qwuqK17 z8f;t>kA&@96W1BP<9mBttzHvcPf4)#f9lJizUs1`NcGG%rK_E7gXl#nSC-e(44z3& z%^yV@L|Iy@Rmz;-pp~Aw4r=E(_NjMC?N1us_V+oqw2JzQZvr%um5?oVfq9J@(75d;K@wzOl12!}d|w z_xgQ)rG6vomavyj$B(LuH+T0?AK6dzT}o%UA6&5!a31fYkKV_!l@w#S3|jBu{}*T} z;C>gs=|dfS=;^LO{T}+pUs`gABJ6Z?ROUV@Z3acjSt-WX5h$@CW1_AJ|6vZs>+tt` zFC}MiPTh~9dn4eyhI36ak(2$8d!ty2hco|E9=vBy<>CHJGSJ^T7Mbiv-HC2+?&~}+ z=J32sES^_v<6Mkm8{*`gV-DS10LGn=97=QDF=jsEcH`Nxzn|nF6VFTX`A+=}FgISw literal 0 HcmV?d00001 diff --git a/Effects/SideStreakTrail.fx b/Effects/SideStreakTrail.fx new file mode 100644 index 0000000000..a4fcdc08e3 --- /dev/null +++ b/Effects/SideStreakTrail.fx @@ -0,0 +1,72 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +matrix uWorldViewProjection; +float4 uShaderSpecificData; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput)0; + float4 pos = mul(input.Position, uWorldViewProjection); + output.Position = pos; + + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + + return output; +} + +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float innerBrightnessIntensity = 2.7; + float4 color = input.Color; + float2 coords = input.TextureCoordinates; + float bloomOpacity = pow(cos(coords.y * 4.8 - 0.8), 55 + pow(coords.x, 4) * 700); + + // Create some noisy opaque blotches in the inner part of the trail. + if (coords.y > 0.15 && coords.y < 0.85) + { + float minOpacity = pow(1 - sin(coords.y * 3.141) + tex2D(uImage1, coords * 1.1 + float2(uTime * -0.6, 0)).r * 2.2, 0.2); + bloomOpacity += pow(coords.x, 0.3) * lerp(0.04, 0.4, minOpacity); + } + + // Make the front half of the trail have a strong bloom effect. + if (coords.x < 0.5) + bloomOpacity *= (1 - coords.x * 2) * innerBrightnessIntensity + 1; + + return color * lerp(0, 3.6, bloomOpacity * pow(coords.x, 0.1)) * pow(1 - coords.x, 1.1); +} + +technique Technique1 +{ + pass TrailPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/SideStreakTrail.xnb b/Effects/SideStreakTrail.xnb new file mode 100644 index 0000000000000000000000000000000000000000..a9983c063f295df0f6b2ec962c714c64b2d1d561 GIT binary patch literal 3360 zcmb_eO>7fK6rQym<3OmZ{zyfN)a?%vts*xGNo7T6 zfr`Ucy-6cPQ$Y6Vwxb zFBa`{W_>I>GF+)<&zM7V=IG$)=zc~`yU@qj@4FtZJk3?{qxA-xYjGj(#3O;;FVyHa z1<9LUFwUBTOkyUYQ6Y3OLyW>{=&pj1HpRqtK=E>R&30Jib5j94&WE^r1+!w;=M3kf za1QCS`-(5+r%tUG-8;5uR4n%*=@Q>30kElflnFTuRM>D)_6UD)8$8v-o3&km?#8ce zgHIB^Xf2p{$~k_gU}+5$6`E**m+d(fa~At2^1Z8oV}L3uOGEcQu$|i6jNP#KbfWq6 z5jbq*BmH(k_NFWcIcWM(o+$+{c}stKV)HXEZ=IcY3!Ef7xo3yOT~d6va^&;k`>SAm ziajQMI{(^7>^Xw>lXKXpj@18admaHq4Nq9+`5DLlNLHp>o4GA{Wi8d*&rzJhJe~T& zqFJ%3R%Oa?4PJNJ*IT*Ld}#f)+G)QP9mA^47>x#GTCbv6nXg+Pd*%>h6pQlrpc5_f ze*s;#eGm>x1zuPXYFknbq^1IQ_5 zt@|No6}=4ERrD*6Zz}q2$oCaJi%A!i^;ijIO8I>#6a1@iPCjgx(7z7#Yml!hxX{c3 zG)emw6*m?Ho54#gSA2W2AL=mz!bTX<(e$JE8AOj`MKqRVS+b&u`*a9v)5k|-+{MP} z;nRaG`cKgJ&Az4|%@^{z*f@I5URbnhrlTLo48NHSB;023 z49n%Giz(G<8+ku(f30paj96)Qq@2%De2vXC<#v%z@}n_%*5vacS{f|~7(0$5rLlDL z`ttI``dWVV^S@snhszY} zgcW`wHpOL#FXojXxszn*Gd??2M(LQ;?|A+7_`|^zA9RhU`=N)T? wI;EHJo=kPWO*KZxnIt{NbuH2pT#rS1itBOcyv{6*zxItKA;(); Item.shootSpeed = 7f; } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/Magic/SubsumingVortexGlow").Value); diff --git a/Projectiles/Magic/EnormousConsumingVortex.cs b/Projectiles/Magic/EnormousConsumingVortex.cs index 4571c906a3..95fea4a38a 100644 --- a/Projectiles/Magic/EnormousConsumingVortex.cs +++ b/Projectiles/Magic/EnormousConsumingVortex.cs @@ -6,11 +6,16 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using Terraria.Graphics.Shaders; +using CalamityMod.Particles; +using CalamityMod.Items.Weapons.Magic; namespace CalamityMod.Projectiles.Magic { public class EnormousConsumingVortex : ModProjectile { + public Player Owner => Main.player[Projectile.owner]; + public float Time { get => Projectile.ai[0]; @@ -23,12 +28,10 @@ namespace CalamityMod.Projectiles.Magic set => Projectile.ai[1] = value; } - public const int TentacleSpawnRate = 20; - public const int PulseInterval = 18; - public const float PulseHitboxExpandRatio = 2.5f; - public const float RadialOffsetVarianceFactor = 0.1f; public const float StartingScale = 0.0004f; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override void SetStaticDefaults() { DisplayName.SetDefault("Subsuming Vortex"); @@ -43,171 +46,140 @@ namespace CalamityMod.Projectiles.Magic Projectile.alpha = 255; Projectile.penetrate = -1; Projectile.scale = StartingScale; - Projectile.timeLeft = 540; + Projectile.timeLeft = 90000; Projectile.tileCollide = false; + Projectile.netImportant = true; Projectile.DamageType = DamageClass.Magic; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 8; + Projectile.localNPCHitCooldown = 7; } // Vanilla Terraria does not sync projectile scale by default. public override void SendExtraAI(BinaryWriter writer) => writer.Write(Projectile.scale); + public override void ReceiveExtraAI(BinaryReader reader) => Projectile.scale = reader.ReadSingle(); public override void AI() { - Projectile.rotation += MathHelper.ToRadians(8f); // Spin 2 win. - Projectile.alpha = (int)MathHelper.Lerp(255, 0, Utils.GetLerpValue(0f, 20f, Time, true)); // Fade in completely after 20 frames. - Projectile.scale = MathHelper.Lerp(StartingScale, IdealScale, Utils.GetLerpValue(0f, 30f, Time, true)); // Expand completely after 30 frames. + // If the player is no longer able to channel the vortex, kill it. + if (!Owner.channel || Owner.noItems || Owner.CCed) + { + Projectile.Kill(); + return; + } // Determine the ideal scale in the first frame. if (IdealScale == 0f) { - IdealScale = Main.rand.NextFloat(2.2f, 3f); + IdealScale = Main.rand.NextFloat(2.67f, 2.85f); Projectile.netUpdate = true; } - // Target enemy if possible and idly spawn tentacles. - if (Time < 150) + // Release energy from the book. + if (Time >= 56f) { - TargetingMovement(); - if (Time % TentacleSpawnRate == TentacleSpawnRate - 1 && Main.myPlayer == Projectile.owner) + Vector2 bookPosition = Owner.Center + Vector2.UnitX * Owner.direction * 22f; + if (Main.rand.NextBool(2)) { - ProduceSubsumingHentai(); + Vector2 energyVelocity = Main.rand.NextVector2Circular(3f, 3f); + Color energyColor = CalamityUtils.MulticolorLerp(Main.rand.NextFloat(), CalamityUtils.ExoPalette); + SquishyLightParticle exoEnergy = new(bookPosition, energyVelocity, 0.55f, energyColor, 40, 1f, 1.5f); + GeneralParticleHandler.SpawnParticle(exoEnergy); + } + + // Fire vortices at nearby target. + NPC potentialTarget = Projectile.Center.ClosestNPCAt(1250f); + if (potentialTarget != null && Time % SubsumingVortex.VortexReleaseRate == SubsumingVortex.VortexReleaseRate - 1) + { + // CheckMana returns true if the mana cost can be paid.. + bool allowContinuedUse = Owner.CheckMana(Owner.ActiveItem(), -1, true, false); + bool crystalStillInUse = Owner.channel && allowContinuedUse && !Owner.noItems && !Owner.CCed; + if (crystalStillInUse) + { + SoundEngine.PlaySound(SoundID.Item84, Projectile.Center); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float hue = (Time - 56f) / 125f; + Vector2 vortexVelocity = Projectile.SafeDirectionTo(potentialTarget.Center) * 8f; + Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center, vortexVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, hue); + } + Projectile.netUpdate = true; + } + else if (!crystalStillInUse) + Projectile.Kill(); } } - // Slow down and pulse frequently. - else if (Time < 220) + + // Create swirling exo energy. + if (Main.rand.NextBool(2)) { - Projectile.velocity *= 0.96f; - if (Time % PulseInterval == 0f) + float dustSpawnChance = Utils.Remap(Time, 12f, 64f, 0.25f, 0.7f); + for (int i = 0; i < 3; i++) { - PulseEffect(); + if (Main.rand.NextFloat() < dustSpawnChance) + { + float spawnOffsetAngle = Main.rand.NextFloat(MathHelper.TwoPi); + float hue = (float)Math.Sin(spawnOffsetAngle + Time / 26f) * 0.5f + 0.5f; + float spawnOffsetFactor = Main.rand.NextFloat(0.3f, 0.95f); + Vector2 energySpawnPosition = Projectile.Center + spawnOffsetAngle.ToRotationVector2() * Projectile.Size * spawnOffsetFactor; + Vector2 energyVelocity = (spawnOffsetAngle - MathHelper.PiOver2).ToRotationVector2() * (Main.rand.NextFloat(5f, 10f) * spawnOffsetFactor) * dustSpawnChance; + Color energyColor = CalamityUtils.MulticolorLerp(hue, CalamityUtils.ExoPalette); + SquishyLightParticle exoEnergy = new(energySpawnPosition, energyVelocity, Projectile.scale * Main.rand.NextFloat(0.18f, 0.3f), energyColor, 32, 1f, 1.5f); + GeneralParticleHandler.SpawnParticle(exoEnergy); + } } } - else if (Time >= 240) + + // Hover above the target. + if (Main.myPlayer == Projectile.owner) { - ExplodeEffect(); - Projectile.Kill(); + float verticalOffset = Utils.Remap(Time, 0f, 90f, -30f, (float)Math.Cos(Projectile.timeLeft / 32f) * 30f - 325f); + Vector2 hoverDestination = Owner.Top + Vector2.UnitY * verticalOffset; + hoverDestination += (Main.MouseWorld - hoverDestination) * 0.25f; + + Vector2 idealVelocity = Vector2.Zero.MoveTowards(hoverDestination - Projectile.Center, 32f); + Projectile.velocity = Vector2.Lerp(Projectile.velocity, idealVelocity, 0.04f); + Projectile.netSpam = 0; + Projectile.netUpdate = true; } - Projectile.ExpandHitboxBy((int)(Projectile.scale * 62)); + + // Re-determine the hitbox size. + Projectile.Opacity = Utils.GetLerpValue(0f, 20f, Time, true); + Projectile.scale = Utils.Remap(Time, 0f, 45f, StartingScale, IdealScale); + Projectile.ExpandHitboxBy((int)(Projectile.scale * 62f)); + + AdjustPlayerValues(); + Time++; } - public void ProduceSubsumingHentai() + public void AdjustPlayerValues() { - int tentacleDamage = (int)(Projectile.damage * 0.25f); - float xStartingAcceleration = Main.rand.NextFloat(0.001f, 0.04f) * Main.rand.NextBool(2).ToDirectionInt(); - float yStartingAcceleration = Main.rand.NextFloat(0.001f, 0.04f) * Main.rand.NextBool(2).ToDirectionInt(); - Projectile subsumingHentai = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), - Projectile.Center, - Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(9f, 13f), - ModContent.ProjectileType(), - tentacleDamage, - Projectile.knockBack * 0.5f, - Projectile.owner, - xStartingAcceleration, - yStartingAcceleration - ); - - subsumingHentai.tileCollide = false; - } - - public void TargetingMovement() - { - NPC potentialTarget = Projectile.Center.ClosestNPCAt(600f, true, true); - if (potentialTarget != null) - Projectile.velocity = (Projectile.velocity * 5f + Projectile.SafeDirectionTo(potentialTarget.Center) * 7f) / 6f; - } - - public void PulseEffect() - { - Projectile.ExpandHitboxBy(PulseHitboxExpandRatio); - Projectile.Damage(); - if (!Main.dedServ) - { - SoundEngine.PlaySound(SoundID.Item43, Projectile.Center); - for (int i = 0; (float)i < 85; i++) - { - float angle = i / 85f * MathHelper.TwoPi; - Vector2 spawnPosition = Projectile.Center + angle.ToRotationVector2() * (500f + Main.rand.NextFloat(-8f, 8f)); - Vector2 velocity = (angle - (float)Math.PI).ToRotationVector2() * Main.rand.NextFloat(27f, 38.5f); - Dust dust = Dust.NewDustPerfect(spawnPosition, 264, velocity); - dust.scale = 0.9f; - dust.fadeIn = 1.25f; - dust.color = Main.hslToRgb(i / 85f, 1f, 0.8f); - dust.noGravity = true; - } - } - Projectile.ExpandHitboxBy(1f / PulseHitboxExpandRatio); - } - - public void ExplodeEffect() - { - SoundEngine.PlaySound(SoundID.Zombie104, Projectile.Center); - if (!Main.dedServ) - { - for (int i = 0; i < 200; i++) - { - Vector2 velocity = Main.rand.NextVector2Circular(50f, 50f); - Dust dust = Dust.NewDustPerfect(Projectile.Center, 264, velocity); - dust.color = Main.hslToRgb(i / 100f % 1f, 1f, 0.8f); - dust.fadeIn = 1.25f; - dust.noGravity = true; - } - } - if (Main.myPlayer == Projectile.owner) - { - int vortexDamage = (int)(Projectile.damage * 0.75f); - NPC closestTarget = Projectile.Center.ClosestNPCAt(1600f, true, true); - - for (int i = 0; i < 12; i++) - { - float rotation = Main.rand.NextFloat(MathHelper.TwoPi); - Vector2 velocity = Vector2.UnitY.RotatedBy(rotation); - if (closestTarget != null) - velocity = Projectile.SafeDirectionTo(closestTarget.Center, -Vector2.UnitY).RotatedByRandom(0.4f); - - velocity *= Main.rand.NextFloat(3f, 5f); - - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, - velocity, - ModContent.ProjectileType(), - vortexDamage, - Projectile.knockBack, - Projectile.owner, - 0f, - Main.rand.NextFloat(0.5f, 1.8f)); - } - } + Projectile.spriteDirection = Projectile.direction = Owner.direction; + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; } public override bool PreDraw(ref Color lightColor) { - int vortexesToDraw = 27; - for (int i = 0; i < vortexesToDraw; i++) + Main.spriteBatch.EnterShaderRegion(BlendState.Additive); + Texture2D worleyNoise = ModContent.Request("CalamityMod/ExtraTextures/BlobbyNoise").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Vector2 scale = Projectile.Size / worleyNoise.Size() * 2f; + float spinRotation = Main.GlobalTimeWrappedHourly * 2.4f; + + GameShaders.Misc["CalamityMod:ExoVortex"].Apply(); + + // Draw the vortex. + for (int i = 0; i < CalamityUtils.ExoPalette.Length; i++) { - float rotation = MathHelper.TwoPi / i * vortexesToDraw + Projectile.rotation; - float drawScale = Projectile.scale * 0.66f; - - drawScale *= (float)(Math.Cos(Time / 18f + rotation * 2f) + 1f) * 0.3f + 0.7f; // Range of 0.7 to 1. Used to give variance with the scale. - float offsetFactor = (float)(Math.Sin(Time / 18f + rotation * 2f) + 1f) * 0.2f + 0.8f; // Range of 0.8 to 1. - - // Due to the way RotatedBy works, the offset can be negative, giving the projectile a - // dual buzzsaw look. - Vector2 drawOffset = Vector2.UnitX.RotatedBy(rotation) * 30f * offsetFactor * drawScale; - Vector2 drawPosition = Projectile.Center + drawOffset - Main.screenPosition; - Color colorToDraw = Main.hslToRgb((i / (float)vortexesToDraw + Time / 40f) % 1f, 1f, 0.75f); - Main.EntitySpriteDraw(ModContent.Request(Texture).Value, - drawPosition, - null, - colorToDraw * 0.7f, - rotation, - ModContent.Request(Texture).Size() * 0.5f, - drawScale, - SpriteEffects.None, - 0); + float spinDirection = (i % 2f == 0f).ToDirectionInt(); + Vector2 drawOffset = (MathHelper.TwoPi * i / CalamityUtils.ExoPalette.Length + Main.GlobalTimeWrappedHourly * spinDirection * 4f).ToRotationVector2() * Projectile.scale * 15f; + Main.spriteBatch.Draw(worleyNoise, drawPosition + drawOffset, null, CalamityUtils.ExoPalette[i], spinDirection * spinRotation, worleyNoise.Size() * 0.5f, scale, 0, 0f); } + + Main.spriteBatch.ExitShaderRegion(); return false; } } diff --git a/Projectiles/Magic/EnormousConsumingVortex.png b/Projectiles/Magic/EnormousConsumingVortex.png deleted file mode 100644 index 0e1de2dd8f5d5f4288a680ea922eefdf964e5b0f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1313 zcmV++1>X9JP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1hz>;K~!i%?VDX_ z990;GC)sS1P-#{)rY(v}p<;94MYPfdz4FFZ(JCcWwqPWnO>erQ7kVK@MG!Pmgep>q znAlMKsXrK@dLg0_Dl7PJLxWUoFqWE0u!WLr<9zR&Z{7KrvvX#5)&}N0Fn!O=HtFs> z=R4=@%(TUc$>QXV$mwgYLo%DLK0KkCU#N`B?exd7#piZYmb?C;sPI7URny`mf0v-yKY4TD@Rw^lWQ>$>Mu6TI2-22^)D)7VeSyfq#L8!vC0YRI%S90m7) zq|IC7QLypS<}Jwc9i7P8%ly&(uRpqwoyRg`Xb6hM;&-Z97drD2)1F|B>p1N0MV@lD zA(=;3?)G0$MAh!d$jD8UNtvH$IS948SBCID;*J5ks@;BMQJl*IhT`xN0Lklx7{``CW*e~z= z48=Y=I=W0bn0*`Ot#PKtw=f24^h-Uu>x@6K@Hvb>{Nt0@&-G3Q-hXC%JHGE*^`C9ky@#|B^`!S#Aw;l-?=UPv%@n&6F@xV1SCdwoudxq)H zF>Ks3o2MKY7-*xESmTXeS*Zf1rKv)pfYDS(UtizPlya2j9$;Ggj5V&I^=x^)LtC>T z(^0mGQmM3sHkzM#j&3IDt?}XEVXVEqTA0F-`U%vww9GXuA`0w%Y@$qqtJ-S-2 zQQQ1^0<#N~UgPug^GzAeb;gUuhYFO1!oF`Qb;wcPz&M-LeU5sdR;vNq%ZAzd=SmRX$%+kE5 z=Ehhx6ji&@XuY)_7w@wy)0SG})$@1&IxCcNMHf}qUi}5;Ted28Irc$_(#s4@j)56~fh&La`ibJO?0^v1Ji zC{k>^>ic-$+SJtXew?BF)+06Vi|cAy5@IqGgWqGiY6~^JZu>9D^cr7$#ecS?TnOG{ za)0vgF|E1v7VK|qdpU5QTzBv4|E8)3R92gW&NO3<^OFNy>zSi>;EZ()+(zMKosm^# zT&@Ur-TW!;dtbh00s9yKo<~a4Op1-~zteB^_@#2F{a*i>5%uIi_Wo-roQ@3>tFp!= zJbUm8%^DZ{cYmDC3)+S<$P3+L81;Fcb-&tyCl8$7w*tp66>K{D+fJCi_~#sjH7?OU z^~CVq)YkPq$ffI#!f^J)4xHJg8$M3NxapW7SAgwj_TYUm%O_`$I@63b9tE41$exgt zdC7ylANsRQr~ki`R%Vxw&Uy6}#(=oyW$l{6*9``L_g8M#cmxd_ zXLRNn*#qh|%v4N^r;@Gl2of{S$kD&m*?@fg*SkWm^q5jHtiD53n8_hbO*1Jq?l}Jf X`le^I_;cv<00000NkvXXu0mjf7PhWi diff --git a/Projectiles/Magic/ExoVortex.cs b/Projectiles/Magic/ExoVortex.cs new file mode 100644 index 0000000000..ec82d94322 --- /dev/null +++ b/Projectiles/Magic/ExoVortex.cs @@ -0,0 +1,136 @@ +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class ExoVortex : ModProjectile + { + public float Hue => Projectile.ai[0]; + + public ref float Time => ref Projectile.ai[1]; + + public const float AngularMovementSpeed = 0.1f; + + public const float Acceleration = 0.0025f; + + public PrimitiveTrail EnergyTrail = null; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Subsuming Vortex"); + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 35; + } + + public override void SetDefaults() + { + Projectile.width = 60; + Projectile.height = 60; + Projectile.alpha = 255; + Projectile.scale = 0.01f; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.MaxUpdates = 4; + Projectile.timeLeft = Projectile.MaxUpdates * 120; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = Projectile.MaxUpdates * 18; + Projectile.ignoreWater = true; + Projectile.hide = true; + } + + public override void AI() + { + Time++; + MoveTowardsTarget(); + + // Rotate. + Projectile.rotation += Projectile.velocity.X * 0.04f; + + // Re-determine the hitbox size. + Projectile.Opacity = Utils.GetLerpValue(0f, 20f, Time, true); + Projectile.scale = Utils.Remap(Time, 0f, Projectile.MaxUpdates * 15f, 0.01f, 1.5f) * Utils.GetLerpValue(0f, Projectile.MaxUpdates * 16f, Projectile.timeLeft, true); + Projectile.ExpandHitboxBy((int)(Projectile.scale * 62f)); + } + + public void MoveTowardsTarget() + { + NPC potentialTarget = Projectile.Center.ClosestNPCAt(1400f); + if (potentialTarget is null) + return; + + Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(potentialTarget.Center) * 10f, 0.02f); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.ExoDebuffs(); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + target.ExoDebuffs(); + } + + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + behindProjectiles.Add(index); + } + + public Color PrimitiveTrailColor(float completionRatio) + { + float hue = Hue % 1f + 0.2f; + if (hue >= 0.99f) + hue = 0.99f; + + Color c = CalamityUtils.MulticolorLerp(hue, CalamityUtils.ExoPalette) * Projectile.Opacity * (1f - completionRatio); + return c * Utils.GetLerpValue(2f, 5f, Projectile.velocity.Length(), true) * Utils.GetLerpValue(0.04f, 0.2f, completionRatio, true); + } + + public override bool PreDraw(ref Color lightColor) + { + Main.spriteBatch.EnterShaderRegion(BlendState.Additive); + Texture2D worleyNoise = ModContent.Request("CalamityMod/ExtraTextures/BlobbyNoise").Value; + float spinRotation = Main.GlobalTimeWrappedHourly * 5.2f; + + Main.spriteBatch.EnterShaderRegion(); + + // Draw the streak trail. + EnergyTrail ??= new(completioRatio => + { + float width = Projectile.width * 0.6f; + width *= MathHelper.SmoothStep(0.6f, 1f, Utils.GetLerpValue(0f, 0.3f, completioRatio, true)); + return width; + }, PrimitiveTrailColor, null, GameShaders.Misc["CalamityMod:SideStreakTrail"]); + + GameShaders.Misc["CalamityMod:SideStreakTrail"].UseImage1("Images/Misc/Perlin"); + EnergyTrail.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition + Projectile.velocity.SafeNormalize(Vector2.Zero) * Projectile.scale * 2f, 51); + + Main.spriteBatch.EnterShaderRegion(BlendState.Additive); + GameShaders.Misc["CalamityMod:ExoVortex"].Apply(); + + // Draw the vortex. + for (int i = 0; i < 5; i++) + { + float hue = Hue % 1f + i / 4f * 0.2f; + Vector2 scale = MathHelper.Lerp(1f, 0.6f, i / 4f) * Projectile.Size / worleyNoise.Size() * 2f; + Vector2 drawOffset = Vector2.UnitY * Projectile.scale * 6f; + Color c = CalamityUtils.MulticolorLerp(hue, CalamityUtils.ExoPalette) * Projectile.Opacity; + Vector2 drawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; + Main.spriteBatch.Draw(worleyNoise, drawPosition - drawOffset, null, c, -spinRotation, worleyNoise.Size() * 0.5f, scale, 0, 0f); + Main.spriteBatch.Draw(worleyNoise, drawPosition + drawOffset, null, c, spinRotation, worleyNoise.Size() * 0.5f, scale, 0, 0f); + } + + Main.spriteBatch.ExitShaderRegion(); + return false; + } + } +} diff --git a/Projectiles/Magic/SubsumingTentacle.cs b/Projectiles/Magic/SubsumingTentacle.cs deleted file mode 100644 index 839a710f94..0000000000 --- a/Projectiles/Magic/SubsumingTentacle.cs +++ /dev/null @@ -1,159 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class SubsumingTentacle : ModProjectile - { - public int AlphaFade - { - get => (int)Projectile.localAI[0]; - set => Projectile.localAI[0] = value; - } - public Vector2 OffsetAcceleration - { - get => new Vector2(Projectile.ai[0], Projectile.ai[1]); - set - { - Projectile.ai[0] = value.X; - Projectile.ai[1] = value.Y; - } - } - public const float SegmentOffset = 5f; - public const float MaxArcingSpeed = 16f; - public const float MaxHomingSpeed = 18f; - public const float MaxEnemyDistance = 1450f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Exo Tentacle"); - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 75; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 20; - Projectile.friendly = true; - Projectile.penetrate = 2; - Projectile.MaxUpdates = 2; - Projectile.DamageType = DamageClass.Magic; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 16; - } - - public override void AI() - { - if (!Projectile.tileCollide) - { - AlphaFade++; - Projectile.alpha = AlphaFade; - if (Projectile.alpha >= 255) - { - Projectile.Kill(); - return; - } - } - // Here, the old positions act more like "control points" than old postions, and will be referred as such henceforth. - // Each control point should have a set offset, to give a "chain" effect. - for (int i = 1; i < Projectile.oldPos.Length; i++) - { - Projectile.oldPos[i] = Projectile.oldPos[i - 1] + Vector2.Normalize(Projectile.oldPos[i] - Projectile.oldPos[i - 1]) * SegmentOffset; - } - Projectile.ExpandHitboxBy((int)(20f * Projectile.scale)); - if (Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height) && Projectile.tileCollide) - { - Projectile.tileCollide = false; - } - - NPC closestTarget = Projectile.Center.ClosestNPCAt(MaxEnemyDistance, true, true); - if (closestTarget != null) - { - HomingMovement(closestTarget); - } - else - { - ArcingMovement(); - } - Projectile.scale -= closestTarget is null ? 0.007f : 0.004f; - if (Projectile.scale <= 0.05f) - { - Projectile.Kill(); - } - } - public void ArcingMovement() - { - // Cause the tentacle to arc around at an increasingly fast rate. - Projectile.velocity += OffsetAcceleration; - if (Projectile.velocity.Length() > MaxArcingSpeed) - { - Projectile.velocity.Normalize(); - Projectile.velocity *= MaxArcingSpeed; - } - - // Accelerate the arc. - OffsetAcceleration *= 1.035f; - } - public void HomingMovement(NPC closestTarget) - { - float angleOffset = MathHelper.WrapAngle(Projectile.AngleTo(closestTarget.Center) - Projectile.velocity.ToRotation()); - angleOffset = MathHelper.Clamp(angleOffset, -0.2f, 0.2f); - - if (Projectile.Distance(closestTarget.Center) > 65f) - { - Projectile.velocity = Projectile.velocity.RotatedBy(angleOffset); - Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * MaxHomingSpeed; - } - } - public override bool PreDraw(ref Color lightColor) - { - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - - if (Projectile.scale < 1f) - { - for (int i = 10; i < Projectile.oldPos.Length; i++) - { - var tentacleShader = GameShaders.Misc["CalamityMod:SubsumingTentacle"]; - tentacleShader.UseImage1("Images/Misc/Perlin"); - - Vector2 drawPos = Projectile.oldPos[i] + ModContent.Request(Texture).Size() / 2f - Main.screenPosition + Projectile.gfxOffY * Vector2.UnitY; - float scale = MathHelper.Lerp(0.05f, 1.3f, i / (float)Projectile.oldPos.Length) * Projectile.scale; - scale = MathHelper.Clamp(scale, 0f, 2f); - Color color = Projectile.GetAlpha(lightColor) * ((Projectile.oldPos.Length - i) / Projectile.oldPos.Length); - - Main.EntitySpriteDraw(ModContent.Request(Texture).Value, drawPos, null, color, Projectile.rotation, ModContent.Request(Texture).Size() / 2f, scale, SpriteEffects.None, 0); - tentacleShader.UseSaturation(i / (float)Projectile.oldPos.Length); // A "completion ratio" for the shader. Used to make the entire tentacle appear multi-colored. - tentacleShader.UseOpacity(1f / Projectile.oldPos.Length); // A "step value" for the shader. Used to give variance in color at each individual segment. - tentacleShader.Apply(null); - } - } - return false; - } - public override void PostDraw(Color drawColor) - { - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - } - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - for (int i = 1; i < Projectile.oldPos.Length; i++) - { - float scale = MathHelper.Lerp(0.05f, 1f, i / (float)Projectile.oldPos.Length) * Projectile.scale * 0.85f; - if (targetHitbox.Intersects(new Rectangle((int)Projectile.oldPos[i].X, (int)Projectile.oldPos[i].Y, (int)(Projectile.width * scale), (int)(Projectile.height * scale)))) - return true; - } - return false; - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Projectile.velocity = oldVelocity; - return false; - } - } -} diff --git a/Projectiles/Magic/SubsumingTentacle.png b/Projectiles/Magic/SubsumingTentacle.png deleted file mode 100644 index c6b3592c9f186c85d600075344c5971cf65960c4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2903 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 Bt@Ho@ diff --git a/Projectiles/Magic/Vortex.cs b/Projectiles/Magic/Vortex.cs deleted file mode 100644 index b8ae55ba76..0000000000 --- a/Projectiles/Magic/Vortex.cs +++ /dev/null @@ -1,163 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class Vortex : ModProjectile - { - public float TargetCheckCooldown - { - get => Projectile.localAI[0]; - set => Projectile.localAI[0] = value; - } - public float Time - { - get => Projectile.localAI[1]; - set => Projectile.localAI[1] = value; - } - public int TargetIndex - { - get => (int)Projectile.ai[0]; - set => Projectile.ai[0] = value; - } - - public const float AngularMovementSpeed = 0.1f; - public const float Acceleration = 0.0025f; - public const float TargetCheckInterval = 30f; - public const float MaximumTargetDistance = 600f; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Subsuming Vortex"); - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 20; - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 60; - Projectile.height = 60; - Projectile.alpha = 255; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Magic; - Projectile.penetrate = 1; - Projectile.tileCollide = true; - Projectile.extraUpdates = 4; - Projectile.timeLeft = 115 * Projectile.extraUpdates; - Projectile.ignoreWater = true; - } - - public override void AI() - { - // At the very beginning, start without a target. - if (Time == 0f) - { - TargetIndex = -1; - } - Time++; - if (Projectile.localAI[1] > 10f && Main.rand.NextBool(3)) - { - VisualEffects(); - } - Movement(HandleTargeting()); - Projectile.rotation += Projectile.velocity.X * 0.1f; - } - - public bool HandleTargeting() - { - float targetCheckDistance = 350f * Projectile.ai[1]; - - // Reduce a cooldown. Nothing special here. - if (TargetCheckCooldown > 0f) - { - TargetCheckCooldown--; - } - - // Attempt to find a target if the projectile has none. - if (TargetIndex == -1 && TargetCheckCooldown <= 0f) - { - NPC potentialTarget = Projectile.Center.ClosestNPCAt(targetCheckDistance, true, true); - if (potentialTarget != null) - TargetIndex = potentialTarget.whoAmI; - Projectile.netUpdate = true; - } - if (TargetCheckCooldown <= 0f && TargetIndex == -1) - { - TargetCheckCooldown = TargetCheckInterval; - } - bool stillCanReachTarget = false; - // Ensure that the target is still in reach if there is indeed a target. - if (TargetIndex != -1) - { - stillCanReachTarget = Projectile.Distance(Main.npc[TargetIndex].Center) < MaximumTargetDistance; - if (!stillCanReachTarget) - { - TargetIndex = -1; - Projectile.netUpdate = true; - } - } - return stillCanReachTarget; - } - - public void VisualEffects() - { - // Generate idle circular dust and light after 10 frames. - if (!Main.dedServ) - { - int dustCount = 5; - for (int i = 0; i < dustCount; i++) - { - Vector2 spawnPosition = Projectile.Center + Projectile.Size.RotatedBy(i / (float)dustCount * MathHelper.TwoPi) * 0.333f; - Vector2 velocity = Main.rand.NextFloat(MathHelper.TwoPi).ToRotationVector2() * Main.rand.NextFloat(6f, 16f); - Dust dust = Dust.NewDustPerfect(spawnPosition, 66, velocity, 0, Main.DiscoColor, 0.7f); - dust.noGravity = true; - dust.noLight = true; - dust.velocity = -Projectile.velocity; - } - } - // Fade in. - Projectile.alpha -= 5; - if (Projectile.alpha < 50) - { - Projectile.alpha = 50; - } - // And make rainbow light. - Lighting.AddLight(Projectile.Center / 16, Main.DiscoColor.ToVector3()); - } - - public void Movement(bool stillCanReachTarget) - { - // Homing sharply towards the target in a circular fashion. - // The way this type of homing is by determining the offset between the angle to the target and the velocity's angle. - // This offset can be thought of as how much, in radians, the velocity would need to rotate to move towards the target. - // Then, the velocity is rotated by that offset (which, as established, would give perfect homing) multiplied by a <1 factor. - // This causes the velocity to constantly rotate sharply towards the target. - if (stillCanReachTarget) - { - float angleOffsetToTarget = Projectile.AngleTo(Main.npc[TargetIndex].Center) - Projectile.velocity.ToRotation(); - angleOffsetToTarget = MathHelper.WrapAngle(angleOffsetToTarget); // Ensure the offset is in the range of -pi to pi. - Projectile.velocity = Projectile.velocity.RotatedBy(angleOffsetToTarget * AngularMovementSpeed); - } - // Accelerate constantly with time. - float oldSpeed = Projectile.velocity.Length(); - Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * (oldSpeed + Acceleration); - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.ExoDebuffs(); - } - - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.ExoDebuffs(); - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); - return false; - } - } -} diff --git a/Projectiles/Magic/Vortex.png b/Projectiles/Magic/Vortex.png deleted file mode 100644 index fd7e0bf39c75fbc901636a91f95b93df7921025e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1412 zcmV-~1$+95P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!T z-^}dIQ6ZW5Y85iu(TOD8LxVSU_O0E3dRR6eJB;kVdo%W_l==g8vNgTW-Kq@+E3#;P(*j;L4NEyFss$K5iFsc!6Ji^`&2EAz2&KWN;cD$~-iA8Y}&HXj@J zgT{|{uSQNa%|qrFn9=>pa0=PCbp$OU-SZ^sr1QNM?$+$EnU@4@39)e-pB8(OzpICl zWSRN_W{F?l9o+dV(q?{d>LcWi@t2S`XuhbHVBgbf82b@+42X?OdW#p3x2yBWRjLnX zHteVz6dETs^E7^Tcn$Wwuw*0li?2H^6R&UIbpUlq^9TLN*tmqo9Xx%xUP$A_X8z=( zrVro$y%~du(?W4fJNLhhy2_=^{c4=KmC@wWw=yqL>}0F1!s`+bhY!d zB&hicvjmQ5_ZQEhqS~g6@k8#_WLFXI$Hs~6DvWTAeyc`z64ZD~4dIx!{rm>%nTeuz zjLM~BZNC<<``FX&R%MztdDr-o&&K~m+P;tTdFsa;j%{6O$ZOo~>(Mn{uRANe zherHNlI#6nyIThNxu9$L*Ltra&pv+&DT$3c)YP;zwdbC^yEQWhlO4!`pGru=7Qnyf zw}vNsKQY7CH+Ox9ltk8eqEKp6y3`A8+RwITOKAvY{e4N4dK2M3{_-Z%w|9A;jD$t@ zZE1N!X2jj{a=74aZS3opuYHTmUNmD4`}*r^zeEyS-`??pnZD)hLLxn?*K{=y_U~ zk0-Jyw!W^{=6+XXq0rakPKm7X>3Ll8_%9ogTmcbVzor%5Y2kd!``?5sG8@~PyO9@< zzJui73)9+Wg00xOE{XO%x4Iv=e$t@}`*iu-t&28XUbJc2t_PXq2uj??C9C(}i+p$A zBBbA(Ek|B?S5>aDZOG5ns&D5rE$G{e3uCB9*tmN=uAUe~kR!a|}+)MA}S~*tj2M&(S@|mf&aJ51J=uPMFzd z<(moY>)d(fzmsm}|3<2*29u}mK=8M!e#FLSi){=DYhL! projectile.ExpandHitboxBy(newSize, newSize); + public static void ExpandHitboxBy(this Projectile projectile, Vector2 newSize) => projectile.ExpandHitboxBy((int)newSize.X, (int)newSize.Y); public static void ExpandHitboxBy(this Projectile projectile, float expandRatio) => projectile.ExpandHitboxBy((int)(projectile.width * expandRatio), (int)(projectile.height * expandRatio)); public static void HomeInOnNPC(Projectile projectile, bool ignoreTiles, float distanceRequired, float homingVelocity, float N) From 68ee6046d1ec6892f956c72d50e00a1b2de9024a Mon Sep 17 00:00:00 2001 From: Dominic Date: Tue, 23 Aug 2022 15:48:34 -0500 Subject: [PATCH 2/3] Damage tweak --- Items/Weapons/Magic/SubsumingVortex.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items/Weapons/Magic/SubsumingVortex.cs b/Items/Weapons/Magic/SubsumingVortex.cs index b4362dcbcb..67caeaa483 100644 --- a/Items/Weapons/Magic/SubsumingVortex.cs +++ b/Items/Weapons/Magic/SubsumingVortex.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - Item.damage = 354; + Item.damage = 397; Item.DamageType = DamageClass.Magic; Item.mana = 78; Item.width = 38; From 5d5985a5865e4e9242f35971d93621218c074078 Mon Sep 17 00:00:00 2001 From: Dominic Date: Wed, 24 Aug 2022 18:39:55 -0500 Subject: [PATCH 3/3] Proper tooltip + code cleaning --- Items/Weapons/Magic/SubsumingVortex.cs | 13 +++-- Projectiles/Magic/EnormousConsumingVortex.cs | 42 ++++++---------- Projectiles/Magic/ExoVortex.cs | 53 ++++++++++---------- 3 files changed, 50 insertions(+), 58 deletions(-) diff --git a/Items/Weapons/Magic/SubsumingVortex.cs b/Items/Weapons/Magic/SubsumingVortex.cs index 67caeaa483..aee5ff1ff9 100644 --- a/Items/Weapons/Magic/SubsumingVortex.cs +++ b/Items/Weapons/Magic/SubsumingVortex.cs @@ -14,12 +14,17 @@ namespace CalamityMod.Items.Weapons.Magic { public const int VortexReleaseRate = 32; + public const int VortexShootDelay = 56; + + public const float SmallVortexTargetRange = 1300f; + + public const float GiantVortexMouseDriftFactor = 0.35f; + public override void SetStaticDefaults() { DisplayName.SetDefault("Subsuming Vortex"); - Tooltip.SetDefault("Releases a gigantic, slow-moving vortex\n" + - "The vortex releases exo tentacles that thrash at nearby enemies\n" + - "After a few seconds the vortex slows down, becomes unstable, and explodes"); + Tooltip.SetDefault("Casts a gigantic vortex above your head with a bias towards the mouse\n" + + "When enemies are near the vortex, it sends multiple fast-moving smaller vortices towards them"); SacrificeTotal = 1; } @@ -27,7 +32,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.damage = 397; Item.DamageType = DamageClass.Magic; - Item.mana = 78; + Item.mana = 12; Item.width = 38; Item.height = 48; Item.UseSound = SoundID.Item84; diff --git a/Projectiles/Magic/EnormousConsumingVortex.cs b/Projectiles/Magic/EnormousConsumingVortex.cs index 95fea4a38a..5d1fcc9ee6 100644 --- a/Projectiles/Magic/EnormousConsumingVortex.cs +++ b/Projectiles/Magic/EnormousConsumingVortex.cs @@ -22,21 +22,13 @@ namespace CalamityMod.Projectiles.Magic set => Projectile.ai[0] = value; } - public float IdealScale - { - get => Projectile.ai[1]; - set => Projectile.ai[1] = value; - } - public const float StartingScale = 0.0004f; + public const float IdealScale = 2.7f; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Subsuming Vortex"); - ProjectileID.Sets.NeedsUUID[Projectile.type] = true; - } + public override void SetStaticDefaults() => DisplayName.SetDefault("Subsuming Vortex"); public override void SetDefaults() { @@ -68,18 +60,11 @@ namespace CalamityMod.Projectiles.Magic return; } - // Determine the ideal scale in the first frame. - if (IdealScale == 0f) - { - IdealScale = Main.rand.NextFloat(2.67f, 2.85f); - Projectile.netUpdate = true; - } - // Release energy from the book. - if (Time >= 56f) + if (Time >= SubsumingVortex.VortexShootDelay) { Vector2 bookPosition = Owner.Center + Vector2.UnitX * Owner.direction * 22f; - if (Main.rand.NextBool(2)) + if (Main.rand.NextBool()) { Vector2 energyVelocity = Main.rand.NextVector2Circular(3f, 3f); Color energyColor = CalamityUtils.MulticolorLerp(Main.rand.NextFloat(), CalamityUtils.ExoPalette); @@ -88,32 +73,32 @@ namespace CalamityMod.Projectiles.Magic } // Fire vortices at nearby target. - NPC potentialTarget = Projectile.Center.ClosestNPCAt(1250f); + NPC potentialTarget = Projectile.Center.ClosestNPCAt(SubsumingVortex.SmallVortexTargetRange - 100f); if (potentialTarget != null && Time % SubsumingVortex.VortexReleaseRate == SubsumingVortex.VortexReleaseRate - 1) { // CheckMana returns true if the mana cost can be paid.. bool allowContinuedUse = Owner.CheckMana(Owner.ActiveItem(), -1, true, false); - bool crystalStillInUse = Owner.channel && allowContinuedUse && !Owner.noItems && !Owner.CCed; - if (crystalStillInUse) + bool vortexStillInUse = Owner.channel && allowContinuedUse && !Owner.noItems && !Owner.CCed; + if (vortexStillInUse) { SoundEngine.PlaySound(SoundID.Item84, Projectile.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - float hue = (Time - 56f) / 125f; + float hue = (Time - SubsumingVortex.VortexShootDelay) / 125f; Vector2 vortexVelocity = Projectile.SafeDirectionTo(potentialTarget.Center) * 8f; Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center, vortexVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, hue); } Projectile.netUpdate = true; } - else if (!crystalStillInUse) + else if (!vortexStillInUse) Projectile.Kill(); } } // Create swirling exo energy. - if (Main.rand.NextBool(2)) + if (Main.rand.NextBool()) { - float dustSpawnChance = Utils.Remap(Time, 12f, 64f, 0.25f, 0.7f); + float dustSpawnChance = Utils.Remap(Time, 12f, SubsumingVortex.VortexShootDelay + 8f, 0.25f, 0.7f); for (int i = 0; i < 3; i++) { if (Main.rand.NextFloat() < dustSpawnChance) @@ -133,9 +118,10 @@ namespace CalamityMod.Projectiles.Magic // Hover above the target. if (Main.myPlayer == Projectile.owner) { + // Smoothly approach a sinusoidal offset as time goes on. float verticalOffset = Utils.Remap(Time, 0f, 90f, -30f, (float)Math.Cos(Projectile.timeLeft / 32f) * 30f - 325f); Vector2 hoverDestination = Owner.Top + Vector2.UnitY * verticalOffset; - hoverDestination += (Main.MouseWorld - hoverDestination) * 0.25f; + hoverDestination += (Main.MouseWorld - hoverDestination) * SubsumingVortex.GiantVortexMouseDriftFactor; Vector2 idealVelocity = Vector2.Zero.MoveTowards(hoverDestination - Projectile.Center, 32f); Projectile.velocity = Vector2.Lerp(Projectile.velocity, idealVelocity, 0.04f); diff --git a/Projectiles/Magic/ExoVortex.cs b/Projectiles/Magic/ExoVortex.cs index ec82d94322..4cb9c6d864 100644 --- a/Projectiles/Magic/ExoVortex.cs +++ b/Projectiles/Magic/ExoVortex.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using CalamityMod.Items.Weapons.Magic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -10,15 +11,13 @@ namespace CalamityMod.Projectiles.Magic { public class ExoVortex : ModProjectile { + public PrimitiveTrail EnergyTrail = null; + public float Hue => Projectile.ai[0]; public ref float Time => ref Projectile.ai[1]; - public const float AngularMovementSpeed = 0.1f; - - public const float Acceleration = 0.0025f; - - public PrimitiveTrail EnergyTrail = null; + public const float HueShiftAcrossAfterimages = 0.2f; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; @@ -50,7 +49,14 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { Time++; - MoveTowardsTarget(); + + // Move sharply towards nearby targets. + NPC potentialTarget = Projectile.Center.ClosestNPCAt(SubsumingVortex.SmallVortexTargetRange); + if (potentialTarget != null) + { + float flySpeed = 40f / Projectile.MaxUpdates; + Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(potentialTarget.Center) * flySpeed, 0.02f); + } // Rotate. Projectile.rotation += Projectile.velocity.X * 0.04f; @@ -61,15 +67,6 @@ namespace CalamityMod.Projectiles.Magic Projectile.ExpandHitboxBy((int)(Projectile.scale * 62f)); } - public void MoveTowardsTarget() - { - NPC potentialTarget = Projectile.Center.ClosestNPCAt(1400f); - if (potentialTarget is null) - return; - - Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(potentialTarget.Center) * 10f, 0.02f); - } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.ExoDebuffs(); @@ -80,19 +77,28 @@ namespace CalamityMod.Projectiles.Magic target.ExoDebuffs(); } + // Draw these vortices behind other projectiles to ensure that it does not draw on top of the big vortex. public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) { behindProjectiles.Add(index); } + public float PrimitiveWidthFunction(float completionRatio) + { + float width = Projectile.width * 0.6f; + width *= MathHelper.SmoothStep(0.6f, 1f, Utils.GetLerpValue(0f, 0.3f, completionRatio, true)); + return width; + } + public Color PrimitiveTrailColor(float completionRatio) { - float hue = Hue % 1f + 0.2f; + float hue = Hue % 1f + HueShiftAcrossAfterimages; if (hue >= 0.99f) hue = 0.99f; + float velocityOpacityFadeout = Utils.GetLerpValue(2f, 5f, Projectile.velocity.Length(), true); Color c = CalamityUtils.MulticolorLerp(hue, CalamityUtils.ExoPalette) * Projectile.Opacity * (1f - completionRatio); - return c * Utils.GetLerpValue(2f, 5f, Projectile.velocity.Length(), true) * Utils.GetLerpValue(0.04f, 0.2f, completionRatio, true); + return c * Utils.GetLerpValue(0.04f, 0.2f, completionRatio, true) * velocityOpacityFadeout; } public override bool PreDraw(ref Color lightColor) @@ -104,23 +110,18 @@ namespace CalamityMod.Projectiles.Magic Main.spriteBatch.EnterShaderRegion(); // Draw the streak trail. - EnergyTrail ??= new(completioRatio => - { - float width = Projectile.width * 0.6f; - width *= MathHelper.SmoothStep(0.6f, 1f, Utils.GetLerpValue(0f, 0.3f, completioRatio, true)); - return width; - }, PrimitiveTrailColor, null, GameShaders.Misc["CalamityMod:SideStreakTrail"]); + EnergyTrail ??= new(PrimitiveWidthFunction, PrimitiveTrailColor, null, GameShaders.Misc["CalamityMod:SideStreakTrail"]); GameShaders.Misc["CalamityMod:SideStreakTrail"].UseImage1("Images/Misc/Perlin"); EnergyTrail.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition + Projectile.velocity.SafeNormalize(Vector2.Zero) * Projectile.scale * 2f, 51); - Main.spriteBatch.EnterShaderRegion(BlendState.Additive); + GameShaders.Misc["CalamityMod:ExoVortex"].Apply(); - // Draw the vortex. + // Draw the vortex, along with some afterimages. for (int i = 0; i < 5; i++) { - float hue = Hue % 1f + i / 4f * 0.2f; + float hue = Hue % 1f + i / 4f * HueShiftAcrossAfterimages; Vector2 scale = MathHelper.Lerp(1f, 0.6f, i / 4f) * Projectile.Size / worleyNoise.Size() * 2f; Vector2 drawOffset = Vector2.UnitY * Projectile.scale * 6f; Color c = CalamityUtils.MulticolorLerp(hue, CalamityUtils.ExoPalette) * Projectile.Opacity;