Profaned Soul Crystal's anti-whip-stack only works on vanilla whips at the moment.
144 lines
5.3 KiB
C#
144 lines
5.3 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Melee
|
|
{
|
|
public class PrismaticWave : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Melee";
|
|
private int alpha = 50;
|
|
public Color[] colors = new Color[]
|
|
{
|
|
new Color(255, 0, 0, 50), //Red
|
|
new Color(255, 128, 0, 50), //Orange
|
|
new Color(255, 255, 0, 50), //Yellow
|
|
new Color(128, 255, 0, 50), //Lime
|
|
new Color(0, 255, 0, 50), //Green
|
|
new Color(0, 255, 128, 50), //Turquoise
|
|
new Color(0, 255, 255, 50), //Cyan
|
|
new Color(0, 128, 255, 50), //Light Blue
|
|
new Color(0, 0, 255, 50), //Blue
|
|
new Color(128, 0, 255, 50), //Purple
|
|
new Color(255, 0, 255, 50), //Fuschia
|
|
new Color(255, 0, 128, 50) //Hot Pink
|
|
};
|
|
List<Color> colorSet = new List<Color>()
|
|
{
|
|
new Color(255, 0, 0, 50), //Red
|
|
new Color(255, 255, 0, 50), //Yellow
|
|
new Color(0, 255, 0, 50), //Green
|
|
new Color(0, 255, 255, 50), //Cyan
|
|
new Color(0, 0, 255, 50), //Blue
|
|
new Color(255, 0, 255, 50), //Fuschia
|
|
};
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10;
|
|
ProjectileID.Sets.TrailingMode[Projectile.type] = 1;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 36;
|
|
Projectile.height = 36;
|
|
Projectile.friendly = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.DamageType = DamageClass.Ranged;
|
|
Projectile.DamageType = DamageClass.Melee;
|
|
Projectile.penetrate = 2;
|
|
Projectile.timeLeft = 360;
|
|
Projectile.tileCollide = false;
|
|
Projectile.usesLocalNPCImmunity = true;
|
|
Projectile.localNPCHitCooldown = 20;
|
|
}
|
|
|
|
public override void SendExtraAI(BinaryWriter writer)
|
|
{
|
|
writer.Write(Projectile.localAI[0]);
|
|
}
|
|
|
|
public override void ReceiveExtraAI(BinaryReader reader)
|
|
{
|
|
Projectile.localAI[0] = reader.ReadSingle();
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
if (Projectile.localAI[0] == 0f)
|
|
{
|
|
Projectile.scale -= 0.02f;
|
|
Projectile.alpha += 30;
|
|
if (Projectile.alpha >= 250)
|
|
{
|
|
Projectile.alpha = 255;
|
|
Projectile.localAI[0] = 1f;
|
|
}
|
|
}
|
|
else if (Projectile.localAI[0] == 1f)
|
|
{
|
|
Projectile.scale += 0.02f;
|
|
Projectile.alpha -= 30;
|
|
if (Projectile.alpha <= 0)
|
|
{
|
|
Projectile.alpha = 0;
|
|
Projectile.localAI[0] = 0f;
|
|
}
|
|
}
|
|
Lighting.AddLight(Projectile.Center, Main.DiscoR * 0.5f / 255f, Main.DiscoG * 0.5f / 255f, Main.DiscoB * 0.5f / 255f);
|
|
Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X);
|
|
if (Main.rand.NextBool())
|
|
{
|
|
int rainbow = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 267, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, alpha, Main.rand.Next(colors));
|
|
Main.dust[rainbow].noGravity = true;
|
|
}
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
if (Projectile.timeLeft > 355)
|
|
return false;
|
|
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 2);
|
|
return false;
|
|
}
|
|
|
|
public override Color? GetAlpha(Color lightColor)
|
|
{
|
|
int colorIndex = (int)(Main.GlobalTimeWrappedHourly / 2 % colorSet.Count);
|
|
Color currentColor = colorSet[colorIndex];
|
|
Color nextColor = colorSet[(colorIndex + 1) % colorSet.Count];
|
|
return Color.Lerp(currentColor, nextColor, Main.GlobalTimeWrappedHourly % 2f > 1f ? 1f : Main.GlobalTimeWrappedHourly % 1f);
|
|
}
|
|
|
|
public override void OnKill(int timeLeft)
|
|
{
|
|
for (int k = 0; k < 3; k++)
|
|
{
|
|
int rainbow = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 267, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f, alpha, Main.rand.Next(colors));
|
|
Main.dust[rainbow].noGravity = true;
|
|
}
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone)
|
|
{
|
|
target.AddBuff(ModContent.BuffType<Nightwither>(), 150);
|
|
target.AddBuff(BuffID.Daybreak, 150);
|
|
Projectile.velocity *= 0.75f;
|
|
}
|
|
|
|
public override void OnHitPlayer(Player target, Player.HurtInfo info)
|
|
{
|
|
target.AddBuff(ModContent.BuffType<Nightwither>(), 150);
|
|
target.AddBuff(BuffID.Daybreak, 150);
|
|
Projectile.velocity *= 0.75f;
|
|
}
|
|
}
|
|
}
|