diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index e0b12307d4..f7e44c3d45 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1752,20 +1752,10 @@ namespace CalamityMod.NPCs #region Can Hit Player public override bool CanHitPlayer(NPC npc, Player target, ref int cooldownSlot) { - if (!npc.boss && !npc.friendly && !npc.dontTakeDamage) - { - if (CalamityWorld.downedDoG && (Main.pumpkinMoon || Main.snowMoon || Main.eclipse)) - { - cooldownSlot = 1; - } - } - if (target.Calamity().prismaticHelmet && !CalamityPlayer.areThereAnyDamnBosses) { if (npc.lifeMax < 500) - { return false; - } } return true; diff --git a/NPCs/ExoMechs/Ares/AresBody.cs b/NPCs/ExoMechs/Ares/AresBody.cs index b61eecbd3b..3dd1b8f8de 100644 --- a/NPCs/ExoMechs/Ares/AresBody.cs +++ b/NPCs/ExoMechs/Ares/AresBody.cs @@ -67,15 +67,15 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Max distance from the target before they are unable to hear sound telegraphs private const float soundDistance = 2800f; + // Variable used to stop the arm spawning loop + private bool armsSpawned = false; + // Total duration of the deathray telegraph private const float deathrayTelegraphDuration = 240f; // Total duration of the deathrays private const float deathrayDuration = 600f; - // Whether or not the other exo mechs have been spawned - private bool otherExoMechsSpawned = false; - public override void SetStaticDefaults() { DisplayName.SetDefault("XF-09 Ares"); @@ -134,38 +134,51 @@ namespace CalamityMod.NPCs.ExoMechs.Ares bool revenge = CalamityWorld.revenge || malice; bool expertMode = Main.expertMode || malice; - // Spawn arms - if (npc.ai[0] == 0f) - { - int totalArms = 4; - for (int i = 0; i < totalArms; i++) - { - int lol = 0; - switch (i) - { - case 0: - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - break; - case 1: - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - break; - case 2: - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - break; - case 3: - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - break; - default: - break; - } + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; - Main.npc[lol].realLife = npc.whoAmI; - Main.npc[lol].ai[0] = npc.whoAmI; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); + // Spawn arms + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (!armsSpawned && npc.ai[0] == 0f) + { + int totalArms = 4; + int Previous = npc.whoAmI; + for (int i = 0; i < totalArms; i++) + { + int lol = 0; + switch (i) + { + case 0: + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + break; + case 1: + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + break; + case 2: + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + break; + case 3: + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + break; + default: + break; + } + + Main.npc[lol].realLife = npc.whoAmI; + Main.npc[lol].ai[2] = npc.whoAmI; + Main.npc[lol].ai[1] = Previous; + Main.npc[Previous].ai[0] = lol; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); + Previous = lol; + } + armsSpawned = true; } - npc.ai[0] = 1f; } + if (npc.life > Main.npc[(int)npc.ai[0]].life) + npc.life = Main.npc[(int)npc.ai[0]].life; + // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -241,9 +254,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Target variable Player player = Main.player[npc.target]; - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - // Despawn if target is dead bool targetDead = false; if (player.dead) @@ -262,14 +272,14 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if ((double)npc.position.Y < Main.topWorld + 16f) npc.velocity.Y -= 2f; - /*if ((double)npc.position.Y < Main.topWorld + 16f) + if ((double)npc.position.Y < Main.topWorld + 16f) { for (int a = 0; a < Main.maxNPCs; a++) { if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) Main.npc[a].active = false; } - }*/ + } } } diff --git a/NPCs/ExoMechs/Ares/AresGaussNuke.cs b/NPCs/ExoMechs/Ares/AresGaussNuke.cs index 9f71b09e1e..bb5b3fe55c 100644 --- a/NPCs/ExoMechs/Ares/AresGaussNuke.cs +++ b/NPCs/ExoMechs/Ares/AresGaussNuke.cs @@ -174,8 +174,11 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Target variable Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - if (npc.ai[0] > 0f) - npc.realLife = (int)npc.ai[0]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; + + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; // Despawn if target is dead bool targetDead = false; @@ -195,18 +198,18 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if ((double)npc.position.Y < Main.topWorld + 16f) npc.velocity.Y -= 2f; - /*if ((double)npc.position.Y < Main.topWorld + 16f) + if ((double)npc.position.Y < Main.topWorld + 16f) { for (int a = 0; a < Main.maxNPCs; a++) { if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) Main.npc[a].active = false; } - }*/ + } } } - CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[0]].Calamity(); + CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[2]].Calamity(); // Adjust opacity bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; @@ -340,7 +343,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares Vector2 gaussNukeVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.Center + Vector2.Normalize(gaussNukeVelocity) * 40f, gaussNukeVelocity, type, damage, 0f, Main.myPlayer, 0f, 0f); + float offset = 40f; + Projectile.NewProjectile(npc.Center + Vector2.Normalize(gaussNukeVelocity) * offset, gaussNukeVelocity, type, damage, 0f, Main.myPlayer, 0f, 0f); // Recoil npc.velocity -= gaussNukeVelocity; diff --git a/NPCs/ExoMechs/Ares/AresLaserCannon.cs b/NPCs/ExoMechs/Ares/AresLaserCannon.cs index a593f80be6..2338b33b54 100644 --- a/NPCs/ExoMechs/Ares/AresLaserCannon.cs +++ b/NPCs/ExoMechs/Ares/AresLaserCannon.cs @@ -172,8 +172,11 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Target variable Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - if (npc.ai[0] > 0f) - npc.realLife = (int)npc.ai[0]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; + + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; // Despawn if target is dead bool targetDead = false; @@ -193,18 +196,18 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if ((double)npc.position.Y < Main.topWorld + 16f) npc.velocity.Y -= 2f; - /*if ((double)npc.position.Y < Main.topWorld + 16f) + if ((double)npc.position.Y < Main.topWorld + 16f) { for (int a = 0; a < Main.maxNPCs; a++) { if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) Main.npc[a].active = false; } - }*/ + } } } - CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[0]].Calamity(); + CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[2]].Calamity(); // Adjust opacity bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; @@ -341,7 +344,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares { // Two possible variants: 1 - Left to right, 2 - Top to bottom npc.velocity = calamityGlobalNPC.newAI[3] == 0f ? new Vector2(deathrayPhaseVelocity, 0f) : new Vector2(0f, deathrayPhaseVelocity); - Vector2 laserVelocity = calamityGlobalNPC.newAI[3] == 0f ? Vector2.UnitY : Vector2.UnitX; calamityGlobalNPC.newAI[3] += 1f; if (calamityGlobalNPC.newAI[3] > 1f) @@ -349,13 +351,16 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if (Main.netMode != NetmodeID.MultiplayerClient) { - /*int type = ModContent.ProjectileType(); + int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 velocity = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(npc.Center, laserVelocity, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - }*/ + float offset = 40f; + Vector2 source = calamityGlobalNPC.newAI[3] == 0f ? new Vector2(npc.Center.X, npc.Center.Y + offset) : new Vector2(npc.Center.X + offset, npc.Center.Y); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), source); + Vector2 laserVelocity = Vector2.Normalize(lookAt - source); + if (laserVelocity.HasNaNs()) + laserVelocity = -Vector2.UnitY; + + Projectile.NewProjectile(source, laserVelocity, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); } } } diff --git a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs index 8956d070fe..accdb35bcc 100644 --- a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs +++ b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs @@ -172,8 +172,11 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Target variable Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - if (npc.ai[0] > 0f) - npc.realLife = (int)npc.ai[0]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; + + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; // Despawn if target is dead bool targetDead = false; @@ -193,18 +196,18 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if ((double)npc.position.Y < Main.topWorld + 16f) npc.velocity.Y -= 2f; - /*if ((double)npc.position.Y < Main.topWorld + 16f) + if ((double)npc.position.Y < Main.topWorld + 16f) { for (int a = 0; a < Main.maxNPCs; a++) { if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) Main.npc[a].active = false; } - }*/ + } } } - CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[0]].Calamity(); + CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[2]].Calamity(); // Adjust opacity bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; @@ -340,9 +343,10 @@ namespace CalamityMod.NPCs.ExoMechs.Ares Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaCasterFire"), npc.Center); float projectileVelocity = 12f; Vector2 plasmaBoltVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; - /*int type = ModContent.ProjectileType(); + int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.Center + Vector2.Normalize(plasmaBoltVelocity) * 40f, plasmaBoltVelocity, type, damage, 0f, Main.myPlayer, 0f, 0f);*/ + float offset = 40f; + Projectile.NewProjectile(npc.Center + Vector2.Normalize(plasmaBoltVelocity) * offset, plasmaBoltVelocity, type, damage, 0f, Main.myPlayer, 0f, 0f); } } } diff --git a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs index 1656fa4940..9464136406 100644 --- a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs +++ b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs @@ -172,8 +172,11 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Target variable Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; - if (npc.ai[0] > 0f) - npc.realLife = (int)npc.ai[0]; + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; + + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; // Despawn if target is dead bool targetDead = false; @@ -193,18 +196,18 @@ namespace CalamityMod.NPCs.ExoMechs.Ares if ((double)npc.position.Y < Main.topWorld + 16f) npc.velocity.Y -= 2f; - /*if ((double)npc.position.Y < Main.topWorld + 16f) + if ((double)npc.position.Y < Main.topWorld + 16f) { for (int a = 0; a < Main.maxNPCs; a++) { if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) Main.npc[a].active = false; } - }*/ + } } } - CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[0]].Calamity(); + CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[2]].Calamity(); // Adjust opacity bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs index a55a6debb4..0cebd79e0e 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs @@ -84,6 +84,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + // Difficulty modes bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || malice; diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs index 9639c99d89..fb40c285ed 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs @@ -84,6 +84,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + // Difficulty modes bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || malice; diff --git a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs index 7fcd784d52..2b2a30f69c 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs @@ -273,6 +273,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } } + if (npc.life > Main.npc[(int)npc.ai[0]].life) + npc.life = Main.npc[(int)npc.ai[0]].life; + // Despawn if target is dead bool targetDead = false; if (player.dead) diff --git a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs index ecccdec52b..a97e300ca9 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs @@ -83,6 +83,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + // Difficulty modes bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || malice; diff --git a/Projectiles/Boss/AresGaussNukeProjectile.cs b/Projectiles/Boss/AresGaussNukeProjectile.cs index e950b6c502..bc5bf5eb3e 100644 --- a/Projectiles/Boss/AresGaussNukeProjectile.cs +++ b/Projectiles/Boss/AresGaussNukeProjectile.cs @@ -27,7 +27,8 @@ namespace CalamityMod.Projectiles.Boss projectile.ignoreWater = true; projectile.tileCollide = false; projectile.penetrate = -1; - projectile.timeLeft = 480; + cooldownSlot = 1; + projectile.timeLeft = 480; projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; } @@ -114,7 +115,7 @@ namespace CalamityMod.Projectiles.Boss Rectangle frame = new Rectangle(0, projectile.frame * Main.projectileTexture[projectile.type].Height, Main.projectileTexture[projectile.type].Width, Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]); - Color color = Color.Lerp(Color.White, Color.GreenYellow, 0.5f) * projectile.Opacity; + Color color = Color.Lerp(Color.White, Color.GreenYellow, 0.5f); spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/AresGaussNukeProjectileGlow"), projectile.Center - Main.screenPosition, frame, color, projectile.rotation, projectile.Size / 2, 1f, SpriteEffects.None, 0f); @@ -181,5 +182,10 @@ namespace CalamityMod.Projectiles.Boss } } } - } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/AresGaussNukeProjectileBoom.cs b/Projectiles/Boss/AresGaussNukeProjectileBoom.cs index 9f316bdfa6..65d483571a 100644 --- a/Projectiles/Boss/AresGaussNukeProjectileBoom.cs +++ b/Projectiles/Boss/AresGaussNukeProjectileBoom.cs @@ -53,6 +53,7 @@ namespace CalamityMod.Projectiles.Boss projectile.ignoreWater = true; projectile.tileCollide = false; projectile.penetrate = -1; + cooldownSlot = 1; projectile.timeLeft = Lifetime; } @@ -89,6 +90,11 @@ namespace CalamityMod.Projectiles.Boss CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(Radius * projectile.scale), (int)(Radius * projectile.scale)); } + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(BuffID.OnFire, 480); + } + public override void Kill(int timeLeft) { CalamityWorld.ScreenShakeSpots.Remove(Projectile.GetByUUID(projectile.owner, projectile.whoAmI)); // Remove the explosion associated with this projectile's UUID. @@ -139,5 +145,10 @@ namespace CalamityMod.Projectiles.Boss return minDist <= Radius * projectile.scale * 0.5f; } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } } } diff --git a/Projectiles/Boss/AresGaussNukeProjectileSpark.cs b/Projectiles/Boss/AresGaussNukeProjectileSpark.cs index 064e5ab9f3..22321dded1 100644 --- a/Projectiles/Boss/AresGaussNukeProjectileSpark.cs +++ b/Projectiles/Boss/AresGaussNukeProjectileSpark.cs @@ -24,15 +24,23 @@ namespace CalamityMod.Projectiles.Boss projectile.hostile = true; projectile.ignoreWater = true; projectile.tileCollide = false; - projectile.alpha = 255; - projectile.penetrate = -1; + projectile.Opacity = 0f; + cooldownSlot = 1; + projectile.penetrate = -1; projectile.timeLeft = 600; projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; } public override void AI() { - projectile.frameCounter++; + if (projectile.timeLeft < 15) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 15f, 0f, 1f); + else + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 595) / 5f), 0f, 1f); + + Lighting.AddLight(projectile.Center, 0.1f * projectile.Opacity, 0.125f * projectile.Opacity, 0.025f * projectile.Opacity); + + projectile.frameCounter++; if (projectile.frameCounter > 4) { projectile.frame++; @@ -40,18 +48,23 @@ namespace CalamityMod.Projectiles.Boss } if (projectile.frame > 3) projectile.frame = 0; - - if (projectile.alpha > 0) - projectile.alpha -= 50; - if (projectile.alpha < 0) - projectile.alpha = 0; projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; } - public override Color? GetAlpha(Color lightColor) + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (projectile.Opacity != 1f) + return; + + target.AddBuff(BuffID.OnFire, 180); + } + + public override Color? GetAlpha(Color lightColor) { - return new Color(255, 255, 255, projectile.alpha); + return new Color(255 * projectile.Opacity, 255 * projectile.Opacity, 255 * projectile.Opacity, projectile.alpha); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -59,5 +72,10 @@ namespace CalamityMod.Projectiles.Boss CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } - } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/AresLaserBeamStart.cs b/Projectiles/Boss/AresLaserBeamStart.cs new file mode 100644 index 0000000000..cd5e8e2bee --- /dev/null +++ b/Projectiles/Boss/AresLaserBeamStart.cs @@ -0,0 +1,223 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs.ExoMechs.Ares; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.Enums; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class AresLaserBeamStart : ModProjectile + { + private int frameDrawn = 0; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Laser Beam"); + } + + public override void SetDefaults() + { + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 30; + projectile.height = 30; + projectile.hostile = true; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft = 600; + cooldownSlot = 1; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(frameDrawn); + writer.Write(projectile.localAI[0]); + writer.Write(projectile.localAI[1]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + frameDrawn = reader.ReadInt32(); + projectile.localAI[0] = reader.ReadSingle(); + projectile.localAI[1] = reader.ReadSingle(); + } + + public override void AI() + { + 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()) + { + float offset = 40f; + Vector2 fireFrom = Main.npc[(int)projectile.ai[1]].Calamity().newAI[3] == 0f ? new Vector2(Main.npc[(int)projectile.ai[1]].Center.X, Main.npc[(int)projectile.ai[1]].Center.Y + offset) : new Vector2(Main.npc[(int)projectile.ai[1]].Center.X + offset, Main.npc[(int)projectile.ai[1]].Center.Y); + projectile.position = fireFrom - new Vector2(projectile.width, projectile.height) / 2f; + } + else + projectile.Kill(); + + float num801 = 1f; + projectile.localAI[0] += 1f; + if (projectile.localAI[0] >= 60f) + { + projectile.Kill(); + return; + } + + if (projectile.localAI[0] % 5f == 0f) + { + frameDrawn++; + if (frameDrawn >= 5) + frameDrawn = 0; + } + + projectile.scale = (float)Math.Sin(projectile.localAI[0] * (float)Math.PI / 60f) * 10f * num801; + if (projectile.scale > num801) + projectile.scale = num801; + + float num804 = projectile.velocity.ToRotation(); + projectile.rotation = num804 - MathHelper.PiOver2; + projectile.velocity = num804.ToRotationVector2(); + + float num805 = 3f; //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); + float num807 = 0f; + for (int num808 = 0; num808 < array3.Length; num808++) + { + num807 += array3[num808]; + } + num807 /= num805; + + // 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; + } + + 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 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, (int)CalamityDusts.Brimstone, vector80.X, vector80.Y, 0, default, 1f); + Main.dust[num812].noGravity = true; + Main.dust[num812].scale = 1.7f; + } + + if (Main.rand.NextBool(5)) + { + Vector2 value29 = projectile.velocity.RotatedBy(MathHelper.PiOver2, default) * ((float)Main.rand.NextDouble() - 0.5f) * projectile.width; + int num813 = Dust.NewDust(vector79 + value29 - Vector2.One * 4f, 8, 8, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); + Dust dust = Main.dust[num813]; + dust.velocity *= 0.5f; + Main.dust[num813].velocity.Y = -Math.Abs(Main.dust[num813].velocity.Y); + } + + DelegateMethods.v3_1 = new Vector3(0.9f, 0.3f, 0.3f); + Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (projectile.velocity == Vector2.Zero) + return false; + + Texture2D beamStart = Main.projectileTexture[projectile.type]; + Texture2D beamMiddle = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/AresLaserBeamMiddle"); + Texture2D beamEnd = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/AresLaserBeamEnd"); + + float drawLength = projectile.localAI[1]; + Color color = new Color(250, 100, 100, 0); + + // Draw start of beam + Vector2 vector = projectile.Center - Main.screenPosition; + Rectangle? sourceRectangle = new Rectangle(0, beamStart.Height / 5 * frameDrawn, beamStart.Width, beamStart.Height / 5); + spriteBatch.Draw(beamStart, vector, sourceRectangle, color, projectile.rotation, new Vector2(beamStart.Width, beamStart.Height / 5) / 2f, projectile.scale, SpriteEffects.None, 0f); + + // Draw middle of beam + drawLength -= (beamStart.Height / 5 / 2 + beamEnd.Height / 5) * projectile.scale; + Vector2 center = projectile.Center; + center += projectile.velocity * projectile.scale * beamStart.Height / 5f / 2f; + if (drawLength > 0f) + { + float i = 0f; + int middleFrameDrawn = frameDrawn; + Rectangle rectangle = new Rectangle(0, beamMiddle.Height / 5 * middleFrameDrawn, beamMiddle.Width, beamMiddle.Height / 5); + while (i + 1f < drawLength) + { + if (drawLength - i < rectangle.Height) + rectangle.Height = (int)(drawLength - i); + + spriteBatch.Draw(beamMiddle, center - Main.screenPosition, rectangle, color, projectile.rotation, new Vector2(rectangle.Width / 2f, 0f), projectile.scale, SpriteEffects.None, 0f); + + middleFrameDrawn++; + if (middleFrameDrawn >= 5) + middleFrameDrawn = 0; + + i += rectangle.Height * projectile.scale; + center += projectile.velocity * rectangle.Height * projectile.scale; + + rectangle.Y += beamMiddle.Height / 5; + if (rectangle.Y + rectangle.Height > beamMiddle.Height / 5) + rectangle.Y = 0; + } + } + + // Draw end of beam + Vector2 vector2 = center - Main.screenPosition; + sourceRectangle = new Rectangle(0, beamEnd.Height / 5 * frameDrawn, beamEnd.Width, beamEnd.Height / 5); + spriteBatch.Draw(beamEnd, vector2, sourceRectangle, color, projectile.rotation, new Vector2(beamEnd.Width, beamEnd.Height / 5) / 2f, projectile.scale, SpriteEffects.None, 0f); + + return false; + } + + public override void CutTiles() + { + DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; + Vector2 unit = projectile.velocity; + Utils.PlotTileLine(projectile.Center, projectile.Center + unit * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); + } + + 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], 30f * projectile.scale, ref num6)) + { + return true; + } + return false; + } + + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 300); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } +} diff --git a/Projectiles/Boss/AresPlasmaBolt.cs b/Projectiles/Boss/AresPlasmaBolt.cs new file mode 100644 index 0000000000..758503b2f8 --- /dev/null +++ b/Projectiles/Boss/AresPlasmaBolt.cs @@ -0,0 +1,83 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class AresPlasmaBolt : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Plasma Bolt"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } + + public override void SetDefaults() + { + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 18; + projectile.height = 18; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.Opacity = 0f; + cooldownSlot = 1; + projectile.penetrate = -1; + projectile.timeLeft = 600; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } + + public override void AI() + { + if (projectile.timeLeft < 15) + projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 15f, 0f, 1f); + else + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 595) / 5f), 0f, 1f); + + Lighting.AddLight(projectile.Center, 0f, 0.4f * projectile.Opacity, 0f); + + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + projectile.frame = 0; + + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; + } + + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (projectile.Opacity != 1f) + return; + + target.AddBuff(BuffID.OnFire, 180); + target.AddBuff(BuffID.CursedInferno, 90); + } + + public override Color? GetAlpha(Color lightColor) + { + return new Color(255 * projectile.Opacity, 255 * projectile.Opacity, 255 * projectile.Opacity, projectile.alpha); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } +} diff --git a/Projectiles/Boss/AresPlasmaFireball.cs b/Projectiles/Boss/AresPlasmaFireball.cs new file mode 100644 index 0000000000..89bad0aa02 --- /dev/null +++ b/Projectiles/Boss/AresPlasmaFireball.cs @@ -0,0 +1,217 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class AresPlasmaFireball : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Plasma Fireball"); + Main.projFrames[projectile.type] = 6; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } + + public override void SetDefaults() + { + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 36; + projectile.height = 36; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.Opacity = 0f; + cooldownSlot = 1; + projectile.timeLeft = 480; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } + + public override void AI() + { + Vector2 targetLocation = new Vector2(projectile.ai[0], projectile.ai[1]); + if (Vector2.Distance(targetLocation, projectile.Center) < 80f) + projectile.tileCollide = true; + + projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 475) / 5f), 0f, 1f); + + Lighting.AddLight(projectile.Center, 0f, 0.6f * projectile.Opacity, 0f); + + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 5) + projectile.frame = 0; + + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; + + if (projectile.localAI[0] == 0f) + { + projectile.localAI[0] = 1f; + + float speed1 = 1.8f; + float speed2 = 2.8f; + float angleRandom = 0.35f; + + for (int num53 = 0; num53 < 40; num53++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + int randomDustType = Main.rand.NextBool(2) ? 107 : 110; + + int num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 1.7f); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + Main.dust[num54].noGravity = true; + + Dust dust = Main.dust[num54]; + dust.velocity *= 3f; + dust = Main.dust[num54]; + + num54 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 100, default, 0.8f); + Main.dust[num54].position = projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * projectile.width / 2f; + + dust = Main.dust[num54]; + dust.velocity *= 2f; + + Main.dust[num54].noGravity = true; + Main.dust[num54].fadeIn = 1f; + Main.dust[num54].color = Color.Green * 0.5f; + + dust = Main.dust[num54]; + } + for (int num55 = 0; num55 < 20; num55++) + { + float dustSpeed = Main.rand.NextFloat(speed1, speed2); + Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + int randomDustType = Main.rand.NextBool(2) ? 107 : 110; + + int num56 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 2f); + Main.dust[num56].position = projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(projectile.velocity.ToRotation()) * projectile.width / 3f; + Main.dust[num56].noGravity = true; + + Dust dust = Main.dust[num56]; + dust.velocity *= 0.5f; + dust = Main.dust[num56]; + } + } + } + + public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; + + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (projectile.Opacity != 1f) + return; + + target.AddBuff(BuffID.OnFire, 360); + target.AddBuff(BuffID.CursedInferno, 180); + } + + public override Color? GetAlpha(Color lightColor) + { + return new Color(255 * projectile.Opacity, 255 * projectile.Opacity, 255 * projectile.Opacity, projectile.alpha); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + + public override void Kill(int timeLeft) + { + int height = 90; + projectile.position = projectile.Center; + projectile.width = projectile.height = height; + projectile.Center = projectile.position; + projectile.Damage(); + + Main.PlaySound(SoundID.Item93, projectile.Center); + + if (Main.myPlayer == projectile.owner) + { + // Plasma bolts + int totalProjectiles = CalamityWorld.malice ? 12 : 8; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + float velocity = 12f; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(projectile.Center, velocity2, type, (int)(projectile.damage * 0.8), 0f, Main.myPlayer); + } + } + + for (int num640 = 0; num640 < 200; num640++) + { + float num641 = 16f; + if (num640 < 150) + num641 = 12f; + if (num640 < 100) + num641 = 8f; + if (num640 < 50) + num641 = 4f; + + int num643 = Dust.NewDust(projectile.Center, 6, 6, Main.rand.NextBool(2) ? 107 : 110, 0f, 0f, 100, default, 1f); + float num644 = Main.dust[num643].velocity.X; + float num645 = Main.dust[num643].velocity.Y; + + if (num644 == 0f && num645 == 0f) + num644 = 1f; + + float num646 = (float)Math.Sqrt(num644 * num644 + num645 * num645); + num646 = num641 / num646; + num644 *= num646; + num645 *= num646; + + float scale = 1f; + switch ((int)num641) + { + case 4: + scale = 1.2f; + break; + case 8: + scale = 1.1f; + break; + case 12: + scale = 1f; + break; + case 16: + scale = 0.9f; + break; + default: + break; + } + + Dust dust = Main.dust[num643]; + dust.velocity *= 0.5f; + dust.velocity.X = dust.velocity.X + num644; + dust.velocity.Y = dust.velocity.Y + num645; + dust.scale = scale; + dust.noGravity = true; + } + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } +} diff --git a/Projectiles/Boss/BrimstoneBarrage.cs b/Projectiles/Boss/BrimstoneBarrage.cs index 4a6548f450..53edf79ac2 100644 --- a/Projectiles/Boss/BrimstoneBarrage.cs +++ b/Projectiles/Boss/BrimstoneBarrage.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Boss projectile.damage = projectile.GetProjectileDamage(ModContent.NPCType()); } - Lighting.AddLight(projectile.Center, 0.75f, 0f, 0f); + Lighting.AddLight(projectile.Center, 0.75f * projectile.Opacity, 0f, 0f); } public override bool CanHitPlayer(Player target) => projectile.Opacity == 1f; diff --git a/Projectiles/Boss/BrimstoneFireblast.cs b/Projectiles/Boss/BrimstoneFireblast.cs index 18bace1779..46652bd2c9 100644 --- a/Projectiles/Boss/BrimstoneFireblast.cs +++ b/Projectiles/Boss/BrimstoneFireblast.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Boss else projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 60) / 60f), 0f, 1f); - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.9f / 255f, 0f, 0f); + Lighting.AddLight(projectile.Center, 0.9f * projectile.Opacity, 0f, 0f); projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; diff --git a/Projectiles/Boss/BrimstoneGigaBlast.cs b/Projectiles/Boss/BrimstoneGigaBlast.cs index cf628bb7ae..717d25ec58 100644 --- a/Projectiles/Boss/BrimstoneGigaBlast.cs +++ b/Projectiles/Boss/BrimstoneGigaBlast.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Boss bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice; - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.9f / 255f, 0f, 0f); + Lighting.AddLight(projectile.Center, 0.9f * projectile.Opacity, 0f, 0f); if (projectile.ai[1] == 1f) projectile.Opacity = MathHelper.Clamp(projectile.timeLeft / 60f, 0f, 1f); diff --git a/Projectiles/Boss/BrimstoneHellblast.cs b/Projectiles/Boss/BrimstoneHellblast.cs index afa6bd1ed6..071da44ca7 100644 --- a/Projectiles/Boss/BrimstoneHellblast.cs +++ b/Projectiles/Boss/BrimstoneHellblast.cs @@ -44,10 +44,10 @@ namespace CalamityMod.Projectiles.Boss { projectile.frame = 0; } + Lighting.AddLight(projectile.Center, 0.9f * projectile.Opacity, 0f, 0f); if (projectile.timeLeft < 51) { - projectile.alpha += 5; - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.9f / 255f, 0f, 0f); + projectile.Opacity -= 0.02f; } if (projectile.ai[1] == 0f) { diff --git a/Projectiles/Boss/BrimstoneHellblast2.cs b/Projectiles/Boss/BrimstoneHellblast2.cs index 776cab7cc1..78e97521ed 100644 --- a/Projectiles/Boss/BrimstoneHellblast2.cs +++ b/Projectiles/Boss/BrimstoneHellblast2.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Boss else projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 1440) / 60f), 0f, 1f); - Lighting.AddLight(projectile.Center, 0.9f, 0f, 0f); + Lighting.AddLight(projectile.Center, 0.9f * projectile.Opacity, 0f, 0f); if (projectile.velocity.X < 0f) { diff --git a/Projectiles/Boss/BrimstoneMonster.cs b/Projectiles/Boss/BrimstoneMonster.cs index d46b5b78e1..52e040ffca 100644 --- a/Projectiles/Boss/BrimstoneMonster.cs +++ b/Projectiles/Boss/BrimstoneMonster.cs @@ -96,7 +96,7 @@ namespace CalamityMod.Projectiles.Boss bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice; bool death = CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice; - Lighting.AddLight(projectile.Center, 3f, 0f, 0f); + Lighting.AddLight(projectile.Center, 3f * projectile.Opacity, 0f, 0f); float inertia = (revenge ? 4.5f : 5f) + speedAdd; float speed = (revenge ? 1.5f : 1.35f) + (speedAdd * 0.25f); diff --git a/Projectiles/Boss/BrimstoneWave.cs b/Projectiles/Boss/BrimstoneWave.cs index ce420fabfb..bb215aa8c3 100644 --- a/Projectiles/Boss/BrimstoneWave.cs +++ b/Projectiles/Boss/BrimstoneWave.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Boss else projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 1170) / 30f), 0f, 1f); - Lighting.AddLight(projectile.Center, 0.5f, 0f, 0f); + Lighting.AddLight(projectile.Center, 0.5f * projectile.Opacity, 0f, 0f); if (projectile.velocity.X < 0f) projectile.spriteDirection = 1; diff --git a/Projectiles/Boss/DarkEnergyBall2.cs b/Projectiles/Boss/DarkEnergyBall2.cs index 8e4b5c5b2c..f68625bac8 100644 --- a/Projectiles/Boss/DarkEnergyBall2.cs +++ b/Projectiles/Boss/DarkEnergyBall2.cs @@ -122,5 +122,10 @@ namespace CalamityMod.Projectiles.Boss Main.dust[num624].velocity *= 2f; } } - } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/ExoDestroyerBeamStart.cs b/Projectiles/Boss/ExoDestroyerBeamStart.cs index 5a90c4d052..23f4956c2b 100644 --- a/Projectiles/Boss/ExoDestroyerBeamStart.cs +++ b/Projectiles/Boss/ExoDestroyerBeamStart.cs @@ -20,6 +20,7 @@ namespace CalamityMod.Projectiles.Boss public ref float LengthOfLaser => ref projectile.localAI[1]; public const int Lifetime = 180; public const float BeamPosOffset = 16f; + private int frameDrawn = 0; public override void SetStaticDefaults() { @@ -41,13 +42,15 @@ namespace CalamityMod.Projectiles.Boss public override void SendExtraAI(BinaryWriter writer) { - writer.Write(Time); + writer.Write(frameDrawn); + writer.Write(Time); writer.Write(LengthOfLaser); } public override void ReceiveExtraAI(BinaryReader reader) { - Time = reader.ReadSingle(); + frameDrawn = reader.ReadInt32(); + Time = reader.ReadSingle(); LengthOfLaser = reader.ReadSingle(); } @@ -86,6 +89,13 @@ namespace CalamityMod.Projectiles.Boss return; } + if (Time % 5 == 0) + { + frameDrawn++; + if (frameDrawn >= 4) + frameDrawn = 0; + } + float scale = 1f; projectile.scale = (float)Math.Sin(Time * MathHelper.Pi / Lifetime) * 10f * scale; if (projectile.scale > scale) @@ -199,8 +209,8 @@ namespace CalamityMod.Projectiles.Boss // Draw start of beam Vector2 vector = projectile.Center - Main.screenPosition; - Rectangle? sourceRectangle = new Rectangle(0, 30 * (projectile.timeLeft / 3 % 4), beamStart.Width, 30); - spriteBatch.Draw(beamStart, vector, sourceRectangle, color, projectile.rotation, new Vector2(32f, 30f) / 2f, projectile.scale, SpriteEffects.None, 0f); + Rectangle? sourceRectangle = new Rectangle(0, beamStart.Height / 4 * frameDrawn, beamStart.Width, beamStart.Height / 4); + spriteBatch.Draw(beamStart, vector, sourceRectangle, color, projectile.rotation, new Vector2(beamStart.Width, beamStart.Height / 4) / 2f, projectile.scale, SpriteEffects.None, 0f); // Draw middle of beam drawLength -= (beamStart.Height / 4 / 2 + beamEnd.Height / 4) * projectile.scale; @@ -209,18 +219,23 @@ namespace CalamityMod.Projectiles.Boss if (drawLength > 0f) { float i = 0f; - Rectangle rectangle = new Rectangle(0, 30 * (projectile.timeLeft / 3 % 4), beamMiddle.Width, 30); - while (i + 1f < drawLength) + int middleFrameDrawn = frameDrawn; + Rectangle rectangle = new Rectangle(0, beamMiddle.Height / 4 * middleFrameDrawn, beamMiddle.Width, beamMiddle.Height / 4); + while (i + 1f < drawLength) { if (drawLength - i < rectangle.Height) rectangle.Height = (int)(drawLength - i); spriteBatch.Draw(beamMiddle, center - Main.screenPosition, rectangle, color, projectile.rotation, new Vector2(rectangle.Width / 2f, 0f), projectile.scale, SpriteEffects.None, 0f); + middleFrameDrawn++; + if (middleFrameDrawn >= 4) + middleFrameDrawn = 0; + i += rectangle.Height * projectile.scale; center += projectile.velocity * rectangle.Height * projectile.scale; - rectangle.Y += 30; + rectangle.Y += beamMiddle.Height / 4; if (rectangle.Y + rectangle.Height > beamMiddle.Height / 4) rectangle.Y = 0; } @@ -228,8 +243,8 @@ namespace CalamityMod.Projectiles.Boss // Draw end of beam Vector2 vector2 = center - Main.screenPosition; - sourceRectangle = new Rectangle(0, 30 * (projectile.timeLeft / 3 % 4), beamEnd.Width, 30); - spriteBatch.Draw(beamEnd, vector2, sourceRectangle, color, projectile.rotation, new Vector2(28f, 30f) / 2f, projectile.scale, SpriteEffects.None, 0f); + sourceRectangle = new Rectangle(0, beamEnd.Height / 4 * frameDrawn, beamEnd.Width, beamEnd.Height / 4); + spriteBatch.Draw(beamEnd, vector2, sourceRectangle, color, projectile.rotation, new Vector2(beamEnd.Width, beamEnd.Height / 4) / 2f, projectile.scale, SpriteEffects.None, 0f); return false; } diff --git a/Projectiles/Boss/FrostMist.cs b/Projectiles/Boss/FrostMist.cs index 7736aa2a9d..948215fa45 100644 --- a/Projectiles/Boss/FrostMist.cs +++ b/Projectiles/Boss/FrostMist.cs @@ -109,6 +109,7 @@ namespace CalamityMod.Projectiles.Boss projectile.velocity *= 1.02f; projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + Lighting.AddLight(projectile.Center, 0f, 0.35f * projectile.Opacity, 0.35f * projectile.Opacity); } diff --git a/Projectiles/Boss/SandPoisonCloudOldDuke.cs b/Projectiles/Boss/SandPoisonCloudOldDuke.cs index 753fce4136..c5f1f60bba 100644 --- a/Projectiles/Boss/SandPoisonCloudOldDuke.cs +++ b/Projectiles/Boss/SandPoisonCloudOldDuke.cs @@ -70,5 +70,10 @@ namespace CalamityMod.Projectiles.Boss if (projectile.timeLeft >= 180) target.AddBuff(ModContent.BuffType(), 240, true); } - } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/SandToothOldDuke.cs b/Projectiles/Boss/SandToothOldDuke.cs index fc74f9937c..fa22b735e0 100644 --- a/Projectiles/Boss/SandToothOldDuke.cs +++ b/Projectiles/Boss/SandToothOldDuke.cs @@ -49,5 +49,10 @@ namespace CalamityMod.Projectiles.Boss spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, tex.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); return false; } - } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } } diff --git a/Projectiles/Boss/WaterSpear.cs b/Projectiles/Boss/WaterSpear.cs index 7215b9f2b7..3ebf575324 100644 --- a/Projectiles/Boss/WaterSpear.cs +++ b/Projectiles/Boss/WaterSpear.cs @@ -66,6 +66,7 @@ namespace CalamityMod.Projectiles.Boss projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - 270) / 30f), 0f, 1f); projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + Lighting.AddLight(projectile.Center, 0f, 0f, 0.5f * projectile.Opacity); } diff --git a/Utilities/NPCStats.cs b/Utilities/NPCStats.cs index 9073336a0b..d6f2f6f6f8 100644 --- a/Utilities/NPCStats.cs +++ b/Utilities/NPCStats.cs @@ -812,9 +812,8 @@ namespace CalamityMod { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 528, 556, 572, 834 } }, //{ new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 500, 752, 788, 808, 1182 } }, - //{ new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 450, 676, 712, 732, 1068 } }, - //{ new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 400, 600, 632, 648, 948 } }, - //{ new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 528, 556, 572, 834 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 450, 676, 712, 732, 1068 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 400, 600, 632, 648, 948 } }, //{ new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 528, 556, 572, 834 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 500, 752, 788, 808, 1182 } },