100 lines
3.9 KiB
C#
100 lines
3.9 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.Audio;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
namespace CalamityMod.Projectiles.Rogue
|
|
{
|
|
public class SphereBlue : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Rogue";
|
|
public override void SetStaticDefaults()
|
|
{
|
|
ProjectileID.Sets.CultistIsResistantTo[Type] = true;
|
|
ProjectileID.Sets.TrailCacheLength[Type] = 10;
|
|
ProjectileID.Sets.TrailingMode[Type] = 0;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 20;
|
|
Projectile.height = 20;
|
|
Projectile.friendly = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.penetrate = 1;
|
|
Projectile.timeLeft = 300;
|
|
Projectile.tileCollide = false;
|
|
Projectile.DamageType = RogueDamageClass.Instance;
|
|
Projectile.extraUpdates = 1;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Lighting.AddLight(Projectile.Center, 0f, 0f, 1f);
|
|
if (Main.rand.NextBool(5))
|
|
{
|
|
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Vortex, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 100);
|
|
}
|
|
Projectile.ai[0] += 1f;
|
|
if (Projectile.ai[0] >= 5f)
|
|
{
|
|
Projectile.tileCollide = true;
|
|
}
|
|
Projectile.rotation += Projectile.velocity.X * 0.02f;
|
|
Projectile.velocity.Y = Projectile.velocity.Y + 0.085f;
|
|
Projectile.velocity.X = Projectile.velocity.X * 0.99f;
|
|
CalamityUtils.HomeInOnNPC(Projectile, true, 300f, 12f, 20f);
|
|
}
|
|
|
|
public override void OnKill(int timeLeft)
|
|
{
|
|
Projectile.position = Projectile.Center;
|
|
Projectile.width = Projectile.height = 192;
|
|
Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2);
|
|
Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2);
|
|
Projectile.maxPenetrate = -1;
|
|
Projectile.penetrate = -1;
|
|
Projectile.usesLocalNPCImmunity = true;
|
|
Projectile.localNPCHitCooldown = 10;
|
|
Projectile.damage /= 2;
|
|
Projectile.Damage();
|
|
SoundEngine.PlaySound(SoundID.NPCDeath37, Projectile.position);
|
|
if (!Main.dedServ)
|
|
{
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
float scaleFactor10 = 0.33f;
|
|
if (i == 1)
|
|
{
|
|
scaleFactor10 = 0.66f;
|
|
}
|
|
if (i == 2)
|
|
{
|
|
scaleFactor10 = 1f;
|
|
}
|
|
int defectiveBruh = Gore.NewGore(Projectile.GetSource_Death(), new Vector2(Projectile.position.X + (float)(Projectile.width / 2) - 24f, Projectile.position.Y + (float)(Projectile.height / 2) - 24f), default, Main.rand.Next(660, 662), 1f);
|
|
Main.gore[defectiveBruh].velocity *= scaleFactor10;
|
|
Main.gore[defectiveBruh].velocity += Projectile.velocity;
|
|
}
|
|
}
|
|
for (int j = 0; j < 25; j++)
|
|
{
|
|
int dustType = Utils.SelectRandom(Main.rand, new int[]
|
|
{
|
|
226,
|
|
229
|
|
});
|
|
int dusty = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 1f);
|
|
Main.dust[dusty].noGravity = true;
|
|
Main.dust[dusty].velocity *= 0f;
|
|
}
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1);
|
|
return false;
|
|
}
|
|
}
|
|
}
|