From 8d39357289c6fc0002cec636c6eb04fc4049a774 Mon Sep 17 00:00:00 2001 From: IbanPlay <56191483+IbanPlay@users.noreply.github.com> Date: Mon, 11 Jul 2022 23:42:52 +0200 Subject: [PATCH] Particle effects & midas prime fixes --- Dusts/GasDust.cs | 34 ++++++++++++ Dusts/GasDust.png | Bin 0 -> 114 bytes Items/Armor/DesertProwler/DesertProwlerSet.cs | 34 +++++++++--- Items/Weapons/Ranged/MidasPrime.cs | 2 + Particles/SandyDust.png | Bin 0 -> 1664 bytes Particles/SandyDustParticle.cs | 50 ++++++++++++++++++ Particles/TimedSmokeParticle.cs | 8 +-- Projectiles/Ranged/MidasBlast.cs | 23 ++++---- 8 files changed, 129 insertions(+), 22 deletions(-) create mode 100644 Dusts/GasDust.cs create mode 100644 Dusts/GasDust.png create mode 100644 Particles/SandyDust.png create mode 100644 Particles/SandyDustParticle.cs diff --git a/Dusts/GasDust.cs b/Dusts/GasDust.cs new file mode 100644 index 0000000000..ce2c48741b --- /dev/null +++ b/Dusts/GasDust.cs @@ -0,0 +1,34 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Dusts +{ + public class GasDust : ModDust + { + public override string Texture => "CalamityMod/Dusts/GasDust"; + public override void OnSpawn(Dust dust) + { + dust.noGravity = true; + dust.alpha = 210; + dust.scale *= Main.rand.NextFloat(0.8f, 2f); + } + + public override Color? GetAlpha(Dust dust, Color lightColor) + { + Color color = lightColor.MultiplyRGB(dust.color * 0.995f); + return color * 0.4f * ((255 - dust.alpha) / 255f); + } + + public override bool Update(Dust dust) + { + dust.velocity *= 0.99f; + dust.position += dust.velocity; + dust.alpha += 3; + if (dust.alpha >= 255) + dust.active = false; + + return false; + } + } +} diff --git a/Dusts/GasDust.png b/Dusts/GasDust.png new file mode 100644 index 0000000000000000000000000000000000000000..16e45b74c70231d32409b332122718e0b7eb6f2f GIT binary patch literal 114 zcmeAS@N?(olHy`uVBq!ia0vp^AhsL_6Of!GE|CtTEInNuLo_BPCoEtwI28H+|9|%m zBcnwg%BK}qCmhPRNWH`|$1LLjQ2gSd_GOJ;UK()); + dust.position += Main.rand.NextVector2Square(-player.height / 2, player.height / 2); + dust.velocity = Main.rand.NextVector2Circular(1, 1) + player.velocity / 2; + dust.scale = 2.4f; + dust.color = new Color(217, 154, 154); + } + */ + + for (int i = 0; i < 15; i++) + { + Particle dust = new SandyDustParticle(player.MountedCenter + Main.rand.NextVector2Square(-player.height / 2, player.height / 2), Main.rand.NextVector2Circular(1, 1) + player.velocity / 2, Color.White, Main.rand.NextFloat(0.7f, 1.2f), Main.rand.Next(10, 40), rotationSpeed:0.03f); + GeneralParticleHandler.SpawnParticle(dust); + } + + + + Color startColor = new Color(173, 156, 112); + Color endColor = new Color(143, 120, 63); if (Main.rand.NextBool()) { - startColor = new Color(143, 120, 83); - endColor = new Color(92, 86, 71); + startColor = new Color(173, 139, 100); + endColor = new Color(149, 106, 50); } - Particle smoke = new TimedSmokeParticle(smokePos, Main.rand.NextVector2Circular(6f, 3f) - Vector2.UnitY * 4f + player.velocity * 0.5f, startColor, endColor, Main.rand.NextFloat(0.7f, 2.2f), Main.rand.NextFloat(0.6f, 0.85f), Main.rand.Next(10, 26), 0.05f); + Particle smoke = new TimedSmokeParticle(smokePos, Main.rand.NextVector2Circular(2f, 1f) - Vector2.UnitY * 1f + player.velocity * 0.5f, startColor, endColor, Main.rand.NextFloat(0.7f, 2.2f), Main.rand.NextFloat(0.6f, 0.85f), Main.rand.Next(40, 76), 0.01f); GeneralParticleHandler.SpawnParticle(smoke); - + // Dust Vector2 dustDirection = Main.rand.NextVector2CircularEdge(1f, 1f); diff --git a/Items/Weapons/Ranged/MidasPrime.cs b/Items/Weapons/Ranged/MidasPrime.cs index b2f2eba069..1485de17ef 100644 --- a/Items/Weapons/Ranged/MidasPrime.cs +++ b/Items/Weapons/Ranged/MidasPrime.cs @@ -133,6 +133,8 @@ namespace CalamityMod.Items.Weapons.Ranged public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) { + position -= Vector2.UnitY * 13f; + //Override every projectile type = ModContent.ProjectileType(); diff --git a/Particles/SandyDust.png b/Particles/SandyDust.png new file mode 100644 index 0000000000000000000000000000000000000000..61aa9036aac3c44c6a076b13ae7ac266d70efbd7 GIT binary patch literal 1664 zcmV-`27md9P)Px*I!Q!9RA_YbHJRhf>hh^aKt1r9SkN5oaP`pRQ&qu)T17JRGW(vIT0r>dzB><|H zdWbU^fUf-=0Msu;0hpbYL0cflp17K!OjRywD zL}U--3G^@!u`1#T0K)!Y24L6LFaXznM{_=#$_}HR48ZoSXu;ex6(Jps+m&aTN#;{Y zEeV0}Ez`>5TZDaj9O8d2HeF15uCN7iD(h6T++i-LbbJ*m9jP3FjC&kgQ&ANpScuML z02-^S0k}D405ELMxblay53L<*lyCv?PDcPpR8_n4W2R=G7*YO>P=o7pB#tesRk8zv zEPIk|fjmC7=k)wBngQ6*P~!o}n5O$D%MAC`zE9Y4PL>n;B$re{R%NvZpnqgWtH-(; zuQpTBlx}zOTLa2&nO4rXX%*y)-7=GT{3KP$wBk?4GU{`sWaSQ9prLySdFja?cVE4} za!-4VNMvNlEhP>GG~1f#kPwlj<0nf&&0dM>hd5IIxUfOqO9qBnCj( zXi+`Tw%Y()`^BgCVhfdOG^=j3+qaooFt;jHMWsika=lf;B5vwQ2!wCN^LnwkMcA*$ zA^zuL;bPKrg)NX%S*Mca4l|?D@TtDpt{j1kFQkK-y|i9zW>)oLmFnX+qiX>ePRCsN z!)Y%7wWCd0i`rwnVbyIXd_H&noPMvG7+3y{bp?8{Q5DCQH7eP`0pAMtVt&5|;KJ=` z)r-}saV8!w)%Sl2_cIj$gtN;&H(5^TlU!Oa=2aVb|9DLAm3&otFP5p)>`s1bjq+o~ z^Lndzk~-g0i~6?`dHh6@Dl@70Q}e198`qb~a**rAV)hNvlRxhMZD_?F_BfHuuChXt zC2&r1Q5AIb^i=>3?cFUVy;m~zYkKdf`o3q!8pD-8k-h)-jz(?U*^y{LzWDF`D|b4b z|LyOB{FQ($kR;=T(WKUDx!da+R*&i)WoV={@ zH>_{+0L)C!*)}VgVpVgUgMYb{v|M2eba&*Qywrj|b@kSYJ?wEJl~Qd@v!N#C+>bZh zd$C%-Hpx%K2K+F1d!PEBrn*240O5%HMNtI$^yIgXDzyLcMB^XO;@R#SU;K9f0000< KMNUMnLSTZ= "CalamityMod/Particles/SandyDust"; + public override bool UseCustomDraw => true; + public override bool SetLifetime => true; + + private float Spin; + private float opacity; + private Vector2 Gravity; + public Rectangle Frame; + + public SandyDustParticle(Vector2 position, Vector2 velocity, Color color, float scale, int lifeTime, float rotationSpeed = 1f, bool bigSize = false, bool emitsLight = false, Vector2? gravity = null) + { + Position = position; + Velocity = velocity; + Color = color; + Scale = scale; + Lifetime = lifeTime; + Rotation = Main.rand.NextFloat(MathHelper.TwoPi); + Spin = rotationSpeed; + Gravity = (Vector2)(gravity == null ? Vector2.Zero : gravity); + Variant = Main.rand.Next(18); + Frame = new Rectangle(Variant % 6 * 12, Variant / 3 * 12, 10, 10); + } + + public override void Update() + { + Velocity += Gravity; + opacity = (float)Math.Sin(LifetimeCompletion * MathHelper.Pi); + + Velocity *= 0.95f; + Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f); + Scale *= 0.98f; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D dustTexture = GeneralParticleHandler.GetTexture(Type); + spriteBatch.Draw(dustTexture, Position - Main.screenPosition, Frame, Color * opacity, Rotation, Frame.Size() / 2f, Scale, SpriteEffects.None, 0); + } + } +} diff --git a/Particles/TimedSmokeParticle.cs b/Particles/TimedSmokeParticle.cs index cf9ab7254f..842bfcaa0c 100644 --- a/Particles/TimedSmokeParticle.cs +++ b/Particles/TimedSmokeParticle.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Particles Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f); Velocity *= 0.85f; - if (LifetimeCompletion < 0.24f) + if (LifetimeCompletion < 0.84f) { Scale += 0.01f; } @@ -41,10 +41,10 @@ namespace CalamityMod.Particles Scale *= 0.975f; } - Velocity -= Vector2.UnitY * 0.05f; - float opacityMult = 1 - (float)Math.Pow(LifetimeCompletion, 2); + Velocity -= Vector2.UnitY * 0.08f; - Color = Color.Lerp(ColorStart, ColorFade, MathHelper.Clamp((float)((255 -Opacity) - 100) / 80, 0f, 1f)) * (Opacity * opacityMult); + float opacityMult = 1 - (float)Math.Pow(LifetimeCompletion, 2); + Color = Color.Lerp(ColorStart, ColorFade, opacityMult) * (Opacity * opacityMult); } } } diff --git a/Projectiles/Ranged/MidasBlast.cs b/Projectiles/Ranged/MidasBlast.cs index afe129c05b..e406d73f90 100644 --- a/Projectiles/Ranged/MidasBlast.cs +++ b/Projectiles/Ranged/MidasBlast.cs @@ -65,7 +65,7 @@ namespace CalamityMod.Projectiles.Ranged if (Ricochets < 4) { - int[] flyingCoins = new int[3]; + int[] flyingCoins = new int[4]; int coinIndex = 0; int struckCoinIndex = -1; @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < Main.maxProjectiles; i++) { Projectile proj = Main.projectile[i]; - if (proj.ModProjectile != null && proj.type == ModContent.ProjectileType() && proj.active) + if (proj.ModProjectile != null && proj.type == ModContent.ProjectileType() && proj.active && proj.owner == Projectile.owner) { flyingCoins[coinIndex] = proj.whoAmI; coinIndex++; @@ -84,7 +84,7 @@ namespace CalamityMod.Projectiles.Ranged coinIndex--; // We don't care about this coin, don't redirect it to itself } - if (coinIndex == 3) + if (coinIndex == 4) break; } } @@ -103,7 +103,7 @@ namespace CalamityMod.Projectiles.Ranged PauseTime--; } - public void RicochetEffect(Vector2 target, Projectile struckCoin) + public void RicochetEffect(Vector2 target, Projectile struckCoin, bool shouldPause = true) { //Play sound SoundEngine.PlaySound(DeadeyeRevolver.BlingHitSound, struckCoin.Center); @@ -124,18 +124,19 @@ namespace CalamityMod.Projectiles.Ranged ORDERSystem.ORDER(); - PauseTime = Pause; + if (shouldPause) + PauseTime = Pause; } public void SimpleRicochet(int[] flyingCoins, int flyingCoinCount, Projectile struckCoin) { //If we find a redirection target, do the ricochet and a bunch of cool effects. - if (FindRicochetTarget(Projectile.Center, flyingCoins, flyingCoinCount, out Vector2 redirectionTarget, out _)) - RicochetEffect(redirectionTarget, struckCoin); + if (FindRicochetTarget(Projectile.Center, flyingCoins, flyingCoinCount, out Vector2 redirectionTarget, out int coinIndex)) + RicochetEffect(redirectionTarget, struckCoin, coinIndex >= 0); //If no target is found, just ricochet the shot forward else - RicochetEffect(Projectile.Center + Projectile.velocity, struckCoin); + RicochetEffect(Projectile.Center + Projectile.velocity, struckCoin, false); } public void PlanFullRicochet(int[] flyingCoins, int flyingCoinCount, Projectile struckCoin) @@ -154,7 +155,7 @@ namespace CalamityMod.Projectiles.Ranged if (firstRicochetTarget == Vector2.Zero) firstRicochetTarget = redirectionTarget; - Main.projectile[i].ai[1] = CoinPause; + Main.projectile[redirectedCoinIndex].ai[1] = CoinPause; ricochetPosition = redirectionTarget; } @@ -164,7 +165,7 @@ namespace CalamityMod.Projectiles.Ranged //If we can't ricochet to any coins from the start but we still found a valid npc target, go to them. if (i == 0) { - RicochetEffect(redirectionTarget, struckCoin); + RicochetEffect(redirectionTarget, struckCoin, false); return; } @@ -178,7 +179,7 @@ namespace CalamityMod.Projectiles.Ranged if (i == 0) { //If no target at all was found, just propel the coin forward - RicochetEffect(Projectile.Center + Projectile.velocity, struckCoin); + RicochetEffect(Projectile.Center + Projectile.velocity, struckCoin, false); return; } else