From 8b98192a7c792db0df99686e2e335396c1cb67bb Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Fri, 3 Jun 2022 23:37:43 -0500 Subject: [PATCH] 1 - Windy Day music IL edit that doesn't work for some fucking reason. 2 - Desert Scourge and Destroyer forward projectile spread velocities no longer scale with their velocity. --- ILEditing/ILChangesLoading.cs | 2 ++ ILEditing/VanillaStupidityFixingILChanges.cs | 15 ++++++++++++ NPCs/DesertScourge/DesertScourgeHead.cs | 2 +- .../VanillaNPCOverrides/Bosses/DestroyerAI.cs | 23 ++++--------------- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index 2b573bcc84..ea60cdcd33 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -102,6 +102,7 @@ namespace CalamityMod.ILEditing // IL.Terraria.NPC.VanillaHitEffect += RemoveLavaDropsFromExpertLavaSlimes; IL.Terraria.Player.IsTileTypeInInteractionRange += IncreasePylonInteractionRange; IL.Terraria.Projectile.CanExplodeTile += MakeMeteoriteExplodable; + IL.Terraria.Main.UpdateWindyDayState += MakeWindyDayMusicPlayLessOften; IL.Terraria.Main.UpdateTime_StartNight += BloodMoonsRequire200MaxLife; IL.Terraria.WorldGen.AttemptFossilShattering += PreventFossilShattering; IL.Terraria.Projectile.Damage += MakeTagDamageMultiplicative; @@ -189,6 +190,7 @@ namespace CalamityMod.ILEditing //IL.Terraria.NPC.VanillaHitEffect -= RemoveLavaDropsFromExpertLavaSlimes; IL.Terraria.Player.IsTileTypeInInteractionRange -= IncreasePylonInteractionRange; IL.Terraria.Projectile.CanExplodeTile -= MakeMeteoriteExplodable; + IL.Terraria.Main.UpdateWindyDayState -= MakeWindyDayMusicPlayLessOften; IL.Terraria.Main.UpdateTime_StartNight -= BloodMoonsRequire200MaxLife; IL.Terraria.WorldGen.AttemptFossilShattering -= PreventFossilShattering; IL.Terraria.Projectile.Damage -= MakeTagDamageMultiplicative; diff --git a/ILEditing/VanillaStupidityFixingILChanges.cs b/ILEditing/VanillaStupidityFixingILChanges.cs index ce93ac6bd5..78abb49df5 100644 --- a/ILEditing/VanillaStupidityFixingILChanges.cs +++ b/ILEditing/VanillaStupidityFixingILChanges.cs @@ -193,6 +193,21 @@ namespace CalamityMod.ILEditing } #endregion + #region Make Windy Day Music Play Less Often + private static void MakeWindyDayMusicPlayLessOften(ILContext il) + { + // Make windy day theme only play when the wind speed is over 0.6f instead of 0.4f. + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchStsfld
("_maxWind"))) // The wind speed check. + { + LogFailure("Make Windy Day Music Play Less Often", "Could not locate the _maxWind variable."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 0.6f); // Change to 0.6f. + } + #endregion Make Windy Day Music Play Less Often + #region Change Blood Moon Max HP Requirements private static void BloodMoonsRequire200MaxLife(ILContext il) { diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index 21e48d0cef..e38b2f85a7 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -218,7 +218,7 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.Calamity().newAI[2] % 30f == 0f) { SoundEngine.PlaySound(SoundID.Item21, NPC.Center); - float velocity = NPC.velocity.Length() + 1f; + float velocity = malice ? 12f : death ? 10f : 9f; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); Vector2 projectileVelocity = Vector2.Normalize(player.Center - NPC.Center) * velocity; diff --git a/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs b/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs index 7a7d4d6833..a41e975391 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs @@ -173,32 +173,17 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { if (calamityGlobalNPC.newAI[0] % 30f == 0f) { - Vector2 vectorCenter = npc.Center; - float num742 = npc.velocity.Length() * 0.33f + 1f; - float num743 = player.position.X + player.width * 0.5f - vectorCenter.X; - float num744 = player.position.Y + player.height * 0.5f - vectorCenter.Y; - float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); - - num745 = num742 / num745; - num743 *= num745; - num744 *= num745; - vectorCenter.X += num743 * 5f; - vectorCenter.Y += num744 * 5f; - + float velocity = malice ? 6f : death ? 5.333f : 5f; int type = ProjectileID.DeathLaser; int damage = npc.GetProjectileDamage(type); + Vector2 projectileVelocity = Vector2.Normalize(player.Center - npc.Center) * velocity; int numProj = calamityGlobalNPC.newAI[0] % 60f == 0f ? 7 : 4; int spread = 54; float rotation = MathHelper.ToRadians(spread); - float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); - double startAngle = Math.Atan2(num743, num744) - rotation / 2; - double deltaAngle = rotation / numProj; - double offsetAngle; - for (int i = 0; i < numProj; i++) { - offsetAngle = startAngle + deltaAngle * i; - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, 1f, 0f); + Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + Vector2.Normalize(perturbedSpeed) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer, 1f, 0f); Main.projectile[proj].timeLeft = 900; } }