diff --git a/DataStructures/NPCStats.cs b/DataStructures/NPCStats.cs index 4512e6eb55..53e017b942 100644 --- a/DataStructures/NPCStats.cs +++ b/DataStructures/NPCStats.cs @@ -643,9 +643,9 @@ namespace CalamityMod { new Tuple(NPCID.Spazmatism, ProjectileID.EyeFire), new int[] { 60, 120, 148, 176, 264 } }, { new Tuple(NPCID.Spazmatism, ModContent.ProjectileType()), new int[] { 70, 120, 148, 176, 264 } }, { new Tuple(NPCID.Spazmatism, ModContent.ProjectileType()), new int[] { 60, 100, 128, 156, 234 } }, - /*{ new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 50, 108, 132, 156, 234 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 148, 176, 264 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 148, 176, 264 } },*/ + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 50, 108, 132, 156, 234 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 148, 176, 264 } }, + //{ new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 148, 176, 264 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 60, 100, 120, 140, 210 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 120, 136, 152, 228 } }, diff --git a/ExtraTextures/Bestiary/SlimeGod_Bestiary.png b/ExtraTextures/Bestiary/SlimeGod_Bestiary.png new file mode 100644 index 0000000000..dbe7056e82 Binary files /dev/null and b/ExtraTextures/Bestiary/SlimeGod_Bestiary.png differ diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson index 81dba17c98..d7a892da35 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson @@ -64,6 +64,8 @@ FlareBomb.DisplayName: Flare Bomb FlareDust.DisplayName: Flare Dust FlareDust2.DisplayName: Flare Bomb Flarenado.DisplayName: Flarenado +FoveanatorEnergyBomb.DisplayName: Nebulous Energy Bomb +FoveanatorLaser.DisplayName: Nebulous Laser FrostMist.DisplayName: Frost Mist GooglyEye.DisplayName: Googly Eye GreatSandBlast.DisplayName: Great Sand Blast diff --git a/NPCs/NormalNPCs/Foveanator.cs b/NPCs/NormalNPCs/Foveanator.cs index b1ec3e8ca6..801be02d26 100644 --- a/NPCs/NormalNPCs/Foveanator.cs +++ b/NPCs/NormalNPCs/Foveanator.cs @@ -4,6 +4,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.DataStructures; using CalamityMod.Events; +using CalamityMod.NPCs.AstrumDeus; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -27,6 +28,8 @@ namespace CalamityMod.NPCs.NormalNPCs public static int phase1IconIndex; public static int phase2IconIndex; + public static Asset GlowTexture; + internal static void LoadHeadIcons() { string phase1IconPath = "CalamityMod/NPCs/NormalNPCs/Foveanator_Head_Boss"; @@ -44,6 +47,9 @@ namespace CalamityMod.NPCs.NormalNPCs Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers() { Hide = true }; NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, bestiaryData); + + if (!Main.dedServ) + GlowTexture = ModContent.Request("CalamityMod/NPCs/NormalNPCs/FoveanatorGlow", AssetRequestMode.AsyncLoad); } public override void SetDefaults() @@ -152,7 +158,7 @@ namespace CalamityMod.NPCs.NormalNPCs hoverRotation -= MathHelper.TwoPi; // Rotate faster during energy bomb and laser barrage - float rotationRate = NPC.ai[1] == 3f ? 0.25f : 0.1f; + float rotationRate = NPC.ai[1] == 3f ? 0.25f : 0.15f; NPC.rotation = NPC.rotation.AngleTowards(hoverRotation, rotationRate); if (Main.rand.NextBool(5)) @@ -308,13 +314,12 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.ai[3] = 0f; + SoundEngine.PlaySound(AstrumDeusHead.LaserSound, NPC.Center); + if (Main.netMode != NetmodeID.MultiplayerClient) { - float laserSpeed = 12f; - laserSpeed += 4f * enrageScale; - - // TODO - Change this to Foveanator's laser when it's implemented - int type = ProjectileID.EyeLaser; + float laserSpeed = 3f + 1.5f * enrageScale; + int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); // Reduce mech boss projectile damage depending on the new ore progression changes @@ -329,7 +334,7 @@ namespace CalamityMod.NPCs.NormalNPCs } Vector2 laserVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * laserSpeed; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 150f, laserVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 60f, laserVelocity, type, damage, 0f, Main.myPlayer); } } } @@ -384,7 +389,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.velocity.Length() < maxVelocity) { - NPC.velocity *= 1.025f; + NPC.velocity *= 1.04f; if (NPC.velocity.Length() > maxVelocity) { NPC.velocity.Normalize(); @@ -458,13 +463,12 @@ namespace CalamityMod.NPCs.NormalNPCs { if (NPC.ai[1] % 10f == 0f) { - SoundEngine.PlaySound(SoundID.Item33, NPC.Center); + SoundEngine.PlaySound(AstrumDeusHead.LaserSound, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { bool shootLaser = NPC.ai[1] % 20f == 0f; - // TODO - Change this to Foveanator's lasers and energy bombs when they're implemented - int type = shootLaser ? ProjectileID.DeathLaser : ModContent.ProjectileType(); + int type = shootLaser ? ModContent.ProjectileType() : ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); // Reduce mech boss projectile damage depending on the new ore progression changes @@ -478,15 +482,15 @@ namespace CalamityMod.NPCs.NormalNPCs damage = (int)(damage * secondMechMultiplier); } - Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * 7f; + float projectileSpeed = shootLaser ? (3f + 1.5f * enrageScale) : 16f; + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; int numProj = shootLaser ? 4 : 2; int spread = shootLaser ? 15 : 30; float rotation = MathHelper.ToRadians(spread); - float offset = shootLaser ? 150f : 100f; for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * offset, perturbedSpeed, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 60f, perturbedSpeed, type, damage, 0f, Main.myPlayer); } } } @@ -614,8 +618,7 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.localAI[1] = 0f; - float foveanatorFlamethrowerSpeed = 4f; - foveanatorFlamethrowerSpeed += 2f * enrageScale; + float foveanatorFlamethrowerSpeed = 4f + 2f * enrageScale; float timeForFlamethrowerToReachMaxVelocity = 60f; float flamethrowerSpeedScalar = MathHelper.Clamp(NPC.ai[2] / timeForFlamethrowerToReachMaxVelocity, 0f, 1f); foveanatorFlamethrowerSpeed = MathHelper.Lerp(0.1f, foveanatorFlamethrowerSpeed, flamethrowerSpeedScalar); @@ -640,7 +643,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.IsMechQueenUp) flamethrowerVelocity = (NPC.rotation + MathHelper.PiOver2).ToRotationVector2() * foveanatorFlamethrowerSpeed + NPC.velocity * 0.5f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + flamethrowerVelocity.SafeNormalize(Vector2.UnitY) * 25f, flamethrowerVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + flamethrowerVelocity.SafeNormalize(Vector2.UnitY) * 40f, flamethrowerVelocity, type, damage, 0f, Main.myPlayer); } } } @@ -668,7 +671,8 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.damage = setDamage; // Play charge sound - SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); + // TODO - Make this a jet turbine sound or something + //SoundEngine.PlaySound(SoundID.ForceRoar, NPC.Center); // Set rotation and velocity NPC.rotation = hoverRotation; @@ -689,7 +693,7 @@ namespace CalamityMod.NPCs.NormalNPCs // Set damage NPC.damage = setDamage; - NPC.ai[2] += (retAlive || spazAlive) ? 1f : 1.25f; + NPC.ai[2] += 1f; float chargeTime = 60f - (death ? 20f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f); @@ -710,7 +714,6 @@ namespace CalamityMod.NPCs.NormalNPCs else { // Accelerative charge - // TODO - Make the charge leave behind energy bomb projectiles when the projectiles are done float maxVelocity = 27f; maxVelocity += 6f * enrageScale; if (death) @@ -718,9 +721,34 @@ namespace CalamityMod.NPCs.NormalNPCs if (Main.getGoodWorld) maxVelocity *= 1.2f; + // Spawn Energy Bombs along the way + float energyBombFireRate = 8f; + if (NPC.ai[2] % energyBombFireRate == 0f) + { + SoundEngine.PlaySound(AstrumDeusHead.LaserSound, NPC.Center); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + + // Reduce mech boss projectile damage depending on the new ore progression changes + if (CalamityServerConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) + { + double firstMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert; + double secondMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert; + if (!NPC.downedMechBossAny) + damage = (int)(damage * firstMechMultiplier); + else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) + damage = (int)(damage * secondMechMultiplier); + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + NPC.velocity.SafeNormalize(Vector2.UnitY) * 60f, Vector2.Zero, type, damage, 0f, Main.myPlayer); + } + } + if (NPC.velocity.Length() < maxVelocity) { - NPC.velocity *= 1.05f; + NPC.velocity *= 1.06f; if (NPC.velocity.Length() > maxVelocity) { NPC.velocity.Normalize(); @@ -785,15 +813,15 @@ namespace CalamityMod.NPCs.NormalNPCs float laserBarrageFireRate = 45f; float energyBombFireRate = 90f; - // Laser barrages NPC.ai[2] += 1f; - if (NPC.ai[2] % laserBarrageFireRate == 0f) + + // Energy bombs + if (NPC.ai[2] % energyBombFireRate == 0f) { - SoundEngine.PlaySound(SoundID.Item33, NPC.Center); + SoundEngine.PlaySound(AstrumDeusHead.LaserSound, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - // TODO - Change this to Foveanator's laser when it's made - int type = ProjectileID.DeathLaser; + int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); // Reduce mech boss projectile damage depending on the new ore progression changes @@ -807,28 +835,26 @@ namespace CalamityMod.NPCs.NormalNPCs damage = (int)(damage * secondMechMultiplier); } - Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * 12f; - int numProj = 4; - int spread = 40; + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * 16f; + int numProj = 3; + int spread = 30; float rotation = MathHelper.ToRadians(spread); for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 50f, perturbedSpeed, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 60f, perturbedSpeed, type, damage, 0f, Main.myPlayer); } } NPC.ai[3] += 1f; } - // Energy bombs - else if (NPC.ai[2] % energyBombFireRate == 0f) + else if (NPC.ai[2] % laserBarrageFireRate == 0f) { - SoundEngine.PlaySound(SoundID.Item33, NPC.Center); + SoundEngine.PlaySound(AstrumDeusHead.LaserSound, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - // TODO - Change this to Foveanator's energy bomb when it's made - int type = ModContent.ProjectileType(); + int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); // Reduce mech boss projectile damage depending on the new ore progression changes @@ -842,15 +868,15 @@ namespace CalamityMod.NPCs.NormalNPCs damage = (int)(damage * secondMechMultiplier); } - Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * 6f; - int numProj = 3; - int spread = 30; + float projectileSpeed = 4f + 2f * enrageScale; + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; + int numProj = 4; + int spread = 40; float rotation = MathHelper.ToRadians(spread); - float offset = 50f; for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * offset, perturbedSpeed, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 60f, perturbedSpeed, type, damage, 0f, Main.myPlayer); } } @@ -886,6 +912,9 @@ namespace CalamityMod.NPCs.NormalNPCs spriteBatch.Draw(TextureAssets.Npc[NPC.type].Value, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, NPC.frame.Size() / 2, NPC.scale, spriteEffects, 0f); + Texture2D glowTexture = GlowTexture.Value; + spriteBatch.Draw(glowTexture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, Color.White, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, spriteEffects, 0f); + return false; } diff --git a/NPCs/NormalNPCs/FoveanatorGlow.png b/NPCs/NormalNPCs/FoveanatorGlow.png new file mode 100644 index 0000000000..d8b3325658 Binary files /dev/null and b/NPCs/NormalNPCs/FoveanatorGlow.png differ diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs index bbcedb215e..a304726551 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs @@ -705,10 +705,25 @@ namespace CalamityMod.NPCs.ProfanedGuardians } } } - else + else if (NPC.localAI[2] == 1f) { inertia *= 1.5f; NPC.velocity = (NPC.velocity * (inertia - 1f) + targetVector * (NPC.velocity.Length() + (0.111111117f * inertia))) / inertia; + + // Stop charging towards the player when within a certain distance + if (NPC.Distance(player.Center) < 160f * NPC.scale) + NPC.localAI[2] = 2f; + } + else + { + // Slow down + if (NPC.Distance(player.Center) >= 240f * NPC.scale || NPC.localAI[2] == 3f) + { + if (NPC.localAI[2] != 3f) + NPC.localAI[2] = 3f; + + NPC.velocity *= 0.98f; + } } // Throw down holy fire while charging diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs index 3d1aca9949..1fac594587 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs @@ -646,11 +646,26 @@ namespace CalamityMod.NPCs.ProfanedGuardians } } } - else + else if (NPC.localAI[2] == 1f) { // Charge towards target float inertia = (bossRush || enraged) ? 57f : death ? 63f : revenge ? 66f : expertMode ? 69f : 75f; NPC.velocity = (NPC.velocity * (inertia - 1f) + targetVector * (NPC.velocity.Length() + (0.111111117f * inertia))) / inertia; + + // Stop charging towards the player when within a certain distance + if (NPC.Distance(player.Center) < 160f * NPC.scale) + NPC.localAI[2] = 2f; + } + else + { + // Slow down + if (NPC.Distance(player.Center) >= 240f * NPC.scale || NPC.localAI[2] == 3f) + { + if (NPC.localAI[2] != 3f) + NPC.localAI[2] = 3f; + + NPC.velocity *= 0.98f; + } } // Lay holy bombs while charging diff --git a/NPCs/SlimeGod/CrimulanPaladin.cs b/NPCs/SlimeGod/CrimulanPaladin.cs index 269c22f3ca..6a3888a392 100644 --- a/NPCs/SlimeGod/CrimulanPaladin.cs +++ b/NPCs/SlimeGod/CrimulanPaladin.cs @@ -5,8 +5,10 @@ using CalamityMod.Events; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -16,25 +18,25 @@ namespace CalamityMod.NPCs.SlimeGod public class CrimulanPaladin : ModNPC { private float bossLife; + private float addedStretch = 0f; + private float landingRecoil = 0f; public override void SetStaticDefaults() { this.HideFromBestiary(); - Main.npcFrameCount[NPC.type] = 6; } public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; NPC.GetNPCDamage(); - NPC.width = 150; - NPC.height = 92; + NPC.width = 206; + NPC.height = 156; NPC.scale = 1.1f; NPC.defense = 12; NPC.LifeMaxNERB(7500, 9000, 160000); NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.knockBackResist = 0f; - AnimationType = NPCID.KingSlime; NPC.value = 0f; NPC.Opacity = 0.8f; NPC.lavaImmune = false; @@ -91,6 +93,17 @@ namespace CalamityMod.NPCs.SlimeGod setDamage += 25; } + // Used for landing squash and stretch + if (landingRecoil > 0f) + { + landingRecoil *= 0.965f; + landingRecoil -= 0.01f; + } + else + landingRecoil = 0f; + + addedStretch = -landingRecoil; + float scale = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.6f : Main.getGoodWorld ? 0.8f : 1f; NPC.aiAction = 0; NPC.noTileCollide = false; @@ -254,90 +267,103 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[3] = 0f; NPC.netUpdate = true; } - else if (NPC.velocity.Y == 0f) - { - // Avoid cheap bullshit - NPC.damage = 0; - - NPC.TargetClosest(); - NPC.velocity.X *= 0.8f; - NPC.ai[1] += 1f; - - float jumpGateValue = 50f; - float velocityX = death ? 10f : revenge ? 9f : expertMode ? 8f : 6f; - if (revenge) - { - float moveBoost = death ? 45f * (1f - lifeRatio) : 30f * (1f - lifeRatio); - float speedBoost = death ? 4.5f * (1f - lifeRatio) : 3f * (1f - lifeRatio); - jumpGateValue -= moveBoost; - velocityX += speedBoost; - } - - float distanceBelowTarget = NPC.position.Y - (player.position.Y + 80f); - float speedMult = 1f; - if (distanceBelowTarget > 0f) - speedMult += distanceBelowTarget * 0.002f; - - if (speedMult > 2f) - speedMult = 2f; - - float velocityY = 4f; - if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) - velocityY += 2f; - - if (NPC.ai[1] > jumpGateValue) - { - // Set damage - NPC.damage = setDamage; - - NPC.ai[3] += 1f; - if (NPC.ai[3] >= 2f) - { - NPC.ai[3] = 0f; - velocityX *= 1.25f; - } - - NPC.ai[1] = 0f; - NPC.velocity.Y -= velocityY * speedMult; - NPC.velocity.X = (velocityX + distanceSpeedBoost) * NPC.direction; - NPC.noTileCollide = true; - NPC.netUpdate = true; - } - else if (NPC.ai[1] >= jumpGateValue - 30f) - NPC.aiAction = 1; - } - else - { - // Set damage - NPC.damage = setDamage; - - NPC.velocity.X *= 0.99f; - if (NPC.direction < 0 && NPC.velocity.X > -1f) - NPC.velocity.X = -1f; - if (NPC.direction > 0 && NPC.velocity.X < 1f) - NPC.velocity.X = 1f; - - if (!player.dead) - { - if (NPC.velocity.Y > 0f && NPC.Bottom.Y > player.Top.Y) - NPC.noTileCollide = false; - else if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) - NPC.noTileCollide = false; - else - NPC.noTileCollide = true; - } - } - - NPC.ai[2] += 1f; - if (revenge) - NPC.ai[2] += death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); if (NPC.velocity.Y == 0f) { // Avoid cheap bullshit NPC.damage = 0; - float phaseSwitchGateValue = 360f; + NPC.ai[2] += 1f; + if (revenge) + NPC.ai[2] += death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); + + NPC.TargetClosest(); + NPC.velocity.X *= 0.8f; + } + + float landingSquashTime = 10f; + float telegraphTime = 20f; + float phaseSwitchGateValue = 240f; + float jumpTelegraphGateValue = phaseSwitchGateValue - telegraphTime; + if (NPC.ai[2] < jumpTelegraphGateValue) + { + if (NPC.velocity.Y == 0f) + { + // Squash when landing + if (NPC.ai[1] < 0f) + landingRecoil += Math.Abs(NPC.ai[1]) / landingSquashTime; + + NPC.ai[1] += 1f; + + float jumpGateValue = 50f; + float velocityX = death ? 10f : revenge ? 9f : expertMode ? 8f : 6f; + if (revenge) + { + float moveBoost = death ? 22f * (1f - lifeRatio) : 14f * (1f - lifeRatio); + float speedBoost = death ? 4.5f * (1f - lifeRatio) : 3f * (1f - lifeRatio); + jumpGateValue -= moveBoost; + velocityX += speedBoost; + } + + float distanceBelowTarget = NPC.position.Y - (player.position.Y + 80f); + float speedMult = 1f; + if (distanceBelowTarget > 0f) + speedMult += distanceBelowTarget * 0.002f; + + if (speedMult > 2f) + speedMult = 2f; + + float velocityY = 8f; + if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) + velocityY += 4f; + + float jumpTelegraphGateValue2 = jumpGateValue - telegraphTime; + if (NPC.ai[1] >= jumpGateValue) + { + // Set damage + NPC.damage = setDamage; + + NPC.ai[3] += 1f; + if (NPC.ai[3] >= 2f) + { + NPC.ai[3] = 0f; + velocityX *= 1.25f; + } + + NPC.ai[1] = -landingSquashTime; + NPC.velocity.Y -= velocityY * speedMult; + NPC.velocity.X = (velocityX + distanceSpeedBoost) * NPC.direction; + NPC.noTileCollide = true; + NPC.netUpdate = true; + } + else if (NPC.ai[1] >= jumpTelegraphGateValue2) + landingRecoil += (NPC.ai[1] - jumpTelegraphGateValue2) / telegraphTime; + } + else + { + // Set damage + NPC.damage = setDamage; + + NPC.velocity.X *= 0.99f; + if (NPC.direction < 0 && NPC.velocity.X > -1f) + NPC.velocity.X = -1f; + if (NPC.direction > 0 && NPC.velocity.X < 1f) + NPC.velocity.X = 1f; + + if (!player.dead) + { + if (NPC.velocity.Y > 0f && NPC.Bottom.Y > player.Top.Y) + NPC.noTileCollide = false; + else if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.noTileCollide = false; + else + NPC.noTileCollide = true; + } + } + } + + if (NPC.velocity.Y == 0f) + { bool switchPhase = NPC.ai[2] >= phaseSwitchGateValue; if (switchPhase) { @@ -371,8 +397,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.netUpdate = true; } } - else if (NPC.ai[1] >= phaseSwitchGateValue - 30f) - NPC.aiAction = 1; + else if (NPC.ai[2] >= jumpTelegraphGateValue) + landingRecoil += (NPC.ai[2] - jumpTelegraphGateValue) / telegraphTime; } } else if (NPC.ai[0] == 1f) @@ -489,6 +515,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[3] = 0f; NPC.netUpdate = true; } + else + landingRecoil += NPC.ai[1] / 10f; } else if (NPC.ai[2] == 0f) NPC.noTileCollide = true; @@ -538,7 +566,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[2] += 1f; } else - NPC.aiAction = 1; + landingRecoil += NPC.ai[1] / 10f; } else { @@ -558,12 +586,18 @@ namespace CalamityMod.NPCs.SlimeGod // Avoid cheap bullshit NPC.damage = 0; - NPC.localAI[2] = NPC.ai[0]; - NPC.ai[0] = 0f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - NPC.netUpdate = true; + NPC.ai[2] += 1f; + if (NPC.ai[2] >= 23f) + { + NPC.localAI[2] = NPC.ai[0]; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } + else + landingRecoil += (NPC.ai[2] - 3f) / 10f; } } @@ -668,7 +702,7 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) { NPC.ai[0] = 0f; - NPC.ai[1] = 0f; + NPC.ai[1] = -10f; NPC.netUpdate = true; NPC.TargetClosest(); } @@ -676,7 +710,7 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportEndTime * 2f) { NPC.ai[0] = 0f; - NPC.ai[1] = 0f; + NPC.ai[1] = -10f; NPC.TargetClosest(); } @@ -691,6 +725,10 @@ namespace CalamityMod.NPCs.SlimeGod } } + // Limit the landing recoil + if (landingRecoil > 0.36f) + landingRecoil = 0.36f; + if (bossLife == 0f && NPC.life > 0) bossLife = NPC.lifeMax; @@ -705,8 +743,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.position.X = NPC.position.X + (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y + (float)NPC.height; NPC.scale = scaleRatio; - NPC.width = (int)(150f * NPC.scale); - NPC.height = (int)(92f * NPC.scale); + NPC.width = (int)(206f * NPC.scale); + NPC.height = (int)(156f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)NPC.height; } @@ -736,6 +774,27 @@ namespace CalamityMod.NPCs.SlimeGod } } + // Can only hit the target if within certain distance + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + Rectangle targetHitbox = target.Hitbox; + + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; + + return minDist <= 75f * NPC.scale; + } + public override Color? GetAlpha(Color drawColor) { Color lightColor = new Color(Main.DiscoR, 100, 150, NPC.alpha); @@ -743,6 +802,31 @@ namespace CalamityMod.NPCs.SlimeGod return newColor * NPC.Opacity; } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D texture = TextureAssets.Npc[Type].Value; + Color drawColorAlpha = NPC.GetAlpha(drawColor); + + // Stretch based on Y velocity. + float stretch = NPC.velocity.Y * 0.03f; + stretch = Math.Abs(stretch) + addedStretch; + + // Stretch rapidly if about to jump or teleport, stretch normally while idle. + if (NPC.velocity.Y == 0f) + stretch += MathHelper.Lerp(0f, 0.16f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * (NPC.aiAction == 1 ? 15f : 2f)) / 2f + 0.5f); + + if (stretch > 0.5f) + stretch = 0.5f; + + Vector2 scaleStretch = new Vector2(1f - stretch, 1f + stretch) * NPC.scale; + float yOffset = stretch * 0.5f * NPC.height; + + spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY - yOffset), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() * 0.5f, scaleStretch, spriteEffects, 0f); + + return false; + } + public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Crimson; diff --git a/NPCs/SlimeGod/CrimulanPaladin.png b/NPCs/SlimeGod/CrimulanPaladin.png index 4496f5c719..dce53c4106 100644 Binary files a/NPCs/SlimeGod/CrimulanPaladin.png and b/NPCs/SlimeGod/CrimulanPaladin.png differ diff --git a/NPCs/SlimeGod/EbonianPaladin.cs b/NPCs/SlimeGod/EbonianPaladin.cs index 93dee0df3c..c3a898aab7 100644 --- a/NPCs/SlimeGod/EbonianPaladin.cs +++ b/NPCs/SlimeGod/EbonianPaladin.cs @@ -5,8 +5,11 @@ using CalamityMod.Events; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -16,27 +19,35 @@ namespace CalamityMod.NPCs.SlimeGod public class EbonianPaladin : ModNPC { private float bossLife; + private float addedStretch = 0f; + private int wingFrameDrawn = 0; + private const int TotalWingFrames = 8; + + public static Asset WingTexture; public override void SetStaticDefaults() { this.HideFromBestiary(); - Main.npcFrameCount[NPC.type] = 6; + + if (!Main.dedServ) + WingTexture = ModContent.Request("CalamityMod/NPCs/SlimeGod/ExtraTextures/EbonianPaladinWings", AssetRequestMode.AsyncLoad); } public override void SetDefaults() { NPC.Calamity().canBreakPlayerDefense = true; NPC.GetNPCDamage(); - NPC.width = 150; - NPC.height = 92; + NPC.width = 134; + NPC.height = 150; NPC.scale = 1.1f; NPC.defense = 10; NPC.LifeMaxNERB(8000, 9600, 220000); NPC.BossBar = Main.BigBossProgressBar.NeverValid; + NPC.noTileCollide = true; + NPC.noGravity = true; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - AnimationType = NPCID.KingSlime; NPC.value = 0f; NPC.Opacity = 0.8f; NPC.HitSound = SoundID.NPCHit1; @@ -50,7 +61,6 @@ namespace CalamityMod.NPCs.SlimeGod public override void SendExtraAI(BinaryWriter writer) { - writer.Write(NPC.localAI[0]); writer.Write(NPC.localAI[1]); writer.Write(NPC.localAI[2]); writer.Write(NPC.localAI[3]); @@ -60,7 +70,6 @@ namespace CalamityMod.NPCs.SlimeGod public override void ReceiveExtraAI(BinaryReader reader) { - NPC.localAI[0] = reader.ReadSingle(); NPC.localAI[1] = reader.ReadSingle(); NPC.localAI[2] = reader.ReadSingle(); NPC.localAI[3] = reader.ReadSingle(); @@ -90,8 +99,6 @@ namespace CalamityMod.NPCs.SlimeGod float scale = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.6f : Main.getGoodWorld ? 0.8f : 1f; NPC.aiAction = 0; - NPC.noTileCollide = false; - NPC.noGravity = false; // Get a target if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) @@ -115,7 +122,6 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[1] = 0f; NPC.ai[2] = 0f; NPC.ai[3] = 0f; - calamityGlobalNPC.newAI[0] = 0f; NPC.netUpdate = true; } } @@ -160,449 +166,151 @@ namespace CalamityMod.NPCs.SlimeGod hyperMode = true; } - // Teleport - float teleportGateValue = 720f; - if (!player.dead && NPC.timeLeft > 10 && calamityGlobalNPC.newAI[0] >= teleportGateValue && NPC.ai[0] == 0f && NPC.velocity.Y == 0f) + // For animating the wings + NPC.localAI[0] += 1f; + + if (NPC.ai[0] == 0f) { // Avoid cheap bullshit NPC.damage = 0; - // Slow down dramatically - NPC.velocity.X *= 0.5f; + NPC.TargetClosest(); - NPC.ai[0] = 6f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - if (Main.netMode != NetmodeID.MultiplayerClient) + FlyMovement(NPC); + + if (NPC.timeLeft > 10) { - NPC.netUpdate = true; - NPC.TargetClosest(false); - player = Main.player[NPC.target]; - - float distanceAhead = 800f; - Vector2 randomDefault = Main.rand.NextBool() ? Vector2.UnitX : -Vector2.UnitX; - Vector2 vectorAimedAheadOfTarget = player.Center + new Vector2((float)Math.Round(player.velocity.X), 0f).SafeNormalize(randomDefault) * distanceAhead; - Point predictiveTeleportPoint = vectorAimedAheadOfTarget.ToTileCoordinates(); - int randomPredictiveTeleportOffset = 5; - int teleportTries = 0; - while (teleportTries < 100) + NPC.ai[1] += 1f; + int idleTime = bossRush ? 30 : death ? 75 : revenge ? 90 : 120; + if (NPC.ai[1] >= idleTime) { - teleportTries++; - int teleportTileX = Main.rand.Next(predictiveTeleportPoint.X - randomPredictiveTeleportOffset, predictiveTeleportPoint.X + randomPredictiveTeleportOffset + 1); - int teleportTileY = Main.rand.Next(predictiveTeleportPoint.Y - randomPredictiveTeleportOffset, predictiveTeleportPoint.Y); - - if (!Main.tile[teleportTileX, teleportTileY].HasUnactuatedTile) - { - bool canTeleportToTile = true; - if (canTeleportToTile && Main.tile[teleportTileX, teleportTileY].LiquidType == LiquidID.Lava) - canTeleportToTile = false; - if (canTeleportToTile && !Collision.CanHitLine(NPC.Center, 0, 0, predictiveTeleportPoint.ToVector2() * 16, 0, 0)) - canTeleportToTile = false; - - if (canTeleportToTile) - { - NPC.localAI[0] = teleportTileX * 16 + 8; - NPC.localAI[3] = teleportTileY * 16 + 16; - calamityGlobalNPC.newAI[0] = 0f; - break; - } - else - predictiveTeleportPoint.X += predictiveTeleportPoint.X < 0f ? 1 : -1; - } - else - predictiveTeleportPoint.X += predictiveTeleportPoint.X < 0f ? 1 : -1; - } - - // Default teleport if the above conditions aren't met in 100 iterations - if (teleportTries >= 100) - { - Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; - NPC.localAI[0] = bottom.X; - NPC.localAI[3] = bottom.Y; - calamityGlobalNPC.newAI[0] = 0f; - } - } - } - - // Get ready to teleport by increasing ai[3] - if (calamityGlobalNPC.newAI[0] < teleportGateValue) - { - if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > 320f) - calamityGlobalNPC.newAI[0] += death ? 3f : 2f; - else - calamityGlobalNPC.newAI[0] += 1f; - } - - float distanceSpeedBoost = Vector2.Distance(player.Center, NPC.Center) * (bossRush ? 0.008f : 0.005f); - - if (NPC.ai[0] == 0f) - { - bool phaseThroughTilesToReachTarget = Vector2.Distance(player.Center, NPC.Center) > 2400f || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); - if (Main.netMode != NetmodeID.MultiplayerClient && phaseThroughTilesToReachTarget) - { - // Set damage - NPC.damage = setDamage; - - NPC.ai[0] = 5f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - NPC.netUpdate = true; - } - - if (NPC.velocity.Y == 0f) - { - // Avoid cheap bullshit - NPC.damage = 0; - - NPC.TargetClosest(); - NPC.velocity.X *= 0.8f; - NPC.ai[1] += hyperMode ? 2f : 1f; - - float jumpGateValue = 60f; - float velocityX = death ? 8f : revenge ? 7f : expertMode ? 6f : 4f; - if (revenge) - { - float moveBoost = death ? 60f * (1f - lifeRatio) : 40f * (1f - lifeRatio); - float speedBoost = death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); - jumpGateValue -= moveBoost; - velocityX += speedBoost; - } - - float distanceBelowTarget = NPC.position.Y - (player.position.Y + 80f); - float speedMult = 1f; - if (distanceBelowTarget > 0f) - speedMult += distanceBelowTarget * 0.002f; - - if (speedMult > 2f) - speedMult = 2f; - - float velocityY = 5f; - if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) - velocityY += 2f; - - if (NPC.ai[1] > jumpGateValue) - { - // Set damage - NPC.damage = setDamage; - - NPC.ai[3] += 1f; - if (NPC.ai[3] >= 2f) - { - NPC.ai[3] = 0f; - velocityY *= 1.25f; - } - NPC.ai[1] = 0f; - NPC.velocity.Y -= velocityY * speedMult; - NPC.velocity.X = (velocityX + distanceSpeedBoost) * NPC.direction; - NPC.noTileCollide = true; + switch ((int)NPC.Calamity().newAI[0]) + { + default: + NPC.ai[0] = Main.rand.NextBool() ? 1f : 2f; + break; + case 1: + NPC.ai[0] = Main.rand.NextBool() ? 2f : 3f; + break; + case 2: + NPC.ai[0] = Main.rand.NextBool() ? 3f : 1f; + break; + } + + // Pick directional movements for slime bombardment + if (NPC.ai[0] == 2f) + NPC.ai[2] = NPC.Center.X - player.Center.X > 0f ? 1f : -1f; + NPC.netUpdate = true; } - else if (NPC.ai[1] >= jumpGateValue - 30f) - NPC.aiAction = 1; - } - else - { - // Set damage - NPC.damage = setDamage; - - NPC.velocity.X *= 0.99f; - if (NPC.direction < 0 && NPC.velocity.X > -1f) - NPC.velocity.X = -1f; - if (NPC.direction > 0 && NPC.velocity.X < 1f) - NPC.velocity.X = 1f; - - if (!player.dead) - { - if (NPC.velocity.Y > 0f && NPC.Bottom.Y > player.Top.Y) - NPC.noTileCollide = false; - else if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) - NPC.noTileCollide = false; - else - NPC.noTileCollide = true; - } - } - - NPC.ai[2] += 1f; - if (revenge) - NPC.ai[2] += death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); - - if (NPC.velocity.Y == 0f) - { - // Avoid cheap bullshit - NPC.damage = 0; - - float phaseSwitchGateValue = 420f; - bool switchPhase = NPC.ai[2] >= phaseSwitchGateValue; - if (switchPhase) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - switch ((int)NPC.localAI[2]) - { - default: - case 1: - NPC.ai[0] = Main.rand.NextBool() ? 2f : 3f; - break; - - case 2: - NPC.ai[0] = Main.rand.NextBool() ? 3f : (hyperMode ? 2f : 1f); - break; - - case 3: - NPC.ai[0] = Main.rand.NextBool() ? (hyperMode ? 3f : 1f) : 2f; - break; - } - - if (NPC.ai[0] == 2f) - { - // Set damage - NPC.damage = setDamage; - - NPC.noTileCollide = true; - NPC.velocity.Y = death ? -9f : revenge ? -8f : expertMode ? -7f : -6f; - } - - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - NPC.netUpdate = true; - } - } - else if (NPC.ai[1] >= phaseSwitchGateValue - 30f) - NPC.aiAction = 1; } } + + // Spread of slime projectiles else if (NPC.ai[0] == 1f) { // Avoid cheap bullshit NPC.damage = 0; - NPC.velocity.X *= 0.85f; + NPC.rotation *= 0.9f; - NPC.ai[1] += 1f; - if (NPC.ai[1] >= 30f) + if (NPC.ai[2] == 1f) { - if (revenge) + // Set animation timer to one in order to prevent weird quick animation here + NPC.localAI[0] = 1f; + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 10f) { - float slimeShotVelocity = 6f; - Vector2 projectileVelocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * slimeShotVelocity; float minFiringDistance = 160f; // 10 tile distance if (Vector2.Distance(NPC.Center, player.Center) > minFiringDistance) { - SoundEngine.PlaySound(SlimeGodCore.BigShotSound, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { + int numProjectiles = Main.getGoodWorld ? 12 : death ? 6 : 4; + float projectileVelocity = death ? 8f : 6f; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - int numProj = death ? 6 : 4; - int spread = death ? 15 : 10; - float rotation = MathHelper.ToRadians(spread); - for (int j = 0; j < numProj; j++) + Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y + 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); + destination *= projectileVelocity; + float rotation = MathHelper.ToRadians(80); + for (int i = 0; i < numProjectiles; i++) { - Vector2 randomVelocity = Main.rand.NextVector2CircularEdge(3f, 3f); - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, j / (float)(numProj - 1))) + randomVelocity; + if (CalamityWorld.LegendaryMode) + destination *= Main.rand.NextFloat() + 0.5f; + + Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProjectiles - 1))); Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale, perturbedSpeed, type, damage, 0f, Main.myPlayer); } } - } - } - NPC.localAI[2] = NPC.ai[0]; - NPC.ai[0] = 0f; - NPC.ai[1] = 0f; + SoundEngine.PlaySound(SlimeGodCore.BigShotSound, NPC.Center); + } + + NPC.Calamity().newAI[0] = NPC.ai[0]; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; + } + } + + if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[1] == 0f) + { + NPC.TargetClosest(); NPC.netUpdate = true; } + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= 50f) + { + NPC.ai[1] = 50f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[1] = 0f; + NPC.ai[2] = 1f; + NPC.netUpdate = true; + } + } + + FlyMovement(NPC); } + + // Fly overhead in a horizontal line and drop slime else if (NPC.ai[0] == 2f) { // Avoid cheap bullshit NPC.damage = 0; - NPC.noTileCollide = true; - NPC.noGravity = true; + FlyMovement(NPC, true); - if (NPC.velocity.X < 0f) - NPC.direction = -1; - else - NPC.direction = 1; - - NPC.spriteDirection = NPC.direction; - NPC.TargetClosest(); - Vector2 targetCenter = player.Center; - targetCenter.Y -= 350f; - Vector2 targetDist = targetCenter - NPC.Center; - - if (NPC.ai[2] == 1f) + // Drop slime while flying horizontally + if (NPC.ai[1] == 1f) { - NPC.ai[1] += 1f; - targetDist = player.Center - NPC.Center; - targetDist.Normalize(); - targetDist *= death ? 9f : revenge ? 8f : expertMode ? 7f : 6f; - NPC.velocity = (NPC.velocity * 4f + targetDist) / 5f; - - if (NPC.ai[1] > 12f) + NPC.ai[3] += 1f; + float slimeDropGateValue = bossRush ? 10f : death ? 20f : revenge ? 25f : expertMode ? 30f : 40f; + if (NPC.ai[3] % slimeDropGateValue == 0f) { - NPC.ai[1] = 0f; - NPC.ai[0] = 2.1f; - NPC.ai[2] = 0f; - NPC.velocity = targetDist; - } - } - else - { - if (Math.Abs(NPC.Center.X - player.Center.X) < 40f && NPC.Center.Y < player.Center.Y - 300f) - { - NPC.ai[1] = 0f; - NPC.ai[2] = 1f; - return; - } - - targetDist.Normalize(); - targetDist *= (death ? 11f : revenge ? 10f : expertMode ? 9f : 8f) + distanceSpeedBoost; - NPC.velocity = (NPC.velocity * 5f + targetDist) / 6f; - } - } - else if (NPC.ai[0] == 2.1f) - { - // Set damage - NPC.damage = setDamage; - - bool atTargetPosition = NPC.position.Y + NPC.height >= player.position.Y; - if (NPC.ai[2] == 0f && atTargetPosition && Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) - { - NPC.ai[2] = 1f; - NPC.netUpdate = true; - } - - if (atTargetPosition || NPC.velocity.Y <= 0f) - { - // Avoid cheap bullshit - NPC.damage = 0; - - NPC.ai[1] += 1f; - if (NPC.ai[1] > 10f) - { - SoundEngine.PlaySound(SlimeGodCore.BigShotSound, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - // Eruption of slime balls - float projectileVelocity = 4f; + float projectileVelocity = 3f; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; - destination.Normalize(); + Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y + 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); destination *= projectileVelocity; - int numProj = 11; - float rotation = MathHelper.ToRadians(90); - for (int i = 0; i < numProj; i++) - { - // Spawn projectiles 0, 1, 2, 3, 7, 8, 9 and 10 - if (i < 4 || i > 6) - { - Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitY * 30f * NPC.scale + Vector2.Normalize(perturbedSpeed) * 30f * NPC.scale, perturbedSpeed, type, damage, 0f, Main.myPlayer); - } - } - - // Fire slime balls directly at players with a max of 2 - if (enraged && expertMode) - { - List targets = new List(); - foreach (Player plr in Main.ActivePlayers) - { - if (!plr.dead) - targets.Add(plr.whoAmI); - - if (targets.Count > 1) - break; - } - foreach (int t in targets) - { - Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projFireDirection) * 30f * NPC.scale, projFireDirection, type, damage, 0f, Main.myPlayer); - } - } + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + destination.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale, destination, type, damage, 0f, Main.myPlayer, 1f); } - NPC.localAI[2] = NPC.ai[0] - 0.1f; - NPC.ai[0] = 0f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - NPC.netUpdate = true; + SoundEngine.PlaySound(SlimeGodCore.ShotSound, NPC.Center); } - } - else if (NPC.ai[2] == 0f) - NPC.noTileCollide = true; - NPC.noGravity = true; - - NPC.velocity.Y += 0.5f; - float velocityLimit = bossRush ? 20f : death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; - if (NPC.velocity.Y > velocityLimit) - NPC.velocity.Y = velocityLimit; - } - else if (NPC.ai[0] == 3f) - { - if (NPC.velocity.Y == 0f) - { - // Avoid cheap bullshit - NPC.damage = 0; - - NPC.TargetClosest(); - NPC.velocity.X *= 0.8f; - - NPC.ai[1] += 1f; - if (NPC.ai[1] > 15f) - { - // Set damage - NPC.damage = setDamage; - - NPC.ai[1] = 0f; - - NPC.velocity.Y -= 6f; - if (player.position.Y + player.height < NPC.Center.Y) - NPC.velocity.Y -= 1.2f; - if (player.position.Y + player.height < NPC.Center.Y - 40f) - NPC.velocity.Y -= 1.4f; - if (player.position.Y + player.height < NPC.Center.Y - 80f) - NPC.velocity.Y -= 1.7f; - if (player.position.Y + player.height < NPC.Center.Y - 120f) - NPC.velocity.Y -= 2f; - if (player.position.Y + player.height < NPC.Center.Y - 160f) - NPC.velocity.Y -= 2.2f; - if (player.position.Y + player.height < NPC.Center.Y - 200f) - NPC.velocity.Y -= 2.4f; - if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) - NPC.velocity.Y -= 2f; - - NPC.velocity.X = ((death ? 11f : revenge ? 10f : expertMode ? 9f : 8f) + distanceSpeedBoost) * NPC.direction; - NPC.ai[2] += 1f; - } - else - NPC.aiAction = 1; - } - else - { - // Set damage - NPC.damage = setDamage; - - NPC.velocity.X *= 0.98f; - float velocityLimit = (death ? 6.5f : revenge ? 6f : expertMode ? 5.5f : 5f); - if (NPC.direction < 0 && NPC.velocity.X > -velocityLimit) - NPC.velocity.X = -velocityLimit; - if (NPC.direction > 0 && NPC.velocity.X < velocityLimit) - NPC.velocity.X = velocityLimit; + NPC.aiAction = 1; } - if (NPC.ai[2] >= 2f && NPC.velocity.Y == 0f) + if (NPC.ai[1] == 2f) { - // Avoid cheap bullshit - NPC.damage = 0; - - NPC.localAI[2] = NPC.ai[0]; + NPC.Calamity().newAI[0] = NPC.ai[0]; NPC.ai[0] = 0f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; @@ -611,13 +319,125 @@ namespace CalamityMod.NPCs.SlimeGod } } + // Charge by swooping down + else if (NPC.ai[0] == 3f) + { + // Charge variables + float chargeVelocityMult = 0.125f; + float maxChargeVelocity = (bossRush || enraged) ? 24f : death ? 21f : revenge ? 19.5f : expertMode ? 18f : 15f; + if (Main.getGoodWorld) + maxChargeVelocity *= 1.15f; + if (CalamityWorld.LegendaryMode && revenge) + maxChargeVelocity *= 2f; + + float inertia = (bossRush || enraged) ? 50f : death ? 55f : revenge ? 57f : expertMode ? 60f : 65f; + if (lifeRatio < 0.75f) + inertia *= 0.8f; + if (Main.getGoodWorld) + inertia *= 0.8f; + + // Start charge + if (NPC.ai[1] == 0f) + { + // Set damage + NPC.damage = setDamage; + + Vector2 velocity = (player.Center - NPC.Center).SafeNormalize(new Vector2(NPC.direction, 0f)) * maxChargeVelocity; + NPC.velocity = velocity * chargeVelocityMult; + + NPC.ai[1] = 1f; + NPC.netUpdate = true; + + SoundEngine.PlaySound(SlimeGodCore.BigShotSound, NPC.Center); + + NPC.aiAction = 1; + } + else if (NPC.ai[1] == 1f) + { + // Set damage + NPC.damage = setDamage; + + NPC.ai[2] += 1f; + float phaseGateValue = (bossRush || enraged) ? 120f : death ? 140f : revenge ? 150f : expertMode ? 160f : 180f; + if (NPC.ai[2] >= phaseGateValue) + { + NPC.ai[1] = 2f; + float slowDownDurationAfterCharge = revenge ? 90f : 120f; + NPC.ai[2] = slowDownDurationAfterCharge; + NPC.localAI[2] = 0f; + NPC.velocity /= 2f; + NPC.netUpdate = true; + } + else + { + Vector2 targetVector = (player.Center - NPC.Center).SafeNormalize(new Vector2(NPC.direction, 0f)); + + if (NPC.localAI[2] == 0f) + { + // Accelerate + if (NPC.velocity.Length() < maxChargeVelocity) + { + float velocityMult = (bossRush || enraged) ? 1.045f : death ? 1.039f : revenge ? 1.036f : expertMode ? 1.033f : 1.03f; + NPC.velocity = targetVector * (NPC.velocity.Length() * velocityMult); + if (NPC.velocity.Length() > maxChargeVelocity) + { + NPC.localAI[2] = 1f; + NPC.velocity = NPC.velocity.SafeNormalize(new Vector2(NPC.direction, 0f)) * maxChargeVelocity; + } + } + } + else if (NPC.localAI[2] == 1f) + { + inertia *= 2f; + NPC.velocity = (NPC.velocity * (inertia - 1f) + targetVector * (NPC.velocity.Length() + (0.111111117f * inertia))) / inertia; + + // Stop charging towards the player when within a certain distance + if (NPC.Distance(player.Center) < 130f * NPC.scale) + NPC.localAI[2] = 2f; + } + else + { + // Slow down + if (NPC.Distance(player.Center) >= 210f * NPC.scale || NPC.localAI[2] == 3f) + { + if (NPC.localAI[2] != 3f) + NPC.localAI[2] = 3f; + + NPC.velocity *= 0.97f; + } + } + } + + NPC.aiAction = 1; + } + else + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[2] -= 1f; + if (NPC.ai[2] <= 0f) + { + NPC.Calamity().newAI[0] = NPC.ai[0]; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.localAI[2] = 0f; + + NPC.TargetClosest(); + NPC.netUpdate = true; + } + + NPC.velocity *= 0.95f; + } + } + // Despawn else if (NPC.ai[0] == 4f) { // Avoid cheap bullshit NPC.damage = 0; - NPC.noTileCollide = true; NPC.Opacity -= 0.03f; if (NPC.timeLeft > 10) @@ -629,111 +449,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.98f; } - else if (NPC.ai[0] == 5f) - { - // Set damage - NPC.damage = setDamage; - - if (NPC.velocity.X > 0f) - NPC.direction = 1; - else - NPC.direction = -1; - - NPC.spriteDirection = NPC.direction; - NPC.noTileCollide = true; - NPC.noGravity = true; - NPC.knockBackResist = 0f; - Vector2 distanceFromTarget = player.Center - NPC.Center; - distanceFromTarget.Y -= 16f; - if (Main.netMode != NetmodeID.MultiplayerClient && distanceFromTarget.Length() < 500f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height) && - Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) - { - // Avoid cheap bullshit - NPC.damage = 0; - - NPC.ai[0] = 0f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - NPC.netUpdate = true; - } - - if (distanceFromTarget.Length() > 12f) - { - distanceFromTarget.Normalize(); - distanceFromTarget *= 12f; - } - - NPC.velocity = (NPC.velocity * 4f + distanceFromTarget) / 5f; - } - else if (NPC.ai[0] == 6f) - { - // Avoid cheap bullshit - NPC.damage = 0; - - NPC.aiAction = 1; - NPC.ai[1] += 1f; - float teleportTime = bossRush ? 20f : death ? 30f : 40f; - scale = MathHelper.Clamp((teleportTime - NPC.ai[1]) / teleportTime, 0f, 1f); - scale = 0.5f + scale * 0.5f; - if (NPC.ai[1] >= teleportTime && Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.Bottom = new Vector2(NPC.localAI[0], NPC.localAI[3]); - NPC.ai[0] = 7f; - NPC.ai[1] = 0f; - NPC.netUpdate = true; - } - - if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportTime * 2f) - { - NPC.ai[0] = 7f; - NPC.ai[1] = 0f; - } - - // Emit teleport dust - Color dustColor = Color.Lavender; - dustColor.A = 150; - for (int i = 0; i < 10; i++) - { - int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[corruptDust].noGravity = true; - Main.dust[corruptDust].velocity *= 0.5f; - } - } - else if (NPC.ai[0] == 7f) - { - // Avoid cheap bullshit - NPC.damage = 0; - - NPC.ai[1] += 1f; - float teleportEndTime = bossRush ? 10f : death ? 15f : 20f; - scale = MathHelper.Clamp(NPC.ai[1] / teleportEndTime, 0f, 1f); - scale = 0.5f + scale * 0.5f; - if (NPC.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.ai[0] = 0f; - NPC.ai[1] = 0f; - NPC.netUpdate = true; - NPC.TargetClosest(); - } - - if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportEndTime * 2f) - { - NPC.ai[0] = 0f; - NPC.ai[1] = 0f; - NPC.TargetClosest(); - } - - // Emit teleport dust - Color dustColor = Color.Lavender; - dustColor.A = 150; - for (int i = 0; i < 10; i++) - { - int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); - Main.dust[corruptDust].noGravity = true; - Main.dust[corruptDust].velocity *= 0.5f; - } - } + NPC.rotation = MathHelper.Clamp(NPC.velocity.X * 0.05f, -0.5f, 0.5f); if (bossLife == 0f && NPC.life > 0) bossLife = NPC.lifeMax; @@ -749,8 +465,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.position.X = NPC.position.X + (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y + (float)NPC.height; NPC.scale = scaleRatio; - NPC.width = (int)(150f * NPC.scale); - NPC.height = (int)(92f * NPC.scale); + NPC.width = (int)(134f * NPC.scale); + NPC.height = (int)(150f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)NPC.height; } @@ -774,13 +490,129 @@ namespace CalamityMod.NPCs.SlimeGod Main.npc[slimeSpawn].ai[0] = (float)(-1000 * Main.rand.Next(3)); Main.npc[slimeSpawn].ai[1] = 0f; if (Main.netMode == NetmodeID.Server && slimeSpawn < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn); } } } } } + public static void FlyMovement(NPC npc, bool slimeBombardment = false) + { + // Difficulty bools + bool bossRush = BossRushEvent.BossRushActive; + bool masterMode = Main.masterMode; + bool death = CalamityWorld.death; + bool revenge = CalamityWorld.revenge; + bool ableToDropSlime = npc.ai[1] == 1f; + + float flyVelocity = bossRush ? 20f : death ? 15f : revenge ? 12.5f : 10f; + float flyAcceleration = bossRush ? 0.24f : death ? 0.18f : revenge ? 0.15f : 0.12f; + + if (slimeBombardment) + { + // Increase max velocity while attempting to line up the bombardment + if (!ableToDropSlime) + flyVelocity *= 1.5f; + + // Keep acceleration high to maintain the bombardment path + flyAcceleration *= 2f; + } + + float slimeBombardmentDistance = 720f; + float flyDistanceY = slimeBombardment ? -450f : masterMode ? -360f : -405f; + float flyDistanceX = slimeBombardment ? (ableToDropSlime ? (slimeBombardmentDistance * -npc.ai[2]) : (slimeBombardmentDistance * npc.ai[2])) : 0f; + Vector2 destination = Main.player[npc.target].Center + new Vector2(flyDistanceX, flyDistanceY); + + if (slimeBombardment) + { + if (!ableToDropSlime) + { + if (npc.Distance(destination) < 40f) + npc.ai[1] = 1f; + } + else + { + if (npc.ai[3] >= 180f || npc.Distance(destination) < 40f) + npc.ai[1] = 2f; + } + } + + Vector2 desiredVelocity = npc.Center; + + if (npc.timeLeft > 10) + { + if (!Collision.CanHit(npc, Main.player[npc.target]) && !slimeBombardment) + { + bool flyToSolidTilesAboveTarget = false; + Vector2 center = Main.player[npc.target].Center; + for (int i = 0; i < 16; i++) + { + float tileDistanceAboveTarget = 16 * i; + Point point = (center + new Vector2(0f, -tileDistanceAboveTarget)).ToTileCoordinates(); + if (WorldGen.SolidOrSlopedTile(point.X, point.Y)) + { + desiredVelocity = center + new Vector2(0f, -tileDistanceAboveTarget + 16f) - npc.Center; + flyToSolidTilesAboveTarget = true; + break; + } + } + + if (!flyToSolidTilesAboveTarget) + desiredVelocity = center - npc.Center; + } + else + desiredVelocity = destination - npc.Center; + } + else + desiredVelocity = npc.Center + new Vector2(500f * npc.direction, flyDistanceY) - npc.Center; + + float distanceFromFlightTarget = desiredVelocity.Length(); + if (Math.Abs(desiredVelocity.X) < 40f) + desiredVelocity.X = npc.velocity.X; + + if (distanceFromFlightTarget > 100f && ((npc.velocity.X < -12f && desiredVelocity.X > 0f) || (npc.velocity.X > 12f && desiredVelocity.X < 0f))) + flyAcceleration *= 1.5f; + + if (distanceFromFlightTarget < 40f) + { + desiredVelocity = npc.velocity; + } + else if (distanceFromFlightTarget < 80f) + { + desiredVelocity = desiredVelocity.SafeNormalize(Vector2.UnitY); + desiredVelocity *= flyVelocity * 0.65f; + } + else + { + desiredVelocity = desiredVelocity.SafeNormalize(Vector2.UnitY); + desiredVelocity *= flyVelocity; + } + + npc.SimpleFlyMovement(desiredVelocity, flyAcceleration); + } + + // Can only hit the target if within certain distance + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + Rectangle targetHitbox = target.Hitbox; + + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; + + return minDist <= 65f * NPC.scale; + } + public override Color? GetAlpha(Color drawColor) { Color lightColor = new Color(200, 150, Main.DiscoB, NPC.alpha); @@ -788,14 +620,70 @@ namespace CalamityMod.NPCs.SlimeGod return newColor * NPC.Opacity; } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D texture = TextureAssets.Npc[Type].Value; + Texture2D wingTexture = WingTexture.Value; + Color drawColorAlpha = NPC.GetAlpha(drawColor); + + // Stretch based on Y velocity. + float stretch = NPC.velocity.Y * 0.015f; + stretch = Math.Abs(stretch) + addedStretch; + + // Stretch rapidly if about to jump or teleport. + if (NPC.aiAction == 1) + stretch += MathHelper.Lerp(0f, 0.32f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 10f) / 2f + 0.5f); + + // Stretch while idle. + else + stretch += MathHelper.Lerp(0f, 0.16f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2f) / 2f + 0.5f); + + if (stretch > 0.5f) + stretch = 0.5f; + + Vector2 scaleStretch = new Vector2(1f - stretch, 1f + stretch) * NPC.scale; + + // Used for animating the wings. + bool blobSpreadPhase = NPC.ai[0] == 1f; + bool useFurledWingFrame = blobSpreadPhase && NPC.ai[1] >= 20f; + bool useSpreadWingFrame = blobSpreadPhase && NPC.ai[2] == 1f; + bool slimeBombardmentPhase = NPC.ai[0] == 2f; + bool slightlyIncreaseWingAnimationSpeed = slimeBombardmentPhase && NPC.ai[1] == 1f; + bool swoopingPhase = NPC.ai[0] == 3f; + bool increaseWingAnimationSpeed = swoopingPhase && NPC.ai[1] < 2f; + bool decreaseWingAnimationSpeed = swoopingPhase && NPC.ai[1] == 2f; + if (useFurledWingFrame) + { + wingFrameDrawn = 4; + } + else if (useSpreadWingFrame) + { + wingFrameDrawn = 0; + } + else if (NPC.localAI[0] % (decreaseWingAnimationSpeed ? 9f : increaseWingAnimationSpeed ? 4f : slightlyIncreaseWingAnimationSpeed ? 5f : 6f) == 0f) + { + wingFrameDrawn++; + if (wingFrameDrawn >= TotalWingFrames) + wingFrameDrawn = 0; + } + Rectangle wingFrame = new Rectangle(0, wingTexture.Height / TotalWingFrames * wingFrameDrawn, wingTexture.Width, wingTexture.Height / TotalWingFrames); + Vector2 wingOrigin = new Vector2(wingTexture.Width, wingTexture.Height / TotalWingFrames) * 0.5f; + + // Draw the wings. + spriteBatch.Draw(wingTexture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), wingFrame, drawColorAlpha, NPC.rotation, wingOrigin, scaleStretch, spriteEffects, 0f); + + spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() * 0.5f, scaleStretch, spriteEffects, 0f); + + return false; + } + public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Lavender; dustColor.A = 150; for (int k = 0; k < 5; k++) - { Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } } public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) diff --git a/NPCs/SlimeGod/EbonianPaladin.png b/NPCs/SlimeGod/EbonianPaladin.png index 11d5836fe5..ac53c2dc32 100644 Binary files a/NPCs/SlimeGod/EbonianPaladin.png and b/NPCs/SlimeGod/EbonianPaladin.png differ diff --git a/NPCs/SlimeGod/ExtraTextures/EbonianPaladinWings.png b/NPCs/SlimeGod/ExtraTextures/EbonianPaladinWings.png new file mode 100644 index 0000000000..0729cab386 Binary files /dev/null and b/NPCs/SlimeGod/ExtraTextures/EbonianPaladinWings.png differ diff --git a/NPCs/SlimeGod/ExtraTextures/QueenSlimeGodCore.png b/NPCs/SlimeGod/ExtraTextures/QueenSlimeGodCore.png new file mode 100644 index 0000000000..274f324303 Binary files /dev/null and b/NPCs/SlimeGod/ExtraTextures/QueenSlimeGodCore.png differ diff --git a/NPCs/SlimeGod/ExtraTextures/SlimeGodCoreEye.png b/NPCs/SlimeGod/ExtraTextures/SlimeGodCoreEye.png new file mode 100644 index 0000000000..6e925fbe03 Binary files /dev/null and b/NPCs/SlimeGod/ExtraTextures/SlimeGodCoreEye.png differ diff --git a/NPCs/SlimeGod/ExtraTextures/SlimeGodCoreEyeGlow.png b/NPCs/SlimeGod/ExtraTextures/SlimeGodCoreEyeGlow.png new file mode 100644 index 0000000000..a93444db0d Binary files /dev/null and b/NPCs/SlimeGod/ExtraTextures/SlimeGodCoreEyeGlow.png differ diff --git a/NPCs/SlimeGod/ExtraTextures/SlimeGodCoreOverlay.png b/NPCs/SlimeGod/ExtraTextures/SlimeGodCoreOverlay.png new file mode 100644 index 0000000000..13ec3b7498 Binary files /dev/null and b/NPCs/SlimeGod/ExtraTextures/SlimeGodCoreOverlay.png differ diff --git a/NPCs/SlimeGod/ExtraTextures/SlimeGodCorePossession.png b/NPCs/SlimeGod/ExtraTextures/SlimeGodCorePossession.png new file mode 100644 index 0000000000..cd8a5d67a3 Binary files /dev/null and b/NPCs/SlimeGod/ExtraTextures/SlimeGodCorePossession.png differ diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 4da12c3fb8..abba1aded8 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -44,15 +44,37 @@ namespace CalamityMod.NPCs.SlimeGod public static readonly SoundStyle ShotSound = new("CalamityMod/Sounds/Custom/SlimeGodShot", 2); public static readonly SoundStyle BigShotSound = new("CalamityMod/Sounds/Custom/SlimeGodBigShot", 2); + public static Asset ZenithSeedEyeTexture; public static Asset EyeTexture; + public static Asset OverlayTexture; + + private int eyeFrameDrawn = 0; + private int eyeFrameX = 0; + private const int TotalXEyeFrames = 2; + private const int TotalEyeFrames = 25; + private const int TotalEyeFrames_FirstColumn = 19; public override void SetStaticDefaults() { NPCID.Sets.BossBestiaryPriority.Add(Type); + NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() + { + Scale = 0.5f, + PortraitScale = 0.6f, + CustomTexturePath = "CalamityMod/ExtraTextures/Bestiary/SlimeGod_Bestiary", + PortraitPositionXOverride = 40, + PortraitPositionYOverride = 40 + }; + value.Position.X += 65; + value.Position.Y += 35; + NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; NPCID.Sets.MPAllowedEnemies[Type] = true; + if (!Main.dedServ) { - EyeTexture = ModContent.Request("CalamityMod/NPCs/SlimeGod/SlimeGodEyes", AssetRequestMode.AsyncLoad); + ZenithSeedEyeTexture = ModContent.Request("CalamityMod/NPCs/SlimeGod/SlimeGodEyes", AssetRequestMode.AsyncLoad); + EyeTexture = ModContent.Request("CalamityMod/NPCs/SlimeGod/ExtraTextures/SlimeGodCoreEye", AssetRequestMode.AsyncLoad); + OverlayTexture = ModContent.Request("CalamityMod/NPCs/SlimeGod/ExtraTextures/SlimeGodCoreOverlay", AssetRequestMode.AsyncLoad); } } @@ -61,8 +83,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.Calamity().canBreakPlayerDefense = true; NPC.GetNPCDamage(); NPC.npcSlots = 10f; - NPC.width = 44; - NPC.height = 44; + NPC.width = 96; + NPC.height = 98; if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) NPC.scale = 2f; @@ -128,6 +150,9 @@ namespace CalamityMod.NPCs.SlimeGod bool revenge = CalamityWorld.revenge || bossRush; bool death = CalamityWorld.death || bossRush; + // For animating the eye + NPC.localAI[0] += 1f; + // Get a target if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); @@ -196,8 +221,8 @@ namespace CalamityMod.NPCs.SlimeGod // Vanish phase if ((!purpleSlimeAlive && !redSlimeAlive) || calamityGlobalNPC.newAI[3] == 1f || NPC.ai[3] == 1f) { - // Avoid cheap bullshit - NPC.damage = 0; + // Avoid cheap bullshit + NPC.damage = 0; // Make sure Opacity is set to 0.8f if it's below that when the vanish phase starts if (NPC.ai[3] == 0f) @@ -510,7 +535,7 @@ namespace CalamityMod.NPCs.SlimeGod if (distanceFromFlyDestination < 300f) NPC.velocity = (NPC.velocity * 7f + idealVelocity) / 8f; - NPC.rotation = NPC.velocity.X * 0.1f; + NPC.rotation = NPC.velocity.X * 0.05f; } public Vector2 GetFlyDestination(Player target) @@ -575,51 +600,108 @@ namespace CalamityMod.NPCs.SlimeGod public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (NPC.spriteDirection == 1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } + SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Color drawColorAlpha = NPC.GetAlpha(drawColor); - Color colorLightingArea = Lighting.GetColor((int)((double)NPC.position.X + (double)NPC.width * 0.5) / 16, (int)(((double)NPC.position.Y + (double)NPC.height * 0.5) / 16.0)); - Texture2D texture2D3 = TextureAssets.Npc[NPC.type].Value; - Texture2D pog = EyeTexture.Value; - int frameTexture = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; - int y3 = frameTexture * (int)NPC.frameCounter; - Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, frameTexture); - Vector2 halfRect = rectangle.Size() / 2f; - int twoConst = 2; - int coreID = 1; - spriteBatch.Draw(texture2D3, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, spriteEffects, 0); - if (Main.zenithWorld) + Vector2 origin = NPC.frame.Size() * 0.5f; + Vector2 halfSize = NPC.Size * 0.5f; + + Texture2D texture = TextureAssets.Npc[NPC.type].Value; + Texture2D eyeTexture = EyeTexture.Value; + Texture2D overlayTexture = OverlayTexture.Value; + Texture2D pog = ZenithSeedEyeTexture.Value; + + // Used for animating the eye + if (NPC.localAI[0] % 6f == 0f) { - spriteBatch.Draw(pog, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, spriteEffects, 0); + eyeFrameDrawn++; + if (eyeFrameX == 0) + { + if (eyeFrameDrawn >= TotalEyeFrames_FirstColumn) + { + eyeFrameDrawn = 0; + eyeFrameX = 1; + } + } + else + { + if (eyeFrameDrawn >= TotalEyeFrames) + { + eyeFrameDrawn = 0; + eyeFrameX = 0; + } + } } + Rectangle eyeFrame = new Rectangle(eyeTexture.Width / TotalXEyeFrames * eyeFrameX, eyeTexture.Height / TotalEyeFrames * eyeFrameDrawn, eyeTexture.Width / TotalXEyeFrames, eyeTexture.Height / TotalEyeFrames); + Vector2 eyeOrigin = new Vector2(eyeTexture.Width / TotalXEyeFrames, eyeTexture.Height / TotalEyeFrames) * 0.5f; + if (!Main.zenithWorld) + { + Vector2 drawPositionAdjustment = halfSize - screenPos + new Vector2(0f, NPC.gfxOffY); + float colorAlphaDivisor = NPCID.Sets.TrailCacheLength[NPC.type] * 1.5f; + int twoConst = 2; + int coreID = 1; + while (((twoConst > 0 && coreID < 8) || (twoConst < 0 && coreID > 8)) && CalamityClientConfig.Instance.Afterimages) { - Color colorLightingAlpha = NPC.GetAlpha(colorLightingArea); - { - goto IL_6899; - } -IL_6881: - coreID += twoConst; - continue; -IL_6899: float trailLengthMult = (float)(8 - coreID); if (twoConst < 0) - { trailLengthMult = (float)(1 - coreID); - } - colorLightingAlpha *= trailLengthMult / ((float)NPCID.Sets.TrailCacheLength[NPC.type] * 1.5f); - Vector2 drawPosition = NPC.oldPos[coreID]; - float coreRotate = NPC.rotation; - Main.spriteBatch.Draw(texture2D3, drawPosition + NPC.Size / 2f - screenPos + new Vector2(0, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), colorLightingAlpha, coreRotate + NPC.rotation * 0f * (float)(coreID - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), halfRect, NPC.scale, spriteEffects, 0f); - goto IL_6881; + + drawColorAlpha *= trailLengthMult / colorAlphaDivisor; + Vector2 drawPosition = NPC.oldPos[coreID] + drawPositionAdjustment; + + // Draw the base texture afterimages + spriteBatch.Draw(texture, drawPosition, NPC.frame, drawColorAlpha, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + + // Draw the eye texture afterimages + spriteBatch.Draw(eyeTexture, drawPosition, eyeFrame, drawColorAlpha, NPC.rotation, eyeOrigin, NPC.scale, spriteEffects, 0f); + + // Draw the overlay texture afterimages + spriteBatch.Draw(overlayTexture, drawPosition, NPC.frame, drawColorAlpha, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + + coreID += twoConst; } + } + + // Reset the color + drawColorAlpha = NPC.GetAlpha(drawColor); + + // Draw the base texture + spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + + // Draw the eye + spriteBatch.Draw(eyeTexture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), eyeFrame, drawColorAlpha, NPC.rotation, eyeOrigin, NPC.scale, spriteEffects, 0f); + + // Draw the overlay + spriteBatch.Draw(overlayTexture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + + if (Main.zenithWorld) + spriteBatch.Draw(pog, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + return false; } + // Can only hit the target if within certain distance + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + Rectangle targetHitbox = target.Hitbox; + + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; + + return minDist <= 40f * NPC.scale; + } + public override void BossLoot(ref string name, ref int potionType) { potionType = ItemID.HealingPotion; diff --git a/NPCs/SlimeGod/SlimeGodCore.png b/NPCs/SlimeGod/SlimeGodCore.png index 64d666f45d..be6295b7cf 100644 Binary files a/NPCs/SlimeGod/SlimeGodCore.png and b/NPCs/SlimeGod/SlimeGodCore.png differ diff --git a/NPCs/SlimeGod/SplitCrimulanPaladin.cs b/NPCs/SlimeGod/SplitCrimulanPaladin.cs index bc312da7d8..2a59e81c35 100644 --- a/NPCs/SlimeGod/SplitCrimulanPaladin.cs +++ b/NPCs/SlimeGod/SplitCrimulanPaladin.cs @@ -5,8 +5,10 @@ using CalamityMod.Events; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; @@ -17,10 +19,11 @@ namespace CalamityMod.NPCs.SlimeGod public class SplitCrimulanPaladin : ModNPC { private float bossLife; + private float addedStretch = 0f; + private float landingRecoil = 0f; public override void SetStaticDefaults() { - Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.BossBestiaryPriority.Add(Type); NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() { @@ -38,12 +41,11 @@ namespace CalamityMod.NPCs.SlimeGod NPC.LifeMaxNERB(1875, 2250, 80000); NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.GetNPCDamage(); - NPC.width = 150; - NPC.height = 92; + NPC.width = 166; + NPC.height = 114; NPC.scale = 0.8f; NPC.defense = 10; NPC.knockBackResist = 0f; - AnimationType = NPCID.KingSlime; NPC.value = Item.buyPrice(0, 1, 0, 0); NPC.Opacity = 0.8f; NPC.lavaImmune = false; @@ -106,6 +108,17 @@ namespace CalamityMod.NPCs.SlimeGod setDamage += 22; } + // Used for landing squash and stretch + if (landingRecoil > 0f) + { + landingRecoil *= 0.965f; + landingRecoil -= 0.01f; + } + else + landingRecoil = 0f; + + addedStretch = -landingRecoil; + float scale = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.6f : Main.getGoodWorld ? 0.8f : 1f; NPC.aiAction = 0; NPC.noTileCollide = false; @@ -251,79 +264,91 @@ namespace CalamityMod.NPCs.SlimeGod // Avoid cheap bullshit NPC.damage = 0; + NPC.ai[2] += 1f; + if (revenge) + NPC.ai[2] += death ? 1f * (1f - lifeRatio) : 0.5f * (1f - lifeRatio); + NPC.TargetClosest(); NPC.velocity.X *= 0.8f; - NPC.ai[1] += 1f; + } - float jumpGateValue = 35f; - float velocityX = death ? 11.5f : revenge ? 10.5f : expertMode ? 9.5f : 7.5f; - if (revenge) + float landingSquashTime = 10f; + float telegraphTime = 20f; + float phaseSwitchGateValue = 120f; + float jumpTelegraphGateValue = phaseSwitchGateValue - telegraphTime; + if (NPC.ai[2] < jumpTelegraphGateValue) + { + if (NPC.velocity.Y == 0f) { - float moveBoost = death ? 11f * (1f - lifeRatio) : 7f * (1f - lifeRatio); - float speedBoost = death ? 2.25f * (1f - lifeRatio) : 1.5f * (1f - lifeRatio); - jumpGateValue -= moveBoost; - velocityX += speedBoost; + // Squash when landing + if (NPC.ai[1] < 0f) + landingRecoil += Math.Abs(NPC.ai[1]) / landingSquashTime; + + NPC.ai[1] += 1f; + + float jumpGateValue = 40f; + float velocityX = death ? 11.5f : revenge ? 10.5f : expertMode ? 9.5f : 7.5f; + if (revenge) + { + float moveBoost = death ? 11f * (1f - lifeRatio) : 7f * (1f - lifeRatio); + float speedBoost = death ? 2.25f * (1f - lifeRatio) : 1.5f * (1f - lifeRatio); + jumpGateValue -= moveBoost; + velocityX += speedBoost; + } + + float distanceBelowTarget = NPC.position.Y - (player.position.Y + 80f); + float speedMult = 1f; + if (distanceBelowTarget > 0f) + speedMult += distanceBelowTarget * 0.002f; + + if (speedMult > 2f) + speedMult = 2f; + + float velocityY = 8f; + if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) + velocityY += 4f; + + float jumpTelegraphGateValue2 = jumpGateValue - telegraphTime; + if (NPC.ai[1] >= jumpGateValue) + { + // Set damage + NPC.damage = setDamage; + + velocityX *= 1.25f; + NPC.ai[1] = -landingSquashTime; + NPC.velocity.Y -= velocityY * speedMult; + NPC.velocity.X = (velocityX + distanceSpeedBoost) * NPC.direction; + NPC.noTileCollide = true; + NPC.netUpdate = true; + } + else if (NPC.ai[1] >= jumpTelegraphGateValue2) + landingRecoil += (NPC.ai[1] - jumpTelegraphGateValue2) / telegraphTime; } - - float distanceBelowTarget = NPC.position.Y - (player.position.Y + 80f); - float speedMult = 1f; - if (distanceBelowTarget > 0f) - speedMult += distanceBelowTarget * 0.002f; - - if (speedMult > 2f) - speedMult = 2f; - - float velocityY = 4f; - if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) - velocityY += 2f; - - if (NPC.ai[1] > jumpGateValue) + else { // Set damage NPC.damage = setDamage; - velocityX *= 1.25f; - NPC.ai[1] = 0f; - NPC.velocity.Y -= velocityY * speedMult; - NPC.velocity.X = (velocityX + distanceSpeedBoost) * NPC.direction; - NPC.noTileCollide = true; - NPC.netUpdate = true; - } - else if (NPC.ai[1] >= jumpGateValue - 30f) - NPC.aiAction = 1; - } - else - { - // Set damage - NPC.damage = setDamage; + NPC.velocity.X *= 0.99f; + if (NPC.direction < 0 && NPC.velocity.X > -1f) + NPC.velocity.X = -1f; + if (NPC.direction > 0 && NPC.velocity.X < 1f) + NPC.velocity.X = 1f; - NPC.velocity.X *= 0.99f; - if (NPC.direction < 0 && NPC.velocity.X > -1f) - NPC.velocity.X = -1f; - if (NPC.direction > 0 && NPC.velocity.X < 1f) - NPC.velocity.X = 1f; - - if (!player.dead) - { - if (NPC.velocity.Y > 0f && NPC.Bottom.Y > player.Top.Y) - NPC.noTileCollide = false; - else if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) - NPC.noTileCollide = false; - else - NPC.noTileCollide = true; + if (!player.dead) + { + if (NPC.velocity.Y > 0f && NPC.Bottom.Y > player.Top.Y) + NPC.noTileCollide = false; + else if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.noTileCollide = false; + else + NPC.noTileCollide = true; + } } } - NPC.ai[2] += 1f; - if (revenge) - NPC.ai[2] += death ? 1f * (1f - lifeRatio) : 0.5f * (1f - lifeRatio); - if (NPC.velocity.Y == 0f) { - // Avoid cheap bullshit - NPC.damage = 0; - - float phaseSwitchGateValue = 180f; bool switchPhase = NPC.ai[2] >= phaseSwitchGateValue; if (switchPhase) { @@ -355,8 +380,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.netUpdate = true; } } - else if (NPC.ai[1] >= phaseSwitchGateValue - 30f) - NPC.aiAction = 1; + else if (NPC.ai[2] >= jumpTelegraphGateValue) + landingRecoil += (NPC.ai[2] - jumpTelegraphGateValue) / telegraphTime; } } else if (NPC.ai[0] == 1f) @@ -472,6 +497,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[2] = 0f; NPC.netUpdate = true; } + else + landingRecoil += NPC.ai[1] / 10f; } else if (NPC.ai[2] == 0f) NPC.noTileCollide = true; @@ -521,7 +548,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[2] += 1f; } else - NPC.aiAction = 1; + landingRecoil += NPC.ai[1] / 10f; } else { @@ -541,11 +568,17 @@ namespace CalamityMod.NPCs.SlimeGod // Avoid cheap bullshit NPC.damage = 0; - NPC.localAI[2] = NPC.ai[0]; - NPC.ai[0] = 0f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.netUpdate = true; + NPC.ai[2] += 1f; + if (NPC.ai[2] >= 23f) + { + NPC.localAI[2] = NPC.ai[0]; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; + } + else + landingRecoil += (NPC.ai[2] - 3f) / 10f; } } @@ -649,7 +682,7 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) { NPC.ai[0] = 0f; - NPC.ai[1] = 0f; + NPC.ai[1] = -10f; NPC.netUpdate = true; NPC.TargetClosest(); } @@ -657,7 +690,7 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportEndTime * 2f) { NPC.ai[0] = 0f; - NPC.ai[1] = 0f; + NPC.ai[1] = -10f; NPC.TargetClosest(); } @@ -672,6 +705,10 @@ namespace CalamityMod.NPCs.SlimeGod } } + // Limit the landing recoil + if (landingRecoil > 0.36f) + landingRecoil = 0.36f; + if (bossLife == 0f && NPC.life > 0) bossLife = NPC.lifeMax; @@ -686,8 +723,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.position.X = NPC.position.X + (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y + (float)NPC.height; NPC.scale = scaleRatio * 0.75f; - NPC.width = (int)(150f * NPC.scale); - NPC.height = (int)(92f * NPC.scale); + NPC.width = (int)(166f * NPC.scale); + NPC.height = (int)(114f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)NPC.height; } @@ -717,6 +754,27 @@ namespace CalamityMod.NPCs.SlimeGod } } + // Can only hit the target if within certain distance + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + Rectangle targetHitbox = target.Hitbox; + + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; + + return minDist <= 55f * NPC.scale; + } + public override Color? GetAlpha(Color drawColor) { Color lightColor = new Color(Main.DiscoR, 100, 150, NPC.alpha); @@ -724,6 +782,31 @@ namespace CalamityMod.NPCs.SlimeGod return newColor * NPC.Opacity; } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D texture = TextureAssets.Npc[Type].Value; + Color drawColorAlpha = NPC.GetAlpha(drawColor); + + // Stretch based on Y velocity. + float stretch = NPC.velocity.Y * 0.03f; + stretch = Math.Abs(stretch) + addedStretch; + + // Stretch rapidly if about to jump or teleport, stretch normally while idle. + if (NPC.velocity.Y == 0f) + stretch += MathHelper.Lerp(0f, 0.16f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * (NPC.aiAction == 1 ? 15f : 2f)) / 2f + 0.5f); + + if (stretch > 0.5f) + stretch = 0.5f; + + Vector2 scaleStretch = new Vector2(1f - stretch, 1f + stretch) * NPC.scale; + float yOffset = stretch * 0.5f * NPC.height; + + spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY - yOffset), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() * 0.5f, scaleStretch, spriteEffects, 0f); + + return false; + } + public override void OnKill() { int heartAmt = Main.rand.Next(3) + 3; diff --git a/NPCs/SlimeGod/SplitCrimulanPaladin.png b/NPCs/SlimeGod/SplitCrimulanPaladin.png index 4496f5c719..bddad0012c 100644 Binary files a/NPCs/SlimeGod/SplitCrimulanPaladin.png and b/NPCs/SlimeGod/SplitCrimulanPaladin.png differ diff --git a/NPCs/SlimeGod/SplitEbonianPaladin.cs b/NPCs/SlimeGod/SplitEbonianPaladin.cs index b0bd111e09..4b7c808dc4 100644 --- a/NPCs/SlimeGod/SplitEbonianPaladin.cs +++ b/NPCs/SlimeGod/SplitEbonianPaladin.cs @@ -5,8 +5,10 @@ using CalamityMod.Events; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; @@ -17,10 +19,11 @@ namespace CalamityMod.NPCs.SlimeGod public class SplitEbonianPaladin : ModNPC { private float bossLife; + private float addedStretch = 0f; + private float landingRecoil = 0f; public override void SetStaticDefaults() { - Main.npcFrameCount[NPC.type] = 6; NPCID.Sets.BossBestiaryPriority.Add(Type); NPCID.Sets.NPCBestiaryDrawModifiers value = new NPCID.Sets.NPCBestiaryDrawModifiers() { @@ -38,14 +41,13 @@ namespace CalamityMod.NPCs.SlimeGod NPC.LifeMaxNERB(2000, 2400, 110000); NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.GetNPCDamage(); - NPC.width = 150; - NPC.height = 92; + NPC.width = 166; + NPC.height = 114; NPC.scale = 0.8f; NPC.defense = 8; NPC.aiStyle = -1; AIType = -1; NPC.knockBackResist = 0f; - AnimationType = NPCID.KingSlime; NPC.value = Item.buyPrice(0, 1, 0, 0); NPC.Opacity = 0.8f; NPC.lavaImmune = false; @@ -106,6 +108,17 @@ namespace CalamityMod.NPCs.SlimeGod setDamage += 20; } + // Used for landing squash and stretch + if (landingRecoil > 0f) + { + landingRecoil *= 0.965f; + landingRecoil -= 0.01f; + } + else + landingRecoil = 0f; + + addedStretch = -landingRecoil; + float scale = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.6f : Main.getGoodWorld ? 0.8f : 1f; NPC.aiAction = 0; NPC.noTileCollide = false; @@ -249,79 +262,91 @@ namespace CalamityMod.NPCs.SlimeGod // Avoid cheap bullshit NPC.damage = 0; + NPC.ai[2] += 1f; + if (revenge) + NPC.ai[2] += death ? 1f * (1f - lifeRatio) : 0.5f * (1f - lifeRatio); + NPC.TargetClosest(); NPC.velocity.X *= 0.8f; - NPC.ai[1] += hyperMode ? 2f : 1f; + } - float jumpGateValue = 40f; - float velocityX = death ? 10f : revenge ? 9f : expertMode ? 8f : 6f; - if (revenge) + float landingSquashTime = 10f; + float telegraphTime = 20f; + float phaseSwitchGateValue = 150f; + float jumpTelegraphGateValue = phaseSwitchGateValue - telegraphTime; + if (NPC.ai[2] < jumpTelegraphGateValue) + { + if (NPC.velocity.Y == 0f) { - float moveBoost = death ? 15f * (1f - lifeRatio) : 10f * (1f - lifeRatio); - float speedBoost = death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio); - jumpGateValue -= moveBoost; - velocityX += speedBoost; + // Squash when landing + if (NPC.ai[1] < 0f) + landingRecoil += Math.Abs(NPC.ai[1]) / landingSquashTime; + + NPC.ai[1] += hyperMode ? 2f : 1f; + + float jumpGateValue = 45f; + float velocityX = death ? 10f : revenge ? 9f : expertMode ? 8f : 6f; + if (revenge) + { + float moveBoost = death ? 15f * (1f - lifeRatio) : 10f * (1f - lifeRatio); + float speedBoost = death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio); + jumpGateValue -= moveBoost; + velocityX += speedBoost; + } + + float distanceBelowTarget = NPC.position.Y - (player.position.Y + 80f); + float speedMult = 1f; + if (distanceBelowTarget > 0f) + speedMult += distanceBelowTarget * 0.002f; + + if (speedMult > 2f) + speedMult = 2f; + + float velocityY = 10f; + if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) + velocityY += 2f; + + float jumpTelegraphGateValue2 = jumpGateValue - telegraphTime; + if (NPC.ai[1] > jumpGateValue) + { + // Set damage + NPC.damage = setDamage; + + velocityY *= 1.25f; + NPC.ai[1] = -landingSquashTime; + NPC.velocity.Y -= velocityY * speedMult; + NPC.velocity.X = (velocityX + distanceSpeedBoost) * NPC.direction; + NPC.noTileCollide = true; + NPC.netUpdate = true; + } + else if (NPC.ai[1] >= jumpTelegraphGateValue2) + landingRecoil += (NPC.ai[1] - jumpTelegraphGateValue2) / telegraphTime; } - - float distanceBelowTarget = NPC.position.Y - (player.position.Y + 80f); - float speedMult = 1f; - if (distanceBelowTarget > 0f) - speedMult += distanceBelowTarget * 0.002f; - - if (speedMult > 2f) - speedMult = 2f; - - float velocityY = 5f; - if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) - velocityY += 2f; - - if (NPC.ai[1] > jumpGateValue) + else { // Set damage NPC.damage = setDamage; - velocityY *= 1.25f; - NPC.ai[1] = 0f; - NPC.velocity.Y -= velocityY * speedMult; - NPC.velocity.X = (velocityX + distanceSpeedBoost) * NPC.direction; - NPC.noTileCollide = true; - NPC.netUpdate = true; - } - else if (NPC.ai[1] >= jumpGateValue - 30f) - NPC.aiAction = 1; - } - else - { - // Set damage - NPC.damage = setDamage; + NPC.velocity.X *= 0.99f; + if (NPC.direction < 0 && NPC.velocity.X > -1f) + NPC.velocity.X = -1f; + if (NPC.direction > 0 && NPC.velocity.X < 1f) + NPC.velocity.X = 1f; - NPC.velocity.X *= 0.99f; - if (NPC.direction < 0 && NPC.velocity.X > -1f) - NPC.velocity.X = -1f; - if (NPC.direction > 0 && NPC.velocity.X < 1f) - NPC.velocity.X = 1f; - - if (!player.dead) - { - if (NPC.velocity.Y > 0f && NPC.Bottom.Y > player.Top.Y) - NPC.noTileCollide = false; - else if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) - NPC.noTileCollide = false; - else - NPC.noTileCollide = true; + if (!player.dead) + { + if (NPC.velocity.Y > 0f && NPC.Bottom.Y > player.Top.Y) + NPC.noTileCollide = false; + else if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + NPC.noTileCollide = false; + else + NPC.noTileCollide = true; + } } } - NPC.ai[2] += 1f; - if (revenge) - NPC.ai[2] += death ? 1f * (1f - lifeRatio) : 0.5f * (1f - lifeRatio); - if (NPC.velocity.Y == 0f) { - // Avoid cheap bullshit - NPC.damage = 0; - - float phaseSwitchGateValue = 210f; bool switchPhase = NPC.ai[2] >= phaseSwitchGateValue; if (switchPhase) { @@ -357,8 +382,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.netUpdate = true; } } - else if (NPC.ai[1] >= phaseSwitchGateValue - 30f) - NPC.aiAction = 1; + else if (NPC.ai[2] >= jumpTelegraphGateValue) + landingRecoil += (NPC.ai[2] - jumpTelegraphGateValue) / telegraphTime; } } else if (NPC.ai[0] == 1f) @@ -390,7 +415,7 @@ namespace CalamityMod.NPCs.SlimeGod { Vector2 randomVelocity = Main.rand.NextVector2CircularEdge(3f, 3f); Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, j / (float)(numProj - 1))) + randomVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale, perturbedSpeed, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 45f * NPC.scale, perturbedSpeed, type, damage, 0f, Main.myPlayer); } } } @@ -519,6 +544,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[2] = 0f; NPC.netUpdate = true; } + else + landingRecoil += NPC.ai[1] / 10f; } else if (NPC.ai[2] == 0f) NPC.noTileCollide = true; @@ -568,7 +595,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[2] += 1f; } else - NPC.aiAction = 1; + landingRecoil += NPC.ai[1] / 10f; } else { @@ -588,11 +615,17 @@ namespace CalamityMod.NPCs.SlimeGod // Avoid cheap bullshit NPC.damage = 0; - NPC.localAI[2] = NPC.ai[0]; - NPC.ai[0] = 0f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.netUpdate = true; + NPC.ai[2] += 1f; + if (NPC.ai[2] >= 22f) + { + NPC.localAI[2] = NPC.ai[0]; + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.netUpdate = true; + } + else + landingRecoil += (NPC.ai[2] - 2f) / 10f; } } @@ -696,7 +729,7 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) { NPC.ai[0] = 0f; - NPC.ai[1] = 0f; + NPC.ai[1] = -10f; NPC.netUpdate = true; NPC.TargetClosest(); } @@ -704,7 +737,7 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportEndTime * 2f) { NPC.ai[0] = 0f; - NPC.ai[1] = 0f; + NPC.ai[1] = -10f; NPC.TargetClosest(); } @@ -719,6 +752,10 @@ namespace CalamityMod.NPCs.SlimeGod } } + // Limit the landing recoil + if (landingRecoil > 0.36f) + landingRecoil = 0.36f; + if (bossLife == 0f && NPC.life > 0) bossLife = NPC.lifeMax; @@ -733,8 +770,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.position.X = NPC.position.X + (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y + (float)NPC.height; NPC.scale = scaleRatio * 0.75f; - NPC.width = (int)(150f * NPC.scale); - NPC.height = (int)(92f * NPC.scale); + NPC.width = (int)(166f * NPC.scale); + NPC.height = (int)(114f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)NPC.height; } @@ -761,6 +798,27 @@ namespace CalamityMod.NPCs.SlimeGod } } + // Can only hit the target if within certain distance + public override bool CanHitPlayer(Player target, ref int cooldownSlot) + { + Rectangle targetHitbox = target.Hitbox; + + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; + + return minDist <= 55f * NPC.scale; + } + public override Color? GetAlpha(Color drawColor) { Color lightColor = new Color(200, 150, Main.DiscoB, NPC.alpha); @@ -768,6 +826,31 @@ namespace CalamityMod.NPCs.SlimeGod return newColor * NPC.Opacity; } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D texture = TextureAssets.Npc[Type].Value; + Color drawColorAlpha = NPC.GetAlpha(drawColor); + + // Stretch based on Y velocity. + float stretch = NPC.velocity.Y * 0.03f; + stretch = Math.Abs(stretch) + addedStretch; + + // Stretch rapidly if about to jump or teleport, stretch normally while idle. + if (NPC.velocity.Y == 0f) + stretch += MathHelper.Lerp(0f, 0.16f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * (NPC.aiAction == 1 ? 15f : 2f)) / 2f + 0.5f); + + if (stretch > 0.5f) + stretch = 0.5f; + + Vector2 scaleStretch = new Vector2(1f - stretch, 1f + stretch) * NPC.scale; + float yOffset = stretch * 0.5f * NPC.height; + + spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY - yOffset), NPC.frame, drawColorAlpha, NPC.rotation, NPC.frame.Size() * 0.5f, scaleStretch, spriteEffects, 0f); + + return false; + } + public override void OnKill() { int heartAmt = Main.rand.Next(3) + 3; diff --git a/NPCs/SlimeGod/SplitEbonianPaladin.png b/NPCs/SlimeGod/SplitEbonianPaladin.png index 11d5836fe5..2c59858364 100644 Binary files a/NPCs/SlimeGod/SplitEbonianPaladin.png and b/NPCs/SlimeGod/SplitEbonianPaladin.png differ diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs index 19474d1d09..9941736d6a 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs @@ -330,24 +330,27 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.type == NPCID.TheDestroyer) { // Spawn segments from head - if (npc.ai[0] == 0f) + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.ai[3] = npc.whoAmI; - npc.realLife = npc.whoAmI; - int index = npc.whoAmI; - for (int j = 0; j <= totalSegments; j++) + if (npc.ai[0] == 0f) { - int type = NPCID.TheDestroyerBody; - if (j == totalSegments) - type = NPCID.TheDestroyerTail; + npc.ai[3] = npc.whoAmI; + npc.realLife = npc.whoAmI; + int index = npc.whoAmI; + for (int j = 0; j <= totalSegments; j++) + { + int type = NPCID.TheDestroyerBody; + if (j == totalSegments) + type = NPCID.TheDestroyerTail; - int segment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)(npc.position.Y + npc.height), type, npc.whoAmI); - Main.npc[segment].ai[3] = npc.whoAmI; - Main.npc[segment].realLife = npc.whoAmI; - Main.npc[segment].ai[1] = index; - Main.npc[index].ai[0] = segment; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segment); - index = segment; + int segment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)(npc.position.Y + npc.height), type, npc.whoAmI); + Main.npc[segment].ai[3] = npc.whoAmI; + Main.npc[segment].realLife = npc.whoAmI; + Main.npc[segment].ai[1] = index; + Main.npc[index].ai[0] = segment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segment); + index = segment; + } } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs index 1206ea87c3..1d4ce19145 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs @@ -57,7 +57,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else if (hoverRotation > MathHelper.TwoPi) hoverRotation -= MathHelper.TwoPi; - float rotationRate = 0.1f; + float rotationRate = 0.15f; npc.rotation = npc.rotation.AngleTowards(hoverRotation, rotationRate); if (Main.rand.NextBool(5)) @@ -251,7 +251,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } Vector2 laserVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * laserSpeed; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 150f, laserVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 90f, laserVelocity, type, damage, 0f, Main.myPlayer); } } } @@ -387,7 +387,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int numProj = shootLaser ? 6 : 2; int spread = shootLaser ? 20 : 80; float rotation = MathHelper.ToRadians(spread); - float offset = shootLaser ? 150f : 50f; + float offset = shootLaser ? 90f : 50f; for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); @@ -535,7 +535,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } Vector2 laserVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * laserSpeed; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 150f, laserVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 120f, laserVelocity, type, damage, 0f, Main.myPlayer); } } } @@ -592,7 +592,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } Vector2 laserVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * laserSpeed; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 150f, laserVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + laserVelocity.SafeNormalize(Vector2.UnitY) * 120f, laserVelocity, type, damage, 0f, Main.myPlayer); } } } @@ -688,7 +688,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } Vector2 laserDartVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * laserDartSpeed; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + npc.velocity.SafeNormalize(Vector2.UnitY) * 50f, laserDartVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + npc.velocity.SafeNormalize(Vector2.UnitY) * 60f, laserDartVelocity, type, damage, 0f, Main.myPlayer); } } } @@ -1851,7 +1851,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses num423 += (float)Main.rand.Next(-inaccuracy, inaccuracy + 1) * 0.08f; Vector2 laserVelocity = new Vector2(num422, num423); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector43 + laserVelocity.SafeNormalize(Vector2.UnitY) * 150f, laserVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), vector43 + laserVelocity.SafeNormalize(Vector2.UnitY) * 90f, laserVelocity, type, damage, 0f, Main.myPlayer); } } } @@ -1990,7 +1990,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 150f, perturbedSpeed, type, damage, 0f, Main.myPlayer); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 90f, perturbedSpeed, type, damage, 0f, Main.myPlayer); Main.projectile[proj].tileCollide = false; } } @@ -2169,7 +2169,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses num441 *= num442; Vector2 laserVelocity = new Vector2(num440, num441); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector45 + laserVelocity.SafeNormalize(Vector2.UnitY) * 150f, laserVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), vector45 + laserVelocity.SafeNormalize(Vector2.UnitY) * 120f, laserVelocity, type, damage, 0f, Main.myPlayer); } return false; @@ -2260,7 +2260,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses num451 *= num452; Vector2 laserVelocity = new Vector2(num450, num451); - Projectile.NewProjectile(npc.GetSource_FromAI(), vector46 + laserVelocity.SafeNormalize(Vector2.UnitY) * 150f, laserVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), vector46 + laserVelocity.SafeNormalize(Vector2.UnitY) * 120f, laserVelocity, type, damage, 0f, Main.myPlayer); } } diff --git a/Projectiles/Boss/FoveanatorEnergyBomb.cs b/Projectiles/Boss/FoveanatorEnergyBomb.cs new file mode 100644 index 0000000000..2e5471a87a --- /dev/null +++ b/Projectiles/Boss/FoveanatorEnergyBomb.cs @@ -0,0 +1,133 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class FoveanatorEnergyBomb : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + + private const int TotalXFrames = 2; + private const int TotalYFrames = 8; + private const int ExplodeFrames = 6; + private const int ExplodeDamageStartFrame = 3; + private const int FrameTimer = 6; + + public int frameX = 0; + public int frameY = 0; + + public int CurrentFrame + { + get => frameX * TotalYFrames + frameY; + set + { + frameX = value / TotalYFrames; + frameY = value % TotalYFrames; + } + } + + private const int TimeLeft = 300; + private const int ExplodeTime = TimeLeft - FrameTimer * ExplodeFrames; + + private const float ExplodeDistance = 50f; + + public override void SetDefaults() + { + Projectile.width = 133; + Projectile.height = 142; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = TimeLeft; + } + + public override void AI() + { + // Get a target and calculate distance from it. + int target = Player.FindClosest(Projectile.Center, 1, 1); + float distanceFromTarget = (Main.player[target].Center - Projectile.Center).Length(); + + // Explode when within a certain distance of the target. + if (distanceFromTarget <= ExplodeDistance && Projectile.timeLeft > ExplodeTime) + Projectile.timeLeft = ExplodeTime; + + bool explode = Projectile.timeLeft <= ExplodeTime; + + // Stop immediately if explosion is triggered. + if (explode && Projectile.velocity.Length() > 0f) + Projectile.velocity = Vector2.Zero; + + // Reset the frame counter and frameY when explosion is triggered. + if (Projectile.timeLeft == ExplodeTime) + { + Projectile.frameCounter = 0; + frameY = 0; + } + + // Explosion noise when actually exploding. + if (frameY == ExplodeDamageStartFrame && explode && Projectile.localAI[0] == 0f) + { + Projectile.localAI[0] = 1f; + SoundEngine.PlaySound(DeusMine.ExplodeSound, Projectile.Center); + } + + Projectile.frameCounter++; + if (Projectile.frameCounter % FrameTimer == 0) + { + CurrentFrame++; + + // Non-explosion uses the left side of the sheet, explosion uses the right side of the sheet. + frameX = explode ? 1 : 0; + + // Kill the projectile when the explosion animation is done. + if (explode && frameY >= ExplodeFrames) + { + Projectile.Kill(); + return; + } + } + + // Explosion has brighter light. + float redLight = explode ? 1.2f : 0.6f; + float greenLight = explode ? 0.3f : 0.15f; + float blueLight = (Main.DiscoB / 255f) * (explode ? 1.5f : 0.75f); + Lighting.AddLight(Projectile.Center, redLight, greenLight, blueLight); + } + + public override bool PreDraw(ref Color lightColor) => false; + + public override void PostDraw(Color lightColor) + { + if (Projectile.frameCounter < 5) + return; + + lightColor.R = (byte)(255 * Projectile.Opacity); + lightColor.G = (byte)(255 * Projectile.Opacity); + lightColor.B = (byte)(255 * Projectile.Opacity); + + Texture2D texture = TextureAssets.Projectile[Projectile.type].Value; + Vector2 position = Projectile.Center - Main.screenPosition; + Vector2 origin = texture.Size() / new Vector2(TotalXFrames, TotalYFrames) * 0.5f; + Rectangle frame = texture.Frame(TotalXFrames, TotalYFrames, frameX, frameY); + Main.EntitySpriteDraw(texture, position, frame, Color.White, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None); + } + + public override bool CanHitPlayer(Player target) => Projectile.timeLeft <= ExplodeTime && frameY >= ExplodeDamageStartFrame; + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, ExplodeDistance, targetHitbox); + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (Projectile.timeLeft <= ExplodeTime) + target.AddBuff(BuffID.Frostburn, 180); + } + } +} diff --git a/Projectiles/Boss/FoveanatorEnergyBomb.png b/Projectiles/Boss/FoveanatorEnergyBomb.png new file mode 100644 index 0000000000..4e2a8120cb Binary files /dev/null and b/Projectiles/Boss/FoveanatorEnergyBomb.png differ diff --git a/Projectiles/Boss/FoveanatorLaser.cs b/Projectiles/Boss/FoveanatorLaser.cs new file mode 100644 index 0000000000..d85670bd5a --- /dev/null +++ b/Projectiles/Boss/FoveanatorLaser.cs @@ -0,0 +1,100 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs.TownNPCs; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class FoveanatorLaser : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Boss"; + + private const int FadeOutTime = 30; + + private const float Acceleration = 1.05f; + private const float MaxVelocity = 24f; + + public override void SetStaticDefaults() + { + Main.projFrames[Projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 2; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } + + public override void SetDefaults() + { + Projectile.width = 16; + Projectile.height = 16; + Projectile.hostile = true; + Projectile.ignoreWater = true; + Projectile.Opacity = 0f; + Projectile.penetrate = -1; + Projectile.timeLeft = 300; + } + + public override void AI() + { + Projectile.frameCounter++; + if (Projectile.frameCounter > 4) + { + Projectile.frame++; + Projectile.frameCounter = 0; + } + if (Projectile.frame > 3) + Projectile.frame = 0; + + if (Projectile.velocity.Length() < MaxVelocity) + { + Projectile.velocity *= Acceleration; + if (Projectile.velocity.Length() > MaxVelocity) + { + Projectile.velocity.Normalize(); + Projectile.velocity *= MaxVelocity; + } + } + + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + Lighting.AddLight(Projectile.Center, 0.4f * Projectile.Opacity, 0.1f * Projectile.Opacity, (Main.DiscoB / 255f) * 0.5f * Projectile.Opacity); + + if (Projectile.timeLeft < FadeOutTime) + { + Projectile.Opacity -= 1f / FadeOutTime; + } + else if (Projectile.Opacity < 1f) + { + Projectile.Opacity += 0.25f; + if (Projectile.Opacity > 1f) + Projectile.Opacity = 1f; + } + } + + public override bool PreDraw(ref Color lightColor) + { + lightColor.R = (byte)(255 * Projectile.Opacity); + lightColor.G = (byte)(255 * Projectile.Opacity); + lightColor.B = (byte)(255 * Projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); + return false; + } + + public override bool CanHitPlayer(Player target) => Projectile.timeLeft >= FadeOutTime; + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + if (Projectile.timeLeft >= FadeOutTime) + target.AddBuff(BuffID.Frostburn, 90); + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(Projectile.Center, Projectile.velocity, Projectile.width, Projectile.height); + SoundEngine.PlaySound(SoundID.Item10, Projectile.position); + return true; + } + } +} diff --git a/Projectiles/Boss/FoveanatorLaser.png b/Projectiles/Boss/FoveanatorLaser.png new file mode 100644 index 0000000000..543c692773 Binary files /dev/null and b/Projectiles/Boss/FoveanatorLaser.png differ diff --git a/Projectiles/Boss/HiveBombGoliath.cs b/Projectiles/Boss/HiveBombGoliath.cs index 202b85a3e9..14a62b1d0a 100644 --- a/Projectiles/Boss/HiveBombGoliath.cs +++ b/Projectiles/Boss/HiveBombGoliath.cs @@ -48,9 +48,8 @@ namespace CalamityMod.Projectiles.Boss Projectile.frameCounter = 0; } if (Projectile.frame > 3) - { Projectile.frame = 0; - } + if (Math.Abs(Projectile.velocity.X) >= 3f || Math.Abs(Projectile.velocity.Y) >= 3f) { float randDustXVel = 0f; @@ -81,6 +80,7 @@ namespace CalamityMod.Projectiles.Boss Main.dust[smoke].noGravity = true; Main.dust[smoke].position = Projectile.Center + new Vector2(0f, (float)(-(float)Projectile.height / 2 - 6)).RotatedBy((double)Projectile.rotation, default) * 1.1f; } + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; } diff --git a/Projectiles/Boss/UnstableEbonianGlob.cs b/Projectiles/Boss/UnstableEbonianGlob.cs index e0f48c3df2..b943ead30d 100644 --- a/Projectiles/Boss/UnstableEbonianGlob.cs +++ b/Projectiles/Boss/UnstableEbonianGlob.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Projectiles.Boss public class UnstableEbonianGlob : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Boss"; + public override void SetDefaults() { Projectile.Calamity().DealsDefenseDamage = true; @@ -28,9 +29,13 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - if (Projectile.velocity.Length() < 12f && (Main.expertMode || BossRushEvent.BossRushActive)) + if (Projectile.velocity.Length() < 12f && (Main.expertMode || BossRushEvent.BossRushActive || Projectile.ai[0] == 1f)) { float velocityMult = BossRushEvent.BossRushActive ? 1.025f : CalamityWorld.death ? 1.015f : CalamityWorld.revenge ? 1.0125f : Main.expertMode ? 1.01f : 1.005f; + + if (Projectile.ai[0] == 1f) + velocityMult += 0.02f; + Projectile.velocity *= velocityMult; }