83 lines
3.1 KiB
C#
83 lines
3.1 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Typeless
|
|
{
|
|
public class EmpyreanEmber : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Typeless";
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 6;
|
|
Projectile.height = 12;
|
|
Projectile.friendly = true;
|
|
Projectile.penetrate = 1;
|
|
Projectile.timeLeft = 180;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
if (Projectile.velocity.X != Projectile.velocity.X)
|
|
{
|
|
Projectile.velocity.X = Projectile.velocity.X * -0.1f;
|
|
}
|
|
if (Projectile.velocity.X != Projectile.velocity.X)
|
|
{
|
|
Projectile.velocity.X = Projectile.velocity.X * -0.5f;
|
|
}
|
|
if (Projectile.velocity.Y != Projectile.velocity.Y && Projectile.velocity.Y > 1f)
|
|
{
|
|
Projectile.velocity.Y = Projectile.velocity.Y * -0.5f;
|
|
}
|
|
Projectile.ai[0] += 1f;
|
|
if (Projectile.ai[0] > 5f)
|
|
{
|
|
Projectile.ai[0] = 5f;
|
|
if (Projectile.velocity.Y == 0f && Projectile.velocity.X != 0f)
|
|
{
|
|
Projectile.velocity.X *= 0.97f;
|
|
if (Projectile.velocity.X > -0.01f && Projectile.velocity.X < 0.01f)
|
|
{
|
|
Projectile.velocity.X = 0f;
|
|
Projectile.netUpdate = true;
|
|
}
|
|
}
|
|
Projectile.velocity.Y = Projectile.velocity.Y + 0.2f;
|
|
}
|
|
Projectile.rotation += Projectile.velocity.X * 0.1f;
|
|
if (Main.rand.NextBool(3))
|
|
{
|
|
int num200 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 0.75f);
|
|
Dust dust2 = Main.dust[num200];
|
|
dust2.position.X -= 2f;
|
|
dust2.position.Y += 2f;
|
|
dust2.scale += 0.3f + (float)Main.rand.Next(50) * 0.01f;
|
|
dust2.noGravity = true;
|
|
dust2.velocity *= 0.1f;
|
|
}
|
|
else
|
|
{
|
|
int num199 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 62, 0f, 0f, 100, default, 0.75f);
|
|
Dust dust = Main.dust[num199];
|
|
dust.position.X -= 2f;
|
|
dust.position.Y += 2f;
|
|
dust.scale += (float)Main.rand.Next(50) * 0.01f;
|
|
dust.noGravity = true;
|
|
dust.velocity.Y -= 2f;
|
|
}
|
|
if (Projectile.velocity.Y < 0.25f && Projectile.velocity.Y > 0.15f)
|
|
{
|
|
Projectile.velocity.X *= 0.8f;
|
|
}
|
|
Projectile.rotation = -Projectile.velocity.X * 0.05f;
|
|
if (Projectile.velocity.Y > 16f)
|
|
{
|
|
Projectile.velocity.Y = 16f;
|
|
}
|
|
}
|
|
|
|
public override bool OnTileCollide(Vector2 oldVelocity) => false;
|
|
}
|
|
}
|