From 982e0b874093631f1c6ab84b9bd00b8e5e8552b4 Mon Sep 17 00:00:00 2001 From: Shucks Date: Thu, 14 Nov 2019 19:13:55 -0600 Subject: [PATCH 1/5] Sea Searing nerf --- Items/Weapons/Ranged/SeasSearing.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Items/Weapons/Ranged/SeasSearing.cs b/Items/Weapons/Ranged/SeasSearing.cs index 5ff9d43fb4..8ab876dfba 100644 --- a/Items/Weapons/Ranged/SeasSearing.cs +++ b/Items/Weapons/Ranged/SeasSearing.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Items.Weapons.Ranged { public class SeasSearing : ModItem { - public static int BaseDamage = 90; + public static int BaseDamage = 60; public override void SetStaticDefaults() { @@ -54,7 +54,7 @@ namespace CalamityMod.Items.Weapons.Ranged { if (player.altFunctionUse == 2) { - item.damage = 130; + item.damage = 73; item.useTime = 30; item.useAnimation = 30; item.reuseDelay = 0; From 81205b9051766d0056a951e32c807933cafc1019 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Thu, 14 Nov 2019 22:15:50 -0500 Subject: [PATCH 2/5] raider's crit stack info --- Items/Accessories/Nanotech.cs | 28 +++++++++++++++++++++------- Items/Accessories/RaidersTalisman.cs | 20 +++++++++++++++++--- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/Items/Accessories/Nanotech.cs b/Items/Accessories/Nanotech.cs index 8d90aa58c3..a5716079db 100644 --- a/Items/Accessories/Nanotech.cs +++ b/Items/Accessories/Nanotech.cs @@ -1,6 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Tiles.Furniture.CraftingStations; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -12,13 +13,7 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Nanotech"); - Tooltip.SetDefault("Rogue projectiles create nanoblades as they travel\n" + - "Stealth strikes summon lunar flares on enemy hits\n" + - "Rogue weapons have a chance to instantly kill normal enemies\n" + - "10% increased rogue damage, 5% increased rogue crit chance, and 15% increased rogue velocity\n" + - "Whenever you crit an enemy with a rogue weapon your rogue damage increases\n" + - "This effect can stack up to 250 times\n" + - "Max rogue damage boost is 25%"); + Tooltip.SetDefault("Rogue projectiles create nanoblades as they travel"); } public override void SetDefaults() @@ -30,6 +25,25 @@ namespace CalamityMod.Items.Accessories item.Calamity().postMoonLordRarity = 20; } + public override void ModifyTooltips(List list) + { + int critLevel = Main.player[Main.myPlayer].Calamity().raiderStack; + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Rogue projectiles create nanoblades as they travel\n" + + "Stealth strikes summon lunar flares on enemy hits\n" + + "Rogue weapons have a chance to instantly kill normal enemies\n" + + "10% increased rogue damage, 5% increased rogue crit chance, and 15% increased rogue velocity\n" + + "Whenever you crit an enemy with a rogue weapon your rogue damage increases\n" + + "This effect can stack up to 250 times\n" + + "Max rogue damage boost is 25%\n" + + "Rogue Crit Level: " + critLevel; + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); diff --git a/Items/Accessories/RaidersTalisman.cs b/Items/Accessories/RaidersTalisman.cs index 2a40c74956..63b3e1a99a 100644 --- a/Items/Accessories/RaidersTalisman.cs +++ b/Items/Accessories/RaidersTalisman.cs @@ -1,4 +1,5 @@ using CalamityMod.CalPlayer; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,9 +11,7 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Raider's Talisman"); - Tooltip.SetDefault("Whenever you crit an enemy with a rogue weapon your rogue damage increases\n" + - "This effect can stack up to 250 times\n" + - "Max rogue damage boost is 25%"); + Tooltip.SetDefault("Whenever you crit an enemy with a rogue weapon your rogue damage increases"); } public override void SetDefaults() @@ -24,6 +23,21 @@ namespace CalamityMod.Items.Accessories item.accessory = true; } + public override void ModifyTooltips(List list) + { + int critLevel = Main.player[Main.myPlayer].Calamity().raiderStack; + foreach (TooltipLine line2 in list) + { + if (line2.mod == "Terraria" && line2.Name == "Tooltip0") + { + line2.text = "Whenever you crit an enemy with a rogue weapon your rogue damage increases\n" + + "This effect can stack up to 250 times\n" + + "Max rogue damage boost is 25%\n" + + "Rogue Crit Level: " + critLevel; + } + } + } + public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); From 5912017e64ccf27bac8e7d2ca1c48e5af6d13f59 Mon Sep 17 00:00:00 2001 From: Andrew Marheine Date: Thu, 14 Nov 2019 22:21:13 -0600 Subject: [PATCH 3/5] This was painful --- NPCs/AquaticScourge/AquaticScourgeBody.cs | 8 +- NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs | 8 +- NPCs/AquaticScourge/AquaticScourgeHead.cs | 8 +- NPCs/AquaticScourge/AquaticScourgeTail.cs | 8 +- NPCs/AstrumDeus/AstrumDeusBody.cs | 109 +-- NPCs/AstrumDeus/AstrumDeusBodySpectral.cs | 180 +---- NPCs/AstrumDeus/AstrumDeusHead.cs | 503 +----------- NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs | 352 +-------- NPCs/AstrumDeus/AstrumDeusTail.cs | 68 +- NPCs/AstrumDeus/AstrumDeusTailSpectral.cs | 133 +--- NPCs/CalamityAI.cs | 762 ++++++++++++++++++- NPCs/CalamityGlobalNPC.cs | 114 ++- 12 files changed, 862 insertions(+), 1391 deletions(-) diff --git a/NPCs/AquaticScourge/AquaticScourgeBody.cs b/NPCs/AquaticScourge/AquaticScourgeBody.cs index aee38a77dd..28c9da387b 100644 --- a/NPCs/AquaticScourge/AquaticScourgeBody.cs +++ b/NPCs/AquaticScourge/AquaticScourgeBody.cs @@ -56,15 +56,9 @@ namespace CalamityMod.NPCs.AquaticScourge public override void AI() { - CalamityAI.AquaticScourgeAI(npc, mod); + CalamityAI.AquaticScourgeAI(npc, mod, false); } - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if ((projectile.penetrate == -1 || projectile.penetrate > 1) && !projectile.minion) - damage = (int)((double)damage * 0.5); - } - public override bool? CanBeHitByProjectile(Projectile projectile) { if (projectile.minion) diff --git a/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs b/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs index f54feea1c6..65c2c17cf4 100644 --- a/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs +++ b/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs @@ -56,15 +56,9 @@ namespace CalamityMod.NPCs.AquaticScourge public override void AI() { - CalamityAI.AquaticScourgeAI(npc, mod); + CalamityAI.AquaticScourgeAI(npc, mod, false); } - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if ((projectile.penetrate == -1 || projectile.penetrate > 1) && !projectile.minion) - damage = (int)((double)damage * 0.5); - } - public override bool? CanBeHitByProjectile(Projectile projectile) { if (projectile.minion) diff --git a/NPCs/AquaticScourge/AquaticScourgeHead.cs b/NPCs/AquaticScourge/AquaticScourgeHead.cs index 3374306027..61629a3d1f 100644 --- a/NPCs/AquaticScourge/AquaticScourgeHead.cs +++ b/NPCs/AquaticScourge/AquaticScourgeHead.cs @@ -80,7 +80,7 @@ namespace CalamityMod.NPCs.AquaticScourge else music = MusicID.Boss2; } - CalamityAI.AquaticScourgeAI(npc, mod); + CalamityAI.AquaticScourgeAI(npc, mod, true); } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -103,12 +103,6 @@ namespace CalamityMod.NPCs.AquaticScourge return minDist <= 50f; } - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if ((projectile.penetrate == -1 || projectile.penetrate > 1) && !projectile.minion) - damage = (int)((double)damage * 0.5); - } - public override bool? CanBeHitByProjectile(Projectile projectile) { if (projectile.minion) diff --git a/NPCs/AquaticScourge/AquaticScourgeTail.cs b/NPCs/AquaticScourge/AquaticScourgeTail.cs index 845067e405..9a9eee58f5 100644 --- a/NPCs/AquaticScourge/AquaticScourgeTail.cs +++ b/NPCs/AquaticScourge/AquaticScourgeTail.cs @@ -53,15 +53,9 @@ namespace CalamityMod.NPCs.AquaticScourge public override void AI() { - CalamityAI.AquaticScourgeAI(npc, mod); + CalamityAI.AquaticScourgeAI(npc, mod, false); } - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if ((projectile.penetrate == -1 || projectile.penetrate > 1) && !projectile.minion) - damage = (int)((double)damage * 0.5); - } - public override bool? CanBeHitByProjectile(Projectile projectile) { if (projectile.minion) diff --git a/NPCs/AstrumDeus/AstrumDeusBody.cs b/NPCs/AstrumDeus/AstrumDeusBody.cs index 6f58fd3019..0fb82a3efc 100644 --- a/NPCs/AstrumDeus/AstrumDeusBody.cs +++ b/NPCs/AstrumDeus/AstrumDeusBody.cs @@ -81,80 +81,8 @@ namespace CalamityMod.NPCs.AstrumDeus public override void AI() { - if (CalamityGlobalNPC.astrumDeusHeadMain != -1) - { - if (Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].active) - { - npc.dontTakeDamage = !Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].dontTakeDamage; - npc.chaseable = !Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].chaseable; - } - } - bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; - bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - if (!Main.npc[(int)npc.ai[1]].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; - } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - npc.alpha -= 42; - if (npc.alpha < 0) - { - npc.alpha = 0; - } - } - /*if (Main.netMode != NetmodeID.MultiplayerClient) - { - int shootTime = 4; - if ((double)npc.life <= (double)npc.lifeMax * 0.3 || CalamityWorld.bossRushActive) - { - shootTime += 2; - } - npc.localAI[0] += (float)Main.rand.Next(shootTime); - if (npc.localAI[0] >= (float)Main.rand.Next(1400, 26000)) - { - npc.localAI[0] = 0f; - npc.TargetClosest(true); - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - float num941 = revenge ? 13f : 12f; - if (CalamityWorld.death) - { - num941 = 15f; - } - if (CalamityWorld.bossRushActive) - { - num941 = 20f; - } - Vector2 vector104 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)(npc.height / 2)); - float num942 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector104.X; - float num943 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector104.Y; - float num944 = (float)Math.Sqrt((double)(num942 * num942 + num943 * num943)); - num944 = num941 / num944; - num942 *= num944; - num943 *= num944; - int num945 = expertMode ? 38 : 45; - int num946 = ModContent.ProjectileType(); - vector104.X += num942 * 5f; - vector104.Y += num943 * 5f; - int num947 = Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, num946, num945, 0f, Main.myPlayer, 0f, 0f); - npc.netUpdate = true; - } - } - }*/ - } + CalamityAI.AstrumDeusAI(npc, mod, false, false); + } public override bool CanHitPlayer(Player target, ref int cooldownSlot) { @@ -170,39 +98,6 @@ namespace CalamityMod.NPCs.AstrumDeus return false; } - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (projectile.type == ModContent.ProjectileType() || ProjectileID.Sets.StardustDragon[projectile.type]) - { - damage = (int)((double)damage * 0.1); - } - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - { - damage = (int)((double)damage * 0.2); - } - else if (projectile.type == ProjectileID.DD2BetsyArrow) - { - damage = (int)((double)damage * 0.3); - } - else if (projectile.type == ModContent.ProjectileType()) - { - damage = (int)((double)damage * 0.5); - } - - if (projectile.penetrate == -1 && !projectile.minion) - { - if (projectile.type == ModContent.ProjectileType()) - damage = (int)((double)damage * 0.3); - else - damage = (int)((double)damage * 0.2); - } - else if (projectile.penetrate > 1 && projectile.type != ModContent.ProjectileType()) - { - damage /= projectile.penetrate; - } - } - public override bool CheckActive() { return false; diff --git a/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs b/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs index 0d17cade2c..1c5dc65b5d 100644 --- a/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs @@ -96,152 +96,7 @@ namespace CalamityMod.NPCs.AstrumDeus public override void AI() { - if (CalamityGlobalNPC.astrumDeusHeadMain != -1) - { - npc.dontTakeDamage = Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].dontTakeDamage; - npc.chaseable = Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].chaseable; - } - bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; - bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - if (npc.ai[3] > 0f) - { - npc.realLife = (int)npc.ai[3]; - } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } - bool flag = false; - if (npc.ai[1] <= 0f) - { - flag = true; - } - else if (Main.npc[(int)npc.ai[1]].life <= 0) - { - flag = true; - } - if (flag) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - npc.alpha -= 42; - if (npc.alpha < 0) - { - npc.alpha = 0; - } - } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int shootTime = 4; - if ((double)npc.life <= (double)npc.lifeMax * 0.65 || CalamityWorld.bossRushActive || Main.player[npc.target].gravDir == -1f) - { - shootTime += CalamityWorld.death ? 4 : 2; - } - if ((double)npc.life <= (double)npc.lifeMax * 0.3 || CalamityWorld.bossRushActive || Main.player[npc.target].gravDir == -1f) - { - shootTime += CalamityWorld.death ? 6 : 2; - } - npc.localAI[0] += (float)Main.rand.Next(shootTime); - if (npc.localAI[0] >= (float)Main.rand.Next(1400, 20000)) - { - npc.localAI[0] = 0f; - npc.TargetClosest(true); - if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - float num941 = revenge ? 14f : 13f; - if (CalamityWorld.death) - { - num941 = 16f; - } - if (CalamityWorld.bossRushActive) - { - num941 = 24f; - } - if (Main.player[npc.target].gravDir == -1f) - { - num941 *= 2f; - } - Vector2 vector104 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)(npc.height / 2)); - float num942 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector104.X; - float num943 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector104.Y; - float num944 = (float)Math.Sqrt((double)(num942 * num942 + num943 * num943)); - num944 = num941 / num944; - num942 *= num944; - num943 *= num944; - int num945 = expertMode ? 38 : 45; - int num946 = ModContent.ProjectileType(); - vector104.X += num942 * 5f; - vector104.Y += num943 * 5f; - int num947 = Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, num946, num945, 0f, Main.myPlayer, 0f, 0f); - npc.netUpdate = true; - } - } - } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) - { - try - { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; - } catch - { - } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - { - npc.spriteDirection = -1; - } - else if (num191 > 0f) - { - npc.spriteDirection = 1; - } - } + CalamityAI.AstrumDeusAI(npc, mod, false, true); } public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) @@ -292,39 +147,6 @@ namespace CalamityMod.NPCs.AstrumDeus return !npc.dontTakeDamage; } - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (projectile.type == ModContent.ProjectileType() || ProjectileID.Sets.StardustDragon[projectile.type]) - { - damage = (int)((double)damage * 0.1); - } - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - { - damage = (int)((double)damage * 0.2); - } - else if (projectile.type == ProjectileID.DD2BetsyArrow) - { - damage = (int)((double)damage * 0.3); - } - else if (projectile.type == ModContent.ProjectileType()) - { - damage = (int)((double)damage * 0.5); - } - - if (projectile.penetrate == -1 && !projectile.minion) - { - if (projectile.type == ModContent.ProjectileType()) - damage = (int)((double)damage * 0.3); - else - damage = (int)((double)damage * 0.2); - } - else if (projectile.penetrate > 1 && projectile.type != ModContent.ProjectileType()) - { - damage /= projectile.penetrate; - } - } - public override bool CheckActive() { return false; diff --git a/NPCs/AstrumDeus/AstrumDeusHead.cs b/NPCs/AstrumDeus/AstrumDeusHead.cs index 1f9aca2d0c..c907765077 100644 --- a/NPCs/AstrumDeus/AstrumDeusHead.cs +++ b/NPCs/AstrumDeus/AstrumDeusHead.cs @@ -18,17 +18,6 @@ namespace CalamityMod.NPCs.AstrumDeus [AutoloadBossHead] public class AstrumDeusHead : ModNPC { - private bool flies = false; - private const int minLength = 4; - private const int maxLength = 5; - private int addOrbiter = 0; - private int addOrbiter2 = 0; - private float speed = 0.12f; - private float turnSpeed = 0.08f; - private bool tailSpawned = false; - private bool secondStage = false; - private bool thirdStage = false; - public override void SetStaticDefaults() { DisplayName.SetDefault("Astrum Deus"); @@ -81,475 +70,20 @@ namespace CalamityMod.NPCs.AstrumDeus public override void SendExtraAI(BinaryWriter writer) { - writer.Write(addOrbiter); - writer.Write(addOrbiter2); - writer.Write(secondStage); - writer.Write(thirdStage); writer.Write(npc.dontTakeDamage); writer.Write(npc.chaseable); } public override void ReceiveExtraAI(BinaryReader reader) { - addOrbiter = reader.ReadInt32(); - addOrbiter2 = reader.ReadInt32(); - secondStage = reader.ReadBoolean(); - thirdStage = reader.ReadBoolean(); npc.dontTakeDamage = reader.ReadBoolean(); npc.chaseable = reader.ReadBoolean(); } public override void AI() { - if (CalamityGlobalNPC.astrumDeusHeadMain != -1) - { - if (Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].active) - { - npc.dontTakeDamage = !Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].dontTakeDamage; - npc.chaseable = !Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].chaseable; - } - } - bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - if (CalamityWorld.death || CalamityWorld.bossRushActive) - { - if (npc.life <= npc.lifeMax * 0.9f) - { - if (secondStage == false && Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 74); - for (int I = 0; I < 3; I++) - { - int FireEye = NPC.NewNPC((int)(npc.Center.X + (Math.Sin(I * 120) * 75)), (int)(npc.Center.Y + (Math.Cos(I * 120) * 75)), ModContent.NPCType(), npc.whoAmI, 0, 0, 0, -1); - NPC Eye = Main.npc[FireEye]; - Eye.ai[0] = I * 120; - Eye.ai[3] = I * 120; - } - secondStage = true; - } - } - if (npc.life <= npc.lifeMax * 0.8f) - { - if (thirdStage == false && Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 74); - for (int I = 0; I < 5; I++) - { - int FireEye = NPC.NewNPC((int)(npc.Center.X + (Math.Sin(I * 72) * 150)), (int)(npc.Center.Y + (Math.Cos(I * 72) * 150)), ModContent.NPCType(), npc.whoAmI, 0, 0, 0, -1); - NPC Eye = Main.npc[FireEye]; - Eye.ai[0] = I * 72; - Eye.ai[3] = I * 72; - } - thirdStage = true; - } - } - } - else - { - if (npc.life <= npc.lifeMax * 0.65f) - { - if (secondStage == false && Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 74); - for (int I = 0; I < 3; I++) - { - int FireEye = NPC.NewNPC((int)(npc.Center.X + (Math.Sin(I * 120) * 75)), (int)(npc.Center.Y + (Math.Cos(I * 120) * 75)), ModContent.NPCType(), npc.whoAmI, 0, 0, 0, -1); - NPC Eye = Main.npc[FireEye]; - Eye.ai[0] = I * 120; - Eye.ai[3] = I * 120; - } - secondStage = true; - } - } - if (npc.life <= npc.lifeMax * 0.3f) - { - if (thirdStage == false && Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 74); - for (int I = 0; I < 5; I++) - { - int FireEye = NPC.NewNPC((int)(npc.Center.X + (Math.Sin(I * 72) * 150)), (int)(npc.Center.Y + (Math.Cos(I * 72) * 150)), ModContent.NPCType(), npc.whoAmI, 0, 0, 0, -1); - NPC Eye = Main.npc[FireEye]; - Eye.ai[0] = I * 72; - Eye.ai[3] = I * 72; - } - thirdStage = true; - } - } - } - if (npc.ai[3] > 0f) - { - npc.realLife = (int)npc.ai[3]; - } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - float speedAdd = expertMode ? 0.06f : 0.045f; - float turnSpeedAdd = expertMode ? 0.04f : 0.03f; - if (CalamityWorld.death || CalamityWorld.bossRushActive) - { - speedAdd *= 1.25f; - turnSpeedAdd *= 1.25f; - } - float life = (float)npc.life; - float totalLife = (float)npc.lifeMax; - float newSpeed = speed + speedAdd * (1f - (life / totalLife)); - float newTurnSpeed = turnSpeed + turnSpeedAdd * (1f - (life / totalLife)); - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - npc.alpha -= 42; - if (npc.alpha < 0) - { - npc.alpha = 0; - } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!tailSpawned && npc.ai[0] == 0f) - { - int Previous = npc.whoAmI; - for (int num36 = 0; num36 < maxLength; num36++) - { - int lol; - if (num36 >= 0 && num36 < minLength) - { - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } - else - { - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } - if (num36 % 2 == 0) - { - Main.npc[lol].localAI[3] = 1f; - } - Main.npc[lol].realLife = npc.whoAmI; - Main.npc[lol].ai[2] = (float)npc.whoAmI; - Main.npc[lol].ai[1] = (float)Previous; - Main.npc[Previous].ai[0] = (float)lol; - Previous = lol; - } - tailSpawned = true; - } - if (!npc.active && Main.netMode == NetmodeID.Server) - { - NetMessage.SendData(28, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0); - } - } - int num180 = (int)(npc.position.X / 16f) - 1; - int num181 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; - int num182 = (int)(npc.position.Y / 16f) - 1; - int num183 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; - if (num180 < 0) - { - num180 = 0; - } - if (num181 > Main.maxTilesX) - { - num181 = Main.maxTilesX; - } - if (num182 < 0) - { - num182 = 0; - } - if (num183 > Main.maxTilesY) - { - num183 = Main.maxTilesY; - } - bool flag94 = flies; - if (!flag94) - { - for (int num952 = num180; num952 < num181; num952++) - { - for (int num953 = num182; num953 < num183; num953++) - { - if (Main.tile[num952, num953] != null && ((Main.tile[num952, num953].nactive() && (Main.tileSolid[(int)Main.tile[num952, num953].type] || (Main.tileSolidTop[(int)Main.tile[num952, num953].type] && Main.tile[num952, num953].frameY == 0))) || Main.tile[num952, num953].liquid > 64)) - { - Vector2 vector105; - vector105.X = (float)(num952 * 16); - vector105.Y = (float)(num953 * 16); - if (npc.position.X + (float)npc.width > vector105.X && npc.position.X < vector105.X + 16f && npc.position.Y + (float)npc.height > vector105.Y && npc.position.Y < vector105.Y + 16f) - { - flag94 = true; - break; - } - } - } - } - } - if (!flag94) - { - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - npc.localAI[1] = 1f; - Rectangle rectangle12 = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int rectX = 300; - int rectY = (npc.Calamity().enraged || (Config.BossRushXerocCurse && CalamityWorld.bossRushActive)) ? 100 : 200; - bool flag95 = true; - if (npc.position.Y > Main.player[npc.target].position.Y) - { - for (int num955 = 0; num955 < 255; num955++) - { - if (Main.player[num955].active) - { - Rectangle rectangle13 = new Rectangle((int)Main.player[num955].position.X - rectX, (int)Main.player[num955].position.Y - rectY, rectX * 2, rectY * 2); - if (rectangle12.Intersects(rectangle13)) - { - flag95 = false; - break; - } - } - } - if (flag95) - { - flag94 = true; - } - } - } - else - { - npc.localAI[1] = 0f; - } - float maxSpeed = 20f; - if (Main.dayTime || Main.player[npc.target].dead || CalamityGlobalNPC.astrumDeusHeadMain < 0 || !Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].active) - { - flag94 = true; - npc.velocity.Y = npc.velocity.Y - 2f; - if ((double)npc.position.Y < Main.topWorld + 16f) - { - npc.velocity.Y = npc.velocity.Y - 2f; - maxSpeed = 40f; - } - if ((double)npc.position.Y < Main.topWorld + 16f) - { - for (int num957 = 0; num957 < 200; num957++) - { - if (Main.npc[num957].aiStyle == npc.aiStyle) - { - Main.npc[num957].active = false; - } - } - } - } - float num188 = newSpeed; - float num189 = newTurnSpeed; - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (!flag94) - { - npc.TargetClosest(true); - npc.velocity.Y = npc.velocity.Y + 0.15f; - if (npc.velocity.Y > maxSpeed) - { - npc.velocity.Y = maxSpeed; - } - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)maxSpeed * 0.4) - { - if (npc.velocity.X < 0f) - { - npc.velocity.X = npc.velocity.X - num188 * 1.1f; - } - else - { - npc.velocity.X = npc.velocity.X + num188 * 1.1f; - } - } - else if (npc.velocity.Y == maxSpeed) - { - if (npc.velocity.X < num191) - { - npc.velocity.X = npc.velocity.X + num188; - } - else if (npc.velocity.X > num191) - { - npc.velocity.X = npc.velocity.X - num188; - } - } - else if (npc.velocity.Y > 4f) - { - if (npc.velocity.X < 0f) - { - npc.velocity.X = npc.velocity.X + num188 * 0.9f; - } - else - { - npc.velocity.X = npc.velocity.X - num188 * 0.9f; - } - } - } - else - { - if (!flies && npc.behindTiles && npc.soundDelay == 0) - { - float num195 = num193 / 40f; - if (num195 < 10f) - { - num195 = 10f; - } - if (num195 > 20f) - { - num195 = 20f; - } - npc.soundDelay = (int)num195; - Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 1); - } - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - float num196 = System.Math.Abs(num191); - float num197 = System.Math.Abs(num192); - float num198 = maxSpeed / num193; - num191 *= num198; - num192 *= num198; - if (((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f)) && ((npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f))) - { - if (npc.velocity.X < num191) - { - npc.velocity.X = npc.velocity.X + num189; - } - else if (npc.velocity.X > num191) - { - npc.velocity.X = npc.velocity.X - num189; - } - if (npc.velocity.Y < num192) - { - npc.velocity.Y = npc.velocity.Y + num189; - } - else if (npc.velocity.Y > num192) - { - npc.velocity.Y = npc.velocity.Y - num189; - } - } - if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) - { - if (npc.velocity.X < num191) - { - npc.velocity.X = npc.velocity.X + num188; - } - else - { - if (npc.velocity.X > num191) - { - npc.velocity.X = npc.velocity.X - num188; - } - } - if (npc.velocity.Y < num192) - { - npc.velocity.Y = npc.velocity.Y + num188; - } - else - { - if (npc.velocity.Y > num192) - { - npc.velocity.Y = npc.velocity.Y - num188; - } - } - if ((double)System.Math.Abs(num192) < (double)maxSpeed * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) - { - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = npc.velocity.Y + num188 * 2f; - } - else - { - npc.velocity.Y = npc.velocity.Y - num188 * 2f; - } - } - if ((double)System.Math.Abs(num191) < (double)maxSpeed * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) - { - if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + num188 * 2f; - } - else - { - npc.velocity.X = npc.velocity.X - num188 * 2f; - } - } - } - else - { - if (num196 > num197) - { - if (npc.velocity.X < num191) - { - npc.velocity.X = npc.velocity.X + num188 * 1.1f; - } - else if (npc.velocity.X > num191) - { - npc.velocity.X = npc.velocity.X - num188 * 1.1f; - } - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)maxSpeed * 0.5) - { - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = npc.velocity.Y + num188; - } - else - { - npc.velocity.Y = npc.velocity.Y - num188; - } - } - } - else - { - if (npc.velocity.Y < num192) - { - npc.velocity.Y = npc.velocity.Y + num188 * 1.1f; - } - else if (npc.velocity.Y > num192) - { - npc.velocity.Y = npc.velocity.Y - num188 * 1.1f; - } - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)maxSpeed * 0.5) - { - if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + num188; - } - else - { - npc.velocity.X = npc.velocity.X - num188; - } - } - } - } - npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; - if (flag94) - { - if (npc.localAI[0] != 1f) - { - npc.netUpdate = true; - } - npc.localAI[0] = 1f; - } - else - { - if (npc.localAI[0] != 0f) - { - npc.netUpdate = true; - } - npc.localAI[0] = 0f; - } - if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) - { - npc.netUpdate = true; - } - } - } + CalamityAI.AstrumDeusAI(npc, mod, true, false); + } public override bool CanHitPlayer(Player target, ref int cooldownSlot) { @@ -568,39 +102,6 @@ namespace CalamityMod.NPCs.AstrumDeus return false; } - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (projectile.type == ModContent.ProjectileType() || ProjectileID.Sets.StardustDragon[projectile.type]) - { - damage = (int)((double)damage * 0.1); - } - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - { - damage = (int)((double)damage * 0.2); - } - else if (projectile.type == ProjectileID.DD2BetsyArrow) - { - damage = (int)((double)damage * 0.3); - } - else if (projectile.type == ModContent.ProjectileType()) - { - damage = (int)((double)damage * 0.5); - } - - if (projectile.penetrate == -1 && !projectile.minion) - { - if (projectile.type == ModContent.ProjectileType()) - damage = (int)((double)damage * 0.3); - else - damage = (int)((double)damage * 0.2); - } - else if (projectile.penetrate > 1 && projectile.type != ModContent.ProjectileType()) - { - damage /= projectile.penetrate; - } - } - public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) diff --git a/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs b/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs index b16fe44ecc..781f74decb 100644 --- a/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs @@ -27,15 +27,6 @@ namespace CalamityMod.NPCs.AstrumDeus [AutoloadBossHead] public class AstrumDeusHeadSpectral : ModNPC { - private bool colorChange = false; - private const int minLength = 12; - private const int maxLength = 13; - private float speed = 10f; - private float turnSpeed = 0.2f; - private bool tailSpawned = false; - private int deusHeadCount = 0; - private int astrumDeusTotalHPMax = 0; - public override void SetStaticDefaults() { DisplayName.SetDefault("Astrum Deus"); @@ -92,322 +83,20 @@ namespace CalamityMod.NPCs.AstrumDeus public override void SendExtraAI(BinaryWriter writer) { - writer.Write(deusHeadCount); - writer.Write(astrumDeusTotalHPMax); - writer.Write(colorChange); writer.Write(npc.dontTakeDamage); writer.Write(npc.chaseable); } public override void ReceiveExtraAI(BinaryReader reader) { - deusHeadCount = reader.ReadInt32(); - astrumDeusTotalHPMax = reader.ReadInt32(); - colorChange = reader.ReadBoolean(); npc.dontTakeDamage = reader.ReadBoolean(); npc.chaseable = reader.ReadBoolean(); } public override void AI() { - CalamityGlobalNPC.astrumDeusHeadMain = npc.whoAmI; - colorChange = NPC.AnyNPCs(ModContent.NPCType()); - int astrumDeusTotalHP = 0; - double mainDeusHPRatio = (double)npc.life / (double)npc.lifeMax; - if (colorChange) - { - for (int i = 0; i < 200; i++) - { - if (Main.npc[i].type == ModContent.NPCType()) - { - astrumDeusTotalHP += Main.npc[i].life; - if (deusHeadCount < 10) - { - deusHeadCount++; - astrumDeusTotalHPMax += Main.npc[i].lifeMax; - } - } - } - double astrumDeusHPRatio = (double)astrumDeusTotalHP / (double)astrumDeusTotalHPMax; - if (astrumDeusHPRatio < 0.33) - { - if (mainDeusHPRatio > 0.33) - colorChange = false; - } - else if (astrumDeusHPRatio < 0.66) - { - if (mainDeusHPRatio > 0.66) - colorChange = false; - } - } - npc.dontTakeDamage = colorChange; - npc.chaseable = !colorChange; - bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; - float speedLimit = CalamityWorld.revenge ? 7f : 6f; - float turnSpeedLimit = CalamityWorld.revenge ? 0.11f : 0.1f; - if (CalamityWorld.death) - { - speedLimit = 8f; - turnSpeedLimit = 0.12f; - } - if (CalamityWorld.bossRushActive) - { - speedLimit *= 1.5f; - turnSpeedLimit *= 1.5f; - } - float speedBoost = speedLimit * (1f - (float)mainDeusHPRatio); - float turnSpeedBoost = turnSpeedLimit * (1f - (float)mainDeusHPRatio); - if (Main.player[npc.target].gravDir == -1f) - { - speedBoost = speedLimit; - turnSpeedBoost = turnSpeedLimit; - } - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - if (npc.ai[3] > 0f) - { - npc.realLife = (int)npc.ai[3]; - } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - npc.alpha -= 42; - if (npc.alpha < 0) - { - npc.alpha = 0; - } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!tailSpawned && npc.ai[0] == 0f) - { - int Previous = npc.whoAmI; - for (int num36 = 0; num36 < maxLength; num36++) - { - int lol; - if (num36 >= 0 && num36 < minLength) - { - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } - else - { - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } - if (num36 % 2 == 0) - { - Main.npc[lol].localAI[3] = 1f; - } - Main.npc[lol].realLife = npc.whoAmI; - Main.npc[lol].ai[2] = (float)npc.whoAmI; - Main.npc[lol].ai[1] = (float)Previous; - Main.npc[Previous].ai[0] = (float)lol; - NetMessage.SendData(23, -1, -1, null, lol, 0f, 0f, 0f, 0); - Previous = lol; - } - tailSpawned = true; - } - } - if (Main.player[npc.target].dead || Main.dayTime) - { - npc.TargetClosest(false); - npc.velocity.Y = npc.velocity.Y - 3f; - if ((double)npc.position.Y < Main.topWorld + 16f) - { - npc.velocity.Y = npc.velocity.Y - 3f; - } - if ((double)npc.position.Y < Main.topWorld + 16f) - { - for (int num957 = 0; num957 < 200; num957++) - { - if (Main.npc[num957].aiStyle == npc.aiStyle) - { - Main.npc[num957].active = false; - } - } - } - } - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } - float num188 = speed + speedBoost; - float num189 = turnSpeed + turnSpeedBoost; - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - int num42 = -1; - int num43 = (int)(Main.player[npc.target].Center.X / 16f); - int num44 = (int)(Main.player[npc.target].Center.Y / 16f); - for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) - { - for (int num46 = num44; num46 <= num44 + 15; num46++) - { - if (WorldGen.SolidTile2(num45, num46)) - { - num42 = num46; - break; - } - } - if (num42 > 0) - { - break; - } - } - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = npc.velocity.Length(); - if (num50 > 0f) - { - if (num50 > num48) - { - npc.velocity.Normalize(); - npc.velocity *= num48; - } - else if (num50 < num49) - { - npc.velocity.Normalize(); - npc.velocity *= num49; - } - } - for (int num52 = 0; num52 < 200; num52++) - { - if (Main.npc[num52].active && Main.npc[num52].type == npc.type && num52 != npc.whoAmI) - { - Vector2 vector4 = Main.npc[num52].Center - npc.Center; - if (vector4.Length() < 60f) - { - vector4.Normalize(); - vector4 *= 200f; - num191 -= vector4.X; - num192 -= vector4.Y; - } - } - } - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - float num196 = System.Math.Abs(num191); - float num197 = System.Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) - { - if (npc.velocity.X < num191) - { - npc.velocity.X = npc.velocity.X + num189; - } - else - { - if (npc.velocity.X > num191) - { - npc.velocity.X = npc.velocity.X - num189; - } - } - if (npc.velocity.Y < num192) - { - npc.velocity.Y = npc.velocity.Y + num189; - } - else - { - if (npc.velocity.Y > num192) - { - npc.velocity.Y = npc.velocity.Y - num189; - } - } - if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) - { - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = npc.velocity.Y + num189 * 2f; - } - else - { - npc.velocity.Y = npc.velocity.Y - num189 * 2f; - } - } - if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) - { - if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + num189 * 2f; //changed from 2 - } - else - { - npc.velocity.X = npc.velocity.X - num189 * 2f; //changed from 2 - } - } - } - else - { - if (num196 > num197) - { - if (npc.velocity.X < num191) - { - npc.velocity.X = npc.velocity.X + num189 * 1.1f; //changed from 1.1 - } - else if (npc.velocity.X > num191) - { - npc.velocity.X = npc.velocity.X - num189 * 1.1f; //changed from 1.1 - } - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5) - { - if (npc.velocity.Y > 0f) - { - npc.velocity.Y = npc.velocity.Y + num189; - } - else - { - npc.velocity.Y = npc.velocity.Y - num189; - } - } - } - else - { - if (npc.velocity.Y < num192) - { - npc.velocity.Y = npc.velocity.Y + num189 * 1.1f; - } - else if (npc.velocity.Y > num192) - { - npc.velocity.Y = npc.velocity.Y - num189 * 1.1f; - } - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5) - { - if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + num189; - } - else - { - npc.velocity.X = npc.velocity.X - num189; - } - } - } - } - npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; - } + CalamityAI.AstrumDeusAI(npc, mod, true, true); + } public override bool CheckActive() { @@ -417,7 +106,7 @@ namespace CalamityMod.NPCs.AstrumDeus public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { Color lightColor = new Color(250, 150, Main.DiscoB, npc.alpha); - Color newColor = colorChange ? lightColor : drawColor; + Color newColor = npc.Calamity().newAI[0] == 1f ? lightColor : drawColor; SpriteEffects spriteEffects = SpriteEffects.None; Color color24 = npc.GetAlpha(newColor); Color color25 = 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)); @@ -459,46 +148,13 @@ namespace CalamityMod.NPCs.AstrumDeus public override bool CanHitPlayer(Player target, ref int cooldownSlot) { - if (colorChange && Main.player[npc.target].gravDir != -1f) + if (npc.Calamity().newAI[0] == 1f && Main.player[npc.target].gravDir != -1f) { return false; } return true; } - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (projectile.type == ModContent.ProjectileType() || ProjectileID.Sets.StardustDragon[projectile.type]) - { - damage = (int)((double)damage * 0.1); - } - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - { - damage = (int)((double)damage * 0.2); - } - else if (projectile.type == ProjectileID.DD2BetsyArrow) - { - damage = (int)((double)damage * 0.3); - } - else if (projectile.type == ModContent.ProjectileType()) - { - damage = (int)((double)damage * 0.5); - } - - if (projectile.penetrate == -1 && !projectile.minion) - { - if (projectile.type == ModContent.ProjectileType()) - damage = (int)((double)damage * 0.3); - else - damage = (int)((double)damage * 0.2); - } - else if (projectile.penetrate > 1 && projectile.type != ModContent.ProjectileType()) - { - damage /= projectile.penetrate; - } - } - public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) diff --git a/NPCs/AstrumDeus/AstrumDeusTail.cs b/NPCs/AstrumDeus/AstrumDeusTail.cs index 8abe407cc6..23d5a00c78 100644 --- a/NPCs/AstrumDeus/AstrumDeusTail.cs +++ b/NPCs/AstrumDeus/AstrumDeusTail.cs @@ -82,39 +82,8 @@ namespace CalamityMod.NPCs.AstrumDeus public override void AI() { - if (CalamityGlobalNPC.astrumDeusHeadMain != -1) - { - if (Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].active) - { - npc.dontTakeDamage = !Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].dontTakeDamage; - npc.chaseable = !Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].chaseable; - } - } - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - if (!Main.npc[(int)npc.ai[1]].active) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.active = false; - } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - npc.alpha -= 42; - if (npc.alpha < 0) - { - npc.alpha = 0; - } - } - } + CalamityAI.AstrumDeusAI(npc, mod, false, false); + } public override bool CanHitPlayer(Player target, ref int cooldownSlot) { @@ -128,39 +97,6 @@ namespace CalamityMod.NPCs.AstrumDeus return null; } - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (projectile.type == ModContent.ProjectileType() || ProjectileID.Sets.StardustDragon[projectile.type]) - { - damage = (int)((double)damage * 0.1); - } - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - { - damage = (int)((double)damage * 0.2); - } - else if (projectile.type == ProjectileID.DD2BetsyArrow) - { - damage = (int)((double)damage * 0.3); - } - else if (projectile.type == ModContent.ProjectileType()) - { - damage = (int)((double)damage * 0.5); - } - - if (projectile.penetrate == -1 && !projectile.minion) - { - if (projectile.type == ModContent.ProjectileType()) - damage = (int)((double)damage * 0.3); - else - damage = (int)((double)damage * 0.2); - } - else if (projectile.penetrate > 1 && projectile.type != ModContent.ProjectileType()) - { - damage /= projectile.penetrate; - } - } - public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) diff --git a/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs b/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs index 0f5eb043e7..1d400d1329 100644 --- a/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs @@ -90,104 +90,8 @@ namespace CalamityMod.NPCs.AstrumDeus public override void AI() { - if (CalamityGlobalNPC.astrumDeusHeadMain != -1) - { - npc.dontTakeDamage = Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].dontTakeDamage; - npc.chaseable = Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].chaseable; - } - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - if (npc.ai[3] > 0f) - { - npc.realLife = (int)npc.ai[3]; - } - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - npc.velocity.Length(); - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } - bool flag = false; - if (npc.ai[1] <= 0f) - { - flag = true; - } - else if (Main.npc[(int)npc.ai[1]].life <= 0) - { - flag = true; - } - if (flag) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - npc.alpha -= 42; - if (npc.alpha < 0) - { - npc.alpha = 0; - } - } - if (Main.player[npc.target].dead) - { - npc.TargetClosest(false); - } - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) - { - try - { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; - } catch - { - } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - { - npc.spriteDirection = -1; - } - else if (num191 > 0f) - { - npc.spriteDirection = 1; - } - } - } + CalamityAI.AstrumDeusAI(npc, mod, false, true); + } public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { @@ -237,39 +141,6 @@ namespace CalamityMod.NPCs.AstrumDeus return !npc.dontTakeDamage; } - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (projectile.type == ModContent.ProjectileType() || ProjectileID.Sets.StardustDragon[projectile.type]) - { - damage = (int)((double)damage * 0.1); - } - else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || - projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) - { - damage = (int)((double)damage * 0.2); - } - else if (projectile.type == ProjectileID.DD2BetsyArrow) - { - damage = (int)((double)damage * 0.3); - } - else if (projectile.type == ModContent.ProjectileType()) - { - damage = (int)((double)damage * 0.5); - } - - if (projectile.penetrate == -1 && !projectile.minion) - { - if (projectile.type == ModContent.ProjectileType()) - damage = (int)((double)damage * 0.3); - else - damage = (int)((double)damage * 0.2); - } - else if (projectile.penetrate > 1 && projectile.type != ModContent.ProjectileType()) - { - damage /= projectile.penetrate; - } - } - public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index a543982e18..3927eb51e3 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -1,6 +1,7 @@ using CalamityMod.Dusts; using CalamityMod.NPCs.AquaticScourge; using CalamityMod.NPCs.AstrumAureus; +using CalamityMod.NPCs.AstrumDeus; using CalamityMod.NPCs.BrimstoneElemental; using CalamityMod.NPCs.Bumblebirb; using CalamityMod.NPCs.Calamitas; @@ -19,12 +20,10 @@ namespace CalamityMod.NPCs public class CalamityAI { #region Aquatic Scourge - public static void AquaticScourgeAI(NPC npc, Mod mod) + public static void AquaticScourgeAI(NPC npc, Mod mod, bool head) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool head = npc.type == ModContent.NPCType(); - // Adjust hostility and stats if (npc.justHit || (double)npc.life <= (double)npc.lifeMax * 0.99 || CalamityWorld.bossRushActive || (double)Main.npc[(int)npc.ai[1]].life <= (double)Main.npc[(int)npc.ai[1]].lifeMax * 0.99) @@ -54,7 +53,7 @@ namespace CalamityMod.NPCs { if (head) { - // Spawn body and tail + // Spawn segments if (calamityGlobalNPC.newAI[2] == 0f && npc.ai[0] == 0f) { int maxLength = 31; @@ -281,10 +280,6 @@ namespace CalamityMod.NPCs else if (npc.velocity.X > 0f) npc.spriteDirection = 1; - // Remove target - if (Main.player[npc.target].dead) - npc.TargetClosest(false); - // Alpha changes if (head || Main.npc[(int)npc.ai[1]].alpha < 128) { @@ -1853,6 +1848,757 @@ namespace CalamityMod.NPCs } #endregion + #region Astrum Deus + public static void AstrumDeusAI(NPC npc, Mod mod, bool head, bool finalWorm) + { + // All parts of every worm use the following code + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + // Difficulty variables + bool expertMode = Main.expertMode || CalamityWorld.bossRushActive; + bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; + + // Emit light + Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); + + // Dust and alpha effects + if (head || Main.npc[(int)npc.ai[1]].alpha < 128) + { + // Spawn dust + if (npc.alpha != 0) + { + for (int num934 = 0; num934 < 2; num934++) + { + int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); + Main.dust[num935].noGravity = true; + Main.dust[num935].noLight = true; + } + } + + // Alpha changes + npc.alpha -= 42; + if (npc.alpha < 0) + npc.alpha = 0; + } + + // Set worm variable + if (npc.ai[3] > 0f) + npc.realLife = (int)npc.ai[3]; + + // Get a target + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) + npc.TargetClosest(true); + + // Velocity + npc.velocity.Length(); + + // Direction + if (npc.velocity.X < 0f) + npc.spriteDirection = -1; + else if (npc.velocity.X > 0f) + npc.spriteDirection = 1; + + // Despawn + float maxSpeed = 20f; + bool flies = false; + if (Main.player[npc.target].dead || Main.dayTime || (!finalWorm && (CalamityGlobalNPC.astrumDeusHeadMain < 0 || !Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].active))) + { + flies = true; + npc.TargetClosest(false); + npc.velocity.Y = npc.velocity.Y - 3f; + if ((double)npc.position.Y < Main.topWorld + 16f) + { + maxSpeed = 40f; + npc.velocity.Y = npc.velocity.Y - 3f; + } + + if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int num957 = 0; num957 < 200; num957++) + { + if (Main.npc[num957].aiStyle == npc.aiStyle) + Main.npc[num957].active = false; + } + } + } + + // All heads use this code + if (head) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (calamityGlobalNPC.newAI[1] == 0f && npc.ai[0] == 0f) + { + int maxLength = finalWorm ? 13 : 5; + int Previous = npc.whoAmI; + int bodyType = finalWorm ? ModContent.NPCType() : ModContent.NPCType(); + int tailType = finalWorm ? ModContent.NPCType() : ModContent.NPCType(); + for (int num36 = 0; num36 < maxLength; num36++) + { + int lol; + if (num36 >= 0 && num36 < maxLength - 1) + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), bodyType, npc.whoAmI); + else + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), tailType, npc.whoAmI); + + if (num36 % 2 == 0) + Main.npc[lol].localAI[3] = 1f; + + Main.npc[lol].realLife = npc.whoAmI; + Main.npc[lol].ai[2] = (float)npc.whoAmI; + Main.npc[lol].ai[1] = (float)Previous; + Main.npc[Previous].ai[0] = (float)lol; + NetMessage.SendData(23, -1, -1, null, lol, 0f, 0f, 0f, 0); + Previous = lol; + } + calamityGlobalNPC.newAI[1] = 1f; + } + } + } + + // All body and tail segments use this code + else + { + // Kill segments + bool flag = false; + if (npc.ai[1] <= 0f) + flag = true; + else if (Main.npc[(int)npc.ai[1]].life <= 0) + flag = true; + + if (flag) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + } + } + + // Only the main worm uses this code + if (finalWorm) + { + // Only the main worm head uses this code + if (head) + { + // For other worms and probes + CalamityGlobalNPC.astrumDeusHeadMain = npc.whoAmI; + + // Change color depending on phase + if (NPC.AnyNPCs(ModContent.NPCType())) + calamityGlobalNPC.newAI[0] = 1f; + else + calamityGlobalNPC.newAI[0] = 0f; + + // Calculate phases based on worm HP + int astrumDeusTotalHP = 0; + double mainDeusHPRatio = (double)npc.life / (double)npc.lifeMax; + if (calamityGlobalNPC.newAI[0] == 1f) + { + for (int i = 0; i < 200; i++) + { + if (Main.npc[i].type == ModContent.NPCType()) + { + astrumDeusTotalHP += Main.npc[i].life; + if (calamityGlobalNPC.newAI[2] < 10f) + { + calamityGlobalNPC.newAI[2] += 1f; + calamityGlobalNPC.newAI[3] += (float)Main.npc[i].lifeMax; + } + } + } + + double astrumDeusHPRatio = (double)astrumDeusTotalHP / (double)calamityGlobalNPC.newAI[3]; + if (astrumDeusHPRatio < 0.33) + { + if (mainDeusHPRatio > 0.33) + calamityGlobalNPC.newAI[0] = 0f; + } + else if (astrumDeusHPRatio < 0.66) + { + if (mainDeusHPRatio > 0.66) + calamityGlobalNPC.newAI[0] = 0f; + } + } + + // Change vulnerability based on phase (indicated by color) + npc.dontTakeDamage = calamityGlobalNPC.newAI[0] == 1f; + npc.chaseable = calamityGlobalNPC.newAI[0] != 1f; + + // Speed and turn speed + float speedLimit = revenge ? 7f : 6f; + float turnSpeedLimit = revenge ? 0.11f : 0.1f; + if (CalamityWorld.death || CalamityWorld.bossRushActive) + { + speedLimit = 8f; + turnSpeedLimit = 0.12f; + } + if (CalamityWorld.bossRushActive) + { + speedLimit *= 1.5f; + turnSpeedLimit *= 1.5f; + } + + // Speed and turn speed boosts based on remaining HP + float speedBoost = speedLimit * (1f - (float)mainDeusHPRatio); + float turnSpeedBoost = turnSpeedLimit * (1f - (float)mainDeusHPRatio); + if (Main.player[npc.target].gravDir == -1f) + { + speedBoost = speedLimit; + turnSpeedBoost = turnSpeedLimit; + } + + // Velocity + float num188 = 10f + speedBoost; + float num189 = 0.2f + turnSpeedBoost; + + Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); + + int num42 = -1; + int num43 = (int)(Main.player[npc.target].Center.X / 16f); + int num44 = (int)(Main.player[npc.target].Center.Y / 16f); + + for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) + { + for (int num46 = num44; num46 <= num44 + 15; num46++) + { + if (WorldGen.SolidTile2(num45, num46)) + { + num42 = num46; + break; + } + } + if (num42 > 0) + break; + } + + float num48 = num188 * 1.3f; + float num49 = num188 * 0.7f; + float num50 = npc.velocity.Length(); + if (num50 > 0f) + { + if (num50 > num48) + { + npc.velocity.Normalize(); + npc.velocity *= num48; + } + else if (num50 < num49) + { + npc.velocity.Normalize(); + npc.velocity *= num49; + } + } + + for (int num52 = 0; num52 < 200; num52++) + { + if (Main.npc[num52].active && Main.npc[num52].type == npc.type && num52 != npc.whoAmI) + { + Vector2 vector4 = Main.npc[num52].Center - npc.Center; + if (vector4.Length() < 60f) + { + vector4.Normalize(); + vector4 *= 200f; + num191 -= vector4.X; + num192 -= vector4.Y; + } + } + } + + num191 = (float)((int)(num191 / 16f) * 16); + num192 = (float)((int)(num192 / 16f) * 16); + vector18.X = (float)((int)(vector18.X / 16f) * 16); + vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + num191 -= vector18.X; + num192 -= vector18.Y; + float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + float num196 = System.Math.Abs(num191); + float num197 = System.Math.Abs(num192); + float num198 = num188 / num193; + num191 *= num198; + num192 *= num198; + + if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) + { + if (npc.velocity.X < num191) + { + npc.velocity.X = npc.velocity.X + num189; + } + else + { + if (npc.velocity.X > num191) + npc.velocity.X = npc.velocity.X - num189; + } + + if (npc.velocity.Y < num192) + { + npc.velocity.Y = npc.velocity.Y + num189; + } + else + { + if (npc.velocity.Y > num192) + npc.velocity.Y = npc.velocity.Y - num189; + } + + if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y = npc.velocity.Y + num189 * 2f; + else + npc.velocity.Y = npc.velocity.Y - num189 * 2f; + } + + if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) + { + if (npc.velocity.X > 0f) + npc.velocity.X = npc.velocity.X + num189 * 2f; + else + npc.velocity.X = npc.velocity.X - num189 * 2f; + } + } + else + { + if (num196 > num197) + { + if (npc.velocity.X < num191) + npc.velocity.X = npc.velocity.X + num189 * 1.1f; + else if (npc.velocity.X > num191) + npc.velocity.X = npc.velocity.X - num189 * 1.1f; + + if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y = npc.velocity.Y + num189; + else + npc.velocity.Y = npc.velocity.Y - num189; + } + } + else + { + if (npc.velocity.Y < num192) + npc.velocity.Y = npc.velocity.Y + num189 * 1.1f; + else if (npc.velocity.Y > num192) + npc.velocity.Y = npc.velocity.Y - num189 * 1.1f; + + if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5) + { + if (npc.velocity.X > 0f) + npc.velocity.X = npc.velocity.X + num189; + else + npc.velocity.X = npc.velocity.X - num189; + } + } + } + npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; + } + + // Only the main worm body and tail use this code + else + { + // Change vulnerability based on phase (indicated by color) + if (CalamityGlobalNPC.astrumDeusHeadMain != -1) + { + npc.dontTakeDamage = Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].dontTakeDamage; + npc.chaseable = Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].chaseable; + } + + // Shoot lasers + if (npc.type == ModContent.NPCType() && Main.netMode != NetmodeID.MultiplayerClient) + { + int shootTime = 4; + if ((double)npc.life <= (double)npc.lifeMax * 0.65 || CalamityWorld.bossRushActive || Main.player[npc.target].gravDir == -1f) + { + shootTime += CalamityWorld.death ? 4 : 2; + } + if ((double)npc.life <= (double)npc.lifeMax * 0.3 || CalamityWorld.bossRushActive || Main.player[npc.target].gravDir == -1f) + { + shootTime += CalamityWorld.death ? 6 : 2; + } + npc.localAI[0] += (float)Main.rand.Next(shootTime); + if (npc.localAI[0] >= (float)Main.rand.Next(1400, 20000)) + { + npc.localAI[0] = 0f; + npc.TargetClosest(true); + if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + { + float num941 = revenge ? 14f : 13f; + if (CalamityWorld.death) + { + num941 = 16f; + } + if (CalamityWorld.bossRushActive) + { + num941 = 24f; + } + if (Main.player[npc.target].gravDir == -1f) + { + num941 *= 2f; + } + Vector2 vector104 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)(npc.height / 2)); + float num942 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector104.X; + float num943 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector104.Y; + float num944 = (float)Math.Sqrt((double)(num942 * num942 + num943 * num943)); + num944 = num941 / num944; + num942 *= num944; + num943 *= num944; + int num945 = expertMode ? 38 : 45; + int num946 = ModContent.ProjectileType(); + vector104.X += num942 * 5f; + vector104.Y += num943 * 5f; + int num947 = Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, num946, num945, 0f, Main.myPlayer, 0f, 0f); + npc.netUpdate = true; + } + } + } + + // Follow the head + Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); + num191 = (float)((int)(num191 / 16f) * 16); + num192 = (float)((int)(num192 / 16f) * 16); + vector18.X = (float)((int)(vector18.X / 16f) * 16); + vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + num191 -= vector18.X; + num192 -= vector18.Y; + float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + + if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + { + try + { + vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; + num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + } + catch + { + } + + npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; + num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + int num194 = npc.width; + num193 = (num193 - (float)num194) / num193; + num191 *= num193; + num192 *= num193; + npc.velocity = Vector2.Zero; + npc.position.X = npc.position.X + num191; + npc.position.Y = npc.position.Y + num192; + + if (num191 < 0f) + npc.spriteDirection = -1; + else if (num191 > 0f) + npc.spriteDirection = 1; + } + } + } + + // Only the smaller worms use this code + else + { + // Change vulnerability based on phase (indicated by final worm color) + if (CalamityGlobalNPC.astrumDeusHeadMain != -1) + { + if (Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].active) + { + npc.dontTakeDamage = !Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].dontTakeDamage; + npc.chaseable = !Main.npc[CalamityGlobalNPC.astrumDeusHeadMain].chaseable; + } + } + + // Life remaining + float deusHPRatio = (float)npc.life / (float)npc.lifeMax; + + // Only the smaller worm heads use this code + if (head) + { + // Spawn mine probes + float firstProbeSpawnThreshold = ((CalamityWorld.death || CalamityWorld.bossRushActive) ? 0.9f : 0.66f); + float secondProbeSpawnThreshold = ((CalamityWorld.death || CalamityWorld.bossRushActive) ? 0.8f : 0.33f); + + if (deusHPRatio <= firstProbeSpawnThreshold) + { + if (calamityGlobalNPC.newAI[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 74); + for (int I = 0; I < 3; I++) + { + int FireEye = NPC.NewNPC((int)(npc.Center.X + (Math.Sin(I * 120) * 75)), (int)(npc.Center.Y + (Math.Cos(I * 120) * 75)), ModContent.NPCType(), npc.whoAmI, 0, 0, 0, -1); + NPC Eye = Main.npc[FireEye]; + Eye.ai[0] = I * 120; + Eye.ai[3] = I * 120; + } + calamityGlobalNPC.newAI[0] = 1f; + } + } + if (deusHPRatio <= secondProbeSpawnThreshold) + { + if (calamityGlobalNPC.newAI[0] == 1f && Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 74); + for (int I = 0; I < 5; I++) + { + int FireEye = NPC.NewNPC((int)(npc.Center.X + (Math.Sin(I * 72) * 150)), (int)(npc.Center.Y + (Math.Cos(I * 72) * 150)), ModContent.NPCType(), npc.whoAmI, 0, 0, 0, -1); + NPC Eye = Main.npc[FireEye]; + Eye.ai[0] = I * 72; + Eye.ai[3] = I * 72; + } + calamityGlobalNPC.newAI[0] = 2f; + } + } + + // Velocity variables + float speedAdd = expertMode ? 0.06f : 0.045f; + float turnSpeedAdd = expertMode ? 0.04f : 0.03f; + if (CalamityWorld.death || CalamityWorld.bossRushActive) + { + speedAdd *= 1.25f; + turnSpeedAdd *= 1.25f; + } + float newSpeed = 0.12f + speedAdd * (1f - deusHPRatio); + float newTurnSpeed = 0.08f + turnSpeedAdd * (1f - deusHPRatio); + + // Movement variables + int num180 = (int)(npc.position.X / 16f) - 1; + int num181 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; + int num182 = (int)(npc.position.Y / 16f) - 1; + int num183 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; + + if (num180 < 0) + num180 = 0; + if (num181 > Main.maxTilesX) + num181 = Main.maxTilesX; + if (num182 < 0) + num182 = 0; + if (num183 > Main.maxTilesY) + num183 = Main.maxTilesY; + + // Fly or not + if (!flies) + { + for (int num952 = num180; num952 < num181; num952++) + { + for (int num953 = num182; num953 < num183; num953++) + { + if (Main.tile[num952, num953] != null && ((Main.tile[num952, num953].nactive() && (Main.tileSolid[(int)Main.tile[num952, num953].type] || (Main.tileSolidTop[(int)Main.tile[num952, num953].type] && Main.tile[num952, num953].frameY == 0))) || Main.tile[num952, num953].liquid > 64)) + { + Vector2 vector105; + vector105.X = (float)(num952 * 16); + vector105.Y = (float)(num953 * 16); + if (npc.position.X + (float)npc.width > vector105.X && npc.position.X < vector105.X + 16f && npc.position.Y + (float)npc.height > vector105.Y && npc.position.Y < vector105.Y + 16f) + { + flies = true; + break; + } + } + } + } + } + + if (!flies) + { + npc.localAI[1] = 1f; + Rectangle rectangle12 = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); + int rectX = 300; + int rectY = (npc.Calamity().enraged || (Config.BossRushXerocCurse && CalamityWorld.bossRushActive)) ? 100 : 200; + bool flag95 = true; + if (npc.position.Y > Main.player[npc.target].position.Y) + { + for (int num955 = 0; num955 < 255; num955++) + { + if (Main.player[num955].active) + { + Rectangle rectangle13 = new Rectangle((int)Main.player[num955].position.X - rectX, (int)Main.player[num955].position.Y - rectY, rectX * 2, rectY * 2); + if (rectangle12.Intersects(rectangle13)) + { + flag95 = false; + break; + } + } + } + if (flag95) + flies = true; + } + } + else + npc.localAI[1] = 0f; + + // Velocity + float num188 = newSpeed; + float num189 = newTurnSpeed; + Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); + num191 = (float)((int)(num191 / 16f) * 16); + num192 = (float)((int)(num192 / 16f) * 16); + vector18.X = (float)((int)(vector18.X / 16f) * 16); + vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + num191 -= vector18.X; + num192 -= vector18.Y; + float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + + if (!flies) + { + npc.TargetClosest(true); + + npc.velocity.Y = npc.velocity.Y + 0.15f; + if (npc.velocity.Y > maxSpeed) + npc.velocity.Y = maxSpeed; + + if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)maxSpeed * 0.4) + { + if (npc.velocity.X < 0f) + npc.velocity.X = npc.velocity.X - num188 * 1.1f; + else + npc.velocity.X = npc.velocity.X + num188 * 1.1f; + } + else if (npc.velocity.Y == maxSpeed) + { + if (npc.velocity.X < num191) + npc.velocity.X = npc.velocity.X + num188; + else if (npc.velocity.X > num191) + npc.velocity.X = npc.velocity.X - num188; + } + else if (npc.velocity.Y > 4f) + { + if (npc.velocity.X < 0f) + npc.velocity.X = npc.velocity.X + num188 * 0.9f; + else + npc.velocity.X = npc.velocity.X - num188 * 0.9f; + } + } + else + { + if (npc.behindTiles && npc.soundDelay == 0) + { + float num195 = num193 / 40f; + if (num195 < 10f) + num195 = 10f; + if (num195 > 20f) + num195 = 20f; + + npc.soundDelay = (int)num195; + Main.PlaySound(15, (int)npc.position.X, (int)npc.position.Y, 1); + } + + num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + float num196 = System.Math.Abs(num191); + float num197 = System.Math.Abs(num192); + float num198 = maxSpeed / num193; + num191 *= num198; + num192 *= num198; + + if (((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f)) && ((npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f))) + { + if (npc.velocity.X < num191) + npc.velocity.X = npc.velocity.X + num189; + else if (npc.velocity.X > num191) + npc.velocity.X = npc.velocity.X - num189; + + if (npc.velocity.Y < num192) + npc.velocity.Y = npc.velocity.Y + num189; + else if (npc.velocity.Y > num192) + npc.velocity.Y = npc.velocity.Y - num189; + } + + if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) + { + if (npc.velocity.X < num191) + { + npc.velocity.X = npc.velocity.X + num188; + } + else + { + if (npc.velocity.X > num191) + npc.velocity.X = npc.velocity.X - num188; + } + + if (npc.velocity.Y < num192) + { + npc.velocity.Y = npc.velocity.Y + num188; + } + else + { + if (npc.velocity.Y > num192) + npc.velocity.Y = npc.velocity.Y - num188; + } + + if ((double)System.Math.Abs(num192) < (double)maxSpeed * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y = npc.velocity.Y + num188 * 2f; + else + npc.velocity.Y = npc.velocity.Y - num188 * 2f; + } + + if ((double)System.Math.Abs(num191) < (double)maxSpeed * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) + { + if (npc.velocity.X > 0f) + npc.velocity.X = npc.velocity.X + num188 * 2f; + else + npc.velocity.X = npc.velocity.X - num188 * 2f; + } + } + else + { + if (num196 > num197) + { + if (npc.velocity.X < num191) + npc.velocity.X = npc.velocity.X + num188 * 1.1f; + else if (npc.velocity.X > num191) + npc.velocity.X = npc.velocity.X - num188 * 1.1f; + + if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)maxSpeed * 0.5) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y = npc.velocity.Y + num188; + else + npc.velocity.Y = npc.velocity.Y - num188; + } + } + else + { + if (npc.velocity.Y < num192) + npc.velocity.Y = npc.velocity.Y + num188 * 1.1f; + else if (npc.velocity.Y > num192) + npc.velocity.Y = npc.velocity.Y - num188 * 1.1f; + + if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)maxSpeed * 0.5) + { + if (npc.velocity.X > 0f) + npc.velocity.X = npc.velocity.X + num188; + else + npc.velocity.X = npc.velocity.X - num188; + } + } + } + + npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; + + if (flies) + { + if (npc.localAI[0] != 1f) + npc.netUpdate = true; + + npc.localAI[0] = 1f; + } + else + { + if (npc.localAI[0] != 0f) + npc.netUpdate = true; + + npc.localAI[0] = 0f; + } + if (((npc.velocity.X > 0f && npc.oldVelocity.X < 0f) || (npc.velocity.X < 0f && npc.oldVelocity.X > 0f) || (npc.velocity.Y > 0f && npc.oldVelocity.Y < 0f) || (npc.velocity.Y < 0f && npc.oldVelocity.Y > 0f)) && !npc.justHit) + { + npc.netUpdate = true; + } + } + } + } + } + #endregion + #region Bumblebirb public static void BumblebirbAI(NPC npc, Mod mod) { diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index bbbb0399fe..111a44568d 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -39,6 +39,8 @@ using CalamityMod.NPCs.StormWeaver; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.TownNPCs; using CalamityMod.NPCs.Yharon; +using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; @@ -238,10 +240,46 @@ namespace CalamityMod.NPCs { NPCID.CultistBoss, Item.buyPrice(0, 25) }, { NPCID.MoonLordCore, Item.buyPrice(0, 30) } }; - #endregion - #region Instance Per Entity - public override bool InstancePerEntity => true; + /// + /// Lists of enemies that resist piercing to some extent (mostly worms). + /// Could prove useful for other things as well. + /// + public static List AstrumDeusIDs = new List + { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType() + }; + + public static List AquaticScourgeIDs = new List + { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType() + }; + + public static List EaterofWorldsIDs = new List + { + NPCID.EaterofWorldsHead, + NPCID.EaterofWorldsBody, + NPCID.EaterofWorldsTail + }; + + public static List DestroyerIDs = new List + { + NPCID.TheDestroyer, + NPCID.TheDestroyerBody, + NPCID.TheDestroyerTail + }; + #endregion + + #region Instance Per Entity + public override bool InstancePerEntity => true; #endregion #region Reset Effects @@ -582,9 +620,7 @@ namespace CalamityMod.NPCs npc.buffImmune[ModContent.BuffType()] = true; } - if (npc.type == NPCID.TheDestroyer || npc.type == NPCID.TheDestroyerBody || npc.type == NPCID.TheDestroyerTail || - npc.type == NPCID.DD2EterniaCrystal || - npc.townNPC) + if (DestroyerIDs.Contains(npc.type) || npc.type == NPCID.DD2EterniaCrystal || npc.townNPC) { for (int k = 0; k < npc.buffImmune.Length; k++) { @@ -805,7 +841,7 @@ namespace CalamityMod.NPCs { npc.lifeMax = CalamityWorld.death ? (int)(npc.lifeMax * 1.2) : (int)(npc.lifeMax * 1.1); } - else if (npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsBody || npc.type == NPCID.EaterofWorldsTail) + else if (EaterofWorldsIDs.Contains(npc.type)) { npc.lifeMax = CalamityWorld.death ? (int)(npc.lifeMax * 1.4) : (int)(npc.lifeMax * 1.3); @@ -833,7 +869,7 @@ namespace CalamityMod.NPCs if (!DraedonMayhem) { - if (npc.type == NPCID.TheDestroyer || npc.type == NPCID.TheDestroyerBody || npc.type == NPCID.TheDestroyerTail) + if (DestroyerIDs.Contains(npc.type)) { npc.lifeMax = CalamityWorld.death ? (int)(npc.lifeMax * 1.6) : (int)(npc.lifeMax * 1.25); npc.scale = 1.5f; @@ -1171,8 +1207,7 @@ namespace CalamityMod.NPCs #region Strike NPC public override bool StrikeNPC(NPC npc, ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { - // TODO -- move this to Destroyer's Rev+ AI; either set his DR or modify npc.takenDamageMultiplier - if (npc.type == NPCID.TheDestroyer || npc.type == NPCID.TheDestroyerBody || npc.type == NPCID.TheDestroyerTail) + if (DestroyerIDs.Contains(npc.type)) { if ((newAI[1] < 480f || newAI[2] > 0f) && (CalamityWorld.revenge || CalamityWorld.bossRushActive)) { @@ -1372,8 +1407,7 @@ namespace CalamityMod.NPCs npc.dontTakeDamage = CalamityPlayer.areThereAnyDamnBosses; } - if (npc.type == NPCID.TheDestroyer || npc.type == NPCID.TheDestroyerBody || npc.type == NPCID.TheDestroyerTail || - npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsBody || npc.type == NPCID.EaterofWorldsTail) + if (DestroyerIDs.Contains(npc.type) || EaterofWorldsIDs.Contains(npc.type)) { npc.buffImmune[ModContent.BuffType()] = false; } @@ -1700,8 +1734,7 @@ namespace CalamityMod.NPCs break; case 7: - if (npc.type != NPCID.EaterofWorldsHead && npc.type != NPCID.EaterofWorldsBody && npc.type != NPCID.EaterofWorldsTail && - npc.type != NPCID.VileSpit) + if (!EaterofWorldsIDs.Contains(npc.type) && npc.type != NPCID.VileSpit) { npc.active = false; npc.netUpdate = true; @@ -1719,8 +1752,7 @@ namespace CalamityMod.NPCs break; case 9: - if (npc.type != NPCID.TheDestroyer && npc.type != NPCID.TheDestroyerBody && npc.type != NPCID.TheDestroyerTail && - npc.type != NPCID.Probe) + if (!DestroyerIDs.Contains(npc.type) && npc.type != NPCID.Probe) { npc.active = false; npc.netUpdate = true; @@ -1934,11 +1966,8 @@ namespace CalamityMod.NPCs break; case 29: - if (npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType() && - npc.type != ModContent.NPCType()) + if (!AstrumDeusIDs.Contains(npc.type) && npc.type != ModContent.NPCType() && + npc.type != ModContent.NPCType() && npc.type != ModContent.NPCType()) { npc.active = false; npc.netUpdate = true; @@ -2354,7 +2383,39 @@ namespace CalamityMod.NPCs damage *= Main.expertMode ? 4 : 2; } - if (npc.type == NPCID.TheDestroyerBody) + if (AstrumDeusIDs.Contains(npc.type)) + { + if (projectile.type == ModContent.ProjectileType() || ProjectileID.Sets.StardustDragon[projectile.type]) + { + damage = (int)(damage * 0.1); + } + else if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || + projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) + { + damage = (int)(damage * 0.2); + } + else if (projectile.type == ProjectileID.DD2BetsyArrow) + { + damage = (int)(damage * 0.3); + } + else if (projectile.type == ModContent.ProjectileType()) + { + damage = (int)(damage * 0.5); + } + + if (projectile.penetrate == -1 && !projectile.minion) + { + if (projectile.type == ModContent.ProjectileType()) + damage = (int)(damage * 0.3); + else + damage = (int)(damage * 0.2); + } + else if (projectile.penetrate > 1 && projectile.type != ModContent.ProjectileType()) + { + damage /= projectile.penetrate; + } + } + else if (DestroyerIDs.Contains(npc.type)) { if (((projectile.penetrate == -1 || projectile.penetrate > 1) && !projectile.minion) || projectile.type == ModContent.ProjectileType()) { @@ -2369,7 +2430,14 @@ namespace CalamityMod.NPCs damage = (int)(damage * 0.25); } } - else if (npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsBody || npc.type == NPCID.EaterofWorldsTail || npc.type == NPCID.Creeper) + else if (AquaticScourgeIDs.Contains(npc.type)) + { + if ((projectile.penetrate == -1 || projectile.penetrate > 1) && !projectile.minion) + { + damage = (int)(damage * 0.5); + } + } + else if (EaterofWorldsIDs.Contains(npc.type) || npc.type == NPCID.Creeper) { if ((projectile.penetrate == -1 || projectile.penetrate > 1) && !projectile.minion) { From 9720009902f19fe189856f5bf1210bab4463a007 Mon Sep 17 00:00:00 2001 From: Shucks Date: Thu, 14 Nov 2019 23:13:12 -0600 Subject: [PATCH 4/5] Bouncing Betty with added gunpowder --- Items/Weapons/Rogue/BouncingBetty.cs | 8 +- Projectiles/Rogue/BettyExplosion.cs | 95 +++++++++++++++++++ Projectiles/Rogue/BettyExplosion.png | Bin 0 -> 148 bytes Projectiles/Rogue/BouncingBettyProjectile.cs | 46 ++++----- 4 files changed, 123 insertions(+), 26 deletions(-) create mode 100644 Projectiles/Rogue/BettyExplosion.cs create mode 100644 Projectiles/Rogue/BettyExplosion.png diff --git a/Items/Weapons/Rogue/BouncingBetty.cs b/Items/Weapons/Rogue/BouncingBetty.cs index 233d76c3d0..3972c1f479 100644 --- a/Items/Weapons/Rogue/BouncingBetty.cs +++ b/Items/Weapons/Rogue/BouncingBetty.cs @@ -7,7 +7,7 @@ namespace CalamityMod.Items.Weapons.Rogue { public class BouncingBetty : RogueWeapon { - public const int BaseDamage = 34; + public const int BaseDamage = 52; public override void SetStaticDefaults() { DisplayName.SetDefault("Bouncing Betty"); @@ -21,8 +21,8 @@ namespace CalamityMod.Items.Weapons.Rogue item.noMelee = true; item.consumable = true; item.noUseGraphic = true; - item.useAnimation = 12; - item.useTime = 12; + item.useAnimation = 24; + item.useTime = 24; item.useStyle = ItemUseStyleID.SwingThrow; item.knockBack = 3f; item.UseSound = SoundID.Item1; @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.value = Item.buyPrice(0, 0, 4, 0); item.rare = 5; item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 15f; + item.shootSpeed = 16f; item.Calamity().rogue = true; } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) diff --git a/Projectiles/Rogue/BettyExplosion.cs b/Projectiles/Rogue/BettyExplosion.cs new file mode 100644 index 0000000000..dc3b929959 --- /dev/null +++ b/Projectiles/Rogue/BettyExplosion.cs @@ -0,0 +1,95 @@ +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Projectiles.Rogue +{ + public class BettyExplosion : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Betty Explosion"); + } + + public override void SetDefaults() + { + projectile.width = 75; + projectile.height = 75; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.timeLeft = 20; + projectile.Calamity().rogue = true; + } + + public override void AI() + { + if (projectile.ai[0] == 0f) + SpawnExplosionDust(); + if (projectile.ai[0] <= 1f) + projectile.ai[0]++; + } + + void SpawnExplosionDust() + { + // Sparks and such + Vector2 corner = new Vector2(projectile.position.X, projectile.position.Y); + for (int i = 0; i < 15; i++) + { + int idx = Dust.NewDust(corner, projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); + Main.dust[idx].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[idx].scale = 0.5f; + Main.dust[idx].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int i = 0; i < 25; i++) + { + int idx = Dust.NewDust(corner, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity *= 5f; + idx = Dust.NewDust(corner, projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); + Main.dust[idx].velocity *= 2f; + } + + // Smoke, which counts as a Gore + Vector2 goreVec = new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f); + for (int i = 0; i < 3; i++) + { + float smokeScale = 0.33f; + if (i == 1) + { + smokeScale = 0.66f; + } + if (i == 2) + { + smokeScale = 1f; + } + int idx = Gore.NewGore(goreVec, default, Main.rand.Next(61, 64), 1f); + Main.gore[idx].velocity *= smokeScale; + Main.gore[idx].velocity.X += 1f; + Main.gore[idx].velocity.Y += 1f; + + idx = Gore.NewGore(goreVec, default, Main.rand.Next(61, 64), 1f); + Main.gore[idx].velocity *= smokeScale; + Main.gore[idx].velocity.X -= 1f; + Main.gore[idx].velocity.Y += 1f; + + idx = Gore.NewGore(goreVec, default, Main.rand.Next(61, 64), 1f); + Main.gore[idx].velocity *= smokeScale; + Main.gore[idx].velocity.X += 1f; + Main.gore[idx].velocity.Y -= 1f; + + idx = Gore.NewGore(goreVec, default, Main.rand.Next(61, 64), 1f); + Main.gore[idx].velocity *= smokeScale; + Main.gore[idx].velocity.X -= 1f; + Main.gore[idx].velocity.Y -= 1f; + } + } + + } +} diff --git a/Projectiles/Rogue/BettyExplosion.png b/Projectiles/Rogue/BettyExplosion.png new file mode 100644 index 0000000000000000000000000000000000000000..983260eb072b8727c0a51e9d46e9d6a08bc460b1 GIT binary patch literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VTavfC3&Vd9T(EcfWS|IVfk$L9 z0|Vb-5N14{zaj-F$X?><>&pIsor6J7WfsE<1)z|kr;B5V#p&cf|Nq-Fn=%SBPd&Jz maWPw;lttEq6^+hE9T+mXnN^!s2qgd&GkCiCxvX bool stealthS = projectile.Calamity().stealthStrike; - int projectileCount = 2; + Projectile.NewProjectile(projectile.Center, new Vector2(0f, 0f), ModContent.ProjectileType(), projectile.damage, 8f, projectile.owner); if (stealthS) { - projectileCount += 2; - } - for (int i = 0; i < projectileCount; i++) - { - if (Main.rand.NextBool(4)) + int projectileCount = 12; + for (int i = 0; i < projectileCount; i++) { - Vector2 shrapnelVelocity = (Vector2.UnitY * (-16f + Main.rand.NextFloat(-7, 4f))).RotatedByRandom((double)MathHelper.ToRadians(30f)); - Projectile.NewProjectile(projectile.Center, projectile.velocity + shrapnelVelocity, - ModContent.ProjectileType(), BouncingBetty.BaseDamage, 3f, projectile.owner); - } - else - { - Vector2 fireVelocity = (Vector2.UnitY * (-16f + Main.rand.NextFloat(-7, 4f))).RotatedByRandom((double)MathHelper.ToRadians(40f)); - int fireIndex = Projectile.NewProjectile(projectile.Center, projectile.velocity + fireVelocity, - Main.rand.Next(ProjectileID.MolotovFire, ProjectileID.MolotovFire3 + 1), - BlastBarrel.BaseDamage, 1f, projectile.owner); - Main.projectile[fireIndex].thrown = false; - Main.projectile[fireIndex].Calamity().forceRogue = true; - Main.projectile[fireIndex].penetrate = -1; - Main.projectile[fireIndex].usesLocalNPCImmunity = true; - Main.projectile[fireIndex].localNPCHitCooldown = 9; - Main.projectile[fireIndex].timeLeft = 120; + if (Main.rand.NextBool(2)) + { + Vector2 shrapnelVelocity = (Vector2.UnitY * (-6f + Main.rand.NextFloat(-6f, 2f))).RotatedByRandom((double)MathHelper.ToRadians(30f)); + Projectile.NewProjectile(projectile.Center, projectile.velocity + shrapnelVelocity, + ModContent.ProjectileType(),(int)(projectile.damage * 0.5f), 3f, projectile.owner); + } + else + { + Vector2 fireVelocity = (Vector2.UnitY * (-6f + Main.rand.NextFloat(-6f, 2f))).RotatedByRandom((double)MathHelper.ToRadians(40f)); + int fireIndex = Projectile.NewProjectile(projectile.Center, projectile.velocity + fireVelocity, + Main.rand.Next(ProjectileID.MolotovFire, ProjectileID.MolotovFire3 + 1), + (int)(projectile.damage * 0.6f), 1f, projectile.owner); + Main.projectile[fireIndex].thrown = false; + Main.projectile[fireIndex].Calamity().forceRogue = true; + Main.projectile[fireIndex].penetrate = -1; + Main.projectile[fireIndex].usesLocalNPCImmunity = true; + Main.projectile[fireIndex].localNPCHitCooldown = 9; + Main.projectile[fireIndex].timeLeft = 240; + } } } } @@ -71,6 +71,8 @@ namespace CalamityMod.Projectiles.Rogue else { projectile.velocity.Y += 0.4f; + if (projectile.velocity.Y > 16f) + projectile.velocity.Y = 16f; } } public override bool OnTileCollide(Vector2 oldVelocity) From 305f85bcdf1d69f55d39268ef85bbbd9cd199792 Mon Sep 17 00:00:00 2001 From: Shucks Date: Fri, 15 Nov 2019 22:24:54 -0600 Subject: [PATCH 5/5] Brick, gale, francisca and tomahawks --- Items/Weapons/Rogue/ThrowingBrick.cs | 2 +- Projectiles/Ranged/ExoMark.cs | 3 ++- Projectiles/Ranged/ExoTornado.cs | 6 +++--- Projectiles/Ranged/GreenExoArrow.cs | 2 +- Projectiles/Rogue/IronFranciscaProj.cs | 2 +- Projectiles/Rogue/LeadTomahawkProj.cs | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Items/Weapons/Rogue/ThrowingBrick.cs b/Items/Weapons/Rogue/ThrowingBrick.cs index f17b9f744a..d36ccd353f 100644 --- a/Items/Weapons/Rogue/ThrowingBrick.cs +++ b/Items/Weapons/Rogue/ThrowingBrick.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Rogue } public override void SafeSetDefaults() { - item.damage = 20; + item.damage = 14; item.shootSpeed = 12f; item.shoot = ModContent.ProjectileType(); item.width = 26; diff --git a/Projectiles/Ranged/ExoMark.cs b/Projectiles/Ranged/ExoMark.cs index f91bffe09a..64f2ab223c 100644 --- a/Projectiles/Ranged/ExoMark.cs +++ b/Projectiles/Ranged/ExoMark.cs @@ -22,7 +22,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.alpha = 255; projectile.penetrate = -1; - projectile.localNPCHitCooldown = 5; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 7; } public override void AI() diff --git a/Projectiles/Ranged/ExoTornado.cs b/Projectiles/Ranged/ExoTornado.cs index ddd7139b3b..da41d4484f 100644 --- a/Projectiles/Ranged/ExoTornado.cs +++ b/Projectiles/Ranged/ExoTornado.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = -1; projectile.timeLeft = 240; //1200 projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 6; + projectile.localNPCHitCooldown = 8; } public override void AI() @@ -134,7 +134,7 @@ namespace CalamityMod.Projectiles.Ranged Color color39 = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, value34, num237 * 2f); if (num237 > 0.5f) { - color39 = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, value34, 2f - num237 * 2f); + color39 = Microsoft.Xna.Framework.Color.Lerp(Microsoft.Xna.Framework.Color.Transparent, value34, 2f - num237 * 2f ); } color39.A = (byte)((float)color39.A * 0.5f); color39 *= scale5; @@ -142,7 +142,7 @@ namespace CalamityMod.Projectiles.Ranged vector34.Y = 0f; vector34.X = 0f; vector34 += new Vector2(value33.X, num236) - Main.screenPosition; - Main.spriteBatch.Draw(texture2D23, vector34, new Microsoft.Xna.Framework.Rectangle?(rectangle9), color39, num233 + num238, origin3, 1f + num239, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(texture2D23, vector34, new Microsoft.Xna.Framework.Rectangle?(rectangle9), color39, num233 + num238, origin3, 1f + num239, SpriteEffects.None , 0f); } return false; } diff --git a/Projectiles/Ranged/GreenExoArrow.cs b/Projectiles/Ranged/GreenExoArrow.cs index acd7ddb664..728ea976a9 100644 --- a/Projectiles/Ranged/GreenExoArrow.cs +++ b/Projectiles/Ranged/GreenExoArrow.cs @@ -111,7 +111,7 @@ namespace CalamityMod.Projectiles.Ranged { if (projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.6f), projectile.knockBack, projectile.owner, 0f, 0f); } } } diff --git a/Projectiles/Rogue/IronFranciscaProj.cs b/Projectiles/Rogue/IronFranciscaProj.cs index 59b2df4c85..30796da0f2 100644 --- a/Projectiles/Rogue/IronFranciscaProj.cs +++ b/Projectiles/Rogue/IronFranciscaProj.cs @@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - if (Main.rand.Next(2) == 0) + if (Main.rand.Next(4) == 0) { Item.NewItem((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height, ModContent.ItemType()); } diff --git a/Projectiles/Rogue/LeadTomahawkProj.cs b/Projectiles/Rogue/LeadTomahawkProj.cs index 2ed2502c62..0a166c0685 100644 --- a/Projectiles/Rogue/LeadTomahawkProj.cs +++ b/Projectiles/Rogue/LeadTomahawkProj.cs @@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { - if (Main.rand.Next(2) == 0) + if (Main.rand.Next(4) == 0) { Item.NewItem((int)projectile.position.X, (int)projectile.position.Y, projectile.width, projectile.height, ModContent.ItemType()); }