From 5d196e38b45563f288e1ef9e6a8d757a14d19d4e Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Thu, 27 Feb 2020 22:27:13 -0500 Subject: [PATCH] more homing shit --- Projectiles/CalamityGlobalProjectile.cs | 5 +- .../Melee/EradicatorMeleeProjectile.cs | 52 +------------------ Projectiles/Rogue/AccretionDiskProj.cs | 52 +++++++++++-------- Projectiles/Rogue/EradicatorProjectile.cs | 52 +------------------ 4 files changed, 35 insertions(+), 126 deletions(-) diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 891ad1a274..0488b644d1 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -2085,8 +2085,11 @@ namespace CalamityMod.Projectiles int projectile2 = Projectile.NewProjectile(value.X, value.Y, velocity.X, velocity.Y, spawnedProjectile, (int)(projectile.damage * damageMult), projectile.knockBack, projectile.owner, 0f, 0f); if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) Main.projectile[projectile2].Calamity().forceMelee = true; + + if (projectile.type == ModContent.ProjectileType()) + Main.projectile[projectile2].Calamity().forceRogue = true; } } } diff --git a/Projectiles/Melee/EradicatorMeleeProjectile.cs b/Projectiles/Melee/EradicatorMeleeProjectile.cs index 07ac5a1d15..ca48fc1b51 100644 --- a/Projectiles/Melee/EradicatorMeleeProjectile.cs +++ b/Projectiles/Melee/EradicatorMeleeProjectile.cs @@ -35,57 +35,7 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Lighting.AddLight(projectile.Center, 0.35f, 0f, 0.25f); - int[] array = new int[20]; - int num428 = 0; - float num429 = 300f; - bool flag14 = false; - for (int num430 = 0; num430 < 200; num430++) - { - if (Main.npc[num430].CanBeChasedBy(projectile, false)) - { - float num431 = Main.npc[num430].position.X + (float)(Main.npc[num430].width / 2); - float num432 = Main.npc[num430].position.Y + (float)(Main.npc[num430].height / 2); - float num433 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num431) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num432); - if (num433 < num429 && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1)) - { - if (num428 < 20) - { - array[num428] = num430; - num428++; - } - flag14 = true; - } - } - } - if (flag14) - { - int num434 = Main.rand.Next(num428); - num434 = array[num434]; - float num435 = Main.npc[num434].position.X + (float)(Main.npc[num434].width / 2); - float num436 = Main.npc[num434].position.Y + (float)(Main.npc[num434].height / 2); - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 8f) - { - projectile.localAI[0] = 0f; - float num437 = 6f; - Vector2 value10 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - value10 += projectile.velocity * 4f; - float num438 = num435 - value10.X; - float num439 = num436 - value10.Y; - float num440 = (float)Math.Sqrt((double)(num438 * num438 + num439 * num439)); - num440 = num437 / num440; - num438 *= num440; - num439 *= num440; - if (Main.rand.NextBool(2)) - { - if (projectile.owner == Main.myPlayer) - { - int proj = Projectile.NewProjectile(value10.X, value10.Y, num438, num439, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceMelee = true; - } - } - } - } + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 8f, 20, ModContent.ProjectileType()); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Rogue/AccretionDiskProj.cs b/Projectiles/Rogue/AccretionDiskProj.cs index d3154692e5..336f01d513 100644 --- a/Projectiles/Rogue/AccretionDiskProj.cs +++ b/Projectiles/Rogue/AccretionDiskProj.cs @@ -45,29 +45,35 @@ namespace CalamityMod.Projectiles.Rogue } } Lighting.AddLight(projectile.Center, 0.15f, 1f, 0.25f); - int[] array = new int[20]; - int num428 = 0; - float num429 = 300f; - bool flag14 = false; - for (int num430 = 0; num430 < 200; num430++) - { - if (Main.npc[num430].CanBeChasedBy(projectile, false)) - { - float num431 = Main.npc[num430].position.X + (float)(Main.npc[num430].width / 2); - float num432 = Main.npc[num430].position.Y + (float)(Main.npc[num430].height / 2); - float num433 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num431) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num432); - if (num433 < num429 && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1)) - { - if (num428 < 20) - { - array[num428] = num430; - num428++; - } - flag14 = true; - } - } - } - if (flag14) + + int[] array = new int[20]; + int num428 = 0; + float distance = 300f; + bool flag14 = false; + for (int num430 = 0; num430 < 200; num430++) + { + if (Main.npc[num430].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[num430].width / 2) + (float)(Main.npc[num430].height / 2); + + bool useCollisionDetection = extraDistance < distance; + bool canHit = true; + if (useCollisionDetection) + canHit = Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1); + + if (Vector2.Distance(Main.npc[num430].Center, projectile.Center) < (distance + extraDistance) && canHit) + { + if (num428 < 20) + { + array[num428] = num430; + num428++; + } + flag14 = true; + } + } + } + + if (flag14) { int num434 = Main.rand.Next(num428); num434 = array[num434]; diff --git a/Projectiles/Rogue/EradicatorProjectile.cs b/Projectiles/Rogue/EradicatorProjectile.cs index 027216cc98..7aabaa17cd 100644 --- a/Projectiles/Rogue/EradicatorProjectile.cs +++ b/Projectiles/Rogue/EradicatorProjectile.cs @@ -35,57 +35,7 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { Lighting.AddLight(projectile.Center, 0.35f, 0f, 0.25f); - int[] array = new int[20]; - int num428 = 0; - float num429 = 300f; - bool flag14 = false; - for (int num430 = 0; num430 < 200; num430++) - { - if (Main.npc[num430].CanBeChasedBy(projectile, false)) - { - float num431 = Main.npc[num430].position.X + (float)(Main.npc[num430].width / 2); - float num432 = Main.npc[num430].position.Y + (float)(Main.npc[num430].height / 2); - float num433 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num431) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num432); - if (num433 < num429 && Collision.CanHit(projectile.Center, 1, 1, Main.npc[num430].Center, 1, 1)) - { - if (num428 < 20) - { - array[num428] = num430; - num428++; - } - flag14 = true; - } - } - } - if (flag14) - { - int num434 = Main.rand.Next(num428); - num434 = array[num434]; - float num435 = Main.npc[num434].position.X + (float)(Main.npc[num434].width / 2); - float num436 = Main.npc[num434].position.Y + (float)(Main.npc[num434].height / 2); - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 8f) - { - projectile.localAI[0] = 0f; - float num437 = 6f; - Vector2 value10 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - value10 += projectile.velocity * 4f; - float num438 = num435 - value10.X; - float num439 = num436 - value10.Y; - float num440 = (float)Math.Sqrt((double)(num438 * num438 + num439 * num439)); - num440 = num437 / num440; - num438 *= num440; - num439 *= num440; - if (Main.rand.NextBool(2)) - { - if (projectile.owner == Main.myPlayer) - { - int proj = Projectile.NewProjectile(value10.X, value10.Y, num438, num439, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[proj].Calamity().forceRogue = true; - } - } - } - } + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 8f, 20, ModContent.ProjectileType()); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)