From 3d93d53a710aa5bc7dd0490a2b91b8b1dd45e866 Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Fri, 23 Aug 2024 09:13:41 -0500 Subject: [PATCH] Renamed Scavenger Laser to Homing Laser Dart (because Ravager will no longer use it in the reworked fight) and refactored more Retinazer code. --- DataStructures/NPCStats.cs | 4 +- .../Mods.CalamityMod.Projectiles.Boss.hjson | 2 +- NPCs/NormalNPCs/Foveanator.cs | 2 +- NPCs/Ravager/RavagerHead2.cs | 2 +- NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs | 79 ++++-------------- .../{ScavengerLaser.cs => HomingLaserDart.cs} | 2 +- ...ScavengerLaser.png => HomingLaserDart.png} | Bin 7 files changed, 24 insertions(+), 67 deletions(-) rename Projectiles/Boss/{ScavengerLaser.cs => HomingLaserDart.cs} (99%) rename Projectiles/Boss/{ScavengerLaser.png => HomingLaserDart.png} (100%) diff --git a/DataStructures/NPCStats.cs b/DataStructures/NPCStats.cs index c1efad8a93..4512e6eb55 100644 --- a/DataStructures/NPCStats.cs +++ b/DataStructures/NPCStats.cs @@ -638,7 +638,7 @@ namespace CalamityMod 132, // 99 in rapid fire 156, // 117 in rapid fire 234 } }, // 176 in rapid fire - { new Tuple(NPCID.Retinazer, ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 228 } }, + { new Tuple(NPCID.Retinazer, ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 228 } }, { new Tuple(NPCID.Spazmatism, ProjectileID.CursedFlameHostile), new int[] { 50, 100, 120, 140, 210 } }, { new Tuple(NPCID.Spazmatism, ProjectileID.EyeFire), new int[] { 60, 120, 148, 176, 264 } }, { new Tuple(NPCID.Spazmatism, ModContent.ProjectileType()), new int[] { 70, 120, 148, 176, 264 } }, @@ -725,7 +725,7 @@ namespace CalamityMod { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 180, 208, 236, 360 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 180, 208, 236, 360 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 90, 144, 172, 200, 300 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 90, 144, 172, 200, 300 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 180, 208, 236, 360 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 90, 144, 172, 200, 300 } }, diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson index a457e9850c..81dba17c98 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson @@ -130,7 +130,7 @@ SandTooth.DisplayName: Sand Tooth SCalBrimstoneFireblast.DisplayName: Brimstone Fireblast SCalBrimstoneGigablast.DisplayName: Brimstone Gigablast SCalRitualDrama.DisplayName: Calamitous Ritual Drama -ScavengerLaser.DisplayName: Homing Dart +HomingLaserDart.DisplayName: Homing Dart ScavengerNuke.DisplayName: Homing Nuke ShadeNimbusHostile.DisplayName: Shade Nimbus ShaderainHostile.DisplayName: Shade Rain diff --git a/NPCs/NormalNPCs/Foveanator.cs b/NPCs/NormalNPCs/Foveanator.cs index 1174df9e6c..0ba4ef047f 100644 --- a/NPCs/NormalNPCs/Foveanator.cs +++ b/NPCs/NormalNPCs/Foveanator.cs @@ -448,7 +448,7 @@ namespace CalamityMod.NPCs.NormalNPCs bool shootLaser = NPC.ai[1] % 20f == 0f; // TODO - Change this to Foveanator's lasers and energy bombs when they're implemented - int type = shootLaser ? ProjectileID.DeathLaser : ModContent.ProjectileType(); + int type = shootLaser ? ProjectileID.DeathLaser : ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); // Reduce mech boss projectile damage depending on the new ore progression changes diff --git a/NPCs/Ravager/RavagerHead2.cs b/NPCs/Ravager/RavagerHead2.cs index fcd1c78b94..2d13521641 100644 --- a/NPCs/Ravager/RavagerHead2.cs +++ b/NPCs/Ravager/RavagerHead2.cs @@ -110,7 +110,7 @@ namespace CalamityMod.NPCs.Ravager bool fireProjectiles = NPC.ai[1] >= (bossRush ? 240f : 480f); if (fireProjectiles && Vector2.Distance(NPC.Center, player.Center) > 80f) { - int type = ModContent.ProjectileType(); + int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); float projectileVelocity = death ? 8f : 6f; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs index eef6f1af18..38f423358f 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs @@ -51,7 +51,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 hoverDestination = new Vector2(npc.Center.X - Main.player[npc.target].position.X - (Main.player[npc.target].width / 2), npc.position.Y + npc.height - 59f - Main.player[npc.target].position.Y - (Main.player[npc.target].height / 2)); int direction = (npc.Center.X < Main.player[npc.target].position.X + Main.player[npc.target].width) ? -1 : 1; - float hoverRotation = (float)Math.Atan2(hoverDestination.Y, hoverDestination.X) + MathHelper.PiOver2; + float hoverRotation = hoverDestination.ToRotation() + MathHelper.PiOver2; if (hoverRotation < 0f) hoverRotation += MathHelper.TwoPi; else if (hoverRotation > MathHelper.TwoPi) @@ -296,7 +296,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.velocity.Y = 0f; } else - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; + npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; float delayBeforeChargingAgain = (masterMode ? 48f : 56f) - (death ? (masterMode ? 3f : 6f) * ((1f - lifeRatio) / (1f - phase2LifeRatio)) : 0f); if (npc.ai[2] >= delayBeforeChargingAgain + (oblivionAlive ? 15f : 0f)) @@ -369,7 +369,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { bool shootLaser = npc.ai[1] % 20f == 0f; - int type = shootLaser ? ProjectileID.DeathLaser : ModContent.ProjectileType(); + int type = shootLaser ? ProjectileID.DeathLaser : ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); // Reduce mech boss projectile damage depending on the new ore progression changes @@ -507,7 +507,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.netUpdate = true; } - npc.rotation = (float)Math.Atan2(Main.player[npc.target].Center.Y - npc.Center.Y, Main.player[npc.target].Center.X - npc.Center.X) - MathHelper.PiOver2; + npc.rotation = (Main.player[npc.target].Center - npc.Center).ToRotation() - MathHelper.PiOver2; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -564,7 +564,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 idealVelocity = (destination - npc.Center).SafeNormalize(Vector2.UnitX * direction); npc.SimpleFlyMovement(idealVelocity * maxVelocity, acceleration); - npc.rotation = (float)Math.Atan2(Main.player[npc.target].Center.Y - npc.Center.Y, Main.player[npc.target].Center.X - npc.Center.X) - MathHelper.PiOver2; + npc.rotation = (Main.player[npc.target].Center - npc.Center).ToRotation() - MathHelper.PiOver2; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -662,22 +662,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } else { - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; + npc.rotation = npc.velocity.ToRotation() - MathHelper.PiOver2; if (npc.ai[3] % 3f == 0f) { float fireRate = spazAlive ? 13f : 9f; if (npc.ai[2] % fireRate == 0f) { - Vector2 retinazerPhase3ChargeLaserPos = npc.Center; - float retinazerPhase3ChargeLaserTargetX = Main.player[npc.target].Center.X - retinazerPhase3ChargeLaserPos.X; - float retinazerPhase3ChargeLaserTargetY = Main.player[npc.target].Center.Y - retinazerPhase3ChargeLaserPos.Y; - float retinazerPhase3ChargeLaserTargetDist = (float)Math.Sqrt(retinazerPhase3ChargeLaserTargetX * retinazerPhase3ChargeLaserTargetX + retinazerPhase3ChargeLaserTargetY * retinazerPhase3ChargeLaserTargetY); - SoundEngine.PlaySound(SoundID.Item33, npc.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - int type = ModContent.ProjectileType(); + float laserDartSpeed = (death ? 9f : 6f) * (spazAlive ? 1f : 1.5f); + int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); // Reduce mech boss projectile damage depending on the new ore progression changes @@ -691,17 +687,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses damage = (int)(damage * secondMechMultiplier); } - float laserDartVelocity = (death ? 9f : 6f) * (spazAlive ? 1f : 1.5f); - retinazerPhase3ChargeLaserPos = npc.Center; - retinazerPhase3ChargeLaserTargetX = Main.player[npc.target].Center.X - retinazerPhase3ChargeLaserPos.X; - retinazerPhase3ChargeLaserTargetY = Main.player[npc.target].Center.Y - retinazerPhase3ChargeLaserPos.Y; - retinazerPhase3ChargeLaserTargetDist = (float)Math.Sqrt(retinazerPhase3ChargeLaserTargetX * retinazerPhase3ChargeLaserTargetX + retinazerPhase3ChargeLaserTargetY * retinazerPhase3ChargeLaserTargetY); - retinazerPhase3ChargeLaserTargetDist = laserDartVelocity / retinazerPhase3ChargeLaserTargetDist; - retinazerPhase3ChargeLaserTargetX *= retinazerPhase3ChargeLaserTargetDist; - retinazerPhase3ChargeLaserTargetY *= retinazerPhase3ChargeLaserTargetDist; - - Vector2 laserVelocity = new Vector2(retinazerPhase3ChargeLaserTargetX, retinazerPhase3ChargeLaserTargetY); - Projectile.NewProjectile(npc.GetSource_FromAI(), retinazerPhase3ChargeLaserPos + npc.velocity.SafeNormalize(Vector2.UnitY) * 50f, laserVelocity, type, damage, 0f, Main.myPlayer); + Vector2 laserDartVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * laserDartSpeed; + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + npc.velocity.SafeNormalize(Vector2.UnitY) * 50f, laserDartVelocity, type, damage, 0f, Main.myPlayer); } } } @@ -747,57 +734,27 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Avoid cheap bullshit npc.damage = 0; - int chargeLineUpDist = spazAlive ? 600 : 500; + float chargeLineUpDistance = spazAlive ? 600f : 500f; float chargeSpeed = 18f + (death ? 6f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); - float chargeAccel = 0.45f + (death ? 0.15f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); + float chargeAcceleration = 0.45f + (death ? 0.15f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); chargeSpeed += 6f * enrageScale; - chargeAccel += 0.15f * enrageScale; + chargeAcceleration += 0.15f * enrageScale; if (spazAlive) { chargeSpeed *= 0.75f; - chargeAccel *= 0.75f; + chargeAcceleration *= 0.75f; } if (Main.getGoodWorld) { chargeSpeed *= 1.15f; - chargeAccel *= 1.15f; + chargeAcceleration *= 1.15f; } - Vector2 spazmatismRetDeadChargePos = npc.Center; - float chargeTargetX = Main.player[npc.target].Center.X + (chargeLineUpDist * direction) - spazmatismRetDeadChargePos.X; - float chargeTargetY = Main.player[npc.target].Center.Y - spazmatismRetDeadChargePos.Y; - float chargeTargetDist = (float)Math.Sqrt(chargeTargetX * chargeTargetX + chargeTargetY * chargeTargetY); - - chargeTargetDist = chargeSpeed / chargeTargetDist; - chargeTargetX *= chargeTargetDist; - chargeTargetY *= chargeTargetDist; - - if (npc.velocity.X < chargeTargetX) - { - npc.velocity.X += chargeAccel; - if (npc.velocity.X < 0f && chargeTargetX > 0f) - npc.velocity.X += chargeAccel; - } - else if (npc.velocity.X > chargeTargetX) - { - npc.velocity.X -= chargeAccel; - if (npc.velocity.X > 0f && chargeTargetX < 0f) - npc.velocity.X -= chargeAccel; - } - if (npc.velocity.Y < chargeTargetY) - { - npc.velocity.Y += chargeAccel; - if (npc.velocity.Y < 0f && chargeTargetY > 0f) - npc.velocity.Y += chargeAccel; - } - else if (npc.velocity.Y > chargeTargetY) - { - npc.velocity.Y -= chargeAccel; - if (npc.velocity.Y > 0f && chargeTargetY < 0f) - npc.velocity.Y -= chargeAccel; - } + Vector2 destination = Main.player[npc.target].Center + Vector2.UnitX * chargeLineUpDistance * direction - Vector2.UnitY * chargeLineUpDistance; + Vector2 idealVelocity = (destination - npc.Center).SafeNormalize(Vector2.UnitX * direction) * chargeSpeed; + npc.SimpleFlyMovement(idealVelocity, chargeAcceleration); // Take 1.25 or 1 second to get in position, then charge npc.ai[2] += 1f; diff --git a/Projectiles/Boss/ScavengerLaser.cs b/Projectiles/Boss/HomingLaserDart.cs similarity index 99% rename from Projectiles/Boss/ScavengerLaser.cs rename to Projectiles/Boss/HomingLaserDart.cs index 418907350e..49f9f9c9e7 100644 --- a/Projectiles/Boss/ScavengerLaser.cs +++ b/Projectiles/Boss/HomingLaserDart.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { - public class ScavengerLaser : ModProjectile, ILocalizedModType + public class HomingLaserDart : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Boss"; diff --git a/Projectiles/Boss/ScavengerLaser.png b/Projectiles/Boss/HomingLaserDart.png similarity index 100% rename from Projectiles/Boss/ScavengerLaser.png rename to Projectiles/Boss/HomingLaserDart.png