93 lines
3.3 KiB
C#
93 lines
3.3 KiB
C#
using CalamityMod.Buffs.DamageOverTime;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Magic
|
|
{
|
|
public class ShadeNimbus : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Magic";
|
|
public override string Texture => "CalamityMod/Projectiles/Boss/ShadeNimbusHostile";
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
Main.projFrames[Projectile.type] = 6;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 54;
|
|
Projectile.height = 24;
|
|
Projectile.tileCollide = false;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.penetrate = -1;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Projectile.frameCounter++;
|
|
if (Projectile.frameCounter > 8)
|
|
{
|
|
Projectile.frameCounter = 0;
|
|
Projectile.frame++;
|
|
if (Projectile.frame >= Main.projFrames[Projectile.type])
|
|
{
|
|
Projectile.frame = 0;
|
|
}
|
|
}
|
|
Projectile.ai[1] += 1f;
|
|
if (Projectile.ai[1] >= 7200f)
|
|
{
|
|
Projectile.alpha += 5;
|
|
if (Projectile.alpha > 255)
|
|
{
|
|
Projectile.alpha = 255;
|
|
Projectile.Kill();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Projectile.ai[0] += 1f;
|
|
if (Projectile.ai[0] > 8f)
|
|
{
|
|
Projectile.ai[0] = 0f;
|
|
if (Projectile.owner == Main.myPlayer)
|
|
{
|
|
int rainX = (int)(Projectile.position.X + 14f + (float)Main.rand.Next(Projectile.width - 28));
|
|
int rainY = (int)(Projectile.position.Y + (float)Projectile.height + 4f);
|
|
Projectile.NewProjectile(Projectile.GetSource_FromThis(), (float)rainX, (float)rainY, 0f, 5f, ModContent.ProjectileType<Shaderain>(), Projectile.damage, 0f, Projectile.owner, 0f, 0f);
|
|
}
|
|
}
|
|
}
|
|
Projectile.localAI[0] += 1f;
|
|
if (Projectile.localAI[0] >= 10f)
|
|
{
|
|
Projectile.localAI[0] = 0f;
|
|
int projCount = 0;
|
|
int oldestCloud = 0;
|
|
float cloudAge = 0f;
|
|
int projType = Projectile.type;
|
|
for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++)
|
|
{
|
|
Projectile proj = Main.projectile[projIndex];
|
|
if (proj.active && proj.owner == Projectile.owner && proj.type == projType && proj.ai[1] < 3600f)
|
|
{
|
|
projCount++;
|
|
if (proj.ai[1] > cloudAge)
|
|
{
|
|
oldestCloud = projIndex;
|
|
cloudAge = proj.ai[1];
|
|
}
|
|
}
|
|
}
|
|
if (projCount > 2)
|
|
{
|
|
Main.projectile[oldestCloud].netUpdate = true;
|
|
Main.projectile[oldestCloud].ai[1] = 36000f;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|