Files
CalamityModPublic/Projectiles/Rogue/CelestusBoomerang.cs
T

152 lines
6.7 KiB
C#

using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Buffs.StatDebuffs;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class CelestusBoomerang : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Celestus");
ProjectileID.Sets.TrailCacheLength[projectile.type] = 8;
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
}
public override void SetDefaults()
{
projectile.width = 94;
projectile.height = 94;
projectile.friendly = true;
projectile.tileCollide = false;
projectile.penetrate = -1;
projectile.extraUpdates = 3;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 30;
projectile.Calamity().rogue = true;
}
public override void AI()
{
Lighting.AddLight(projectile.Center, Main.DiscoR * 0.5f / 255f, Main.DiscoG * 0.5f / 255f, Main.DiscoB * 0.5f / 255f);
if (projectile.soundDelay == 0)
{
projectile.soundDelay = 8;
Main.PlaySound(SoundID.Item7, projectile.position);
}
if (projectile.ai[0] == 0f)
{
projectile.ai[1] += 1f;
if (projectile.ai[1] >= 40f)
{
projectile.ai[0] = 1f;
projectile.ai[1] = 0f;
projectile.netUpdate = true;
}
}
else
{
float num42 = 25f;
float num43 = 5f;
Vector2 vector2 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f);
float num44 = Main.player[projectile.owner].position.X + (float)(Main.player[projectile.owner].width / 2) - vector2.X;
float num45 = Main.player[projectile.owner].position.Y + (float)(Main.player[projectile.owner].height / 2) - vector2.Y;
float num46 = (float)Math.Sqrt((double)(num44 * num44 + num45 * num45));
if (num46 > 4000f)
{
projectile.Kill();
}
num46 = num42 / num46;
num44 *= num46;
num45 *= num46;
if (projectile.velocity.X < num44)
{
projectile.velocity.X = projectile.velocity.X + num43;
if (projectile.velocity.X < 0f && num44 > 0f)
{
projectile.velocity.X = projectile.velocity.X + num43;
}
}
else if (projectile.velocity.X > num44)
{
projectile.velocity.X = projectile.velocity.X - num43;
if (projectile.velocity.X > 0f && num44 < 0f)
{
projectile.velocity.X = projectile.velocity.X - num43;
}
}
if (projectile.velocity.Y < num45)
{
projectile.velocity.Y = projectile.velocity.Y + num43;
if (projectile.velocity.Y < 0f && num45 > 0f)
{
projectile.velocity.Y = projectile.velocity.Y + num43;
}
}
else if (projectile.velocity.Y > num45)
{
projectile.velocity.Y = projectile.velocity.Y - num43;
if (projectile.velocity.Y > 0f && num45 < 0f)
{
projectile.velocity.Y = projectile.velocity.Y - num43;
}
}
if (Main.myPlayer == projectile.owner)
{
Rectangle rectangle = new Rectangle((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height);
Rectangle value2 = new Rectangle((int)Main.player[projectile.owner].position.X, (int)Main.player[projectile.owner].position.Y, Main.player[projectile.owner].width, Main.player[projectile.owner].height);
if (rectangle.Intersects(value2))
{
projectile.Kill();
}
}
}
projectile.rotation += 1f;
}
public override Color? GetAlpha(Color lightColor)
{
return new Color(250, 250, 250, 50);
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
target.AddBuff(ModContent.BuffType<ExoFreeze>(), 30);
target.AddBuff(ModContent.BuffType<BrimstoneFlames>(), 120);
target.AddBuff(ModContent.BuffType<GlacialState>(), 120);
target.AddBuff(ModContent.BuffType<Plague>(), 120);
target.AddBuff(ModContent.BuffType<HolyFlames>(), 120);
target.AddBuff(BuffID.CursedInferno, 120);
target.AddBuff(BuffID.Frostburn, 120);
target.AddBuff(BuffID.OnFire, 120);
target.AddBuff(BuffID.Ichor, 120);
if (projectile.owner == Main.myPlayer)
{
float spread = 45f * 0.0174f;
double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2;
double deltaAngle = spread / 8f;
double offsetAngle;
int i;
for (i = 0; i < 4; i++)
{
offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i;
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 2f), (float)(Math.Cos(offsetAngle) * 2f), ModContent.ProjectileType<Celestus2>(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 2f), (float)(-Math.Cos(offsetAngle) * 2f), ModContent.ProjectileType<Celestus2>(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
}
}
Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 122);
}
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
{
CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1);
return false;
}
}
}