cleaned up Terra Disk code

This commit is contained in:
termigator1359 authored and Cameron Ewell committed 2020-12-03 01:10:20 -05:00
1 parent ff264d5d27
commit 83140f3d44
2 files changed
+36 -50

No files matched your search

+2 -4
View File
@@ -85,10 +85,8 @@ namespace CalamityMod.Projectiles.Rogue
for (int i = 0; i < 4; i++)
{
offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i;
int disk = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), splitProj, projectile.damage, projectile.knockBack, projectile.owner);
Main.projectile[disk].Calamity().forceRogue = true;
int disk2 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), splitProj, projectile.damage, projectile.knockBack, projectile.owner);
Main.projectile[disk2].Calamity().forceRogue = true;
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), splitProj, projectile.damage, projectile.knockBack, projectile.owner);
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), splitProj, projectile.damage, projectile.knockBack, projectile.owner);
}
}
}
+34 -46
View File
@@ -20,16 +20,15 @@ namespace CalamityMod.Projectiles.Rogue
public override void SetDefaults()
{
projectile.width = 46;
projectile.height = 46;
projectile.width = projectile.height = 46;
projectile.friendly = true;
projectile.tileCollide = false;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 10;
projectile.penetrate = -1;
projectile.aiStyle = 3;
projectile.timeLeft = 180;
aiType = ProjectileID.WoodenBoomerang;
projectile.timeLeft = 180;
projectile.Calamity().rogue = true;
}
@@ -38,60 +37,49 @@ namespace CalamityMod.Projectiles.Rogue
Lighting.AddLight(projectile.Center, 0f, (255 - projectile.alpha) * 0.75f / 255f, 0f);
if (Main.rand.NextBool(5))
Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 107, projectile.velocity.X, projectile.velocity.Y);
int[] array = new int[20];
int num428 = 0;
float num429 = 300f;
bool flag14 = false;
for (int num430 = 0; num430 < 200; num430++)
float maxDistance = 300f;
bool homeIn = false;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[num430].CanBeChasedBy(projectile, false))
NPC npc = Main.npc[i];
if (npc.CanBeChasedBy(projectile, false))
{
float num431 = Main.npc[num430].position.X + Main.npc[num430].width / 2;
float num432 = Main.npc[num430].position.Y + Main.npc[num430].height / 2;
float num433 = Math.Abs(projectile.position.X + projectile.width / 2 - num431) + Math.Abs(projectile.position.Y + projectile.height / 2 - num432);
if (num433 < num429 && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1))
float extraDistance = npc.width / 2 + npc.height / 2;
bool canHit = true;
if (extraDistance < maxDistance)
canHit = Collision.CanHit(projectile.Center, 1, 1, npc.Center, 1, 1);
if (Vector2.Distance(npc.Center, projectile.Center) < maxDistance + extraDistance && canHit)
{
if (num428 < 20)
{
array[num428] = num430;
num428++;
}
flag14 = true;
homeIn = true;
break;
}
}
}
if (flag14)
if (!projectile.friendly)
homeIn = false;
if (homeIn)
{
int num434 = Main.rand.Next(num428);
num434 = array[num434];
float num435 = Main.npc[num434].position.X + Main.npc[num434].width / 2;
float num436 = Main.npc[num434].position.Y + Main.npc[num434].height / 2;
projectile.localAI[0] += 1f;
if (projectile.localAI[0] > 8f)
if (projectile.localAI[0] % 8f == 0f && Main.rand.NextBool(5))
{
projectile.localAI[0] = 0f;
float num437 = 6f;
Vector2 value10 = new Vector2(projectile.position.X + projectile.width * 0.5f, projectile.position.Y + projectile.height * 0.5f);
value10 += projectile.velocity * 4f;
float num438 = num435 - value10.X;
float num439 = num436 - value10.Y;
float num440 = (float)Math.Sqrt(num438 * num438 + num439 * num439);
num440 = num437 / num440;
if (Main.rand.NextBool(5))
int splitProj = ModContent.ProjectileType<TerraDiskProjectile2>();
if (projectile.owner == Main.myPlayer)
{
if (projectile.owner == Main.myPlayer)
float spread = 60f * 0.0174f;
double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2;
double deltaAngle = spread / 6f;
double offsetAngle;
for (int i = 0; i < 3; i++)
{
float spread = 60f * 0.0174f;
double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2;
double deltaAngle = spread / 6f;
double offsetAngle;
int i;
for (i = 0; i < 3; i++)
{
offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i;
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType<TerraDiskProjectile2>(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType<TerraDiskProjectile2>(), projectile.damage / 2, projectile.knockBack, projectile.owner, 0f, 0f);
}
offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i;
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), splitProj, projectile.damage / 2, projectile.knockBack / 2f, projectile.owner);
Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), splitProj, projectile.damage / 2, projectile.knockBack / 2f, projectile.owner);
}
}
}