From fc486cd9f5a98c5b890050b480e4e4198321da81 Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Sun, 12 Feb 2023 12:56:00 -0600 Subject: [PATCH] 1 - Added some syncing to Commander that was missing. 2 - DoG lasers fade out. --- .../ProfanedGuardianCommander.cs | 4 +++ Projectiles/Boss/DoGDeath.cs | 30 +++++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs index a4e4a7df8b..cca321f174 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs @@ -98,6 +98,8 @@ namespace CalamityMod.NPCs.ProfanedGuardians writer.Write(NPC.localAI[1]); writer.Write(NPC.localAI[2]); writer.Write(NPC.localAI[3]); + for (int i = 0; i < 4; i++) + writer.Write(NPC.Calamity().newAI[i]); } public override void ReceiveExtraAI(BinaryReader reader) @@ -110,6 +112,8 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.localAI[1] = reader.ReadSingle(); NPC.localAI[2] = reader.ReadSingle(); NPC.localAI[3] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + NPC.Calamity().newAI[i] = reader.ReadSingle(); } public override void FindFrame(int frameHeight) diff --git a/Projectiles/Boss/DoGDeath.cs b/Projectiles/Boss/DoGDeath.cs index 21d3eef2ef..b23d4c99ea 100644 --- a/Projectiles/Boss/DoGDeath.cs +++ b/Projectiles/Boss/DoGDeath.cs @@ -22,6 +22,7 @@ namespace CalamityMod.Projectiles.Boss public const float TelegraphTotalTime = 210f; public const float TelegraphFadeTime = 30f; public const float TelegraphWidth = 4200f; + public const float FadeTime = 100f; public override void SetStaticDefaults() { @@ -37,10 +38,10 @@ namespace CalamityMod.Projectiles.Boss Projectile.hostile = true; Projectile.ignoreWater = true; Projectile.tileCollide = false; - Projectile.alpha = 255; + Projectile.Opacity = 0f; Projectile.penetrate = -1; Projectile.extraUpdates = 3; - Projectile.timeLeft = 780; + Projectile.timeLeft = 1200; CooldownSlot = ImmunityCooldownID.Bosses; } @@ -63,17 +64,22 @@ namespace CalamityMod.Projectiles.Boss Projectile.localAI[0] = 1f; Projectile.netUpdate = true; } + // Fade in after telegraphs have faded. if (TelegraphDelay > TelegraphTotalTime) { - if (Projectile.alpha > 0) + if (Projectile.timeLeft < FadeTime) { - Projectile.alpha -= 12; + Projectile.Opacity = Projectile.timeLeft / FadeTime; } - if (Projectile.alpha < 0) + else { - Projectile.alpha = 0; + if (Projectile.Opacity < 1f) + Projectile.Opacity += 0.05f; + if (Projectile.Opacity > 1f) + Projectile.Opacity = 1f; } + // If an old velocity is in reserve, set the true velocity to it and make it as "taken" by setting it to <0,0> if (OldVelocity != Vector2.Zero) { @@ -81,8 +87,10 @@ namespace CalamityMod.Projectiles.Boss OldVelocity = Vector2.Zero; Projectile.netUpdate = true; } + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; } + // Otherwise, be sure to save the velocity the projectile started with. It will be set again when the telegraph is over. else if (OldVelocity == Vector2.Zero) { @@ -91,24 +99,22 @@ namespace CalamityMod.Projectiles.Boss Projectile.netUpdate = true; Projectile.rotation = OldVelocity.ToRotation() + MathHelper.PiOver2; } + TelegraphDelay++; } - public override bool CanHitPlayer(Player target) => TelegraphDelay > TelegraphTotalTime; + public override bool CanHitPlayer(Player target) => TelegraphDelay > TelegraphTotalTime && Projectile.Opacity == 1f; public override void OnHitPlayer(Player target, int damage, bool crit) { if (damage <= 0) return; - if (TelegraphDelay > TelegraphTotalTime) + if (TelegraphDelay > TelegraphTotalTime && Projectile.Opacity == 1f) target.AddBuff(ModContent.BuffType(), 180); } - public override Color? GetAlpha(Color lightColor) - { - return new Color(255, 255, 255, Projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => Color.White * Projectile.Opacity; public override bool PreDraw(ref Color lightColor) {