Lots of particle effects. Broken biome blade is done

This commit is contained in:
IbanPlay committed 2022-01-08 00:03:03 +01:00
1 parent 64330b2ee0
commit 46b2436577
19 files changed
+428 -67

No files matched your search

-51
View File
@@ -1,51 +0,0 @@
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Dusts {
public class PumplerDust : ModDust //TURN THAT INTO A PARTICLE WHEN I REMEMBER
{
public override bool Autoload(ref string name, ref string texture)
{
texture = "CalamityMod/Particles/SmallSmoke";
return true;
}
public override void OnSpawn(Dust dust)
{
dust.noGravity = true;
dust.frame = new Rectangle(0, 0, 24, 24);
}
public override Color? GetAlpha(Dust dust, Color lightColor)
{
Color gray = new Color(40, 40, 40);
Color ret;
ret = Color.Lerp(Color.Orange, gray, MathHelper.Clamp((float)(dust.alpha - 100) / 80, 0f, 1f));
return ret * ((255 - dust.alpha) / 255f);
}
public override bool Update(Dust dust)
{
dust.velocity *= 0.85f;
if (dust.alpha < 165)
{
Lighting.AddLight(dust.position, dust.color.ToVector3() * 0.1f);
dust.scale += 0.01f;
dust.alpha += 3;
}
else
{
dust.scale *= 0.975f;
dust.alpha += 2;
}
dust.position += dust.velocity;
if (dust.alpha >= 255)
dust.active = false;
return false;
}
}
}
+17 -2
View File
@@ -490,7 +490,7 @@ namespace CalamityMod.Items.Weapons.Melee
Owner.heldProj = projectile.whoAmI;
projectile.Center = Owner.Center + new Vector2(16f * Owner.direction, -30 * SwordHeight() + 10f) ;
projectile.rotation = Utils.AngleLerp(-MathHelper.PiOver4, MathHelper.PiOver4 + MathHelper.PiOver2, MathHelper.Clamp(((ChannelTimer - 20f) / 10f), 0f, 1f));
projectile.rotation = Utils.AngleLerp(-MathHelper.PiOver4, MathHelper.PiOver4 + MathHelper.PiOver2, MathHelper.Clamp(((ChannelTimer - 20f) / 50f), 0f, 1f));
ChannelTimer++;
projectile.timeLeft = 60;
@@ -498,7 +498,22 @@ namespace CalamityMod.Items.Weapons.Melee
{
Attune((BiomeBlade)associatedItem.modItem);
projectile.timeLeft = 120;
ChanneledState = 2f;
ChanneledState = 2f; //State where it stays invisible doing nothing. Acts as a cooldown
Color particleColor = (associatedItem.modItem as BiomeBlade).GetAttunementInfo((associatedItem.modItem as BiomeBlade).mainAttunement).color;
for (int i = 0; i <= 5; i++)
{
Vector2 displace = Vector2.UnitX * 20 * Main.rand.NextFloat(-1f, 1f);
Particle Glow = new GenericBloom(Owner.Bottom + displace, -Vector2.UnitY * Main.rand.NextFloat(1f, 5f), particleColor, 0.02f + Main.rand.NextFloat(0f, 0.2f), 20 + Main.rand.Next(30));
GeneralParticleHandler.SpawnParticle(Glow);
}
for (int i = 0; i <= 10; i++)
{
Vector2 displace = Vector2.UnitX * 16 * Main.rand.NextFloat(-1f, 1f);
Particle Sparkle = new GenericSparkle(Owner.Bottom + displace, -Vector2.UnitY * Main.rand.NextFloat(1f, 5f), particleColor, particleColor, 0.5f + Main.rand.NextFloat(-0.2f, 0.2f), 20 + Main.rand.Next(30), 1, 2f);
GeneralParticleHandler.SpawnParticle(Sparkle);
}
}
}
+55
View File
@@ -0,0 +1,55 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class CritSpark : Particle
{
public override string Texture => "CalamityMod/Particles/ThinSparkle";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
private float Spin;
private float opacity;
private Color Bloom;
private Color LightColor => Bloom * opacity;
private float BloomScale;
public CritSpark(Vector2 position, Vector2 velocity, Color color, Color bloom, float scale, int lifeTime, float rotationSpeed = 1f, float bloomScale = 1f)
{
Position = position;
Velocity = velocity;
Color = color;
Bloom = bloom;
Scale = scale;
Lifetime = lifeTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
BloomScale = bloomScale;
}
public override void Update()
{
opacity = (float)Math.Sin(MathHelper.PiOver2 + LifetimeCompletion * MathHelper.PiOver2);
Velocity *= 0.80f;
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f) * (LifetimeCompletion > 0.5 ? 1f : 0.5f);
Lighting.AddLight(Position, LightColor.R / 255f, LightColor.G / 255f, LightColor.B / 255f);
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D sparkTexture = GeneralParticleHandler.GetTexture(Type);
Texture2D bloomTexture = ModContent.GetTexture("CalamityMod/Particles/BloomCircle");
//Ajust the bloom's texture to be the same size as the star's
float properBloomSize = (float)sparkTexture.Height / (float)bloomTexture.Height;
spriteBatch.Draw(bloomTexture, Position - Main.screenPosition, null, Bloom * opacity * 0.5f, 0, bloomTexture.Size() / 2f, Scale * BloomScale * properBloomSize, SpriteEffects.None, 0);
spriteBatch.Draw(sparkTexture, Position - Main.screenPosition, null, Color * opacity, Rotation, sparkTexture.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B

+7 -3
View File
@@ -14,7 +14,8 @@ namespace CalamityMod.Particles
public static class GeneralParticleHandler
{
private static List<Particle> particles;
private static int nextVacantIndex;
//List containing the particles to delete
private static List<Particle> particlesToKill;
//Static list for details concerning every particle type
private static Dictionary<Type, int> particleTypes;
private static Dictionary<int, Texture2D> particleTextures;
@@ -26,6 +27,7 @@ namespace CalamityMod.Particles
internal static void Load()
{
particles = new List<Particle>();
particlesToKill = new List<Particle>();
particleTypes = new Dictionary<Type, int>();
particleTextures = new Dictionary<int, Texture2D>();
particleInstances = new List<Particle>();
@@ -57,6 +59,7 @@ namespace CalamityMod.Particles
internal static void Unload()
{
particles = null;
particlesToKill = null;
particleTypes = null;
particleTextures = null;
particleInstances = null;
@@ -87,12 +90,13 @@ namespace CalamityMod.Particles
particle.Update();
}
//Clear out particles whose time is up
particles.RemoveAll(particle => particle.Time >= particle.Lifetime && particle.SetLifetime);
particles.RemoveAll(particle => (particle.Time >= particle.Lifetime && particle.SetLifetime) || particlesToKill.Contains(particle));
particlesToKill.Clear();
}
public static void RemoveParticle(Particle particle)
{
particles.Remove(particle);
particlesToKill.Add(particle);
}
public static void DrawAllParticles(SpriteBatch sb)
+43
View File
@@ -0,0 +1,43 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class GenericBloom : Particle
{
public override string Texture => "CalamityMod/Particles/Light";
public override bool UseAdditiveBlend => true;
public override bool SetLifetime => true;
private float opacity;
private Color BaseColor;
public GenericBloom(Vector2 position, Vector2 velocity, Color color, float scale, int lifeTime)
{
Position = position;
Velocity = velocity;
BaseColor = color;
Scale = scale;
Lifetime = lifeTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
}
public override void Update()
{
opacity = (float)Math.Sin(LifetimeCompletion * MathHelper.Pi);
Color = BaseColor * opacity;
Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f);
Velocity *= 0.95f;
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D tex = GeneralParticleHandler.GetTexture(Type);
spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * opacity, Rotation, tex.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

+57
View File
@@ -0,0 +1,57 @@
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles {
public class MediumMistParticle : Particle
{
public override string Texture => "CalamityMod/Particles/MediumMist";
public override int FrameVariants => 3;
public override bool UseAdditiveBlend => true;
private float Opacity;
private Color ColorFire;
private Color ColorFade;
private float Spin;
public MediumMistParticle(Vector2 position, Vector2 velocity, Color colorFire, Color colorFade, float scale, float opacity, float rotationSpeed = 0f)
{
Position = position;
Velocity = velocity;
ColorFire = colorFire;
ColorFade = colorFade;
Scale = scale;
Opacity = opacity;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
Variant = Main.rand.Next(3);
}
public override void Update()
{
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
Velocity *= 0.85f;
if (Opacity > 90)
{
Lighting.AddLight(Position, Color.ToVector3() * 0.1f);
Scale += 0.01f;
Opacity -= 3;
}
else
{
Scale *= 0.975f;
Opacity -= 2;
}
if (Opacity < 0)
Kill();
Color = Color.Lerp(ColorFire, ColorFade, MathHelper.Clamp((float)((255 -Opacity) - 100) / 80, 0f, 1f)) * (Opacity / 255f);
}
}
}
+53
View File
@@ -0,0 +1,53 @@
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles {
public class SmallSmokeParticle : Particle
{
public override string Texture => "CalamityMod/Particles/SmallSmoke";
private float Opacity;
private Color ColorFire;
private Color ColorFade;
private float Spin;
public SmallSmokeParticle(Vector2 position, Vector2 velocity, Color colorFire, Color colorFade, float scale, float opacity, float rotationSpeed = 0f)
{
Position = position;
Velocity = velocity;
ColorFire = colorFire;
ColorFade = colorFade;
Scale = scale;
Opacity = opacity;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
}
public override void Update()
{
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
Velocity *= 0.85f;
if (Opacity > 90)
{
Lighting.AddLight(Position, Color.ToVector3() * 0.1f);
Scale += 0.01f;
Opacity -= 3;
}
else
{
Scale *= 0.975f;
Opacity -= 2;
}
if (Opacity < 0)
Kill();
Color = Color.Lerp(ColorFire, ColorFade, MathHelper.Clamp((float)((255 -Opacity) - 100) / 80, 0f, 1f)) * (Opacity / 255f);
}
}
}
+61
View File
@@ -0,0 +1,61 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class SnowflakeSparkle : Particle
{
public override string Texture => "CalamityMod/Particles/HalfIceStar";
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override bool SetLifetime => true;
private float Spin;
private float opacity;
private Color Bloom;
private Color LightColor => Bloom * opacity;
private float BloomScale;
private int Spokes;
public SnowflakeSparkle(Vector2 position, Vector2 velocity, Color color, Color bloom, float scale, int lifeTime, float rotationSpeed = 1f, float bloomScale = 1f, int spokes = 3)
{
Position = position;
Velocity = velocity;
Color = color;
Bloom = bloom;
Scale = scale;
Lifetime = lifeTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
BloomScale = bloomScale;
Spokes = spokes;
}
public override void Update()
{
opacity = (float)Math.Sin(LifetimeCompletion * MathHelper.Pi);
Lighting.AddLight(Position, LightColor.R / 255f, LightColor.G / 255f, LightColor.B / 255f);
Velocity *= 0.95f;
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D spokesTexture = GeneralParticleHandler.GetTexture(Type);
Texture2D bloomTexture = ModContent.GetTexture("CalamityMod/Particles/BloomCircle");
//Ajust the bloom's texture to be the same size as the star's
float properBloomSize = (float)spokesTexture.Height / (float)bloomTexture.Height;
spriteBatch.Draw(bloomTexture, Position - Main.screenPosition, null, Bloom * opacity * 0.5f, 0, bloomTexture.Size()/2f, Scale * BloomScale * properBloomSize, SpriteEffects.None, 0);
for (int i = 0; i < Spokes; i++)
{
float rotation = Rotation + MathHelper.Lerp(0f, MathHelper.Pi, i/(float)Spokes);
spriteBatch.Draw(spokesTexture, Position - Main.screenPosition, null, Color * opacity * 0.5f, Rotation + rotation, spokesTexture.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

+40
View File
@@ -0,0 +1,40 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class StoneDebrisParticle : Particle
{
public override string Texture => "CalamityMod/Particles/StoneDebris";
public override bool SetLifetime => true;
public override int FrameVariants => 5;
private float Spin;
private float opacity;
Color originalColor;
public StoneDebrisParticle(Vector2 position, Vector2 velocity, Color color, float scale, int lifeTime, float rotationSpeed = 1f)
{
Position = position;
Velocity = velocity;
Color = color;
originalColor = color;
Scale = scale;
Lifetime = lifeTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
Variant = Main.rand.Next(3);
}
public override void Update()
{
opacity = LifetimeCompletion < 0.5f ? 1f : (float)Math.Sin(LifetimeCompletion * MathHelper.Pi);
Color = originalColor * opacity;
Velocity = Velocity * 0.95f + Vector2.UnitY * 0.1f;
Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
}
}
}
+43
View File
@@ -0,0 +1,43 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class StrongBloom : Particle
{
public override string Texture => "CalamityMod/Particles/BloomCircle";
public override bool UseAdditiveBlend => true;
public override bool SetLifetime => true;
private float opacity;
private Color BaseColor;
public StrongBloom(Vector2 position, Vector2 velocity, Color color, float scale, int lifeTime)
{
Position = position;
Velocity = velocity;
BaseColor = color;
Scale = scale;
Lifetime = lifeTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
}
public override void Update()
{
opacity = (float)Math.Sin(LifetimeCompletion * MathHelper.Pi);
Color = BaseColor * opacity;
Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f);
Velocity *= 0.95f;
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D tex = GeneralParticleHandler.GetTexture(Type);
spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * opacity, Rotation, tex.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

@@ -369,6 +369,20 @@ namespace CalamityMod.Projectiles.Melee
if (projectile.frameCounter % 5 == 0 && projectile.frame + 1 < Main.projFrames[projectile.type])
projectile.frame++;
if (Main.rand.NextBool())
{
Particle mist = new MediumMistParticle(Owner.Center + direction * 40 + Main.rand.NextVector2Circular(30f, 30f), Vector2.Zero, new Color(172, 238, 255), new Color(145, 170, 188), Main.rand.NextFloat(0.5f, 1.5f), 245 - Main.rand.Next(50), 0.02f);
mist.Velocity = (mist.Position - Owner.Center) * 0.2f + Owner.velocity;
GeneralParticleHandler.SpawnParticle(mist);
}
}
else if (Main.rand.NextFloat(0f, 1f) > 0.75f)
{
Vector2 particlePosition = Owner.Center + (rotation.ToRotationVector2() * 100f * projectile.scale);
Particle snowflake = new SnowflakeSparkle(particlePosition, rotation.ToRotationVector2() * 3f, Color.White, new Color(75, 177, 250), Main.rand.NextFloat(0.3f, 1.5f), 40, 0.5f);
GeneralParticleHandler.SpawnParticle(snowflake);
}
//Make the owner look like theyre holding the sword bla bla
@@ -512,6 +526,27 @@ namespace CalamityMod.Projectiles.Melee
PogoCooldown = 30; //Cooldown
Main.PlaySound(SoundID.DD2_MonkStaffGroundImpact, projectile.position);
Vector2 hitPosition = Owner.Center + (direction * 84 * projectile.scale);
for (int i = 0; i < 8; i++)
{
Vector2 hitPositionDisplace = direction.RotatedBy(MathHelper.PiOver2) * Main.rand.NextFloat(-10f, 10f);
Vector2 flyDirection = -direction.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4));
Particle smoke = new SmallSmokeParticle(hitPosition + hitPositionDisplace, flyDirection * 9f, Color.OrangeRed, new Color(130, 130, 130), Main.rand.NextFloat(1.8f, 2.6f), 115 - Main.rand.Next(30));
GeneralParticleHandler.SpawnParticle(smoke);
Particle Glow = new StrongBloom(hitPosition - hitPositionDisplace * 3, -direction * 6 * Main.rand.NextFloat(0.5f, 1f), Color.Orange * 0.5f, 0.01f + Main.rand.NextFloat(0f, 0.2f), 20 + Main.rand.Next(40));
GeneralParticleHandler.SpawnParticle(Glow);
}
for (int i = 0; i < 3; i++)
{
Vector2 hitPositionDisplace = direction.RotatedBy(MathHelper.PiOver2) * Main.rand.NextFloat(-10f, 10f);
Vector2 flyDirection = -direction.RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver4, MathHelper.PiOver4));
Particle Rock = new StoneDebrisParticle(hitPosition - hitPositionDisplace * 3, flyDirection * Main.rand.NextFloat(3f, 6f), Color.Beige, 1f + Main.rand.NextFloat(0f, 0.4f), 30 + Main.rand.Next(50), 0.1f);
GeneralParticleHandler.SpawnParticle(Rock);
}
if (Owner.HeldItem.type == ItemType<BiomeBlade>())
(Owner.HeldItem.modItem as BiomeBlade).CanLunge = 1; // Reset the lunge counter on pogo. This should make for more interesting and fun synergies
}
@@ -729,7 +764,16 @@ namespace CalamityMod.Projectiles.Melee
if (Collision.CheckAABBvLineCollision(target.Hitbox.TopLeft(), target.Hitbox.Size(), projectile.Center - projectileHalfLenght, projectile.Center + projectileHalfLenght, 32, ref collisionPoint))
{
if (SnapCoyoteTime > 0f)
{
crit = true;
for (int i = 0; i < 3; i++)
{
Vector2 sparkSpeed = Owner.DirectionTo(target.Center).RotatedBy(Main.rand.NextFloat(-MathHelper.PiOver2, MathHelper.PiOver2)) * 9f;
Particle Spark = new CritSpark(target.Center, sparkSpeed, Color.White, Color.LimeGreen, 1f + Main.rand.NextFloat(0, 1f), 30, 0.4f, 0.6f);
GeneralParticleHandler.SpawnParticle(Spark);
}
}
}
else
damage = (int)(damage * ChainDamageReduction); //If the enemy is hit with the chain of the whip, the damage gets reduced
+4 -6
View File
@@ -4,6 +4,7 @@ using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using CalamityMod.Dusts;
using CalamityMod.Particles;
namespace CalamityMod.Projectiles.Ranged
{
@@ -35,13 +36,10 @@ namespace CalamityMod.Projectiles.Ranged
{
for (int i = 0; i < 15; i++)
{
Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(15f, 15f), ModContent.DustType<PumplerDust>());
dust.velocity = (dust.position - projectile.Center) * 0.2f + projectile.velocity;
dust.scale = Main.rand.NextFloat(0.8f, 1.6f);
dust.alpha = Main.rand.Next(30) + 100;
dust.rotation = Main.rand.NextFloat(6.28f);
Particle smoke = new SmallSmokeParticle(projectile.Center + Main.rand.NextVector2Circular(15f, 15f), Vector2.Zero, Color.Orange, new Color(40, 40, 40), Main.rand.NextFloat(0.8f, 1.6f), 145 - Main.rand.Next(30));
smoke.Velocity = (smoke.Position - projectile.Center) * 0.2f + projectile.velocity;
GeneralParticleHandler.SpawnParticle(smoke);
}
//CalamityUtils.ExplosionGores(projectile.Center, 1);
}
projectile.Kill();
}
+4 -5
View File
@@ -10,6 +10,7 @@ using Terraria.Graphics.Effects;
using System.Collections.Generic;
using Terraria.Graphics.Shaders;
using CalamityMod.Dusts;
using CalamityMod.Particles;
//TY dom for coding condemnation, great reference, would steal code from again :)
@@ -128,11 +129,9 @@ namespace CalamityMod.Projectiles.Ranged
for (int i = 0; i < 2 * PumpkinsCharge; i++)
{
Dust dust = Dust.NewDustPerfect(tipPosition + Main.rand.NextVector2Circular(10f, 10f), ModContent.DustType<PumplerDust>());
dust.velocity = (dust.position - Owner.Center) * 0.3f + Owner.velocity;
dust.scale = Main.rand.NextFloat(0.3f, 0.8f);
dust.alpha = Main.rand.Next(50) + 100;
dust.rotation = Main.rand.NextFloat(6.28f);
Particle smoke = new SmallSmokeParticle(tipPosition + Main.rand.NextVector2Circular(10f, 10f), Vector2.Zero, Color.Orange, new Color(40, 40, 40), Main.rand.NextFloat(0.3f, 0.8f), 145 - Main.rand.Next(50));
smoke.Velocity = (smoke.Position - Owner.Center) * 0.3f + Owner.velocity;
GeneralParticleHandler.SpawnParticle(smoke);
}
}