added better dust effects The projectile now fades out at the end of life instead of popping out of existence instantly
84 lines
3.1 KiB
C#
84 lines
3.1 KiB
C#
using System;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.Audio;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Melee
|
|
{
|
|
public class GelWave : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Melee";
|
|
public override void SetStaticDefaults()
|
|
{
|
|
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10;
|
|
ProjectileID.Sets.TrailingMode[Projectile.type] = 1;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 164;
|
|
Projectile.height = 164;
|
|
Projectile.friendly = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.DamageType = DamageClass.Melee;
|
|
Projectile.penetrate = -1;
|
|
Projectile.timeLeft = 200;
|
|
Projectile.tileCollide = false;
|
|
Projectile.usesLocalNPCImmunity = true;
|
|
Projectile.localNPCHitCooldown = -1;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
if (Projectile.localAI[0] == 0f)
|
|
{
|
|
SoundEngine.PlaySound(SoundID.Item92, Projectile.position);
|
|
Projectile.localAI[0] += 1f;
|
|
}
|
|
Lighting.AddLight(Projectile.Center, Color.Blue.ToVector3());
|
|
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
|
|
if (Main.rand.NextBool(10))
|
|
{
|
|
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.BlueFairy, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f);
|
|
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.PinkFairy, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f);
|
|
}
|
|
if (Projectile.timeLeft <= 60)
|
|
{
|
|
Projectile.alpha = (int)Utils.Remap(Projectile.timeLeft, 0, 60, 255, 0);
|
|
Projectile.velocity *= 0.94f;
|
|
}
|
|
else if (Projectile.scale < 2f)
|
|
{
|
|
Projectile.velocity *= 0.99f;
|
|
Projectile.scale += 0.02f;
|
|
}
|
|
if (Projectile.timeLeft > 60)
|
|
{
|
|
Dust disgustingtrail = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity, 119, -Projectile.velocity * Main.rand.NextFloat(0.2f, 0.4f));
|
|
disgustingtrail.noGravity = true;
|
|
disgustingtrail.scale = 1.2f;
|
|
}
|
|
}
|
|
|
|
public override bool? CanDamage() => (Projectile.alpha == 0 ? null : false);
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 2);
|
|
return false;
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
|
{
|
|
target.AddBuff(BuffID.Slimed, 300);
|
|
Projectile.velocity *= 1.1f;
|
|
|
|
if (Projectile.numHits >= 3 && Projectile.timeLeft > 60)
|
|
Projectile.timeLeft = 60;
|
|
}
|
|
|
|
}
|
|
}
|