Files
CalamityModPublic/Projectiles/Ranged/CosmicFire.cs
T

89 lines
2.8 KiB
C#

using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class CosmicFire : ModProjectile
{
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Fire");
}
public override void SetDefaults()
{
Projectile.width = 10;
Projectile.height = 10;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.DamageType = DamageClass.Ranged;
Projectile.penetrate = -1;
Projectile.extraUpdates = 3;
Projectile.timeLeft = 100;
}
public override void AI()
{
if (Projectile.scale <= 1.5f)
{
Projectile.scale *= 1.01f;
}
Lighting.AddLight(Projectile.Center, 0.25f, 0f, 0.1f);
if (Projectile.ai[0] > 7f)
{
float scalar = 1f;
if (Projectile.ai[0] == 8f)
{
scalar = 0.25f;
}
else if (Projectile.ai[0] == 9f)
{
scalar = 0.5f;
}
else if (Projectile.ai[0] == 10f)
{
scalar = 0.75f;
}
Projectile.ai[0] += 1f;
int dustType = Main.rand.NextBool(4) ? 61 : 62;
if (Main.rand.NextBool(2))
{
int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f);
Dust dust = Main.dust[fire];
if (Main.rand.NextBool(3))
{
dust.noGravity = true;
dust.scale *= 3f;
dust.velocity.X *= 2f;
dust.velocity.Y *= 2f;
}
else
{
dust.scale *= 1.5f;
}
dust.velocity.X *= 1.2f;
dust.velocity.Y *= 1.2f;
dust.scale *= scalar;
dust.velocity += Projectile.velocity;
if (!dust.noGravity)
{
dust.velocity *= 0.5f;
}
}
}
else
{
Projectile.ai[0] += 1f;
}
Projectile.rotation += 0.3f * (float)Projectile.direction;
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.immune[Projectile.owner] = 3;
}
}
}