132 lines
5.3 KiB
C#
132 lines
5.3 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using CalamityMod.Dusts;
|
|
using CalamityMod.Buffs.DamageOverTime;
|
|
|
|
namespace CalamityMod.Projectiles.Rogue
|
|
{
|
|
public class RegulusEnergy : ModProjectile
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Regulus Energy");
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
projectile.width = 8;
|
|
projectile.height = 8;
|
|
projectile.friendly = true;
|
|
projectile.penetrate = 1;
|
|
projectile.tileCollide = false;
|
|
projectile.Calamity().rogue = true;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
int num154 = 14;
|
|
int coolDust;
|
|
projectile.ai[0] += 1;
|
|
if (projectile.ai[0] % 2 == 0)
|
|
{
|
|
if (projectile.ai[0] % 4 == 0)
|
|
{
|
|
coolDust = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width - num154 * 2, projectile.height - num154 * 2, ModContent.DustType<AstralBlue>(), 0f, 0f, 100, default, 1.5f);
|
|
}
|
|
else
|
|
{
|
|
coolDust = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width - num154 * 2, projectile.height - num154 * 2, ModContent.DustType<AstralOrange>(), 0f, 0f, 100, default, 1.5f);
|
|
}
|
|
Main.dust[coolDust].noGravity = true;
|
|
Main.dust[coolDust].velocity *= 0.1f;
|
|
Main.dust[coolDust].velocity += projectile.velocity * 0.5f;
|
|
}
|
|
if (projectile.ai[0] < 90)
|
|
{
|
|
projectile.velocity.X *= 0.98f;
|
|
projectile.velocity.Y *= 0.98f;
|
|
}
|
|
else
|
|
{
|
|
projectile.extraUpdates = 1;
|
|
|
|
float num472 = projectile.Center.X;
|
|
float num473 = projectile.Center.Y;
|
|
float num474 = 500f;
|
|
bool flag17 = false;
|
|
|
|
for (int num475 = 0; num475 < 200; num475++)
|
|
{
|
|
if (Main.npc[num475].CanBeChasedBy(projectile, false))
|
|
{
|
|
float num476 = Main.npc[num475].position.X + (float)(Main.npc[num475].width / 2);
|
|
float num477 = Main.npc[num475].position.Y + (float)(Main.npc[num475].height / 2);
|
|
float num478 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num476) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num477);
|
|
if (num478 < num474)
|
|
{
|
|
num474 = num478;
|
|
num472 = num476;
|
|
num473 = num477;
|
|
flag17 = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (flag17)
|
|
{
|
|
float num483 = 12f;
|
|
Vector2 vector35 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f);
|
|
float num484 = num472 - vector35.X;
|
|
float num485 = num473 - vector35.Y;
|
|
float num486 = (float)Math.Sqrt((double)(num484 * num484 + num485 * num485));
|
|
num486 = num483 / num486;
|
|
num484 *= num486;
|
|
num485 *= num486;
|
|
projectile.velocity.X = (projectile.velocity.X * 20f + num484) / 21f;
|
|
projectile.velocity.Y = (projectile.velocity.Y * 20f + num485) / 21f;
|
|
}
|
|
else
|
|
projectile.Kill();
|
|
}
|
|
|
|
projectile.rotation += 0.25f;
|
|
}
|
|
|
|
public override bool CanDamage()
|
|
{
|
|
return projectile.ai[0] >= 90;
|
|
}
|
|
|
|
public override void Kill(int timeLeft)
|
|
{
|
|
projectile.position = projectile.Center;
|
|
projectile.width = projectile.height = 24;
|
|
projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
|
|
projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);
|
|
int num226 = 36;
|
|
for (int num227 = 0; num227 < num226; num227++)
|
|
{
|
|
Vector2 vector6 = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f;
|
|
vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + projectile.Center;
|
|
Vector2 vector7 = vector6 - projectile.Center;
|
|
int num228 = Dust.NewDust(vector6 + vector7, 0, 0, ModContent.DustType<AstralOrange>(), vector7.X * 0.5f, vector7.Y * 0.5f, 100, default, 0.75f);
|
|
Main.dust[num228].noGravity = true;
|
|
}
|
|
}
|
|
|
|
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
|
{
|
|
target.AddBuff(ModContent.BuffType<AstralInfectionDebuff>(), 60);
|
|
}
|
|
|
|
public override void OnHitPvp(Player target, int damage, bool crit)
|
|
{
|
|
target.AddBuff(ModContent.BuffType<AstralInfectionDebuff>(), 60);
|
|
}
|
|
}
|
|
}
|