Particle effects & midas prime fixes

This commit is contained in:
IbanPlay committed 2022-07-11 23:42:52 +02:00
1 parent 3f2715b99d
commit 8d39357289
8 files changed
+129 -22

No files matched your search

+34
View File
@@ -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;
}
}
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

+27 -7
View File
@@ -13,6 +13,7 @@ using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.Items.Weapons.Melee;
using Terraria.Audio;
using Terraria.DataStructures;
using CalamityMod.Dusts;
namespace CalamityMod.Items.Armor.DesertProwler
{
@@ -95,19 +96,38 @@ namespace CalamityMod.Items.Armor.DesertProwler
player.GetCritChance(DamageClass.Ranged) += 300;
//Visuals
Vector2 smokePos = player.Hitbox.BottomLeft() + Vector2.UnitX * player.Hitbox.Width * Main.rand.NextFloat() - Vector2.UnitY * Main.rand.NextFloat(28f);
Vector2 smokePos = player.MountedCenter + Main.rand.NextVector2Square(-player.height / 2, player.height / 2);
Color startColor = new Color(122, 100, 83);
Color endColor = new Color(106, 80, 82);
/*
for (int i = 0; i < 5; i++)
{
Dust dust = Dust.NewDustDirect(player.MountedCenter, 0, 0, DustType<GasDust>());
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);
+2
View File
@@ -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<MidasBlast>();
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

+50
View File
@@ -0,0 +1,50 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class SandyDustParticle : Particle
{
public override string Texture => "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);
}
}
}
+4 -4
View File
@@ -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);
}
}
}
+12 -11
View File
@@ -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<MidasCoin>() && proj.active)
if (proj.ModProjectile != null && proj.type == ModContent.ProjectileType<MidasCoin>() && 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