diff --git a/Projectiles/Boss/OldDukeGore.cs b/Projectiles/Boss/OldDukeGore.cs index e51fb94960..fde7c930d7 100644 --- a/Projectiles/Boss/OldDukeGore.cs +++ b/Projectiles/Boss/OldDukeGore.cs @@ -50,13 +50,13 @@ namespace CalamityMod.Projectiles.Boss projectile.rotation += projectile.velocity.X * 0.1f; - int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 5, 0f, 0f, 100, default, 1f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + int blood = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Blood, 0f, 0f, 100, default, 1f); + Main.dust[blood].noGravity = true; + Main.dust[blood].velocity *= 0f; - int num470 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 1f); - Main.dust[num470].noGravity = true; - Main.dust[num470].velocity *= 0f; + int acid = Dust.NewDust(projectile.position, projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 1f); + Main.dust[acid].noGravity = true; + Main.dust[acid].velocity *= 0f; } public override void Kill(int timeLeft) @@ -66,23 +66,23 @@ namespace CalamityMod.Projectiles.Boss int num226 = 8; 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, 5, vector7.X, vector7.Y, 100, default, 1.2f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 source = Vector2.Normalize(projectile.velocity) * new Vector2((float)projectile.width / 2f, (float)projectile.height) * 0.75f; + source = source.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * 6.28318548f / (float)num226), default) + projectile.Center; + Vector2 dustVel = source - projectile.Center; + int blood = Dust.NewDust(source + dustVel, 0, 0, DustID.Blood, dustVel.X, dustVel.Y, 100, default, 1.2f); + Main.dust[blood].noGravity = true; + Main.dust[blood].noLight = true; + Main.dust[blood].velocity = dustVel; } - for (int num623 = 0; num623 < 6; num623++) + for (int d = 0; d < 6; d++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default(Color), 3f); - 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, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default(Color), 2f); - Main.dust[num624].velocity *= 2f; - Main.dust[num624].noGravity = true; + int acid = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default(Color), 3f); + Main.dust[acid].noGravity = true; + Main.dust[acid].velocity *= 5f; + acid = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default(Color), 2f); + Main.dust[acid].velocity *= 2f; + Main.dust[acid].noGravity = true; } } diff --git a/Projectiles/Rogue/ShroomerangSpore.cs b/Projectiles/Rogue/ShroomerangSpore.cs index 66cf5ec7b6..69c919e116 100644 --- a/Projectiles/Rogue/ShroomerangSpore.cs +++ b/Projectiles/Rogue/ShroomerangSpore.cs @@ -36,165 +36,12 @@ namespace CalamityMod.Projectiles.Rogue } Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0f / 255f, (255 - projectile.alpha) * 0.35f / 255f, (255 - projectile.alpha) * 0.5f / 255f); - scaleFactor++; - if (scaleFactor >= 90) - { - scaleFactor *= -1; - } - if (scaleFactor >= 0) - { - projectile.scale += 0.003f; - } - else - { - projectile.scale -= 0.003f; - } - projectile.rotation += 0.0025f * projectile.scale; - float num945 = 1f; - float num946 = 1f; - if (projectile.identity % 6 == 0) - { - num946 *= -1f; - } - if (projectile.identity % 6 == 1) - { - num945 *= -1f; - } - if (projectile.identity % 6 == 2) - { - num946 *= -1f; - num945 *= -1f; - } - if (projectile.identity % 6 == 3) - { - num946 = 0f; - } - if (projectile.identity % 6 == 4) - { - num945 = 0f; - } - projectile.localAI[1] += 1f; - if (projectile.localAI[1] > 60f) - { - projectile.localAI[1] = -180f; - } - if (projectile.localAI[1] >= -60f) - { - projectile.velocity.X = projectile.velocity.X + 0.002f * num946; - projectile.velocity.Y = projectile.velocity.Y + 0.002f * num945; - } - else - { - projectile.velocity.X = projectile.velocity.X - 0.002f * num946; - projectile.velocity.Y = projectile.velocity.Y - 0.002f * num945; - } - projectile.ai[0] += 1f; - if (projectile.ai[0] > 5400f) - { - projectile.damage = 0; - projectile.ai[1] = 1f; - if (projectile.alpha < 255) - { - projectile.alpha += 5; - if (projectile.alpha > 255) - { - projectile.alpha = 255; - } - } - else if (projectile.owner == Main.myPlayer) - { - projectile.Kill(); - } - } - else - { - float num947 = (projectile.Center - Main.player[projectile.owner].Center).Length() / 100f; - if (num947 > 4f) - { - num947 *= 1.1f; - } - if (num947 > 5f) - { - num947 *= 1.2f; - } - if (num947 > 6f) - { - num947 *= 1.3f; - } - if (num947 > 7f) - { - num947 *= 1.4f; - } - if (num947 > 8f) - { - num947 *= 1.5f; - } - if (num947 > 9f) - { - num947 *= 1.6f; - } - if (num947 > 10f) - { - num947 *= 1.7f; - } - projectile.ai[0] += num947; - if (projectile.alpha > 50) - { - projectile.alpha -= 10; - if (projectile.alpha < 50) - { - projectile.alpha = 50; - } - } - } - if (projectile.Calamity().lineColor != 1 || projectile.timeLeft < (3300 + projectile.localAI[0])) - { - bool flag49 = false; - Vector2 center12 = new Vector2(0f, 0f); - float num948 = 600f; - for (int num949 = 0; num949 < Main.maxNPCs; num949++) - { - if (Main.npc[num949].CanBeChasedBy(projectile, false)) - { - float num950 = Main.npc[num949].position.X + (float)(Main.npc[num949].width / 2); - float num951 = Main.npc[num949].position.Y + (float)(Main.npc[num949].height / 2); - float num952 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num950) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num951); - if (num952 < num948) - { - num948 = num952; - center12 = Main.npc[num949].Center; - flag49 = true; - } - } - } - if (flag49) - { - if (projectile.Calamity().lineColor == 1) - projectile.extraUpdates = 5; - - Vector2 vector101 = center12 - projectile.Center; - vector101.Normalize(); - vector101 *= 0.75f; - projectile.velocity = (projectile.velocity * 10f + vector101) / 11f; - return; - } - else - { - projectile.extraUpdates = 0; - } - } - if ((double)projectile.velocity.Length() > 0.2) - { - projectile.velocity *= 0.98f; - } + projectile.SporeSacAI(); } public override void Kill(int timeLeft) { - projectile.position = projectile.Center; - projectile.width = projectile.height = 56; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 56); int num226 = 36; for (int num227 = 0; num227 < num226; num227++) { diff --git a/Projectiles/Summon/ApexShark.cs b/Projectiles/Summon/ApexShark.cs index c195f32f2b..d7bb437c32 100644 --- a/Projectiles/Summon/ApexShark.cs +++ b/Projectiles/Summon/ApexShark.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Summon 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, 67, vector7.X * 1.75f, vector7.Y * 1.75f, 100, default, 1.1f); + int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 85, vector7.X * 1.75f, vector7.Y * 1.75f, 100, default, 1.1f); Main.dust[num228].noGravity = true; Main.dust[num228].velocity = vector7; } diff --git a/Projectiles/Typeless/KelvinCatalystStar.cs b/Projectiles/Typeless/KelvinCatalystStar.cs index 72092691cf..1610ad77a6 100644 --- a/Projectiles/Typeless/KelvinCatalystStar.cs +++ b/Projectiles/Typeless/KelvinCatalystStar.cs @@ -38,41 +38,33 @@ namespace CalamityMod.Projectiles.Typeless { projectile.extraUpdates = 1; - float num472 = projectile.Center.X; - float num473 = projectile.Center.Y; - float num474 = 500f; - bool flag17 = false; + Vector2 center = projectile.Center; + float maxDistance = 500f; + bool homeIn = 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; - } - } - } + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(projectile, false)) + { + float extraDistance = (float)(Main.npc[i].width / 2) + (float)(Main.npc[i].height / 2); - 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; - } + if (Vector2.Distance(Main.npc[i].Center, projectile.Center) < (maxDistance + extraDistance) && Collision.CanHit(projectile.Center, 1, 1, Main.npc[i].Center, 1, 1)) + { + center = Main.npc[i].Center; + homeIn = true; + break; + } + } + } + + if (homeIn) + { + Vector2 homeInVector = projectile.DirectionTo(center); + if (homeInVector.HasNaNs()) + homeInVector = Vector2.UnitY; + + projectile.velocity = (projectile.velocity * 20f + homeInVector * 12f) / (21f); + } else projectile.Kill(); } @@ -103,10 +95,7 @@ namespace CalamityMod.Projectiles.Typeless public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item27, projectile.position); - 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); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 24); int num226 = 36; for (int num227 = 0; num227 < num226; num227++) { @@ -116,6 +105,8 @@ namespace CalamityMod.Projectiles.Typeless int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 67, vector7.X * 0.5f, vector7.Y * 0.5f, 100, default, 0.75f); Main.dust[num228].noGravity = true; } + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; projectile.Damage(); } diff --git a/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index 5eae202b94..59fa533c56 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -1326,30 +1326,36 @@ namespace CalamityMod } } } - bool foundTarget = false; - Vector2 targetPos = new Vector2(0f, 0f); - float maxDist = 600f; - for (int i = 0; i < Main.maxNPCs; i++) + if (projectile.Calamity().lineColor != 1 || projectile.timeLeft < (3300 + projectile.localAI[0])) { - NPC npc = Main.npc[i]; - if (npc.CanBeChasedBy(projectile, false)) + bool foundTarget = false; + Vector2 targetPos = new Vector2(0f, 0f); + float maxDist = 600f; + for (int i = 0; i < Main.maxNPCs; i++) { - float targetDist = Vector2.Distance(projectile.Center, npc.Center); - if (targetDist < maxDist) + NPC npc = Main.npc[i]; + if (npc.CanBeChasedBy(projectile, false)) { - targetPos = npc.Center; - foundTarget = true; - break; + float targetDist = Vector2.Distance(projectile.Center, npc.Center); + if (targetDist < maxDist) + { + targetPos = npc.Center; + foundTarget = true; + break; + } } } - } - if (foundTarget) - { - Vector2 targetVec = targetPos - projectile.Center; - targetVec.Normalize(); - targetVec *= 0.75f; - projectile.velocity = (projectile.velocity * 10f + targetVec) / 11f; - return; + if (foundTarget) + { + if (projectile.Calamity().lineColor == 1) + projectile.extraUpdates = 5; + + Vector2 targetVec = targetPos - projectile.Center; + targetVec.Normalize(); + targetVec *= 0.75f; + projectile.velocity = (projectile.velocity * 10f + targetVec) / 11f; + return; + } } if (projectile.velocity.Length() > 0.2f) {