From c4fd6c6839954099baabc8a0da1bc59ed817c4fa Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Thu, 16 Feb 2023 14:40:51 -0600 Subject: [PATCH] Guardian laser attack. --- DataStructures/NPCStats.cs | 1 + .../ProfanedGuardianCommander.cs | 270 ++++++++++++++---- .../ProfanedGuardianDefender.cs | 185 +++++++----- .../ProfanedGuardianHealer.cs | 204 +++++++++---- NPCs/Providence/Providence.cs | 12 +- Projectiles/Boss/ProvidenceHolyRay.cs | 54 ++-- 6 files changed, 506 insertions(+), 220 deletions(-) diff --git a/DataStructures/NPCStats.cs b/DataStructures/NPCStats.cs index 2062dbdd43..4ced7e1f7b 100644 --- a/DataStructures/NPCStats.cs +++ b/DataStructures/NPCStats.cs @@ -725,6 +725,7 @@ namespace CalamityMod { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 256, 366 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 220, 236, 330 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 220, 236, 330 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 160, 320, 352, 370, 528 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 220, 244, 256, 366 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 105, 171, 189, 198, 284 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 228, 252, 264, 378 } }, diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs index cca321f174..be2c1d0b69 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs @@ -31,6 +31,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians private int healTimer = 0; private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; private const float TimeForShieldDespawn = 120f; + public static readonly SoundStyle HolyRaySound = new("CalamityMod/Sounds/Custom/Providence/ProvidenceHolyRay") { Volume = 1.25f }; public override void SetStaticDefaults() { @@ -181,9 +182,22 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.Calamity().CurrentlyIncreasingDefenseOrDR = false; } - // Healing + // Healing and laser + bool hasDoneLaser = calamityGlobalNPC.newAI[2] == 1f; + if (healerAlive) { + // Laser attack when the healer is at or below 50% HP + bool shouldDoLaser = (Main.npc[CalamityGlobalNPC.doughnutBossHealer].life / (float)Main.npc[CalamityGlobalNPC.doughnutBossHealer].lifeMax) <= 0.5f; + if (!hasDoneLaser && shouldDoLaser && NPC.ai[0] != 5f) + { + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.localAI[3] = 0f; + NPC.netUpdate = true; + } + float distanceFromHealer = Vector2.Distance(Main.npc[CalamityGlobalNPC.doughnutBossHealer].Center, NPC.Center); bool dontHeal = distanceFromHealer > 2000f || Main.npc[CalamityGlobalNPC.doughnutBossHealer].justHit || NPC.life == NPC.lifeMax; if (dontHeal) @@ -817,67 +831,215 @@ namespace CalamityMod.NPCs.ProfanedGuardians } } } + else if (NPC.ai[0] == 5f) + { + // Face the target + if (Math.Abs(NPC.Center.X - player.Center.X) > 10f) + { + float playerLocation = NPC.Center.X - player.Center.X; + NPC.direction = playerLocation < 0f ? 1 : -1; + NPC.spriteDirection = NPC.direction; + } + + float laserGateValue = 120f; + float velocity = (bossRush || biomeEnraged) ? 4.5f : death ? 4f : revenge ? 3.75f : expertMode ? 3.5f : 3f; + if (NPC.ai[1] < laserGateValue) + velocity *= 6f; + if (Main.getGoodWorld) + velocity *= 1.25f; + + calamityGlobalNPC.newAI[0] = -NPC.direction; + float distanceToStayAwayFromTarget = 600f; + Vector2 destination = player.Center + Vector2.UnitX * distanceToStayAwayFromTarget * calamityGlobalNPC.newAI[0]; + Vector2 targetVector = destination - NPC.Center; + Vector2 desiredVelocity = targetVector.SafeNormalize(new Vector2(NPC.direction, 0f)) * velocity; + + // Move towards destination + if (Vector2.Distance(NPC.Center, destination) > 80f) + NPC.velocity = (NPC.velocity * (inertia - 1f) + desiredVelocity) / inertia; + else + NPC.velocity *= 0.98f; + + // Limit Y velocity while firing laser + if (NPC.ai[1] >= laserGateValue) + { + float speedCap = Main.getGoodWorld ? 4f : 2f; + if (NPC.velocity.Y > speedCap) + NPC.velocity.Y = speedCap; + if (NPC.velocity.Y < -speedCap) + NPC.velocity.Y = -speedCap; + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] < laserGateValue) + { + Vector2 dustPosOffset = new Vector2(27f, 59f); + if (NPC.ai[2] >= 40f) + { + int extraDustAmt = 0; + if (NPC.ai[2] >= 80f) + extraDustAmt = 1; + + for (int d = 0; d < 1 + extraDustAmt; d++) + { + float scalar = 1.2f; + if (d % 2 == 1) + scalar = 2.8f; + + Vector2 dustPos = shootFrom + ((float)Main.rand.NextDouble() * MathHelper.TwoPi).ToRotationVector2() * dustPosOffset / 2f; + int index = Dust.NewDust(dustPos - Vector2.One * 8f, 16, 16, (int)CalamityDusts.ProfanedFire, NPC.velocity.X / 2f, NPC.velocity.Y / 2f, 0, default, 1f); + Main.dust[index].velocity = Vector2.Normalize(NPC.Center - dustPos) * 3.5f * (10f - extraDustAmt * 2f) / 10f; + Main.dust[index].noGravity = true; + Main.dust[index].scale = scalar; + } + } + } + else if (NPC.ai[2] < (revenge ? 220f : 300f)) + { + if (NPC.ai[2] == laserGateValue) + { + float rotation = (bossRush || biomeEnraged) ? 435f : death ? 445f : revenge ? 450f : expertMode ? 455f : 465f; + + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, NPC.Center) < 2800f) + SoundEngine.PlaySound(HolyRaySound, Main.LocalPlayer.Center); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 laserVelocity = player.Center - NPC.Center; + laserVelocity.Normalize(); + + float beamDirection = -1f; + if (laserVelocity.X < 0f) + beamDirection = 1f; + + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + + // 60 degrees offset + laserVelocity = laserVelocity.RotatedBy(-(double)beamDirection * MathHelper.TwoPi / 6f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, laserVelocity, type, damage, 0f, Main.myPlayer, beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI); + + // -60 degrees offset + if (revenge) + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, -laserVelocity, type, damage, 0f, Main.myPlayer, -beamDirection * MathHelper.TwoPi / rotation, NPC.whoAmI); + + NPC.netUpdate = true; + } + } + } + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= (revenge ? 235f : 315f)) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + calamityGlobalNPC.newAI[2] = 1f; + NPC.netUpdate = true; + } + } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 drawPos = NPC.Center - screenPos; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; - if (NPC.ai[0] == 2f) - num153 = 10; - - if (CalamityConfig.Instance.Afterimages) + void drawGuardianInstance(Vector2 drawOffset, Color? colorOverride) { - for (int num155 = 1; num155 < num153; num155 += 2) + SpriteEffects spriteEffects = SpriteEffects.None; + if (NPC.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; + Vector2 drawPos = NPC.Center - screenPos; + Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; + if (NPC.ai[0] == 2f) + num153 = 10; + + if (CalamityConfig.Instance.Afterimages) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = drawColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = NPC.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + if (colorOverride != null) + color38 = colorOverride.Value; + + Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + } + } + + Vector2 vector43 = drawPos; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, vector43, NPC.frame, colorOverride ?? NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + + texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianCommanderGlow").Value; + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + if (CalamityWorld.getFixedBoi) + { + texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianCommanderGlowNight").Value; + color37 = Color.Cyan; + } + if (colorOverride != null) + color37 = colorOverride.Value; + + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 = NPC.GetAlpha(color41); + color41 *= (num153 - num163) / 15f; + if (colorOverride != null) + color41 = colorOverride.Value; + + Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + } + + // Draw laser effects + float useLaserGateValue = 120f; + float stopLaserGateValue = (CalamityWorld.revenge || BossRushEvent.BossRushActive) ? 235f : 315f; + float maxIntensity = 45f; + float increaseIntensityGateValue = useLaserGateValue - maxIntensity; + float decreaseIntensityGateValue = stopLaserGateValue - maxIntensity; + bool usingLaser = NPC.ai[0] == 5f; + bool increaseIntensity = NPC.ai[1] > increaseIntensityGateValue; + bool decreaseIntensity = NPC.ai[1] > decreaseIntensityGateValue; + if (usingLaser) + { + float burnIntensity = decreaseIntensity ? Utils.GetLerpValue(0f, maxIntensity, maxIntensity - (NPC.ai[1] - decreaseIntensityGateValue), true) : Utils.GetLerpValue(0f, maxIntensity, NPC.ai[1], true); + int totalGuardiansToDraw = (int)MathHelper.Lerp(1f, 30f, burnIntensity); + for (int i = 0; i < totalGuardiansToDraw; i++) + { + float offsetAngle = MathHelper.TwoPi * i * 2f / totalGuardiansToDraw; + float drawOffsetFactor = (float)Math.Sin(offsetAngle * 6f + Main.GlobalTimeWrappedHourly * MathHelper.Pi); + drawOffsetFactor *= (float)Math.Pow(burnIntensity, 3f) * 50f; + + Vector2 drawOffset = offsetAngle.ToRotationVector2() * drawOffsetFactor; + Color baseColor = Color.White * (MathHelper.Lerp(0.4f, 0.8f, burnIntensity) / totalGuardiansToDraw * 1.5f); + baseColor.A = 0; + + baseColor = Color.Lerp(Color.White, baseColor, burnIntensity); + drawGuardianInstance(drawOffset, totalGuardiansToDraw == 1 ? null : baseColor); } } - - Vector2 vector43 = drawPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); - - texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianCommanderGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - if (CalamityWorld.getFixedBoi) - { - texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianCommanderGlowNight").Value; - color37 = Color.Cyan; - } - - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); - } - } - - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + else + drawGuardianInstance(Vector2.Zero, null); bool defenderAlive = false; bool healerAlive = false; diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs index 99de8c1012..842c248e19 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs @@ -266,6 +266,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (Main.getGoodWorld) maxChargeVelocity *= 1.15f; + // Whether the commander is calling all guardians together for the laser attack + bool commanderUsingLaser = Main.npc[CalamityGlobalNPC.doughnutBoss].ai[0] == 5f; + // Go low just before moving to the other side to avoid bullshit hits float moveToOtherSideInPhase2GateValue = commanderGuardPhase2Duration - 120f; float timeBeforeMoveToOtherSideInPhase2Reset = moveToOtherSideInPhase2GateValue * 2f; @@ -407,30 +410,33 @@ namespace CalamityMod.NPCs.ProfanedGuardians return; } - // Lay a holy bomb every once in a while in phase 1 - float projectileShootGateValue = (bossRush || biomeEnraged) ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; - NPC.ai[1] += 1f; - if (NPC.ai[1] >= projectileShootGateValue) + // Lay a holy bomb every once in a while in phase 1 and while not doing the laser attack + if (!commanderUsingLaser) { - NPC.ai[1] = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient) + float projectileShootGateValue = (bossRush || biomeEnraged) ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; + NPC.ai[1] += 1f; + if (NPC.ai[1] >= projectileShootGateValue) { - float projectileVelocityY = NPC.velocity.Y; - if (projectileVelocityY < 0f) - projectileVelocityY = 0f; + NPC.ai[1] = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float projectileVelocityY = NPC.velocity.Y; + if (projectileVelocityY < 0f) + projectileVelocityY = 0f; - projectileVelocityY += expertMode ? 4f : 3f; - Vector2 projectileVelocity = new Vector2(NPC.velocity.X * 0.25f, projectileVelocityY); - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, projectileVelocity, type, damage, 0f, Main.myPlayer); + projectileVelocityY += expertMode ? 4f : 3f; + Vector2 projectileVelocity = new Vector2(NPC.velocity.X * 0.25f, projectileVelocityY); + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + Projectile.NewProjectile(NPC.GetSource_FromAI(), shootFrom, projectileVelocity, type, damage, 0f, Main.myPlayer); + } } } // Defend the commander - Vector2 distanceFromDestination = Main.npc[CalamityGlobalNPC.doughnutBoss].Center + Vector2.UnitX * distanceInFrontOfCommander * Main.npc[CalamityGlobalNPC.doughnutBoss].direction - NPC.Center; + Vector2 distanceFromDestination = Main.npc[CalamityGlobalNPC.doughnutBoss].Center + Vector2.UnitX * (commanderUsingLaser ? 0f : distanceInFrontOfCommander) * Main.npc[CalamityGlobalNPC.doughnutBoss].direction - NPC.Center; Vector2 desiredVelocity = distanceFromDestination.SafeNormalize(new Vector2(NPC.direction, 0f)) * (Main.npc[CalamityGlobalNPC.doughnutBoss].velocity.Length() + 5f); - if (distanceFromDestination.Length() > 80f) + if (distanceFromDestination.Length() > (commanderUsingLaser ? 40f : 80f)) { float inertia = 20f; if (Main.getGoodWorld) @@ -665,63 +671,104 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 drawPos = NPC.Center - screenPos; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; - if (NPC.ai[0] == 2f) - num153 = 10; - - if (CalamityConfig.Instance.Afterimages) + void drawGuardianInstance(Vector2 drawOffset, Color? colorOverride) { - for (int num155 = 1; num155 < num153; num155 += 2) + SpriteEffects spriteEffects = SpriteEffects.None; + if (NPC.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; + Vector2 drawPos = NPC.Center - screenPos; + Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; + if (NPC.ai[0] == 2f) + num153 = 10; + + if (CalamityConfig.Instance.Afterimages) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = drawColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = NPC.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + if (colorOverride != null) + color38 = colorOverride.Value; + + Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + } + } + + Vector2 vector43 = drawPos; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, vector43, NPC.frame, colorOverride ?? NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + + texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianDefenderGlow").Value; + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + if (CalamityWorld.getFixedBoi) + { + texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianDefenderGlowNight").Value; + color37 = Color.Cyan; + } + if (colorOverride != null) + color37 = colorOverride.Value; + + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 = NPC.GetAlpha(color41); + color41 *= (num153 - num163) / 15f; + if (colorOverride != null) + color41 = colorOverride.Value; + + Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + } + + // Draw laser effects + float useLaserGateValue = 120f; + float stopLaserGateValue = (CalamityWorld.revenge || BossRushEvent.BossRushActive) ? 235f : 315f; + float maxIntensity = 45f; + float increaseIntensityGateValue = useLaserGateValue - maxIntensity; + float decreaseIntensityGateValue = stopLaserGateValue - maxIntensity; + bool usingLaser = Main.npc[CalamityGlobalNPC.doughnutBoss].ai[0] == 5f; + bool increaseIntensity = Main.npc[CalamityGlobalNPC.doughnutBoss].ai[1] > increaseIntensityGateValue; + bool decreaseIntensity = Main.npc[CalamityGlobalNPC.doughnutBoss].ai[1] > decreaseIntensityGateValue; + if (usingLaser) + { + float burnIntensity = decreaseIntensity ? Utils.GetLerpValue(0f, maxIntensity, maxIntensity - (Main.npc[CalamityGlobalNPC.doughnutBoss].ai[1] - decreaseIntensityGateValue), true) : Utils.GetLerpValue(0f, maxIntensity, Main.npc[CalamityGlobalNPC.doughnutBoss].ai[1], true); + int totalGuardiansToDraw = (int)MathHelper.Lerp(1f, 30f, burnIntensity); + for (int i = 0; i < totalGuardiansToDraw; i++) + { + float offsetAngle = MathHelper.TwoPi * i * 2f / totalGuardiansToDraw; + float drawOffsetFactor = (float)Math.Sin(offsetAngle * 6f + Main.GlobalTimeWrappedHourly * MathHelper.Pi); + drawOffsetFactor *= (float)Math.Pow(burnIntensity, 3f) * 50f; + + Vector2 drawOffset = offsetAngle.ToRotationVector2() * drawOffsetFactor; + Color baseColor = Color.White * (MathHelper.Lerp(0.4f, 0.8f, burnIntensity) / totalGuardiansToDraw * 1.5f); + baseColor.A = 0; + + baseColor = Color.Lerp(Color.White, baseColor, burnIntensity); + drawGuardianInstance(drawOffset, totalGuardiansToDraw == 1 ? null : baseColor); } } - - Vector2 vector43 = drawPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); - - texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianDefenderGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - if (CalamityWorld.getFixedBoi) - { - texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianDefenderGlowNight").Value; - color37 = Color.Cyan; - } - - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); - } - } - - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + else + drawGuardianInstance(Vector2.Zero, null); // Draw shields while healer is alive if (NPC.localAI[1] < TimeForShieldDespawn) diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs b/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs index 4e6bb60083..697edd588b 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs @@ -228,6 +228,43 @@ namespace CalamityMod.NPCs.ProfanedGuardians Vector2 distanceFromDestination = destination - NPC.Center; Vector2 desiredVelocity = distanceFromDestination.SafeNormalize(new Vector2(NPC.direction, 0f)) * velocity; + // Whether the commander is calling all guardians together for the laser attack + bool commanderUsingLaser = Main.npc[CalamityGlobalNPC.doughnutBoss].ai[0] == 5f; + if (commanderUsingLaser) + { + NPC.Calamity().DR = 0.9f; + NPC.Calamity().unbreakableDR = true; + NPC.Calamity().CurrentlyIncreasingDefenseOrDR = true; + } + else + { + NPC.Calamity().DR = 0.2f; + NPC.Calamity().unbreakableDR = false; + NPC.Calamity().CurrentlyIncreasingDefenseOrDR = false; + } + + // Laser attack + if (commanderUsingLaser) + { + AITimer = 0f; + + // Move towards the commander + distanceFromDestination = Main.npc[CalamityGlobalNPC.doughnutBoss].Center - NPC.Center; + desiredVelocity = distanceFromDestination.SafeNormalize(new Vector2(NPC.direction, 0f)) * (Main.npc[CalamityGlobalNPC.doughnutBoss].velocity.Length() + 5f); + if (distanceFromDestination.Length() > 40f) + { + float inertia = 20f; + if (Main.getGoodWorld) + inertia *= 0.8f; + + NPC.velocity = (NPC.velocity * (inertia - 1) + desiredVelocity) / inertia; + } + else + NPC.velocity *= 0.96f; + + return; + } + // Fire crystal rain similar to Providence's Crystal attack if (useCrystalShards) { @@ -389,70 +426,117 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Texture2D texture2D16 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianHealerGlow2").Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; - - if (CalamityConfig.Instance.Afterimages) + void drawGuardianInstance(Vector2 drawOffset, Color? colorOverride) { - for (int num155 = 1; num155 < num153; num155 += 2) + SpriteEffects spriteEffects = SpriteEffects.None; + if (NPC.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; + Texture2D texture2D16 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianHealerGlow2").Value; + Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; + + if (CalamityConfig.Instance.Afterimages) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = drawColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = NPC.GetAlpha(color38); + color38 *= (num153 - num155) / 15f; + if (colorOverride != null) + color38 = colorOverride.Value; + + Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + } + } + + Vector2 vector43 = NPC.Center - screenPos; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, vector43, NPC.frame, colorOverride ?? NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + + texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianHealerGlow").Value; + Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); + if (CalamityWorld.getFixedBoi) + { + texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianHealerGlowNight").Value; + color37 = Color.Cyan; + } + Color color42 = Color.Lerp(Color.White, Color.Violet, 0.5f); + if (colorOverride != null) + { + color37 = colorOverride.Value; + color42 = colorOverride.Value; + } + + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163++) + { + Color color41 = color37; + color41 = Color.Lerp(color41, color36, amount9); + color41 = NPC.GetAlpha(color41); + color41 *= (num153 - num163) / 15f; + if (colorOverride != null) + color41 = colorOverride.Value; + + Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY) + drawOffset; + spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + + Color color43 = color42; + color43 = Color.Lerp(color43, color36, amount9); + color43 = NPC.GetAlpha(color43); + color43 *= (num153 - num163) / 15f; + if (colorOverride != null) + color43 = colorOverride.Value; + + spriteBatch.Draw(texture2D16, vector44, NPC.frame, color43, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + } + } + + spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + + spriteBatch.Draw(texture2D16, vector43, NPC.frame, color42, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + } + + // Draw laser effects + float useLaserGateValue = 120f; + float stopLaserGateValue = (CalamityWorld.revenge || BossRushEvent.BossRushActive) ? 235f : 315f; + float maxIntensity = 45f; + float increaseIntensityGateValue = useLaserGateValue - maxIntensity; + float decreaseIntensityGateValue = stopLaserGateValue - maxIntensity; + bool usingLaser = Main.npc[CalamityGlobalNPC.doughnutBoss].ai[0] == 5f; + bool increaseIntensity = Main.npc[CalamityGlobalNPC.doughnutBoss].ai[1] > increaseIntensityGateValue; + bool decreaseIntensity = Main.npc[CalamityGlobalNPC.doughnutBoss].ai[1] > decreaseIntensityGateValue; + if (usingLaser) + { + float burnIntensity = decreaseIntensity ? Utils.GetLerpValue(0f, maxIntensity, maxIntensity - (Main.npc[CalamityGlobalNPC.doughnutBoss].ai[1] - decreaseIntensityGateValue), true) : Utils.GetLerpValue(0f, maxIntensity, Main.npc[CalamityGlobalNPC.doughnutBoss].ai[1], true); + int totalGuardiansToDraw = (int)MathHelper.Lerp(1f, 30f, burnIntensity); + for (int i = 0; i < totalGuardiansToDraw; i++) + { + float offsetAngle = MathHelper.TwoPi * i * 2f / totalGuardiansToDraw; + float drawOffsetFactor = (float)Math.Sin(offsetAngle * 6f + Main.GlobalTimeWrappedHourly * MathHelper.Pi); + drawOffsetFactor *= (float)Math.Pow(burnIntensity, 3f) * 50f; + + Vector2 drawOffset = offsetAngle.ToRotationVector2() * drawOffsetFactor; + Color baseColor = Color.White * (MathHelper.Lerp(0.4f, 0.8f, burnIntensity) / totalGuardiansToDraw * 1.5f); + baseColor.A = 0; + + baseColor = Color.Lerp(Color.White, baseColor, burnIntensity); + drawGuardianInstance(drawOffset, totalGuardiansToDraw == 1 ? null : baseColor); } } - - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); - - texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianHealerGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Yellow, 0.5f); - if (CalamityWorld.getFixedBoi) - { - texture2D15 = ModContent.Request("CalamityMod/NPCs/ProfanedGuardians/ProfanedGuardianHealerGlowNight").Value; - color37 = Color.Cyan; - } - Color color42 = Color.Lerp(Color.White, Color.Violet, 0.5f); - - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163++) - { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 = NPC.GetAlpha(color41); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector44 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); - - Color color43 = color42; - color43 = Color.Lerp(color43, color36, amount9); - color43 = NPC.GetAlpha(color43); - color43 *= (num153 - num163) / 15f; - spriteBatch.Draw(texture2D16, vector44, NPC.frame, color43, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); - } - } - - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); - - spriteBatch.Draw(texture2D16, vector43, NPC.frame, color42, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + else + drawGuardianInstance(Vector2.Zero, null); return false; } diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 10211309dc..d187f79bd8 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -798,14 +798,14 @@ namespace CalamityMod.NPCs.Providence if (num855 > (laserPhaseSlow ? 200f : 250f)) // 200 NPC.velocity.Y += Main.getGoodWorld ? 0.4f : 0.2f; - float speedVariance = laserPhaseSlow ? 2f : 6f; + float speedCap = laserPhaseSlow ? 2f : 6f; if (Main.getGoodWorld) - speedVariance *= 1.5f; + speedCap *= 1.5f; - if (NPC.velocity.Y > speedVariance) - NPC.velocity.Y = speedVariance; - if (NPC.velocity.Y < -speedVariance) - NPC.velocity.Y = -speedVariance; + if (NPC.velocity.Y > speedCap) + NPC.velocity.Y = speedCap; + if (NPC.velocity.Y < -speedCap) + NPC.velocity.Y = -speedCap; } } } diff --git a/Projectiles/Boss/ProvidenceHolyRay.cs b/Projectiles/Boss/ProvidenceHolyRay.cs index 44087e0153..21572206b7 100644 --- a/Projectiles/Boss/ProvidenceHolyRay.cs +++ b/Projectiles/Boss/ProvidenceHolyRay.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.NPCs; +using CalamityMod.NPCs.ProfanedGuardians; using CalamityMod.NPCs.Providence; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -48,7 +49,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - //Day mode by default but syncs with the boss + // Day mode by default but syncs with the boss if (CalamityGlobalNPC.holyBoss != -1) { if (Main.npc[CalamityGlobalNPC.holyBoss].active) @@ -61,24 +62,21 @@ namespace CalamityMod.Projectiles.Boss Vector2? vector78 = null; if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero) - { Projectile.velocity = -Vector2.UnitY; - } - if (Main.npc[(int)Projectile.ai[1]].active && Main.npc[(int)Projectile.ai[1]].type == ModContent.NPCType()) + if (Main.npc[(int)Projectile.ai[1]].active && (Main.npc[(int)Projectile.ai[1]].type == ModContent.NPCType() || Main.npc[(int)Projectile.ai[1]].type == ModContent.NPCType())) { - Vector2 fireFrom = new Vector2(Main.npc[(int)Projectile.ai[1]].Center.X, Main.npc[(int)Projectile.ai[1]].Center.Y + 32f); + Vector2 laserOffset = Main.npc[(int)Projectile.ai[1]].type == ModContent.NPCType() ? new Vector2(40f * Main.npc[(int)Projectile.ai[1]].direction, 20f) : Vector2.UnitY * 32f; + Vector2 fireFrom = new Vector2(Main.npc[(int)Projectile.ai[1]].Center.X, Main.npc[(int)Projectile.ai[1]].Center.Y) + laserOffset; Projectile.position = fireFrom - new Vector2(Projectile.width, Projectile.height) / 2f; } else Projectile.Kill(); if (Projectile.velocity.HasNaNs() || Projectile.velocity == Vector2.Zero) - { Projectile.velocity = -Vector2.UnitY; - } - float num801 = 1f; + float num801 = Main.npc[(int)Projectile.ai[1]].type == ModContent.NPCType() ? 0.66f : 1f; Projectile.localAI[0] += 1f; if (Projectile.localAI[0] >= (scissorLasers ? 100f : 180f)) { @@ -88,23 +86,19 @@ namespace CalamityMod.Projectiles.Boss Projectile.scale = (float)Math.Sin(Projectile.localAI[0] * MathHelper.Pi / (scissorLasers ? 100f : 180f)) * 10f * num801; if (Projectile.scale > num801) - { Projectile.scale = num801; - } float num804 = Projectile.velocity.ToRotation(); num804 += Projectile.ai[0]; Projectile.rotation = num804 - MathHelper.PiOver2; Projectile.velocity = num804.ToRotationVector2(); - float num805 = 3f; //3f + float num805 = 3f; float num806 = Projectile.width; Vector2 samplingPoint = Projectile.Center; if (vector78.HasValue) - { samplingPoint = vector78.Value; - } float[] array3 = new float[(int)num805]; Collision.LaserScan(samplingPoint, Projectile.velocity, num806 * Projectile.scale, 2400f, array3); @@ -117,17 +111,15 @@ namespace CalamityMod.Projectiles.Boss // Fire laser through walls at max length if target cannot be seen if (!Collision.CanHitLine(Main.npc[(int)Projectile.ai[1]].Center, 1, 1, Main.player[Main.npc[(int)Projectile.ai[1]].target].Center, 1, 1)) - { num807 = 2400f; - } int dustType = ProvUtils.GetDustID(Projectile.maxPenetrate); - float amount = 0.5f; //0.5f - Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], num807, amount); //length of laser, linear interpolation + float amount = 0.5f; + Projectile.localAI[1] = MathHelper.Lerp(Projectile.localAI[1], num807, amount); // Length of laser, linear interpolation Vector2 vector79 = Projectile.Center + Projectile.velocity * (Projectile.localAI[1] - 14f); for (int num809 = 0; num809 < 2; num809++) { - float num810 = Projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; + float num810 = Projectile.velocity.ToRotation() + (Main.rand.NextBool() ? -1f : 1f) * MathHelper.PiOver2; float num811 = (float)Main.rand.NextDouble() * 2f + 2f; Vector2 vector80 = new Vector2((float)Math.Cos(num810) * num811, (float)Math.Sin(num810) * num811); int num812 = Dust.NewDust(vector79, 0, 0, dustType, vector80.X, vector80.Y, 0, default, 1f); @@ -151,16 +143,16 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { if (Projectile.velocity == Vector2.Zero) - { return false; - } - bool dayTime = (Projectile.maxPenetrate == (int)Providence.BossMode.Day); + + bool dayTime = Projectile.maxPenetrate == (int)Providence.BossMode.Day; Texture2D texture2D19 = dayTime ? ModContent.Request(Texture, AssetRequestMode.ImmediateLoad).Value : ModContent.Request("CalamityMod/Projectiles/Boss/ProvidenceHolyRayNight", AssetRequestMode.ImmediateLoad).Value; Texture2D texture2D20 = dayTime ? ModContent.Request("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayMid", AssetRequestMode.ImmediateLoad).Value : ModContent.Request("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayMidNight", AssetRequestMode.ImmediateLoad).Value; Texture2D texture2D21 = dayTime ? ModContent.Request("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayEnd", AssetRequestMode.ImmediateLoad).Value : ModContent.Request("CalamityMod/ExtraTextures/Lasers/ProvidenceHolyRayEndNight", AssetRequestMode.ImmediateLoad).Value; + float num223 = Projectile.localAI[1]; //length of laser Color color44 = ProvUtils.GetProjectileColor(Projectile.maxPenetrate, 0) * 0.9f; Vector2 vector = Projectile.Center - Main.screenPosition; @@ -169,6 +161,7 @@ namespace CalamityMod.Projectiles.Boss num223 -= (texture2D19.Height / 2 + texture2D21.Height) * Projectile.scale; Vector2 value20 = Projectile.Center; value20 += Projectile.velocity * Projectile.scale * texture2D19.Height / 2f; + if (num223 > 0f) { float num224 = 0f; @@ -176,22 +169,23 @@ namespace CalamityMod.Projectiles.Boss while (num224 + 1f < num223) { if (num223 - num224 < rectangle7.Height) - { rectangle7.Height = (int)(num223 - num224); - } + Main.spriteBatch.Draw(texture2D20, value20 - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(rectangle7), color44, Projectile.rotation, new Vector2(rectangle7.Width / 2, 0f), Projectile.scale, SpriteEffects.None, 0); num224 += rectangle7.Height * Projectile.scale; value20 += Projectile.velocity * rectangle7.Height * Projectile.scale; rectangle7.Y += 36; + if (rectangle7.Y + rectangle7.Height > texture2D20.Height) - { rectangle7.Y = 0; - } } } + Vector2 vector2 = value20 - Main.screenPosition; sourceRectangle2 = null; + Main.spriteBatch.Draw(texture2D21, vector2, sourceRectangle2, color44, Projectile.rotation, texture2D21.Frame(1, 1, 0, 0).Top(), Projectile.scale, SpriteEffects.None, 0); + return false; } @@ -205,24 +199,22 @@ namespace CalamityMod.Projectiles.Boss public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { if (projHitbox.Intersects(targetHitbox)) - { return true; - } + float num6 = 0f; if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, Projectile.Center + Projectile.velocity * Projectile.localAI[1], 22f * Projectile.scale, ref num6)) - { return true; - } + return false; } public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) { - //In GFB, "real damage" is replaced with negative healing + // In GFB, "real damage" is replaced with negative healing if (Projectile.maxPenetrate >= (int)Providence.BossMode.Red) damage = 0; - //If the player is dodging, don't apply debuffs + // If the player is dodging, don't apply debuffs if (damage <= 0 && Projectile.maxPenetrate < (int)Providence.BossMode.Red || target.creativeGodMode) return;