132 lines
5.8 KiB
C#
132 lines
5.8 KiB
C#
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using Terraria.Audio;
|
|
|
|
namespace CalamityMod.Projectiles.Melee
|
|
{
|
|
public class OrderbringerBeam : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Melee";
|
|
private int whiteLightTimer = 5;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4;
|
|
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 20;
|
|
Projectile.height = 20;
|
|
Projectile.extraUpdates = 3;
|
|
Projectile.friendly = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.penetrate = 1;
|
|
Projectile.timeLeft = 120;
|
|
Projectile.DamageType = DamageClass.Melee;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + 0.785f;
|
|
|
|
if (Projectile.ai[1] == 0f)
|
|
{
|
|
Projectile.ai[1] = 1f;
|
|
SoundEngine.PlaySound(SoundID.Item60, Projectile.position);
|
|
}
|
|
|
|
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((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16, (float)Main.DiscoR / 200f, (float)Main.DiscoG / 200f, (float)Main.DiscoB / 200f);
|
|
|
|
whiteLightTimer--;
|
|
if (whiteLightTimer == 0)
|
|
{
|
|
float spread = 180f * 0.0174f;
|
|
double startAngle = Math.Atan2(Projectile.velocity.X, Projectile.velocity.Y) - spread / 2;
|
|
double deltaAngle = spread / 8f;
|
|
double offsetAngle;
|
|
int i;
|
|
if (Projectile.owner == Main.myPlayer)
|
|
{
|
|
for (i = 0; i < 1; i++)
|
|
{
|
|
offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i;
|
|
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 0.6f), (float)(Math.Cos(offsetAngle) * 0.6f), ModContent.ProjectileType<OrderbringerWhiteOrb>(), Projectile.damage, Projectile.knockBack, Projectile.owner);
|
|
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 0.6f), (float)(-Math.Cos(offsetAngle) * 0.6f), ModContent.ProjectileType<OrderbringerWhiteOrb>(), Projectile.damage, Projectile.knockBack, Projectile.owner);
|
|
}
|
|
}
|
|
whiteLightTimer = 5;
|
|
}
|
|
|
|
int rainbow = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.6f);
|
|
Main.dust[rainbow].noGravity = true;
|
|
Main.dust[rainbow].velocity *= 0.5f;
|
|
Main.dust[rainbow].velocity += Projectile.velocity * 0.1f;
|
|
|
|
CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 200f, 10f, 20f);
|
|
}
|
|
|
|
public override Color? GetAlpha(Color lightColor)
|
|
{
|
|
return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Projectile.alpha);
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
if (Projectile.timeLeft > 115)
|
|
return false;
|
|
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
|
|
return false;
|
|
}
|
|
|
|
public override void OnKill(int timeLeft)
|
|
{
|
|
SoundEngine.PlaySound(SoundID.Item122, Projectile.Center);
|
|
for (int i = 0; i < 2; i++)
|
|
{
|
|
int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.5f);
|
|
Main.dust[dust].noGravity = true;
|
|
}
|
|
for (int j = 0; j < 20; j++)
|
|
{
|
|
int deathRainbow = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 2.5f);
|
|
Main.dust[deathRainbow].noGravity = true;
|
|
Main.dust[deathRainbow].velocity *= 3f;
|
|
deathRainbow = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 66, 0f, 0f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.5f);
|
|
Main.dust[deathRainbow].velocity *= 2f;
|
|
Main.dust[deathRainbow].noGravity = true;
|
|
}
|
|
if (Projectile.owner == Main.myPlayer)
|
|
{
|
|
Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y - 100, 0f, 0f, ModContent.ProjectileType<OrderbringerAura>(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f);
|
|
}
|
|
}
|
|
}
|
|
}
|