Files
CalamityModPublic/Projectiles/Rogue/DragonShit.cs
T

148 lines
6.9 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class DragonShit : ModProjectile
{
public NPC target;
public Vector2 rotationVector = Vector2.UnitY * -13f;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Fire");
Main.projFrames[projectile.type] = 4;
}
public override void SetDefaults()
{
projectile.width = 30;
projectile.height = 30;
projectile.scale = 1f;
projectile.friendly = true;
projectile.ignoreWater = true;
projectile.tileCollide = false;
projectile.penetrate = 1;
projectile.timeLeft = 420;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = -1;
projectile.Calamity().rogue = true;
cooldownSlot = 1;
}
public override void AI()
{
target = projectile.Center.ClosestNPCAt(1200f);
if (projectile.localAI[0] == 0f)
{
projectile.ai[0] = Utils.SelectRandom(Main.rand, -1f, 1f);
projectile.localAI[0] = 1f;
}
projectile.frameCounter++;
if (projectile.frameCounter > 4)
{
projectile.frame++;
projectile.frameCounter = 0;
}
if (projectile.frame > 3)
{
projectile.frame = 0;
}
if (projectile.timeLeft >= 380)
{
projectile.velocity *= 1.07f;
}
else if (target != null)
{
projectile.velocity = (projectile.velocity * 23f + projectile.DirectionTo(target.Center) * 14.975f) / 24f;
}
else
{
projectile.timeLeft = Math.Min(projectile.timeLeft, 15);
projectile.alpha += 17;
projectile.velocity = rotationVector;
rotationVector = rotationVector.RotatedBy(MathHelper.ToRadians(14.975f * projectile.ai[0]));
}
}
public override Color? GetAlpha(Color lightColor)
{
return new Color(255, Main.DiscoG, 53, projectile.alpha);
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
Texture2D projectileTexture = Main.projectileTexture[projectile.type];
int frameHeight = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type];
int frameY = frameHeight * projectile.frame;
Main.spriteBatch.Draw(projectileTexture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameY, projectileTexture.Width, frameHeight)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)projectileTexture.Width / 2f, (float)frameHeight / 2f), projectile.scale, SpriteEffects.None, 0f);
return false;
}
public override void Kill(int timeLeft)
{
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 14);
projectile.position = projectile.Center;
projectile.width = projectile.height = 80;
projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);
for (int num621 = 0; num621 < 5; num621++)
{
int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f);
Main.dust[num622].velocity *= 3f;
if (Main.rand.NextBool(2))
{
Main.dust[num622].scale = 0.5f;
Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f;
}
}
for (int num623 = 0; num623 < 8; num623++)
{
int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f);
Main.dust[num624].noGravity = true;
Main.dust[num624].velocity *= 5f;
num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f);
Main.dust[num624].velocity *= 2f;
}
for (int num625 = 0; num625 < 3; num625++)
{
float scaleFactor10 = 0.33f;
if (num625 == 1)
{
scaleFactor10 = 0.66f;
}
if (num625 == 2)
{
scaleFactor10 = 1f;
}
int num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f);
Main.gore[num626].velocity *= scaleFactor10;
Gore expr_13AB6_cp_0 = Main.gore[num626];
expr_13AB6_cp_0.velocity.X += 1f;
Gore expr_13AD6_cp_0 = Main.gore[num626];
expr_13AD6_cp_0.velocity.Y += 1f;
num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f);
Main.gore[num626].velocity *= scaleFactor10;
Gore expr_13B79_cp_0 = Main.gore[num626];
expr_13B79_cp_0.velocity.X -= 1f;
Gore expr_13B99_cp_0 = Main.gore[num626];
expr_13B99_cp_0.velocity.Y += 1f;
num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f);
Main.gore[num626].velocity *= scaleFactor10;
Gore expr_13C3C_cp_0 = Main.gore[num626];
expr_13C3C_cp_0.velocity.X += 1f;
Gore expr_13C5C_cp_0 = Main.gore[num626];
expr_13C5C_cp_0.velocity.Y -= 1f;
num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f);
Main.gore[num626].velocity *= scaleFactor10;
Gore expr_13CFF_cp_0 = Main.gore[num626];
expr_13CFF_cp_0.velocity.X -= 1f;
Gore expr_13D1F_cp_0 = Main.gore[num626];
expr_13D1F_cp_0.velocity.Y -= 1f;
}
projectile.Damage();
}
}
}