diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 6cf4a85e61..a49ee4d783 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -319,6 +319,7 @@ namespace CalamityMod.CalPlayer public bool eGauntlet = false; public bool eTalisman = false; public bool statisBeltOfCurses = false; + public bool conceptionApparatus = false; public bool elysianAegis = false; public bool elysianGuard = false; public bool nCore = false; @@ -1237,6 +1238,7 @@ namespace CalamityMod.CalPlayer eGauntlet = false; eTalisman = false; statisBeltOfCurses = false; + conceptionApparatus = false; heartOfDarkness = false; shadowMinions = false; tearMinions = false; diff --git a/Items/Accessories/ConceptionApparatus.cs b/Items/Accessories/ConceptionApparatus.cs new file mode 100644 index 0000000000..2d82f92015 --- /dev/null +++ b/Items/Accessories/ConceptionApparatus.cs @@ -0,0 +1,55 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + public class ConceptionApparatus : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Conception Apparatus"); + Tooltip.SetDefault("Increased max minions by 4 and 15% increased minion damage\n" + + "Increased minion knockback\n" + + "Minions inflict a variety of debuffs\n" + + "Minion attacks have a chance to instantly kill normal enemies"); + } + + public override void SetDefaults() + { + item.width = 28; + item.height = 32; + item.value = Item.buyPrice(0, 90, 0, 0); + item.accessory = true; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.conceptionApparatus = true; + modPlayer.shadowMinions = true; //shadowflame + modPlayer.tearMinions = true; //temporal sadness + modPlayer.voltaicJelly = true; //electrified + modPlayer.starTaintedGenerator = true; //astral infection + player.minionKB += 2.5f; + player.minionDamage += 0.15f; + player.maxMinions += 4; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Accessories/ConceptionApparatus.png b/Items/Accessories/ConceptionApparatus.png new file mode 100644 index 0000000000..1ba42b2a88 Binary files /dev/null and b/Items/Accessories/ConceptionApparatus.png differ diff --git a/Items/Accessories/StatisBeltOfCurses.cs b/Items/Accessories/StatisBeltOfCurses.cs index d1c602b8aa..6ce7232ffa 100644 --- a/Items/Accessories/StatisBeltOfCurses.cs +++ b/Items/Accessories/StatisBeltOfCurses.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories @@ -13,13 +14,6 @@ namespace CalamityMod.Items.Accessories DisplayName.SetDefault("Statis' Belt of Curses"); Tooltip.SetDefault("Increases jump speed and allows constant jumping\n" + "Can climb walls, dash, and dodge attacks\n" + - "10% increased rogue damage and velocity\n" + - "5% increased rogue crit chance\n" + - "Increased max minions by 3 and 10% increased minion damage\n" + - "Increased minion knockback\n" + - "Grants shadowflame powers to all minions\n" + - "Minions make enemies cry on hit\n" + - "Minion attacks have a chance to instantly kill normal enemies\n" + "Toggle visibility of this accessory to enable/disable the dash"); } @@ -27,20 +21,14 @@ namespace CalamityMod.Items.Accessories { item.width = 28; item.height = 32; - item.value = Item.buyPrice(0, 90, 0, 0); + item.value = Item.buyPrice(0, 80, 0, 0); item.accessory = true; - item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.Calamity().postMoonLordRarity = 13; } public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.statisBeltOfCurses = true; - modPlayer.shadowMinions = true; - modPlayer.tearMinions = true; - player.minionKB += 2.5f; - player.minionDamage += 0.1f; - player.maxMinions += 3; player.autoJump = true; player.jumpSpeedBoost += 1.2f; player.extraFall += 50; @@ -48,20 +36,14 @@ namespace CalamityMod.Items.Accessories if (!hideVisual) player.dash = 1; player.spikedBoots = 2; - player.Calamity().throwingDamage += 0.1f; - player.Calamity().throwingCrit += 5; - player.Calamity().throwingVelocity += 0.1f; } public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 20); - recipe.AddIngredient(ModContent.ItemType(), 20); - recipe.AddIngredient(ModContent.ItemType(), 20); - recipe.AddTile(ModContent.TileType()); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index e84911018e..5dc10ec2c2 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -3459,7 +3459,7 @@ namespace CalamityMod.NPCs } } - if (modPlayer.statisBeltOfCurses) + if (modPlayer.conceptionApparatus) { if ((projectile.minion || CalamityMod.projectileMinionList.Contains(projectile.type)) && ShouldAffectNPC(npc) && !projectile.npcProj && Main.rand.NextBool(15)) { diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 694862085f..0f003e5a2f 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -1207,6 +1207,8 @@ namespace CalamityMod.Projectiles Main.dust[num195].noGravity = true; } projectile.damage *= modPlayer.auricSet ? 7 : 4; + projectile.localNPCHitCooldown = 10; + projectile.usesLocalNPCImmunity = true; projectile.Damage(); } @@ -1265,52 +1267,7 @@ namespace CalamityMod.Projectiles } else if (modPlayer.ataxiaMage && modPlayer.ataxiaDmg <= 0) { - int num = projectile.damage / 2; - modPlayer.ataxiaDmg += (float)num; - int[] array = new int[Main.maxNPCs]; - int num3 = 0; - int num4 = 0; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].CanBeChasedBy(projectile, false)) - { - float num5 = Math.Abs(Main.npc[i].position.X + (float)(Main.npc[i].width / 2) - projectile.position.X + (float)(projectile.width / 2)) + Math.Abs(Main.npc[i].position.Y + (float)(Main.npc[i].height / 2) - projectile.position.Y + (float)(projectile.height / 2)); - if (num5 < 800f) - { - if (Collision.CanHit(projectile.position, 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height) && num5 > 50f) - { - array[num4] = i; - num4++; - } - else if (num4 == 0) - { - array[num3] = i; - num3++; - } - } - } - } - if (num3 == 0 && num4 == 0) - { - return; - } - int num6; - if (num4 > 0) - { - num6 = array[Main.rand.Next(num4)]; - } - else - { - num6 = array[Main.rand.Next(num3)]; - } - float num7 = 20f; - float num8 = (float)Main.rand.Next(-100, 101); - float num9 = (float)Main.rand.Next(-100, 101); - float num10 = (float)Math.Sqrt((double)(num8 * num8 + num9 * num9)); - num10 = num7 / num10; - num8 *= num10; - num9 *= num10; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, num8, num9, ModContent.ProjectileType(), (int)((double)num * 1.25), 0f, projectile.owner, (float)num6, 0f); + SpawnOrb(projectile, modPlayer.ataxiaDmg, 0.5f, 1.25f, ModContent.ProjectileType(), 800f, 20f); if (target.canGhostHeal) { if (Main.player[Main.myPlayer].lifeSteal <= 0f) @@ -1348,60 +1305,14 @@ namespace CalamityMod.Projectiles } else if (modPlayer.godSlayerMage && modPlayer.godSlayerDmg <= 0) { - int num = projectile.damage / 2; - modPlayer.godSlayerDmg += (float)num; - int[] array = new int[Main.maxNPCs]; - int num3 = 0; - int num4 = 0; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].CanBeChasedBy(projectile, false)) - { - float num5 = Math.Abs(Main.npc[i].position.X + (float)(Main.npc[i].width / 2) - projectile.position.X + (float)(projectile.width / 2)) + Math.Abs(Main.npc[i].position.Y + (float)(Main.npc[i].height / 2) - projectile.position.Y + (float)(projectile.height / 2)); - if (num5 < 800f) - { - if (Collision.CanHit(projectile.position, 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height) && num5 > 50f) - { - array[num4] = i; - num4++; - } - else if (num4 == 0) - { - array[num3] = i; - num3++; - } - } - } - } - if (num3 == 0 && num4 == 0) - { - return; - } - int num6; - if (num4 > 0) - { - num6 = array[Main.rand.Next(num4)]; - } - else - { - num6 = array[Main.rand.Next(num3)]; - } - float num7 = 20f; - float num8 = (float)Main.rand.Next(-100, 101); - float num9 = (float)Main.rand.Next(-100, 101); - float num10 = (float)Math.Sqrt((double)(num8 * num8 + num9 * num9)); - num10 = num7 / num10; - num8 *= num10; - num9 *= num10; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, num8, num9, ModContent.ProjectileType(), - (int)((double)num * (modPlayer.auricSet ? 2.0 : 1.5)), 0f, projectile.owner, (float)num6, 0f); + SpawnOrb(projectile, modPlayer.godSlayerDmg, 0.5f, modPlayer.auricSet ? 2f : 1.5f, ModContent.ProjectileType(), 800f, 20f); if (target.canGhostHeal) { if (Main.player[Main.myPlayer].lifeSteal <= 0f) { return; } - float num11 = Main.player[projectile.owner].Calamity().auricSet ? 0.03f : 0.06f; //0.2 + float num11 = modPlayer.auricSet ? 0.03f : 0.06f; //0.2 num11 -= (float)projectile.numHits * 0.015f; //0.05 if (num11 <= 0f) { @@ -1449,101 +1360,11 @@ namespace CalamityMod.Projectiles { if (Main.rand.NextBool(5)) { - int num = projectile.damage / 2; - modPlayer.xerocDmg += (float)num; - int[] array = new int[Main.maxNPCs]; - int num3 = 0; - int num4 = 0; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].CanBeChasedBy(projectile, false)) - { - float num5 = Math.Abs(Main.npc[i].position.X + (float)(Main.npc[i].width / 2) - projectile.position.X + (float)(projectile.width / 2)) + Math.Abs(Main.npc[i].position.Y + (float)(Main.npc[i].height / 2) - projectile.position.Y + (float)(projectile.height / 2)); - if (num5 < 800f) - { - if (Collision.CanHit(projectile.position, 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height) && num5 > 50f) - { - array[num4] = i; - num4++; - } - else if (num4 == 0) - { - array[num3] = i; - num3++; - } - } - } - } - if (num3 == 0 && num4 == 0) - { - return; - } - int num6; - if (num4 > 0) - { - num6 = array[Main.rand.Next(num4)]; - } - else - { - num6 = array[Main.rand.Next(num3)]; - } - float num7 = Main.rand.Next(15, 30); - float num8 = (float)Main.rand.Next(-100, 101); - float num9 = (float)Main.rand.Next(-100, 101); - float num10 = (float)Math.Sqrt((double)(num8 * num8 + num9 * num9)); - num10 = num7 / num10; - num8 *= num10; - num9 *= num10; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, num8, num9, ModContent.ProjectileType(), (int)((double)num * 1.6), 0f, projectile.owner, (float)num6, 0f); + SpawnOrb(projectile, modPlayer.xerocDmg, 0.5f, 1.6f, ModContent.ProjectileType(), 800f, Main.rand.Next(15, 30)); } else if (Main.rand.NextBool(4)) { - int num = projectile.damage / 2; - modPlayer.xerocDmg += (float)num; - int[] array = new int[Main.maxNPCs]; - int num3 = 0; - int num4 = 0; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].CanBeChasedBy(projectile, false)) - { - float num5 = Math.Abs(Main.npc[i].position.X + (float)(Main.npc[i].width / 2) - projectile.position.X + (float)(projectile.width / 2)) + Math.Abs(Main.npc[i].position.Y + (float)(Main.npc[i].height / 2) - projectile.position.Y + (float)(projectile.height / 2)); - if (num5 < 800f) - { - if (Collision.CanHit(projectile.position, 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height) && num5 > 50f) - { - array[num4] = i; - num4++; - } - else if (num4 == 0) - { - array[num3] = i; - num3++; - } - } - } - } - if (num3 == 0 && num4 == 0) - { - return; - } - int num6; - if (num4 > 0) - { - num6 = array[Main.rand.Next(num4)]; - } - else - { - num6 = array[Main.rand.Next(num3)]; - } - float num7 = 30f; - float num8 = (float)Main.rand.Next(-100, 101); - float num9 = (float)Main.rand.Next(-100, 101); - float num10 = (float)Math.Sqrt((double)(num8 * num8 + num9 * num9)); - num10 = num7 / num10; - num8 *= num10; - num9 *= num10; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, num8, num9, ModContent.ProjectileType(), (int)((double)num * 1.25), 0f, projectile.owner, (float)num6, 0f); + SpawnOrb(projectile, modPlayer.xerocDmg, 0.5f, 1.25f, ModContent.ProjectileType(), 800f, 30f); if (target.canGhostHeal) { if (Main.player[Main.myPlayer].lifeSteal <= 0f) @@ -1599,52 +1420,7 @@ namespace CalamityMod.Projectiles } else { - int num = projectile.damage / 2; - modPlayer.xerocDmg += (float)num; - int[] array = new int[Main.maxNPCs]; - int num3 = 0; - int num4 = 0; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].CanBeChasedBy(projectile, false)) - { - float num5 = Math.Abs(Main.npc[i].position.X + (float)(Main.npc[i].width / 2) - projectile.position.X + (float)(projectile.width / 2)) + Math.Abs(Main.npc[i].position.Y + (float)(Main.npc[i].height / 2) - projectile.position.Y + (float)(projectile.height / 2)); - if (num5 < 800f) - { - if (Collision.CanHit(projectile.position, 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height) && num5 > 50f) - { - array[num4] = i; - num4++; - } - else if (num4 == 0) - { - array[num3] = i; - num3++; - } - } - } - } - if (num3 == 0 && num4 == 0) - { - return; - } - int num6; - if (num4 > 0) - { - num6 = array[Main.rand.Next(num4)]; - } - else - { - num6 = array[Main.rand.Next(num3)]; - } - float num7 = 15f; - float num8 = (float)Main.rand.Next(-100, 101); - float num9 = (float)Main.rand.Next(-100, 101); - float num10 = (float)Math.Sqrt((double)(num8 * num8 + num9 * num9)); - num10 = num7 / num10; - num8 *= num10; - num9 *= num10; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, num8, num9, ModContent.ProjectileType(), (int)((double)num * 1.2), 0f, projectile.owner, (float)num6, 0f); + SpawnOrb(projectile, modPlayer.xerocDmg, 0.5f, 1.2f, ModContent.ProjectileType(), 800f, 15f); } } if (modPlayer.featherCrown && stealthStrike && modPlayer.featherCrownCooldown <= 0) @@ -1705,69 +1481,21 @@ namespace CalamityMod.Projectiles target.AddBuff(BuffID.ShadowFlame, 300); } - if (modPlayer.voltaicJelly && Main.rand.NextBool(5)) - { - target.AddBuff(BuffID.Electrified, 60); - } + if (modPlayer.voltaicJelly) + { + //100% chance for Star Tainted Generator or Conception Apparatus + //20% chance for Voltaic Jelly + if (Main.rand.NextBool(modPlayer.starTaintedGenerator ? 1 : 5)) + { + target.AddBuff(BuffID.Electrified, 60); + } + } if (modPlayer.starTaintedGenerator) { target.AddBuff(ModContent.BuffType(), 180); } - if (modPlayer.jellyChargedBattery) - { - if (modPlayer.jellyDmg <= 0) - { - int num = projectile.damage / 2; - modPlayer.jellyDmg += (float)num; - int[] array = new int[Main.maxNPCs]; - int num3 = 0; - int num4 = 0; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].CanBeChasedBy(projectile, false)) - { - float num5 = Math.Abs(Main.npc[i].position.X + (float)(Main.npc[i].width / 2) - projectile.position.X + (float)(projectile.width / 2)) + Math.Abs(Main.npc[i].position.Y + (float)(Main.npc[i].height / 2) - projectile.position.Y + (float)(projectile.height / 2)); - if (num5 < 800f) - { - if (Collision.CanHit(projectile.position, 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height) && num5 > 50f) - { - array[num4] = i; - num4++; - } - else if (num4 == 0) - { - array[num3] = i; - num3++; - } - } - } - } - if (num3 == 0 && num4 == 0) - { - return; - } - int num6; - if (num4 > 0) - { - num6 = array[Main.rand.Next(num4)]; - } - else - { - num6 = array[Main.rand.Next(num3)]; - } - float num7 = 15f; - float num8 = (float)Main.rand.Next(-100, 101); - float num9 = (float)Main.rand.Next(-100, 101); - float num10 = (float)Math.Sqrt((double)(num8 * num8 + num9 * num9)); - num10 = num7 / num10; - num8 *= num10; - num9 *= num10; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, num8, num9, ModContent.ProjectileType(), (int)((double)num * 1.05), 0f, projectile.owner, (float)num6, 0f); - } - } - // Fearmonger set's colossal life regeneration if(modPlayer.fearmongerSet) { @@ -1778,60 +1506,46 @@ namespace CalamityMod.Projectiles if (modPlayer.godSlayerSummon && modPlayer.godSlayerDmg <= 0) { - int num = projectile.damage / 2; - float ai1 = Main.rand.NextFloat() + 0.5f; - modPlayer.godSlayerDmg += (float)num; - int[] array = new int[Main.maxNPCs]; - int num3 = 0; - int num4 = 0; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].CanBeChasedBy(projectile, false)) - { - float num5 = Math.Abs(Main.npc[i].position.X + (float)(Main.npc[i].width / 2) - projectile.position.X + (float)(projectile.width / 2)) + Math.Abs(Main.npc[i].position.Y + (float)(Main.npc[i].height / 2) - projectile.position.Y + (float)(projectile.height / 2)); - if (num5 < 800f) - { - if (Collision.CanHit(projectile.position, 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height) && num5 > 50f) - { - array[num4] = i; - num4++; - } - else if (num4 == 0) - { - array[num3] = i; - num3++; - } - } - } - } - if (num3 == 0 && num4 == 0) - { - return; - } - int num6; - if (num4 > 0) - { - num6 = array[Main.rand.Next(num4)]; - } - else - { - num6 = array[Main.rand.Next(num3)]; - } - float num7 = 15f; - float num8 = (float)Main.rand.Next(-100, 101); - float num9 = (float)Main.rand.Next(-100, 101); - float num10 = (float)Math.Sqrt((double)(num8 * num8 + num9 * num9)); - num10 = num7 / num10; - num8 *= num10; - num9 *= num10; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, num8, num9, ModContent.ProjectileType(), (int)((double)num * 2.0), 0f, projectile.owner, 0f, ai1); + SpawnOrb(projectile, modPlayer.godSlayerDmg, 0.5f, 2f, ModContent.ProjectileType(), 800f, 15f, true); } - if (modPlayer.starbusterCore && Main.rand.NextBool(3) && projectile.type != ModContent.ProjectileType() && projectile.type != ModContent.ProjectileType()) - { - int boom = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), - (int)(projectile.damage * 0.5f), 3f, projectile.owner); - } + //Conception Apparatus takes priority over Starbuster Core which takes priority over Jelly-Charged Battery + if (projectile.type != ModContent.ProjectileType() && projectile.type != ModContent.ProjectileType() && projectile.type != ModContent.ProjectileType()) + { + if (modPlayer.conceptionApparatus) + { + if (Main.rand.NextBool(4)) + { + for (int num252 = 0; num252 < 3; num252++) + { + Vector2 value15 = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); + while (value15.X == 0f && value15.Y == 0f) + { + value15 = new Vector2((float)Main.rand.Next(-50, 51), (float)Main.rand.Next(-50, 51)); + } + value15.Normalize(); + value15 *= (float)Main.rand.Next(30, 61) * 0.1f; + int spark = Projectile.NewProjectile(target.Center.X, target.Center.Y, value15.X, value15.Y, ModContent.ProjectileType(), (int)((double)damage * 0.15), 0f, player.whoAmI, 0f, 0f); + Main.projectile[spark].Calamity().forceMinion = true; + } + } + } + else if (modPlayer.starbusterCore) + { + if (Main.rand.NextBool(3)) + { + int boom = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), + (int)(projectile.damage * 0.5f), 3f, projectile.owner); + } + } + else if (modPlayer.jellyChargedBattery) + { + if (modPlayer.jellyDmg <= 0) + { + SpawnOrb(projectile, modPlayer.jellyDmg, 0.5f, 1.05f, ModContent.ProjectileType(), 800f, 15f); + } + } + } } if (projectile.ranged) @@ -2062,7 +1776,61 @@ namespace CalamityMod.Projectiles } #endregion - #region Homing AI + #region AI Shortcuts + public void SpawnOrb(Projectile projectile, float timer, float counterMult, float dmgMult, int projType, float distanceRequired, float N, bool gsPhantom = false) + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + + int num = (int)(projectile.damage * counterMult); + float ai1 = Main.rand.NextFloat() + 0.5f; + timer += (float)num; + int[] array = new int[Main.maxNPCs]; + int num3 = 0; + int num4 = 0; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(projectile, false)) + { + float num5 = Math.Abs(Main.npc[i].position.X + (float)(Main.npc[i].width / 2) - projectile.position.X + (float)(projectile.width / 2)) + Math.Abs(Main.npc[i].position.Y + (float)(Main.npc[i].height / 2) - projectile.position.Y + (float)(projectile.height / 2)); + if (num5 < distanceRequired) + { + if (Collision.CanHit(projectile.position, 1, 1, Main.npc[i].position, Main.npc[i].width, Main.npc[i].height) && num5 > 50f) + { + array[num4] = i; + num4++; + } + else if (num4 == 0) + { + array[num3] = i; + num3++; + } + } + } + } + if (num3 == 0 && num4 == 0) + { + return; + } + int num6; + if (num4 > 0) + { + num6 = array[Main.rand.Next(num4)]; + } + else + { + num6 = array[Main.rand.Next(num3)]; + } + float num7 = N; + float num8 = (float)Main.rand.Next(-100, 101); + float num9 = (float)Main.rand.Next(-100, 101); + float num10 = (float)Math.Sqrt((double)(num8 * num8 + num9 * num9)); + num10 = num7 / num10; + num8 *= num10; + num9 *= num10; + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, num8, num9, projType, (int)(num * dmgMult), 0f, projectile.owner, gsPhantom ? 0f : (float)num6, gsPhantom ? ai1 : 0f); + } + public static void HomeInOnNPC(Projectile projectile, bool ignoreTiles, float distanceRequired, float homingVelocity, float N) { Vector2 center = projectile.Center; @@ -2161,9 +1929,7 @@ namespace CalamityMod.Projectiles } } } - #endregion - #region Floating Pet AI public static void FloatingPetAI(Projectile projectile, bool lightPet = false, bool faceRight = false, float tiltFloat = 0.05f) { Player player = Main.player[projectile.owner];