Files
CalamityModPublic/Projectiles/Rogue/ScarletBlast.cs
T
2024-04-04 04:22:36 +07:00

94 lines
3.4 KiB
C#

using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class ScarletBlast : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Rogue";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetDefaults()
{
Projectile.width = 500;
Projectile.height = 500;
Projectile.friendly = true;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.penetrate = -1;
Projectile.timeLeft = 30;
Projectile.usesLocalNPCImmunity = true;
Projectile.localNPCHitCooldown = 10;
Projectile.DamageType = RogueDamageClass.Instance;
}
public override void AI()
{
Lighting.AddLight(Projectile.Center, 0.55f, 0.25f, 0f);
if (Projectile.localAI[0] == 0f)
{
SoundEngine.PlaySound(SoundID.Item20, Projectile.position);
Projectile.localAI[0] += 1f;
}
bool xflag = false;
bool yflag = false;
if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0])
{
xflag = true;
}
if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0])
{
xflag = true;
}
if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1])
{
yflag = true;
}
if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1])
{
yflag = true;
}
if (xflag && yflag)
{
Projectile.Kill();
}
float projTimer = 25f;
if (Projectile.ai[0] > 180f)
{
projTimer -= (Projectile.ai[0] - 180f) / 2f;
}
if (projTimer <= 0f)
{
projTimer = 0f;
Projectile.Kill();
}
projTimer *= 0.7f;
Projectile.ai[0] += 4f;
int timerCompare = 0;
while ((float)timerCompare < projTimer)
{
float random1 = (float)Main.rand.Next(-30, 35);
float random2 = (float)Main.rand.Next(-30, 35);
float random3 = (float)Main.rand.Next(13, 18);
float randomAdjust = (float)Math.Sqrt((double)(random1 * random1 + random2 * random2));
randomAdjust = random3 / randomAdjust;
random1 *= randomAdjust;
random2 *= randomAdjust;
int redDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Firework_Red, 0f, 0f, 100, default, 1.25f);
Dust dust = Main.dust[redDust];
dust.noGravity = true;
dust.position.X = Projectile.Center.X;
dust.position.Y = Projectile.Center.Y;
dust.position.X += (float)Main.rand.Next(-10, 11);
dust.position.Y += (float)Main.rand.Next(-10, 11);
dust.velocity.X = random1;
dust.velocity.Y = random2;
timerCompare++;
}
}
}
}